mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-12-16 01:41:17 -06:00
Merge pull request #9042 from Microsoft/ES6ModulesES5Target
Fix #6319: Add support for `--t: es5` and `--m es6`
This commit is contained in:
commit
97d7aa5fb5
@ -635,10 +635,6 @@
|
||||
"category": "Error",
|
||||
"code": 1203
|
||||
},
|
||||
"Cannot compile modules into 'es2015' when targeting 'ES5' or lower.": {
|
||||
"category": "Error",
|
||||
"code": 1204
|
||||
},
|
||||
"Decorators are not valid here.": {
|
||||
"category": "Error",
|
||||
"code": 1206
|
||||
|
||||
@ -5613,7 +5613,11 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
|
||||
function emitClassLikeDeclarationBelowES6(node: ClassLikeDeclaration) {
|
||||
const isES6ExportedClass = isES6ExportedDeclaration(node);
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
if (isES6ExportedClass && !(node.flags & NodeFlags.Default)) {
|
||||
write("export ");
|
||||
}
|
||||
// source file level classes in system modules are hoisted so 'var's for them are already defined
|
||||
if (!shouldHoistDeclarationInSystemJsModule(node)) {
|
||||
write("var ");
|
||||
@ -5683,9 +5687,15 @@ const _super = (function (geti, seti) {
|
||||
}
|
||||
emitEnd(node);
|
||||
|
||||
if (node.kind === SyntaxKind.ClassDeclaration) {
|
||||
if (node.kind === SyntaxKind.ClassDeclaration && !isES6ExportedClass) {
|
||||
emitExportMemberAssignment(<ClassDeclaration>node);
|
||||
}
|
||||
else if (isES6ExportedClass && (node.flags & NodeFlags.Default)) {
|
||||
writeLine();
|
||||
write("export default ");
|
||||
emitDeclarationName(node);
|
||||
write(";");
|
||||
}
|
||||
}
|
||||
|
||||
function emitClassMemberPrefix(node: ClassLikeDeclaration, member: Node) {
|
||||
|
||||
@ -2160,11 +2160,6 @@ namespace ts {
|
||||
programDiagnostics.add(createFileDiagnostic(firstExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
|
||||
}
|
||||
|
||||
// Cannot specify module gen target of es6 when below es6
|
||||
if (options.module === ModuleKind.ES6 && languageVersion < ScriptTarget.ES6) {
|
||||
programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Cannot_compile_modules_into_es2015_when_targeting_ES5_or_lower));
|
||||
}
|
||||
|
||||
// Cannot specify module gen that isn't amd or system with --out
|
||||
if (outFile) {
|
||||
if (options.module && !(options.module === ModuleKind.AMD || options.module === ModuleKind.System)) {
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
error TS1204: Cannot compile modules into 'es2015' when targeting 'ES5' or lower.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'es2015' when targeting 'ES5' or lower.
|
||||
==== tests/cases/compiler/es5andes6module.ts (0 errors) ====
|
||||
|
||||
export default class A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,4 +23,4 @@ var A = (function () {
|
||||
};
|
||||
return A;
|
||||
}());
|
||||
exports.default = A;
|
||||
export default A;
|
||||
|
||||
17
tests/baselines/reference/es5andes6module.symbols
Normal file
17
tests/baselines/reference/es5andes6module.symbols
Normal file
@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es5andes6module.ts ===
|
||||
|
||||
export default class A
|
||||
>A : Symbol(A, Decl(es5andes6module.ts, 0, 0))
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : Symbol(A.B, Decl(es5andes6module.ts, 6, 5))
|
||||
{
|
||||
return 42;
|
||||
}
|
||||
}
|
||||
|
||||
18
tests/baselines/reference/es5andes6module.types
Normal file
18
tests/baselines/reference/es5andes6module.types
Normal file
@ -0,0 +1,18 @@
|
||||
=== tests/cases/compiler/es5andes6module.ts ===
|
||||
|
||||
export default class A
|
||||
>A : A
|
||||
{
|
||||
constructor ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public B()
|
||||
>B : () => number
|
||||
{
|
||||
return 42;
|
||||
>42 : number
|
||||
}
|
||||
}
|
||||
|
||||
56
tests/baselines/reference/es6modulekindWithES5Target.js
Normal file
56
tests/baselines/reference/es6modulekindWithES5Target.js
Normal file
@ -0,0 +1,56 @@
|
||||
//// [es6modulekindWithES5Target.ts]
|
||||
|
||||
export class C {
|
||||
static s = 0;
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
export { C as C2 };
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
@foo
|
||||
export class D {
|
||||
static s = 0;
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
export { D as D2 };
|
||||
|
||||
class E { }
|
||||
export {E};
|
||||
|
||||
|
||||
//// [es6modulekindWithES5Target.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
export var C = (function () {
|
||||
function C() {
|
||||
this.p = 1;
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
C.s = 0;
|
||||
return C;
|
||||
}());
|
||||
export { C as C2 };
|
||||
export var D = (function () {
|
||||
function D() {
|
||||
this.p = 1;
|
||||
}
|
||||
D.prototype.method = function () { };
|
||||
D.s = 0;
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
return D;
|
||||
}());
|
||||
export { D as D2 };
|
||||
var E = (function () {
|
||||
function E() {
|
||||
}
|
||||
return E;
|
||||
}());
|
||||
export { E };
|
||||
47
tests/baselines/reference/es6modulekindWithES5Target.symbols
Normal file
47
tests/baselines/reference/es6modulekindWithES5Target.symbols
Normal file
@ -0,0 +1,47 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target.ts ===
|
||||
|
||||
export class C {
|
||||
>C : Symbol(C, Decl(es6modulekindWithES5Target.ts, 0, 0))
|
||||
|
||||
static s = 0;
|
||||
>s : Symbol(C.s, Decl(es6modulekindWithES5Target.ts, 1, 16))
|
||||
|
||||
p = 1;
|
||||
>p : Symbol(C.p, Decl(es6modulekindWithES5Target.ts, 2, 17))
|
||||
|
||||
method() { }
|
||||
>method : Symbol(C.method, Decl(es6modulekindWithES5Target.ts, 3, 10))
|
||||
}
|
||||
export { C as C2 };
|
||||
>C : Symbol(C2, Decl(es6modulekindWithES5Target.ts, 6, 8))
|
||||
>C2 : Symbol(C2, Decl(es6modulekindWithES5Target.ts, 6, 8))
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
>foo : Symbol(foo, Decl(es6modulekindWithES5Target.ts, 6, 19))
|
||||
>args : Symbol(args, Decl(es6modulekindWithES5Target.ts, 8, 21))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(es6modulekindWithES5Target.ts, 6, 19))
|
||||
|
||||
export class D {
|
||||
>D : Symbol(D, Decl(es6modulekindWithES5Target.ts, 8, 42))
|
||||
|
||||
static s = 0;
|
||||
>s : Symbol(D.s, Decl(es6modulekindWithES5Target.ts, 10, 16))
|
||||
|
||||
p = 1;
|
||||
>p : Symbol(D.p, Decl(es6modulekindWithES5Target.ts, 11, 17))
|
||||
|
||||
method() { }
|
||||
>method : Symbol(D.method, Decl(es6modulekindWithES5Target.ts, 12, 10))
|
||||
}
|
||||
export { D as D2 };
|
||||
>D : Symbol(D2, Decl(es6modulekindWithES5Target.ts, 15, 8))
|
||||
>D2 : Symbol(D2, Decl(es6modulekindWithES5Target.ts, 15, 8))
|
||||
|
||||
class E { }
|
||||
>E : Symbol(E, Decl(es6modulekindWithES5Target.ts, 15, 19))
|
||||
|
||||
export {E};
|
||||
>E : Symbol(E, Decl(es6modulekindWithES5Target.ts, 18, 8))
|
||||
|
||||
51
tests/baselines/reference/es6modulekindWithES5Target.types
Normal file
51
tests/baselines/reference/es6modulekindWithES5Target.types
Normal file
@ -0,0 +1,51 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target.ts ===
|
||||
|
||||
export class C {
|
||||
>C : C
|
||||
|
||||
static s = 0;
|
||||
>s : number
|
||||
>0 : number
|
||||
|
||||
p = 1;
|
||||
>p : number
|
||||
>1 : number
|
||||
|
||||
method() { }
|
||||
>method : () => void
|
||||
}
|
||||
export { C as C2 };
|
||||
>C : typeof C
|
||||
>C2 : typeof C
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
>foo : (...args: any[]) => any
|
||||
>args : any[]
|
||||
|
||||
@foo
|
||||
>foo : (...args: any[]) => any
|
||||
|
||||
export class D {
|
||||
>D : D
|
||||
|
||||
static s = 0;
|
||||
>s : number
|
||||
>0 : number
|
||||
|
||||
p = 1;
|
||||
>p : number
|
||||
>1 : number
|
||||
|
||||
method() { }
|
||||
>method : () => void
|
||||
}
|
||||
export { D as D2 };
|
||||
>D : typeof D
|
||||
>D2 : typeof D
|
||||
|
||||
class E { }
|
||||
>E : E
|
||||
|
||||
export {E};
|
||||
>E : typeof E
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
tests/cases/compiler/es6modulekindWithES5Target10.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 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(2,20): error TS2307: Cannot find module 'mod'.
|
||||
tests/cases/compiler/es6modulekindWithES5Target10.ts(7,1): error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
|
||||
|
||||
==== tests/cases/compiler/es6modulekindWithES5Target10.ts (3 errors) ====
|
||||
|
||||
import i = require("mod"); // Error;
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 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'.
|
||||
|
||||
|
||||
namespace N {
|
||||
}
|
||||
export = N; // Error
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1203: Export assignment cannot be used when targeting ECMAScript 6 modules. Consider using 'export default' or another module format instead.
|
||||
10
tests/baselines/reference/es6modulekindWithES5Target10.js
Normal file
10
tests/baselines/reference/es6modulekindWithES5Target10.js
Normal file
@ -0,0 +1,10 @@
|
||||
//// [es6modulekindWithES5Target10.ts]
|
||||
|
||||
import i = require("mod"); // Error;
|
||||
|
||||
|
||||
namespace N {
|
||||
}
|
||||
export = N; // Error
|
||||
|
||||
//// [es6modulekindWithES5Target10.js]
|
||||
31
tests/baselines/reference/es6modulekindWithES5Target11.js
Normal file
31
tests/baselines/reference/es6modulekindWithES5Target11.js
Normal file
@ -0,0 +1,31 @@
|
||||
//// [es6modulekindWithES5Target11.ts]
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
@foo
|
||||
export default class C {
|
||||
static x() { return C.y; }
|
||||
static y = 1
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
|
||||
//// [es6modulekindWithES5Target11.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this.p = 1;
|
||||
}
|
||||
C.x = function () { return C.y; };
|
||||
C.prototype.method = function () { };
|
||||
C.y = 1;
|
||||
C = __decorate([
|
||||
foo
|
||||
], C);
|
||||
return C;
|
||||
}());
|
||||
export default C;
|
||||
@ -0,0 +1,27 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target11.ts ===
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
>foo : Symbol(foo, Decl(es6modulekindWithES5Target11.ts, 0, 0))
|
||||
>args : Symbol(args, Decl(es6modulekindWithES5Target11.ts, 1, 21))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(es6modulekindWithES5Target11.ts, 0, 0))
|
||||
|
||||
export default class C {
|
||||
>C : Symbol(C, Decl(es6modulekindWithES5Target11.ts, 1, 42))
|
||||
|
||||
static x() { return C.y; }
|
||||
>x : Symbol(C.x, Decl(es6modulekindWithES5Target11.ts, 3, 24))
|
||||
>C.y : Symbol(C.y, Decl(es6modulekindWithES5Target11.ts, 4, 30))
|
||||
>C : Symbol(C, Decl(es6modulekindWithES5Target11.ts, 1, 42))
|
||||
>y : Symbol(C.y, Decl(es6modulekindWithES5Target11.ts, 4, 30))
|
||||
|
||||
static y = 1
|
||||
>y : Symbol(C.y, Decl(es6modulekindWithES5Target11.ts, 4, 30))
|
||||
|
||||
p = 1;
|
||||
>p : Symbol(C.p, Decl(es6modulekindWithES5Target11.ts, 5, 16))
|
||||
|
||||
method() { }
|
||||
>method : Symbol(C.method, Decl(es6modulekindWithES5Target11.ts, 6, 10))
|
||||
}
|
||||
29
tests/baselines/reference/es6modulekindWithES5Target11.types
Normal file
29
tests/baselines/reference/es6modulekindWithES5Target11.types
Normal file
@ -0,0 +1,29 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target11.ts ===
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
>foo : (...args: any[]) => any
|
||||
>args : any[]
|
||||
|
||||
@foo
|
||||
>foo : (...args: any[]) => any
|
||||
|
||||
export default class C {
|
||||
>C : C
|
||||
|
||||
static x() { return C.y; }
|
||||
>x : () => number
|
||||
>C.y : number
|
||||
>C : typeof C
|
||||
>y : number
|
||||
|
||||
static y = 1
|
||||
>y : number
|
||||
>1 : number
|
||||
|
||||
p = 1;
|
||||
>p : number
|
||||
>1 : number
|
||||
|
||||
method() { }
|
||||
>method : () => void
|
||||
}
|
||||
19
tests/baselines/reference/es6modulekindWithES5Target2.js
Normal file
19
tests/baselines/reference/es6modulekindWithES5Target2.js
Normal file
@ -0,0 +1,19 @@
|
||||
//// [es6modulekindWithES5Target2.ts]
|
||||
|
||||
export default class C {
|
||||
static s = 0;
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
|
||||
|
||||
//// [es6modulekindWithES5Target2.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this.p = 1;
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
C.s = 0;
|
||||
return C;
|
||||
}());
|
||||
export default C;
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target2.ts ===
|
||||
|
||||
export default class C {
|
||||
>C : Symbol(C, Decl(es6modulekindWithES5Target2.ts, 0, 0))
|
||||
|
||||
static s = 0;
|
||||
>s : Symbol(C.s, Decl(es6modulekindWithES5Target2.ts, 1, 24))
|
||||
|
||||
p = 1;
|
||||
>p : Symbol(C.p, Decl(es6modulekindWithES5Target2.ts, 2, 17))
|
||||
|
||||
method() { }
|
||||
>method : Symbol(C.method, Decl(es6modulekindWithES5Target2.ts, 3, 10))
|
||||
}
|
||||
|
||||
17
tests/baselines/reference/es6modulekindWithES5Target2.types
Normal file
17
tests/baselines/reference/es6modulekindWithES5Target2.types
Normal file
@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target2.ts ===
|
||||
|
||||
export default class C {
|
||||
>C : C
|
||||
|
||||
static s = 0;
|
||||
>s : number
|
||||
>0 : number
|
||||
|
||||
p = 1;
|
||||
>p : number
|
||||
>1 : number
|
||||
|
||||
method() { }
|
||||
>method : () => void
|
||||
}
|
||||
|
||||
30
tests/baselines/reference/es6modulekindWithES5Target3.js
Normal file
30
tests/baselines/reference/es6modulekindWithES5Target3.js
Normal file
@ -0,0 +1,30 @@
|
||||
//// [es6modulekindWithES5Target3.ts]
|
||||
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
@foo
|
||||
export default class D {
|
||||
static s = 0;
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
|
||||
//// [es6modulekindWithES5Target3.js]
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var D = (function () {
|
||||
function D() {
|
||||
this.p = 1;
|
||||
}
|
||||
D.prototype.method = function () { };
|
||||
D.s = 0;
|
||||
D = __decorate([
|
||||
foo
|
||||
], D);
|
||||
return D;
|
||||
}());
|
||||
export default D;
|
||||
@ -0,0 +1,22 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target3.ts ===
|
||||
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
>foo : Symbol(foo, Decl(es6modulekindWithES5Target3.ts, 0, 0))
|
||||
>args : Symbol(args, Decl(es6modulekindWithES5Target3.ts, 2, 21))
|
||||
|
||||
@foo
|
||||
>foo : Symbol(foo, Decl(es6modulekindWithES5Target3.ts, 0, 0))
|
||||
|
||||
export default class D {
|
||||
>D : Symbol(D, Decl(es6modulekindWithES5Target3.ts, 2, 42))
|
||||
|
||||
static s = 0;
|
||||
>s : Symbol(D.s, Decl(es6modulekindWithES5Target3.ts, 4, 24))
|
||||
|
||||
p = 1;
|
||||
>p : Symbol(D.p, Decl(es6modulekindWithES5Target3.ts, 5, 17))
|
||||
|
||||
method() { }
|
||||
>method : Symbol(D.method, Decl(es6modulekindWithES5Target3.ts, 6, 10))
|
||||
}
|
||||
24
tests/baselines/reference/es6modulekindWithES5Target3.types
Normal file
24
tests/baselines/reference/es6modulekindWithES5Target3.types
Normal file
@ -0,0 +1,24 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target3.ts ===
|
||||
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
>foo : (...args: any[]) => any
|
||||
>args : any[]
|
||||
|
||||
@foo
|
||||
>foo : (...args: any[]) => any
|
||||
|
||||
export default class D {
|
||||
>D : D
|
||||
|
||||
static s = 0;
|
||||
>s : number
|
||||
>0 : number
|
||||
|
||||
p = 1;
|
||||
>p : number
|
||||
>1 : number
|
||||
|
||||
method() { }
|
||||
>method : () => void
|
||||
}
|
||||
12
tests/baselines/reference/es6modulekindWithES5Target4.js
Normal file
12
tests/baselines/reference/es6modulekindWithES5Target4.js
Normal file
@ -0,0 +1,12 @@
|
||||
//// [es6modulekindWithES5Target4.ts]
|
||||
|
||||
class E { }
|
||||
export default E;
|
||||
|
||||
//// [es6modulekindWithES5Target4.js]
|
||||
var E = (function () {
|
||||
function E() {
|
||||
}
|
||||
return E;
|
||||
}());
|
||||
export default E;
|
||||
@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target4.ts ===
|
||||
|
||||
class E { }
|
||||
>E : Symbol(E, Decl(es6modulekindWithES5Target4.ts, 0, 0))
|
||||
|
||||
export default E;
|
||||
>E : Symbol(E, Decl(es6modulekindWithES5Target4.ts, 0, 0))
|
||||
|
||||
@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target4.ts ===
|
||||
|
||||
class E { }
|
||||
>E : E
|
||||
|
||||
export default E;
|
||||
>E : E
|
||||
|
||||
19
tests/baselines/reference/es6modulekindWithES5Target5.js
Normal file
19
tests/baselines/reference/es6modulekindWithES5Target5.js
Normal file
@ -0,0 +1,19 @@
|
||||
//// [es6modulekindWithES5Target5.ts]
|
||||
|
||||
export enum E1 {
|
||||
value1
|
||||
}
|
||||
|
||||
export const enum E2 {
|
||||
value1
|
||||
}
|
||||
|
||||
//// [es6modulekindWithES5Target5.js]
|
||||
export var E1;
|
||||
(function (E1) {
|
||||
E1[E1["value1"] = 0] = "value1";
|
||||
})(E1 || (E1 = {}));
|
||||
export var E2;
|
||||
(function (E2) {
|
||||
E2[E2["value1"] = 0] = "value1";
|
||||
})(E2 || (E2 = {}));
|
||||
@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target5.ts ===
|
||||
|
||||
export enum E1 {
|
||||
>E1 : Symbol(E1, Decl(es6modulekindWithES5Target5.ts, 0, 0))
|
||||
|
||||
value1
|
||||
>value1 : Symbol(E1.value1, Decl(es6modulekindWithES5Target5.ts, 1, 16))
|
||||
}
|
||||
|
||||
export const enum E2 {
|
||||
>E2 : Symbol(E2, Decl(es6modulekindWithES5Target5.ts, 3, 1))
|
||||
|
||||
value1
|
||||
>value1 : Symbol(E2.value1, Decl(es6modulekindWithES5Target5.ts, 5, 22))
|
||||
}
|
||||
15
tests/baselines/reference/es6modulekindWithES5Target5.types
Normal file
15
tests/baselines/reference/es6modulekindWithES5Target5.types
Normal file
@ -0,0 +1,15 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target5.ts ===
|
||||
|
||||
export enum E1 {
|
||||
>E1 : E1
|
||||
|
||||
value1
|
||||
>value1 : E1
|
||||
}
|
||||
|
||||
export const enum E2 {
|
||||
>E2 : E2
|
||||
|
||||
value1
|
||||
>value1 : E2
|
||||
}
|
||||
25
tests/baselines/reference/es6modulekindWithES5Target6.js
Normal file
25
tests/baselines/reference/es6modulekindWithES5Target6.js
Normal file
@ -0,0 +1,25 @@
|
||||
//// [es6modulekindWithES5Target6.ts]
|
||||
|
||||
export function f1(d = 0) {
|
||||
}
|
||||
|
||||
export function f2(...arg) {
|
||||
}
|
||||
|
||||
export default function f3(d = 0) {
|
||||
}
|
||||
|
||||
|
||||
//// [es6modulekindWithES5Target6.js]
|
||||
export function f1(d) {
|
||||
if (d === void 0) { d = 0; }
|
||||
}
|
||||
export function f2() {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
export default function f3(d) {
|
||||
if (d === void 0) { d = 0; }
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target6.ts ===
|
||||
|
||||
export function f1(d = 0) {
|
||||
>f1 : Symbol(f1, Decl(es6modulekindWithES5Target6.ts, 0, 0))
|
||||
>d : Symbol(d, Decl(es6modulekindWithES5Target6.ts, 1, 19))
|
||||
}
|
||||
|
||||
export function f2(...arg) {
|
||||
>f2 : Symbol(f2, Decl(es6modulekindWithES5Target6.ts, 2, 1))
|
||||
>arg : Symbol(arg, Decl(es6modulekindWithES5Target6.ts, 4, 19))
|
||||
}
|
||||
|
||||
export default function f3(d = 0) {
|
||||
>f3 : Symbol(f3, Decl(es6modulekindWithES5Target6.ts, 5, 1))
|
||||
>d : Symbol(d, Decl(es6modulekindWithES5Target6.ts, 7, 27))
|
||||
}
|
||||
|
||||
19
tests/baselines/reference/es6modulekindWithES5Target6.types
Normal file
19
tests/baselines/reference/es6modulekindWithES5Target6.types
Normal file
@ -0,0 +1,19 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target6.ts ===
|
||||
|
||||
export function f1(d = 0) {
|
||||
>f1 : (d?: number) => void
|
||||
>d : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
export function f2(...arg) {
|
||||
>f2 : (...arg: any[]) => void
|
||||
>arg : any[]
|
||||
}
|
||||
|
||||
export default function f3(d = 0) {
|
||||
>f3 : (d?: number) => void
|
||||
>d : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
16
tests/baselines/reference/es6modulekindWithES5Target7.js
Normal file
16
tests/baselines/reference/es6modulekindWithES5Target7.js
Normal file
@ -0,0 +1,16 @@
|
||||
//// [es6modulekindWithES5Target7.ts]
|
||||
|
||||
export namespace N {
|
||||
var x = 0;
|
||||
}
|
||||
|
||||
export namespace N2 {
|
||||
export interface I { }
|
||||
}
|
||||
|
||||
|
||||
//// [es6modulekindWithES5Target7.js]
|
||||
export var N;
|
||||
(function (N) {
|
||||
var x = 0;
|
||||
})(N || (N = {}));
|
||||
@ -0,0 +1,16 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target7.ts ===
|
||||
|
||||
export namespace N {
|
||||
>N : Symbol(N, Decl(es6modulekindWithES5Target7.ts, 0, 0))
|
||||
|
||||
var x = 0;
|
||||
>x : Symbol(x, Decl(es6modulekindWithES5Target7.ts, 2, 7))
|
||||
}
|
||||
|
||||
export namespace N2 {
|
||||
>N2 : Symbol(N2, Decl(es6modulekindWithES5Target7.ts, 3, 1))
|
||||
|
||||
export interface I { }
|
||||
>I : Symbol(I, Decl(es6modulekindWithES5Target7.ts, 5, 21))
|
||||
}
|
||||
|
||||
17
tests/baselines/reference/es6modulekindWithES5Target7.types
Normal file
17
tests/baselines/reference/es6modulekindWithES5Target7.types
Normal file
@ -0,0 +1,17 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target7.ts ===
|
||||
|
||||
export namespace N {
|
||||
>N : typeof N
|
||||
|
||||
var x = 0;
|
||||
>x : number
|
||||
>0 : number
|
||||
}
|
||||
|
||||
export namespace N2 {
|
||||
>N2 : any
|
||||
|
||||
export interface I { }
|
||||
>I : I
|
||||
}
|
||||
|
||||
8
tests/baselines/reference/es6modulekindWithES5Target8.js
Normal file
8
tests/baselines/reference/es6modulekindWithES5Target8.js
Normal file
@ -0,0 +1,8 @@
|
||||
//// [es6modulekindWithES5Target8.ts]
|
||||
|
||||
export const c = 0;
|
||||
export let l = 1;
|
||||
|
||||
//// [es6modulekindWithES5Target8.js]
|
||||
export var c = 0;
|
||||
export var l = 1;
|
||||
@ -0,0 +1,8 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target8.ts ===
|
||||
|
||||
export const c = 0;
|
||||
>c : Symbol(c, Decl(es6modulekindWithES5Target8.ts, 1, 12))
|
||||
|
||||
export let l = 1;
|
||||
>l : Symbol(l, Decl(es6modulekindWithES5Target8.ts, 2, 10))
|
||||
|
||||
10
tests/baselines/reference/es6modulekindWithES5Target8.types
Normal file
10
tests/baselines/reference/es6modulekindWithES5Target8.types
Normal file
@ -0,0 +1,10 @@
|
||||
=== tests/cases/compiler/es6modulekindWithES5Target8.ts ===
|
||||
|
||||
export const c = 0;
|
||||
>c : number
|
||||
>0 : number
|
||||
|
||||
export let l = 1;
|
||||
>l : number
|
||||
>1 : number
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
tests/cases/compiler/es6modulekindWithES5Target9.ts(2,15): error TS2307: Cannot find module 'mod'.
|
||||
tests/cases/compiler/es6modulekindWithES5Target9.ts(4,17): error TS2307: Cannot find module 'mod'.
|
||||
tests/cases/compiler/es6modulekindWithES5Target9.ts(6,20): error TS2307: Cannot find module 'mod'.
|
||||
tests/cases/compiler/es6modulekindWithES5Target9.ts(14,15): error TS2307: Cannot find module 'mod'.
|
||||
tests/cases/compiler/es6modulekindWithES5Target9.ts(16,17): error TS2307: Cannot find module 'mod'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/es6modulekindWithES5Target9.ts (5 errors) ====
|
||||
|
||||
import d from "mod";
|
||||
~~~~~
|
||||
!!! error TS2307: Cannot find module 'mod'.
|
||||
|
||||
import {a} from "mod";
|
||||
~~~~~
|
||||
!!! error TS2307: Cannot find module 'mod'.
|
||||
|
||||
import * as M from "mod";
|
||||
~~~~~
|
||||
!!! error TS2307: Cannot find module 'mod'.
|
||||
|
||||
export {a};
|
||||
|
||||
export {M};
|
||||
|
||||
export {d};
|
||||
|
||||
export * from "mod";
|
||||
~~~~~
|
||||
!!! error TS2307: Cannot find module 'mod'.
|
||||
|
||||
export {b} from "mod"
|
||||
~~~~~
|
||||
!!! error TS2307: Cannot find module 'mod'.
|
||||
|
||||
export default d;
|
||||
|
||||
31
tests/baselines/reference/es6modulekindWithES5Target9.js
Normal file
31
tests/baselines/reference/es6modulekindWithES5Target9.js
Normal file
@ -0,0 +1,31 @@
|
||||
//// [es6modulekindWithES5Target9.ts]
|
||||
|
||||
import d from "mod";
|
||||
|
||||
import {a} from "mod";
|
||||
|
||||
import * as M from "mod";
|
||||
|
||||
export {a};
|
||||
|
||||
export {M};
|
||||
|
||||
export {d};
|
||||
|
||||
export * from "mod";
|
||||
|
||||
export {b} from "mod"
|
||||
|
||||
export default d;
|
||||
|
||||
|
||||
//// [es6modulekindWithES5Target9.js]
|
||||
import d from "mod";
|
||||
import { a } from "mod";
|
||||
import * as M from "mod";
|
||||
export { a };
|
||||
export { M };
|
||||
export { d };
|
||||
export * from "mod";
|
||||
export { b } from "mod";
|
||||
export default d;
|
||||
@ -1,8 +1,6 @@
|
||||
error TS1204: Cannot compile modules into 'es2015' when targeting 'ES5' or lower.
|
||||
tests/cases/compiler/test.ts(2,19): error TS2307: Cannot find module './foo'.
|
||||
|
||||
|
||||
!!! error TS1204: Cannot compile modules into 'es2015' when targeting 'ES5' or lower.
|
||||
==== tests/cases/compiler/test.ts (1 errors) ====
|
||||
|
||||
import {foo} from './foo';
|
||||
|
||||
22
tests/cases/compiler/es6modulekindWithES5Target.ts
Normal file
22
tests/cases/compiler/es6modulekindWithES5Target.ts
Normal file
@ -0,0 +1,22 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
// @experimentalDecorators: true
|
||||
|
||||
export class C {
|
||||
static s = 0;
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
export { C as C2 };
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
@foo
|
||||
export class D {
|
||||
static s = 0;
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
export { D as D2 };
|
||||
|
||||
class E { }
|
||||
export {E};
|
||||
9
tests/cases/compiler/es6modulekindWithES5Target10.ts
Normal file
9
tests/cases/compiler/es6modulekindWithES5Target10.ts
Normal file
@ -0,0 +1,9 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
|
||||
import i = require("mod"); // Error;
|
||||
|
||||
|
||||
namespace N {
|
||||
}
|
||||
export = N; // Error
|
||||
12
tests/cases/compiler/es6modulekindWithES5Target11.ts
Normal file
12
tests/cases/compiler/es6modulekindWithES5Target11.ts
Normal file
@ -0,0 +1,12 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
// @experimentalDecorators: true
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
@foo
|
||||
export default class C {
|
||||
static x() { return C.y; }
|
||||
static y = 1
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
8
tests/cases/compiler/es6modulekindWithES5Target2.ts
Normal file
8
tests/cases/compiler/es6modulekindWithES5Target2.ts
Normal file
@ -0,0 +1,8 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
|
||||
export default class C {
|
||||
static s = 0;
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
12
tests/cases/compiler/es6modulekindWithES5Target3.ts
Normal file
12
tests/cases/compiler/es6modulekindWithES5Target3.ts
Normal file
@ -0,0 +1,12 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
// @experimentalDecorators: true
|
||||
|
||||
|
||||
declare function foo(...args: any[]): any;
|
||||
@foo
|
||||
export default class D {
|
||||
static s = 0;
|
||||
p = 1;
|
||||
method() { }
|
||||
}
|
||||
5
tests/cases/compiler/es6modulekindWithES5Target4.ts
Normal file
5
tests/cases/compiler/es6modulekindWithES5Target4.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
|
||||
class E { }
|
||||
export default E;
|
||||
11
tests/cases/compiler/es6modulekindWithES5Target5.ts
Normal file
11
tests/cases/compiler/es6modulekindWithES5Target5.ts
Normal file
@ -0,0 +1,11 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
// @preserveConstEnums: true
|
||||
|
||||
export enum E1 {
|
||||
value1
|
||||
}
|
||||
|
||||
export const enum E2 {
|
||||
value1
|
||||
}
|
||||
11
tests/cases/compiler/es6modulekindWithES5Target6.ts
Normal file
11
tests/cases/compiler/es6modulekindWithES5Target6.ts
Normal file
@ -0,0 +1,11 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
|
||||
export function f1(d = 0) {
|
||||
}
|
||||
|
||||
export function f2(...arg) {
|
||||
}
|
||||
|
||||
export default function f3(d = 0) {
|
||||
}
|
||||
10
tests/cases/compiler/es6modulekindWithES5Target7.ts
Normal file
10
tests/cases/compiler/es6modulekindWithES5Target7.ts
Normal file
@ -0,0 +1,10 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
|
||||
export namespace N {
|
||||
var x = 0;
|
||||
}
|
||||
|
||||
export namespace N2 {
|
||||
export interface I { }
|
||||
}
|
||||
5
tests/cases/compiler/es6modulekindWithES5Target8.ts
Normal file
5
tests/cases/compiler/es6modulekindWithES5Target8.ts
Normal file
@ -0,0 +1,5 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
|
||||
export const c = 0;
|
||||
export let l = 1;
|
||||
20
tests/cases/compiler/es6modulekindWithES5Target9.ts
Normal file
20
tests/cases/compiler/es6modulekindWithES5Target9.ts
Normal file
@ -0,0 +1,20 @@
|
||||
// @target: es5
|
||||
// @module: es2015
|
||||
|
||||
import d from "mod";
|
||||
|
||||
import {a} from "mod";
|
||||
|
||||
import * as M from "mod";
|
||||
|
||||
export {a};
|
||||
|
||||
export {M};
|
||||
|
||||
export {d};
|
||||
|
||||
export * from "mod";
|
||||
|
||||
export {b} from "mod"
|
||||
|
||||
export default d;
|
||||
Loading…
x
Reference in New Issue
Block a user