🔎 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
constvalue=1;export{valueas"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
constvalue=1;export{valueas"an export"};main.mjs
import*aslibfrom"./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.
🔎 Search Terms
"export as", "string literal"
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.3.0-dev.20231023#code/MYewdgzgLgBAbgQwDYFcCmMC8MCMBuAKDQA8AHEAJ1gG95l0YEIYAiBMGE8qlmAXzxA
💻 Code
🙁 Actual behavior
🙂 Expected behavior
It should compile correctly and emit a parseable
.d.tsif configured in the project's settings.See plain JavaScript example:
lib.mjs
main.mjs
node main.mjs
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
It seems like an exotic request but has benefits for CSS modules which export classes as named exports.