Merge branch 'master' into extendsExpressions

Conflicts:
	src/compiler/checker.ts
	tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt
This commit is contained in:
Anders Hejlsberg
2015-06-16 12:04:04 -07:00
135 changed files with 1963 additions and 1102 deletions

View File

@@ -1,8 +1,11 @@
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts(2,4): error TS1123: Variable declaration list cannot be empty.
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts(2,1): error TS1212: Identifier expected. 'let' is a reserved word in strict mode
tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts(2,1): error TS2304: Cannot find name 'let'.
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts (1 errors) ====
==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration11_es6.ts (2 errors) ====
"use strict";
let
!!! error TS1123: Variable declaration list cannot be empty.
~~~
!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode
~~~
!!! error TS2304: Cannot find name 'let'.

View File

@@ -4,4 +4,4 @@ let
//// [VariableDeclaration11_es6.js]
"use strict";
let ;
let;

View File

@@ -1,8 +1,14 @@
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1163: A 'yield' expression is only allowed in a generator body.
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS1212: Identifier expected. 'yield' is a reserved word in strict mode
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,1): error TS2304: Cannot find name 'yield'.
tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts(2,7): error TS2304: Cannot find name 'foo'.
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (1 errors) ====
==== tests/cases/conformance/es6/yieldExpressions/YieldExpression18_es6.ts (3 errors) ====
"use strict";
yield(foo);
~~~~~
!!! error TS1163: A 'yield' expression is only allowed in a generator body.
!!! error TS1212: Identifier expected. 'yield' is a reserved word in strict mode
~~~~~
!!! error TS2304: Cannot find name 'yield'.
~~~
!!! error TS2304: Cannot find name 'foo'.

View File

@@ -4,4 +4,4 @@ yield(foo);
//// [YieldExpression18_es6.js]
"use strict";
yield (foo);
yield(foo);

View File

@@ -1,10 +1,10 @@
tests/cases/compiler/class2.ts(1,29): error TS1129: Statement expected.
tests/cases/compiler/class2.ts(1,29): error TS1128: Declaration or statement expected.
tests/cases/compiler/class2.ts(1,45): error TS1128: Declaration or statement expected.
==== tests/cases/compiler/class2.ts (2 errors) ====
class foo { constructor() { static f = 3; } }
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~
!!! error TS1128: Declaration or statement expected.

View File

@@ -6,14 +6,14 @@ tests/cases/compiler/classUpdateTests.ts(63,7): error TS2415: Class 'L' incorrec
tests/cases/compiler/classUpdateTests.ts(69,7): error TS2415: Class 'M' incorrectly extends base class 'G'.
Property 'p1' is private in type 'M' but not in type 'G'.
tests/cases/compiler/classUpdateTests.ts(70,2): error TS2376: A 'super' call must be the first statement in the constructor when a class contains initialized properties or has parameter properties.
tests/cases/compiler/classUpdateTests.ts(93,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(93,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(95,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(99,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(99,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(101,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(105,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(105,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(105,14): error TS1005: ';' expected.
tests/cases/compiler/classUpdateTests.ts(107,1): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(111,3): error TS1129: Statement expected.
tests/cases/compiler/classUpdateTests.ts(111,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/classUpdateTests.ts(111,15): error TS1005: ';' expected.
tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or statement expected.
@@ -133,7 +133,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st
constructor() {
public p1 = 0; // ERROR
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
}
}
~
@@ -143,7 +143,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st
constructor() {
private p1 = 0; // ERROR
~~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
}
}
~
@@ -153,7 +153,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st
constructor() {
public this.p1 = 0; // ERROR
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~
!!! error TS1005: ';' expected.
}
@@ -165,7 +165,7 @@ tests/cases/compiler/classUpdateTests.ts(113,1): error TS1128: Declaration or st
constructor() {
private this.p1 = 0; // ERROR
~~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~
!!! error TS1005: ';' expected.
}

View File

@@ -5,7 +5,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,35): error TS
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(22,39): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,28): error TS1005: ':' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,29): error TS1005: ',' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,18): error TS1129: Statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,18): error TS1128: Declaration or statement expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,26): error TS2304: Cannot find name 'bfs'.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,30): error TS1005: '=' expected.
tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(31,18): error TS1109: Expression expected.
@@ -129,7 +129,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS
case = bfs.STATEMENTS(4);
~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~
!!! error TS2304: Cannot find name 'bfs'.
if (retValue != 0) {

View File

@@ -0,0 +1,39 @@
//// [cyclicGenericTypeInstantiationInference.ts]
function foo<T>() {
var z = foo<typeof y>();
var y: {
y2: typeof z
};
return y;
}
function bar<T>() {
var z = bar<typeof y>();
var y: {
y2: typeof z;
}
return y;
}
var a = foo<number>();
var b = bar<number>();
function test<T>(x: typeof a): void { }
test(b);
//// [cyclicGenericTypeInstantiationInference.js]
function foo() {
var z = foo();
var y;
return y;
}
function bar() {
var z = bar();
var y;
return y;
}
var a = foo();
var b = bar();
function test(x) { }
test(b);

View File

@@ -0,0 +1,61 @@
=== tests/cases/compiler/cyclicGenericTypeInstantiationInference.ts ===
function foo<T>() {
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0))
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 13))
var z = foo<typeof y>();
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 1, 7))
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0))
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7))
var y: {
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7))
y2: typeof z
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 12))
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 1, 7))
};
return y;
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 2, 7))
}
function bar<T>() {
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1))
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 9, 13))
var z = bar<typeof y>();
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 10, 7))
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1))
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7))
var y: {
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7))
y2: typeof z;
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 12))
>z : Symbol(z, Decl(cyclicGenericTypeInstantiationInference.ts, 10, 7))
}
return y;
>y : Symbol(y, Decl(cyclicGenericTypeInstantiationInference.ts, 11, 7))
}
var a = foo<number>();
>a : Symbol(a, Decl(cyclicGenericTypeInstantiationInference.ts, 17, 3))
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiationInference.ts, 0, 0))
var b = bar<number>();
>b : Symbol(b, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 3))
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiationInference.ts, 6, 1))
function test<T>(x: typeof a): void { }
>test : Symbol(test, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 22))
>T : Symbol(T, Decl(cyclicGenericTypeInstantiationInference.ts, 20, 14))
>x : Symbol(x, Decl(cyclicGenericTypeInstantiationInference.ts, 20, 17))
>a : Symbol(a, Decl(cyclicGenericTypeInstantiationInference.ts, 17, 3))
test(b);
>test : Symbol(test, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 22))
>b : Symbol(b, Decl(cyclicGenericTypeInstantiationInference.ts, 18, 3))

View File

@@ -0,0 +1,66 @@
=== tests/cases/compiler/cyclicGenericTypeInstantiationInference.ts ===
function foo<T>() {
>foo : <T>() => { y2: any; }
>T : T
var z = foo<typeof y>();
>z : { y2: any; }
>foo<typeof y>() : { y2: any; }
>foo : <T>() => { y2: any; }
>y : { y2: any; }
var y: {
>y : { y2: any; }
y2: typeof z
>y2 : { y2: any; }
>z : { y2: any; }
};
return y;
>y : { y2: any; }
}
function bar<T>() {
>bar : <T>() => { y2: any; }
>T : T
var z = bar<typeof y>();
>z : { y2: any; }
>bar<typeof y>() : { y2: any; }
>bar : <T>() => { y2: any; }
>y : { y2: any; }
var y: {
>y : { y2: any; }
y2: typeof z;
>y2 : { y2: any; }
>z : { y2: any; }
}
return y;
>y : { y2: any; }
}
var a = foo<number>();
>a : { y2: any; }
>foo<number>() : { y2: any; }
>foo : <T>() => { y2: any; }
var b = bar<number>();
>b : { y2: any; }
>bar<number>() : { y2: any; }
>bar : <T>() => { y2: any; }
function test<T>(x: typeof a): void { }
>test : <T>(x: { y2: any; }) => void
>T : T
>x : { y2: any; }
>a : { y2: any; }
test(b);
>test(b) : void
>test : <T>(x: { y2: any; }) => void
>b : { y2: any; }

View File

@@ -1,9 +1,10 @@
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,20): error TS1005: ',' expected.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(5,27): error TS1109: Expression expected.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(8,23): error TS1109: Expression expected.
tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts(13,16): error TS1102: 'delete' cannot be called on an identifier in strict mode.
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (3 errors) ====
==== tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperatorInvalidOperations.ts (4 errors) ====
// Unary operator delete
var ANY;
@@ -23,5 +24,7 @@ tests/cases/conformance/expressions/unaryOperators/deleteOperator/deleteOperator
class testADelx {
constructor(public s: () => {}) {
delete s; //expect error
~
!!! error TS1102: 'delete' cannot be called on an identifier in strict mode.
}
}

View File

@@ -1,8 +1,11 @@
tests/cases/compiler/downlevelLetConst11.ts(2,4): error TS1123: Variable declaration list cannot be empty.
tests/cases/compiler/downlevelLetConst11.ts(2,1): error TS1212: Identifier expected. 'let' is a reserved word in strict mode
tests/cases/compiler/downlevelLetConst11.ts(2,1): error TS2304: Cannot find name 'let'.
==== tests/cases/compiler/downlevelLetConst11.ts (1 errors) ====
==== tests/cases/compiler/downlevelLetConst11.ts (2 errors) ====
"use strict";
let
!!! error TS1123: Variable declaration list cannot be empty.
~~~
!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode
~~~
!!! error TS2304: Cannot find name 'let'.

View File

@@ -4,4 +4,4 @@ let
//// [downlevelLetConst11.js]
"use strict";
var ;
let;

View File

@@ -0,0 +1,18 @@
tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts(4,15): error TS1003: Identifier expected.
tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts(9,2): error TS1005: '}' expected.
==== tests/cases/compiler/errorRecoveryWithDotFollowedByNamespaceKeyword.ts (2 errors) ====
namespace A {
function foo() {
if (true) {
B.
!!! error TS1003: Identifier expected.
namespace B {
export function baz() { }
}
!!! error TS1005: '}' expected.

View File

@@ -0,0 +1,26 @@
//// [errorRecoveryWithDotFollowedByNamespaceKeyword.ts]
namespace A {
function foo() {
if (true) {
B.
namespace B {
export function baz() { }
}
//// [errorRecoveryWithDotFollowedByNamespaceKeyword.js]
var A;
(function (A) {
function foo() {
if (true) {
B.
;
var B;
(function (B) {
function baz() { }
B.baz = baz;
})(B || (B = {}));
}
}
})(A || (A = {}));

View File

@@ -1,15 +1,18 @@
tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts(2,4): error TS1123: Variable declaration list cannot be empty.
tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts(3,1): error TS2304: Cannot find name 'let'.
tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts(4,6): error TS1123: Variable declaration list cannot be empty.
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts (3 errors) ====
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesAMD.ts (4 errors) ====
var;
!!! error TS1123: Variable declaration list cannot be empty.
let;
~~~
!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~
!!! error TS2304: Cannot find name 'let'.
const;

View File

@@ -1,15 +1,18 @@
tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts(2,4): error TS1123: Variable declaration list cannot be empty.
tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts(3,1): error TS2304: Cannot find name 'let'.
tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts(4,6): error TS1123: Variable declaration list cannot be empty.
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts (3 errors) ====
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesCommonJS.ts (4 errors) ====
var;
!!! error TS1123: Variable declaration list cannot be empty.
let;
~~~
!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~
!!! error TS2304: Cannot find name 'let'.
const;

View File

@@ -1,15 +1,18 @@
tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts(2,4): error TS1123: Variable declaration list cannot be empty.
tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts(3,1): error TS2304: Cannot find name 'let'.
tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts(4,6): error TS1123: Variable declaration list cannot be empty.
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts (3 errors) ====
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesES6.ts (4 errors) ====
var;
!!! error TS1123: Variable declaration list cannot be empty.
let;
~~~
!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~
!!! error TS2304: Cannot find name 'let'.
const;

View File

@@ -1,15 +1,18 @@
tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts(2,4): error TS1123: Variable declaration list cannot be empty.
tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts(3,1): error TS2304: Cannot find name 'let'.
tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts(4,6): error TS1123: Variable declaration list cannot be empty.
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts (3 errors) ====
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesSystem.ts (4 errors) ====
var;
!!! error TS1123: Variable declaration list cannot be empty.
let;
~~~
!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~
!!! error TS2304: Cannot find name 'let'.
const;

View File

@@ -1,15 +1,18 @@
tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts(2,4): error TS1123: Variable declaration list cannot be empty.
tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts(3,1): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts(3,1): error TS2304: Cannot find name 'let'.
tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts(4,6): error TS1123: Variable declaration list cannot be empty.
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts (3 errors) ====
==== tests/cases/conformance/externalModules/exportNonInitializedVariablesUMD.ts (4 errors) ====
var;
!!! error TS1123: Variable declaration list cannot be empty.
let;
~~~
!!! error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~
!!! error TS2304: Cannot find name 'let'.
const;

View File

@@ -0,0 +1,23 @@
tests/cases/conformance/es6/modules/t3.ts(1,17): error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
==== tests/cases/conformance/es6/modules/t1.ts (0 errors) ====
let set = {
set foo(x: number) {
}
}
let get = 10;
export { set, get };
==== tests/cases/conformance/es6/modules/t2.ts (0 errors) ====
import * as set from "./t1";
==== tests/cases/conformance/es6/modules/t3.ts (1 errors) ====
import { set as yield } from "./t1";
~~~~~
!!! error TS1214: Identifier expected. 'yield' is a reserved word in strict mode. Modules are automatically in strict mode.
==== tests/cases/conformance/es6/modules/t4.ts (0 errors) ====
import { get } from "./t1";

View File

@@ -1,30 +0,0 @@
=== tests/cases/conformance/es6/modules/t1.ts ===
let set = {
>set : Symbol(set, Decl(t1.ts, 1, 3))
set foo(x: number) {
>foo : Symbol(foo, Decl(t1.ts, 1, 11))
>x : Symbol(x, Decl(t1.ts, 2, 12))
}
}
let get = 10;
>get : Symbol(get, Decl(t1.ts, 5, 3))
export { set, get };
>set : Symbol(set, Decl(t1.ts, 7, 8))
>get : Symbol(get, Decl(t1.ts, 7, 13))
=== tests/cases/conformance/es6/modules/t2.ts ===
import * as set from "./t1";
>set : Symbol(set, Decl(t2.ts, 0, 6))
=== tests/cases/conformance/es6/modules/t3.ts ===
import { set as yield } from "./t1";
>set : Symbol(yield, Decl(t3.ts, 0, 8))
>yield : Symbol(yield, Decl(t3.ts, 0, 8))
=== tests/cases/conformance/es6/modules/t4.ts ===
import { get } from "./t1";
>get : Symbol(get, Decl(t4.ts, 0, 8))

View File

@@ -1,32 +0,0 @@
=== tests/cases/conformance/es6/modules/t1.ts ===
let set = {
>set : { foo: number; }
>{ set foo(x: number) { }} : { foo: number; }
set foo(x: number) {
>foo : number
>x : number
}
}
let get = 10;
>get : number
>10 : number
export { set, get };
>set : { foo: number; }
>get : number
=== tests/cases/conformance/es6/modules/t2.ts ===
import * as set from "./t1";
>set : typeof set
=== tests/cases/conformance/es6/modules/t3.ts ===
import { set as yield } from "./t1";
>set : { foo: number; }
>yield : { foo: number; }
=== tests/cases/conformance/es6/modules/t4.ts ===
import { get } from "./t1";
>get : number

View File

@@ -0,0 +1,24 @@
tests/cases/compiler/genericTypeConstraints.ts(9,27): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
Property 'fooMethod' is missing in type 'FooExtended'.
tests/cases/compiler/genericTypeConstraints.ts(9,31): error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
==== tests/cases/compiler/genericTypeConstraints.ts (2 errors) ====
class Foo {
fooMethod() {}
}
class FooExtended { }
class Bar<T extends Foo> { }
class BarExtended extends Bar<FooExtended> {
~~~~~~~~~~~~~~~~
!!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
!!! error TS2344: Property 'fooMethod' is missing in type 'FooExtended'.
~~~~~~~~~~~
!!! error TS2344: Type 'FooExtended' does not satisfy the constraint 'Foo'.
constructor() {
super();
}
}

View File

@@ -0,0 +1,45 @@
//// [genericTypeConstraints.ts]
class Foo {
fooMethod() {}
}
class FooExtended { }
class Bar<T extends Foo> { }
class BarExtended extends Bar<FooExtended> {
constructor() {
super();
}
}
//// [genericTypeConstraints.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var Foo = (function () {
function Foo() {
}
Foo.prototype.fooMethod = function () { };
return Foo;
})();
var FooExtended = (function () {
function FooExtended() {
}
return FooExtended;
})();
var Bar = (function () {
function Bar() {
}
return Bar;
})();
var BarExtended = (function (_super) {
__extends(BarExtended, _super);
function BarExtended() {
_super.call(this);
}
return BarExtended;
})(Bar);

View File

@@ -0,0 +1,19 @@
//// [isArray.ts]
var maybeArray: number | number[];
if (Array.isArray(maybeArray)) {
maybeArray.length; // OK
}
else {
maybeArray.toFixed(); // OK
}
//// [isArray.js]
var maybeArray;
if (Array.isArray(maybeArray)) {
maybeArray.length; // OK
}
else {
maybeArray.toFixed(); // OK
}

View File

@@ -0,0 +1,22 @@
=== tests/cases/compiler/isArray.ts ===
var maybeArray: number | number[];
>maybeArray : Symbol(maybeArray, Decl(isArray.ts, 0, 3))
if (Array.isArray(maybeArray)) {
>Array.isArray : Symbol(ArrayConstructor.isArray, Decl(lib.d.ts, 1166, 28))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>isArray : Symbol(ArrayConstructor.isArray, Decl(lib.d.ts, 1166, 28))
>maybeArray : Symbol(maybeArray, Decl(isArray.ts, 0, 3))
maybeArray.length; // OK
>maybeArray.length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
>maybeArray : Symbol(maybeArray, Decl(isArray.ts, 0, 3))
>length : Symbol(Array.length, Decl(lib.d.ts, 1007, 20))
}
else {
maybeArray.toFixed(); // OK
>maybeArray.toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, 463, 37))
>maybeArray : Symbol(maybeArray, Decl(isArray.ts, 0, 3))
>toFixed : Symbol(Number.toFixed, Decl(lib.d.ts, 463, 37))
}

View File

@@ -0,0 +1,24 @@
=== tests/cases/compiler/isArray.ts ===
var maybeArray: number | number[];
>maybeArray : number | number[]
if (Array.isArray(maybeArray)) {
>Array.isArray(maybeArray) : boolean
>Array.isArray : (arg: any) => boolean
>Array : ArrayConstructor
>isArray : (arg: any) => boolean
>maybeArray : number | number[]
maybeArray.length; // OK
>maybeArray.length : number
>maybeArray : number[]
>length : number
}
else {
maybeArray.toFixed(); // OK
>maybeArray.toFixed() : string
>maybeArray.toFixed : (fractionDigits?: number) => string
>maybeArray : number
>toFixed : (fractionDigits?: number) => string
}

View File

@@ -0,0 +1,15 @@
tests/cases/compiler/letAsIdentifier.ts(3,5): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/letAsIdentifier.ts(6,1): error TS2300: Duplicate identifier 'a'.
==== tests/cases/compiler/letAsIdentifier.ts (2 errors) ====
var let = 10;
var a = 10;
~
!!! error TS2300: Duplicate identifier 'a'.
let = 30;
let
a;
~
!!! error TS2300: Duplicate identifier 'a'.

View File

@@ -10,10 +10,10 @@ a;
var let = 10;
var a = 10;
let = 30;
let;
a;
var a;
//// [letAsIdentifier.d.ts]
declare var let: number;
declare var a: number;
declare let a: any;

View File

@@ -1,17 +0,0 @@
=== tests/cases/compiler/letAsIdentifier.ts ===
var let = 10;
>let : Symbol(let, Decl(letAsIdentifier.ts, 1, 3))
var a = 10;
>a : Symbol(a, Decl(letAsIdentifier.ts, 2, 3))
let = 30;
>let : Symbol(let, Decl(letAsIdentifier.ts, 1, 3))
let
>let : Symbol(let, Decl(letAsIdentifier.ts, 1, 3))
a;
>a : Symbol(a, Decl(letAsIdentifier.ts, 2, 3))

View File

@@ -1,21 +0,0 @@
=== tests/cases/compiler/letAsIdentifier.ts ===
var let = 10;
>let : number
>10 : number
var a = 10;
>a : number
>10 : number
let = 30;
>let = 30 : number
>let : number
>30 : number
let
>let : number
a;
>a : number

View File

@@ -1,20 +1,20 @@
tests/cases/compiler/letAsIdentifierInStrictMode.ts(2,5): error TS1212: Identifier expected. 'let' is a reserved word in strict mode
tests/cases/compiler/letAsIdentifierInStrictMode.ts(3,5): error TS2300: Duplicate identifier 'a'.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,5): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,7): error TS1134: Variable declaration expected.
tests/cases/compiler/letAsIdentifierInStrictMode.ts(4,1): error TS1212: Identifier expected. 'let' is a reserved word in strict mode
tests/cases/compiler/letAsIdentifierInStrictMode.ts(6,1): error TS2300: Duplicate identifier 'a'.
==== tests/cases/compiler/letAsIdentifierInStrictMode.ts (4 errors) ====
"use strict";
var let = 10;
~~~
!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode
var a = 10;
~
!!! error TS2300: Duplicate identifier 'a'.
let = 30;
~
!!! error TS1134: Variable declaration expected.
~~
!!! error TS1134: Variable declaration expected.
~~~
!!! error TS1212: Identifier expected. 'let' is a reserved word in strict mode
let
a;
~

View File

@@ -10,6 +10,5 @@ a;
"use strict";
var let = 10;
var a = 10;
var ;
30;
let = 30;
var a;

View File

@@ -2,22 +2,22 @@
// Array.prototype.slice can have zero, one, or two arguments
Array.prototype.slice();
>Array.prototype.slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15))
>Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 31))
>Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 41))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 31))
>prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 41))
>slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15))
Array.prototype.slice(0);
>Array.prototype.slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15))
>Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 31))
>Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 41))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 31))
>prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 41))
>slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15))
Array.prototype.slice(0, 1);
>Array.prototype.slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15))
>Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 31))
>Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 41))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 31))
>prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 41))
>slice : Symbol(Array.slice, Decl(lib.d.ts, 1048, 15))

View File

@@ -0,0 +1,87 @@
tests/cases/compiler/moduleElementsInWrongContext.ts(2,5): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext.ts(3,5): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext.ts(7,5): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext.ts(9,5): error TS1234: An ambient module declaration is only allowed at the top level in a file.
tests/cases/compiler/moduleElementsInWrongContext.ts(13,5): error TS1231: An export assignment can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext.ts(17,5): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext.ts(18,5): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext.ts(19,5): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext.ts(19,14): error TS2305: Module '"ambient"' has no exported member 'baz'.
tests/cases/compiler/moduleElementsInWrongContext.ts(20,5): error TS1231: An export assignment can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext.ts(21,5): error TS1184: Modifiers cannot appear here.
tests/cases/compiler/moduleElementsInWrongContext.ts(22,5): error TS1184: Modifiers cannot appear here.
tests/cases/compiler/moduleElementsInWrongContext.ts(23,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext.ts(24,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext.ts(25,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext.ts(26,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext.ts(27,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext.ts(28,5): error TS1232: An import declaration can only be used in a namespace or module.
==== tests/cases/compiler/moduleElementsInWrongContext.ts (18 errors) ====
{
module M { }
~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
export namespace N {
~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
export interface I { }
}
namespace Q.K { }
~~~~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
declare module "ambient" {
~~~~~~~
!!! error TS1234: An ambient module declaration is only allowed at the top level in a file.
}
export = M;
~~~~~~
!!! error TS1231: An export assignment can only be used in a module.
var v;
function foo() { }
export * from "ambient";
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
export { foo };
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
export { baz as b } from "ambient";
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
~~~
!!! error TS2305: Module '"ambient"' has no exported member 'baz'.
export default v;
~~~~~~
!!! error TS1231: An export assignment can only be used in a module.
export default class C { }
~~~~~~
!!! error TS1184: Modifiers cannot appear here.
export function bee() { }
~~~~~~
!!! error TS1184: Modifiers cannot appear here.
import I = M;
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import I2 = require("foo");
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import * as Foo from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import bar from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import { baz } from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
}

View File

@@ -0,0 +1,47 @@
//// [moduleElementsInWrongContext.ts]
{
module M { }
export namespace N {
export interface I { }
}
namespace Q.K { }
declare module "ambient" {
}
export = M;
var v;
function foo() { }
export * from "ambient";
export { foo };
export { baz as b } from "ambient";
export default v;
export default class C { }
export function bee() { }
import I = M;
import I2 = require("foo");
import * as Foo from "ambient";
import bar from "ambient";
import { baz } from "ambient";
import "ambient";
}
//// [moduleElementsInWrongContext.js]
{
var v;
function foo() { }
__export(require("ambient"));
exports["default"] = v;
var C = (function () {
function C() {
}
return C;
})();
exports["default"] = C;
function bee() { }
exports.bee = bee;
}

View File

@@ -0,0 +1,87 @@
tests/cases/compiler/moduleElementsInWrongContext2.ts(2,5): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(3,5): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(7,5): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(9,5): error TS1234: An ambient module declaration is only allowed at the top level in a file.
tests/cases/compiler/moduleElementsInWrongContext2.ts(13,5): error TS1231: An export assignment can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(17,5): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(18,5): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(19,5): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(19,30): error TS2307: Cannot find module 'ambient'.
tests/cases/compiler/moduleElementsInWrongContext2.ts(20,5): error TS1231: An export assignment can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(21,5): error TS1184: Modifiers cannot appear here.
tests/cases/compiler/moduleElementsInWrongContext2.ts(22,5): error TS1184: Modifiers cannot appear here.
tests/cases/compiler/moduleElementsInWrongContext2.ts(23,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(24,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(25,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(26,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(27,5): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext2.ts(28,5): error TS1232: An import declaration can only be used in a namespace or module.
==== tests/cases/compiler/moduleElementsInWrongContext2.ts (18 errors) ====
function blah () {
module M { }
~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
export namespace N {
~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
export interface I { }
}
namespace Q.K { }
~~~~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
declare module "ambient" {
~~~~~~~
!!! error TS1234: An ambient module declaration is only allowed at the top level in a file.
}
export = M;
~~~~~~
!!! error TS1231: An export assignment can only be used in a module.
var v;
function foo() { }
export * from "ambient";
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
export { foo };
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
export { baz as b } from "ambient";
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
~~~~~~~~~
!!! error TS2307: Cannot find module 'ambient'.
export default v;
~~~~~~
!!! error TS1231: An export assignment can only be used in a module.
export default class C { }
~~~~~~
!!! error TS1184: Modifiers cannot appear here.
export function bee() { }
~~~~~~
!!! error TS1184: Modifiers cannot appear here.
import I = M;
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import I2 = require("foo");
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import * as Foo from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import bar from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import { baz } from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
}

View File

@@ -0,0 +1,47 @@
//// [moduleElementsInWrongContext2.ts]
function blah () {
module M { }
export namespace N {
export interface I { }
}
namespace Q.K { }
declare module "ambient" {
}
export = M;
var v;
function foo() { }
export * from "ambient";
export { foo };
export { baz as b } from "ambient";
export default v;
export default class C { }
export function bee() { }
import I = M;
import I2 = require("foo");
import * as Foo from "ambient";
import bar from "ambient";
import { baz } from "ambient";
import "ambient";
}
//// [moduleElementsInWrongContext2.js]
function blah() {
var v;
function foo() { }
__export(require("ambient"));
exports["default"] = v;
var C = (function () {
function C() {
}
return C;
})();
exports["default"] = C;
function bee() { }
exports.bee = bee;
}

View File

@@ -0,0 +1,88 @@
tests/cases/compiler/moduleElementsInWrongContext3.ts(3,9): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(4,9): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(8,9): error TS1235: A namespace declaration is only allowed in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(10,9): error TS1234: An ambient module declaration is only allowed at the top level in a file.
tests/cases/compiler/moduleElementsInWrongContext3.ts(14,9): error TS1231: An export assignment can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(18,9): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(19,9): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(20,9): error TS1233: An export declaration can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(20,34): error TS2307: Cannot find module 'ambient'.
tests/cases/compiler/moduleElementsInWrongContext3.ts(21,9): error TS1231: An export assignment can only be used in a module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(22,9): error TS1184: Modifiers cannot appear here.
tests/cases/compiler/moduleElementsInWrongContext3.ts(23,9): error TS1184: Modifiers cannot appear here.
tests/cases/compiler/moduleElementsInWrongContext3.ts(24,9): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(25,9): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(26,9): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(27,9): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(28,9): error TS1232: An import declaration can only be used in a namespace or module.
tests/cases/compiler/moduleElementsInWrongContext3.ts(29,9): error TS1232: An import declaration can only be used in a namespace or module.
==== tests/cases/compiler/moduleElementsInWrongContext3.ts (18 errors) ====
module P {
{
module M { }
~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
export namespace N {
~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
export interface I { }
}
namespace Q.K { }
~~~~~~~~~
!!! error TS1235: A namespace declaration is only allowed in a namespace or module.
declare module "ambient" {
~~~~~~~
!!! error TS1234: An ambient module declaration is only allowed at the top level in a file.
}
export = M;
~~~~~~
!!! error TS1231: An export assignment can only be used in a module.
var v;
function foo() { }
export * from "ambient";
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
export { foo };
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
export { baz as b } from "ambient";
~~~~~~
!!! error TS1233: An export declaration can only be used in a module.
~~~~~~~~~
!!! error TS2307: Cannot find module 'ambient'.
export default v;
~~~~~~
!!! error TS1231: An export assignment can only be used in a module.
export default class C { }
~~~~~~
!!! error TS1184: Modifiers cannot appear here.
export function bee() { }
~~~~~~
!!! error TS1184: Modifiers cannot appear here.
import I = M;
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import I2 = require("foo");
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import * as Foo from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import bar from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import { baz } from "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
import "ambient";
~~~~~~
!!! error TS1232: An import declaration can only be used in a namespace or module.
}
}

View File

@@ -0,0 +1,51 @@
//// [moduleElementsInWrongContext3.ts]
module P {
{
module M { }
export namespace N {
export interface I { }
}
namespace Q.K { }
declare module "ambient" {
}
export = M;
var v;
function foo() { }
export * from "ambient";
export { foo };
export { baz as b } from "ambient";
export default v;
export default class C { }
export function bee() { }
import I = M;
import I2 = require("foo");
import * as Foo from "ambient";
import bar from "ambient";
import { baz } from "ambient";
import "ambient";
}
}
//// [moduleElementsInWrongContext3.js]
var P;
(function (P) {
{
var v;
function foo() { }
__export(require("ambient"));
P["default"] = v;
var C = (function () {
function C() {
}
return C;
})();
exports["default"] = C;
function bee() { }
P.bee = bee;
}
})(P || (P = {}));

View File

@@ -1,12 +1,12 @@
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(1,14): error TS1005: '(' expected.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(2,3): error TS1129: Statement expected.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(2,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(2,10): error TS2304: Cannot find name 'test'.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(3,3): error TS1129: Statement expected.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(3,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(3,10): error TS2304: Cannot find name 'test'.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(3,15): error TS2304: Cannot find name 'name'.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(3,19): error TS1005: ',' expected.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(3,20): error TS2304: Cannot find name 'string'.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(4,3): error TS1129: Statement expected.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(4,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(4,10): error TS2304: Cannot find name 'test'.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(4,15): error TS2304: Cannot find name 'name'.
tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(4,20): error TS1109: Expression expected.
@@ -20,12 +20,12 @@ tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(4,25): error TS100
!!! error TS1005: '(' expected.
static test()
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~~
!!! error TS2304: Cannot find name 'test'.
static test(name:string)
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~~
!!! error TS2304: Cannot find name 'test'.
~~~~
@@ -36,7 +36,7 @@ tests/cases/compiler/overloadingStaticFunctionsInFunctions.ts(4,25): error TS100
!!! error TS2304: Cannot find name 'string'.
static test(name?:any){ }
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~~
!!! error TS2304: Cannot find name 'test'.
~~~~

View File

@@ -18,7 +18,6 @@ error TS2318: Cannot find global type 'String'.
!!! error TS2318: Cannot find global type 'String'.
==== tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509698.ts (0 errors) ====
/// <style requireSemi="on" />
/// <reference no-default-lib="true"/>
declare function foo(): void;
declare function bar(): void;

View File

@@ -1,6 +1,5 @@
//// [parser509698.ts]
/// <style requireSemi="on" />
/// <reference no-default-lib="true"/>
declare function foo(): void;
declare function bar(): void;

View File

@@ -1,4 +1,4 @@
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21): error TS1216: Type expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21): error TS2304: Cannot find name 'public'.
@@ -7,7 +7,7 @@ tests/cases/conformance/parser/ecmascript5/RegressionTests/parser553699.ts(3,21)
constructor() { }
public banana (x: public) { }
~~~~~~
!!! error TS1216: Type expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~
!!! error TS2304: Cannot find name 'public'.
}

View File

@@ -1,5 +1,5 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErrorRecoveryIfStatement6.ts(3,9): error TS2304: Cannot find name 'a'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErrorRecoveryIfStatement6.ts(5,3): error TS1129: Statement expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErrorRecoveryIfStatement6.ts(5,3): error TS1128: Declaration or statement expected.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErrorRecoveryIfStatement6.ts (2 errors) ====
@@ -11,7 +11,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IfStatements/parserErro
}
public f2() {
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
}
f3() {
}

View File

@@ -1,5 +1,5 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(2,18): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,5): error TS1129: Statement expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,5): error TS1128: Declaration or statement expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecovery_Block3.ts(4,18): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
@@ -11,7 +11,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/Blocks/parserErrorRecov
private b(): boolean {
~~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~~~~~
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
}

View File

@@ -1,19 +1,13 @@
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,8): error TS2503: Cannot find namespace 'TypeModule1'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,8): error TS1005: '=' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,8): error TS2304: Cannot find name 'TypeModule2'.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(2,20): error TS1005: ',' expected.
tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts(1,20): error TS1003: Identifier expected.
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts (4 errors) ====
==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/parserUnfinishedTypeNameBeforeKeyword1.ts (2 errors) ====
var x: TypeModule1.
~~~~~~~~~~~
!!! error TS2503: Cannot find namespace 'TypeModule1'.
!!! error TS1003: Identifier expected.
module TypeModule2 {
~~~~~~~~~~~
!!! error TS1005: '=' expected.
~~~~~~~~~~~
!!! error TS2304: Cannot find name 'TypeModule2'.
~
!!! error TS1005: ',' expected.
}

View File

@@ -5,4 +5,4 @@ module TypeModule2 {
//// [parserUnfinishedTypeNameBeforeKeyword1.js]
var x = TypeModule2, _a = void 0;
var x;

View File

@@ -1,5 +1,5 @@
tests/cases/compiler/propertyWrappedInTry.ts(3,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected.
tests/cases/compiler/propertyWrappedInTry.ts(5,9): error TS1129: Statement expected.
tests/cases/compiler/propertyWrappedInTry.ts(5,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/propertyWrappedInTry.ts(5,16): error TS2304: Cannot find name 'bar'.
tests/cases/compiler/propertyWrappedInTry.ts(5,22): error TS2304: Cannot find name 'someInitThatMightFail'.
tests/cases/compiler/propertyWrappedInTry.ts(11,5): error TS1128: Declaration or statement expected.
@@ -17,7 +17,7 @@ tests/cases/compiler/propertyWrappedInTry.ts(17,1): error TS1128: Declaration or
public bar = someInitThatMightFail();
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~
!!! error TS2304: Cannot find name 'bar'.
~~~~~~~~~~~~~~~~~~~~~

View File

@@ -14,9 +14,9 @@ module M1 {
return Array.prototype.reduce.apply(ar, e ? [f, e] : [f]);
>Array.prototype.reduce.apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20))
>Array.prototype.reduce : Symbol(Array.reduce, Decl(lib.d.ts, 1129, 93), Decl(lib.d.ts, 1136, 120))
>Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 31))
>Array.prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 41))
>Array : Symbol(Array, Decl(lib.d.ts, 1000, 23), Decl(lib.d.ts, 1171, 11))
>prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 31))
>prototype : Symbol(ArrayConstructor.prototype, Decl(lib.d.ts, 1167, 41))
>reduce : Symbol(Array.reduce, Decl(lib.d.ts, 1129, 93), Decl(lib.d.ts, 1136, 120))
>apply : Symbol(Function.apply, Decl(lib.d.ts, 228, 20))
>ar : Symbol(ar, Decl(returnTypeParameterWithModules.ts, 1, 30))

View File

@@ -1,4 +1,4 @@
tests/cases/compiler/staticClassProps.ts(4,9): error TS1129: Statement expected.
tests/cases/compiler/staticClassProps.ts(4,9): error TS1128: Declaration or statement expected.
tests/cases/compiler/staticClassProps.ts(6,1): error TS1128: Declaration or statement expected.
@@ -8,7 +8,7 @@ tests/cases/compiler/staticClassProps.ts(6,1): error TS1128: Declaration or stat
public foo() {
static z = 1;
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
}
}
~

View File

@@ -1,12 +1,12 @@
tests/cases/compiler/staticsInAFunction.ts(1,13): error TS1005: '(' expected.
tests/cases/compiler/staticsInAFunction.ts(2,4): error TS1129: Statement expected.
tests/cases/compiler/staticsInAFunction.ts(2,4): error TS1128: Declaration or statement expected.
tests/cases/compiler/staticsInAFunction.ts(2,11): error TS2304: Cannot find name 'test'.
tests/cases/compiler/staticsInAFunction.ts(3,4): error TS1129: Statement expected.
tests/cases/compiler/staticsInAFunction.ts(3,4): error TS1128: Declaration or statement expected.
tests/cases/compiler/staticsInAFunction.ts(3,11): error TS2304: Cannot find name 'test'.
tests/cases/compiler/staticsInAFunction.ts(3,16): error TS2304: Cannot find name 'name'.
tests/cases/compiler/staticsInAFunction.ts(3,20): error TS1005: ',' expected.
tests/cases/compiler/staticsInAFunction.ts(3,21): error TS2304: Cannot find name 'string'.
tests/cases/compiler/staticsInAFunction.ts(4,4): error TS1129: Statement expected.
tests/cases/compiler/staticsInAFunction.ts(4,4): error TS1128: Declaration or statement expected.
tests/cases/compiler/staticsInAFunction.ts(4,11): error TS2304: Cannot find name 'test'.
tests/cases/compiler/staticsInAFunction.ts(4,16): error TS2304: Cannot find name 'name'.
tests/cases/compiler/staticsInAFunction.ts(4,21): error TS1109: Expression expected.
@@ -20,12 +20,12 @@ tests/cases/compiler/staticsInAFunction.ts(4,26): error TS1005: ';' expected.
!!! error TS1005: '(' expected.
static test()
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~~
!!! error TS2304: Cannot find name 'test'.
static test(name:string)
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~~
!!! error TS2304: Cannot find name 'test'.
~~~~
@@ -36,7 +36,7 @@ tests/cases/compiler/staticsInAFunction.ts(4,26): error TS1005: ';' expected.
!!! error TS2304: Cannot find name 'string'.
static test(name?:any){}
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
~~~~
!!! error TS2304: Cannot find name 'test'.
~~~~

View File

@@ -1,4 +1,4 @@
tests/cases/compiler/staticsInConstructorBodies.ts(3,3): error TS1129: Statement expected.
tests/cases/compiler/staticsInConstructorBodies.ts(3,3): error TS1128: Declaration or statement expected.
tests/cases/compiler/staticsInConstructorBodies.ts(6,1): error TS1128: Declaration or statement expected.
@@ -7,7 +7,7 @@ tests/cases/compiler/staticsInConstructorBodies.ts(6,1): error TS1128: Declarati
constructor() {
static p1 = 0; // ERROR
~~~~~~
!!! error TS1129: Statement expected.
!!! error TS1128: Declaration or statement expected.
static m1() {} // ERROR
}
}

View File

@@ -16,30 +16,32 @@ tests/cases/compiler/strictModeReservedWord.ts(12,41): error TS1212: Identifier
tests/cases/compiler/strictModeReservedWord.ts(13,11): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(13,20): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(13,28): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(15,25): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWord.ts(15,25): error TS9003: 'class' expressions are not currently supported.
tests/cases/compiler/strictModeReservedWord.ts(15,41): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWord.ts(17,9): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS1215: Type expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(17,12): error TS2503: Cannot find namespace 'public'.
tests/cases/compiler/strictModeReservedWord.ts(19,21): error TS1215: Type expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(19,21): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(19,21): error TS2503: Cannot find namespace 'private'.
tests/cases/compiler/strictModeReservedWord.ts(20,22): error TS1215: Type expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(20,22): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(20,22): error TS2503: Cannot find namespace 'private'.
tests/cases/compiler/strictModeReservedWord.ts(20,30): error TS1215: Type expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,22): error TS1215: Type expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(20,30): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,22): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,22): error TS2503: Cannot find namespace 'private'.
tests/cases/compiler/strictModeReservedWord.ts(21,30): error TS1215: Type expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,38): error TS1215: Type expected. 'protected' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,30): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(21,38): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,9): error TS2300: Duplicate identifier 'b'.
tests/cases/compiler/strictModeReservedWord.ts(22,12): error TS1215: Type expected. 'interface' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,12): error TS1212: Identifier expected. 'interface' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,12): error TS2503: Cannot find namespace 'interface'.
tests/cases/compiler/strictModeReservedWord.ts(22,22): error TS1215: Type expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,30): error TS1215: Type expected. 'implements' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,22): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(22,30): error TS1212: Identifier expected. 'implements' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(23,5): error TS2304: Cannot find name 'ublic'.
tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS1212: Identifier expected. 'static' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invoke an expression whose type lacks a call signature.
==== tests/cases/compiler/strictModeReservedWord.ts (39 errors) ====
==== tests/cases/compiler/strictModeReservedWord.ts (41 errors) ====
let let = 10;
function foo() {
@@ -92,48 +94,52 @@ tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invok
var myClass = class package extends public {}
~~~~~~~
!!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode.
~~~~~~~
!!! error TS9003: 'class' expressions are not currently supported.
~~~~~~
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
var b: public.bar;
~
!!! error TS2300: Duplicate identifier 'b'.
~~~~~~
!!! error TS1215: Type expected. 'public' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
~~~~~~
!!! error TS2503: Cannot find namespace 'public'.
function foo(x: private.x) { }
~~~~~~~
!!! error TS1215: Type expected. 'private' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
~~~~~~~
!!! error TS2503: Cannot find namespace 'private'.
function foo1(x: private.package.x) { }
~~~~~~~
!!! error TS1215: Type expected. 'private' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
~~~~~~~
!!! error TS2503: Cannot find namespace 'private'.
~~~~~~~
!!! error TS1215: Type expected. 'package' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
function foo2(x: private.package.protected) { }
~~~~~~~
!!! error TS1215: Type expected. 'private' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
~~~~~~~
!!! error TS2503: Cannot find namespace 'private'.
~~~~~~~
!!! error TS1215: Type expected. 'package' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
~~~~~~~~~
!!! error TS1215: Type expected. 'protected' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
let b: interface.package.implements.B;
~
!!! error TS2300: Duplicate identifier 'b'.
~~~~~~~~~
!!! error TS1215: Type expected. 'interface' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'interface' is a reserved word in strict mode
~~~~~~~~~
!!! error TS2503: Cannot find namespace 'interface'.
~~~~~~~
!!! error TS1215: Type expected. 'package' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
~~~~~~~~~~
!!! error TS1215: Type expected. 'implements' is a reserved word in strict mode
!!! error TS1212: Identifier expected. 'implements' is a reserved word in strict mode
ublic();
~~~~~
!!! error TS2304: Cannot find name 'ublic'.

View File

@@ -4,13 +4,14 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(4,34): error TS
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(5,9): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(5,19): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(5,28): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(7,22): error TS1216: Type expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(7,22): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(11,24): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(11,32): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(13,10): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(13,19): error TS1213: Identifier expected. 'static' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(13,27): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(14,18): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(15,26): error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,9): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,17): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(23,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
@@ -44,7 +45,7 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T
}
public banana(x: public) { }
~~~~~~
!!! error TS1216: Type expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
!!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}
class C {
@@ -65,6 +66,8 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T
~~~
!!! error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
var z = function let() { };
~~~
!!! error TS1213: Identifier expected. 'let' is a reserved word in strict mode. Class definitions are automatically in strict mode.
}
public pulbic() { } // No Error;
@@ -97,4 +100,4 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T
!!! error TS2304: Cannot find name 'package'.
class H extends package.A { }
~~~~~~~
!!! error TS2304: Cannot find name 'package'.
!!! error TS2304: Cannot find name 'package'.

View File

@@ -3,8 +3,8 @@ tests/cases/compiler/strictModeReservedWordInDestructuring.ts(3,10): error TS121
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(4,7): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(5,15): error TS1212: Identifier expected. 'static' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(5,38): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,6): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,14): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,7): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,15): error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
==== tests/cases/compiler/strictModeReservedWordInDestructuring.ts (7 errors) ====
@@ -18,13 +18,15 @@ tests/cases/compiler/strictModeReservedWordInDestructuring.ts(6,14): error TS121
var [[private]] = [["hello"]];
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
var { y: { s: static }, z: { o: { p: package } }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
~~~~~~
!!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
var {public, protected} = { public: 1, protected: 2 };
~~~~~~
var { public, protected } = { public: 1, protected: 2 };
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
~~~~~~~~~
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
~~~~~~~~~
!!! error TS1212: Identifier expected. 'protected' is a reserved word in strict mode
var { public: a, protected: b } = { public: 1, protected: 2 };

View File

@@ -3,8 +3,10 @@
var [public] = [1];
var { x: public } = { x: 1 };
var [[private]] = [["hello"]];
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
var {public, protected} = { public: 1, protected: 2 };
var { y: { s: static }, z: { o: { p: package } }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
var { public, protected } = { public: 1, protected: 2 };
var { public: a, protected: b } = { public: 1, protected: 2 };
//// [strictModeReservedWordInDestructuring.js]
"use strict";
@@ -13,3 +15,4 @@ var public = { x: 1 }.x;
var private = [["hello"]][0][0];
var _a = { y: { s: 1 }, z: { o: { p: 'h' } } }, static = _a.y.s, package = _a.z.o.p;
var _b = { public: 1, protected: 2 }, public = _b.public, protected = _b.protected;
var _c = { public: 1, protected: 2 }, a = _c.public, b = _c.protected;

View File

@@ -1,4 +1,4 @@
tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,8): error TS1212: Identifier expected. 'public' is a reserved word in strict mode
tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,8): error TS1214: Identifier expected. 'public' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,25): error TS2307: Cannot find module '1'.
@@ -7,6 +7,6 @@ tests/cases/compiler/strictModeReservedWordInImportEqualDeclaration.ts(3,25): er
"use strict"
import public = require("1");
~~~~~~
!!! error TS1212: Identifier expected. 'public' is a reserved word in strict mode
!!! error TS1214: Identifier expected. 'public' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~
!!! error TS2307: Cannot find module '1'.

View File

@@ -1,22 +1,25 @@
tests/cases/compiler/strictModeWordInImportDeclaration.ts(2,13): error TS1212: Identifier expected. 'package' is a reserved word in strict mode
tests/cases/compiler/strictModeWordInImportDeclaration.ts(2,13): error TS1214: Identifier expected. 'package' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/compiler/strictModeWordInImportDeclaration.ts(2,26): error TS2307: Cannot find module './1'.
tests/cases/compiler/strictModeWordInImportDeclaration.ts(3,16): error TS1212: Identifier expected. 'private' is a reserved word in strict mode
tests/cases/compiler/strictModeWordInImportDeclaration.ts(3,16): error TS1214: Identifier expected. 'private' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/compiler/strictModeWordInImportDeclaration.ts(3,30): error TS2307: Cannot find module './1'.
tests/cases/compiler/strictModeWordInImportDeclaration.ts(4,8): error TS1214: Identifier expected. 'public' is a reserved word in strict mode. Modules are automatically in strict mode.
tests/cases/compiler/strictModeWordInImportDeclaration.ts(4,20): error TS2307: Cannot find module './1'.
==== tests/cases/compiler/strictModeWordInImportDeclaration.ts (5 errors) ====
==== tests/cases/compiler/strictModeWordInImportDeclaration.ts (6 errors) ====
"use strict"
import * as package from "./1"
~~~~~~~
!!! error TS1212: Identifier expected. 'package' is a reserved word in strict mode
!!! error TS1214: Identifier expected. 'package' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~~~
!!! error TS2307: Cannot find module './1'.
import {foo as private} from "./1"
~~~~~~~
!!! error TS1212: Identifier expected. 'private' is a reserved word in strict mode
!!! error TS1214: Identifier expected. 'private' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~~~
!!! error TS2307: Cannot find module './1'.
import public from "./1"
~~~~~~
!!! error TS1214: Identifier expected. 'public' is a reserved word in strict mode. Modules are automatically in strict mode.
~~~~~
!!! error TS2307: Cannot find module './1'.

View File

@@ -1,9 +1,7 @@
tests/cases/compiler/withStatementErrors.ts(3,7): error TS2410: All symbols within a 'with' block will be resolved to 'any'.
tests/cases/compiler/withStatementErrors.ts(15,5): error TS1129: Statement expected.
tests/cases/compiler/withStatementErrors.ts(17,1): error TS1128: Declaration or statement expected.
==== tests/cases/compiler/withStatementErrors.ts (3 errors) ====
==== tests/cases/compiler/withStatementErrors.ts (1 errors) ====
declare var ooo:any;
with (ooo.eee.oo.ah_ah.ting.tang.walla.walla) { // error
@@ -21,10 +19,6 @@ tests/cases/compiler/withStatementErrors.ts(17,1): error TS1128: Declaration or
interface I {} // error
module M {} // error
~~~~~~
!!! error TS1129: Statement expected.
}
~
!!! error TS1128: Declaration or statement expected.

View File

@@ -29,4 +29,4 @@ with (ooo.eee.oo.ah_ah.ting.tang.walla.walla) {
}
return C;
})(); // error
} // error
}

View File

@@ -0,0 +1,22 @@
function foo<T>() {
var z = foo<typeof y>();
var y: {
y2: typeof z
};
return y;
}
function bar<T>() {
var z = bar<typeof y>();
var y: {
y2: typeof z;
}
return y;
}
var a = foo<number>();
var b = bar<number>();
function test<T>(x: typeof a): void { }
test(b);

View File

@@ -0,0 +1,9 @@
namespace A {
function foo() {
if (true) {
B.
namespace B {
export function baz() { }
}

View File

@@ -0,0 +1,13 @@
class Foo {
fooMethod() {}
}
class FooExtended { }
class Bar<T extends Foo> { }
class BarExtended extends Bar<FooExtended> {
constructor() {
super();
}
}

View File

@@ -0,0 +1,9 @@
var maybeArray: number | number[];
if (Array.isArray(maybeArray)) {
maybeArray.length; // OK
}
else {
maybeArray.toFixed(); // OK
}

View File

@@ -0,0 +1,29 @@
{
module M { }
export namespace N {
export interface I { }
}
namespace Q.K { }
declare module "ambient" {
}
export = M;
var v;
function foo() { }
export * from "ambient";
export { foo };
export { baz as b } from "ambient";
export default v;
export default class C { }
export function bee() { }
import I = M;
import I2 = require("foo");
import * as Foo from "ambient";
import bar from "ambient";
import { baz } from "ambient";
import "ambient";
}

View File

@@ -0,0 +1,29 @@
function blah () {
module M { }
export namespace N {
export interface I { }
}
namespace Q.K { }
declare module "ambient" {
}
export = M;
var v;
function foo() { }
export * from "ambient";
export { foo };
export { baz as b } from "ambient";
export default v;
export default class C { }
export function bee() { }
import I = M;
import I2 = require("foo");
import * as Foo from "ambient";
import bar from "ambient";
import { baz } from "ambient";
import "ambient";
}

View File

@@ -0,0 +1,31 @@
module P {
{
module M { }
export namespace N {
export interface I { }
}
namespace Q.K { }
declare module "ambient" {
}
export = M;
var v;
function foo() { }
export * from "ambient";
export { foo };
export { baz as b } from "ambient";
export default v;
export default class C { }
export function bee() { }
import I = M;
import I2 = require("foo");
import * as Foo from "ambient";
import bar from "ambient";
import { baz } from "ambient";
import "ambient";
}
}

View File

@@ -2,5 +2,6 @@
var [public] = [1];
var { x: public } = { x: 1 };
var [[private]] = [["hello"]];
var { y: { s: static }, z: { o: { p: package} }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
var {public, protected} = { public: 1, protected: 2 };
var { y: { s: static }, z: { o: { p: package } }} = { y: { s: 1 }, z: { o: { p: 'h' } } };
var { public, protected } = { public: 1, protected: 2 };
var { public: a, protected: b } = { public: 1, protected: 2 };

View File

@@ -1,4 +1,4 @@
// @noLib: true
/// <style requireSemi="on" />
/// <reference no-default-lib="true"/>
declare function foo(): void;
declare function bar(): void;

View File

@@ -0,0 +1,12 @@
/// <reference path='fourslash.ts'/>
////namespace A {
//// function foo() {
//// if (true) {
//// B./**/
//// namespace B {
//// export function baz() { }
////}
goTo.marker();
verify.completionListContains("baz", "function B.baz(): void");

View File

@@ -0,0 +1,24 @@
/// <reference path='fourslash.ts'/>
////function f() {
//// namespace n {
//// interface I {
//// x: number
//// }
//// /*1*/
//// }
//// /*2*/
////}
/////*3*/
goTo.marker('1');
verify.completionListContains("f", "function f(): void");
verify.completionListContains("n", "namespace n");
verify.completionListContains("I", "interface I");
goTo.marker('2');
verify.completionListContains("f", "function f(): void");
verify.completionListContains("n", "namespace n");
goTo.marker('3');
verify.completionListContains("f", "function f(): void");

View File

@@ -0,0 +1,7 @@
/// <reference path='fourslash.ts' />
//// /**/function bar(a: A): a is B {}
goTo.marker();
format.document();
verify.currentLineContentIs("function bar(a: A): a is B { }");

View File

@@ -1,4 +1,4 @@
/// <reference path="..\..\..\src\harness\harness.ts" />
/// <reference path="..\..\..\src\harness\harness.ts" />
module ts {
describe('convertToBase64', () => {
@@ -8,25 +8,25 @@ module ts {
assert.equal(actual, expected, "Encoded string using convertToBase64 does not match buffer.toString('base64')");
}
it("Converts ASCII charaters correctelly", () => {
it("Converts ASCII charaters correctly", () => {
runTest(" !\"#$ %&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~");
});
it("Converts escape sequences correctelly", () => {
it("Converts escape sequences correctly", () => {
runTest("\t\n\r\\\"\'\u0062");
});
it("Converts simple unicode characters correctelly", () => {
it("Converts simple unicode characters correctly", () => {
runTest("ΠΣ ٵپ औठ ⺐⺠");
});
it("Converts simple code snippit correctelly", () => {
it("Converts simple code snippet correctly", () => {
runTest(`/// <reference path="file.ts" />
var x: string = "string";
console.log(x);`);
});
it("Converts simple code snippit with unicode characters correctelly", () => {
it("Converts simple code snippet with unicode characters correctly", () => {
runTest(`var Π = 3.1415; console.log(Π);`);
});
});

View File

@@ -252,57 +252,41 @@ module ts {
});
it('Strict mode 1',() => {
// In non-strict mode 'package' means nothing and can be reused. In strict mode though
// we'll have to reparse the nodes (and generate an error for 'package();'
//
// Note: in this test we don't actually add 'use strict'. This is so we can compare
// reuse with/without a strict mode change.
var source = "foo1();\r\nfoo1();\r\nfoo1();\r\package();";
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withInsert(oldText, 0, "'strict';\r\n");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9);
});
it('Strict mode 2',() => {
// In non-strict mode 'package' means nothing and can be reused. In strict mode though
// we'll have to reparse the nodes (and generate an error for 'package();'
var source = "foo1();\r\nfoo1();\r\nfoo1();\r\package();";
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withInsert(oldText, 0, "'use strict';\r\n");
// Note the decreased reuse of nodes compared to 'Strict mode 1'
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9);
});
it('Strict mode 3',() => {
// In non-strict mode 'package' means nothing and can be reused. In strict mode though
// we'll have to reparse the nodes (and generate an error for 'package();'
//
// Note: in this test we don't actually remove 'use strict'. This is so we can compare
// reuse with/without a strict mode change.
var source = "'strict';\r\nfoo1();\r\nfoo1();\r\nfoo1();\r\npackage();";
var index = source.indexOf('f');
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withDelete(oldText, 0, index);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9);
});
it('Strict mode 4',() => {
// In non-strict mode 'package' means nothing and can be reused. In strict mode though
// we'll have to reparse the nodes (and generate an error for 'package();'
var source = "'use strict';\r\nfoo1();\r\nfoo1();\r\nfoo1();\r\npackage();";
var index = source.indexOf('f');
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withDelete(oldText, 0, index);
// Note the decreased reuse of nodes compared to testStrictMode3
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9);
});
it('Strict mode 5',() => {
@@ -312,7 +296,7 @@ module ts {
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withChange(oldText, index, 6, "strict");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 27);
});
it('Strict mode 6',() => {
@@ -322,7 +306,7 @@ module ts {
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withChange(oldText, index, 6, "blahhh");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 27);
});
it('Strict mode 7',() => {
@@ -332,7 +316,7 @@ module ts {
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withDelete(oldText, 0, index);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 24);
});
it('Parenthesized expression to arrow function 1',() => {
@@ -492,7 +476,6 @@ module ts {
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withChange(oldText, index, ": Foo<Bar<".length, "= ");
// Note the decreased reuse of nodes compared to testStrictMode3
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
});
@@ -545,7 +528,7 @@ module ts {
var index = source.lastIndexOf(";");
var newTextAndChange = withDelete(oldText, index, 1);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 14);
});
it('Edit after empty type parameter list',() => {
@@ -555,7 +538,7 @@ module ts {
var index = source.length;
var newTextAndChange = withInsert(oldText, index, "var x;");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 2);
});
it('Delete parameter after comment',() => {
@@ -579,7 +562,7 @@ var o2 = { set Foo(val:number) { } };";
var index = source.indexOf("set");
var newTextAndChange = withInsert(oldText, index, "public ");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 6);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 14);
});
it('Insert parameter ahead of parameter',() => {
@@ -595,7 +578,7 @@ constructor(name) { }\
var index = source.indexOf("100");
var newTextAndChange = withInsert(oldText, index, "'1', ");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 5);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 7);
});
it('Insert declare modifier before module',() => {
@@ -700,7 +683,7 @@ module m3 { }\
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withDelete(oldText, 0, "{".length);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0);
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 9);
});
it('Moving methods from class to object literal',() => {
@@ -718,7 +701,7 @@ module m3 { }\
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code.
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4);
});
it('Moving methods from object literal to class in strict mode', () => {
@@ -736,7 +719,7 @@ module m3 { }\
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withChange(oldText, 0, "class".length, "interface");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code.
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 18);
});
it('Moving index signatures from class to interface in strict mode', () => {
@@ -754,7 +737,7 @@ module m3 { }\
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withChange(oldText, 0, "interface".length, "class");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code.
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 18);
});
@@ -782,7 +765,7 @@ module m3 { }\
var oldText = ScriptSnapshot.fromString(source);
var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C");
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code.
compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4);
});

View File

@@ -1,11 +1,11 @@
/// <reference path="..\..\..\src\harness\harness.ts" />
/// <reference path="..\..\..\src\harness\harness.ts" />
module ts {
describe("Transpile", () => {
function runTest(input: string, compilerOptions: ts.CompilerOptions = {}, moduleName?: string, expectedOutput?: string, expectedDiagnosticCodes: number[] = []): void {
function runTest(input: string, compilerOptions: ts.CompilerOptions = {}, fileName?: string, moduleName?: string, expectedOutput?: string, expectedDiagnosticCodes: number[] = []): void {
let diagnostics: Diagnostic[] = [];
let result = transpile(input, compilerOptions, "file.ts", diagnostics, moduleName);
let result = transpile(input, compilerOptions, fileName || "file.ts", diagnostics, moduleName);
for (let i = 0; i < expectedDiagnosticCodes.length; i++) {
assert.equal(expectedDiagnosticCodes[i], diagnostics[i] && diagnostics[i].code, `Could not find expeced diagnostic.`);
@@ -19,41 +19,41 @@ module ts {
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;`, {}, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [5047]);
runTest(`var x = 0;`, {}, /*fileName*/ undefined, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [5047]);
});
it("Generates no diagnostics with valid inputs", () => {
// No errors
runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, /*fileName*/ undefined, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
});
it("Generates no diagnostics for missing file references", () => {
runTest(`/// <reference path="file2.ts" />
var x = 0;`,
{ module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
{ module: ModuleKind.CommonJS }, /*fileName*/ undefined, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
});
it("Generates no diagnostics for missing module imports", () => {
runTest(`import {a} from "module2";`,
{ module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
{ module: ModuleKind.CommonJS }, /*fileName*/ undefined,/*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
});
it("Generates expected syntactic diagnostics", () => {
runTest(`a b`,
{ module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [1005]); /// 1005: ';' Expected
{ module: ModuleKind.CommonJS }, /*fileName*/ undefined, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ [1005]); /// 1005: ';' Expected
});
it("Does not generate semantic diagnostics", () => {
runTest(`var x: string = 0;`,
{ module: ModuleKind.CommonJS }, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
{ module: ModuleKind.CommonJS }, /*fileName*/ undefined, /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/ []);
});
it("Generates module output", () => {
runTest(`var x = 0;`, { module: ModuleKind.AMD }, /*moduleName*/undefined, `define(["require", "exports"], function (require, exports) {\r\n var x = 0;\r\n});\r\n`);
runTest(`var x = 0;`, { module: ModuleKind.AMD }, /*fileName*/ undefined, /*moduleName*/undefined, `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 }, /*moduleName*/undefined, `var x = 0;\n`, /*expectedDiagnosticCodes*/ []);
runTest(`var x = 0;`, { module: ModuleKind.CommonJS, newLine: NewLineKind.LineFeed }, /*fileName*/ undefined, /*moduleName*/undefined, `var x = 0;\n`, /*expectedDiagnosticCodes*/ []);
});
it("Sets module name", () => {
@@ -66,7 +66,11 @@ var x = 0;`,
` }\n` +
` }\n` +
`});\n`;
runTest("var x = 1;", { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, "NamedModule", output)
runTest("var x = 1;", { module: ModuleKind.System, newLine: NewLineKind.LineFeed }, /*fileName*/ undefined, "NamedModule", output)
});
it("No extra errors for file without extension", () => {
runTest(`var x = 0;`, { module: ModuleKind.CommonJS }, "file", /*moduleName*/undefined, /*expectedOutput*/ undefined, /*expectedDiagnosticCodes*/[]);
});
});
}