mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
Merge branch 'master' into lightMode
Conflicts: src/compiler/program.ts
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_1.ts(1,18): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_1.ts (1 errors) ====
|
||||
var { x } = <any>foo();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringTypeAssertionsES5_1.ts]
|
||||
var { x } = <any>foo();
|
||||
|
||||
//// [destructuringTypeAssertionsES5_1.js]
|
||||
var x = foo().x;
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_2.ts(1,19): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_2.ts (1 errors) ====
|
||||
var { x } = (<any>foo());
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringTypeAssertionsES5_2.ts]
|
||||
var { x } = (<any>foo());
|
||||
|
||||
//// [destructuringTypeAssertionsES5_2.js]
|
||||
var x = foo().x;
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_3.ts(1,19): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_3.ts (1 errors) ====
|
||||
var { x } = <any>(foo());
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringTypeAssertionsES5_3.ts]
|
||||
var { x } = <any>(foo());
|
||||
|
||||
//// [destructuringTypeAssertionsES5_3.js]
|
||||
var x = (foo()).x;
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_4.ts(1,23): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_4.ts (1 errors) ====
|
||||
var { x } = <any><any>foo();
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringTypeAssertionsES5_4.ts]
|
||||
var { x } = <any><any>foo();
|
||||
|
||||
//// [destructuringTypeAssertionsES5_4.js]
|
||||
var x = foo().x;
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringTypeAssertionsES5_5.ts]
|
||||
var { x } = <any>0;
|
||||
|
||||
//// [destructuringTypeAssertionsES5_5.js]
|
||||
var x = (0).x;
|
||||
@@ -0,0 +1,4 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_5.ts ===
|
||||
var { x } = <any>0;
|
||||
>x : Symbol(x, Decl(destructuringTypeAssertionsES5_5.ts, 0, 5))
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
=== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_5.ts ===
|
||||
var { x } = <any>0;
|
||||
>x : any
|
||||
><any>0 : any
|
||||
>0 : number
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_6.ts(1,22): error TS2304: Cannot find name 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_6.ts (1 errors) ====
|
||||
var { x } = <any>new Foo;
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringTypeAssertionsES5_6.ts]
|
||||
var { x } = <any>new Foo;
|
||||
|
||||
//// [destructuringTypeAssertionsES5_6.js]
|
||||
var x = (new Foo).x;
|
||||
@@ -0,0 +1,7 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_7.ts(1,27): error TS2304: Cannot find name 'Foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringTypeAssertionsES5_7.ts (1 errors) ====
|
||||
var { x } = <any><any>new Foo;
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'Foo'.
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [destructuringTypeAssertionsES5_7.ts]
|
||||
var { x } = <any><any>new Foo;
|
||||
|
||||
//// [destructuringTypeAssertionsES5_7.js]
|
||||
var x = (new Foo).x;
|
||||
@@ -20,7 +20,7 @@ System.register([], function(exports_1) {
|
||||
(function (M) {
|
||||
var x = 1;
|
||||
})(M = M || (M = {}));
|
||||
exports_1("M", M)
|
||||
exports_1("M", M);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ System.register([], function(exports_1) {
|
||||
(function (F) {
|
||||
var x;
|
||||
})(F = F || (F = {}));
|
||||
exports_1("F", F)
|
||||
exports_1("F", F);
|
||||
C = (function () {
|
||||
function C() {
|
||||
}
|
||||
@@ -30,14 +30,14 @@ System.register([], function(exports_1) {
|
||||
(function (C) {
|
||||
var x;
|
||||
})(C = C || (C = {}));
|
||||
exports_1("C", C)
|
||||
exports_1("C", C);
|
||||
(function (E) {
|
||||
})(E || (E = {}));
|
||||
exports_1("E", E)
|
||||
exports_1("E", E);
|
||||
(function (E) {
|
||||
var x;
|
||||
})(E = E || (E = {}));
|
||||
exports_1("E", E)
|
||||
exports_1("E", E);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -29,11 +29,11 @@ System.register([], function(exports_1) {
|
||||
(function (TopLevelModule) {
|
||||
var v;
|
||||
})(TopLevelModule = TopLevelModule || (TopLevelModule = {}));
|
||||
exports_1("TopLevelModule", TopLevelModule)
|
||||
exports_1("TopLevelModule", TopLevelModule);
|
||||
(function (TopLevelEnum) {
|
||||
TopLevelEnum[TopLevelEnum["E"] = 0] = "E";
|
||||
})(TopLevelEnum || (TopLevelEnum = {}));
|
||||
exports_1("TopLevelEnum", TopLevelEnum)
|
||||
exports_1("TopLevelEnum", TopLevelEnum);
|
||||
(function (TopLevelModule2) {
|
||||
var NonTopLevelClass = (function () {
|
||||
function NonTopLevelClass() {
|
||||
@@ -52,7 +52,7 @@ System.register([], function(exports_1) {
|
||||
})(TopLevelModule2.NonTopLevelEnum || (TopLevelModule2.NonTopLevelEnum = {}));
|
||||
var NonTopLevelEnum = TopLevelModule2.NonTopLevelEnum;
|
||||
})(TopLevelModule2 = TopLevelModule2 || (TopLevelModule2 = {}));
|
||||
exports_1("TopLevelModule2", TopLevelModule2)
|
||||
exports_1("TopLevelModule2", TopLevelModule2);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
//@target: ES5
|
||||
var { x } = <any>foo();
|
||||
@@ -0,0 +1,2 @@
|
||||
//@target: ES5
|
||||
var { x } = (<any>foo());
|
||||
@@ -0,0 +1,2 @@
|
||||
//@target: ES5
|
||||
var { x } = <any>(foo());
|
||||
@@ -0,0 +1,2 @@
|
||||
//@target: ES5
|
||||
var { x } = <any><any>foo();
|
||||
@@ -0,0 +1,2 @@
|
||||
//@target: ES5
|
||||
var { x } = <any>0;
|
||||
@@ -0,0 +1,2 @@
|
||||
//@target: ES5
|
||||
var { x } = <any>new Foo;
|
||||
@@ -0,0 +1,2 @@
|
||||
//@target: ES5
|
||||
var { x } = <any><any>new Foo;
|
||||
59
tests/cases/unittests/transpile.ts
Normal file
59
tests/cases/unittests/transpile.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
/// <reference path="..\..\..\src\harness\harness.ts" />
|
||||
|
||||
module ts {
|
||||
describe("Transpile", () => {
|
||||
|
||||
function runTest(input: string, compilerOptions: ts.CompilerOptions = {}, expectedOutput?: string, expectedDiagnosticCodes: number[] = []): void {
|
||||
let diagnostics: Diagnostic[] = [];
|
||||
let result = transpile(input, compilerOptions, "file.ts", diagnostics);
|
||||
|
||||
for (let i = 0; i < expectedDiagnosticCodes.length; i++) {
|
||||
assert.equal(expectedDiagnosticCodes[i], diagnostics[i] && diagnostics[i].code, `Could not find expeced diagnostic.`);
|
||||
}
|
||||
assert.equal(diagnostics.length, expectedDiagnosticCodes.length, "Resuting diagnostics count does not match expected");
|
||||
|
||||
if (expectedOutput !== undefined) {
|
||||
assert.equal(result, expectedOutput);
|
||||
}
|
||||
}
|
||||
|
||||
it("Generates correct compilerOptions diagnostics", () => {
|
||||
// Expecting 5047: "Option 'isolatedModules' can only be used when either option'--module' is provided or option 'target' is 'ES6' or higher."
|
||||
runTest(`var x = 0;`, {}, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [5047]);
|
||||
});
|
||||
|
||||
it("Generates no diagnostics with valid inputs", () => {
|
||||
// No errors
|
||||
runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
|
||||
});
|
||||
|
||||
it("Generates no diagnostics for missing file references", () => {
|
||||
runTest(`/// <reference path="file2.ts" />
|
||||
var x = 0;`,
|
||||
{ module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
|
||||
});
|
||||
|
||||
it("Generates no diagnostics for missing module imports", () => {
|
||||
runTest(`import {a} from "module2";`,
|
||||
{ module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
|
||||
});
|
||||
|
||||
it("Generates expected syntactic diagnostics", () => {
|
||||
runTest(`a b`,
|
||||
{ module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [1005]); /// 1005: ';' Expected
|
||||
});
|
||||
|
||||
it("Does not generate semantic diagnostics", () => {
|
||||
runTest(`var x: string = 0;`,
|
||||
{ module: ModuleKind.CommonJS }, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
|
||||
});
|
||||
|
||||
it("Generates module output", () => {
|
||||
runTest(`var x = 0;`, { module: ModuleKind.AMD }, `define(["require", "exports"], function (require, exports) {\r\n var x = 0;\r\n});\r\n`);
|
||||
});
|
||||
|
||||
it("Uses correct newLine character", () => {
|
||||
runTest(`var x = 0;`, { module: ModuleKind.CommonJS, newLine: NewLineKind.LineFeed }, `var x = 0;\n`, /*expectedDiagnosticCodes*/ []);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user