Skip to content
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

Merged
merged 34 commits into from
Mar 17, 2015
Merged

ES6 emit for new import / export syntax #2335

merged 34 commits into from
Mar 17, 2015

Conversation

mhegazy
Copy link
Contributor

@mhegazy mhegazy commented Mar 13, 2015

This is mostly @sheetalkamat's work in #2065, just bringing it up to date and adding implementation for export default.

Notes:

  • Emitting class in ES6 is in tracked in Class emit for ES6 #2333, and i will merge with that and fix the class baselines
  • Emitting declarations is not done yet, so declaration files in baselines are not correct.

mhegazy and others added 22 commits March 11, 2015 21:40
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);
Copy link
Contributor

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).

Copy link
Contributor Author

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.

mhegazy added 5 commits March 15, 2015 15:48
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);
Copy link
Contributor

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)

return "exports." + unescapeIdentifier(symbol.name);
var symbolName = unescapeIdentifier(symbol.name);
if (languageVersion >= ScriptTarget.ES6) {
return symbolName;
Copy link
Contributor

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+?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

mhegazy added a commit that referenced this pull request Mar 17, 2015
ES6 emit for new import / export syntax
@mhegazy mhegazy merged commit 42a0c34 into master Mar 17, 2015
@mhegazy mhegazy deleted the es6ImportExportEmit branch March 17, 2015 20:59
@mhegazy
Copy link
Contributor Author

mhegazy commented Mar 17, 2015

@csnover this is now in master the declaration emit (#2139) should follow shortly.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants