-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Support ES6 syntax for Import statements #1203
Comments
ES6 Imported bindings are 'mutable', meaning that the module exporting the binding can update the value at any time, and any consumers of the module should have the new value. The downlevel syntax below creates new identifiers that copy the value of the export, which would break that assumption. A better way might be:
Keeping a reference to the imported module and always pointing to the actual export binding ensures this works as expected. Sent from my Windows Phone From: Sheetal Nandimailto:notifications@github.com As per ES6 grammer ImportDeclaration : ImportClause : ImportedDefaultBinding : NameSpaceImport :
NamedImports : FromClause : ImportsList : ImportSpecifier : ModuleSpecifier : ImportedBinding : Downlevel emit and meaning of each import syntax: import BindingIdentifier from StringLiteral import * as BindingIdentifier from StringLiteral import { } from StringLiteral import { ImportedBinding1, … } from StringLiteral import { IdentifierName1 as ImportedBinding1, … } from StringLiteral import BindingIdentifier1, * as BindingIdentifier2 from StringLiteral Import BindingIdentifier1, { ImportedBinding2, IdentifierName1 as ImportedBinding3, … } from StringLiteral In all cases, the import syntax when the import syntax is specified it has exactly the meaning of commented code. The import bindings will have exact same meaning as that of declaration it binds to and there will be no emit if the binding corresponds to type or uninitialized module — |
According to spec section 8.1.1.5.3 the import bindings are immutable:
|
But in example
b.ts
a should result in dynamic value of a so we would need to emit the _tmp.Idenfitier kind of bindings. Agreed. But it should also be error to do a = someexpression |
Agreed. The bindings are only mutable on the export side |
As per ES6 grammer
Downlevel emit and meaning of each import syntax:
In all cases, the import syntax when the import syntax is specified it has exactly the meaning of commented code. The import bindings will have exact same meaning as that of declaration it binds to and there will be no emit if the binding corresponds to type or uninitialized module
The text was updated successfully, but these errors were encountered: