-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
DuplicateAn existing issue was already createdAn existing issue was already createdFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Description
🔍 Search Terms
export string name literal
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
JavaScript allows exporting and importing names that are string literals and not just identifiers. This is for compatibility with future non-JS modules types that might not have the same restrictions on export names, like WASM, CSS, HTML, etc.
See https://tc39.es/ecma262/multipage/ecmascript-language-scripts-and-modules.html#prod-ModuleExportName
📃 Motivating Example
import {'product-card' as productCard} from './product.html` with {type: 'html'};
import {'fast-inverse-square-root' as fastInverseSquareRoot} from 'carmack.wasm';💻 Use Cases
-
What do you want to use this for?
Importing from non-JS modules and defining types for non-JS modules -
What shortcomings exist with current approaches?
You can't do either of the above -
What workarounds are you using in the meantime?
None?
bivens-dev
Metadata
Metadata
Assignees
Labels
DuplicateAn existing issue was already createdAn existing issue was already createdFix AvailableA PR has been opened for this issueA PR has been opened for this issue