Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22149,9 +22149,9 @@ namespace ts {
}
}
else {
if (modulekind === ModuleKind.ES2015 && !isInAmbientContext(node)) {
if (modulekind >= ModuleKind.ES2015 && !isInAmbientContext(node)) {
// Import equals declaration is deprecated in es6 or above
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
grammarErrorOnNode(node, Diagnostics.Import_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_import_d_from_mod_or_another_module_format_instead);
}
}
}
Expand Down Expand Up @@ -22187,7 +22187,7 @@ namespace ts {
error(node.moduleSpecifier, Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
}

if (modulekind !== ModuleKind.System && modulekind !== ModuleKind.ES2015) {
if (modulekind !== ModuleKind.System && modulekind !== ModuleKind.ES2015 && modulekind !== ModuleKind.ESNext) {
checkExternalEmitHelpers(node, ExternalEmitHelpers.ExportStar);
}
}
Expand Down Expand Up @@ -22249,9 +22249,9 @@ namespace ts {
checkExternalModuleExports(container);

if (node.isExportEquals && !isInAmbientContext(node)) {
if (modulekind === ModuleKind.ES2015) {
if (modulekind >= ModuleKind.ES2015) {
// export assignment is not supported in es6 modules
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_2015_modules_Consider_using_export_default_or_another_module_format_instead);
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
}
else if (modulekind === ModuleKind.System) {
// system modules does not support export assignment
Expand Down Expand Up @@ -24851,7 +24851,7 @@ namespace ts {
}
}

if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit &&
if (compilerOptions.module !== ModuleKind.ES2015 && compilerOptions.module !== ModuleKind.ESNext && compilerOptions.module !== ModuleKind.System && !compilerOptions.noEmit &&
!isInAmbientContext(node.parent.parent) && hasModifier(node.parent.parent, ModifierFlags.Export)) {
checkESModuleMarker(node.name);
}
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,11 @@
"category": "Error",
"code": 1200
},
"Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": {
"Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"', 'import d from \"mod\"', or another module format instead.": {
"category": "Error",
"code": 1202
},
"Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.": {
"Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.": {
"category": "Error",
"code": 1203
},
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4158,7 +4158,8 @@ namespace ts {
const moduleKind = getEmitModuleKind(compilerOptions);
let create = hasExportStarsToExportValues
&& moduleKind !== ModuleKind.System
&& moduleKind !== ModuleKind.ES2015;
&& moduleKind !== ModuleKind.ES2015
&& moduleKind !== ModuleKind.ESNext;
if (!create) {
const helpers = getEmitHelpers(node);
if (helpers) {
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/transformers/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ namespace ts {

function visitSourceFile(node: SourceFile) {
const alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) &&
!(isExternalModule(node) && moduleKind === ModuleKind.ES2015);
!(isExternalModule(node) && moduleKind >= ModuleKind.ES2015);
return updateSourceFileNode(
node,
visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict));
Expand Down Expand Up @@ -2665,6 +2665,7 @@ namespace ts {
return isExportOfNamespace(node)
|| (isExternalModuleExport(node)
&& moduleKind !== ModuleKind.ES2015
&& moduleKind !== ModuleKind.ESNext
&& moduleKind !== ModuleKind.System);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/es6ExportAssignment.errors.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
tests/cases/compiler/es6ExportAssignment.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
tests/cases/compiler/es6ExportAssignment.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.


==== tests/cases/compiler/es6ExportAssignment.ts (1 errors) ====
var a = 10;
export = a;
~~~~~~~~~~~
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
4 changes: 2 additions & 2 deletions tests/baselines/reference/es6ExportAssignment2.errors.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
tests/cases/compiler/a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
tests/cases/compiler/a.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.


==== tests/cases/compiler/a.ts (1 errors) ====
var a = 10;
export = a; // Error: export = not allowed in ES6
~~~~~~~~~~~
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.

==== tests/cases/compiler/b.ts (0 errors) ====
import * as a from "a";
Expand Down
4 changes: 2 additions & 2 deletions tests/baselines/reference/es6ExportEquals.errors.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests/cases/compiler/es6ExportEquals.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
tests/cases/compiler/es6ExportEquals.ts(3,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
tests/cases/compiler/es6ExportEquals.ts(3,1): error TS2309: An export assignment cannot be used in a module with other exported elements.


Expand All @@ -7,7 +7,7 @@ tests/cases/compiler/es6ExportEquals.ts(3,1): error TS2309: An export assignment

export = f;
~~~~~~~~~~~
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
~~~~~~~~~~~
!!! error TS2309: An export assignment cannot be used in a module with other exported elements.

Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
tests/cases/compiler/server.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
tests/cases/compiler/client.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
tests/cases/compiler/server.ts(2,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.


==== tests/cases/compiler/client.ts (1 errors) ====
import a = require("server");
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
==== tests/cases/compiler/server.ts (1 errors) ====
var a = 10;
export = a;
~~~~~~~~~~~
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.

2 changes: 1 addition & 1 deletion tests/baselines/reference/es6modulekind.symbols
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekind.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekind.ts ===
export default class A
>A : Symbol(A, Decl(es6modulekind.ts, 0, 0))
{
Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/es6modulekind.types
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekind.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekind.ts ===
export default class A
>A : A
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES2015Target.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts ===
export default class A
>A : Symbol(A, Decl(es6modulekindWithES2015Target.ts, 0, 0))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES2015Target.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES2015Target.ts ===
export default class A
>A : A
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts ===
export class C {
>C : Symbol(C, Decl(es6modulekindWithES5Target.ts, 0, 0))

Expand Down
2 changes: 1 addition & 1 deletion tests/baselines/reference/es6modulekindWithES5Target.types
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target.ts ===
export class C {
>C : C

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
tests/cases/compiler/es6modulekindWithES5Target10.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
tests/cases/compiler/es6modulekindWithES5Target10.ts(1,20): error TS2307: Cannot find module 'mod'.
tests/cases/compiler/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(1,1): error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(1,20): error TS2307: Cannot find module 'mod'.
tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.


==== tests/cases/compiler/es6modulekindWithES5Target10.ts (3 errors) ====
==== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target10.ts (3 errors) ====
import i = require("mod"); // Error;
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
~~~~~
!!! error TS2307: Cannot find module 'mod'.

Expand All @@ -15,4 +15,4 @@ tests/cases/compiler/es6modulekindWithES5Target10.ts(6,1): error TS1203: Export
}
export = N; // Error
~~~~~~~~~~~
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'export default' or another module format instead.
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript modules. Consider using 'export default' or another module format instead.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target11.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts ===
declare function foo(...args: any[]): any;
>foo : Symbol(foo, Decl(es6modulekindWithES5Target11.ts, 0, 0))
>args : Symbol(args, Decl(es6modulekindWithES5Target11.ts, 0, 21))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target11.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target11.ts ===
declare function foo(...args: any[]): any;
>foo : (...args: any[]) => any
>args : any[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target12.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts ===
export class C {
>C : Symbol(C, Decl(es6modulekindWithES5Target12.ts, 0, 0), Decl(es6modulekindWithES5Target12.ts, 1, 1))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target12.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target12.ts ===
export class C {
>C : C
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target2.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts ===
export default class C {
>C : Symbol(C, Decl(es6modulekindWithES5Target2.ts, 0, 0))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target2.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target2.ts ===
export default class C {
>C : C

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target3.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts ===
declare function foo(...args: any[]): any;
>foo : Symbol(foo, Decl(es6modulekindWithES5Target3.ts, 0, 0))
>args : Symbol(args, Decl(es6modulekindWithES5Target3.ts, 0, 21))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target3.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target3.ts ===
declare function foo(...args: any[]): any;
>foo : (...args: any[]) => any
>args : any[]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target4.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts ===
class E { }
>E : Symbol(E, Decl(es6modulekindWithES5Target4.ts, 0, 0))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target4.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target4.ts ===
class E { }
>E : E

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target5.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts ===
export enum E1 {
>E1 : Symbol(E1, Decl(es6modulekindWithES5Target5.ts, 0, 0))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target5.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target5.ts ===
export enum E1 {
>E1 : E1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target6.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts ===
export function f1(d = 0) {
>f1 : Symbol(f1, Decl(es6modulekindWithES5Target6.ts, 0, 0))
>d : Symbol(d, Decl(es6modulekindWithES5Target6.ts, 0, 19))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target6.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target6.ts ===
export function f1(d = 0) {
>f1 : (d?: number) => void
>d : number
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target7.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts ===
export namespace N {
>N : Symbol(N, Decl(es6modulekindWithES5Target7.ts, 0, 0))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target7.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target7.ts ===
export namespace N {
>N : typeof N

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target8.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts ===
export const c = 0;
>c : Symbol(c, Decl(es6modulekindWithES5Target8.ts, 0, 12))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
=== tests/cases/compiler/es6modulekindWithES5Target8.ts ===
=== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target8.ts ===
export const c = 0;
>c : 0
>0 : 0
Expand Down
12 changes: 6 additions & 6 deletions tests/baselines/reference/es6modulekindWithES5Target9.errors.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
tests/cases/compiler/es6modulekindWithES5Target9.ts(1,15): error TS2307: Cannot find module 'mod'.
tests/cases/compiler/es6modulekindWithES5Target9.ts(3,17): error TS2307: Cannot find module 'mod'.
tests/cases/compiler/es6modulekindWithES5Target9.ts(5,20): error TS2307: Cannot find module 'mod'.
tests/cases/compiler/es6modulekindWithES5Target9.ts(13,15): error TS2307: Cannot find module 'mod'.
tests/cases/compiler/es6modulekindWithES5Target9.ts(15,17): error TS2307: Cannot find module 'mod'.
tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(1,15): error TS2307: Cannot find module 'mod'.
tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(3,17): error TS2307: Cannot find module 'mod'.
tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(5,20): error TS2307: Cannot find module 'mod'.
tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(13,15): error TS2307: Cannot find module 'mod'.
tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts(15,17): error TS2307: Cannot find module 'mod'.


==== tests/cases/compiler/es6modulekindWithES5Target9.ts (5 errors) ====
==== tests/cases/conformance/externalModules/es6/es6modulekindWithES5Target9.ts (5 errors) ====
import d from "mod";
~~~~~
!!! error TS2307: Cannot find module 'mod'.
Expand Down
22 changes: 22 additions & 0 deletions tests/baselines/reference/esnextmodulekind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//// [esnextmodulekind.ts]
export default class A
{
constructor ()
{

}

public B()
{
return 42;
}
}

//// [esnextmodulekind.js]
export default class A {
constructor() {
}
B() {
return 42;
}
}
Loading