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

Does not support export as "string literal" #56200

Closed
laverdet opened this issue Oct 24, 2023 · 2 comments Β· Fixed by #58640
Closed

Does not support export as "string literal" #56200

laverdet opened this issue Oct 24, 2023 · 2 comments Β· Fixed by #58640
Labels
Fix Available A PR has been opened for this issue

Comments

@laverdet
Copy link
Contributor

πŸ”Ž Search Terms

"export as", "string literal"

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about [syntax]

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.3.0-dev.20231023#code/MYewdgzgLgBAbgQwDYFcCmMC8MCMBuAKDQA8AHEAJ1gG95l0YEIYAiBMGE8qlmAXzxA

πŸ’» Code

const value = 1;
export { value as "an export" };

πŸ™ Actual behavior

Cannot find module 'an export' or its corresponding type declarations.(2307)

πŸ™‚ Expected behavior

It should compile correctly and emit a parseable .d.ts if configured in the project's settings.

See plain JavaScript example:

lib.mjs

const value = 1;
export { value as "an export" };

main.mjs

import * as lib from "./lib.mjs";
console.log(lib);

node main.mjs

[Module: null prototype] { 'an export': 1 }

Additional information about the issue

This fails the "TypeScript is a superset of JavaScript" assertion in the project's description.

Relevant syntax documentation can be found here:
https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export#syntax

And in the language specification, 16.2 Modules:
https://tc39.es/ecma262/#prod-ModuleExportName

[...]
ModuleExportName:
  IdentifierName
  StringLiteral

It seems like an exotic request but has benefits for CSS modules which export classes as named exports.

@MartinJohns
Copy link
Contributor

Duplicate of #40594.

@laverdet
Copy link
Contributor Author

Thanks! It didn't turn up in my queries.

@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
Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants