Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportSpecifier.propertyName should allow string literals #49147

Closed
Josh-Cena opened this issue May 17, 2022 · 2 comments Β· Fixed by #58640
Closed

ImportSpecifier.propertyName should allow string literals #49147

Josh-Cena opened this issue May 17, 2022 · 2 comments Β· Fixed by #58640
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Help Wanted You can do this
Milestone

Comments

@Josh-Cena
Copy link
Contributor

Josh-Cena commented May 17, 2022

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" };
@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this labels May 20, 2022
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone May 20, 2022
@Josh-Cena
Copy link
Contributor Author

I'm self-claiming this because no-one seems to be working on it at the moment. It's much more non-trivial than I thought, so if I failed to prepare a PR by this weekend I can be seen as automatically stepping out.

@Josh-Cena
Copy link
Contributor Author

Duplicate of #40594 it seems πŸ€”

@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants