mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Report error if module gen target is specified in es6
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
This commit is contained in:
parent
04ea7fe6de
commit
b52d9ec23e
@ -159,6 +159,7 @@ module ts {
|
||||
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
|
||||
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1200, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
|
||||
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1201, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
|
||||
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1202, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
|
||||
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
|
||||
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
|
||||
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
|
||||
|
||||
@ -627,6 +627,10 @@
|
||||
"category": "Error",
|
||||
"code": 1201
|
||||
},
|
||||
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
|
||||
"category": "Error",
|
||||
"code": 1202
|
||||
},
|
||||
|
||||
"Duplicate identifier '{0}'.": {
|
||||
"category": "Error",
|
||||
|
||||
@ -428,9 +428,16 @@ module ts {
|
||||
|
||||
var firstExternalModuleSourceFile = forEach(files, f => isExternalModule(f) ? f : undefined);
|
||||
if (firstExternalModuleSourceFile && !options.module) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
var span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
|
||||
if (!options.module && options.target < ScriptTarget.ES6) {
|
||||
// We cannot use createDiagnosticFromNode because nodes do not have parents yet
|
||||
var span = getErrorSpanForNode(firstExternalModuleSourceFile, firstExternalModuleSourceFile.externalModuleIndicator);
|
||||
diagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_external_modules_unless_the_module_flag_is_provided));
|
||||
}
|
||||
}
|
||||
|
||||
// Cannot specify module gen target when in es6 or above
|
||||
if (options.module && options.target >= ScriptTarget.ES6) {
|
||||
diagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher));
|
||||
}
|
||||
|
||||
// there has to be common source directory if user specified --outdir || --sourcRoot
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1200: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
|
||||
@ -19,6 +20,7 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper
|
||||
tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
|
||||
|
||||
|
||||
!!! error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ====
|
||||
///<reference path='constDeclarations_access_1.ts'/>
|
||||
import m = require('constDeclarations_access_1');
|
||||
|
||||
25
tests/baselines/reference/es5ModuleWithModuleGenAmd.js
Normal file
25
tests/baselines/reference/es5ModuleWithModuleGenAmd.js
Normal file
@ -0,0 +1,25 @@
|
||||
//// [es5ModuleWithModuleGenAmd.ts]
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es5ModuleWithModuleGenAmd.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.B = function () {
|
||||
return 42;
|
||||
};
|
||||
return A;
|
||||
})();
|
||||
exports.A = A;
|
||||
});
|
||||
@ -1,11 +1,9 @@
|
||||
=== tests/cases/compiler/es6-declaration-amd.ts ===
|
||||
|
||||
class A
|
||||
=== tests/cases/compiler/es5ModuleWithModuleGenAmd.ts ===
|
||||
export class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
23
tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js
Normal file
23
tests/baselines/reference/es5ModuleWithModuleGenCommonjs.js
Normal file
@ -0,0 +1,23 @@
|
||||
//// [es5ModuleWithModuleGenCommonjs.ts]
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es5ModuleWithModuleGenCommonjs.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.B = function () {
|
||||
return 42;
|
||||
};
|
||||
return A;
|
||||
})();
|
||||
exports.A = A;
|
||||
@ -1,11 +1,9 @@
|
||||
=== tests/cases/compiler/es6-sourcemap-amd.ts ===
|
||||
|
||||
class A
|
||||
=== tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts ===
|
||||
export class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
@ -0,0 +1,17 @@
|
||||
tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts(1,14): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
|
||||
|
||||
==== tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts (1 errors) ====
|
||||
export class A
|
||||
~
|
||||
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
23
tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js
Normal file
23
tests/baselines/reference/es5ModuleWithoutModuleGenTarget.js
Normal file
@ -0,0 +1,23 @@
|
||||
//// [es5ModuleWithoutModuleGenTarget.ts]
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es5ModuleWithoutModuleGenTarget.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.B = function () {
|
||||
return 42;
|
||||
};
|
||||
return A;
|
||||
})();
|
||||
exports.A = A;
|
||||
18
tests/baselines/reference/es6-amd.errors.txt
Normal file
18
tests/baselines/reference/es6-amd.errors.txt
Normal file
@ -0,0 +1,18 @@
|
||||
error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
|
||||
|
||||
!!! error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
==== tests/cases/compiler/es6-amd.ts (0 errors) ====
|
||||
|
||||
class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
18
tests/baselines/reference/es6-declaration-amd.errors.txt
Normal file
18
tests/baselines/reference/es6-declaration-amd.errors.txt
Normal file
@ -0,0 +1,18 @@
|
||||
error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
|
||||
|
||||
!!! error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
==== tests/cases/compiler/es6-declaration-amd.ts (0 errors) ====
|
||||
|
||||
class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
18
tests/baselines/reference/es6-sourcemap-amd.errors.txt
Normal file
18
tests/baselines/reference/es6-sourcemap-amd.errors.txt
Normal file
@ -0,0 +1,18 @@
|
||||
error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
|
||||
|
||||
!!! error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
==== tests/cases/compiler/es6-sourcemap-amd.ts (0 errors) ====
|
||||
|
||||
class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,9 @@
|
||||
tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
tests/cases/compiler/es6ExportAssignment.ts(3,1): error TS1201: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/es6ExportAssignment.ts (2 errors) ====
|
||||
==== tests/cases/compiler/es6ExportAssignment.ts (1 errors) ====
|
||||
|
||||
var a = 10;
|
||||
export = a;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1201: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
@ -8,4 +8,5 @@ tests/cases/compiler/es6ImportDefaultBinding_1.ts(1,8): error TS1192: External m
|
||||
==== tests/cases/compiler/es6ImportDefaultBinding_1.ts (1 errors) ====
|
||||
import defaultBinding from "es6ImportDefaultBinding_0";
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBinding_0"' has no default export or export assignment.
|
||||
!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBinding_0"' has no default export or export assignment.
|
||||
|
||||
@ -5,8 +5,14 @@
|
||||
export var a = 10;
|
||||
|
||||
//// [es6ImportDefaultBinding_1.ts]
|
||||
import defaultBinding from "es6ImportDefaultBinding_0";
|
||||
import defaultBinding from "es6ImportDefaultBinding_0";
|
||||
|
||||
|
||||
//// [es6ImportDefaultBinding_0.js]
|
||||
exports.a = 10;
|
||||
//// [es6ImportDefaultBinding_1.js]
|
||||
|
||||
|
||||
//// [es6ImportDefaultBinding_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportDefaultBinding_1.d.ts]
|
||||
|
||||
@ -48,4 +48,5 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_1.ts(6,8): e
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamedImport_0"' has no default export or export assignment.
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2300: Duplicate identifier 'defaultBinding'.
|
||||
!!! error TS2300: Duplicate identifier 'defaultBinding'.
|
||||
|
||||
@ -12,10 +12,18 @@ import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImpor
|
||||
import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
|
||||
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_0.js]
|
||||
exports.a = 10;
|
||||
exports.x = exports.a;
|
||||
exports.m = exports.a;
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_1.js]
|
||||
|
||||
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_0.d.ts]
|
||||
export declare var a: number;
|
||||
export declare var x: number;
|
||||
export declare var m: number;
|
||||
//// [es6ImportDefaultBindingFollowedWithNamedImport_1.d.ts]
|
||||
|
||||
@ -8,4 +8,5 @@ tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts(1,
|
||||
==== tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts (1 errors) ====
|
||||
import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0";
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export or export assignment.
|
||||
!!! error TS1192: External module '"tests/cases/compiler/es6ImportDefaultBindingFollowedWithNamespaceBinding_0"' has no default export or export assignment.
|
||||
var x: number = nameSpaceBinding.a;
|
||||
@ -5,8 +5,16 @@
|
||||
export var a = 10;
|
||||
|
||||
//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts]
|
||||
import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0";
|
||||
import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0";
|
||||
var x: number = nameSpaceBinding.a;
|
||||
|
||||
//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.js]
|
||||
exports.a = 10;
|
||||
//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.js]
|
||||
var defaultBinding = require("es6ImportDefaultBindingFollowedWithNamespaceBinding_0");
|
||||
var x = nameSpaceBinding.a;
|
||||
|
||||
|
||||
//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportDefaultBindingFollowedWithNamespaceBinding_1.d.ts]
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
tests/cases/compiler/client.ts(1,1): error TS1200: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
tests/cases/compiler/server.ts(3,1): error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
tests/cases/compiler/server.ts(3,1): error TS1201: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
|
||||
|
||||
@ -7,12 +6,10 @@ tests/cases/compiler/server.ts(3,1): error TS1201: Export assignment cannot be u
|
||||
import a = require("server");
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1200: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
|
||||
==== tests/cases/compiler/server.ts (2 errors) ====
|
||||
==== tests/cases/compiler/server.ts (1 errors) ====
|
||||
|
||||
var a = 10;
|
||||
export = a;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1148: Cannot compile external modules unless the '--module' flag is provided.
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1201: Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.
|
||||
|
||||
@ -5,8 +5,14 @@
|
||||
export var a = 10;
|
||||
|
||||
//// [es6ImportNameSpaceImport_1.ts]
|
||||
import * as nameSpaceBinding from "es6ImportNameSpaceImport_0";
|
||||
import * as nameSpaceBinding from "es6ImportNameSpaceImport_0";
|
||||
|
||||
|
||||
//// [es6ImportNameSpaceImport_0.js]
|
||||
exports.a = 10;
|
||||
//// [es6ImportNameSpaceImport_1.js]
|
||||
|
||||
|
||||
//// [es6ImportNameSpaceImport_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportNameSpaceImport_1.d.ts]
|
||||
|
||||
@ -16,7 +16,8 @@ import { x, a as y } from "es6ImportNamedImport_0";
|
||||
import { x as z, } from "es6ImportNamedImport_0";
|
||||
import { m, } from "es6ImportNamedImport_0";
|
||||
import { a1, x1 } from "es6ImportNamedImport_0";
|
||||
import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0";
|
||||
import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0";
|
||||
|
||||
|
||||
//// [es6ImportNamedImport_0.js]
|
||||
exports.a = 10;
|
||||
@ -25,3 +26,12 @@ exports.m = exports.a;
|
||||
exports.a1 = 10;
|
||||
exports.x1 = 10;
|
||||
//// [es6ImportNamedImport_1.js]
|
||||
|
||||
|
||||
//// [es6ImportNamedImport_0.d.ts]
|
||||
export declare var a: number;
|
||||
export declare var x: number;
|
||||
export declare var m: number;
|
||||
export declare var a1: number;
|
||||
export declare var x1: number;
|
||||
//// [es6ImportNamedImport_1.d.ts]
|
||||
|
||||
@ -5,9 +5,15 @@
|
||||
export var a = 10;
|
||||
|
||||
//// [es6ImportWithoutFromClause_1.ts]
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
|
||||
|
||||
//// [es6ImportWithoutFromClause_0.js]
|
||||
exports.a = 10;
|
||||
//// [es6ImportWithoutFromClause_1.js]
|
||||
require("es6ImportWithoutFromClause_0");
|
||||
|
||||
|
||||
//// [es6ImportWithoutFromClause_0.d.ts]
|
||||
export declare var a: number;
|
||||
//// [es6ImportWithoutFromClause_1.d.ts]
|
||||
|
||||
@ -5,4 +5,5 @@ export var a = 10;
|
||||
|
||||
=== tests/cases/compiler/es6ImportWithoutFromClause_1.ts ===
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
No type information for this code.
|
||||
No type information for this code.
|
||||
23
tests/baselines/reference/es6Module.js
Normal file
23
tests/baselines/reference/es6Module.js
Normal file
@ -0,0 +1,23 @@
|
||||
//// [es6Module.ts]
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es6Module.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.B = function () {
|
||||
return 42;
|
||||
};
|
||||
return A;
|
||||
})();
|
||||
exports.A = A;
|
||||
@ -1,11 +1,9 @@
|
||||
=== tests/cases/compiler/es6-amd.ts ===
|
||||
|
||||
class A
|
||||
=== tests/cases/compiler/es6Module.ts ===
|
||||
export class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
@ -0,0 +1,16 @@
|
||||
error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
|
||||
|
||||
!!! error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
==== tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts (0 errors) ====
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
25
tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js
Normal file
25
tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.js
Normal file
@ -0,0 +1,25 @@
|
||||
//// [es6ModuleWithModuleGenTargetAmd.ts]
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es6ModuleWithModuleGenTargetAmd.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.B = function () {
|
||||
return 42;
|
||||
};
|
||||
return A;
|
||||
})();
|
||||
exports.A = A;
|
||||
});
|
||||
@ -0,0 +1,16 @@
|
||||
error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
|
||||
|
||||
!!! error TS1202: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
|
||||
==== tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts (0 errors) ====
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
//// [es6ModuleWithModuleGenTargetCommonjs.ts]
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
//// [es6ModuleWithModuleGenTargetCommonjs.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
A.prototype.B = function () {
|
||||
return 42;
|
||||
};
|
||||
return A;
|
||||
})();
|
||||
exports.A = A;
|
||||
13
tests/cases/compiler/es5ModuleWithModuleGenAmd.ts
Normal file
13
tests/cases/compiler/es5ModuleWithModuleGenAmd.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @target: ES5
|
||||
// @module: amd
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
13
tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts
Normal file
13
tests/cases/compiler/es5ModuleWithModuleGenCommonjs.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @target: ES5
|
||||
// @module: commonjs
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
12
tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts
Normal file
12
tests/cases/compiler/es5ModuleWithoutModuleGenTarget.ts
Normal file
@ -0,0 +1,12 @@
|
||||
// @target: ES5
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportDefaultBinding_0.ts
|
||||
export var a = 10;
|
||||
|
||||
// @filename: es6ImportDefaultBinding_1.ts
|
||||
import defaultBinding from "es6ImportDefaultBinding_0";
|
||||
import defaultBinding from "es6ImportDefaultBinding_0";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportDefaultBindingFollowedWithNamedImport_0.ts
|
||||
export var a = 10;
|
||||
@ -12,4 +12,4 @@ import defaultBinding, { a } from "es6ImportDefaultBindingFollowedWithNamedImpor
|
||||
import defaultBinding, { a as b } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding, { x, a as y } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding, { x as z, } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
import defaultBinding, { m, } from "es6ImportDefaultBindingFollowedWithNamedImport_0";
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_0.ts
|
||||
export var a = 10;
|
||||
|
||||
// @filename: es6ImportDefaultBindingFollowedWithNamespaceBinding_1.ts
|
||||
import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0";
|
||||
import defaultBinding, * as nameSpaceBinding from "es6ImportDefaultBindingFollowedWithNamespaceBinding_0";
|
||||
var x: number = nameSpaceBinding.a;
|
||||
@ -1,8 +1,8 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportNameSpaceImport_0.ts
|
||||
export var a = 10;
|
||||
|
||||
// @filename: es6ImportNameSpaceImport_1.ts
|
||||
import * as nameSpaceBinding from "es6ImportNameSpaceImport_0";
|
||||
import * as nameSpaceBinding from "es6ImportNameSpaceImport_0";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportNamedImport_0.ts
|
||||
export var a = 10;
|
||||
@ -16,4 +16,4 @@ import { x, a as y } from "es6ImportNamedImport_0";
|
||||
import { x as z, } from "es6ImportNamedImport_0";
|
||||
import { m, } from "es6ImportNamedImport_0";
|
||||
import { a1, x1 } from "es6ImportNamedImport_0";
|
||||
import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0";
|
||||
import { a1 as a11, x1 as x11 } from "es6ImportNamedImport_0";
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
|
||||
import { yield } from "somemodule"; // Allowed
|
||||
import { default } from "somemodule"; // Error - as this is keyword that is not allowed as identifier
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
|
||||
// @filename: es6ImportNamedImportParsingError_0.ts
|
||||
export var a = 10;
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
|
||||
import 10;
|
||||
@ -1,8 +1,8 @@
|
||||
// @target: es6
|
||||
// @module: commonjs
|
||||
// @declaration: true
|
||||
|
||||
// @filename: es6ImportWithoutFromClause_0.ts
|
||||
export var a = 10;
|
||||
|
||||
// @filename: es6ImportWithoutFromClause_1.ts
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
import "es6ImportWithoutFromClause_0";
|
||||
|
||||
12
tests/cases/compiler/es6Module.ts
Normal file
12
tests/cases/compiler/es6Module.ts
Normal file
@ -0,0 +1,12 @@
|
||||
// @target: ES6
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
13
tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts
Normal file
13
tests/cases/compiler/es6ModuleWithModuleGenTargetAmd.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @target: ES6
|
||||
// @module: amd
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
13
tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts
Normal file
13
tests/cases/compiler/es6ModuleWithModuleGenTargetCommonjs.ts
Normal file
@ -0,0 +1,13 @@
|
||||
// @target: ES6
|
||||
// @module: commonjs
|
||||
export class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user