Skip to content

Support string literal export namesΒ #57017

Closed
@justinfagnani

Description

@justinfagnani

πŸ” Search Terms

export string name literal

βœ… Viability Checklist

⭐ 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

  1. What do you want to use this for?
    Importing from non-JS modules and defining types for non-JS modules

  2. What shortcomings exist with current approaches?
    You can't do either of the above

  3. What workarounds are you using in the meantime?
    None?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdFix AvailableA PR has been opened for this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions