Skip to content

ImportSpecifier.propertyName should allow string literalsΒ #49147

Closed
@Josh-Cena

Description

@Josh-Cena

Bug Report

πŸ”Ž Search Terms

import specifier, property name, ModuleExportName, named import

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

import { "useState" as useEffect } from "react";

πŸ™ Actual behavior

Parser error

πŸ™‚ Expected behavior

This should be parsed as valid code and properly type-checked. According to ES spec, ImportSpecifier can be ModuleExportName as ImportedBinding, where ModuleExportName includes StringLiteral.

Babel parses this correctly.

Accordingly, this should be also allowed:

const a = 1;
export { a as "a-b" };

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFix AvailableA PR has been opened for this issueHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions