-
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
ES6 emit for new import / export syntax #2335
Conversation
Conflicts: src/compiler/checker.ts src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json
Conflicts: src/compiler/checker.ts tests/baselines/reference/es6ImportDefaultBinding.errors.txt tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport1.errors.txt tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt tests/cases/compiler/es6ImportNameSpaceImportMergeErrors.ts tests/cases/compiler/es6ImportNameSpaceImportNoNamedExports.ts tests/cases/compiler/es6ImportNamedImportInExportAssignment.ts tests/cases/compiler/es6ImportNamedImportInIndirectExportAssignment.ts tests/cases/compiler/es6ImportNamedImportNoNamedExports.ts
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json src/compiler/program.ts tests/baselines/reference/constDeclarations-access5.errors.txt tests/baselines/reference/es6ExportAssignment.errors.txt tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.errors.txt tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding.js tests/baselines/reference/es6ImportDefaultBindingMergeErrors.errors.txt tests/baselines/reference/es6ImportEqualsDeclaration.errors.txt tests/cases/compiler/es6ImportDefaultBinding.ts tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport.ts tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport1.ts tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.ts tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding.ts tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding1.ts tests/cases/compiler/es6ImportDefaultBindingMergeErrors.ts tests/cases/compiler/es6ImportDefaultBindingNoDefaultProperty.ts tests/cases/compiler/es6ImportNameSpaceImport.ts tests/cases/compiler/es6ImportNamedImport.ts tests/cases/compiler/es6ImportNamedImportMergeErrors.ts tests/cases/compiler/es6ImportNamedImportNoExportMember.ts tests/cases/compiler/es6ImportWithoutFromClause.ts tests/cases/compiler/es6ImportWithoutFromClauseNonInstantiatedModule.ts
Conflicts: src/compiler/emitter.ts tests/baselines/reference/es6ImportDefaultBinding.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js tests/baselines/reference/es6ImportNameSpaceImport.js tests/baselines/reference/es6ImportNamedImport.js
Conflicts: src/compiler/emitter.ts tests/baselines/reference/es6ImportDefaultBinding.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js tests/baselines/reference/es6ImportNameSpaceImport.js tests/baselines/reference/es6ImportNamedImport.js
Conflicts: tests/baselines/reference/es6ExportAll.js tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js tests/baselines/reference/es6ImportNamedImport.js
…modules Conflicts: src/compiler/checker.ts tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js tests/baselines/reference/es6ImportNamedImport.js
Conflicts: src/compiler/emitter.ts tests/baselines/reference/es6ExportAll.js tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js tests/baselines/reference/es6ImportNamedImport.js
Conflicts: src/compiler/emitter.ts tests/baselines/reference/es6ExportAll.js tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js
Conflicts: src/compiler/emitter.ts
Conflicts: src/compiler/emitter.ts
Note since we havent yet changed the emitting of class declaration to es6 format, we are just exporting the constructor function Conflicts: src/compiler/emitter.ts
Conflicts: src/compiler/emitter.ts tests/baselines/reference/es6ExportAll.js tests/baselines/reference/es6ExportClause.js tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.js
else { | ||
if (languageVersion >= ScriptTarget.ES6) { | ||
// Import equals declaration is deprecated in es6 or above | ||
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this documented with Jonathan as a breaking change? (it seems like a very big one, erroring on an entire feature if you move to ES6).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. that is the current design. we will have a blog post about moving to the new module syntax.
Conflicts: src/compiler/checker.ts src/compiler/emitter.ts src/compiler/program.ts
Conflicts: src/compiler/checker.ts src/compiler/emitter.ts tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportInEs5.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImportWithExport.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.js tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.js
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json
|
||
// ES6 import | ||
if (node.importClause) { | ||
let shouldEmitDefaultBindings = node.importClause.name && resolver.isReferencedAliasDeclaration(node.importClause); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems it should be isReferencedAliasDeclaration(node.importClause.name)
Conflicts: src/compiler/diagnosticInformationMap.generated.ts src/compiler/diagnosticMessages.json
… name of an export default class
return "exports." + unescapeIdentifier(symbol.name); | ||
var symbolName = unescapeIdentifier(symbol.name); | ||
if (languageVersion >= ScriptTarget.ES6) { | ||
return symbolName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment why we don't prefix export name with 'exports.' when emitting for ES6+?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
ES6 emit for new import / export syntax
This is mostly @sheetalkamat's work in #2065, just bringing it up to date and adding implementation for export default.
Notes: