diff --git a/tests/baselines/reference/ArrowFunction2.js b/tests/baselines/reference/ArrowFunction2.js new file mode 100644 index 00000000000..fa6b8bf3b9e --- /dev/null +++ b/tests/baselines/reference/ArrowFunction2.js @@ -0,0 +1,8 @@ +//// [ArrowFunction2.ts] +var v = (a: b,) => { + +}; + +//// [ArrowFunction2.js] +var v = function (a) { +}; diff --git a/tests/baselines/reference/FunctionDeclaration10_es6.js b/tests/baselines/reference/FunctionDeclaration10_es6.js new file mode 100644 index 00000000000..51694533964 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration10_es6.js @@ -0,0 +1,8 @@ +//// [FunctionDeclaration10_es6.ts] +function * foo(a = yield => yield) { +} + +//// [FunctionDeclaration10_es6.js] +function foo(a) { + if (a === void 0) { a = function (yield) { return yield; }; } +} diff --git a/tests/baselines/reference/FunctionDeclaration11_es6.js b/tests/baselines/reference/FunctionDeclaration11_es6.js new file mode 100644 index 00000000000..ba497b3e529 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration11_es6.js @@ -0,0 +1,7 @@ +//// [FunctionDeclaration11_es6.ts] +function * yield() { +} + +//// [FunctionDeclaration11_es6.js] +function yield() { +} diff --git a/tests/baselines/reference/FunctionDeclaration13_es6.js b/tests/baselines/reference/FunctionDeclaration13_es6.js new file mode 100644 index 00000000000..4c82b037569 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration13_es6.js @@ -0,0 +1,12 @@ +//// [FunctionDeclaration13_es6.ts] +function * foo() { + // Legal to use 'yield' in a type context. + var v: yield; +} + + +//// [FunctionDeclaration13_es6.js] +function foo() { + // Legal to use 'yield' in a type context. + var v; +} diff --git a/tests/baselines/reference/FunctionDeclaration1_es6.js b/tests/baselines/reference/FunctionDeclaration1_es6.js new file mode 100644 index 00000000000..262c7ea02fb --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration1_es6.js @@ -0,0 +1,7 @@ +//// [FunctionDeclaration1_es6.ts] +function * foo() { +} + +//// [FunctionDeclaration1_es6.js] +function foo() { +} diff --git a/tests/baselines/reference/FunctionDeclaration6_es6.js b/tests/baselines/reference/FunctionDeclaration6_es6.js new file mode 100644 index 00000000000..07b3ff52212 --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration6_es6.js @@ -0,0 +1,8 @@ +//// [FunctionDeclaration6_es6.ts] +function*foo(a = yield) { +} + +//// [FunctionDeclaration6_es6.js] +function foo(a) { + if (a === void 0) { a = yield; } +} diff --git a/tests/baselines/reference/FunctionDeclaration7_es6.js b/tests/baselines/reference/FunctionDeclaration7_es6.js new file mode 100644 index 00000000000..661e1668e0f --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration7_es6.js @@ -0,0 +1,14 @@ +//// [FunctionDeclaration7_es6.ts] +function*bar() { + // 'yield' here is an identifier, and not a yield expression. + function*foo(a = yield) { + } +} + +//// [FunctionDeclaration7_es6.js] +function bar() { + // 'yield' here is an identifier, and not a yield expression. + function foo(a) { + if (a === void 0) { a = yield; } + } +} diff --git a/tests/baselines/reference/FunctionDeclaration8_es6.js b/tests/baselines/reference/FunctionDeclaration8_es6.js new file mode 100644 index 00000000000..5f9f0a2a49e --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration8_es6.js @@ -0,0 +1,5 @@ +//// [FunctionDeclaration8_es6.ts] +var v = { [yield]: foo } + +//// [FunctionDeclaration8_es6.js] +var v = { [yield]: foo }; diff --git a/tests/baselines/reference/FunctionDeclaration9_es6.js b/tests/baselines/reference/FunctionDeclaration9_es6.js new file mode 100644 index 00000000000..388275ed4fa --- /dev/null +++ b/tests/baselines/reference/FunctionDeclaration9_es6.js @@ -0,0 +1,9 @@ +//// [FunctionDeclaration9_es6.ts] +function * foo() { + var v = { [yield]: foo } +} + +//// [FunctionDeclaration9_es6.js] +function foo() { + var v = { []: foo }; +} diff --git a/tests/baselines/reference/FunctionExpression1_es6.js b/tests/baselines/reference/FunctionExpression1_es6.js new file mode 100644 index 00000000000..7c8d82f4ca8 --- /dev/null +++ b/tests/baselines/reference/FunctionExpression1_es6.js @@ -0,0 +1,6 @@ +//// [FunctionExpression1_es6.ts] +var v = function * () { } + +//// [FunctionExpression1_es6.js] +var v = function () { +}; diff --git a/tests/baselines/reference/FunctionExpression2_es6.js b/tests/baselines/reference/FunctionExpression2_es6.js new file mode 100644 index 00000000000..0a2468bcb8c --- /dev/null +++ b/tests/baselines/reference/FunctionExpression2_es6.js @@ -0,0 +1,6 @@ +//// [FunctionExpression2_es6.ts] +var v = function * foo() { } + +//// [FunctionExpression2_es6.js] +var v = function foo() { +}; diff --git a/tests/baselines/reference/FunctionPropertyAssignments1_es6.js b/tests/baselines/reference/FunctionPropertyAssignments1_es6.js new file mode 100644 index 00000000000..a451dcfb363 --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments1_es6.js @@ -0,0 +1,6 @@ +//// [FunctionPropertyAssignments1_es6.ts] +var v = { *foo() { } } + +//// [FunctionPropertyAssignments1_es6.js] +var v = { foo: function () { +} }; diff --git a/tests/baselines/reference/FunctionPropertyAssignments5_es6.js b/tests/baselines/reference/FunctionPropertyAssignments5_es6.js new file mode 100644 index 00000000000..2bfc675acff --- /dev/null +++ b/tests/baselines/reference/FunctionPropertyAssignments5_es6.js @@ -0,0 +1,6 @@ +//// [FunctionPropertyAssignments5_es6.ts] +var v = { *[foo()]() { } } + +//// [FunctionPropertyAssignments5_es6.js] +var v = { [foo()]: function () { +} }; diff --git a/tests/baselines/reference/MemberAccessorDeclaration15.js b/tests/baselines/reference/MemberAccessorDeclaration15.js new file mode 100644 index 00000000000..41ed265a878 --- /dev/null +++ b/tests/baselines/reference/MemberAccessorDeclaration15.js @@ -0,0 +1,17 @@ +//// [MemberAccessorDeclaration15.ts] +class C { + set Foo(public a: number) { } +} + +//// [MemberAccessorDeclaration15.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/MemberFunctionDeclaration1_es6.js b/tests/baselines/reference/MemberFunctionDeclaration1_es6.js new file mode 100644 index 00000000000..86e7c9d418a --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration1_es6.js @@ -0,0 +1,13 @@ +//// [MemberFunctionDeclaration1_es6.ts] +class C { + *foo() { } +} + +//// [MemberFunctionDeclaration1_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/MemberFunctionDeclaration2_es6.js b/tests/baselines/reference/MemberFunctionDeclaration2_es6.js new file mode 100644 index 00000000000..efd60844dc7 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration2_es6.js @@ -0,0 +1,13 @@ +//// [MemberFunctionDeclaration2_es6.ts] +class C { + public * foo() { } +} + +//// [MemberFunctionDeclaration2_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/MemberFunctionDeclaration3_es6.js b/tests/baselines/reference/MemberFunctionDeclaration3_es6.js new file mode 100644 index 00000000000..357f9175b42 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration3_es6.js @@ -0,0 +1,13 @@ +//// [MemberFunctionDeclaration3_es6.ts] +class C { + *[foo]() { } +} + +//// [MemberFunctionDeclaration3_es6.js] +var C = (function () { + function C() { + } + C.prototype[foo] = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/MemberFunctionDeclaration7_es6.js b/tests/baselines/reference/MemberFunctionDeclaration7_es6.js new file mode 100644 index 00000000000..211713c6e14 --- /dev/null +++ b/tests/baselines/reference/MemberFunctionDeclaration7_es6.js @@ -0,0 +1,13 @@ +//// [MemberFunctionDeclaration7_es6.ts] +class C { + *foo() { } +} + +//// [MemberFunctionDeclaration7_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/Protected1.js b/tests/baselines/reference/Protected1.js new file mode 100644 index 00000000000..eebce2f4ecc --- /dev/null +++ b/tests/baselines/reference/Protected1.js @@ -0,0 +1,10 @@ +//// [Protected1.ts] +protected class C { +} + +//// [Protected1.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/Protected2.js b/tests/baselines/reference/Protected2.js new file mode 100644 index 00000000000..6675d9d50fb --- /dev/null +++ b/tests/baselines/reference/Protected2.js @@ -0,0 +1,5 @@ +//// [Protected2.ts] +protected module M { +} + +//// [Protected2.js] diff --git a/tests/baselines/reference/Protected3.js b/tests/baselines/reference/Protected3.js new file mode 100644 index 00000000000..4c4d5e2a12c --- /dev/null +++ b/tests/baselines/reference/Protected3.js @@ -0,0 +1,11 @@ +//// [Protected3.ts] +class C { + protected constructor() { } +} + +//// [Protected3.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/Protected4.js b/tests/baselines/reference/Protected4.js new file mode 100644 index 00000000000..665a182ef33 --- /dev/null +++ b/tests/baselines/reference/Protected4.js @@ -0,0 +1,13 @@ +//// [Protected4.ts] +class C { + protected public m() { } +} + +//// [Protected4.js] +var C = (function () { + function C() { + } + C.prototype.m = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/Protected6.js b/tests/baselines/reference/Protected6.js new file mode 100644 index 00000000000..004f30b27f8 --- /dev/null +++ b/tests/baselines/reference/Protected6.js @@ -0,0 +1,13 @@ +//// [Protected6.ts] +class C { + static protected m() { } +} + +//// [Protected6.js] +var C = (function () { + function C() { + } + C.m = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/Protected7.js b/tests/baselines/reference/Protected7.js new file mode 100644 index 00000000000..466f6909d67 --- /dev/null +++ b/tests/baselines/reference/Protected7.js @@ -0,0 +1,13 @@ +//// [Protected7.ts] +class C { + protected private m() { } +} + +//// [Protected7.js] +var C = (function () { + function C() { + } + C.prototype.m = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/TupleType3.js b/tests/baselines/reference/TupleType3.js new file mode 100644 index 00000000000..8d357a77be7 --- /dev/null +++ b/tests/baselines/reference/TupleType3.js @@ -0,0 +1,5 @@ +//// [TupleType3.ts] +var v: [] + +//// [TupleType3.js] +var v; diff --git a/tests/baselines/reference/TupleType5.js b/tests/baselines/reference/TupleType5.js new file mode 100644 index 00000000000..5e9a0a580be --- /dev/null +++ b/tests/baselines/reference/TupleType5.js @@ -0,0 +1,5 @@ +//// [TupleType5.ts] +var v: [number,] + +//// [TupleType5.js] +var v; diff --git a/tests/baselines/reference/VariableDeclaration10_es6.js b/tests/baselines/reference/VariableDeclaration10_es6.js new file mode 100644 index 00000000000..14f47cea04d --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration10_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration10_es6.ts] +let a: number = 1 + +//// [VariableDeclaration10_es6.js] +let a = 1; diff --git a/tests/baselines/reference/VariableDeclaration11_es6.js b/tests/baselines/reference/VariableDeclaration11_es6.js new file mode 100644 index 00000000000..83eec6d9a13 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration11_es6.js @@ -0,0 +1,7 @@ +//// [VariableDeclaration11_es6.ts] +"use strict"; +let + +//// [VariableDeclaration11_es6.js] +"use strict"; +let ; diff --git a/tests/baselines/reference/VariableDeclaration1_es6.js b/tests/baselines/reference/VariableDeclaration1_es6.js new file mode 100644 index 00000000000..26433bd88c3 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration1_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration1_es6.ts] +const + +//// [VariableDeclaration1_es6.js] +const ; diff --git a/tests/baselines/reference/VariableDeclaration2_es6.js b/tests/baselines/reference/VariableDeclaration2_es6.js new file mode 100644 index 00000000000..a955315a2f0 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration2_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration2_es6.ts] +const a + +//// [VariableDeclaration2_es6.js] +const a; diff --git a/tests/baselines/reference/VariableDeclaration3_es6.js b/tests/baselines/reference/VariableDeclaration3_es6.js new file mode 100644 index 00000000000..4be8a3daf38 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration3_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration3_es6.ts] +const a = 1 + +//// [VariableDeclaration3_es6.js] +const a = 1; diff --git a/tests/baselines/reference/VariableDeclaration4_es6.js b/tests/baselines/reference/VariableDeclaration4_es6.js new file mode 100644 index 00000000000..7a9934e052b --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration4_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration4_es6.ts] +const a: number + +//// [VariableDeclaration4_es6.js] +const a; diff --git a/tests/baselines/reference/VariableDeclaration5_es6.js b/tests/baselines/reference/VariableDeclaration5_es6.js new file mode 100644 index 00000000000..e6a3c175651 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration5_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration5_es6.ts] +const a: number = 1 + +//// [VariableDeclaration5_es6.js] +const a = 1; diff --git a/tests/baselines/reference/VariableDeclaration7_es6.js b/tests/baselines/reference/VariableDeclaration7_es6.js new file mode 100644 index 00000000000..00ab95503a6 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration7_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration7_es6.ts] +let a + +//// [VariableDeclaration7_es6.js] +let a; diff --git a/tests/baselines/reference/VariableDeclaration8_es6.js b/tests/baselines/reference/VariableDeclaration8_es6.js new file mode 100644 index 00000000000..9178871ef65 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration8_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration8_es6.ts] +let a = 1 + +//// [VariableDeclaration8_es6.js] +let a = 1; diff --git a/tests/baselines/reference/VariableDeclaration9_es6.js b/tests/baselines/reference/VariableDeclaration9_es6.js new file mode 100644 index 00000000000..b22c5691eb2 --- /dev/null +++ b/tests/baselines/reference/VariableDeclaration9_es6.js @@ -0,0 +1,5 @@ +//// [VariableDeclaration9_es6.ts] +let a: number + +//// [VariableDeclaration9_es6.js] +let a; diff --git a/tests/baselines/reference/YieldExpression10_es6.js b/tests/baselines/reference/YieldExpression10_es6.js new file mode 100644 index 00000000000..f111e6e1bdf --- /dev/null +++ b/tests/baselines/reference/YieldExpression10_es6.js @@ -0,0 +1,11 @@ +//// [YieldExpression10_es6.ts] +var v = { * foo() { + yield(foo); + } +} + + +//// [YieldExpression10_es6.js] +var v = { foo: function () { + ; +} }; diff --git a/tests/baselines/reference/YieldExpression11_es6.js b/tests/baselines/reference/YieldExpression11_es6.js new file mode 100644 index 00000000000..306cef3051e --- /dev/null +++ b/tests/baselines/reference/YieldExpression11_es6.js @@ -0,0 +1,16 @@ +//// [YieldExpression11_es6.ts] +class C { + *foo() { + yield(foo); + } +} + +//// [YieldExpression11_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + ; + }; + return C; +})(); diff --git a/tests/baselines/reference/YieldExpression12_es6.js b/tests/baselines/reference/YieldExpression12_es6.js new file mode 100644 index 00000000000..020340fc4a3 --- /dev/null +++ b/tests/baselines/reference/YieldExpression12_es6.js @@ -0,0 +1,14 @@ +//// [YieldExpression12_es6.ts] +class C { + constructor() { + yield foo + } +} + +//// [YieldExpression12_es6.js] +var C = (function () { + function C() { + ; + } + return C; +})(); diff --git a/tests/baselines/reference/YieldExpression13_es6.js b/tests/baselines/reference/YieldExpression13_es6.js new file mode 100644 index 00000000000..328fc80dbdd --- /dev/null +++ b/tests/baselines/reference/YieldExpression13_es6.js @@ -0,0 +1,7 @@ +//// [YieldExpression13_es6.ts] +function* foo() { yield } + +//// [YieldExpression13_es6.js] +function foo() { + ; +} diff --git a/tests/baselines/reference/YieldExpression14_es6.js b/tests/baselines/reference/YieldExpression14_es6.js new file mode 100644 index 00000000000..132890b1b6a --- /dev/null +++ b/tests/baselines/reference/YieldExpression14_es6.js @@ -0,0 +1,16 @@ +//// [YieldExpression14_es6.ts] +class C { + foo() { + yield foo + } +} + +//// [YieldExpression14_es6.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + ; + }; + return C; +})(); diff --git a/tests/baselines/reference/YieldExpression15_es6.js b/tests/baselines/reference/YieldExpression15_es6.js new file mode 100644 index 00000000000..13e6b92a577 --- /dev/null +++ b/tests/baselines/reference/YieldExpression15_es6.js @@ -0,0 +1,9 @@ +//// [YieldExpression15_es6.ts] +var v = () => { + yield foo + } + +//// [YieldExpression15_es6.js] +var v = function () { + ; +}; diff --git a/tests/baselines/reference/YieldExpression16_es6.js b/tests/baselines/reference/YieldExpression16_es6.js new file mode 100644 index 00000000000..ee73439a2d5 --- /dev/null +++ b/tests/baselines/reference/YieldExpression16_es6.js @@ -0,0 +1,13 @@ +//// [YieldExpression16_es6.ts] +function* foo() { + function bar() { + yield foo; + } +} + +//// [YieldExpression16_es6.js] +function foo() { + function bar() { + ; + } +} diff --git a/tests/baselines/reference/YieldExpression17_es6.js b/tests/baselines/reference/YieldExpression17_es6.js new file mode 100644 index 00000000000..6fd39844d80 --- /dev/null +++ b/tests/baselines/reference/YieldExpression17_es6.js @@ -0,0 +1,7 @@ +//// [YieldExpression17_es6.ts] +var v = { get foo() { yield foo; } } + +//// [YieldExpression17_es6.js] +var v = { get foo() { + ; +} }; diff --git a/tests/baselines/reference/YieldExpression18_es6.js b/tests/baselines/reference/YieldExpression18_es6.js new file mode 100644 index 00000000000..7fb630b9c08 --- /dev/null +++ b/tests/baselines/reference/YieldExpression18_es6.js @@ -0,0 +1,7 @@ +//// [YieldExpression18_es6.ts] +"use strict"; +yield(foo); + +//// [YieldExpression18_es6.js] +"use strict"; +; diff --git a/tests/baselines/reference/YieldExpression19_es6.js b/tests/baselines/reference/YieldExpression19_es6.js new file mode 100644 index 00000000000..91643e09b0e --- /dev/null +++ b/tests/baselines/reference/YieldExpression19_es6.js @@ -0,0 +1,17 @@ +//// [YieldExpression19_es6.ts] +function*foo() { + function bar() { + function* quux() { + yield(foo); + } + } +} + +//// [YieldExpression19_es6.js] +function foo() { + function bar() { + function quux() { + ; + } + } +} diff --git a/tests/baselines/reference/YieldExpression2_es6.js b/tests/baselines/reference/YieldExpression2_es6.js new file mode 100644 index 00000000000..0207b8afca0 --- /dev/null +++ b/tests/baselines/reference/YieldExpression2_es6.js @@ -0,0 +1,5 @@ +//// [YieldExpression2_es6.ts] +yield foo; + +//// [YieldExpression2_es6.js] +; diff --git a/tests/baselines/reference/YieldExpression3_es6.js b/tests/baselines/reference/YieldExpression3_es6.js new file mode 100644 index 00000000000..cc3716587ea --- /dev/null +++ b/tests/baselines/reference/YieldExpression3_es6.js @@ -0,0 +1,11 @@ +//// [YieldExpression3_es6.ts] +function* foo() { + yield + yield +} + +//// [YieldExpression3_es6.js] +function foo() { + ; + ; +} diff --git a/tests/baselines/reference/YieldExpression4_es6.js b/tests/baselines/reference/YieldExpression4_es6.js new file mode 100644 index 00000000000..84b11a03a2c --- /dev/null +++ b/tests/baselines/reference/YieldExpression4_es6.js @@ -0,0 +1,11 @@ +//// [YieldExpression4_es6.ts] +function* foo() { + yield; + yield; +} + +//// [YieldExpression4_es6.js] +function foo() { + ; + ; +} diff --git a/tests/baselines/reference/YieldExpression6_es6.js b/tests/baselines/reference/YieldExpression6_es6.js new file mode 100644 index 00000000000..5024e9bbd40 --- /dev/null +++ b/tests/baselines/reference/YieldExpression6_es6.js @@ -0,0 +1,9 @@ +//// [YieldExpression6_es6.ts] +function* foo() { + yield*foo +} + +//// [YieldExpression6_es6.js] +function foo() { + ; +} diff --git a/tests/baselines/reference/YieldExpression7_es6.js b/tests/baselines/reference/YieldExpression7_es6.js new file mode 100644 index 00000000000..96ef5af107e --- /dev/null +++ b/tests/baselines/reference/YieldExpression7_es6.js @@ -0,0 +1,9 @@ +//// [YieldExpression7_es6.ts] +function* foo() { + yield foo +} + +//// [YieldExpression7_es6.js] +function foo() { + ; +} diff --git a/tests/baselines/reference/YieldExpression8_es6.js b/tests/baselines/reference/YieldExpression8_es6.js new file mode 100644 index 00000000000..190c2cc3da5 --- /dev/null +++ b/tests/baselines/reference/YieldExpression8_es6.js @@ -0,0 +1,11 @@ +//// [YieldExpression8_es6.ts] +yield(foo); +function* foo() { + yield(foo); +} + +//// [YieldExpression8_es6.js] +yield(foo); +function foo() { + ; +} diff --git a/tests/baselines/reference/YieldExpression9_es6.js b/tests/baselines/reference/YieldExpression9_es6.js new file mode 100644 index 00000000000..978e0d455bd --- /dev/null +++ b/tests/baselines/reference/YieldExpression9_es6.js @@ -0,0 +1,9 @@ +//// [YieldExpression9_es6.ts] +var v = function*() { + yield(foo); +} + +//// [YieldExpression9_es6.js] +var v = function () { + ; +}; diff --git a/tests/baselines/reference/accessibilityModifiers.js b/tests/baselines/reference/accessibilityModifiers.js new file mode 100644 index 00000000000..901b3a29c2e --- /dev/null +++ b/tests/baselines/reference/accessibilityModifiers.js @@ -0,0 +1,171 @@ +//// [accessibilityModifiers.ts] + +// No errors +class C { + private static privateProperty; + private static privateMethod() { } + private static get privateGetter() { return 0; } + private static set privateSetter(a: number) { } + + protected static protectedProperty; + protected static protectedMethod() { } + protected static get protectedGetter() { return 0; } + protected static set protectedSetter(a: number) { } + + public static publicProperty; + public static publicMethod() { } + public static get publicGetter() { return 0; } + public static set publicSetter(a: number) { } +} + +// Errors, accessibility modifiers must precede static +class D { + static private privateProperty; + static private privateMethod() { } + static private get privateGetter() { return 0; } + static private set privateSetter(a: number) { } + + static protected protectedProperty; + static protected protectedMethod() { } + static protected get protectedGetter() { return 0; } + static protected set protectedSetter(a: number) { } + + static public publicProperty; + static public publicMethod() { } + static public get publicGetter() { return 0; } + static public set publicSetter(a: number) { } +} + +// Errors, multiple accessibility modifier +class E { + private public protected property; + public protected method() { } + private protected get getter() { return 0; } + public public set setter(a: number) { } +} + + +//// [accessibilityModifiers.js] +// No errors +var C = (function () { + function C() { + } + C.privateMethod = function () { + }; + Object.defineProperty(C, "privateGetter", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "privateSetter", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + C.protectedMethod = function () { + }; + Object.defineProperty(C, "protectedGetter", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "protectedSetter", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + C.publicMethod = function () { + }; + Object.defineProperty(C, "publicGetter", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "publicSetter", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); +// Errors, accessibility modifiers must precede static +var D = (function () { + function D() { + } + D.privateMethod = function () { + }; + Object.defineProperty(D, "privateGetter", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(D, "privateSetter", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + D.protectedMethod = function () { + }; + Object.defineProperty(D, "protectedGetter", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(D, "protectedSetter", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + D.publicMethod = function () { + }; + Object.defineProperty(D, "publicGetter", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(D, "publicSetter", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return D; +})(); +// Errors, multiple accessibility modifier +var E = (function () { + function E() { + } + E.prototype.method = function () { + }; + Object.defineProperty(E.prototype, "getter", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(E.prototype, "setter", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return E; +})(); diff --git a/tests/baselines/reference/accessorWithES3.js b/tests/baselines/reference/accessorWithES3.js new file mode 100644 index 00000000000..6eba5238a91 --- /dev/null +++ b/tests/baselines/reference/accessorWithES3.js @@ -0,0 +1,57 @@ +//// [accessorWithES3.ts] + +// error to use accessors in ES3 mode + +class C { + get x() { + return 1; + } +} + +class D { + set x(v) { + } +} + +var x = { + get a() { return 1 } +} + +var y = { + set b(v) { } +} + +//// [accessorWithES3.js] +// error to use accessors in ES3 mode +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var D = (function () { + function D() { + } + Object.defineProperty(D.prototype, "x", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return D; +})(); +var x = { + get a() { + return 1; + } +}; +var y = { + set b(v) { + } +}; diff --git a/tests/baselines/reference/accessorWithInitializer.js b/tests/baselines/reference/accessorWithInitializer.js new file mode 100644 index 00000000000..26e72fe7d7d --- /dev/null +++ b/tests/baselines/reference/accessorWithInitializer.js @@ -0,0 +1,27 @@ +//// [accessorWithInitializer.ts] + +class C { + set X(v = 0) { } + static set X(v2 = 0) { } +} + +//// [accessorWithInitializer.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "X", { + set: function (v) { + if (v === void 0) { v = 0; } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "X", { + set: function (v2) { + if (v2 === void 0) { v2 = 0; } + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/accessorWithRestParam.js b/tests/baselines/reference/accessorWithRestParam.js new file mode 100644 index 00000000000..9feafe1904d --- /dev/null +++ b/tests/baselines/reference/accessorWithRestParam.js @@ -0,0 +1,33 @@ +//// [accessorWithRestParam.ts] + +class C { + set X(...v) { } + static set X(...v2) { } +} + +//// [accessorWithRestParam.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "X", { + set: function () { + var v = []; + for (var _i = 0; _i < arguments.length; _i++) { + v[_i - 0] = arguments[_i]; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "X", { + set: function () { + var v2 = []; + for (var _i = 0; _i < arguments.length; _i++) { + v2[_i - 0] = arguments[_i]; + } + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/accessorWithoutBody1.js b/tests/baselines/reference/accessorWithoutBody1.js new file mode 100644 index 00000000000..37f0ecbcfee --- /dev/null +++ b/tests/baselines/reference/accessorWithoutBody1.js @@ -0,0 +1,6 @@ +//// [accessorWithoutBody1.ts] +var v = { get foo() } + +//// [accessorWithoutBody1.js] +var v = { get foo() { +} }; diff --git a/tests/baselines/reference/accessorWithoutBody2.js b/tests/baselines/reference/accessorWithoutBody2.js new file mode 100644 index 00000000000..9dc34c1e744 --- /dev/null +++ b/tests/baselines/reference/accessorWithoutBody2.js @@ -0,0 +1,6 @@ +//// [accessorWithoutBody2.ts] +var v = { set foo(a) } + +//// [accessorWithoutBody2.js] +var v = { set foo(a) { +} }; diff --git a/tests/baselines/reference/accessorsAreNotContextuallyTyped.js b/tests/baselines/reference/accessorsAreNotContextuallyTyped.js new file mode 100644 index 00000000000..8c01173a13c --- /dev/null +++ b/tests/baselines/reference/accessorsAreNotContextuallyTyped.js @@ -0,0 +1,33 @@ +//// [accessorsAreNotContextuallyTyped.ts] +// accessors are not contextually typed + +class C { + set x(v: (a: string) => string) { + } + + get x() { + return (x: string) => ""; + } +} + +var c: C; +var r = c.x(''); // string + +//// [accessorsAreNotContextuallyTyped.js] +// accessors are not contextually typed +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return function (x) { return ""; }; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var c; +var r = c.x(''); // string diff --git a/tests/baselines/reference/accessorsEmit.js b/tests/baselines/reference/accessorsEmit.js new file mode 100644 index 00000000000..e2c097e263f --- /dev/null +++ b/tests/baselines/reference/accessorsEmit.js @@ -0,0 +1,49 @@ +//// [accessorsEmit.ts] +class Result { } + +class Test { + get Property(): Result { + var x = 1; + return null; + } +} + +class Test2 { + get Property() { + var x = 1; + return null; + } +} + +//// [accessorsEmit.js] +var Result = (function () { + function Result() { + } + return Result; +})(); +var Test = (function () { + function Test() { + } + Object.defineProperty(Test.prototype, "Property", { + get: function () { + var x = 1; + return null; + }, + enumerable: true, + configurable: true + }); + return Test; +})(); +var Test2 = (function () { + function Test2() { + } + Object.defineProperty(Test2.prototype, "Property", { + get: function () { + var x = 1; + return null; + }, + enumerable: true, + configurable: true + }); + return Test2; +})(); diff --git a/tests/baselines/reference/accessorsInAmbientContext.js b/tests/baselines/reference/accessorsInAmbientContext.js new file mode 100644 index 00000000000..e60831ede5b --- /dev/null +++ b/tests/baselines/reference/accessorsInAmbientContext.js @@ -0,0 +1,21 @@ +//// [accessorsInAmbientContext.ts] + +declare module M { + class C { + get X() { return 1; } + set X(v) { } + + static get Y() { return 1; } + static set Y(v) { } + } +} + +declare class C { + get X() { return 1; } + set X(v) { } + + static get Y() { return 1; } + static set Y(v) { } +} + +//// [accessorsInAmbientContext.js] diff --git a/tests/baselines/reference/accessorsNotAllowedInES3.js b/tests/baselines/reference/accessorsNotAllowedInES3.js new file mode 100644 index 00000000000..5cb5a5dc47a --- /dev/null +++ b/tests/baselines/reference/accessorsNotAllowedInES3.js @@ -0,0 +1,24 @@ +//// [accessorsNotAllowedInES3.ts] + +class C { + get x(): number { return 1; } +} +var y = { get foo() { return 3; } }; + + +//// [accessorsNotAllowedInES3.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var y = { get foo() { + return 3; +} }; diff --git a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.js b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.js new file mode 100644 index 00000000000..6a3b3773aa6 --- /dev/null +++ b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.js @@ -0,0 +1,59 @@ +//// [accessors_spec_section-4.5_error-cases.ts] +class LanguageSpec_section_4_5_error_cases { + public set AnnotatedSetter_SetterFirst(a: number) { } + public get AnnotatedSetter_SetterFirst() { return ""; } + + public get AnnotatedSetter_SetterLast() { return ""; } + public set AnnotatedSetter_SetterLast(a: number) { } + + public get AnnotatedGetter_GetterFirst(): string { return ""; } + public set AnnotatedGetter_GetterFirst(aStr) { aStr = 0; } + + public set AnnotatedGetter_GetterLast(aStr) { aStr = 0; } + public get AnnotatedGetter_GetterLast(): string { return ""; } +} + +//// [accessors_spec_section-4.5_error-cases.js] +var LanguageSpec_section_4_5_error_cases = (function () { + function LanguageSpec_section_4_5_error_cases() { + } + Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterFirst", { + get: function () { + return ""; + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterLast", { + get: function () { + return ""; + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterFirst", { + get: function () { + return ""; + }, + set: function (aStr) { + aStr = 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterLast", { + get: function () { + return ""; + }, + set: function (aStr) { + aStr = 0; + }, + enumerable: true, + configurable: true + }); + return LanguageSpec_section_4_5_error_cases; +})(); diff --git a/tests/baselines/reference/accessors_spec_section-4.5_inference.js b/tests/baselines/reference/accessors_spec_section-4.5_inference.js new file mode 100644 index 00000000000..b140e565b29 --- /dev/null +++ b/tests/baselines/reference/accessors_spec_section-4.5_inference.js @@ -0,0 +1,104 @@ +//// [accessors_spec_section-4.5_inference.ts] +class A { } +class B extends A { } + +class LanguageSpec_section_4_5_inference { + + public set InferredGetterFromSetterAnnotation(a: A) { } + public get InferredGetterFromSetterAnnotation() { return new B(); } + + public get InferredGetterFromSetterAnnotation_GetterFirst() { return new B(); } + public set InferredGetterFromSetterAnnotation_GetterFirst(a: A) { } + + + public get InferredFromGetter() { return new B(); } + public set InferredFromGetter(a) { } + + public set InferredFromGetter_SetterFirst(a) { } + public get InferredFromGetter_SetterFirst() { return new B(); } + + public set InferredSetterFromGetterAnnotation(a) { } + public get InferredSetterFromGetterAnnotation() : A { return new B(); } + + public get InferredSetterFromGetterAnnotation_GetterFirst() : A { return new B(); } + public set InferredSetterFromGetterAnnotation_GetterFirst(a) { } +} + +//// [accessors_spec_section-4.5_inference.js] +var __extends = 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 A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var LanguageSpec_section_4_5_inference = (function () { + function LanguageSpec_section_4_5_inference() { + } + Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredGetterFromSetterAnnotation", { + get: function () { + return new B(); + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredGetterFromSetterAnnotation_GetterFirst", { + get: function () { + return new B(); + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredFromGetter", { + get: function () { + return new B(); + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredFromGetter_SetterFirst", { + get: function () { + return new B(); + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredSetterFromGetterAnnotation", { + get: function () { + return new B(); + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredSetterFromGetterAnnotation_GetterFirst", { + get: function () { + return new B(); + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return LanguageSpec_section_4_5_inference; +})(); diff --git a/tests/baselines/reference/ambientEnum1.js b/tests/baselines/reference/ambientEnum1.js new file mode 100644 index 00000000000..8a477ab99fa --- /dev/null +++ b/tests/baselines/reference/ambientEnum1.js @@ -0,0 +1,11 @@ +//// [ambientEnum1.ts] + declare enum E1 { + y = 4.23 + } + + // Ambient enum with computer member + declare enum E2 { + x = 'foo'.length + } + +//// [ambientEnum1.js] diff --git a/tests/baselines/reference/ambientEnumElementInitializer3.js b/tests/baselines/reference/ambientEnumElementInitializer3.js new file mode 100644 index 00000000000..7a7a077ff8f --- /dev/null +++ b/tests/baselines/reference/ambientEnumElementInitializer3.js @@ -0,0 +1,6 @@ +//// [ambientEnumElementInitializer3.ts] +declare enum E { + e = 3.3 // Decimal +} + +//// [ambientEnumElementInitializer3.js] diff --git a/tests/baselines/reference/ambientErrors.js b/tests/baselines/reference/ambientErrors.js new file mode 100644 index 00000000000..c524a6cfe72 --- /dev/null +++ b/tests/baselines/reference/ambientErrors.js @@ -0,0 +1,63 @@ +//// [ambientErrors.ts] +// Ambient variable with an initializer +declare var x = 4; + +// Ambient functions with invalid overloads +declare function fn(x: number): string; +declare function fn(x: 'foo'): number; + +// Ambient functions with duplicate signatures +declare function fn1(x: number): string; +declare function fn1(x: number): string; + +// Ambient function overloads that differ only by return type +declare function fn2(x: number): string; +declare function fn2(x: number): number; + +// Ambient function with default parameter values +declare function fn3(x = 3); + +// Ambient function with function body +declare function fn4() { }; + +// Ambient enum with non - integer literal constant member +declare enum E1 { + y = 4.23 +} + +// Ambient enum with computer member +declare enum E2 { + x = 'foo'.length +} + +// Ambient module with initializers for values, bodies for functions / classes +declare module M1 { + var x = 3; + function fn() { } + class C { + static x = 3; + y = 4; + constructor() { } + fn() { } + static sfn() { } + } +} + +// Ambient external module not in the global module +module M2 { + declare module 'nope' { } +} + +// Ambient external module with a string literal name that isn't a top level external module name +declare module '../foo' { } + +// Ambient external module with export assignment and other exported members +declare module 'bar' { + var n; + export var q; + export = n; +} + + +//// [ambientErrors.js] +; diff --git a/tests/baselines/reference/ambientErrors1.js b/tests/baselines/reference/ambientErrors1.js new file mode 100644 index 00000000000..8605489d3df --- /dev/null +++ b/tests/baselines/reference/ambientErrors1.js @@ -0,0 +1,4 @@ +//// [ambientErrors1.ts] +declare var x = 4; + +//// [ambientErrors1.js] diff --git a/tests/baselines/reference/ambientGetters.js b/tests/baselines/reference/ambientGetters.js new file mode 100644 index 00000000000..9e267a1dddb --- /dev/null +++ b/tests/baselines/reference/ambientGetters.js @@ -0,0 +1,11 @@ +//// [ambientGetters.ts] + +declare class A { + get length() : number; +} + +declare class B { + get length() { return 0; } +} + +//// [ambientGetters.js] diff --git a/tests/baselines/reference/ambientStatement1.js b/tests/baselines/reference/ambientStatement1.js new file mode 100644 index 00000000000..f986f9717ad --- /dev/null +++ b/tests/baselines/reference/ambientStatement1.js @@ -0,0 +1,8 @@ +//// [ambientStatement1.ts] + declare module M1 { + while(true); + + export var v1 = () => false; + } + +//// [ambientStatement1.js] diff --git a/tests/baselines/reference/ambientWithStatements.js b/tests/baselines/reference/ambientWithStatements.js new file mode 100644 index 00000000000..997916d0bf7 --- /dev/null +++ b/tests/baselines/reference/ambientWithStatements.js @@ -0,0 +1,30 @@ +//// [ambientWithStatements.ts] +declare module M { + break; + continue; + debugger; + do { } while (true); + var x; + for (x in null) { } + if (true) { } else { } + 1; + L: var y; + return; + switch (x) { + case 1: + break; + default: + break; + } + throw "nooo"; + try { + } + catch (e) { + } + finally { + } + with (x) { + } +} + +//// [ambientWithStatements.js] diff --git a/tests/baselines/reference/anyIdenticalToItself.js b/tests/baselines/reference/anyIdenticalToItself.js new file mode 100644 index 00000000000..dc221b69aa7 --- /dev/null +++ b/tests/baselines/reference/anyIdenticalToItself.js @@ -0,0 +1,32 @@ +//// [anyIdenticalToItself.ts] +function foo(x: any); +function foo(x: any); +function foo(x: any, y: number) { } + +class C { + get X(): any { + var y: any; + return y; + } + set X(v: any) { + } +} + +//// [anyIdenticalToItself.js] +function foo(x, y) { +} +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "X", { + get: function () { + var y; + return y; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/arraySigChecking.js b/tests/baselines/reference/arraySigChecking.js new file mode 100644 index 00000000000..16189305ead --- /dev/null +++ b/tests/baselines/reference/arraySigChecking.js @@ -0,0 +1,46 @@ +//// [arraySigChecking.ts] +declare module M { + interface iBar { t: any; } + interface iFoo extends iBar { + s: any; + } + + class cFoo { + t: any; + } + + var foo: { [index: any]; }; // expect an error here +} + +interface myInt { + voidFn(): void; +} +var myVar: myInt; +var strArray: string[] = [myVar.voidFn()]; + + +var myArray: number[][][]; +myArray = [[1, 2]]; + +function isEmpty(l: { length: number }) { + return l.length === 0; +} + +isEmpty([]); +isEmpty(new Array(3)); +isEmpty(new Array(3)); +isEmpty(['a']); + + +//// [arraySigChecking.js] +var myVar; +var strArray = [myVar.voidFn()]; +var myArray; +myArray = [[1, 2]]; +function isEmpty(l) { + return l.length === 0; +} +isEmpty([]); +isEmpty(new Array(3)); +isEmpty(new Array(3)); +isEmpty(['a']); diff --git a/tests/baselines/reference/asiReturn.js b/tests/baselines/reference/asiReturn.js new file mode 100644 index 00000000000..ef2aada682c --- /dev/null +++ b/tests/baselines/reference/asiReturn.js @@ -0,0 +1,7 @@ +//// [asiReturn.ts] +// This should be an error for using a return outside a function, but ASI should work properly +return + +//// [asiReturn.js] +// This should be an error for using a return outside a function, but ASI should work properly +return; diff --git a/tests/baselines/reference/assignmentCompatBug3.js b/tests/baselines/reference/assignmentCompatBug3.js new file mode 100644 index 00000000000..6d3deedc5b8 --- /dev/null +++ b/tests/baselines/reference/assignmentCompatBug3.js @@ -0,0 +1,61 @@ +//// [assignmentCompatBug3.ts] +function makePoint(x: number, y: number) { + return { + get x() { return x;}, // shouldn't be "void" + get y() { return y;}, // shouldn't be "void" + //x: "yo", + //y: "boo", + dist: function () { + return Math.sqrt(x*x+y*y); // shouldn't be picking up "x" and "y" from the object lit + } + } +} + +class C { + get x() { + return 0; + } +} + +function foo(test: string) { } + +var x: any; +var y: any; + +foo(x); +foo(x + y); + +//// [assignmentCompatBug3.js] +function makePoint(x, y) { + return { + get x() { + return x; + }, + get y() { + return y; + }, + //x: "yo", + //y: "boo", + dist: function () { + return Math.sqrt(x * x + y * y); // shouldn't be picking up "x" and "y" from the object lit + } + }; +} +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +function foo(test) { +} +var x; +var y; +foo(x); +foo(x + y); diff --git a/tests/baselines/reference/badArrayIndex.js b/tests/baselines/reference/badArrayIndex.js new file mode 100644 index 00000000000..210dd6add8e --- /dev/null +++ b/tests/baselines/reference/badArrayIndex.js @@ -0,0 +1,5 @@ +//// [badArrayIndex.ts] +var results = number[]; + +//// [badArrayIndex.js] +var results = number[]; diff --git a/tests/baselines/reference/badArraySyntax.js b/tests/baselines/reference/badArraySyntax.js new file mode 100644 index 00000000000..f5ca1e0c0ba --- /dev/null +++ b/tests/baselines/reference/badArraySyntax.js @@ -0,0 +1,26 @@ +//// [badArraySyntax.ts] +class Z { + public x = ""; +} + +var a1: Z[] = []; +var a2 = new Z[]; +var a3 = new Z[](); +var a4: Z[] = new Z[]; +var a5: Z[] = new Z[](); +var a6: Z[][] = new Z [ ] [ ]; + + +//// [badArraySyntax.js] +var Z = (function () { + function Z() { + this.x = ""; + } + return Z; +})(); +var a1 = []; +var a2 = new Z[]; +var a3 = new Z[](); +var a4 = new Z[]; +var a5 = new Z[](); +var a6 = new Z[][]; diff --git a/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.js b/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.js new file mode 100644 index 00000000000..21ca5d4cce4 --- /dev/null +++ b/tests/baselines/reference/breakNotInIterationOrSwitchStatement1.js @@ -0,0 +1,5 @@ +//// [breakNotInIterationOrSwitchStatement1.ts] +break; + +//// [breakNotInIterationOrSwitchStatement1.js] +break; diff --git a/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.js b/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.js new file mode 100644 index 00000000000..531e5b5e5b6 --- /dev/null +++ b/tests/baselines/reference/breakNotInIterationOrSwitchStatement2.js @@ -0,0 +1,13 @@ +//// [breakNotInIterationOrSwitchStatement2.ts] +while (true) { + function f() { + break; + } +} + +//// [breakNotInIterationOrSwitchStatement2.js] +while (true) { + function f() { + break; + } +} diff --git a/tests/baselines/reference/breakTarget5.js b/tests/baselines/reference/breakTarget5.js new file mode 100644 index 00000000000..197e4e147bd --- /dev/null +++ b/tests/baselines/reference/breakTarget5.js @@ -0,0 +1,18 @@ +//// [breakTarget5.ts] +target: +while (true) { + function f() { + while (true) { + break target; + } + } +} + +//// [breakTarget5.js] +target: while (true) { + function f() { + while (true) { + break target; + } + } +} diff --git a/tests/baselines/reference/breakTarget6.js b/tests/baselines/reference/breakTarget6.js new file mode 100644 index 00000000000..9c5bcc3ded1 --- /dev/null +++ b/tests/baselines/reference/breakTarget6.js @@ -0,0 +1,9 @@ +//// [breakTarget6.ts] +while (true) { + break target; +} + +//// [breakTarget6.js] +while (true) { + break target; +} diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.js b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.js new file mode 100644 index 00000000000..0f8a033067d --- /dev/null +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.js @@ -0,0 +1,112 @@ +//// [callSignatureWithOptionalParameterAndInitializer.ts] +// Optional parameters cannot also have initializer expressions, these are all errors + +function foo(x?: number = 1) { } +var f = function foo(x?: number = 1) { } +var f2 = (x: number, y? = 1) => { } + +foo(1); +foo(); +f(1); +f(); +f2(1); +f2(1, 2); + +class C { + foo(x?: number = 1) { } +} + +var c: C; +c.foo(); +c.foo(1); + +interface I { + (x? = 1); + foo(x: number, y?: number = 1); +} + +var i: I; +i(); +i(1); +i.foo(1); +i.foo(1, 2); + +var a: { + (x?: number = 1); + foo(x? = 1); +} + +a(); +a(1); +a.foo(); +a.foo(1); + +var b = { + foo(x?: number = 1) { }, + a: function foo(x: number, y?: number = '') { }, + b: (x?: any = '') => { } +} + +b.foo(); +b.foo(1); +b.a(1); +b.a(1, 2); +b.b(); +b.b(1); + + +//// [callSignatureWithOptionalParameterAndInitializer.js] +// Optional parameters cannot also have initializer expressions, these are all errors +function foo(x) { + if (x === void 0) { x = 1; } +} +var f = function foo(x) { + if (x === void 0) { x = 1; } +}; +var f2 = function (x, y) { + if (y === void 0) { y = 1; } +}; +foo(1); +foo(); +f(1); +f(); +f2(1); +f2(1, 2); +var C = (function () { + function C() { + } + C.prototype.foo = function (x) { + if (x === void 0) { x = 1; } + }; + return C; +})(); +var c; +c.foo(); +c.foo(1); +var i; +i(); +i(1); +i.foo(1); +i.foo(1, 2); +var a; +a(); +a(1); +a.foo(); +a.foo(1); +var b = { + foo: function (x) { + if (x === void 0) { x = 1; } + }, + a: function foo(x, y) { + if (y === void 0) { y = ''; } + }, + b: function (x) { + if (x === void 0) { x = ''; } + } +}; +b.foo(); +b.foo(1); +b.a(1); +b.a(1, 2); +b.b(); +b.b(1); diff --git a/tests/baselines/reference/cannotInvokeNewOnErrorExpression.js b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.js new file mode 100644 index 00000000000..2b05f8d3389 --- /dev/null +++ b/tests/baselines/reference/cannotInvokeNewOnErrorExpression.js @@ -0,0 +1,17 @@ +//// [cannotInvokeNewOnErrorExpression.ts] +module M +{ + class ClassA {} +} +var t = new M.ClassA[]; + +//// [cannotInvokeNewOnErrorExpression.js] +var M; +(function (M) { + var ClassA = (function () { + function ClassA() { + } + return ClassA; + })(); +})(M || (M = {})); +var t = new M.ClassA[]; diff --git a/tests/baselines/reference/catchClauseWithTypeAnnotation.js b/tests/baselines/reference/catchClauseWithTypeAnnotation.js new file mode 100644 index 00000000000..097abe0a9ca --- /dev/null +++ b/tests/baselines/reference/catchClauseWithTypeAnnotation.js @@ -0,0 +1,10 @@ +//// [catchClauseWithTypeAnnotation.ts] +try { +} catch (e: any) { +} + +//// [catchClauseWithTypeAnnotation.js] +try { +} +catch (e) { +} diff --git a/tests/baselines/reference/classConstructorAccessibility.js b/tests/baselines/reference/classConstructorAccessibility.js new file mode 100644 index 00000000000..15b12190392 --- /dev/null +++ b/tests/baselines/reference/classConstructorAccessibility.js @@ -0,0 +1,82 @@ +//// [classConstructorAccessibility.ts] +class C { + public constructor(public x: number) { } +} + +class D { + private constructor(public x: number) { } // error +} + +class E { + protected constructor(public x: number) { } // error +} + +var c = new C(1); +var d = new D(1); +var e = new E(1); + +module Generic { + class C { + public constructor(public x: T) { } + } + + class D { + private constructor(public x: T) { } // error + } + + class E { + protected constructor(public x: T) { } // error + } + + var c = new C(1); + var d = new D(1); + var e = new E(1); +} + + +//// [classConstructorAccessibility.js] +var C = (function () { + function C(x) { + this.x = x; + } + return C; +})(); +var D = (function () { + function D(x) { + this.x = x; + } // error + return D; +})(); +var E = (function () { + function E(x) { + this.x = x; + } // error + return E; +})(); +var c = new C(1); +var d = new D(1); +var e = new E(1); +var Generic; +(function (Generic) { + var C = (function () { + function C(x) { + this.x = x; + } + return C; + })(); + var D = (function () { + function D(x) { + this.x = x; + } // error + return D; + })(); + var E = (function () { + function E(x) { + this.x = x; + } // error + return E; + })(); + var c = new C(1); + var d = new D(1); + var e = new E(1); +})(Generic || (Generic = {})); diff --git a/tests/baselines/reference/classExtendsMultipleBaseClasses.js b/tests/baselines/reference/classExtendsMultipleBaseClasses.js new file mode 100644 index 00000000000..07d6450f405 --- /dev/null +++ b/tests/baselines/reference/classExtendsMultipleBaseClasses.js @@ -0,0 +1,29 @@ +//// [classExtendsMultipleBaseClasses.ts] +class A { } +class B { } +class C extends A,B { } + +//// [classExtendsMultipleBaseClasses.js] +var __extends = 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 A = (function () { + function A() { + } + return A; +})(); +var B = (function () { + function B() { + } + return B; +})(); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/classHeritageWithTrailingSeparator.js b/tests/baselines/reference/classHeritageWithTrailingSeparator.js new file mode 100644 index 00000000000..5c6470ffdfd --- /dev/null +++ b/tests/baselines/reference/classHeritageWithTrailingSeparator.js @@ -0,0 +1,24 @@ +//// [classHeritageWithTrailingSeparator.ts] +class C { foo: number } +class D extends C, { +} + +//// [classHeritageWithTrailingSeparator.js] +var __extends = 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 C = (function () { + function C() { + } + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(C); diff --git a/tests/baselines/reference/classPropertyAsPrivate.js b/tests/baselines/reference/classPropertyAsPrivate.js new file mode 100644 index 00000000000..8b59dcde771 --- /dev/null +++ b/tests/baselines/reference/classPropertyAsPrivate.js @@ -0,0 +1,63 @@ +//// [classPropertyAsPrivate.ts] +class C { + private x: string; + private get y() { return null; } + private set y(x) { } + private foo() { } + + private static a: string; + private static get b() { return null; } + private static set b(x) { } + private static foo() { } +} + +var c: C; +// all errors +c.x; +c.y; +c.y = 1; +c.foo(); + +C.a; +C.b(); +C.b = 1; +C.foo(); + +//// [classPropertyAsPrivate.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return null; + }, + set: function (x) { + }, + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + }; + Object.defineProperty(C, "b", { + get: function () { + return null; + }, + set: function (x) { + }, + enumerable: true, + configurable: true + }); + C.foo = function () { + }; + return C; +})(); +var c; +// all errors +c.x; +c.y; +c.y = 1; +c.foo(); +C.a; +C.b(); +C.b = 1; +C.foo(); diff --git a/tests/baselines/reference/classPropertyAsProtected.js b/tests/baselines/reference/classPropertyAsProtected.js new file mode 100644 index 00000000000..ddb193f072a --- /dev/null +++ b/tests/baselines/reference/classPropertyAsProtected.js @@ -0,0 +1,63 @@ +//// [classPropertyAsProtected.ts] +class C { + protected x: string; + protected get y() { return null; } + protected set y(x) { } + protected foo() { } + + protected static a: string; + protected static get b() { return null; } + protected static set b(x) { } + protected static foo() { } +} + +var c: C; +// all errors +c.x; +c.y; +c.y = 1; +c.foo(); + +C.a; +C.b(); +C.b = 1; +C.foo(); + +//// [classPropertyAsProtected.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return null; + }, + set: function (x) { + }, + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + }; + Object.defineProperty(C, "b", { + get: function () { + return null; + }, + set: function (x) { + }, + enumerable: true, + configurable: true + }); + C.foo = function () { + }; + return C; +})(); +var c; +// all errors +c.x; +c.y; +c.y = 1; +c.foo(); +C.a; +C.b(); +C.b = 1; +C.foo(); diff --git a/tests/baselines/reference/classPropertyIsPublicByDefault.js b/tests/baselines/reference/classPropertyIsPublicByDefault.js new file mode 100644 index 00000000000..db1eca56c11 --- /dev/null +++ b/tests/baselines/reference/classPropertyIsPublicByDefault.js @@ -0,0 +1,61 @@ +//// [classPropertyIsPublicByDefault.ts] +class C { + x: string; + get y() { return null; } + set y(x) { } + foo() { } + + static a: string; + static get b() { return null; } + static set b(x) { } + static foo() { } +} + +var c: C; +c.x; +c.y; +c.y = 1; +c.foo(); + +C.a; +C.b(); +C.b = 1; +C.foo(); + +//// [classPropertyIsPublicByDefault.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return null; + }, + set: function (x) { + }, + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + }; + Object.defineProperty(C, "b", { + get: function () { + return null; + }, + set: function (x) { + }, + enumerable: true, + configurable: true + }); + C.foo = function () { + }; + return C; +})(); +var c; +c.x; +c.y; +c.y = 1; +c.foo(); +C.a; +C.b(); +C.b = 1; +C.foo(); diff --git a/tests/baselines/reference/classWithOptionalParameter.js b/tests/baselines/reference/classWithOptionalParameter.js new file mode 100644 index 00000000000..082e624916a --- /dev/null +++ b/tests/baselines/reference/classWithOptionalParameter.js @@ -0,0 +1,29 @@ +//// [classWithOptionalParameter.ts] +// classes do not permit optional parameters, these are errors + +class C { + x?: string; + f?() {} +} + +class C2 { + x?: T; + f?(x: T) {} +} + +//// [classWithOptionalParameter.js] +// classes do not permit optional parameters, these are errors +var C = (function () { + function C() { + } + C.prototype.f = function () { + }; + return C; +})(); +var C2 = (function () { + function C2() { + } + C2.prototype.f = function (x) { + }; + return C2; +})(); diff --git a/tests/baselines/reference/classWithStaticMembers.js b/tests/baselines/reference/classWithStaticMembers.js new file mode 100644 index 00000000000..2cded4b1f2e --- /dev/null +++ b/tests/baselines/reference/classWithStaticMembers.js @@ -0,0 +1,60 @@ +//// [classWithStaticMembers.ts] +class C { + static fn() { return this; } + static get x() { return 1; } + static set x(v) { } + constructor(public a: number, private b: number) { } + static foo: string; +} + +var r = C.fn(); +var r2 = r.x; +var r3 = r.foo; + +class D extends C { + bar: string; +} + +var r = D.fn(); +var r2 = r.x; +var r3 = r.foo; + +//// [classWithStaticMembers.js] +var __extends = 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 C = (function () { + function C(a, b) { + this.a = a; + this.b = b; + } + C.fn = function () { + return this; + }; + Object.defineProperty(C, "x", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var r = C.fn(); +var r2 = r.x; +var r3 = r.foo; +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(C); +var r = D.fn(); +var r2 = r.x; +var r3 = r.foo; diff --git a/tests/baselines/reference/classdecl.js b/tests/baselines/reference/classdecl.js new file mode 100644 index 00000000000..6c6e542e032 --- /dev/null +++ b/tests/baselines/reference/classdecl.js @@ -0,0 +1,206 @@ +//// [classdecl.ts] +class a { + //constructor (); + constructor (n: number); + constructor (s: string); + constructor (ns: any) { + + } + + public pgF() { } + + public pv; + public get d() { + return 30; + } + public set d() { + } + + public static get p2() { + return { x: 30, y: 40 }; + } + + private static d2() { + } + private static get p3() { + return "string"; + } + private pv3; + + private foo(n: number): string; + private foo(s: string): string; + private foo(ns: any) { + return ns.toString(); + } +} + +class b extends a { +} + +module m1 { + export class b { + } + class d { + } + + + export interface ib { + } +} + +module m2 { + + export module m3 { + export class c extends b { + } + export class ib2 implements m1.ib { + } + } +} + +class c extends m1.b { +} + +class ib2 implements m1.ib { +} + +declare class aAmbient { + constructor (n: number); + constructor (s: string); + public pgF(): void; + public pv; + public d : number; + static p2 : { x: number; y: number; }; + static d2(); + static p3; + private pv3; + private foo(s); +} + +class d { + private foo(n: number): string; + private foo(s: string): string; + private foo(ns: any) { + return ns.toString(); + } +} + +class e { + private foo(s: string): string; + private foo(n: number): string; + private foo(ns: any) { + return ns.toString(); + } +} + +//// [classdecl.js] +var __extends = 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 a = (function () { + function a(ns) { + } + a.prototype.pgF = function () { + }; + Object.defineProperty(a.prototype, "d", { + get: function () { + return 30; + }, + set: function () { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(a, "p2", { + get: function () { + return { x: 30, y: 40 }; + }, + enumerable: true, + configurable: true + }); + a.d2 = function () { + }; + Object.defineProperty(a, "p3", { + get: function () { + return "string"; + }, + enumerable: true, + configurable: true + }); + a.prototype.foo = function (ns) { + return ns.toString(); + }; + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + return b; +})(a); +var m1; +(function (m1) { + var b = (function () { + function b() { + } + return b; + })(); + m1.b = b; + var d = (function () { + function d() { + } + return d; + })(); +})(m1 || (m1 = {})); +var m2; +(function (m2) { + var m3; + (function (m3) { + var c = (function (_super) { + __extends(c, _super); + function c() { + _super.apply(this, arguments); + } + return c; + })(b); + m3.c = c; + var ib2 = (function () { + function ib2() { + } + return ib2; + })(); + m3.ib2 = ib2; + })(m3 = m2.m3 || (m2.m3 = {})); +})(m2 || (m2 = {})); +var c = (function (_super) { + __extends(c, _super); + function c() { + _super.apply(this, arguments); + } + return c; +})(m1.b); +var ib2 = (function () { + function ib2() { + } + return ib2; +})(); +var d = (function () { + function d() { + } + d.prototype.foo = function (ns) { + return ns.toString(); + }; + return d; +})(); +var e = (function () { + function e() { + } + e.prototype.foo = function (ns) { + return ns.toString(); + }; + return e; +})(); diff --git a/tests/baselines/reference/cloduleWithDuplicateMember1.js b/tests/baselines/reference/cloduleWithDuplicateMember1.js new file mode 100644 index 00000000000..ed4d69545fc --- /dev/null +++ b/tests/baselines/reference/cloduleWithDuplicateMember1.js @@ -0,0 +1,52 @@ +//// [cloduleWithDuplicateMember1.ts] +class C { + get x() { return 1; } + static get x() { + return ''; + } + static foo() { } +} + +module C { + export var x = 1; +} +module C { + export function foo() { } + export function x() { } +} + +//// [cloduleWithDuplicateMember1.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "x", { + get: function () { + return ''; + }, + enumerable: true, + configurable: true + }); + C.foo = function () { + }; + return C; +})(); +var C; +(function (C) { + C.x = 1; +})(C || (C = {})); +var C; +(function (C) { + function foo() { + } + C.foo = foo; + function x() { + } + C.x = x; +})(C || (C = {})); diff --git a/tests/baselines/reference/cloduleWithDuplicateMember2.js b/tests/baselines/reference/cloduleWithDuplicateMember2.js new file mode 100644 index 00000000000..461930c02ae --- /dev/null +++ b/tests/baselines/reference/cloduleWithDuplicateMember2.js @@ -0,0 +1,41 @@ +//// [cloduleWithDuplicateMember2.ts] +class C { + set x(y) { } + static set y(z) { } +} + +module C { + export var x = 1; +} +module C { + export function x() { } +} + +//// [cloduleWithDuplicateMember2.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + set: function (y) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "y", { + set: function (z) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var C; +(function (C) { + C.x = 1; +})(C || (C = {})); +var C; +(function (C) { + function x() { + } + C.x = x; +})(C || (C = {})); diff --git a/tests/baselines/reference/collisionCodeGenModuleWithAccessorChildren.js b/tests/baselines/reference/collisionCodeGenModuleWithAccessorChildren.js new file mode 100644 index 00000000000..9db005de9b9 --- /dev/null +++ b/tests/baselines/reference/collisionCodeGenModuleWithAccessorChildren.js @@ -0,0 +1,126 @@ +//// [collisionCodeGenModuleWithAccessorChildren.ts] +module M { + export var x = 3; + class c { + private y; + set Z(M) { + this.y = x; + } + } +} + +module M { + class d { + private y; + set Z(p) { + var M = 10; + this.y = x; + } + } +} + +module M { // Shouldnt be _M + class e { + private y; + set M(p) { + this.y = x; + } + } +} + +module M { + class f { + get Z() { + var M = 10; + return x; + } + } +} + +module M { // Shouldnt be _M + class e { + get M() { + return x; + } + } +} + +//// [collisionCodeGenModuleWithAccessorChildren.js] +var M; +(function (_M) { + _M.x = 3; + var c = (function () { + function c() { + } + Object.defineProperty(c.prototype, "Z", { + set: function (M) { + this.y = _M.x; + }, + enumerable: true, + configurable: true + }); + return c; + })(); +})(M || (M = {})); +var M; +(function (_M) { + var d = (function () { + function d() { + } + Object.defineProperty(d.prototype, "Z", { + set: function (p) { + var M = 10; + this.y = _M.x; + }, + enumerable: true, + configurable: true + }); + return d; + })(); +})(M || (M = {})); +var M; +(function (M) { + var e = (function () { + function e() { + } + Object.defineProperty(e.prototype, "M", { + set: function (p) { + this.y = M.x; + }, + enumerable: true, + configurable: true + }); + return e; + })(); +})(M || (M = {})); +var M; +(function (_M) { + var f = (function () { + function f() { + } + Object.defineProperty(f.prototype, "Z", { + get: function () { + var M = 10; + return _M.x; + }, + enumerable: true, + configurable: true + }); + return f; + })(); +})(M || (M = {})); +var M; +(function (M) { + var e = (function () { + function e() { + } + Object.defineProperty(e.prototype, "M", { + get: function () { + return M.x; + }, + enumerable: true, + configurable: true + }); + return e; + })(); +})(M || (M = {})); diff --git a/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js new file mode 100644 index 00000000000..92ddebd156c --- /dev/null +++ b/tests/baselines/reference/collisionSuperAndLocalFunctionInAccessors.js @@ -0,0 +1,112 @@ +//// [collisionSuperAndLocalFunctionInAccessors.ts] +function _super() { // No error +} +class Foo { + get prop1(): number { + function _super() { // No error + } + return 10; + } + set prop1(val: number) { + function _super() { // No error + } + } +} +class b extends Foo { + get prop2(): number { + function _super() { // Should be error + } + return 10; + } + set prop2(val: number) { + function _super() { // Should be error + } + } +} +class c extends Foo { + get prop2(): number { + var x = () => { + function _super() { // Should be error + } + } + return 10; + } + set prop2(val: number) { + var x = () => { + function _super() { // Should be error + } + } + } +} + +//// [collisionSuperAndLocalFunctionInAccessors.js] +var __extends = 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 __(); +}; +function _super() { +} +var Foo = (function () { + function Foo() { + } + Object.defineProperty(Foo.prototype, "prop1", { + get: function () { + function _super() { + } + return 10; + }, + set: function (val) { + function _super() { + } + }, + enumerable: true, + configurable: true + }); + return Foo; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + Object.defineProperty(b.prototype, "prop2", { + get: function () { + function _super() { + } + return 10; + }, + set: function (val) { + function _super() { + } + }, + enumerable: true, + configurable: true + }); + return b; +})(Foo); +var c = (function (_super) { + __extends(c, _super); + function c() { + _super.apply(this, arguments); + } + Object.defineProperty(c.prototype, "prop2", { + get: function () { + var x = function () { + function _super() { + } + }; + return 10; + }, + set: function (val) { + var x = function () { + function _super() { + } + }; + }, + enumerable: true, + configurable: true + }); + return c; +})(Foo); diff --git a/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js new file mode 100644 index 00000000000..5a8e54a6c3d --- /dev/null +++ b/tests/baselines/reference/collisionSuperAndLocalVarInAccessors.js @@ -0,0 +1,98 @@ +//// [collisionSuperAndLocalVarInAccessors.ts] +var _super = 10; // No Error +class Foo { + get prop1(): number { + var _super = 10; // No error + return 10; + } + set prop1(val: number) { + var _super = 10; // No error + } +} +class b extends Foo { + get prop2(): number { + var _super = 10; // Should be error + return 10; + } + set prop2(val: number) { + var _super = 10; // Should be error + } +} +class c extends Foo { + get prop2(): number { + var x = () => { + var _super = 10; // Should be error + } + return 10; + } + set prop2(val: number) { + var x = () => { + var _super = 10; // Should be error + } + } +} + +//// [collisionSuperAndLocalVarInAccessors.js] +var __extends = 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 _super = 10; // No Error +var Foo = (function () { + function Foo() { + } + Object.defineProperty(Foo.prototype, "prop1", { + get: function () { + var _super = 10; // No error + return 10; + }, + set: function (val) { + var _super = 10; // No error + }, + enumerable: true, + configurable: true + }); + return Foo; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + Object.defineProperty(b.prototype, "prop2", { + get: function () { + var _super = 10; // Should be error + return 10; + }, + set: function (val) { + var _super = 10; // Should be error + }, + enumerable: true, + configurable: true + }); + return b; +})(Foo); +var c = (function (_super) { + __extends(c, _super); + function c() { + _super.apply(this, arguments); + } + Object.defineProperty(c.prototype, "prop2", { + get: function () { + var x = function () { + var _super = 10; // Should be error + }; + return 10; + }, + set: function (val) { + var x = function () { + var _super = 10; // Should be error + }; + }, + enumerable: true, + configurable: true + }); + return c; +})(Foo); diff --git a/tests/baselines/reference/collisionSuperAndParameter.js b/tests/baselines/reference/collisionSuperAndParameter.js new file mode 100644 index 00000000000..be9e0ce3f68 --- /dev/null +++ b/tests/baselines/reference/collisionSuperAndParameter.js @@ -0,0 +1,136 @@ +//// [collisionSuperAndParameter.ts] +class Foo { + a() { + var lamda = (_super: number) => { // No Error + return x => this; // New scope. So should inject new _this capture + } + } + b(_super: number) { // No Error + var lambda = () => { + return x => this; // New scope. So should inject new _this capture + } + } + set c(_super: number) { // No error + } +} +class Foo2 extends Foo { + x() { + var lamda = (_super: number) => { // Error + return x => this; // New scope. So should inject new _this capture + } + } + y(_super: number) { // Error + var lambda = () => { + return x => this; // New scope. So should inject new _this capture + } + } + set z(_super: number) { // Error + } + public prop3: { + doStuff: (_super: number) => void; // no error - no code gen + } + public prop4 = { + doStuff: (_super: number) => { // should be error + } + } + constructor(_super: number) { // should be error + super(); + } +} +declare class Foo3 extends Foo { + x(); + y(_super: number); // No error - no code gen + constructor(_super: number); // No error - no code gen + public prop2: { + doStuff: (_super: number) => void; // no error - no code gen + }; + public _super: number; // No error +} + +class Foo4 extends Foo { + constructor(_super: number); // no code gen - no error + constructor(_super: string);// no code gen - no error + constructor(_super: any) { // should be error + super(); + } + y(_super: number); // no code gen - no error + y(_super: string); // no code gen - no error + y(_super: any) { // Error + var lambda = () => { + return x => this; // New scope. So should inject new _this capture + } + } +} + +//// [collisionSuperAndParameter.js] +var __extends = 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.a = function () { + var _this = this; + var lamda = function (_super) { + return function (x) { return _this; }; // New scope. So should inject new _this capture + }; + }; + Foo.prototype.b = function (_super) { + var _this = this; + var lambda = function () { + return function (x) { return _this; }; // New scope. So should inject new _this capture + }; + }; + Object.defineProperty(Foo.prototype, "c", { + set: function (_super) { + }, + enumerable: true, + configurable: true + }); + return Foo; +})(); +var Foo2 = (function (_super) { + __extends(Foo2, _super); + function Foo2(_super) { + _super.call(this); + this.prop4 = { + doStuff: function (_super) { + } + }; + } + Foo2.prototype.x = function () { + var _this = this; + var lamda = function (_super) { + return function (x) { return _this; }; // New scope. So should inject new _this capture + }; + }; + Foo2.prototype.y = function (_super) { + var _this = this; + var lambda = function () { + return function (x) { return _this; }; // New scope. So should inject new _this capture + }; + }; + Object.defineProperty(Foo2.prototype, "z", { + set: function (_super) { + }, + enumerable: true, + configurable: true + }); + return Foo2; +})(Foo); +var Foo4 = (function (_super) { + __extends(Foo4, _super); + function Foo4(_super) { + _super.call(this); + } + Foo4.prototype.y = function (_super) { + var _this = this; + var lambda = function () { + return function (x) { return _this; }; // New scope. So should inject new _this capture + }; + }; + return Foo4; +})(Foo); diff --git a/tests/baselines/reference/collisionThisExpressionAndLocalVarInAccessors.js b/tests/baselines/reference/collisionThisExpressionAndLocalVarInAccessors.js new file mode 100644 index 00000000000..53df2984544 --- /dev/null +++ b/tests/baselines/reference/collisionThisExpressionAndLocalVarInAccessors.js @@ -0,0 +1,102 @@ +//// [collisionThisExpressionAndLocalVarInAccessors.ts] +class class1 { + get a(): number { + var x2 = { + doStuff: (callback) => () => { + var _this = 2; + return callback(this); + } + } + + return 10; + } + set a(val: number) { + var x2 = { + doStuff: (callback) => () => { + var _this = 2; + return callback(this); + } + } + + } +} + +class class2 { + get a(): number { + var _this = 2; + var x2 = { + doStuff: (callback) => () => { + return callback(this); + } + } + + return 10; + } + set a(val: number) { + var _this = 2; + var x2 = { + doStuff: (callback) => () => { + return callback(this); + } + } + + } +} + +//// [collisionThisExpressionAndLocalVarInAccessors.js] +var class1 = (function () { + function class1() { + } + Object.defineProperty(class1.prototype, "a", { + get: function () { + var _this = this; + var x2 = { + doStuff: function (callback) { return function () { + var _this = 2; + return callback(_this); + }; } + }; + return 10; + }, + set: function (val) { + var _this = this; + var x2 = { + doStuff: function (callback) { return function () { + var _this = 2; + return callback(_this); + }; } + }; + }, + enumerable: true, + configurable: true + }); + return class1; +})(); +var class2 = (function () { + function class2() { + } + Object.defineProperty(class2.prototype, "a", { + get: function () { + var _this = this; + var _this = 2; + var x2 = { + doStuff: function (callback) { return function () { + return callback(_this); + }; } + }; + return 10; + }, + set: function (val) { + var _this = this; + var _this = 2; + var x2 = { + doStuff: function (callback) { return function () { + return callback(_this); + }; } + }; + }, + enumerable: true, + configurable: true + }); + return class2; +})(); diff --git a/tests/baselines/reference/commentOnClassAccessor1.js b/tests/baselines/reference/commentOnClassAccessor1.js new file mode 100644 index 00000000000..cdd14a829fc --- /dev/null +++ b/tests/baselines/reference/commentOnClassAccessor1.js @@ -0,0 +1,24 @@ +//// [commentOnClassAccessor1.ts] +class C { + /** + * @type {number} + */ + get bar(): number { return 1;} +} + +//// [commentOnClassAccessor1.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "bar", { + /** + * @type {number} + */ + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/commentOnClassAccessor2.js b/tests/baselines/reference/commentOnClassAccessor2.js new file mode 100644 index 00000000000..c85d17e6e19 --- /dev/null +++ b/tests/baselines/reference/commentOnClassAccessor2.js @@ -0,0 +1,34 @@ +//// [commentOnClassAccessor2.ts] +class C { + /** + * Getter. + */ + get bar(): number { return 1;} + + /** + * Setter. + */ + set bar(v) { } +} + +//// [commentOnClassAccessor2.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "bar", { + /** + * Getter. + */ + get: function () { + return 1; + }, + /** + * Setter. + */ + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/computedPropertyNames12.js b/tests/baselines/reference/computedPropertyNames12.js new file mode 100644 index 00000000000..5e5dec0c549 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames12.js @@ -0,0 +1,31 @@ +//// [computedPropertyNames12.ts] +var s: string; +var n: number; +var a: any; +class C { + [s]: number; + [n] = n; + static [s + s]: string; + [s + n] = 2; + [+s]: typeof s; + static [""]: number; + [0]: number; + [a]: number; + static [true]: number; + [`hello bye`] = 0; + static [`hello ${a} bye`] = 0 +} + +//// [computedPropertyNames12.js] +var s; +var n; +var a; +var C = (function () { + function C() { + this[n] = n; + this[s + n] = 2; + this[`hello bye`] = 0; + } + C[`hello ${a} bye`] = 0; + return C; +})(); diff --git a/tests/baselines/reference/computedPropertyNames35.js b/tests/baselines/reference/computedPropertyNames35.js new file mode 100644 index 00000000000..5a731fd8bda --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames35.js @@ -0,0 +1,11 @@ +//// [computedPropertyNames35.ts] +function foo() { return '' } +interface I { + bar(): string; + [foo()](): void; +} + +//// [computedPropertyNames35.js] +function foo() { + return ''; +} diff --git a/tests/baselines/reference/computedPropertyNames42.js b/tests/baselines/reference/computedPropertyNames42.js new file mode 100644 index 00000000000..c9f24a1c708 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNames42.js @@ -0,0 +1,27 @@ +//// [computedPropertyNames42.ts] +class Foo { x } +class Foo2 { x; y } + +class C { + [s: string]: Foo2; + + // Computed properties + [""]: Foo; +} + +//// [computedPropertyNames42.js] +var Foo = (function () { + function Foo() { + } + return Foo; +})(); +var Foo2 = (function () { + function Foo2() { + } + return Foo2; +})(); +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit3.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3.js new file mode 100644 index 00000000000..df351acf6e9 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit3.js @@ -0,0 +1,6 @@ +//// [computedPropertyNamesDeclarationEmit3.ts] +interface I { + ["" + ""](): void; +} + +//// [computedPropertyNamesDeclarationEmit3.js] diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit4.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4.js new file mode 100644 index 00000000000..870f87bb613 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit4.js @@ -0,0 +1,7 @@ +//// [computedPropertyNamesDeclarationEmit4.ts] +var v: { + ["" + ""](): void; +} + +//// [computedPropertyNamesDeclarationEmit4.js] +var v; diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads.js b/tests/baselines/reference/computedPropertyNamesOnOverloads.js new file mode 100644 index 00000000000..1db857620e9 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads.js @@ -0,0 +1,19 @@ +//// [computedPropertyNamesOnOverloads.ts] +var methodName = "method"; +var accessorName = "accessor"; +class C { + [methodName](v: string); + [methodName](); + [methodName](v?: string) { } +} + +//// [computedPropertyNamesOnOverloads.js] +var methodName = "method"; +var accessorName = "accessor"; +var C = (function () { + function C() { + } + C.prototype[methodName] = function (v) { + }; + return C; +})(); diff --git a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration.js b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration.js new file mode 100644 index 00000000000..9fcc9f8f568 --- /dev/null +++ b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration.js @@ -0,0 +1,43 @@ +//// [constDeclarationShadowedByVarDeclaration.ts] + +// Error as declaration of var would cause a write to the const value +var x = 0; +{ + const x = 0; + + var x = 0; +} + + +var y = 0; +{ + const y = 0; + { + var y = 0; + } +} + + +{ + const z = 0; + var z = 0 +} + +//// [constDeclarationShadowedByVarDeclaration.js] +// Error as declaration of var would cause a write to the const value +var x = 0; +{ + const x = 0; + var x = 0; +} +var y = 0; +{ + const y = 0; + { + var y = 0; + } +} +{ + const z = 0; + var z = 0; +} diff --git a/tests/baselines/reference/constDeclarations-access.js b/tests/baselines/reference/constDeclarations-access.js new file mode 100644 index 00000000000..ba913f2d5fc --- /dev/null +++ b/tests/baselines/reference/constDeclarations-access.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/constDeclarations-access.ts] //// + +//// [file1.ts] + +const x = 0 + +//// [file2.ts] +x++; + +//// [file1.js] +const x = 0; +//// [file2.js] +x++; diff --git a/tests/baselines/reference/constDeclarations-access2.js b/tests/baselines/reference/constDeclarations-access2.js new file mode 100644 index 00000000000..fd51c932636 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-access2.js @@ -0,0 +1,74 @@ +//// [constDeclarations-access2.ts] + +const x = 0 + +// Errors +x = 1; +x += 2; +x -= 3; +x *= 4; +x /= 5; +x %= 6; +x <<= 7; +x >>= 8; +x >>>= 9; +x &= 10; +x |= 11; +x ^= 12; + +x++; +x--; +++x; +--x; + +++((x)); + +// OK +var a = x + 1; + +function f(v: number) { } +f(x); + +if (x) { } + +x; +(x); + +-x; ++x; + +x.toString(); + + +//// [constDeclarations-access2.js] +const x = 0; +// Errors +x = 1; +x += 2; +x -= 3; +x *= 4; +x /= 5; +x %= 6; +x <<= 7; +x >>= 8; +x >>>= 9; +x &= 10; +x |= 11; +x ^= 12; +x++; +x--; +++x; +--x; +++((x)); +// OK +var a = x + 1; +function f(v) { +} +f(x); +if (x) { +} +x; +(x); +-x; ++x; +x.toString(); diff --git a/tests/baselines/reference/constDeclarations-access3.js b/tests/baselines/reference/constDeclarations-access3.js new file mode 100644 index 00000000000..9ac4880bdd1 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-access3.js @@ -0,0 +1,83 @@ +//// [constDeclarations-access3.ts] + + +module M { + export const x = 0; +} + +// Errors +M.x = 1; +M.x += 2; +M.x -= 3; +M.x *= 4; +M.x /= 5; +M.x %= 6; +M.x <<= 7; +M.x >>= 8; +M.x >>>= 9; +M.x &= 10; +M.x |= 11; +M.x ^= 12; + +M.x++; +M.x--; +++M.x; +--M.x; + +++((M.x)); + +M["x"] = 0; + +// OK +var a = M.x + 1; + +function f(v: number) { } +f(M.x); + +if (M.x) { } + +M.x; +(M.x); + +-M.x; ++M.x; + +M.x.toString(); + + +//// [constDeclarations-access3.js] +var M; +(function (M) { + M.x = 0; +})(M || (M = {})); +// Errors +M.x = 1; +M.x += 2; +M.x -= 3; +M.x *= 4; +M.x /= 5; +M.x %= 6; +M.x <<= 7; +M.x >>= 8; +M.x >>>= 9; +M.x &= 10; +M.x |= 11; +M.x ^= 12; +M.x++; +M.x--; +++M.x; +--M.x; +++((M.x)); +M["x"] = 0; +// OK +var a = M.x + 1; +function f(v) { +} +f(M.x); +if (M.x) { +} +M.x; +(M.x); +-M.x; ++M.x; +M.x.toString(); diff --git a/tests/baselines/reference/constDeclarations-access4.js b/tests/baselines/reference/constDeclarations-access4.js new file mode 100644 index 00000000000..b226e746bba --- /dev/null +++ b/tests/baselines/reference/constDeclarations-access4.js @@ -0,0 +1,79 @@ +//// [constDeclarations-access4.ts] + + +declare module M { + const x: number; +} + +// Errors +M.x = 1; +M.x += 2; +M.x -= 3; +M.x *= 4; +M.x /= 5; +M.x %= 6; +M.x <<= 7; +M.x >>= 8; +M.x >>>= 9; +M.x &= 10; +M.x |= 11; +M.x ^= 12; + +M.x++; +M.x--; +++M.x; +--M.x; + +++((M.x)); + +M["x"] = 0; + +// OK +var a = M.x + 1; + +function f(v: number) { } +f(M.x); + +if (M.x) { } + +M.x; +(M.x); + +-M.x; ++M.x; + +M.x.toString(); + + +//// [constDeclarations-access4.js] +// Errors +M.x = 1; +M.x += 2; +M.x -= 3; +M.x *= 4; +M.x /= 5; +M.x %= 6; +M.x <<= 7; +M.x >>= 8; +M.x >>>= 9; +M.x &= 10; +M.x |= 11; +M.x ^= 12; +M.x++; +M.x--; +++M.x; +--M.x; +++((M.x)); +M["x"] = 0; +// OK +var a = M.x + 1; +function f(v) { +} +f(M.x); +if (M.x) { +} +M.x; +(M.x); +-M.x; ++M.x; +M.x.toString(); diff --git a/tests/baselines/reference/constDeclarations-access5.js b/tests/baselines/reference/constDeclarations-access5.js new file mode 100644 index 00000000000..7acc95ad055 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-access5.js @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/constDeclarations-access5.ts] //// + +//// [constDeclarations_access_1.ts] + + +export const x = 0; + +//// [constDeclarations_access_2.ts] +/// +import m = require('constDeclarations_access_1'); +// Errors +m.x = 1; +m.x += 2; +m.x -= 3; +m.x *= 4; +m.x /= 5; +m.x %= 6; +m.x <<= 7; +m.x >>= 8; +m.x >>>= 9; +m.x &= 10; +m.x |= 11; +m.x ^= 12; +m +m.x++; +m.x--; +++m.x; +--m.x; + +++((m.x)); + +m["x"] = 0; + +// OK +var a = m.x + 1; + +function f(v: number) { } +f(m.x); + +if (m.x) { } + +m.x; +(m.x); + +-m.x; ++m.x; + +m.x.toString(); + + +//// [constDeclarations_access_1.js] +define(["require", "exports"], function (require, exports) { + exports.x = 0; +}); +//// [constDeclarations_access_2.js] +define(["require", "exports", 'constDeclarations_access_1'], function (require, exports, m) { + // Errors + m.x = 1; + m.x += 2; + m.x -= 3; + m.x *= 4; + m.x /= 5; + m.x %= 6; + m.x <<= 7; + m.x >>= 8; + m.x >>>= 9; + m.x &= 10; + m.x |= 11; + m.x ^= 12; + m; + m.x++; + m.x--; + ++m.x; + --m.x; + ++((m.x)); + m["x"] = 0; + // OK + var a = m.x + 1; + function f(v) { + } + f(m.x); + if (m.x) { + } + m.x; + (m.x); + -m.x; + +m.x; + m.x.toString(); +}); diff --git a/tests/baselines/reference/constDeclarations-ambient-errors.js b/tests/baselines/reference/constDeclarations-ambient-errors.js new file mode 100644 index 00000000000..e6e7ac1fb16 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-ambient-errors.js @@ -0,0 +1,13 @@ +//// [constDeclarations-ambient-errors.ts] + +// error: no intialization expected in ambient declarations +declare const c1: boolean = true; +declare const c2: number = 0; +declare const c3 = null, c4 :string = "", c5: any = 0; + +declare module M { + const c6 = 0; + const c7: number = 7; +} + +//// [constDeclarations-ambient-errors.js] diff --git a/tests/baselines/reference/constDeclarations-errors.js b/tests/baselines/reference/constDeclarations-errors.js new file mode 100644 index 00000000000..0af646010f0 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-errors.js @@ -0,0 +1,36 @@ +//// [constDeclarations-errors.ts] + +// error, missing intialicer +const c1; +const c2: number; +const c3, c4, c5 :string, c6; // error, missing initialicer + +// error, can not be unintalized +for(const c in {}) { } + +// error, assigning to a const +for(const c8 = 0; c8 < 1; c8++) { } + +// error, can not be unintalized +for(const c9; c9 < 1;) { } + +// error, can not be unintalized +for(const c10 = 0, c11; c10 < 1;) { } + +//// [constDeclarations-errors.js] +// error, missing intialicer +const c1; +const c2; +const c3, c4, c5, c6; // error, missing initialicer +// error, can not be unintalized +for (var c in {}) { +} +// error, assigning to a const +for (const c8 = 0; c8 < 1; c8++) { +} +// error, can not be unintalized +for (const c9; c9 < 1;) { +} +// error, can not be unintalized +for (const c10 = 0, c11; c10 < 1;) { +} diff --git a/tests/baselines/reference/constDeclarations-es5.js b/tests/baselines/reference/constDeclarations-es5.js new file mode 100644 index 00000000000..20deb9dca37 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-es5.js @@ -0,0 +1,11 @@ +//// [constDeclarations-es5.ts] + +const z7 = false; +const z8: number = 23; +const z9 = 0, z10 :string = "", z11 = null; + + +//// [constDeclarations-es5.js] +const z7 = false; +const z8 = 23; +const z9 = 0, z10 = "", z11 = null; diff --git a/tests/baselines/reference/constDeclarations-invalidContexts.js b/tests/baselines/reference/constDeclarations-invalidContexts.js new file mode 100644 index 00000000000..a9dc1b47145 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-invalidContexts.js @@ -0,0 +1,57 @@ +//// [constDeclarations-invalidContexts.ts] + +// Errors, const must be defined inside a block +if (true) + const c1 = 0; +else + const c2 = 0; + +while (true) + const c3 = 0; + +do + const c4 = 0; +while (true); + +var obj; +with (obj) + const c5 = 0; // No Error will be reported here since we turn off all type checking + +for (var i = 0; i < 10; i++) + const c6 = 0; + +for (var i2 in {}) + const c7 = 0; + +if (true) + label: const c8 = 0; + +while (false) + label2: label3: label4: const c9 = 0; + + + + + +//// [constDeclarations-invalidContexts.js] +// Errors, const must be defined inside a block +if (true) + const c1 = 0; +else + const c2 = 0; +while (true) + const c3 = 0; +do + const c4 = 0; +while (true); +var obj; +with (obj) + const c5 = 0; // No Error will be reported here since we turn off all type checking +for (var i = 0; i < 10; i++) + const c6 = 0; +for (var i2 in {}) + const c7 = 0; +if (true) + label: const c8 = 0; +while (false) + label2: label3: label4: const c9 = 0; diff --git a/tests/baselines/reference/constDeclarations-useBeforeDefinition.js b/tests/baselines/reference/constDeclarations-useBeforeDefinition.js new file mode 100644 index 00000000000..4fe0e64f275 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-useBeforeDefinition.js @@ -0,0 +1,24 @@ +//// [constDeclarations-useBeforeDefinition.ts] + +{ + c1; + const c1 = 0; +} + +var v1; +{ + v1; + const v1 = 0; +} + + +//// [constDeclarations-useBeforeDefinition.js] +{ + c1; + const c1 = 0; +} +var v1; +{ + v1; + const v1 = 0; +} diff --git a/tests/baselines/reference/constDeclarations-useBeforeDefinition2.js b/tests/baselines/reference/constDeclarations-useBeforeDefinition2.js new file mode 100644 index 00000000000..7d1f4cf5725 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-useBeforeDefinition2.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/constDeclarations-useBeforeDefinition2.ts] //// + +//// [file1.ts] + +c; + +//// [file2.ts] +const c = 0; + +//// [out.js] +c; +const c = 0; diff --git a/tests/baselines/reference/constEnumBadPropertyNames.js b/tests/baselines/reference/constEnumBadPropertyNames.js new file mode 100644 index 00000000000..b73eed780e5 --- /dev/null +++ b/tests/baselines/reference/constEnumBadPropertyNames.js @@ -0,0 +1,6 @@ +//// [constEnumBadPropertyNames.ts] +const enum E { A } +var x = E["B"] + +//// [constEnumBadPropertyNames.js] +var x = E["B"]; diff --git a/tests/baselines/reference/constEnumErrors.js b/tests/baselines/reference/constEnumErrors.js new file mode 100644 index 00000000000..4afd98982f0 --- /dev/null +++ b/tests/baselines/reference/constEnumErrors.js @@ -0,0 +1,58 @@ +//// [constEnumErrors.ts] +const enum E { + A +} + +module E { + var x = 1; +} + +const enum E1 { + // illegal case + // forward reference to the element of the same enum + X = Y, + // forward reference to the element of the same enum + Y = E1.Z, + Y1 = E1["Z"] +} + +const enum E2 { + A +} + +var y0 = E2[1] +var name = "A"; +var y1 = E2[name]; + +var x = E2; +var y = [E2]; + +function foo(t: any): void { +} + +foo(E2); + +const enum NaNOrInfinity { + A = 9007199254740992, + B = A * A, + C = B * B, + D = C * C, + E = D * D, + F = E * E, // overflow + G = 1 / 0, // overflow + H = 0 / 0 // NaN +} + +//// [constEnumErrors.js] +var E; +(function (E) { + var x = 1; +})(E || (E = {})); +var y0 = E2[1]; +var name = "A"; +var y1 = E2[name]; +var x = E2; +var y = [E2]; +function foo(t) { +} +foo(E2); diff --git a/tests/baselines/reference/constructorArgsErrors1.js b/tests/baselines/reference/constructorArgsErrors1.js new file mode 100644 index 00000000000..25701901e13 --- /dev/null +++ b/tests/baselines/reference/constructorArgsErrors1.js @@ -0,0 +1,12 @@ +//// [constructorArgsErrors1.ts] +class foo { + constructor (static a: number) { + } +} + +//// [constructorArgsErrors1.js] +var foo = (function () { + function foo(a) { + } + return foo; +})(); diff --git a/tests/baselines/reference/constructorArgsErrors2.js b/tests/baselines/reference/constructorArgsErrors2.js new file mode 100644 index 00000000000..a0cab9f39f8 --- /dev/null +++ b/tests/baselines/reference/constructorArgsErrors2.js @@ -0,0 +1,14 @@ +//// [constructorArgsErrors2.ts] +class foo { + constructor (public static a: number) { + } +} + + +//// [constructorArgsErrors2.js] +var foo = (function () { + function foo(a) { + this.a = a; + } + return foo; +})(); diff --git a/tests/baselines/reference/constructorArgsErrors3.js b/tests/baselines/reference/constructorArgsErrors3.js new file mode 100644 index 00000000000..3f9b09254a1 --- /dev/null +++ b/tests/baselines/reference/constructorArgsErrors3.js @@ -0,0 +1,14 @@ +//// [constructorArgsErrors3.ts] +class foo { + constructor (public public a: number) { + } +} + + +//// [constructorArgsErrors3.js] +var foo = (function () { + function foo(a) { + this.a = a; + } + return foo; +})(); diff --git a/tests/baselines/reference/constructorArgsErrors4.js b/tests/baselines/reference/constructorArgsErrors4.js new file mode 100644 index 00000000000..c0646a54148 --- /dev/null +++ b/tests/baselines/reference/constructorArgsErrors4.js @@ -0,0 +1,14 @@ +//// [constructorArgsErrors4.ts] +class foo { + constructor (private public a: number) { + } +} + + +//// [constructorArgsErrors4.js] +var foo = (function () { + function foo(a) { + this.a = a; + } + return foo; +})(); diff --git a/tests/baselines/reference/constructorArgsErrors5.js b/tests/baselines/reference/constructorArgsErrors5.js new file mode 100644 index 00000000000..3455490aa6f --- /dev/null +++ b/tests/baselines/reference/constructorArgsErrors5.js @@ -0,0 +1,13 @@ +//// [constructorArgsErrors5.ts] +class foo { + constructor (export a: number) { + } +} + + +//// [constructorArgsErrors5.js] +var foo = (function () { + function foo(a) { + } + return foo; +})(); diff --git a/tests/baselines/reference/constructorOverloads6.js b/tests/baselines/reference/constructorOverloads6.js new file mode 100644 index 00000000000..1996449165c --- /dev/null +++ b/tests/baselines/reference/constructorOverloads6.js @@ -0,0 +1,32 @@ +//// [constructorOverloads6.ts] +declare class FooBase { + constructor(s: string); + constructor(n: number); + constructor(x: any) { + + } + bar1():void; +} + + declare class Foo extends FooBase { + constructor(s: string); + constructor(n: number); + constructor(x: any, y?:any); + + bar1():void; +} + +var f1 = new Foo("hey"); +var f2 = new Foo(0); +var f3 = new Foo(f1); +var f4 = new Foo([f1,f2,f3]); + +f1.bar1(); + + +//// [constructorOverloads6.js] +var f1 = new Foo("hey"); +var f2 = new Foo(0); +var f3 = new Foo(f1); +var f4 = new Foo([f1, f2, f3]); +f1.bar1(); diff --git a/tests/baselines/reference/contextualTypingOfAccessors.js b/tests/baselines/reference/contextualTypingOfAccessors.js new file mode 100644 index 00000000000..45463936831 --- /dev/null +++ b/tests/baselines/reference/contextualTypingOfAccessors.js @@ -0,0 +1,25 @@ +//// [contextualTypingOfAccessors.ts] +// not contextually typing accessors + +var x: { + foo: (x: number) => number; +} + +x = { + get foo() { + return (n)=>n + }, + set foo(x) {} +} + + +//// [contextualTypingOfAccessors.js] +// not contextually typing accessors +var x; +x = { + get foo() { + return function (n) { return n; }; + }, + set foo(x) { + } +}; diff --git a/tests/baselines/reference/continueNotInIterationStatement1.js b/tests/baselines/reference/continueNotInIterationStatement1.js new file mode 100644 index 00000000000..b6fd1786cdf --- /dev/null +++ b/tests/baselines/reference/continueNotInIterationStatement1.js @@ -0,0 +1,5 @@ +//// [continueNotInIterationStatement1.ts] +continue; + +//// [continueNotInIterationStatement1.js] +continue; diff --git a/tests/baselines/reference/continueNotInIterationStatement2.js b/tests/baselines/reference/continueNotInIterationStatement2.js new file mode 100644 index 00000000000..047c3b49f06 --- /dev/null +++ b/tests/baselines/reference/continueNotInIterationStatement2.js @@ -0,0 +1,13 @@ +//// [continueNotInIterationStatement2.ts] +while (true) { + function f() { + continue; + } +} + +//// [continueNotInIterationStatement2.js] +while (true) { + function f() { + continue; + } +} diff --git a/tests/baselines/reference/continueNotInIterationStatement3.js b/tests/baselines/reference/continueNotInIterationStatement3.js new file mode 100644 index 00000000000..11018019871 --- /dev/null +++ b/tests/baselines/reference/continueNotInIterationStatement3.js @@ -0,0 +1,11 @@ +//// [continueNotInIterationStatement3.ts] +switch (0) { + default: + continue; +} + +//// [continueNotInIterationStatement3.js] +switch (0) { + default: + continue; +} diff --git a/tests/baselines/reference/continueNotInIterationStatement4.js b/tests/baselines/reference/continueNotInIterationStatement4.js new file mode 100644 index 00000000000..f3f52ecb48c --- /dev/null +++ b/tests/baselines/reference/continueNotInIterationStatement4.js @@ -0,0 +1,15 @@ +//// [continueNotInIterationStatement4.ts] +TWO: +while (true){ + var x = () => { + continue TWO; + } +} + + +//// [continueNotInIterationStatement4.js] +TWO: while (true) { + var x = function () { + continue TWO; + }; +} diff --git a/tests/baselines/reference/continueTarget1.js b/tests/baselines/reference/continueTarget1.js new file mode 100644 index 00000000000..07e5a7b9b50 --- /dev/null +++ b/tests/baselines/reference/continueTarget1.js @@ -0,0 +1,6 @@ +//// [continueTarget1.ts] +target: + continue target; + +//// [continueTarget1.js] +target: continue target; diff --git a/tests/baselines/reference/continueTarget5.js b/tests/baselines/reference/continueTarget5.js new file mode 100644 index 00000000000..5bf309d2690 --- /dev/null +++ b/tests/baselines/reference/continueTarget5.js @@ -0,0 +1,18 @@ +//// [continueTarget5.ts] +target: +while (true) { + function f() { + while (true) { + continue target; + } + } +} + +//// [continueTarget5.js] +target: while (true) { + function f() { + while (true) { + continue target; + } + } +} diff --git a/tests/baselines/reference/continueTarget6.js b/tests/baselines/reference/continueTarget6.js new file mode 100644 index 00000000000..aefa8e97652 --- /dev/null +++ b/tests/baselines/reference/continueTarget6.js @@ -0,0 +1,9 @@ +//// [continueTarget6.ts] +while (true) { + continue target; +} + +//// [continueTarget6.js] +while (true) { + continue target; +} diff --git a/tests/baselines/reference/createArray.js b/tests/baselines/reference/createArray.js new file mode 100644 index 00000000000..82572e05cad --- /dev/null +++ b/tests/baselines/reference/createArray.js @@ -0,0 +1,34 @@ +//// [createArray.ts] +var na=new number[]; + +class C { +} + +new C[]; +var ba=new boolean[]; +var sa=new string[]; +function f(s:string):number { return 0; +} +if (ba[14]) { + na[2]=f(sa[3]); +} + +new C[1]; // not an error + +//// [createArray.js] +var na = new number[]; +var C = (function () { + function C() { + } + return C; +})(); +new C[]; +var ba = new boolean[]; +var sa = new string[]; +function f(s) { + return 0; +} +if (ba[14]) { + na[2] = f(sa[3]); +} +new C[1]; // not an error diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.js b/tests/baselines/reference/declFileObjectLiteralWithAccessors.js new file mode 100644 index 00000000000..00598cfcf3e --- /dev/null +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.js @@ -0,0 +1,29 @@ +//// [declFileObjectLiteralWithAccessors.ts] + +function /*1*/makePoint(x: number) { + return { + b: 10, + get x() { return x; }, + set x(a: number) { this.b = a; } + }; +}; +var /*4*/point = makePoint(2); +var /*2*/x = point.x; +point./*3*/x = 30; + +//// [declFileObjectLiteralWithAccessors.js] +function makePoint(x) { + return { + b: 10, + get x() { + return x; + }, + set x(a) { + this.b = a; + } + }; +} +; +var point = makePoint(2); +var x = point.x; +point.x = 30; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js b/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js new file mode 100644 index 00000000000..ed457931a69 --- /dev/null +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js @@ -0,0 +1,22 @@ +//// [declFileObjectLiteralWithOnlyGetter.ts] + +function /*1*/makePoint(x: number) { + return { + get x() { return x; }, + }; +}; +var /*4*/point = makePoint(2); +var /*2*/x = point./*3*/x; + + +//// [declFileObjectLiteralWithOnlyGetter.js] +function makePoint(x) { + return { + get x() { + return x; + } + }; +} +; +var point = makePoint(2); +var x = point.x; diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js new file mode 100644 index 00000000000..f5716bb06e0 --- /dev/null +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js @@ -0,0 +1,23 @@ +//// [declFileObjectLiteralWithOnlySetter.ts] + +function /*1*/makePoint(x: number) { + return { + b: 10, + set x(a: number) { this.b = a; } + }; +}; +var /*3*/point = makePoint(2); +point./*2*/x = 30; + +//// [declFileObjectLiteralWithOnlySetter.js] +function makePoint(x) { + return { + b: 10, + set x(a) { + this.b = a; + } + }; +} +; +var point = makePoint(2); +point.x = 30; diff --git a/tests/baselines/reference/declFilePrivateStatic.js b/tests/baselines/reference/declFilePrivateStatic.js new file mode 100644 index 00000000000..38dbdb126af --- /dev/null +++ b/tests/baselines/reference/declFilePrivateStatic.js @@ -0,0 +1,54 @@ +//// [declFilePrivateStatic.ts] + +class C { + private static x = 1; + static y = 1; + + private static a() { } + static b() { } + + private static get c() { return 1; } + static get d() { return 1; } + + private static set e(v) { } + static set f(v) { } +} + +//// [declFilePrivateStatic.js] +var C = (function () { + function C() { + } + C.a = function () { + }; + C.b = function () { + }; + Object.defineProperty(C, "c", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "d", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "e", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "f", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + C.x = 1; + C.y = 1; + return C; +})(); diff --git a/tests/baselines/reference/declarationInAmbientContext.js b/tests/baselines/reference/declarationInAmbientContext.js new file mode 100644 index 00000000000..eb39bccc818 --- /dev/null +++ b/tests/baselines/reference/declarationInAmbientContext.js @@ -0,0 +1,6 @@ +//// [declarationInAmbientContext.ts] +declare var [a, b]; // Error, destructuring declaration not allowed in ambient context +declare var {c, d}; // Error, destructuring declaration not allowed in ambient context + + +//// [declarationInAmbientContext.js] diff --git a/tests/baselines/reference/declarationWithNoInitializer.js b/tests/baselines/reference/declarationWithNoInitializer.js new file mode 100644 index 00000000000..54d89368fb1 --- /dev/null +++ b/tests/baselines/reference/declarationWithNoInitializer.js @@ -0,0 +1,8 @@ +//// [declarationWithNoInitializer.ts] +var [a, b]; // Error, no initializer +var {c, d}; // Error, no initializer + + +//// [declarationWithNoInitializer.js] +var _a = void 0, a = _a[0], b = _a[1]; // Error, no initializer +var _b = void 0, c = _b.c, d = _b.d; // Error, no initializer diff --git a/tests/baselines/reference/declareAlreadySeen.js b/tests/baselines/reference/declareAlreadySeen.js new file mode 100644 index 00000000000..51421a67cb7 --- /dev/null +++ b/tests/baselines/reference/declareAlreadySeen.js @@ -0,0 +1,14 @@ +//// [declareAlreadySeen.ts] +module M { + declare declare var x; + declare declare function f(); + + declare declare module N { } + + declare declare class C { } +} + +//// [declareAlreadySeen.js] +var M; +(function (M) { +})(M || (M = {})); diff --git a/tests/baselines/reference/declareModifierOnImport1.js b/tests/baselines/reference/declareModifierOnImport1.js new file mode 100644 index 00000000000..510407b4deb --- /dev/null +++ b/tests/baselines/reference/declareModifierOnImport1.js @@ -0,0 +1,4 @@ +//// [declareModifierOnImport1.ts] +declare import a = b; + +//// [declareModifierOnImport1.js] diff --git a/tests/baselines/reference/deleteOperatorInStrictMode.js b/tests/baselines/reference/deleteOperatorInStrictMode.js new file mode 100644 index 00000000000..3fcf8dd836b --- /dev/null +++ b/tests/baselines/reference/deleteOperatorInStrictMode.js @@ -0,0 +1,9 @@ +//// [deleteOperatorInStrictMode.ts] +"use strict" +var a; +delete a; + +//// [deleteOperatorInStrictMode.js] +"use strict"; +var a; +delete a; diff --git a/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js new file mode 100644 index 00000000000..615c3e7f7a6 --- /dev/null +++ b/tests/baselines/reference/derivedClassFunctionOverridesBaseClassAccessor.js @@ -0,0 +1,48 @@ +//// [derivedClassFunctionOverridesBaseClassAccessor.ts] +class Base { + get x() { + return 1; + } + set x(v) { + } +} + +// error +class Derived extends Base { + x() { + return 1; + } +} + +//// [derivedClassFunctionOverridesBaseClassAccessor.js] +var __extends = 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 Base = (function () { + function Base() { + } + Object.defineProperty(Base.prototype, "x", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return Base; +})(); +// error +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived() { + _super.apply(this, arguments); + } + Derived.prototype.x = function () { + return 1; + }; + return Derived; +})(Base); diff --git a/tests/baselines/reference/derivedClassIncludesInheritedMembers.js b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js new file mode 100644 index 00000000000..db54affa6d9 --- /dev/null +++ b/tests/baselines/reference/derivedClassIncludesInheritedMembers.js @@ -0,0 +1,107 @@ +//// [derivedClassIncludesInheritedMembers.ts] +class Base { + a: string; + b() { } + get c() { return ''; } + set c(v) { } + + static r: string; + static s() { } + static get t() { return ''; } + static set t(v) { } + + constructor(x) { } +} + +class Derived extends Base { +} + +var d: Derived = new Derived(1); +var r1 = d.a; +var r2 = d.b(); +var r3 = d.c; +d.c = ''; +var r4 = Derived.r; +var r5 = Derived.s(); +var r6 = Derived.t; +Derived.t = ''; + +class Base2 { + [x: string]: Object; + [x: number]: Date; +} + +class Derived2 extends Base2 { +} + +var d2: Derived2; +var r7 = d2['']; +var r8 = d2[1]; + + + +//// [derivedClassIncludesInheritedMembers.js] +var __extends = 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 Base = (function () { + function Base(x) { + } + Base.prototype.b = function () { + }; + Object.defineProperty(Base.prototype, "c", { + get: function () { + return ''; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + Base.s = function () { + }; + Object.defineProperty(Base, "t", { + get: function () { + return ''; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return Base; +})(); +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived() { + _super.apply(this, arguments); + } + return Derived; +})(Base); +var d = new Derived(1); +var r1 = d.a; +var r2 = d.b(); +var r3 = d.c; +d.c = ''; +var r4 = Derived.r; +var r5 = Derived.s(); +var r6 = Derived.t; +Derived.t = ''; +var Base2 = (function () { + function Base2() { + } + return Base2; +})(); +var Derived2 = (function (_super) { + __extends(Derived2, _super); + function Derived2() { + _super.apply(this, arguments); + } + return Derived2; +})(Base2); +var d2; +var r7 = d2['']; +var r8 = d2[1]; diff --git a/tests/baselines/reference/derivedClassOverridesPublicMembers.js b/tests/baselines/reference/derivedClassOverridesPublicMembers.js new file mode 100644 index 00000000000..f673d9ab856 --- /dev/null +++ b/tests/baselines/reference/derivedClassOverridesPublicMembers.js @@ -0,0 +1,155 @@ +//// [derivedClassOverridesPublicMembers.ts] +var x: { foo: string; } +var y: { foo: string; bar: string; } + +class Base { + a: typeof x; + b(a: typeof x) { } + get c() { return x; } + set c(v: typeof x) { } + d: (a: typeof x) => void; + + static r: typeof x; + static s(a: typeof x) { } + static get t() { return x; } + static set t(v: typeof x) { } + static u: (a: typeof x) => void; + + constructor(a: typeof x) { } +} + +class Derived extends Base { + a: typeof y; + b(a: typeof y) { } + get c() { return y; } + set c(v: typeof y) { } + d: (a: typeof y) => void; + + static r: typeof y; + static s(a: typeof y) { } + static get t() { return y; } + static set t(a: typeof y) { } + static u: (a: typeof y) => void; + + constructor(a: typeof y) { super(x) } +} + +var d: Derived = new Derived(y); +var r1 = d.a; +var r2 = d.b(y); +var r3 = d.c; +var r3a = d.d; +d.c = y; +var r4 = Derived.r; +var r5 = Derived.s(y); +var r6 = Derived.t; +var r6a = Derived.u; +Derived.t = y; + +class Base2 { + [i: string]: Object; + [i: number]: typeof x; +} + +class Derived2 extends Base2 { + [i: string]: typeof x; + [i: number]: typeof y; +} + +var d2: Derived2; +var r7 = d2['']; +var r8 = d2[1]; + + + +//// [derivedClassOverridesPublicMembers.js] +var __extends = 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 x; +var y; +var Base = (function () { + function Base(a) { + } + Base.prototype.b = function (a) { + }; + Object.defineProperty(Base.prototype, "c", { + get: function () { + return x; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + Base.s = function (a) { + }; + Object.defineProperty(Base, "t", { + get: function () { + return x; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return Base; +})(); +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived(a) { + _super.call(this, x); + } + Derived.prototype.b = function (a) { + }; + Object.defineProperty(Derived.prototype, "c", { + get: function () { + return y; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + Derived.s = function (a) { + }; + Object.defineProperty(Derived, "t", { + get: function () { + return y; + }, + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return Derived; +})(Base); +var d = new Derived(y); +var r1 = d.a; +var r2 = d.b(y); +var r3 = d.c; +var r3a = d.d; +d.c = y; +var r4 = Derived.r; +var r5 = Derived.s(y); +var r6 = Derived.t; +var r6a = Derived.u; +Derived.t = y; +var Base2 = (function () { + function Base2() { + } + return Base2; +})(); +var Derived2 = (function (_super) { + __extends(Derived2, _super); + function Derived2() { + _super.apply(this, arguments); + } + return Derived2; +})(Base2); +var d2; +var r7 = d2['']; +var r8 = d2[1]; diff --git a/tests/baselines/reference/derivedClassWithAny.js b/tests/baselines/reference/derivedClassWithAny.js new file mode 100644 index 00000000000..0b568eaec9b --- /dev/null +++ b/tests/baselines/reference/derivedClassWithAny.js @@ -0,0 +1,154 @@ +//// [derivedClassWithAny.ts] +class C { + x: number; + get X(): number { return 1; } + foo(): number { + return 1; + } + + static y: number; + static get Y(): number { + return 1; + } + static bar(): number { + return 1; + } +} + +class D extends C { + x: any; + get X(): any { + return null; + } + foo(): any { + return 1; + } + + static y: any; + static get Y(): any { + return null; + } + static bar(): any { + return null; + } +} + +// if D is a valid class definition than E is now not safe tranisitively through C +class E extends D { + x: string; + get X(): string{ return ''; } + foo(): string { + return ''; + } + + static y: string; + static get Y(): string { + return ''; + } + static bar(): string { + return ''; + } +} + +var c: C; +var d: D; +var e: E; + +c = d; +c = e; +var r = c.foo(); // e.foo would return string + + +//// [derivedClassWithAny.js] +var __extends = 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 C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "X", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + return 1; + }; + Object.defineProperty(C, "Y", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + C.bar = function () { + return 1; + }; + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + Object.defineProperty(D.prototype, "X", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + D.prototype.foo = function () { + return 1; + }; + Object.defineProperty(D, "Y", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + D.bar = function () { + return null; + }; + return D; +})(C); +// if D is a valid class definition than E is now not safe tranisitively through C +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + Object.defineProperty(E.prototype, "X", { + get: function () { + return ''; + }, + enumerable: true, + configurable: true + }); + E.prototype.foo = function () { + return ''; + }; + Object.defineProperty(E, "Y", { + get: function () { + return ''; + }, + enumerable: true, + configurable: true + }); + E.bar = function () { + return ''; + }; + return E; +})(D); +var c; +var d; +var e; +c = d; +c = e; +var r = c.foo(); // e.foo would return string diff --git a/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js new file mode 100644 index 00000000000..fb0dee3e57b --- /dev/null +++ b/tests/baselines/reference/derivedClassWithPrivateInstanceShadowingPublicInstance.js @@ -0,0 +1,86 @@ +//// [derivedClassWithPrivateInstanceShadowingPublicInstance.ts] +class Base { + public x: string; + public fn(): string { + return ''; + } + + public get a() { return 1; } + public set a(v) { } +} + +// error, not a subtype +class Derived extends Base { + private x: string; + private fn(): string { + return ''; + } + + private get a() { return 1; } + private set a(v) { } +} + +var r = Base.x; // ok +var r2 = Derived.x; // error + +var r3 = Base.fn(); // ok +var r4 = Derived.fn(); // error + +var r5 = Base.a; // ok +Base.a = 2; // ok + +var r6 = Derived.a; // error +Derived.a = 2; // error + +//// [derivedClassWithPrivateInstanceShadowingPublicInstance.js] +var __extends = 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 Base = (function () { + function Base() { + } + Base.prototype.fn = function () { + return ''; + }; + Object.defineProperty(Base.prototype, "a", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return Base; +})(); +// error, not a subtype +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived() { + _super.apply(this, arguments); + } + Derived.prototype.fn = function () { + return ''; + }; + Object.defineProperty(Derived.prototype, "a", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return Derived; +})(Base); +var r = Base.x; // ok +var r2 = Derived.x; // error +var r3 = Base.fn(); // ok +var r4 = Derived.fn(); // error +var r5 = Base.a; // ok +Base.a = 2; // ok +var r6 = Derived.a; // error +Derived.a = 2; // error diff --git a/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js new file mode 100644 index 00000000000..b2468f62d81 --- /dev/null +++ b/tests/baselines/reference/derivedClassWithPrivateStaticShadowingPublicStatic.js @@ -0,0 +1,88 @@ +//// [derivedClassWithPrivateStaticShadowingPublicStatic.ts] +class Base { + public static x: string; + public static fn(): string { + return ''; + } + + public static get a() { return 1; } + public static set a(v) { } +} + +// BUG 847404 +// should be error +class Derived extends Base { + private static x: string; + private static fn(): string { + return ''; + } + + private static get a() { return 1; } + private static set a(v) { } +} + +var r = Base.x; // ok +var r2 = Derived.x; // error + +var r3 = Base.fn(); // ok +var r4 = Derived.fn(); // error + +var r5 = Base.a; // ok +Base.a = 2; // ok + +var r6 = Derived.a; // error +Derived.a = 2; // error + +//// [derivedClassWithPrivateStaticShadowingPublicStatic.js] +var __extends = 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 Base = (function () { + function Base() { + } + Base.fn = function () { + return ''; + }; + Object.defineProperty(Base, "a", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return Base; +})(); +// BUG 847404 +// should be error +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived() { + _super.apply(this, arguments); + } + Derived.fn = function () { + return ''; + }; + Object.defineProperty(Derived, "a", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return Derived; +})(Base); +var r = Base.x; // ok +var r2 = Derived.x; // error +var r3 = Base.fn(); // ok +var r4 = Derived.fn(); // error +var r5 = Base.a; // ok +Base.a = 2; // ok +var r6 = Derived.a; // error +Derived.a = 2; // error diff --git a/tests/baselines/reference/derivedGenericClassWithAny.js b/tests/baselines/reference/derivedGenericClassWithAny.js new file mode 100644 index 00000000000..677fadf3876 --- /dev/null +++ b/tests/baselines/reference/derivedGenericClassWithAny.js @@ -0,0 +1,118 @@ +//// [derivedGenericClassWithAny.ts] +class C { + x: T; + get X(): T { return null; } + foo(): T { + return null; + } +} + +class D extends C { + x: any; + get X(): any { + return null; + } + foo(): any { + return 1; + } + + static y: any; + static get Y(): any { + return null; + } + static bar(): any { + return null; + } +} + +// if D is a valid class definition than E is now not safe tranisitively through C +class E extends D { + x: T; + get X(): T { return ''; } // error + foo(): T { + return ''; // error + } +} + +var c: C; +var d: D; +var e: E; + +c = d; +c = e; +var r = c.foo(); // e.foo would return string + +//// [derivedGenericClassWithAny.js] +var __extends = 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 C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "X", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + return null; + }; + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + Object.defineProperty(D.prototype, "X", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + D.prototype.foo = function () { + return 1; + }; + Object.defineProperty(D, "Y", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + D.bar = function () { + return null; + }; + return D; +})(C); +// if D is a valid class definition than E is now not safe tranisitively through C +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + Object.defineProperty(E.prototype, "X", { + get: function () { + return ''; + } // error + , + enumerable: true, + configurable: true + }); + E.prototype.foo = function () { + return ''; // error + }; + return E; +})(D); +var c; +var d; +var e; +c = d; +c = e; +var r = c.foo(); // e.foo would return string diff --git a/tests/baselines/reference/duplicateClassElements.js b/tests/baselines/reference/duplicateClassElements.js new file mode 100644 index 00000000000..da320eb9ac4 --- /dev/null +++ b/tests/baselines/reference/duplicateClassElements.js @@ -0,0 +1,105 @@ +//// [duplicateClassElements.ts] +class a { + public a; + public a; + public b() { + } + public b() { + } + public x; + get x() { + return 10; + } + set x(_x: number) { + } + + get y() { + return "Hello"; + } + set y(_y: string) { + } + + public z() { + } + get z() { + return "Hello"; + } + set z(_y: string) { + } + + get x2() { + return 10; + } + set x2(_x: number) { + } + public x2; + + get z2() { + return "Hello"; + } + set z2(_y: string) { + } + public z2() { + } + +} + +//// [duplicateClassElements.js] +var a = (function () { + function a() { + } + a.prototype.b = function () { + }; + a.prototype.b = function () { + }; + Object.defineProperty(a.prototype, "x", { + get: function () { + return 10; + }, + set: function (_x) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(a.prototype, "y", { + get: function () { + return "Hello"; + }, + set: function (_y) { + }, + enumerable: true, + configurable: true + }); + a.prototype.z = function () { + }; + Object.defineProperty(a.prototype, "z", { + get: function () { + return "Hello"; + }, + set: function (_y) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(a.prototype, "x2", { + get: function () { + return 10; + }, + set: function (_x) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(a.prototype, "z2", { + get: function () { + return "Hello"; + }, + set: function (_y) { + }, + enumerable: true, + configurable: true + }); + a.prototype.z2 = function () { + }; + return a; +})(); diff --git a/tests/baselines/reference/duplicateLabel1.js b/tests/baselines/reference/duplicateLabel1.js new file mode 100644 index 00000000000..e7976895c94 --- /dev/null +++ b/tests/baselines/reference/duplicateLabel1.js @@ -0,0 +1,9 @@ +//// [duplicateLabel1.ts] +target: +target: +while (true) { +} + +//// [duplicateLabel1.js] +target: target: while (true) { +} diff --git a/tests/baselines/reference/duplicateLabel2.js b/tests/baselines/reference/duplicateLabel2.js new file mode 100644 index 00000000000..9ee9671d59d --- /dev/null +++ b/tests/baselines/reference/duplicateLabel2.js @@ -0,0 +1,13 @@ +//// [duplicateLabel2.ts] +target: +while (true) { + target: + while (true) { + } +} + +//// [duplicateLabel2.js] +target: while (true) { + target: while (true) { + } +} diff --git a/tests/baselines/reference/duplicateObjectLiteralProperty.js b/tests/baselines/reference/duplicateObjectLiteralProperty.js new file mode 100644 index 00000000000..5bbeb433a0c --- /dev/null +++ b/tests/baselines/reference/duplicateObjectLiteralProperty.js @@ -0,0 +1,41 @@ +//// [duplicateObjectLiteralProperty.ts] +var x = { + a: 1, + b: true, // OK + a: 56, // Duplicate + \u0061: "ss", // Duplicate + a: { + c: 1, + "c": 56, // Duplicate + } +}; + + +var y = { + get a() { return 0; }, + set a(v: number) { }, + get a() { return 0; } +}; + + +//// [duplicateObjectLiteralProperty.js] +var x = { + a: 1, + b: true, + a: 56, + \u0061: "ss", + a: { + c: 1, + "c": 56, + } +}; +var y = { + get a() { + return 0; + }, + set a(v) { + }, + get a() { + return 0; + } +}; diff --git a/tests/baselines/reference/duplicatePropertiesInStrictMode.js b/tests/baselines/reference/duplicatePropertiesInStrictMode.js new file mode 100644 index 00000000000..37bb3d62b7f --- /dev/null +++ b/tests/baselines/reference/duplicatePropertiesInStrictMode.js @@ -0,0 +1,13 @@ +//// [duplicatePropertiesInStrictMode.ts] +"use strict"; +var x = { + x: 1, + x: 2 +} + +//// [duplicatePropertiesInStrictMode.js] +"use strict"; +var x = { + x: 1, + x: 2 +}; diff --git a/tests/baselines/reference/emptyGenericParamList.js b/tests/baselines/reference/emptyGenericParamList.js new file mode 100644 index 00000000000..c5d01778f2d --- /dev/null +++ b/tests/baselines/reference/emptyGenericParamList.js @@ -0,0 +1,11 @@ +//// [emptyGenericParamList.ts] +class I {} +var x: I<>; + +//// [emptyGenericParamList.js] +var I = (function () { + function I() { + } + return I; +})(); +var x; diff --git a/tests/baselines/reference/emptyTypeArgumentList.js b/tests/baselines/reference/emptyTypeArgumentList.js new file mode 100644 index 00000000000..91fce396289 --- /dev/null +++ b/tests/baselines/reference/emptyTypeArgumentList.js @@ -0,0 +1,8 @@ +//// [emptyTypeArgumentList.ts] +function foo() { } +foo<>(); + +//// [emptyTypeArgumentList.js] +function foo() { +} +foo(); diff --git a/tests/baselines/reference/emptyTypeArgumentListWithNew.js b/tests/baselines/reference/emptyTypeArgumentListWithNew.js new file mode 100644 index 00000000000..d51c4f630a6 --- /dev/null +++ b/tests/baselines/reference/emptyTypeArgumentListWithNew.js @@ -0,0 +1,11 @@ +//// [emptyTypeArgumentListWithNew.ts] +class foo { } +new foo<>(); + +//// [emptyTypeArgumentListWithNew.js] +var foo = (function () { + function foo() { + } + return foo; +})(); +new foo(); diff --git a/tests/baselines/reference/enumConstantMembers.js b/tests/baselines/reference/enumConstantMembers.js new file mode 100644 index 00000000000..f58c7d253af --- /dev/null +++ b/tests/baselines/reference/enumConstantMembers.js @@ -0,0 +1,38 @@ +//// [enumConstantMembers.ts] +// Constant members allow negatives, but not decimals. Also hex literals are allowed +enum E1 { + a = 1, + b +} +enum E2 { + a = - 1, + b +} +enum E3 { + a = 0.1, + b // Error because 0.1 is not a constant +} + +declare enum E4 { + a = 1, + b = -1, + c = 0.1 // Not a constant +} + +//// [enumConstantMembers.js] +// Constant members allow negatives, but not decimals. Also hex literals are allowed +var E1; +(function (E1) { + E1[E1["a"] = 1] = "a"; + E1[E1["b"] = 2] = "b"; +})(E1 || (E1 = {})); +var E2; +(function (E2) { + E2[E2["a"] = -1] = "a"; + E2[E2["b"] = 0] = "b"; +})(E2 || (E2 = {})); +var E3; +(function (E3) { + E3[E3["a"] = 0.1] = "a"; + E3[E3["b"] = 1.1] = "b"; // Error because 0.1 is not a constant +})(E3 || (E3 = {})); diff --git a/tests/baselines/reference/enumInitializersWithExponents.js b/tests/baselines/reference/enumInitializersWithExponents.js new file mode 100644 index 00000000000..b4dd38e32c2 --- /dev/null +++ b/tests/baselines/reference/enumInitializersWithExponents.js @@ -0,0 +1,12 @@ +//// [enumInitializersWithExponents.ts] +// Must be integer literals. +declare enum E { + a = 1e3, // ok + b = 1e25, // ok + c = 1e-3, // error + d = 1e-9, // error + e = 1e0, // ok + f = 1e+25 // ok +} + +//// [enumInitializersWithExponents.js] diff --git a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.js b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.js new file mode 100644 index 00000000000..ef9192c1c90 --- /dev/null +++ b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.js @@ -0,0 +1,14 @@ +//// [enumWithoutInitializerAfterComputedMember.ts] +enum E { + a, + b = a, + c +} + +//// [enumWithoutInitializerAfterComputedMember.js] +var E; +(function (E) { + E[E["a"] = 0] = "a"; + E[E["b"] = E.a] = "b"; + E[E["c"] = undefined] = "c"; +})(E || (E = {})); diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js new file mode 100644 index 00000000000..26c66a1222c --- /dev/null +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -0,0 +1,280 @@ +//// [errorSuperPropertyAccess.ts] +//super property access in constructor of class with no base type +//super property access in instance member function of class with no base type +//super property access in instance member accessor(get and set) of class with no base type +class NoBase { + constructor() { + var a = super.prototype; + var b = super.hasOwnProperty(''); + } + + fn() { + var a = super.prototype; + var b = super.hasOwnProperty(''); + } + + m = super.prototype; + n = super.hasOwnProperty(''); + + //super static property access in static member function of class with no base type + //super static property access in static member accessor(get and set) of class with no base type + public static static1() { + super.hasOwnProperty(''); + } + + public static get static2() { + super.hasOwnProperty(''); + return ''; + } + + public static set static2(n) { + super.hasOwnProperty(''); + } +} + +class SomeBase { + private privateFunc() { } + private privateMember = 0; + + public publicFunc() { } + public publicMember = 0; + + private static privateStaticFunc() { } + private static privateStaticMember = 0; + + public static publicStaticFunc() { } + public static publicStaticMember = 0; + +} + + +//super.publicInstanceMemberNotFunction in constructor of derived class +//super.publicInstanceMemberNotFunction in instance member function of derived class +//super.publicInstanceMemberNotFunction in instance member accessor(get and set) of derived class +//super property access only available with typed this +class SomeDerived1 extends SomeBase { + constructor() { + super(); + super.publicMember = 1; + } + + fn() { + var x = super.publicMember; + } + + get a() { + var x = super.publicMember; + return undefined; + } + set a(n) { + n = super.publicMember; + } + fn2() { + function inner() { + super.publicFunc(); + } + var x = { + test: function () { return super.publicFunc(); } + } + } +} + +//super.privateProperty in constructor of derived class +//super.privateProperty in instance member function of derived class +//super.privateProperty in instance member accessor(get and set) of derived class +class SomeDerived2 extends SomeBase { + constructor() { + super(); + super.privateMember = 1; + } + + fn() { + var x = super.privateMember; + } + + get a() { + var x = super.privateMember; + return undefined; + } + set a(n) { + n = super.privateMember; + } +} + +//super.publicStaticMemberNotFunction in static member function of derived class +//super.publicStaticMemberNotFunction in static member accessor(get and set) of derived class +//super.privateStaticProperty in static member function of derived class +//super.privateStaticProperty in static member accessor(get and set) of derived class +class SomeDerived3 extends SomeBase { + static fn() { + super.publicStaticMember = 3; + super.privateStaticMember = 3; + super.privateStaticFunc(); + } + static get a() { + super.publicStaticMember = 3; + super.privateStaticMember = 3; + super.privateStaticFunc(); + return ''; + } + static set a(n) { + super.publicStaticMember = 3; + super.privateStaticMember = 3; + super.privateStaticFunc(); + } +} + +// In object literal +var obj = { n: super.wat, p: super.foo() }; + + +//// [errorSuperPropertyAccess.js] +var __extends = 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 __(); +}; +//super property access in constructor of class with no base type +//super property access in instance member function of class with no base type +//super property access in instance member accessor(get and set) of class with no base type +var NoBase = (function () { + function NoBase() { + this.m = super.prototype; + this.n = super.hasOwnProperty.call(this, ''); + var a = super.prototype; + var b = super.hasOwnProperty.call(this, ''); + } + NoBase.prototype.fn = function () { + var a = super.prototype; + var b = super.hasOwnProperty.call(this, ''); + }; + //super static property access in static member function of class with no base type + //super static property access in static member accessor(get and set) of class with no base type + NoBase.static1 = function () { + super.hasOwnProperty.call(this, ''); + }; + Object.defineProperty(NoBase, "static2", { + get: function () { + super.hasOwnProperty.call(this, ''); + return ''; + }, + set: function (n) { + super.hasOwnProperty.call(this, ''); + }, + enumerable: true, + configurable: true + }); + return NoBase; +})(); +var SomeBase = (function () { + function SomeBase() { + this.privateMember = 0; + this.publicMember = 0; + } + SomeBase.prototype.privateFunc = function () { + }; + SomeBase.prototype.publicFunc = function () { + }; + SomeBase.privateStaticFunc = function () { + }; + SomeBase.publicStaticFunc = function () { + }; + SomeBase.privateStaticMember = 0; + SomeBase.publicStaticMember = 0; + return SomeBase; +})(); +//super.publicInstanceMemberNotFunction in constructor of derived class +//super.publicInstanceMemberNotFunction in instance member function of derived class +//super.publicInstanceMemberNotFunction in instance member accessor(get and set) of derived class +//super property access only available with typed this +var SomeDerived1 = (function (_super) { + __extends(SomeDerived1, _super); + function SomeDerived1() { + _super.call(this); + _super.prototype.publicMember = 1; + } + SomeDerived1.prototype.fn = function () { + var x = _super.prototype.publicMember; + }; + Object.defineProperty(SomeDerived1.prototype, "a", { + get: function () { + var x = _super.prototype.publicMember; + return undefined; + }, + set: function (n) { + n = _super.prototype.publicMember; + }, + enumerable: true, + configurable: true + }); + SomeDerived1.prototype.fn2 = function () { + function inner() { + super.publicFunc.call(this); + } + var x = { + test: function () { + return super.publicFunc.call(this); + } + }; + }; + return SomeDerived1; +})(SomeBase); +//super.privateProperty in constructor of derived class +//super.privateProperty in instance member function of derived class +//super.privateProperty in instance member accessor(get and set) of derived class +var SomeDerived2 = (function (_super) { + __extends(SomeDerived2, _super); + function SomeDerived2() { + _super.call(this); + _super.prototype.privateMember = 1; + } + SomeDerived2.prototype.fn = function () { + var x = _super.prototype.privateMember; + }; + Object.defineProperty(SomeDerived2.prototype, "a", { + get: function () { + var x = _super.prototype.privateMember; + return undefined; + }, + set: function (n) { + n = _super.prototype.privateMember; + }, + enumerable: true, + configurable: true + }); + return SomeDerived2; +})(SomeBase); +//super.publicStaticMemberNotFunction in static member function of derived class +//super.publicStaticMemberNotFunction in static member accessor(get and set) of derived class +//super.privateStaticProperty in static member function of derived class +//super.privateStaticProperty in static member accessor(get and set) of derived class +var SomeDerived3 = (function (_super) { + __extends(SomeDerived3, _super); + function SomeDerived3() { + _super.apply(this, arguments); + } + SomeDerived3.fn = function () { + _super.publicStaticMember = 3; + _super.privateStaticMember = 3; + _super.privateStaticFunc.call(this); + }; + Object.defineProperty(SomeDerived3, "a", { + get: function () { + _super.publicStaticMember = 3; + _super.privateStaticMember = 3; + _super.privateStaticFunc.call(this); + return ''; + }, + set: function (n) { + _super.publicStaticMember = 3; + _super.privateStaticMember = 3; + _super.privateStaticFunc.call(this); + }, + enumerable: true, + configurable: true + }); + return SomeDerived3; +})(SomeBase); +// In object literal +var obj = { n: super.wat, p: super.foo.call(this) }; diff --git a/tests/baselines/reference/errorsInGenericTypeReference.js b/tests/baselines/reference/errorsInGenericTypeReference.js new file mode 100644 index 00000000000..6a9f62c5e49 --- /dev/null +++ b/tests/baselines/reference/errorsInGenericTypeReference.js @@ -0,0 +1,158 @@ +//// [errorsInGenericTypeReference.ts] + +interface IFoo { } + +class Foo { } + + +// in call type arguments +class testClass1 { + method(): void { } +} +var tc1 = new testClass1(); +tc1.method<{ x: V }>(); // error: could not find symbol V + + +// in constructor type arguments +class testClass2 { +} +var tc2 = new testClass2<{ x: V }>(); // error: could not find symbol V + + +// in method return type annotation +class testClass3 { + testMethod1(): Foo<{ x: V }> { return null; } // error: could not find symbol V + static testMethod2(): Foo<{ x: V }> { return null } // error: could not find symbol V + set a(value: Foo<{ x: V }>) { } // error: could not find symbol V + property: Foo<{ x: V }>; // error: could not find symbol V +} + + +// in function return type annotation +function testFunction1(): Foo<{ x: V }> { return null; } // error: could not find symbol V + + +// in paramter types +function testFunction2(p: Foo<{ x: V }>) { }// error: could not find symbol V + + +// in var type annotation +var f: Foo<{ x: V }>; // error: could not find symbol V + + +// in constraints +class testClass4 { } // error: could not find symbol V + +interface testClass5> { } // error: could not find symbol V + +class testClass6 { + method(): void { } // error: could not find symbol V +} + +interface testInterface1 { + new (a: M); // error: could not find symbol V +} + + +// in extends clause +class testClass7 extends Foo<{ x: V }> { } // error: could not find symbol V + + +// in implements clause +class testClass8 implements IFoo<{ x: V }> { } // error: could not find symbol V + + +// in signatures +interface testInterface2 { + new (a: Foo<{ x: V }>): Foo<{ x: V }>; //2x: error: could not find symbol V + [x: string]: Foo<{ x: V }>; // error: could not find symbol V + method(a: Foo<{ x: V }>): Foo<{ x: V }>; //2x: error: could not find symbol V + property: Foo<{ x: V }>; // error: could not find symbol V +} + + + +//// [errorsInGenericTypeReference.js] +var __extends = 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() { + } + return Foo; +})(); +// in call type arguments +var testClass1 = (function () { + function testClass1() { + } + testClass1.prototype.method = function () { + }; + return testClass1; +})(); +var tc1 = new testClass1(); +tc1.method(); // error: could not find symbol V +// in constructor type arguments +var testClass2 = (function () { + function testClass2() { + } + return testClass2; +})(); +var tc2 = new testClass2(); // error: could not find symbol V +// in method return type annotation +var testClass3 = (function () { + function testClass3() { + } + testClass3.prototype.testMethod1 = function () { + return null; + }; // error: could not find symbol V + testClass3.testMethod2 = function () { + return null; + }; // error: could not find symbol V + Object.defineProperty(testClass3.prototype, "a", { + set: function (value) { + } // error: could not find symbol V + , + enumerable: true, + configurable: true + }); + return testClass3; +})(); +// in function return type annotation +function testFunction1() { + return null; +} // error: could not find symbol V +// in paramter types +function testFunction2(p) { +} // error: could not find symbol V +// in var type annotation +var f; // error: could not find symbol V +// in constraints +var testClass4 = (function () { + function testClass4() { + } + return testClass4; +})(); // error: could not find symbol V +var testClass6 = (function () { + function testClass6() { + } + testClass6.prototype.method = function () { + }; // error: could not find symbol V + return testClass6; +})(); +// in extends clause +var testClass7 = (function (_super) { + __extends(testClass7, _super); + function testClass7() { + _super.apply(this, arguments); + } + return testClass7; +})(Foo); // error: could not find symbol V +// in implements clause +var testClass8 = (function () { + function testClass8() { + } + return testClass8; +})(); // error: could not find symbol V diff --git a/tests/baselines/reference/es6ClassTest.js b/tests/baselines/reference/es6ClassTest.js new file mode 100644 index 00000000000..5fd9f0e9b7f --- /dev/null +++ b/tests/baselines/reference/es6ClassTest.js @@ -0,0 +1,151 @@ +//// [es6ClassTest.ts] +class Bar { + public goo: number; + public prop1(x) { + return x; + } + + constructor (n) { } +} + +// new-style class +class Foo extends Bar { + foo:number; + gar = 0; + zoo:string = "zoo"; + x: any; + + bar() { return 0; } + + private boo(); + private boo(x?) { return x; } + + static statVal = 0; + + constructor(); + constructor(x?, private y?:string, public z?=0) { + super(x); + this.x = x; + this.gar = 5; + } +} + +var f = new Foo(); + +declare module AmbientMod { + export class Provide { + foo:number; + zoo:string; + + constructor(); + + private boo(); + bar(); + } +} + + +//class GetSetMonster { + + +// // attack(target) { +// // WScript.Echo("Attacks " + target); +// // } +// // The contextual keyword "get" followed by an identifier and +// // a curly body defines a getter in the same way that "get" +// // defines one in an object literal. +// // get isAlive() { +// // return this.health > 0; +// // } + +// // Likewise, "set" can be used to define setters. +// set health(value:number) { +// if (value < 0) { +// throw new Error('Health must be non-negative.') +// } +// this.health = value +// } +// get health() { return 0; } + +// constructor(this.name: string, health: number) { +// this.health = 0; +// } +//} + + +//class bar { + +// static fnOverload( ); + +// static fnOverload(foo: string){ } // no error + +// constructor(){}; + +//} + + +//// [es6ClassTest.js] +var __extends = 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 Bar = (function () { + function Bar(n) { + } + Bar.prototype.prop1 = function (x) { + return x; + }; + return Bar; +})(); +// new-style class +var Foo = (function (_super) { + __extends(Foo, _super); + function Foo(x, y, z) { + if (z === void 0) { z = 0; } + _super.call(this, x); + this.y = y; + this.z = z; + this.gar = 0; + this.zoo = "zoo"; + this.x = x; + this.gar = 5; + } + Foo.prototype.bar = function () { + return 0; + }; + Foo.prototype.boo = function (x) { + return x; + }; + Foo.statVal = 0; + return Foo; +})(Bar); +var f = new Foo(); +//class GetSetMonster { +// // attack(target) { +// // WScript.Echo("Attacks " + target); +// // } +// // The contextual keyword "get" followed by an identifier and +// // a curly body defines a getter in the same way that "get" +// // defines one in an object literal. +// // get isAlive() { +// // return this.health > 0; +// // } +// // Likewise, "set" can be used to define setters. +// set health(value:number) { +// if (value < 0) { +// throw new Error('Health must be non-negative.') +// } +// this.health = value +// } +// get health() { return 0; } +// constructor(this.name: string, health: number) { +// this.health = 0; +// } +//} +//class bar { +// static fnOverload( ); +// static fnOverload(foo: string){ } // no error +// constructor(){}; +//} diff --git a/tests/baselines/reference/es6ClassTest2.js b/tests/baselines/reference/es6ClassTest2.js new file mode 100644 index 00000000000..8ef7a2fa379 --- /dev/null +++ b/tests/baselines/reference/es6ClassTest2.js @@ -0,0 +1,326 @@ +//// [es6ClassTest2.ts] +class BasicMonster { + constructor(public name: string, public health: number) { + + } + + attack(target) { + // WScript.Echo("Attacks " + target); + } + + isAlive = true; +} + +var m1 = new BasicMonster("1", 100); +var m2 = new BasicMonster("2", 100); +m1.attack(m2); +m1.health = 0; +console.log((m5.isAlive).toString()); + +class GetSetMonster { + constructor(public name: string, private _health: number) { + + } + + attack(target) { + // WScript.Echo("Attacks " + target); + } + // The contextual keyword "get" followed by an identifier and + // a curly body defines a getter in the same way that "get" + // defines one in an object literal. + get isAlive() { + return this._health > 0; + } + + // Likewise, "set" can be used to define setters. + set health(value: number) { + if (value < 0) { + throw new Error('Health must be non-negative.') + } + this._health = value + } +} + +var m3 = new BasicMonster("1", 100); +var m4 = new BasicMonster("2", 100); +m3.attack(m4); +m3.health = 0; +var x = (m5.isAlive).toString() + +class OverloadedMonster { + constructor(name: string); + constructor(public name: string, public health?: number) { + + } + + attack(); + attack(a: any); + attack(target?) { + //WScript.Echo("Attacks " + target); + } + + isAlive = true; +} + +var m5 = new OverloadedMonster("1"); +var m6 = new OverloadedMonster("2"); +m5.attack(m6); +m5.health = 0; +var y = (m5.isAlive).toString() + +class SplatMonster { + constructor(...args: string[]) { } + roar(name: string, ...args: number[]) { } +} + + +function foo() { return true; } +class PrototypeMonster { + age: number = 1; + name: string; + b = foo(); +} + +class SuperParent { + constructor(a: number) { + + } + + b(b: string) { + + } + + c() { + + } +} + +class SuperChild extends SuperParent { + constructor() { + super(1); + } + + b() { + super.b('str'); + } + + c() { + super.c(); + } +} + +class Statics { + static foo = 1; + static bar: string; + + static baz() { + return ""; + } +} + +var stat = new Statics(); + +interface IFoo { + x: number; + z: string; +} + +class ImplementsInterface implements IFoo { + public x: number; + public z: string; + constructor() { + this.x = 1; + this.z = "foo"; + } +} + +class Visibility { + public foo() { } + private bar() { } + private x: number; + public y: number; + public z: number; + constructor() { + this.x = 1; + this.y = 2; + } +} + +class BaseClassWithConstructor { + constructor(public x: number, public s: string) { } +} + +// used to test codegen +class ChildClassWithoutConstructor extends BaseClassWithConstructor { } + + +var ccwc = new ChildClassWithoutConstructor(1, "s"); + + + +//// [es6ClassTest2.js] +var __extends = 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 BasicMonster = (function () { + function BasicMonster(name, health) { + this.name = name; + this.health = health; + this.isAlive = true; + } + BasicMonster.prototype.attack = function (target) { + // WScript.Echo("Attacks " + target); + }; + return BasicMonster; +})(); +var m1 = new BasicMonster("1", 100); +var m2 = new BasicMonster("2", 100); +m1.attack(m2); +m1.health = 0; +console.log(m5.isAlive.toString()); +var GetSetMonster = (function () { + function GetSetMonster(name, _health) { + this.name = name; + this._health = _health; + } + GetSetMonster.prototype.attack = function (target) { + // WScript.Echo("Attacks " + target); + }; + Object.defineProperty(GetSetMonster.prototype, "isAlive", { + // The contextual keyword "get" followed by an identifier and + // a curly body defines a getter in the same way that "get" + // defines one in an object literal. + get: function () { + return this._health > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GetSetMonster.prototype, "health", { + // Likewise, "set" can be used to define setters. + set: function (value) { + if (value < 0) { + throw new Error('Health must be non-negative.'); + } + this._health = value; + }, + enumerable: true, + configurable: true + }); + return GetSetMonster; +})(); +var m3 = new BasicMonster("1", 100); +var m4 = new BasicMonster("2", 100); +m3.attack(m4); +m3.health = 0; +var x = m5.isAlive.toString(); +var OverloadedMonster = (function () { + function OverloadedMonster(name, health) { + this.name = name; + this.health = health; + this.isAlive = true; + } + OverloadedMonster.prototype.attack = function (target) { + //WScript.Echo("Attacks " + target); + }; + return OverloadedMonster; +})(); +var m5 = new OverloadedMonster("1"); +var m6 = new OverloadedMonster("2"); +m5.attack(m6); +m5.health = 0; +var y = m5.isAlive.toString(); +var SplatMonster = (function () { + function SplatMonster() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i - 0] = arguments[_i]; + } + } + SplatMonster.prototype.roar = function (name) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + }; + return SplatMonster; +})(); +function foo() { + return true; +} +var PrototypeMonster = (function () { + function PrototypeMonster() { + this.age = 1; + this.b = foo(); + } + return PrototypeMonster; +})(); +var SuperParent = (function () { + function SuperParent(a) { + } + SuperParent.prototype.b = function (b) { + }; + SuperParent.prototype.c = function () { + }; + return SuperParent; +})(); +var SuperChild = (function (_super) { + __extends(SuperChild, _super); + function SuperChild() { + _super.call(this, 1); + } + SuperChild.prototype.b = function () { + _super.prototype.b.call(this, 'str'); + }; + SuperChild.prototype.c = function () { + _super.prototype.c.call(this); + }; + return SuperChild; +})(SuperParent); +var Statics = (function () { + function Statics() { + } + Statics.baz = function () { + return ""; + }; + Statics.foo = 1; + return Statics; +})(); +var stat = new Statics(); +var ImplementsInterface = (function () { + function ImplementsInterface() { + this.x = 1; + this.z = "foo"; + } + return ImplementsInterface; +})(); +var Visibility = (function () { + function Visibility() { + this.x = 1; + this.y = 2; + } + Visibility.prototype.foo = function () { + }; + Visibility.prototype.bar = function () { + }; + return Visibility; +})(); +var BaseClassWithConstructor = (function () { + function BaseClassWithConstructor(x, s) { + this.x = x; + this.s = s; + } + return BaseClassWithConstructor; +})(); +// used to test codegen +var ChildClassWithoutConstructor = (function (_super) { + __extends(ChildClassWithoutConstructor, _super); + function ChildClassWithoutConstructor() { + _super.apply(this, arguments); + } + return ChildClassWithoutConstructor; +})(BaseClassWithConstructor); +var ccwc = new ChildClassWithoutConstructor(1, "s"); diff --git a/tests/baselines/reference/exportAlreadySeen.js b/tests/baselines/reference/exportAlreadySeen.js new file mode 100644 index 00000000000..e18c0bbf7f6 --- /dev/null +++ b/tests/baselines/reference/exportAlreadySeen.js @@ -0,0 +1,38 @@ +//// [exportAlreadySeen.ts] +module M { + export export var x = 1; + export export function f() { } + + export export module N { + export export class C { } + export export interface I { } + } +} + +declare module A { + export export var x; + export export function f() + + export export module N { + export export class C { } + export export interface I { } + } +} + +//// [exportAlreadySeen.js] +var M; +(function (M) { + M.x = 1; + function f() { + } + M.f = f; + var N; + (function (N) { + var C = (function () { + function C() { + } + return C; + })(); + N.C = C; + })(N = M.N || (M.N = {})); +})(M || (M = {})); diff --git a/tests/baselines/reference/exportAssignmentWithDeclareAndExportModifiers.js b/tests/baselines/reference/exportAssignmentWithDeclareAndExportModifiers.js new file mode 100644 index 00000000000..74396bb951b --- /dev/null +++ b/tests/baselines/reference/exportAssignmentWithDeclareAndExportModifiers.js @@ -0,0 +1,7 @@ +//// [exportAssignmentWithDeclareAndExportModifiers.ts] +var x; +export declare export = x; + +//// [exportAssignmentWithDeclareAndExportModifiers.js] +var x; +module.exports = x; diff --git a/tests/baselines/reference/exportAssignmentWithDeclareModifier.js b/tests/baselines/reference/exportAssignmentWithDeclareModifier.js new file mode 100644 index 00000000000..711538616aa --- /dev/null +++ b/tests/baselines/reference/exportAssignmentWithDeclareModifier.js @@ -0,0 +1,7 @@ +//// [exportAssignmentWithDeclareModifier.ts] +var x; +declare export = x; + +//// [exportAssignmentWithDeclareModifier.js] +var x; +module.exports = x; diff --git a/tests/baselines/reference/exportAssignmentWithExportModifier.js b/tests/baselines/reference/exportAssignmentWithExportModifier.js new file mode 100644 index 00000000000..9d94cc8db75 --- /dev/null +++ b/tests/baselines/reference/exportAssignmentWithExportModifier.js @@ -0,0 +1,7 @@ +//// [exportAssignmentWithExportModifier.ts] +var x; +export export = x; + +//// [exportAssignmentWithExportModifier.js] +var x; +module.exports = x; diff --git a/tests/baselines/reference/exportingContainingVisibleType.js b/tests/baselines/reference/exportingContainingVisibleType.js new file mode 100644 index 00000000000..2246a63bc49 --- /dev/null +++ b/tests/baselines/reference/exportingContainingVisibleType.js @@ -0,0 +1,29 @@ +//// [exportingContainingVisibleType.ts] +class Foo { + public get foo() { + var i: Foo; + return i; // Should be fine (previous bug report visibility error). + + } +} + +export var x = 5; + + +//// [exportingContainingVisibleType.js] +define(["require", "exports"], function (require, exports) { + var Foo = (function () { + function Foo() { + } + Object.defineProperty(Foo.prototype, "foo", { + get: function () { + var i; + return i; // Should be fine (previous bug report visibility error). + }, + enumerable: true, + configurable: true + }); + return Foo; + })(); + exports.x = 5; +}); diff --git a/tests/baselines/reference/extendsClauseAlreadySeen.js b/tests/baselines/reference/extendsClauseAlreadySeen.js new file mode 100644 index 00000000000..5c328e39131 --- /dev/null +++ b/tests/baselines/reference/extendsClauseAlreadySeen.js @@ -0,0 +1,29 @@ +//// [extendsClauseAlreadySeen.ts] +class C { + +} +class D extends C extends C { + baz() { } +} + +//// [extendsClauseAlreadySeen.js] +var __extends = 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 C = (function () { + function C() { + } + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + D.prototype.baz = function () { + }; + return D; +})(C); diff --git a/tests/baselines/reference/extendsClauseAlreadySeen2.js b/tests/baselines/reference/extendsClauseAlreadySeen2.js new file mode 100644 index 00000000000..3f3b7049311 --- /dev/null +++ b/tests/baselines/reference/extendsClauseAlreadySeen2.js @@ -0,0 +1,29 @@ +//// [extendsClauseAlreadySeen2.ts] +class C { + +} +class D extends C extends C { + baz() { } +} + +//// [extendsClauseAlreadySeen2.js] +var __extends = 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 C = (function () { + function C() { + } + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + D.prototype.baz = function () { + }; + return D; +})(C); diff --git a/tests/baselines/reference/externSemantics.js b/tests/baselines/reference/externSemantics.js new file mode 100644 index 00000000000..ed418c66f18 --- /dev/null +++ b/tests/baselines/reference/externSemantics.js @@ -0,0 +1,7 @@ +//// [externSemantics.ts] +declare var x=10; +declare var v; +declare var y:number=3; + + +//// [externSemantics.js] diff --git a/tests/baselines/reference/externSyntax.js b/tests/baselines/reference/externSyntax.js new file mode 100644 index 00000000000..409a9bcecef --- /dev/null +++ b/tests/baselines/reference/externSyntax.js @@ -0,0 +1,17 @@ +//// [externSyntax.ts] +declare var v; +declare module M { + export class D { + public p; + } + export class C { + public f(); + public g() { } // error body + } +} + + + + + +//// [externSyntax.js] diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.js b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.js new file mode 100644 index 00000000000..428a085ca56 --- /dev/null +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors1.js @@ -0,0 +1,38 @@ +//// [fatarrowfunctionsOptionalArgsErrors1.ts] +(arg1?, arg2) => 101; +(...arg?) => 102; +(...arg) => 103; +(...arg:number [] = []) => 104; + +// Non optional parameter following an optional one +(arg1 = 1, arg2) => 1; + +//// [fatarrowfunctionsOptionalArgsErrors1.js] +(function (arg1, arg2) { return 101; }); +(function () { + var arg = []; + for (var _i = 0; _i < arguments.length; _i++) { + arg[_i - 0] = arguments[_i]; + } + return 102; +}); +(function () { + var arg = []; + for (var _i = 0; _i < arguments.length; _i++) { + arg[_i - 0] = arguments[_i]; + } + return 103; +}); +(function () { + if (arg === void 0) { arg = []; } + var arg = []; + for (var _i = 0; _i < arguments.length; _i++) { + arg[_i - 0] = arguments[_i]; + } + return 104; +}); +// Non optional parameter following an optional one +(function (arg1, arg2) { + if (arg1 === void 0) { arg1 = 1; } + return 1; +}); diff --git a/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.js b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.js new file mode 100644 index 00000000000..dfd7e9f74dc --- /dev/null +++ b/tests/baselines/reference/fatarrowfunctionsOptionalArgsErrors4.js @@ -0,0 +1,69 @@ +//// [fatarrowfunctionsOptionalArgsErrors4.ts] + false ? (arg?: number = 0) => 47 : null; + false ? ((arg?: number = 0) => 57) : null; + false ? null : (arg?: number = 0) => 67; + ((arg?:number = 1) => 0) + '' + ((arg?:number = 2) => 106); + + foo( + (a) => 110, + ((a) => 111), + (a) => { + return 112; + }, + (a? ) => 113, + (a, b? ) => 114, + (a: number) => 115, + (a: number = 0) => 116, + (a = 0) => 117, + (a?: number = 0) => 118, + (...a: number[]) => 119, + (a, b? = 0, ...c: number[]) => 120, + (a) => (b) => (c) => 121, + false? (a) => 0 : (b) => 122 + ); + +//// [fatarrowfunctionsOptionalArgsErrors4.js] +false ? function (arg) { + if (arg === void 0) { arg = 0; } + return 47; +} : null; +false ? (function (arg) { + if (arg === void 0) { arg = 0; } + return 57; +}) : null; +false ? null : function (arg) { + if (arg === void 0) { arg = 0; } + return 67; +}; +(function (arg) { + if (arg === void 0) { arg = 1; } + return 0; +}) + '' + (function (arg) { + if (arg === void 0) { arg = 2; } + return 106; +}); +foo(function (a) { return 110; }, (function (a) { return 111; }), function (a) { + return 112; +}, function (a) { return 113; }, function (a, b) { return 114; }, function (a) { return 115; }, function (a) { + if (a === void 0) { a = 0; } + return 116; +}, function (a) { + if (a === void 0) { a = 0; } + return 117; +}, function (a) { + if (a === void 0) { a = 0; } + return 118; +}, function () { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i - 0] = arguments[_i]; + } + return 119; +}, function (a, b) { + if (b === void 0) { b = 0; } + var c = []; + for (var _i = 2; _i < arguments.length; _i++) { + c[_i - 2] = arguments[_i]; + } + return 120; +}, function (a) { return function (b) { return function (c) { return 121; }; }; }, false ? function (a) { return 0; } : function (b) { return 122; }); diff --git a/tests/baselines/reference/fieldAndGetterWithSameName.js b/tests/baselines/reference/fieldAndGetterWithSameName.js new file mode 100644 index 00000000000..64129ff9365 --- /dev/null +++ b/tests/baselines/reference/fieldAndGetterWithSameName.js @@ -0,0 +1,22 @@ +//// [fieldAndGetterWithSameName.ts] +export class C { + x: number; + get x(): number { return 1; } +} + +//// [fieldAndGetterWithSameName.js] +define(["require", "exports"], function (require, exports) { + var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; + })(); + exports.C = C; +}); diff --git a/tests/baselines/reference/functionAndPropertyNameConflict.js b/tests/baselines/reference/functionAndPropertyNameConflict.js new file mode 100644 index 00000000000..1368f8241d5 --- /dev/null +++ b/tests/baselines/reference/functionAndPropertyNameConflict.js @@ -0,0 +1,23 @@ +//// [functionAndPropertyNameConflict.ts] +class C65 { + public aaaaa() { } + public get aaaaa() { + return 1; + } +} + +//// [functionAndPropertyNameConflict.js] +var C65 = (function () { + function C65() { + } + C65.prototype.aaaaa = function () { + }; + Object.defineProperty(C65.prototype, "aaaaa", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C65; +})(); diff --git a/tests/baselines/reference/functionOverloadErrorsSyntax.js b/tests/baselines/reference/functionOverloadErrorsSyntax.js new file mode 100644 index 00000000000..3706f4da744 --- /dev/null +++ b/tests/baselines/reference/functionOverloadErrorsSyntax.js @@ -0,0 +1,20 @@ +//// [functionOverloadErrorsSyntax.ts] +//Function overload signature with optional parameter followed by non-optional parameter +function fn4a(x?: number, y: string); +function fn4a() { } + +function fn4b(n: string, x?: number, y: string); +function fn4b() { } + +//Function overload signature with rest param followed by non-optional parameter +function fn5(x: string, ...y: any[], z: string); +function fn5() { } + + +//// [functionOverloadErrorsSyntax.js] +function fn4a() { +} +function fn4b() { +} +function fn5() { +} diff --git a/tests/baselines/reference/functionsWithModifiersInBlocks1.js b/tests/baselines/reference/functionsWithModifiersInBlocks1.js new file mode 100644 index 00000000000..1d381bccfe1 --- /dev/null +++ b/tests/baselines/reference/functionsWithModifiersInBlocks1.js @@ -0,0 +1,13 @@ +//// [functionsWithModifiersInBlocks1.ts] +{ + declare function f() { } + export function f() { } + declare export function f() { } +} + +//// [functionsWithModifiersInBlocks1.js] +{ + function f() { + } + exports.f = f; +} diff --git a/tests/baselines/reference/genericGetter.js b/tests/baselines/reference/genericGetter.js new file mode 100644 index 00000000000..59425d8c13b --- /dev/null +++ b/tests/baselines/reference/genericGetter.js @@ -0,0 +1,26 @@ +//// [genericGetter.ts] +class C { + data: T; + get x(): T { + return this.data; + } +} + +var c = new C(); +var r: string = c.x; + +//// [genericGetter.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return this.data; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var c = new C(); +var r = c.x; diff --git a/tests/baselines/reference/genericGetter2.js b/tests/baselines/reference/genericGetter2.js new file mode 100644 index 00000000000..9d39ce02d5f --- /dev/null +++ b/tests/baselines/reference/genericGetter2.js @@ -0,0 +1,28 @@ +//// [genericGetter2.ts] +class A { } + +class C { + data: A; + get x(): A { + return this.data; + } +} + +//// [genericGetter2.js] +var A = (function () { + function A() { + } + return A; +})(); +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return this.data; + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/genericGetter3.js b/tests/baselines/reference/genericGetter3.js new file mode 100644 index 00000000000..1cb01c6f112 --- /dev/null +++ b/tests/baselines/reference/genericGetter3.js @@ -0,0 +1,33 @@ +//// [genericGetter3.ts] +class A { } + +class C { + data: A; + get x(): A { + return this.data; + } +} + +var c = new C(); +var r: string = c.x; + +//// [genericGetter3.js] +var A = (function () { + function A() { + } + return A; +})(); +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return this.data; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var c = new C(); +var r = c.x; diff --git a/tests/baselines/reference/genericReturnTypeFromGetter1.js b/tests/baselines/reference/genericReturnTypeFromGetter1.js new file mode 100644 index 00000000000..208b12308e1 --- /dev/null +++ b/tests/baselines/reference/genericReturnTypeFromGetter1.js @@ -0,0 +1,27 @@ +//// [genericReturnTypeFromGetter1.ts] +export interface A { + new (dbSet: DbSet): T; +} +export class DbSet { + _entityType: A; + get entityType() { return this._entityType; } // used to ICE without return type annotation +} + + +//// [genericReturnTypeFromGetter1.js] +define(["require", "exports"], function (require, exports) { + var DbSet = (function () { + function DbSet() { + } + Object.defineProperty(DbSet.prototype, "entityType", { + get: function () { + return this._entityType; + } // used to ICE without return type annotation + , + enumerable: true, + configurable: true + }); + return DbSet; + })(); + exports.DbSet = DbSet; +}); diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js new file mode 100644 index 00000000000..dbda6074830 --- /dev/null +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument.js @@ -0,0 +1,103 @@ +//// [genericTypeReferenceWithoutTypeArgument.ts] +// it is an error to use a generic type without type arguments +// all of these are errors + +class C { + foo: T; +} + +var c: C; + +var a: { x: C }; +var b: { (x: C): C }; +var d: { [x: C]: C }; + +var e = (x: C) => { var y: C; return y; } + +function f(x: C): C { var y: C; return y; } + +var g = function f(x: C): C { var y: C; return y; } + +class D extends C { +} + +interface I extends C {} + +module M { + export class E { foo: T } +} + +class D2 extends M.E { } +class D3 { } +interface I2 extends M.E { } + +function h(x: T) { } +function i(x: T) { } + +var j = null; +var k = null; + +//// [genericTypeReferenceWithoutTypeArgument.js] +// it is an error to use a generic type without type arguments +// all of these are errors +var __extends = 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 C = (function () { + function C() { + } + return C; +})(); +var c; +var a; +var b; +var d; +var e = function (x) { + var y; + return y; +}; +function f(x) { + var y; + return y; +} +var g = function f(x) { + var y; + return y; +}; +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(C); +var M; +(function (M) { + var E = (function () { + function E() { + } + return E; + })(); + M.E = E; +})(M || (M = {})); +var D2 = (function (_super) { + __extends(D2, _super); + function D2() { + _super.apply(this, arguments); + } + return D2; +})(M.E); +var D3 = (function () { + function D3() { + } + return D3; +})(); +function h(x) { +} +function i(x) { +} +var j = null; +var k = null; diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js new file mode 100644 index 00000000000..f6a22073702 --- /dev/null +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.js @@ -0,0 +1,84 @@ +//// [genericTypeReferenceWithoutTypeArgument2.ts] +// it is an error to use a generic type without type arguments +// all of these are errors + +interface I { + foo: T; +} + +var c: I; + +var a: { x: I }; +var b: { (x: I): I }; +var d: { [x: I]: I }; + +var e = (x: I) => { var y: I; return y; } + +function f(x: I): I { var y: I; return y; } + +var g = function f(x: I): I { var y: I; return y; } + +class D extends I { +} + +interface U extends I {} + +module M { + export interface E { foo: T } +} + +class D2 extends M.C { } +interface D3 { } +interface I2 extends M.C { } + +function h(x: T) { } +function i(x: T) { } + +var j = null; +var k = null; + +//// [genericTypeReferenceWithoutTypeArgument2.js] +// it is an error to use a generic type without type arguments +// all of these are errors +var __extends = 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 c; +var a; +var b; +var d; +var e = function (x) { + var y; + return y; +}; +function f(x) { + var y; + return y; +} +var g = function f(x) { + var y; + return y; +}; +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(I); +var D2 = (function (_super) { + __extends(D2, _super); + function D2() { + _super.apply(this, arguments); + } + return D2; +})(M.C); +function h(x) { +} +function i(x) { +} +var j = null; +var k = null; diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.js b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.js new file mode 100644 index 00000000000..a56ec43d7c3 --- /dev/null +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument3.js @@ -0,0 +1,31 @@ +//// [genericTypeReferenceWithoutTypeArgument3.ts] +// it is an error to use a generic type without type arguments +// all of these are errors + +declare class C { + foo: T; +} + +declare var c: C; + +declare var a: { x: C }; +declare var b: { (x: C): C }; +declare var d: { [x: C]: C }; + +declare function f(x: C): C; + +declare class D extends C {} + +declare module M { + export class E { foo: T } +} + +declare class D2 extends M.C { } +declare class D3 { } + +declare function h(x: T); +declare function i(x: T); + +//// [genericTypeReferenceWithoutTypeArgument3.js] +// it is an error to use a generic type without type arguments +// all of these are errors diff --git a/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.js b/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.js new file mode 100644 index 00000000000..0211ce55119 --- /dev/null +++ b/tests/baselines/reference/getAccessorWithImpliedReturnTypeAndFunctionClassMerge.js @@ -0,0 +1,47 @@ +//// [getAccessorWithImpliedReturnTypeAndFunctionClassMerge.ts] +declare function _(value: Array): _; +declare function _(value: T): _; + +declare module _ { + export function each( + //list: List, + //iterator: ListIterator, + context?: any): void; + + interface ListIterator { + (value: T, index: number, list: T[]): TResult; + } +} + +declare class _ { + each(iterator: _.ListIterator, context?: any): void; +} + +module MyModule { + export class MyClass { + public get myGetter() { + var obj:any = {}; + + return obj; + } + } +} + +//// [getAccessorWithImpliedReturnTypeAndFunctionClassMerge.js] +var MyModule; +(function (MyModule) { + var MyClass = (function () { + function MyClass() { + } + Object.defineProperty(MyClass.prototype, "myGetter", { + get: function () { + var obj = {}; + return obj; + }, + enumerable: true, + configurable: true + }); + return MyClass; + })(); + MyModule.MyClass = MyClass; +})(MyModule || (MyModule = {})); diff --git a/tests/baselines/reference/getAndSetAsMemberNames.js b/tests/baselines/reference/getAndSetAsMemberNames.js new file mode 100644 index 00000000000..22f99920fb1 --- /dev/null +++ b/tests/baselines/reference/getAndSetAsMemberNames.js @@ -0,0 +1,66 @@ +//// [getAndSetAsMemberNames.ts] +class C1 { + set: boolean; + get = 1; +} +class C2 { + set; +} +class C3 { + set (x) { + return x + 1; + } +} +class C4 { + get: boolean = true; +} +class C5 { + public set: () => boolean = function () { return true; }; + get (): boolean { return true; } + set t(x) { } +} + + +//// [getAndSetAsMemberNames.js] +var C1 = (function () { + function C1() { + this.get = 1; + } + return C1; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); +var C3 = (function () { + function C3() { + } + C3.prototype.set = function (x) { + return x + 1; + }; + return C3; +})(); +var C4 = (function () { + function C4() { + this.get = true; + } + return C4; +})(); +var C5 = (function () { + function C5() { + this.set = function () { + return true; + }; + } + C5.prototype.get = function () { + return true; + }; + Object.defineProperty(C5.prototype, "t", { + set: function (x) { + }, + enumerable: true, + configurable: true + }); + return C5; +})(); diff --git a/tests/baselines/reference/getAndSetNotIdenticalType.js b/tests/baselines/reference/getAndSetNotIdenticalType.js new file mode 100644 index 00000000000..7e77fc25d0b --- /dev/null +++ b/tests/baselines/reference/getAndSetNotIdenticalType.js @@ -0,0 +1,23 @@ +//// [getAndSetNotIdenticalType.ts] +class C { + get x(): number { + return 1; + } + set x(v: string) { } +} + +//// [getAndSetNotIdenticalType.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/getAndSetNotIdenticalType2.js b/tests/baselines/reference/getAndSetNotIdenticalType2.js new file mode 100644 index 00000000000..d73f07ec388 --- /dev/null +++ b/tests/baselines/reference/getAndSetNotIdenticalType2.js @@ -0,0 +1,41 @@ +//// [getAndSetNotIdenticalType2.ts] +class A { foo: T; } + +class C { + data: A; + get x(): A { + return this.data; + } + set x(v: A) { + this.data = v; + } +} + +var x = new C(); +var r = x.x; +x.x = r; + +//// [getAndSetNotIdenticalType2.js] +var A = (function () { + function A() { + } + return A; +})(); +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return this.data; + }, + set: function (v) { + this.data = v; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var x = new C(); +var r = x.x; +x.x = r; diff --git a/tests/baselines/reference/getAndSetNotIdenticalType3.js b/tests/baselines/reference/getAndSetNotIdenticalType3.js new file mode 100644 index 00000000000..2f37a7cbfae --- /dev/null +++ b/tests/baselines/reference/getAndSetNotIdenticalType3.js @@ -0,0 +1,41 @@ +//// [getAndSetNotIdenticalType3.ts] +class A { foo: T; } + +class C { + data: A; + get x(): A { + return this.data; + } + set x(v: A) { + this.data = v; + } +} + +var x = new C(); +var r = x.x; +x.x = r; + +//// [getAndSetNotIdenticalType3.js] +var A = (function () { + function A() { + } + return A; +})(); +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return this.data; + }, + set: function (v) { + this.data = v; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var x = new C(); +var r = x.x; +x.x = r; diff --git a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline index a5d5d2eb9d7..889902d98a2 100644 --- a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline @@ -1,2 +1,5 @@ -EmitOutputStatus : AllOutputGenerationSkipped +EmitOutputStatus : JSGeneratedWithSemanticErrors +Filename : tests/cases/fourslash/inputFile1.js +// File contains early errors. All outputs should be skipped. +const uninitialized_const_error; diff --git a/tests/baselines/reference/getsetReturnTypes.js b/tests/baselines/reference/getsetReturnTypes.js new file mode 100644 index 00000000000..55d7e9285b0 --- /dev/null +++ b/tests/baselines/reference/getsetReturnTypes.js @@ -0,0 +1,20 @@ +//// [getsetReturnTypes.ts] +function makePoint(x: number) { + return { + get x() { return x; } + } +}; +var x = makePoint(2).x; +var y: number = makePoint(2).x; + +//// [getsetReturnTypes.js] +function makePoint(x) { + return { + get x() { + return x; + } + }; +} +; +var x = makePoint(2).x; +var y = makePoint(2).x; diff --git a/tests/baselines/reference/getterMissingReturnError.js b/tests/baselines/reference/getterMissingReturnError.js new file mode 100644 index 00000000000..76566d9346e --- /dev/null +++ b/tests/baselines/reference/getterMissingReturnError.js @@ -0,0 +1,20 @@ +//// [getterMissingReturnError.ts] +class test { + public get p2(){ + + } +} + + +//// [getterMissingReturnError.js] +var test = (function () { + function test() { + } + Object.defineProperty(test.prototype, "p2", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return test; +})(); diff --git a/tests/baselines/reference/getterThatThrowsShouldNotNeedReturn.js b/tests/baselines/reference/getterThatThrowsShouldNotNeedReturn.js new file mode 100644 index 00000000000..c48e5c9c6bc --- /dev/null +++ b/tests/baselines/reference/getterThatThrowsShouldNotNeedReturn.js @@ -0,0 +1,27 @@ +//// [getterThatThrowsShouldNotNeedReturn.ts] +class Greeter { + public get greet(): string { + throw ''; // should not raise an error + } + public greeting(): string { + throw ''; // should not raise an error + } +} + + +//// [getterThatThrowsShouldNotNeedReturn.js] +var Greeter = (function () { + function Greeter() { + } + Object.defineProperty(Greeter.prototype, "greet", { + get: function () { + throw ''; // should not raise an error + }, + enumerable: true, + configurable: true + }); + Greeter.prototype.greeting = function () { + throw ''; // should not raise an error + }; + return Greeter; +})(); diff --git a/tests/baselines/reference/gettersAndSetters.js b/tests/baselines/reference/gettersAndSetters.js new file mode 100644 index 00000000000..4c94cbc43db --- /dev/null +++ b/tests/baselines/reference/gettersAndSetters.js @@ -0,0 +1,98 @@ +//// [gettersAndSetters.ts] +// classes +class C { + public fooBack = ""; + static barBack:string = ""; + public bazBack = ""; + + public get Foo() { return this.fooBack;} // ok + public set Foo(foo:string) {this.fooBack = foo;} // ok + + static get Bar() {return C.barBack;} // ok + static set Bar(bar:string) {C.barBack = bar;} // ok + + public get = function() {} // ok + public set = function() {} // ok +} + +var c = new C(); + +var foo = c.Foo; +c.Foo = "foov"; + +var bar = C.Bar; +C.Bar = "barv"; + +var baz = c.Baz; +c.Baz = "bazv"; + +// The Foo accessors' return and param types should be contextually typed to the Foo field +var o : {Foo:number;} = {get Foo() {return 0;}, set Foo(val:number){val}}; // o + +var ofg = o.Foo; +o.Foo = 0; + + +interface I1 { + (n:number):number; +} + +var i:I1 = function (n) {return n;} + + +//// [gettersAndSetters.js] +// classes +var C = (function () { + function C() { + this.fooBack = ""; + this.bazBack = ""; + this.get = function () { + }; // ok + this.set = function () { + }; // ok + } + Object.defineProperty(C.prototype, "Foo", { + get: function () { + return this.fooBack; + } // ok + , + set: function (foo) { + this.fooBack = foo; + } // ok + , + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "Bar", { + get: function () { + return C.barBack; + } // ok + , + set: function (bar) { + C.barBack = bar; + } // ok + , + enumerable: true, + configurable: true + }); + C.barBack = ""; + return C; +})(); +var c = new C(); +var foo = c.Foo; +c.Foo = "foov"; +var bar = C.Bar; +C.Bar = "barv"; +var baz = c.Baz; +c.Baz = "bazv"; +// The Foo accessors' return and param types should be contextually typed to the Foo field +var o = { get Foo() { + return 0; +}, set Foo(val) { + val; +} }; // o +var ofg = o.Foo; +o.Foo = 0; +var i = function (n) { + return n; +}; diff --git a/tests/baselines/reference/gettersAndSettersAccessibility.js b/tests/baselines/reference/gettersAndSettersAccessibility.js new file mode 100644 index 00000000000..9a7564ec96d --- /dev/null +++ b/tests/baselines/reference/gettersAndSettersAccessibility.js @@ -0,0 +1,23 @@ +//// [gettersAndSettersAccessibility.ts] +class C99 { + private get Baz():number { return 0; } + public set Baz(n:number) {} // error - accessors do not agree in visibility +} + + +//// [gettersAndSettersAccessibility.js] +var C99 = (function () { + function C99() { + } + Object.defineProperty(C99.prototype, "Baz", { + get: function () { + return 0; + }, + set: function (n) { + } // error - accessors do not agree in visibility + , + enumerable: true, + configurable: true + }); + return C99; +})(); diff --git a/tests/baselines/reference/gettersAndSettersErrors.js b/tests/baselines/reference/gettersAndSettersErrors.js new file mode 100644 index 00000000000..514a69b2513 --- /dev/null +++ b/tests/baselines/reference/gettersAndSettersErrors.js @@ -0,0 +1,62 @@ +//// [gettersAndSettersErrors.ts] +class C { + public get Foo() { return "foo";} // ok + public set Foo(foo:string) {} // ok + + public Foo = 0; // error - duplicate identifier Foo - confirmed + public get Goo(v:string):string {return null;} // error - getters must not have a parameter + public set Goo(v:string):string {} // error - setters must not specify a return type +} + +class E { + private get Baz():number { return 0; } + public set Baz(n:number) {} // error - accessors do not agree in visibility +} + + + + +//// [gettersAndSettersErrors.js] +var C = (function () { + function C() { + this.Foo = 0; // error - duplicate identifier Foo - confirmed + } + Object.defineProperty(C.prototype, "Foo", { + get: function () { + return "foo"; + } // ok + , + set: function (foo) { + } // ok + , + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "Goo", { + get: function (v) { + return null; + } // error - getters must not have a parameter + , + set: function (v) { + } // error - setters must not specify a return type + , + enumerable: true, + configurable: true + }); + return C; +})(); +var E = (function () { + function E() { + } + Object.defineProperty(E.prototype, "Baz", { + get: function () { + return 0; + }, + set: function (n) { + } // error - accessors do not agree in visibility + , + enumerable: true, + configurable: true + }); + return E; +})(); diff --git a/tests/baselines/reference/gettersAndSettersTypesAgree.js b/tests/baselines/reference/gettersAndSettersTypesAgree.js new file mode 100644 index 00000000000..48c0ac1500c --- /dev/null +++ b/tests/baselines/reference/gettersAndSettersTypesAgree.js @@ -0,0 +1,48 @@ +//// [gettersAndSettersTypesAgree.ts] +class C { + public get Foo() { return "foo";} // ok + public set Foo(foo) {} // ok - type inferred from getter return statement + + public get Bar() { return "foo";} // ok + public set Bar(bar:string) {} // ok - type must be declared +} + +var o1 = {get Foo(){return 0;}, set Foo(val){}}; // ok - types agree (inference) +var o2 = {get Foo(){return 0;}, set Foo(val:number){}}; // ok - types agree + +//// [gettersAndSettersTypesAgree.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + get: function () { + return "foo"; + } // ok + , + set: function (foo) { + } // ok - type inferred from getter return statement + , + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "Bar", { + get: function () { + return "foo"; + } // ok + , + set: function (bar) { + } // ok - type must be declared + , + enumerable: true, + configurable: true + }); + return C; +})(); +var o1 = { get Foo() { + return 0; +}, set Foo(val) { +} }; // ok - types agree (inference) +var o2 = { get Foo() { + return 0; +}, set Foo(val) { +} }; // ok - types agree diff --git a/tests/baselines/reference/giant.js b/tests/baselines/reference/giant.js new file mode 100644 index 00000000000..d5f17c9728f --- /dev/null +++ b/tests/baselines/reference/giant.js @@ -0,0 +1,1220 @@ +//// [giant.ts] + +/* + Prefixes + p -> public + r -> private + i -> import + e -> export + a -> ambient + t -> static + s -> set + g -> get + + MAX DEPTH 3 LEVELS +*/ +var V; +function F() { }; +class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() +} +interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; +} +module M { + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + module M { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { }; + export declare module eaM { }; + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + export module eM { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { }; + export declare module eaM { }; + } + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + export declare module eaM { + var V; + function F() { }; + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + export class eC { } + export interface eI { } + export module eM { } + } +} +export var eV; +export function eF() { }; +export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() +} +export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; +} +export module eM { + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + interface I { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + module M { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { }; + export declare module eaM { }; + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + export module eM { + var V; + function F() { }; + class C { }; + interface I { }; + module M { }; + export var eV; + export function eF() { }; + export class eC { }; + export interface eI { }; + export module eM { }; + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { }; + export declare module eaM { }; + } + export declare var eaV; + export declare function eaF() { }; + export declare class eaC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() + } + export declare module eaM { + var V; + function F() { }; + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + export class eC { } + export interface eI { } + export module eM { } + } +} +export declare var eaV; +export declare function eaF() { }; +export declare class eaC { + constructor () { } + public pV; + private rV; + public pF() { } + private rF() { } + public pgF() { } + public get pgF() + public psF(param:any) { } + public set psF(param:any) + private rgF() { } + private get rgF() + private rsF(param:any) { } + private set rsF(param:any) + static tV; + static tF() { } + static tsF(param:any) { } + static set tsF(param:any) + static tgF() { } + static get tgF() +} +export declare module eaM { + var V; + function F() { }; + class C { + constructor () { } + public pV; + private rV; + public pF() { } + static tV; + static tF() { } + } + interface I { + //Call Signature + (); + (): number; + (p: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + module M { + var V; + function F() { }; + class C { } + interface I { } + module M { } + export var eV; + export function eF() { }; + export class eC { } + export interface eI { } + export module eM { } + export declare var eaV + export declare function eaF() { }; + export declare class eaC { } + export declare module eaM { } + } + export var eV; + export function eF() { }; + export class eC { + constructor () { } + public pV; + private rV; + public pF() { } + static tV + static tF() { } + } + export interface eI { + //Call Signature + (); + (): number; + (p); + (p1: string); + (p2?: string); + (...p3: any[]); + (p4: string, p5?: string); + (p6: string, ...p7: any[]); + //(p8?: string, ...p9: any[]); + //(p10:string, p8?: string, ...p9: any[]); + + //Construct Signature + new (); + new (): number; + new (p: string); + new (p2?: string); + new (...p3: any[]); + new (p4: string, p5?: string); + new (p6: string, ...p7: any[]); + + //Index Signature + [p]; + [p1: string]; + [p2: string, p3: number]; + + //Property Signature + p; + p1?; + p2?: string; + + //Function Signature + p3(); + p4? (); + p5? (): void; + p6(pa1): void; + p7(pa1, pa2): void; + p7? (pa1, pa2): void; + } + export module eM { + var V; + function F() { }; + class C { } + module M { } + export var eV; + export function eF() { }; + export class eC { } + export interface eI { } + export module eM { } + } +} + +//// [giant.js] +define(["require", "exports"], function (require, exports) { + /* + Prefixes + p -> public + r -> private + i -> import + e -> export + a -> ambient + t -> static + s -> set + g -> get + + MAX DEPTH 3 LEVELS + */ + var V; + function F() { + } + ; + var C = (function () { + function C() { + } + C.prototype.pF = function () { + }; + C.prototype.rF = function () { + }; + C.prototype.pgF = function () { + }; + Object.defineProperty(C.prototype, "pgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + C.prototype.psF = function (param) { + }; + Object.defineProperty(C.prototype, "psF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.prototype.rgF = function () { + }; + Object.defineProperty(C.prototype, "rgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + C.prototype.rsF = function (param) { + }; + Object.defineProperty(C.prototype, "rsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.tF = function () { + }; + C.tsF = function (param) { + }; + Object.defineProperty(C, "tsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.tgF = function () { + }; + Object.defineProperty(C, "tgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; + })(); + var M; + (function (_M) { + var V; + function F() { + } + ; + var C = (function () { + function C() { + } + C.prototype.pF = function () { + }; + C.prototype.rF = function () { + }; + C.prototype.pgF = function () { + }; + Object.defineProperty(C.prototype, "pgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + C.prototype.psF = function (param) { + }; + Object.defineProperty(C.prototype, "psF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.prototype.rgF = function () { + }; + Object.defineProperty(C.prototype, "rgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + C.prototype.rsF = function (param) { + }; + Object.defineProperty(C.prototype, "rsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.tF = function () { + }; + C.tsF = function (param) { + }; + Object.defineProperty(C, "tsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.tgF = function () { + }; + Object.defineProperty(C, "tgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; + })(); + var M; + (function (M) { + var V; + function F() { + } + ; + var C = (function () { + function C() { + } + return C; + })(); + ; + ; + ; + M.eV; + function eF() { + } + M.eF = eF; + ; + var eC = (function () { + function eC() { + } + return eC; + })(); + M.eC = eC; + ; + ; + ; + ; + ; + ; + })(M || (M = {})); + _M.eV; + function eF() { + } + _M.eF = eF; + ; + var eC = (function () { + function eC() { + } + eC.prototype.pF = function () { + }; + eC.prototype.rF = function () { + }; + eC.prototype.pgF = function () { + }; + Object.defineProperty(eC.prototype, "pgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + eC.prototype.psF = function (param) { + }; + Object.defineProperty(eC.prototype, "psF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.prototype.rgF = function () { + }; + Object.defineProperty(eC.prototype, "rgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + eC.prototype.rsF = function (param) { + }; + Object.defineProperty(eC.prototype, "rsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.tF = function () { + }; + eC.tsF = function (param) { + }; + Object.defineProperty(eC, "tsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.tgF = function () { + }; + Object.defineProperty(eC, "tgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return eC; + })(); + _M.eC = eC; + var eM; + (function (eM) { + var V; + function F() { + } + ; + var C = (function () { + function C() { + } + return C; + })(); + ; + ; + ; + eM.eV; + function eF() { + } + eM.eF = eF; + ; + var eC = (function () { + function eC() { + } + return eC; + })(); + eM.eC = eC; + ; + ; + ; + ; + ; + ; + })(eM = _M.eM || (_M.eM = {})); + ; + })(M || (M = {})); + exports.eV; + function eF() { + } + exports.eF = eF; + ; + var eC = (function () { + function eC() { + } + eC.prototype.pF = function () { + }; + eC.prototype.rF = function () { + }; + eC.prototype.pgF = function () { + }; + Object.defineProperty(eC.prototype, "pgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + eC.prototype.psF = function (param) { + }; + Object.defineProperty(eC.prototype, "psF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.prototype.rgF = function () { + }; + Object.defineProperty(eC.prototype, "rgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + eC.prototype.rsF = function (param) { + }; + Object.defineProperty(eC.prototype, "rsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.tF = function () { + }; + eC.tsF = function (param) { + }; + Object.defineProperty(eC, "tsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.tgF = function () { + }; + Object.defineProperty(eC, "tgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return eC; + })(); + exports.eC = eC; + var eM; + (function (_eM) { + var V; + function F() { + } + ; + var C = (function () { + function C() { + } + C.prototype.pF = function () { + }; + C.prototype.rF = function () { + }; + C.prototype.pgF = function () { + }; + Object.defineProperty(C.prototype, "pgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + C.prototype.psF = function (param) { + }; + Object.defineProperty(C.prototype, "psF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.prototype.rgF = function () { + }; + Object.defineProperty(C.prototype, "rgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + C.prototype.rsF = function (param) { + }; + Object.defineProperty(C.prototype, "rsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.tF = function () { + }; + C.tsF = function (param) { + }; + Object.defineProperty(C, "tsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + C.tgF = function () { + }; + Object.defineProperty(C, "tgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; + })(); + var M; + (function (M) { + var V; + function F() { + } + ; + var C = (function () { + function C() { + } + return C; + })(); + ; + ; + ; + M.eV; + function eF() { + } + M.eF = eF; + ; + var eC = (function () { + function eC() { + } + return eC; + })(); + M.eC = eC; + ; + ; + ; + ; + ; + ; + })(M || (M = {})); + _eM.eV; + function eF() { + } + _eM.eF = eF; + ; + var eC = (function () { + function eC() { + } + eC.prototype.pF = function () { + }; + eC.prototype.rF = function () { + }; + eC.prototype.pgF = function () { + }; + Object.defineProperty(eC.prototype, "pgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + eC.prototype.psF = function (param) { + }; + Object.defineProperty(eC.prototype, "psF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.prototype.rgF = function () { + }; + Object.defineProperty(eC.prototype, "rgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + eC.prototype.rsF = function (param) { + }; + Object.defineProperty(eC.prototype, "rsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.tF = function () { + }; + eC.tsF = function (param) { + }; + Object.defineProperty(eC, "tsF", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + eC.tgF = function () { + }; + Object.defineProperty(eC, "tgF", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return eC; + })(); + _eM.eC = eC; + var eM; + (function (eM) { + var V; + function F() { + } + ; + var C = (function () { + function C() { + } + return C; + })(); + ; + ; + ; + eM.eV; + function eF() { + } + eM.eF = eF; + ; + var eC = (function () { + function eC() { + } + return eC; + })(); + eM.eC = eC; + ; + ; + ; + ; + ; + ; + })(eM = _eM.eM || (_eM.eM = {})); + ; + })(eM = exports.eM || (exports.eM = {})); + ; +}); diff --git a/tests/baselines/reference/illegalModifiersOnClassElements.js b/tests/baselines/reference/illegalModifiersOnClassElements.js new file mode 100644 index 00000000000..b9a40fa6aa0 --- /dev/null +++ b/tests/baselines/reference/illegalModifiersOnClassElements.js @@ -0,0 +1,14 @@ +//// [illegalModifiersOnClassElements.ts] +class C { + declare foo = 1; + export bar = 1; +} + +//// [illegalModifiersOnClassElements.js] +var C = (function () { + function C() { + this.foo = 1; + this.bar = 1; + } + return C; +})(); diff --git a/tests/baselines/reference/illegalSuperCallsInConstructor.js b/tests/baselines/reference/illegalSuperCallsInConstructor.js new file mode 100644 index 00000000000..b978af1a609 --- /dev/null +++ b/tests/baselines/reference/illegalSuperCallsInConstructor.js @@ -0,0 +1,56 @@ +//// [illegalSuperCallsInConstructor.ts] +class Base { + x: string; +} + +class Derived extends Base { + constructor() { + var r2 = () => super(); + var r3 = () => { super(); } + var r4 = function () { super(); } + var r5 = { + get foo() { + super(); + return 1; + }, + set foo(v: number) { + super(); + } + } + } +} + +//// [illegalSuperCallsInConstructor.js] +var __extends = 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 Base = (function () { + function Base() { + } + return Base; +})(); +var Derived = (function (_super) { + __extends(Derived, _super); + function Derived() { + var r2 = function () { return _super.call(this); }; + var r3 = function () { + _super.call(this); + }; + var r4 = function () { + _super.call(this); + }; + var r5 = { + get foo() { + _super.call(this); + return 1; + }, + set foo(v) { + _super.call(this); + } + }; + } + return Derived; +})(Base); diff --git a/tests/baselines/reference/implementClausePrecedingExtends.js b/tests/baselines/reference/implementClausePrecedingExtends.js new file mode 100644 index 00000000000..e8f0b96f485 --- /dev/null +++ b/tests/baselines/reference/implementClausePrecedingExtends.js @@ -0,0 +1,23 @@ +//// [implementClausePrecedingExtends.ts] +class C { foo: number } +class D implements C extends C { } + +//// [implementClausePrecedingExtends.js] +var __extends = 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 C = (function () { + function C() { + } + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(C); diff --git a/tests/baselines/reference/implementsClauseAlreadySeen.js b/tests/baselines/reference/implementsClauseAlreadySeen.js new file mode 100644 index 00000000000..84823c13fa8 --- /dev/null +++ b/tests/baselines/reference/implementsClauseAlreadySeen.js @@ -0,0 +1,21 @@ +//// [implementsClauseAlreadySeen.ts] +class C { + +} +class D implements C implements C { + baz() { } +} + +//// [implementsClauseAlreadySeen.js] +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + D.prototype.baz = function () { + }; + return D; +})(); diff --git a/tests/baselines/reference/implicitAnyCastedValue.js b/tests/baselines/reference/implicitAnyCastedValue.js new file mode 100644 index 00000000000..be6bd1bfef3 --- /dev/null +++ b/tests/baselines/reference/implicitAnyCastedValue.js @@ -0,0 +1,163 @@ +//// [implicitAnyCastedValue.ts] +var x = function () { + return 0; // this should not be an error +} + +function foo() { + return "hello world"; // this should not be an error +} + +class C { + bar = null; // this should be an error + foo = undefined; // this should be an error + public get tempVar() { + return 0; // this should not be an error + } + + public returnBarWithCase() { // this should not be an error + return this.bar; + } + + public returnFooWithCase() { + return this.foo; // this should not be an error + } +} + +class C1 { + getValue = null; // this should be an error + + public get castedGet() { + return this.getValue; // this should not be an error + } + + public get notCastedGet() { + return this.getValue; // this should not be an error + } +} + +function castedNull() { + return null; // this should not be an error +} + +function notCastedNull() { + return null; // this should be an error +} + +function returnTypeBar(): any { + return null; // this should not be an error +} + +function undefinedBar() { + return undefined; // this should not be an error +} + +function multipleRets1(x) { // this should not be an error + if (x) { + return 0; + } + else { + return null; + } +} + +function multipleRets2(x) { // this should not be an error + if (x) { + return null; + } + else if (x == 1) { + return 0; + } + else { + return undefined; + } +} + +// this should not be an error +var bar1 = null; +var bar2 = undefined; +var bar3 = 0; +var array = [null, undefined]; + +//// [implicitAnyCastedValue.js] +var x = function () { + return 0; // this should not be an error +}; +function foo() { + return "hello world"; // this should not be an error +} +var C = (function () { + function C() { + this.bar = null; // this should be an error + this.foo = undefined; // this should be an error + } + Object.defineProperty(C.prototype, "tempVar", { + get: function () { + return 0; // this should not be an error + }, + enumerable: true, + configurable: true + }); + C.prototype.returnBarWithCase = function () { + return this.bar; + }; + C.prototype.returnFooWithCase = function () { + return this.foo; // this should not be an error + }; + return C; +})(); +var C1 = (function () { + function C1() { + this.getValue = null; // this should be an error + } + Object.defineProperty(C1.prototype, "castedGet", { + get: function () { + return this.getValue; // this should not be an error + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C1.prototype, "notCastedGet", { + get: function () { + return this.getValue; // this should not be an error + }, + enumerable: true, + configurable: true + }); + return C1; +})(); +function castedNull() { + return null; // this should not be an error +} +function notCastedNull() { + return null; // this should be an error +} +function returnTypeBar() { + return null; // this should not be an error +} +function undefinedBar() { + return undefined; // this should not be an error +} +function multipleRets1(x) { + if (x) { + return 0; + } + else { + return null; + } +} +function multipleRets2(x) { + if (x) { + return null; + } + else if (x == 1) { + return 0; + } + else { + return undefined; + } +} +// this should not be an error +var bar1 = null; +var bar2 = undefined; +var bar3 = 0; +var array = [null, undefined]; diff --git a/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.js b/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.js new file mode 100644 index 00000000000..ac3b5e66493 --- /dev/null +++ b/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.js @@ -0,0 +1,67 @@ +//// [implicitAnyGetAndSetAccessorWithAnyReturnType.ts] +// these should be errors +class GetAndSet { + getAndSet = null; // error at "getAndSet" + public get haveGetAndSet() { // this should not be an error + return this.getAndSet; + } + + // this shouldn't be an error + public set haveGetAndSet(value) { // error at "value" + this.getAndSet = value; + } +} + +class SetterOnly { + public set haveOnlySet(newXValue) { // error at "haveOnlySet, newXValue" + } +} + +class GetterOnly { + public get haveOnlyGet() { // error at "haveOnlyGet" + return null; + } +} + +//// [implicitAnyGetAndSetAccessorWithAnyReturnType.js] +// these should be errors +var GetAndSet = (function () { + function GetAndSet() { + this.getAndSet = null; // error at "getAndSet" + } + Object.defineProperty(GetAndSet.prototype, "haveGetAndSet", { + get: function () { + return this.getAndSet; + }, + // this shouldn't be an error + set: function (value) { + this.getAndSet = value; + }, + enumerable: true, + configurable: true + }); + return GetAndSet; +})(); +var SetterOnly = (function () { + function SetterOnly() { + } + Object.defineProperty(SetterOnly.prototype, "haveOnlySet", { + set: function (newXValue) { + }, + enumerable: true, + configurable: true + }); + return SetterOnly; +})(); +var GetterOnly = (function () { + function GetterOnly() { + } + Object.defineProperty(GetterOnly.prototype, "haveOnlyGet", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + return GetterOnly; +})(); diff --git a/tests/baselines/reference/implicitAnyInAmbientDeclaration.js b/tests/baselines/reference/implicitAnyInAmbientDeclaration.js new file mode 100644 index 00000000000..7807f8fc1ee --- /dev/null +++ b/tests/baselines/reference/implicitAnyInAmbientDeclaration.js @@ -0,0 +1,16 @@ +//// [implicitAnyInAmbientDeclaration.ts] +module Test { + declare class C { + public publicMember; // this should be an error + private privateMember; // this should not be an error + + public publicFunction(x); // this should be an error + private privateFunction(privateParam); // this should not be an error + private constructor(privateParam); + } +} + +//// [implicitAnyInAmbientDeclaration.js] +var Test; +(function (Test) { +})(Test || (Test = {})); diff --git a/tests/baselines/reference/importDeclWithClassModifiers.js b/tests/baselines/reference/importDeclWithClassModifiers.js new file mode 100644 index 00000000000..c8aefe03bab --- /dev/null +++ b/tests/baselines/reference/importDeclWithClassModifiers.js @@ -0,0 +1,15 @@ +//// [importDeclWithClassModifiers.ts] +module x { + interface c { + } +} +export public import a = x.c; +export private import b = x.c; +export static import c = x.c; +var b: a; + + +//// [importDeclWithClassModifiers.js] +define(["require", "exports"], function (require, exports) { + var b; +}); diff --git a/tests/baselines/reference/importDeclWithDeclareModifierInAmbientContext.js b/tests/baselines/reference/importDeclWithDeclareModifierInAmbientContext.js new file mode 100644 index 00000000000..a268c8a0987 --- /dev/null +++ b/tests/baselines/reference/importDeclWithDeclareModifierInAmbientContext.js @@ -0,0 +1,12 @@ +//// [importDeclWithDeclareModifierInAmbientContext.ts] +declare module "m" { + module x { + interface c { + } + } + declare export import a = x.c; + var b: a; +} + + +//// [importDeclWithDeclareModifierInAmbientContext.js] diff --git a/tests/baselines/reference/importDeclarationInModuleDeclaration1.js b/tests/baselines/reference/importDeclarationInModuleDeclaration1.js new file mode 100644 index 00000000000..46a62fd0584 --- /dev/null +++ b/tests/baselines/reference/importDeclarationInModuleDeclaration1.js @@ -0,0 +1,6 @@ +//// [importDeclarationInModuleDeclaration1.ts] +module m2 { + import m3 = require("use_glo_M1_public"); +} + +//// [importDeclarationInModuleDeclaration1.js] diff --git a/tests/baselines/reference/importInsideModule.js b/tests/baselines/reference/importInsideModule.js new file mode 100644 index 00000000000..b0ba16fa850 --- /dev/null +++ b/tests/baselines/reference/importInsideModule.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/importInsideModule.ts] //// + +//// [importInsideModule_file1.ts] +export var x = 1; + +//// [importInsideModule_file2.ts] +export module myModule { + import foo = require("importInsideModule_file1"); + var a = foo.x; +} + +//// [importInsideModule_file2.js] +var myModule; +(function (myModule) { + var foo = require("importInsideModule_file1"); + var a = foo.x; +})(myModule = exports.myModule || (exports.myModule = {})); diff --git a/tests/baselines/reference/importNonStringLiteral.js b/tests/baselines/reference/importNonStringLiteral.js new file mode 100644 index 00000000000..52ef5a10a67 --- /dev/null +++ b/tests/baselines/reference/importNonStringLiteral.js @@ -0,0 +1,7 @@ +//// [importNonStringLiteral.ts] +var x = "filename"; +import foo = require(x); // invalid + + +//// [importNonStringLiteral.js] +var x = "filename"; diff --git a/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.js b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.js new file mode 100644 index 00000000000..f586a19bf0e --- /dev/null +++ b/tests/baselines/reference/indexSignatureMustHaveTypeAnnotation.js @@ -0,0 +1,28 @@ +//// [indexSignatureMustHaveTypeAnnotation.ts] +interface I { + // Used to be indexer, now it is a computed property + [x]: string; + [x: string]; +} + +class C { + // Used to be indexer, now it is a computed property + [x]: string + +} + +class C2 { + [x: string] +} + +//// [indexSignatureMustHaveTypeAnnotation.js] +var C = (function () { + function C() { + } + return C; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); diff --git a/tests/baselines/reference/indexSignatureTypeCheck.js b/tests/baselines/reference/indexSignatureTypeCheck.js new file mode 100644 index 00000000000..02676348bec --- /dev/null +++ b/tests/baselines/reference/indexSignatureTypeCheck.js @@ -0,0 +1,24 @@ +//// [indexSignatureTypeCheck.ts] +interface IPropertySet { + + [index: string]: any; + +} + + +var ps: IPropertySet = null; +var index: any = "hello"; +ps[index] = 12; + + +interface indexErrors { + [p2?: string]; + [...p3: any[]]; + [p4: string, p5?: string]; + [p6: string, ...p7: any[]]; +} + +//// [indexSignatureTypeCheck.js] +var ps = null; +var index = "hello"; +ps[index] = 12; diff --git a/tests/baselines/reference/indexSignatureTypeCheck2.js b/tests/baselines/reference/indexSignatureTypeCheck2.js new file mode 100644 index 00000000000..6dcc0f392a5 --- /dev/null +++ b/tests/baselines/reference/indexSignatureTypeCheck2.js @@ -0,0 +1,25 @@ +//// [indexSignatureTypeCheck2.ts] +class IPropertySet { + [index: string]: any +} + +var ps: IPropertySet = null; +var index: any = "hello"; +ps[index] = 12; + +interface indexErrors { + [p2?: string]; + [...p3: any[]]; + [p4: string, p5?: string]; + [p6: string, ...p7: any[]]; +} + +//// [indexSignatureTypeCheck2.js] +var IPropertySet = (function () { + function IPropertySet() { + } + return IPropertySet; +})(); +var ps = null; +var index = "hello"; +ps[index] = 12; diff --git a/tests/baselines/reference/indexSignatureWithAccessibilityModifier.js b/tests/baselines/reference/indexSignatureWithAccessibilityModifier.js new file mode 100644 index 00000000000..798fef924b9 --- /dev/null +++ b/tests/baselines/reference/indexSignatureWithAccessibilityModifier.js @@ -0,0 +1,15 @@ +//// [indexSignatureWithAccessibilityModifier.ts] +interface I { + [public x: string]: string; +} + +class C { + [public x: string]: string +} + +//// [indexSignatureWithAccessibilityModifier.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/indexSignatureWithInitializer.js b/tests/baselines/reference/indexSignatureWithInitializer.js new file mode 100644 index 00000000000..490033dde0f --- /dev/null +++ b/tests/baselines/reference/indexSignatureWithInitializer.js @@ -0,0 +1,16 @@ +//// [indexSignatureWithInitializer.ts] +// These used to be indexers, now they are computed properties +interface I { + [x = '']: string; +} + +class C { + [x = 0]: string +} + +//// [indexSignatureWithInitializer.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/indexSignatureWithInitializer1.js b/tests/baselines/reference/indexSignatureWithInitializer1.js new file mode 100644 index 00000000000..16852fd4174 --- /dev/null +++ b/tests/baselines/reference/indexSignatureWithInitializer1.js @@ -0,0 +1,11 @@ +//// [indexSignatureWithInitializer1.ts] +class C { + [a: number = 1]: number; +} + +//// [indexSignatureWithInitializer1.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/indexSignatureWithoutTypeAnnotation1.js b/tests/baselines/reference/indexSignatureWithoutTypeAnnotation1.js new file mode 100644 index 00000000000..bef6af37931 --- /dev/null +++ b/tests/baselines/reference/indexSignatureWithoutTypeAnnotation1.js @@ -0,0 +1,11 @@ +//// [indexSignatureWithoutTypeAnnotation1.ts] +class C { + [a: number]; +} + +//// [indexSignatureWithoutTypeAnnotation1.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/indexTypeCheck.js b/tests/baselines/reference/indexTypeCheck.js new file mode 100644 index 00000000000..6e74111a357 --- /dev/null +++ b/tests/baselines/reference/indexTypeCheck.js @@ -0,0 +1,87 @@ +//// [indexTypeCheck.ts] +interface Red { + [n:number]; // ok + [s:string]; // ok +} + +interface Blue { + [n:number]: any; // ok + [s:string]: any; // ok +} + +interface Yellow { + [n:number]: Red; // ok + [s:string]: Red; // ok +} + +interface Orange { + [n:number]: number; // ok + [s:string]: string; // error +} + +interface Green { + [n:number]: Orange; // error + [s:string]: Yellow; // ok +} + +interface Cyan { + [n:number]: number; // error + [s:string]: string; // ok +} + +interface Purple { + [n:number, s:string]; // error +} + +interface Magenta { + [p:Purple]; // error +} + +var yellow: Yellow; +var blue: Blue; +var s = "some string"; + +yellow[5]; // ok +yellow["hue"]; // ok +yellow[{}]; // ok + +s[0]; // error +s["s"]; // ok +s[{}]; // ok + +yellow[blue]; // error + +var x:number[]; +x[0]; + +class Benchmark { + + public results: { [x:string]: any; } = <{ [x:string]: any; }>{}; + + public addTimingFor(name: string, timing: number) { + this.results[name] = this.results[name]; + } +} + +//// [indexTypeCheck.js] +var yellow; +var blue; +var s = "some string"; +yellow[5]; // ok +yellow["hue"]; // ok +yellow[{}]; // ok +s[0]; // error +s["s"]; // ok +s[{}]; // ok +yellow[blue]; // error +var x; +x[0]; +var Benchmark = (function () { + function Benchmark() { + this.results = {}; + } + Benchmark.prototype.addTimingFor = function (name, timing) { + this.results[name] = this.results[name]; + }; + return Benchmark; +})(); diff --git a/tests/baselines/reference/indexWithoutParamType.js b/tests/baselines/reference/indexWithoutParamType.js new file mode 100644 index 00000000000..0ea3e8f897f --- /dev/null +++ b/tests/baselines/reference/indexWithoutParamType.js @@ -0,0 +1,5 @@ +//// [indexWithoutParamType.ts] +var y: { []; } // Error + +//// [indexWithoutParamType.js] +var y; // Error diff --git a/tests/baselines/reference/indexWithoutParamType2.js b/tests/baselines/reference/indexWithoutParamType2.js new file mode 100644 index 00000000000..4197b0596ec --- /dev/null +++ b/tests/baselines/reference/indexWithoutParamType2.js @@ -0,0 +1,12 @@ +//// [indexWithoutParamType2.ts] +class C { + // Used to be indexer, now it is a computed property + [x]: string +} + +//// [indexWithoutParamType2.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/indexerAsOptional.js b/tests/baselines/reference/indexerAsOptional.js new file mode 100644 index 00000000000..509e3890ec8 --- /dev/null +++ b/tests/baselines/reference/indexerAsOptional.js @@ -0,0 +1,17 @@ +//// [indexerAsOptional.ts] +interface indexSig { + //Index signatures can't be optional + [idx?: number]: any; //err +} + +class indexSig2 { + //Index signatures can't be optional + [idx?: number]: any //err +} + +//// [indexerAsOptional.js] +var indexSig2 = (function () { + function indexSig2() { + } + return indexSig2; +})(); diff --git a/tests/baselines/reference/indexerSignatureWithRestParam.js b/tests/baselines/reference/indexerSignatureWithRestParam.js new file mode 100644 index 00000000000..8a7defb049c --- /dev/null +++ b/tests/baselines/reference/indexerSignatureWithRestParam.js @@ -0,0 +1,15 @@ +//// [indexerSignatureWithRestParam.ts] +interface I { + [...x]: string; +} + +class C { + [...x]: string +} + +//// [indexerSignatureWithRestParam.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/inferSetterParamType.js b/tests/baselines/reference/inferSetterParamType.js new file mode 100644 index 00000000000..c0be3a5c394 --- /dev/null +++ b/tests/baselines/reference/inferSetterParamType.js @@ -0,0 +1,49 @@ +//// [inferSetterParamType.ts] +class Foo { + + get bar() { + return 0; + } + set bar(n) { // should not be an error - infer number + } +} + +class Foo2 { + + get bar() { + return 0; // should be an error - can't coerce infered return type to match setter annotated type + } + set bar(n:string) { + } +} + + +//// [inferSetterParamType.js] +var Foo = (function () { + function Foo() { + } + Object.defineProperty(Foo.prototype, "bar", { + get: function () { + return 0; + }, + set: function (n) { + }, + enumerable: true, + configurable: true + }); + return Foo; +})(); +var Foo2 = (function () { + function Foo2() { + } + Object.defineProperty(Foo2.prototype, "bar", { + get: function () { + return 0; // should be an error - can't coerce infered return type to match setter annotated type + }, + set: function (n) { + }, + enumerable: true, + configurable: true + }); + return Foo2; +})(); diff --git a/tests/baselines/reference/infinitelyExpandingOverloads.js b/tests/baselines/reference/infinitelyExpandingOverloads.js new file mode 100644 index 00000000000..1e84eba27cf --- /dev/null +++ b/tests/baselines/reference/infinitelyExpandingOverloads.js @@ -0,0 +1,52 @@ +//// [infinitelyExpandingOverloads.ts] +interface KnockoutSubscription2 { + target: KnockoutObservableBase2; +} +interface KnockoutObservableBase2 { + subscribe(callback: (newValue: T) => void, target?: any, topic?: string): KnockoutSubscription2; +} +interface ValidationPlacement2 { + initialize(validatable: Validatable2): void; +} +interface Validatable2 { + validators: KnockoutObservableBase2>; +} +class Validator2 { + private _subscription: KnockoutSubscription2; +} +class ViewModel { + public validationPlacements: Array> = new Array>(); +} +class Widget { + constructor(viewModelType: new () => ViewModel); // Shouldnt error on this overload + constructor(viewModelType: new () => ViewModel) { + } + public get options(): ViewModel { + return null; + } +} + +//// [infinitelyExpandingOverloads.js] +var Validator2 = (function () { + function Validator2() { + } + return Validator2; +})(); +var ViewModel = (function () { + function ViewModel() { + this.validationPlacements = new Array(); + } + return ViewModel; +})(); +var Widget = (function () { + function Widget(viewModelType) { + } + Object.defineProperty(Widget.prototype, "options", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + return Widget; +})(); diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js new file mode 100644 index 00000000000..d1eb53c4ec7 --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingAccessor.js @@ -0,0 +1,56 @@ +//// [inheritanceMemberAccessorOverridingAccessor.ts] +class a { + get x() { + return "20"; + } + set x(aValue: string) { + + } +} + +class b extends a { + get x() { + return "20"; + } + set x(aValue: string) { + + } +} + +//// [inheritanceMemberAccessorOverridingAccessor.js] +var __extends = 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 a = (function () { + function a() { + } + Object.defineProperty(a.prototype, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + Object.defineProperty(b.prototype, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js new file mode 100644 index 00000000000..d234eb89582 --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingMethod.js @@ -0,0 +1,47 @@ +//// [inheritanceMemberAccessorOverridingMethod.ts] +class a { + x() { + return "20"; + } +} + +class b extends a { + get x() { + return "20"; + } + set x(aValue: string) { + + } +} + +//// [inheritanceMemberAccessorOverridingMethod.js] +var __extends = 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 a = (function () { + function a() { + } + a.prototype.x = function () { + return "20"; + }; + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + Object.defineProperty(b.prototype, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js new file mode 100644 index 00000000000..b307f3bfedb --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberAccessorOverridingProperty.js @@ -0,0 +1,42 @@ +//// [inheritanceMemberAccessorOverridingProperty.ts] +class a { + x: string; +} + +class b extends a { + get x() { + return "20"; + } + set x(aValue: string) { + + } +} + +//// [inheritanceMemberAccessorOverridingProperty.js] +var __extends = 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 a = (function () { + function a() { + } + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + Object.defineProperty(b.prototype, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js new file mode 100644 index 00000000000..e05ed9633cc --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingAccessor.js @@ -0,0 +1,47 @@ +//// [inheritanceMemberFuncOverridingAccessor.ts] +class a { + get x() { + return "20"; + } + set x(aValue: string) { + + } +} + +class b extends a { + x() { + return "20"; + } +} + +//// [inheritanceMemberFuncOverridingAccessor.js] +var __extends = 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 a = (function () { + function a() { + } + Object.defineProperty(a.prototype, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + b.prototype.x = function () { + return "20"; + }; + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js new file mode 100644 index 00000000000..7d92b494416 --- /dev/null +++ b/tests/baselines/reference/inheritanceMemberPropertyOverridingAccessor.js @@ -0,0 +1,44 @@ +//// [inheritanceMemberPropertyOverridingAccessor.ts] +class a { + private __x: () => string; + get x() { + return this.__x; + } + set x(aValue: () => string) { + this.__x = aValue; + } +} + +class b extends a { + x: () => string; +} + +//// [inheritanceMemberPropertyOverridingAccessor.js] +var __extends = 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 a = (function () { + function a() { + } + Object.defineProperty(a.prototype, "x", { + get: function () { + return this.__x; + }, + set: function (aValue) { + this.__x = aValue; + }, + enumerable: true, + configurable: true + }); + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js new file mode 100644 index 00000000000..f7ed912d030 --- /dev/null +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingAccessor.js @@ -0,0 +1,56 @@ +//// [inheritanceStaticAccessorOverridingAccessor.ts] +class a { + static get x() { + return "20"; + } + static set x(aValue: string) { + + } +} + +class b extends a { + static get x() { + return "20"; + } + static set x(aValue: string) { + + } +} + +//// [inheritanceStaticAccessorOverridingAccessor.js] +var __extends = 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 a = (function () { + function a() { + } + Object.defineProperty(a, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + Object.defineProperty(b, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js new file mode 100644 index 00000000000..dbef001740e --- /dev/null +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingMethod.js @@ -0,0 +1,47 @@ +//// [inheritanceStaticAccessorOverridingMethod.ts] +class a { + static x() { + return "20"; + } +} + +class b extends a { + static get x() { + return "20"; + } + static set x(aValue: string) { + + } +} + +//// [inheritanceStaticAccessorOverridingMethod.js] +var __extends = 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 a = (function () { + function a() { + } + a.x = function () { + return "20"; + }; + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + Object.defineProperty(b, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js new file mode 100644 index 00000000000..3536ca8accb --- /dev/null +++ b/tests/baselines/reference/inheritanceStaticAccessorOverridingProperty.js @@ -0,0 +1,42 @@ +//// [inheritanceStaticAccessorOverridingProperty.ts] +class a { + static x: string; +} + +class b extends a { + static get x() { + return "20"; + } + static set x(aValue: string) { + + } +} + +//// [inheritanceStaticAccessorOverridingProperty.js] +var __extends = 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 a = (function () { + function a() { + } + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + Object.defineProperty(b, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js new file mode 100644 index 00000000000..b3cc7d3461e --- /dev/null +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessor.js @@ -0,0 +1,47 @@ +//// [inheritanceStaticFuncOverridingAccessor.ts] +class a { + static get x() { + return "20"; + } + static set x(aValue: string) { + + } +} + +class b extends a { + static x() { + return "20"; + } +} + +//// [inheritanceStaticFuncOverridingAccessor.js] +var __extends = 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 a = (function () { + function a() { + } + Object.defineProperty(a, "x", { + get: function () { + return "20"; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + b.x = function () { + return "20"; + }; + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js new file mode 100644 index 00000000000..bb77561153e --- /dev/null +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingAccessorOfFuncType.js @@ -0,0 +1,42 @@ +//// [inheritanceStaticFuncOverridingAccessorOfFuncType.ts] +class a { + static get x(): () => string { + return null; + } +} + +class b extends a { + static x() { + return "20"; + } +} + +//// [inheritanceStaticFuncOverridingAccessorOfFuncType.js] +var __extends = 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 a = (function () { + function a() { + } + Object.defineProperty(a, "x", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + b.x = function () { + return "20"; + }; + return b; +})(a); diff --git a/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js new file mode 100644 index 00000000000..da3a42eafe1 --- /dev/null +++ b/tests/baselines/reference/inheritanceStaticPropertyOverridingAccessor.js @@ -0,0 +1,42 @@ +//// [inheritanceStaticPropertyOverridingAccessor.ts] +class a { + static get x(): () => string { + return null;; + } + static set x(aValue: () => string) { + } +} + +class b extends a { + static x: () => string; +} + +//// [inheritanceStaticPropertyOverridingAccessor.js] +var __extends = 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 a = (function () { + function a() { + } + Object.defineProperty(a, "x", { + get: function () { + return null; + ; + }, + set: function (aValue) { + }, + enumerable: true, + configurable: true + }); + return a; +})(); +var b = (function (_super) { + __extends(b, _super); + function b() { + _super.apply(this, arguments); + } + return b; +})(a); diff --git a/tests/baselines/reference/initializersInDeclarations.js b/tests/baselines/reference/initializersInDeclarations.js new file mode 100644 index 00000000000..0506c72fc56 --- /dev/null +++ b/tests/baselines/reference/initializersInDeclarations.js @@ -0,0 +1,23 @@ +//// [initializersInDeclarations.ts] + +// Errors: Initializers & statements in declaration file + +declare class Foo { + name = "test"; + "some prop" = 42; + fn(): boolean { + return false; + } +} + +declare var x = []; +declare var y = {}; + +declare module M1 { + while(true); + + export var v1 = () => false; +} + +//// [initializersInDeclarations.js] +// Errors: Initializers & statements in declaration file diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js new file mode 100644 index 00000000000..eca12f7b1ae --- /dev/null +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.js @@ -0,0 +1,121 @@ +//// [instancePropertiesInheritedIntoClassType.ts] +module NonGeneric { + class C { + x: string; + get y() { + return 1; + } + set y(v) { } + fn() { return this; } + constructor(public a: number, private b: number) { } + } + + class D extends C { e: string; } + + var d = new D(1, 2); + var r = d.fn(); + var r2 = r.x; + var r3 = r.y; + r.y = 4; + var r6 = d.y(); // error + +} + +module Generic { + class C { + x: T; + get y() { + return null; + } + set y(v: U) { } + fn() { return this; } + constructor(public a: T, private b: U) { } + } + + class D extends C { e: T; } + + var d = new D(1, ''); + var r = d.fn(); + var r2 = r.x; + var r3 = r.y; + r.y = ''; + var r6 = d.y(); // error +} + +//// [instancePropertiesInheritedIntoClassType.js] +var __extends = 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 NonGeneric; +(function (NonGeneric) { + var C = (function () { + function C(a, b) { + this.a = a; + this.b = b; + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + C.prototype.fn = function () { + return this; + }; + return C; + })(); + var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; + })(C); + var d = new D(1, 2); + var r = d.fn(); + var r2 = r.x; + var r3 = r.y; + r.y = 4; + var r6 = d.y(); // error +})(NonGeneric || (NonGeneric = {})); +var Generic; +(function (Generic) { + var C = (function () { + function C(a, b) { + this.a = a; + this.b = b; + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return null; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + C.prototype.fn = function () { + return this; + }; + return C; + })(); + var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; + })(C); + var d = new D(1, ''); + var r = d.fn(); + var r2 = r.x; + var r3 = r.y; + r.y = ''; + var r6 = d.y(); // error +})(Generic || (Generic = {})); diff --git a/tests/baselines/reference/instancePropertyInClassType.js b/tests/baselines/reference/instancePropertyInClassType.js new file mode 100644 index 00000000000..b2df44db6f0 --- /dev/null +++ b/tests/baselines/reference/instancePropertyInClassType.js @@ -0,0 +1,97 @@ +//// [instancePropertyInClassType.ts] +module NonGeneric { + class C { + x: string; + get y() { + return 1; + } + set y(v) { } + fn() { return this; } + constructor(public a: number, private b: number) { } + } + + var c = new C(1, 2); + var r = c.fn(); + var r2 = r.x; + var r3 = r.y; + r.y = 4; + var r6 = c.y(); // error + +} + +module Generic { + class C { + x: T; + get y() { + return null; + } + set y(v: U) { } + fn() { return this; } + constructor(public a: T, private b: U) { } + } + + var c = new C(1, ''); + var r = c.fn(); + var r2 = r.x; + var r3 = r.y; + r.y = ''; + var r6 = c.y(); // error +} + +//// [instancePropertyInClassType.js] +var NonGeneric; +(function (NonGeneric) { + var C = (function () { + function C(a, b) { + this.a = a; + this.b = b; + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + C.prototype.fn = function () { + return this; + }; + return C; + })(); + var c = new C(1, 2); + var r = c.fn(); + var r2 = r.x; + var r3 = r.y; + r.y = 4; + var r6 = c.y(); // error +})(NonGeneric || (NonGeneric = {})); +var Generic; +(function (Generic) { + var C = (function () { + function C(a, b) { + this.a = a; + this.b = b; + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return null; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + C.prototype.fn = function () { + return this; + }; + return C; + })(); + var c = new C(1, ''); + var r = c.fn(); + var r2 = r.x; + var r3 = r.y; + r.y = ''; + var r6 = c.y(); // error +})(Generic || (Generic = {})); diff --git a/tests/baselines/reference/interfaceExtendingClass.js b/tests/baselines/reference/interfaceExtendingClass.js new file mode 100644 index 00000000000..39db7460915 --- /dev/null +++ b/tests/baselines/reference/interfaceExtendingClass.js @@ -0,0 +1,42 @@ +//// [interfaceExtendingClass.ts] +class Foo { + x: string; + y() { } + get Z() { + return 1; + } + [x: string]: Object; +} + +interface I extends Foo { +} + +var i: I; +var r1 = i.x; +var r2 = i.y(); +var r3 = i.Z; + +var f: Foo = i; +i = f; + +//// [interfaceExtendingClass.js] +var Foo = (function () { + function Foo() { + } + Foo.prototype.y = function () { + }; + Object.defineProperty(Foo.prototype, "Z", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return Foo; +})(); +var i; +var r1 = i.x; +var r2 = i.y(); +var r3 = i.Z; +var f = i; +i = f; diff --git a/tests/baselines/reference/interfaceImplementation5.js b/tests/baselines/reference/interfaceImplementation5.js new file mode 100644 index 00000000000..667c5f045ec --- /dev/null +++ b/tests/baselines/reference/interfaceImplementation5.js @@ -0,0 +1,110 @@ +//// [interfaceImplementation5.ts] +interface I1 { + getset1:number; +} + +class C1 implements I1 { + public get getset1(){return 1;} +} + +class C2 implements I1 { + public set getset1(baz:number){} +} + +class C3 implements I1 { + public get getset1(){return 1;} + public set getset1(baz:number){} +} + +class C4 implements I1 { + public get getset1(){var x:any; return x;} +} + +class C5 implements I1 { + public set getset1(baz:any){} +} + +class C6 implements I1 { + public set getset1(baz:any){} + public get getset1(){var x:any; return x;} +} + + + +//// [interfaceImplementation5.js] +var C1 = (function () { + function C1() { + } + Object.defineProperty(C1.prototype, "getset1", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C1; +})(); +var C2 = (function () { + function C2() { + } + Object.defineProperty(C2.prototype, "getset1", { + set: function (baz) { + }, + enumerable: true, + configurable: true + }); + return C2; +})(); +var C3 = (function () { + function C3() { + } + Object.defineProperty(C3.prototype, "getset1", { + get: function () { + return 1; + }, + set: function (baz) { + }, + enumerable: true, + configurable: true + }); + return C3; +})(); +var C4 = (function () { + function C4() { + } + Object.defineProperty(C4.prototype, "getset1", { + get: function () { + var x; + return x; + }, + enumerable: true, + configurable: true + }); + return C4; +})(); +var C5 = (function () { + function C5() { + } + Object.defineProperty(C5.prototype, "getset1", { + set: function (baz) { + }, + enumerable: true, + configurable: true + }); + return C5; +})(); +var C6 = (function () { + function C6() { + } + Object.defineProperty(C6.prototype, "getset1", { + get: function () { + var x; + return x; + }, + set: function (baz) { + }, + enumerable: true, + configurable: true + }); + return C6; +})(); diff --git a/tests/baselines/reference/interfaceThatInheritsFromItself.js b/tests/baselines/reference/interfaceThatInheritsFromItself.js new file mode 100644 index 00000000000..59794dc40c7 --- /dev/null +++ b/tests/baselines/reference/interfaceThatInheritsFromItself.js @@ -0,0 +1,16 @@ +//// [interfaceThatInheritsFromItself.ts] +interface Foo extends Foo { // error +} + +interface Foo2 extends Foo2 { // error +} + +interface Foo3 extends Foo3 { // error +} + +interface Bar implements Bar { // error +} + + + +//// [interfaceThatInheritsFromItself.js] diff --git a/tests/baselines/reference/interfaceWithImplements1.js b/tests/baselines/reference/interfaceWithImplements1.js new file mode 100644 index 00000000000..bc8ccba8192 --- /dev/null +++ b/tests/baselines/reference/interfaceWithImplements1.js @@ -0,0 +1,7 @@ +//// [interfaceWithImplements1.ts] +interface IFoo { } + +interface IBar implements IFoo { +} + +//// [interfaceWithImplements1.js] diff --git a/tests/baselines/reference/invalidDoWhileBreakStatements.js b/tests/baselines/reference/invalidDoWhileBreakStatements.js new file mode 100644 index 00000000000..e6617ef98cd --- /dev/null +++ b/tests/baselines/reference/invalidDoWhileBreakStatements.js @@ -0,0 +1,70 @@ +//// [invalidDoWhileBreakStatements.ts] +// All errors + +// naked break not allowed +break; + +// non-existent label +ONE: +do break TWO; while (true) + +// break from inside function +TWO: +do { + var x = () => { + break TWO; + } +}while (true) + +THREE: +do { + var fn = function () { + break THREE; + } +}while (true) + +// break forward +do { + break FIVE; + FIVE: + do { } while (true) +}while (true) + +// label on non-loop statement +NINE: +var y = 12; + +do { + break NINE; +}while (true) + +//// [invalidDoWhileBreakStatements.js] +// All errors +// naked break not allowed +break; +// non-existent label +ONE: do + break TWO; +while (true); +// break from inside function +TWO: do { + var x = function () { + break TWO; + }; +} while (true); +THREE: do { + var fn = function () { + break THREE; + }; +} while (true); +// break forward +do { + break FIVE; + FIVE: do { + } while (true); +} while (true); +// label on non-loop statement +NINE: var y = 12; +do { + break NINE; +} while (true); diff --git a/tests/baselines/reference/invalidDoWhileContinueStatements.js b/tests/baselines/reference/invalidDoWhileContinueStatements.js new file mode 100644 index 00000000000..d32ccfe0074 --- /dev/null +++ b/tests/baselines/reference/invalidDoWhileContinueStatements.js @@ -0,0 +1,70 @@ +//// [invalidDoWhileContinueStatements.ts] +// All errors + +// naked continue not allowed +continue; + +// non-existent label +ONE: +do continue TWO; while (true) + +// continue from inside function +TWO: +do { + var x = () => { + continue TWO; + } +}while (true) + +THREE: +do { + var fn = function () { + continue THREE; + } +}while (true) + +// continue forward +do { + continue FIVE; + FIVE: + do { } while (true) +}while (true) + +// label on non-loop statement +NINE: +var y = 12; + +do { + continue NINE; +}while (true) + +//// [invalidDoWhileContinueStatements.js] +// All errors +// naked continue not allowed +continue; +// non-existent label +ONE: do + continue TWO; +while (true); +// continue from inside function +TWO: do { + var x = function () { + continue TWO; + }; +} while (true); +THREE: do { + var fn = function () { + continue THREE; + }; +} while (true); +// continue forward +do { + continue FIVE; + FIVE: do { + } while (true); +} while (true); +// label on non-loop statement +NINE: var y = 12; +do { + continue NINE; +} while (true); diff --git a/tests/baselines/reference/invalidForBreakStatements.js b/tests/baselines/reference/invalidForBreakStatements.js new file mode 100644 index 00000000000..abcd078ff2d --- /dev/null +++ b/tests/baselines/reference/invalidForBreakStatements.js @@ -0,0 +1,68 @@ +//// [invalidForBreakStatements.ts] +// All errors + +// naked break not allowed +break; + +// non-existent label +ONE: +for(;;) break TWO; + +// break from inside function +TWO: +for(;;) { + var x = () => { + break TWO; + } +} + +THREE: +for(;;) { + var fn = function () { + break THREE; + } +} + +// break forward +for(;;) { + break FIVE; + FIVE: + for (; ;) { } +} +// label on non-loop statement +NINE: +var y = 12; + +for(;;) { + break NINE; +} + +//// [invalidForBreakStatements.js] +// All errors +// naked break not allowed +break; +// non-existent label +ONE: for (;;) + break TWO; +// break from inside function +TWO: for (;;) { + var x = function () { + break TWO; + }; +} +THREE: for (;;) { + var fn = function () { + break THREE; + }; +} +// break forward +for (;;) { + break FIVE; + FIVE: for (;;) { + } +} +// label on non-loop statement +NINE: var y = 12; +for (;;) { + break NINE; +} diff --git a/tests/baselines/reference/invalidForContinueStatements.js b/tests/baselines/reference/invalidForContinueStatements.js new file mode 100644 index 00000000000..af0eba2a59a --- /dev/null +++ b/tests/baselines/reference/invalidForContinueStatements.js @@ -0,0 +1,68 @@ +//// [invalidForContinueStatements.ts] +// All errors + +// naked continue not allowed +continue; + +// non-existent label +ONE: +for(;;) continue TWO; + +// continue from inside function +TWO: +for(;;) { + var x = () => { + continue TWO; + } +} + +THREE: +for(;;) { + var fn = function () { + continue THREE; + } +} + +// continue forward +for(;;) { + continue FIVE; + FIVE: + for (; ;) { } +} +// label on non-loop statement +NINE: +var y = 12; + +for(;;) { + continue NINE; +} + +//// [invalidForContinueStatements.js] +// All errors +// naked continue not allowed +continue; +// non-existent label +ONE: for (;;) + continue TWO; +// continue from inside function +TWO: for (;;) { + var x = function () { + continue TWO; + }; +} +THREE: for (;;) { + var fn = function () { + continue THREE; + }; +} +// continue forward +for (;;) { + continue FIVE; + FIVE: for (;;) { + } +} +// label on non-loop statement +NINE: var y = 12; +for (;;) { + continue NINE; +} diff --git a/tests/baselines/reference/invalidForInBreakStatements.js b/tests/baselines/reference/invalidForInBreakStatements.js new file mode 100644 index 00000000000..bf383613c3b --- /dev/null +++ b/tests/baselines/reference/invalidForInBreakStatements.js @@ -0,0 +1,69 @@ +//// [invalidForInBreakStatements.ts] +// All errors + +// naked break not allowed +break; + +// non-existent label +ONE: +for (var x in {}) break TWO; + +// break from inside function +TWO: +for (var x in {}) { + var fn = () => { + break TWO; + } +} + +THREE: +for (var x in {}) { + var fn = function () { + break THREE; + } +} + +// break forward +for (var x in {}) { + break FIVE; + FIVE: + for (var x in {}) { } +} + +// label on non-loop statement +NINE: +var y = 12; + +for (var x in {}) { + break NINE; +} + +//// [invalidForInBreakStatements.js] +// All errors +// naked break not allowed +break; +// non-existent label +ONE: for (var x in {}) + break TWO; +// break from inside function +TWO: for (var x in {}) { + var fn = function () { + break TWO; + }; +} +THREE: for (var x in {}) { + var fn = function () { + break THREE; + }; +} +// break forward +for (var x in {}) { + break FIVE; + FIVE: for (var x in {}) { + } +} +// label on non-loop statement +NINE: var y = 12; +for (var x in {}) { + break NINE; +} diff --git a/tests/baselines/reference/invalidForInContinueStatements.js b/tests/baselines/reference/invalidForInContinueStatements.js new file mode 100644 index 00000000000..d40dbd80ca0 --- /dev/null +++ b/tests/baselines/reference/invalidForInContinueStatements.js @@ -0,0 +1,69 @@ +//// [invalidForInContinueStatements.ts] +// All errors + +// naked continue not allowed +continue; + +// non-existent label +ONE: +for (var x in {}) continue TWO; + +// continue from inside function +TWO: +for (var x in {}) { + var fn = () => { + continue TWO; + } +} + +THREE: +for (var x in {}) { + var fn = function () { + continue THREE; + } +} + +// continue forward +for (var x in {}) { + continue FIVE; + FIVE: + for (var x in {}) { } +} + +// label on non-loop statement +NINE: +var y = 12; + +for (var x in {}) { + continue NINE; +} + +//// [invalidForInContinueStatements.js] +// All errors +// naked continue not allowed +continue; +// non-existent label +ONE: for (var x in {}) + continue TWO; +// continue from inside function +TWO: for (var x in {}) { + var fn = function () { + continue TWO; + }; +} +THREE: for (var x in {}) { + var fn = function () { + continue THREE; + }; +} +// continue forward +for (var x in {}) { + continue FIVE; + FIVE: for (var x in {}) { + } +} +// label on non-loop statement +NINE: var y = 12; +for (var x in {}) { + continue NINE; +} diff --git a/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js new file mode 100644 index 00000000000..077d7ddbcdc --- /dev/null +++ b/tests/baselines/reference/invalidModuleWithStatementsOfEveryKind.js @@ -0,0 +1,235 @@ +//// [invalidModuleWithStatementsOfEveryKind.ts] +// All of these should be an error + +module Y { + public class A { s: string } + + public class BB extends A { + id: number; + } +} + +module Y2 { + public class AA { s: T } + public interface I { id: number } + + public class B extends AA implements I { id: number } +} + +module Y3 { + public module Module { + class A { s: string } + } +} + +module Y4 { + public enum Color { Blue, Red } +} + +module YY { + private class A { s: string } + + private class BB extends A { + id: number; + } +} + +module YY2 { + private class AA { s: T } + private interface I { id: number } + + private class B extends AA implements I { id: number } +} + +module YY3 { + private module Module { + class A { s: string } + } +} + +module YY4 { + private enum Color { Blue, Red } +} + + +module YYY { + static class A { s: string } + + static class BB extends A { + id: number; + } +} + +module YYY2 { + static class AA { s: T } + static interface I { id: number } + + static class B extends AA implements I { id: number } +} + +module YYY3 { + static module Module { + class A { s: string } + } +} + +module YYY4 { + static enum Color { Blue, Red } +} + + +//// [invalidModuleWithStatementsOfEveryKind.js] +// All of these should be an error +var __extends = 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 Y; +(function (Y) { + var A = (function () { + function A() { + } + return A; + })(); + var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; + })(A); +})(Y || (Y = {})); +var Y2; +(function (Y2) { + var AA = (function () { + function AA() { + } + return AA; + })(); + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(AA); +})(Y2 || (Y2 = {})); +var Y3; +(function (Y3) { + var Module; + (function (Module) { + var A = (function () { + function A() { + } + return A; + })(); + })(Module || (Module = {})); +})(Y3 || (Y3 = {})); +var Y4; +(function (Y4) { + var Color; + (function (Color) { + Color[Color["Blue"] = 0] = "Blue"; + Color[Color["Red"] = 1] = "Red"; + })(Color || (Color = {})); +})(Y4 || (Y4 = {})); +var YY; +(function (YY) { + var A = (function () { + function A() { + } + return A; + })(); + var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; + })(A); +})(YY || (YY = {})); +var YY2; +(function (YY2) { + var AA = (function () { + function AA() { + } + return AA; + })(); + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(AA); +})(YY2 || (YY2 = {})); +var YY3; +(function (YY3) { + var Module; + (function (Module) { + var A = (function () { + function A() { + } + return A; + })(); + })(Module || (Module = {})); +})(YY3 || (YY3 = {})); +var YY4; +(function (YY4) { + var Color; + (function (Color) { + Color[Color["Blue"] = 0] = "Blue"; + Color[Color["Red"] = 1] = "Red"; + })(Color || (Color = {})); +})(YY4 || (YY4 = {})); +var YYY; +(function (YYY) { + var A = (function () { + function A() { + } + return A; + })(); + var BB = (function (_super) { + __extends(BB, _super); + function BB() { + _super.apply(this, arguments); + } + return BB; + })(A); +})(YYY || (YYY = {})); +var YYY2; +(function (YYY2) { + var AA = (function () { + function AA() { + } + return AA; + })(); + var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; + })(AA); +})(YYY2 || (YYY2 = {})); +var YYY3; +(function (YYY3) { + var Module; + (function (Module) { + var A = (function () { + function A() { + } + return A; + })(); + })(Module || (Module = {})); +})(YYY3 || (YYY3 = {})); +var YYY4; +(function (YYY4) { + var Color; + (function (Color) { + Color[Color["Blue"] = 0] = "Blue"; + Color[Color["Red"] = 1] = "Red"; + })(Color || (Color = {})); +})(YYY4 || (YYY4 = {})); diff --git a/tests/baselines/reference/invalidModuleWithVarStatements.js b/tests/baselines/reference/invalidModuleWithVarStatements.js new file mode 100644 index 00000000000..4014709d361 --- /dev/null +++ b/tests/baselines/reference/invalidModuleWithVarStatements.js @@ -0,0 +1,58 @@ +//// [invalidModuleWithVarStatements.ts] +// All of these should be an error + +module Y { + public var x: number = 0; +} + +module Y2 { + public function fn(x: string) { } +} + +module Y4 { + static var x: number = 0; +} + +module YY { + static function fn(x: string) { } +} + +module YY2 { + private var x: number = 0; +} + + +module YY3 { + private function fn(x: string) { } +} + + +//// [invalidModuleWithVarStatements.js] +// All of these should be an error +var Y; +(function (Y) { + var x = 0; +})(Y || (Y = {})); +var Y2; +(function (Y2) { + function fn(x) { + } +})(Y2 || (Y2 = {})); +var Y4; +(function (Y4) { + var x = 0; +})(Y4 || (Y4 = {})); +var YY; +(function (YY) { + function fn(x) { + } +})(YY || (YY = {})); +var YY2; +(function (YY2) { + var x = 0; +})(YY2 || (YY2 = {})); +var YY3; +(function (YY3) { + function fn(x) { + } +})(YY3 || (YY3 = {})); diff --git a/tests/baselines/reference/invalidSwitchContinueStatement.js b/tests/baselines/reference/invalidSwitchContinueStatement.js new file mode 100644 index 00000000000..759056ce3e5 --- /dev/null +++ b/tests/baselines/reference/invalidSwitchContinueStatement.js @@ -0,0 +1,15 @@ +//// [invalidSwitchContinueStatement.ts] +// continue is not allowed in a switch statement + +switch (12) { + case 5: + continue; +} + + +//// [invalidSwitchContinueStatement.js] +// continue is not allowed in a switch statement +switch (12) { + case 5: + continue; +} diff --git a/tests/baselines/reference/invalidTryStatements.js b/tests/baselines/reference/invalidTryStatements.js new file mode 100644 index 00000000000..8afadf41b4d --- /dev/null +++ b/tests/baselines/reference/invalidTryStatements.js @@ -0,0 +1,36 @@ +//// [invalidTryStatements.ts] +function fn() { + try { + } catch (x) { + var x: string; // ensure x is 'Any' + } + + // no type annotation allowed + try { } catch (z: any) { } + try { } catch (a: number) { } + try { } catch (y: string) { } +} + + + +//// [invalidTryStatements.js] +function fn() { + try { + } + catch (x) { + var x; // ensure x is 'Any' + } + // no type annotation allowed + try { + } + catch (z) { + } + try { + } + catch (a) { + } + try { + } + catch (y) { + } +} diff --git a/tests/baselines/reference/invalidWhileBreakStatements.js b/tests/baselines/reference/invalidWhileBreakStatements.js new file mode 100644 index 00000000000..a8e261f036c --- /dev/null +++ b/tests/baselines/reference/invalidWhileBreakStatements.js @@ -0,0 +1,69 @@ +//// [invalidWhileBreakStatements.ts] +// All errors + +// naked break not allowed +break; + +// non-existent label +ONE: +while (true) break TWO; + +// break from inside function +TWO: +while (true){ + var x = () => { + break TWO; + } +} + +THREE: +while (true) { + var fn = function () { + break THREE; + } +} + +// break forward +while (true) { + break FIVE; + FIVE: + while (true) { } +} + +// label on non-loop statement +NINE: +var y = 12; + +while (true) { + break NINE; +} + +//// [invalidWhileBreakStatements.js] +// All errors +// naked break not allowed +break; +// non-existent label +ONE: while (true) + break TWO; +// break from inside function +TWO: while (true) { + var x = function () { + break TWO; + }; +} +THREE: while (true) { + var fn = function () { + break THREE; + }; +} +// break forward +while (true) { + break FIVE; + FIVE: while (true) { + } +} +// label on non-loop statement +NINE: var y = 12; +while (true) { + break NINE; +} diff --git a/tests/baselines/reference/invalidWhileContinueStatements.js b/tests/baselines/reference/invalidWhileContinueStatements.js new file mode 100644 index 00000000000..544314bf68d --- /dev/null +++ b/tests/baselines/reference/invalidWhileContinueStatements.js @@ -0,0 +1,69 @@ +//// [invalidWhileContinueStatements.ts] +// All errors + +// naked continue not allowed +continue; + +// non-existent label +ONE: +while (true) continue TWO; + +// continue from inside function +TWO: +while (true){ + var x = () => { + continue TWO; + } +} + +THREE: +while (true) { + var fn = function () { + continue THREE; + } +} + +// continue forward +while (true) { + continue FIVE; + FIVE: + while (true) { } +} + +// label on non-loop statement +NINE: +var y = 12; + +while (true) { + continue NINE; +} + +//// [invalidWhileContinueStatements.js] +// All errors +// naked continue not allowed +continue; +// non-existent label +ONE: while (true) + continue TWO; +// continue from inside function +TWO: while (true) { + var x = function () { + continue TWO; + }; +} +THREE: while (true) { + var fn = function () { + continue THREE; + }; +} +// continue forward +while (true) { + continue FIVE; + FIVE: while (true) { + } +} +// label on non-loop statement +NINE: var y = 12; +while (true) { + continue NINE; +} diff --git a/tests/baselines/reference/letDeclarations-es5-1.js b/tests/baselines/reference/letDeclarations-es5-1.js new file mode 100644 index 00000000000..24c2c62e58f --- /dev/null +++ b/tests/baselines/reference/letDeclarations-es5-1.js @@ -0,0 +1,15 @@ +//// [letDeclarations-es5-1.ts] + let l1; + let l2: number; + let l3, l4, l5 :string, l6; + let l7 = false; + let l8: number = 23; + let l9 = 0, l10 :string = "", l11 = null; + +//// [letDeclarations-es5-1.js] +let l1; +let l2; +let l3, l4, l5, l6; +let l7 = false; +let l8 = 23; +let l9 = 0, l10 = "", l11 = null; diff --git a/tests/baselines/reference/letDeclarations-es5.js b/tests/baselines/reference/letDeclarations-es5.js new file mode 100644 index 00000000000..d5d1d96d350 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-es5.js @@ -0,0 +1,26 @@ +//// [letDeclarations-es5.ts] + +let l1; +let l2: number; +let l3, l4, l5 :string, l6; + +let l7 = false; +let l8: number = 23; +let l9 = 0, l10 :string = "", l11 = null; + +for(let l11 in {}) { } + +for(let l12 = 0; l12 < 9; l12++) { } + + +//// [letDeclarations-es5.js] +let l1; +let l2; +let l3, l4, l5, l6; +let l7 = false; +let l8 = 23; +let l9 = 0, l10 = "", l11 = null; +for (let l11 in {}) { +} +for (let l12 = 0; l12 < 9; l12++) { +} diff --git a/tests/baselines/reference/letDeclarations-invalidContexts.js b/tests/baselines/reference/letDeclarations-invalidContexts.js new file mode 100644 index 00000000000..f8c3bb04bdb --- /dev/null +++ b/tests/baselines/reference/letDeclarations-invalidContexts.js @@ -0,0 +1,57 @@ +//// [letDeclarations-invalidContexts.ts] + +// Errors, let must be defined inside a block +if (true) + let l1 = 0; +else + let l2 = 0; + +while (true) + let l3 = 0; + +do + let l4 = 0; +while (true); + +var obj; +with (obj) + let l5 = 0; + +for (var i = 0; i < 10; i++) + let l6 = 0; + +for (var i2 in {}) + let l7 = 0; + +if (true) + label: let l8 = 0; + +while (false) + label2: label3: label4: let l9 = 0; + + + + + +//// [letDeclarations-invalidContexts.js] +// Errors, let must be defined inside a block +if (true) + let l1 = 0; +else + let l2 = 0; +while (true) + let l3 = 0; +do + let l4 = 0; +while (true); +var obj; +with (obj) + let l5 = 0; +for (var i = 0; i < 10; i++) + let l6 = 0; +for (var i2 in {}) + let l7 = 0; +if (true) + label: let l8 = 0; +while (false) + label2: label3: label4: let l9 = 0; diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates.js b/tests/baselines/reference/letDeclarations-scopes-duplicates.js new file mode 100644 index 00000000000..c7d2ef9863a --- /dev/null +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates.js @@ -0,0 +1,140 @@ +//// [letDeclarations-scopes-duplicates.ts] + +// Errors: redeclaration +let var1 = 0; +let var1 = 0; // error + +let var2 = 0; +const var2 = 0; + +const var3 = 0; +let var3 = 0; + +const var4 = 0; +const var4 = 0; + +var var5 = 0; +let var5 = 0; + +let var6 = 0; +var var6 = 0; + +{ + let var7 = 0; + let var7 = 0; + { + let var8 = 0; + const var8 = 0; + } +} + +switch (0) { + default: + let var9 = 0; + let var9 = 0; +} + +try { + const var10 = 0; + const var10 = 0; +} +catch (e) { + let var11 = 0; + let var11 = 0; +} + +function F1() { + let var12; + let var12; +} + +// OK +var var20 = 0; + +var var20 = 0 +{ + let var20 = 0; + { + let var20 = 0; + } +} + +switch (0) { + default: + let var20 = 0; +} + +try { + let var20 = 0; +} +catch (e) { + let var20 = 0; +} + +function F() { + let var20; +} + + + +//// [letDeclarations-scopes-duplicates.js] +// Errors: redeclaration +let var1 = 0; +let var1 = 0; // error +let var2 = 0; +const var2 = 0; +const var3 = 0; +let var3 = 0; +const var4 = 0; +const var4 = 0; +var var5 = 0; +let var5 = 0; +let var6 = 0; +var var6 = 0; +{ + let var7 = 0; + let var7 = 0; + { + let var8 = 0; + const var8 = 0; + } +} +switch (0) { + default: + let var9 = 0; + let var9 = 0; +} +try { + const var10 = 0; + const var10 = 0; +} +catch (e) { + let var11 = 0; + let var11 = 0; +} +function F1() { + let var12; + let var12; +} +// OK +var var20 = 0; +var var20 = 0; +{ + let var20 = 0; + { + let var20 = 0; + } +} +switch (0) { + default: + let var20 = 0; +} +try { + let var20 = 0; +} +catch (e) { + let var20 = 0; +} +function F() { + let var20; +} diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates2.js b/tests/baselines/reference/letDeclarations-scopes-duplicates2.js new file mode 100644 index 00000000000..9b35bd81c76 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates2.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/letDeclarations-scopes-duplicates2.ts] //// + +//// [file1.ts] + +let var1 = 0; + +//// [file2.ts] +let var1 = 0; + +//// [file1.js] +let var1 = 0; +//// [file2.js] +let var1 = 0; diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates3.js b/tests/baselines/reference/letDeclarations-scopes-duplicates3.js new file mode 100644 index 00000000000..e74caf37219 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates3.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/letDeclarations-scopes-duplicates3.ts] //// + +//// [file1.ts] + +let var1 = 0; + +//// [file2.ts] +const var1 = 0; + +//// [file1.js] +let var1 = 0; +//// [file2.js] +const var1 = 0; diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates4.js b/tests/baselines/reference/letDeclarations-scopes-duplicates4.js new file mode 100644 index 00000000000..ac338e31c72 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates4.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/letDeclarations-scopes-duplicates4.ts] //// + +//// [file1.ts] + +const var1 = 0; + +//// [file2.ts] +let var1 = 0; + +//// [file1.js] +const var1 = 0; +//// [file2.js] +let var1 = 0; diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates5.js b/tests/baselines/reference/letDeclarations-scopes-duplicates5.js new file mode 100644 index 00000000000..2424c91ab90 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates5.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/letDeclarations-scopes-duplicates5.ts] //// + +//// [file1.ts] + +const var1 = 0; + +//// [file2.ts] +const var1 = 0; + +//// [file1.js] +const var1 = 0; +//// [file2.js] +const var1 = 0; diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates6.js b/tests/baselines/reference/letDeclarations-scopes-duplicates6.js new file mode 100644 index 00000000000..24edc0b7bde --- /dev/null +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates6.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/letDeclarations-scopes-duplicates6.ts] //// + +//// [file1.ts] + +var var1 = 0; + +//// [file2.ts] +let var1 = 0; + +//// [file1.js] +var var1 = 0; +//// [file2.js] +let var1 = 0; diff --git a/tests/baselines/reference/letDeclarations-scopes-duplicates7.js b/tests/baselines/reference/letDeclarations-scopes-duplicates7.js new file mode 100644 index 00000000000..4cbc359e2c2 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-scopes-duplicates7.js @@ -0,0 +1,13 @@ +//// [tests/cases/compiler/letDeclarations-scopes-duplicates7.ts] //// + +//// [file1.ts] + +let var1 = 0; + +//// [file2.ts] +var var1 = 0; + +//// [file1.js] +let var1 = 0; +//// [file2.js] +var var1 = 0; diff --git a/tests/baselines/reference/letDeclarations-useBeforeDefinition.js b/tests/baselines/reference/letDeclarations-useBeforeDefinition.js new file mode 100644 index 00000000000..be1f9a127f4 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-useBeforeDefinition.js @@ -0,0 +1,24 @@ +//// [letDeclarations-useBeforeDefinition.ts] + +{ + l1; + let l1; +} + +var v1; +{ + v1; + let v1 = 0; +} + + +//// [letDeclarations-useBeforeDefinition.js] +{ + l1; + let l1; +} +var v1; +{ + v1; + let v1 = 0; +} diff --git a/tests/baselines/reference/letDeclarations-useBeforeDefinition2.js b/tests/baselines/reference/letDeclarations-useBeforeDefinition2.js new file mode 100644 index 00000000000..35560edd1c8 --- /dev/null +++ b/tests/baselines/reference/letDeclarations-useBeforeDefinition2.js @@ -0,0 +1,12 @@ +//// [tests/cases/compiler/letDeclarations-useBeforeDefinition2.ts] //// + +//// [file1.ts] + +l; + +//// [file2.ts] +const l = 0; + +//// [out.js] +l; +const l = 0; diff --git a/tests/baselines/reference/libMembers.js b/tests/baselines/reference/libMembers.js new file mode 100644 index 00000000000..38d1356ccc3 --- /dev/null +++ b/tests/baselines/reference/libMembers.js @@ -0,0 +1,36 @@ +//// [libMembers.ts] +var s="hello"; +s.substring(0); +s.substring(3,4); +s.subby(12); // error unresolved +String.fromCharCode(12); +module M { + export class C { + } + var a=new C[]; + a.length; + a.push(new C()); + (new C()).prototype; +} + + + +//// [libMembers.js] +var s = "hello"; +s.substring(0); +s.substring(3, 4); +s.subby(12); // error unresolved +String.fromCharCode(12); +var M; +(function (M) { + var C = (function () { + function C() { + } + return C; + })(); + M.C = C; + var a = new C[]; + a.length; + a.push(new C()); + (new C()).prototype; +})(M || (M = {})); diff --git a/tests/baselines/reference/literals.js b/tests/baselines/reference/literals.js new file mode 100644 index 00000000000..b92e11c13ce --- /dev/null +++ b/tests/baselines/reference/literals.js @@ -0,0 +1,74 @@ +//// [literals.ts] + +//typeof null is Null +//typeof true is Boolean +//typeof false is Boolean +//typeof numeric literal is Number +//typeof string literal is String +//typeof regex literal is Regex + +var nu = null / null; +var u = undefined / undefined; + +var b: boolean; +var b = true; +var b = false; + +var n: number; +var n = 1; +var n = 1.0; +var n = 1e4; +var n = 001; // Error in ES5 +var n = 0x1; +var n = -1; +var n = -1.0; +var n = -1e-4; +var n = -003; // Error in ES5 +var n = -0x1; + +var s: string; +var s = ''; +var s = ""; +var s = 'foo\ + bar'; +var s = "foo\ + bar"; + +var r: RegExp; +var r = /what/; +var r = /\\\\/; + + +//// [literals.js] +//typeof null is Null +//typeof true is Boolean +//typeof false is Boolean +//typeof numeric literal is Number +//typeof string literal is String +//typeof regex literal is Regex +var nu = null / null; +var u = undefined / undefined; +var b; +var b = true; +var b = false; +var n; +var n = 1; +var n = 1.0; +var n = 1e4; +var n = 001; // Error in ES5 +var n = 0x1; +var n = -1; +var n = -1.0; +var n = -1e-4; +var n = -003; // Error in ES5 +var n = -0x1; +var s; +var s = ''; +var s = ""; +var s = 'foo\ + bar'; +var s = "foo\ + bar"; +var r; +var r = /what/; +var r = /\\\\/; diff --git a/tests/baselines/reference/methodInAmbientClass1.js b/tests/baselines/reference/methodInAmbientClass1.js new file mode 100644 index 00000000000..73b79b3464c --- /dev/null +++ b/tests/baselines/reference/methodInAmbientClass1.js @@ -0,0 +1,7 @@ +//// [methodInAmbientClass1.ts] + declare class Foo { + fn(): boolean { + } + } + +//// [methodInAmbientClass1.js] diff --git a/tests/baselines/reference/missingArgument1.js b/tests/baselines/reference/missingArgument1.js new file mode 100644 index 00000000000..eed0d9b11d6 --- /dev/null +++ b/tests/baselines/reference/missingArgument1.js @@ -0,0 +1,5 @@ +//// [missingArgument1.ts] +foo(a,,b); + +//// [missingArgument1.js] +foo(a, , b); diff --git a/tests/baselines/reference/modifierOnParameter1.js b/tests/baselines/reference/modifierOnParameter1.js new file mode 100644 index 00000000000..69b54a09384 --- /dev/null +++ b/tests/baselines/reference/modifierOnParameter1.js @@ -0,0 +1,11 @@ +//// [modifierOnParameter1.ts] +class C { + constructor(declare p) { } +} + +//// [modifierOnParameter1.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/modifiersOnInterfaceIndexSignature1.js b/tests/baselines/reference/modifiersOnInterfaceIndexSignature1.js new file mode 100644 index 00000000000..1e91071e36a --- /dev/null +++ b/tests/baselines/reference/modifiersOnInterfaceIndexSignature1.js @@ -0,0 +1,6 @@ +//// [modifiersOnInterfaceIndexSignature1.ts] +interface I { + public [a: string]: number; +} + +//// [modifiersOnInterfaceIndexSignature1.js] diff --git a/tests/baselines/reference/moduledecl.js b/tests/baselines/reference/moduledecl.js new file mode 100644 index 00000000000..9be1b116a5e --- /dev/null +++ b/tests/baselines/reference/moduledecl.js @@ -0,0 +1,378 @@ +//// [moduledecl.ts] +module a { +} + +module b.a { +} + +module c.a.b { + import ma = a; +} + +module mImport { + import d = a; + import e = b.a; + import d1 = a; + import e1 = b.a; +} + +module m0 { + function f1() { + } + + function f2(s: string); + function f2(n: number); + function f2(ns: any) { + } + + class c1 { + public a : ()=>string; + private b: ()=>number; + private static s1; + public static s2; + } + + interface i1 { + () : Object; + [n: number]: c1; + } + + import m2 = a; + import m3 = b; + import m4 = b.a; + import m5 = c; + import m6 = c.a; + import m7 = c.a.b; +} + +module m1 { + export function f1() { + } + + export function f2(s: string); + export function f2(n: number); + export function f2(ns: any) { + } + + export class c1 { + public a: () =>string; + private b: () =>number; + private static s1; + public static s2; + + public d() { + return "Hello"; + } + + public e: { x: number; y: string; }; + constructor (public n, public n2: number, private n3, private n4: string) { + } + } + + export interface i1 { + () : Object; + [n: number]: c1; + } + + import m2 = a; + import m3 = b; + import m4 = b.a; + import m5 = c; + import m6 = c.a; + import m7 = c.a.b; +} + +module m { + export module m2 { + var a = 10; + export var b: number; + } + + export module m3 { + export var c: number; + } +} + +module m { + + export module m25 { + export module m5 { + export var c: number; + } + } +} + +module m13 { + export module m4 { + export module m2 { + export module m3 { + export var c: number; + } + } + + export function f() { + return 20; + } + } +} + +declare module m4 { + export var b; +} + +declare module m5 { + export var c; +} + +declare module m43 { + export var b; +} + +declare module m55 { + export var c; +} + +declare module "m3" { + export var b: number; +} + +module exportTests { + export class C1_public { + private f2() { + return 30; + } + + public f3() { + return "string"; + } + } + class C2_private { + private f2() { + return 30; + } + + public f3() { + return "string"; + } + } + + export class C3_public { + private getC2_private() { + return new C2_private(); + } + private setC2_private(arg: C2_private) { + } + private get c2() { + return new C2_private(); + } + public getC1_public() { + return new C1_public(); + } + public setC1_public(arg: C1_public) { + } + public get c1() { + return new C1_public(); + } + } +} + +declare module mAmbient { + class C { + public myProp: number; + } + + function foo() : C; + var aVar: C; + interface B { + x: number; + y: C; + } + enum e { + x, + y, + z + } + + module m3 { + class C { + public myProp: number; + } + + function foo(): C; + var aVar: C; + interface B { + x: number; + y: C; + } + enum e { + x, + y, + z + } + } +} + +function foo() { + return mAmbient.foo(); +} + +var cVar = new mAmbient.C(); +var aVar = mAmbient.aVar; +var bB: mAmbient.B; +var eVar: mAmbient.e; + +function m3foo() { + return mAmbient.m3.foo(); +} + +var m3cVar = new mAmbient.m3.C(); +var m3aVar = mAmbient.m3.aVar; +var m3bB: mAmbient.m3.B; +var m3eVar: mAmbient.m3.e; + + + +//// [moduledecl.js] +var m0; +(function (m0) { + function f1() { + } + function f2(ns) { + } + var c1 = (function () { + function c1() { + } + return c1; + })(); +})(m0 || (m0 = {})); +var m1; +(function (m1) { + function f1() { + } + m1.f1 = f1; + function f2(ns) { + } + m1.f2 = f2; + var c1 = (function () { + function c1(n, n2, n3, n4) { + this.n = n; + this.n2 = n2; + this.n3 = n3; + this.n4 = n4; + } + c1.prototype.d = function () { + return "Hello"; + }; + return c1; + })(); + m1.c1 = c1; +})(m1 || (m1 = {})); +var m; +(function (m) { + var m2; + (function (m2) { + var a = 10; + m2.b; + })(m2 = m.m2 || (m.m2 = {})); + var m3; + (function (m3) { + m3.c; + })(m3 = m.m3 || (m.m3 = {})); +})(m || (m = {})); +var m; +(function (m) { + var m25; + (function (m25) { + var m5; + (function (m5) { + m5.c; + })(m5 = m25.m5 || (m25.m5 = {})); + })(m25 = m.m25 || (m.m25 = {})); +})(m || (m = {})); +var m13; +(function (m13) { + var m4; + (function (m4) { + var m2; + (function (m2) { + var m3; + (function (m3) { + m3.c; + })(m3 = m2.m3 || (m2.m3 = {})); + })(m2 = m4.m2 || (m4.m2 = {})); + function f() { + return 20; + } + m4.f = f; + })(m4 = m13.m4 || (m13.m4 = {})); +})(m13 || (m13 = {})); +var exportTests; +(function (exportTests) { + var C1_public = (function () { + function C1_public() { + } + C1_public.prototype.f2 = function () { + return 30; + }; + C1_public.prototype.f3 = function () { + return "string"; + }; + return C1_public; + })(); + exportTests.C1_public = C1_public; + var C2_private = (function () { + function C2_private() { + } + C2_private.prototype.f2 = function () { + return 30; + }; + C2_private.prototype.f3 = function () { + return "string"; + }; + return C2_private; + })(); + var C3_public = (function () { + function C3_public() { + } + C3_public.prototype.getC2_private = function () { + return new C2_private(); + }; + C3_public.prototype.setC2_private = function (arg) { + }; + Object.defineProperty(C3_public.prototype, "c2", { + get: function () { + return new C2_private(); + }, + enumerable: true, + configurable: true + }); + C3_public.prototype.getC1_public = function () { + return new C1_public(); + }; + C3_public.prototype.setC1_public = function (arg) { + }; + Object.defineProperty(C3_public.prototype, "c1", { + get: function () { + return new C1_public(); + }, + enumerable: true, + configurable: true + }); + return C3_public; + })(); + exportTests.C3_public = C3_public; +})(exportTests || (exportTests = {})); +function foo() { + return mAmbient.foo(); +} +var cVar = new mAmbient.C(); +var aVar = mAmbient.aVar; +var bB; +var eVar; +function m3foo() { + return mAmbient.m3.foo(); +} +var m3cVar = new mAmbient.m3.C(); +var m3aVar = mAmbient.m3.aVar; +var m3bB; +var m3eVar; diff --git a/tests/baselines/reference/multipleClassPropertyModifiers.js b/tests/baselines/reference/multipleClassPropertyModifiers.js new file mode 100644 index 00000000000..7dec786c447 --- /dev/null +++ b/tests/baselines/reference/multipleClassPropertyModifiers.js @@ -0,0 +1,14 @@ +//// [multipleClassPropertyModifiers.ts] +class C { + public static p1; + static public p2; + private static p3; + static private p4; +} + +//// [multipleClassPropertyModifiers.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/multipleClassPropertyModifiersErrors.js b/tests/baselines/reference/multipleClassPropertyModifiersErrors.js new file mode 100644 index 00000000000..191476e9a62 --- /dev/null +++ b/tests/baselines/reference/multipleClassPropertyModifiersErrors.js @@ -0,0 +1,17 @@ +//// [multipleClassPropertyModifiersErrors.ts] +class C { + public public p1; + private private p2; + static static p3; + public private p4; + private public p5; + public static p6; + private static p7; +} + +//// [multipleClassPropertyModifiersErrors.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/multipleInheritance.js b/tests/baselines/reference/multipleInheritance.js new file mode 100644 index 00000000000..9cab77f3dba --- /dev/null +++ b/tests/baselines/reference/multipleInheritance.js @@ -0,0 +1,121 @@ +//// [multipleInheritance.ts] +class B1 { + public x; +} + +class B2 { + public x; +} + +class C extends B1, B2 { // duplicate member +} + +class D1 extends B1 { +} + +class D2 extends B2 { +} + +class E extends D1, D2 { // nope, duplicate member +} + +class N { + public y:number; +} + +class ND extends N { // any is assignable to number + public y; +} + +class Good { + public f:() => number = function() { return 0; } + public g() { return 0; } +} + +class Baad extends Good { + public f(): number { return 0; } + public g(n:number) { return 0; } +} + + +//// [multipleInheritance.js] +var __extends = 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 B1 = (function () { + function B1() { + } + return B1; +})(); +var B2 = (function () { + function B2() { + } + return B2; +})(); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B1); +var D1 = (function (_super) { + __extends(D1, _super); + function D1() { + _super.apply(this, arguments); + } + return D1; +})(B1); +var D2 = (function (_super) { + __extends(D2, _super); + function D2() { + _super.apply(this, arguments); + } + return D2; +})(B2); +var E = (function (_super) { + __extends(E, _super); + function E() { + _super.apply(this, arguments); + } + return E; +})(D1); +var N = (function () { + function N() { + } + return N; +})(); +var ND = (function (_super) { + __extends(ND, _super); + function ND() { + _super.apply(this, arguments); + } + return ND; +})(N); +var Good = (function () { + function Good() { + this.f = function () { + return 0; + }; + } + Good.prototype.g = function () { + return 0; + }; + return Good; +})(); +var Baad = (function (_super) { + __extends(Baad, _super); + function Baad() { + _super.apply(this, arguments); + } + Baad.prototype.f = function () { + return 0; + }; + Baad.prototype.g = function (n) { + return 0; + }; + return Baad; +})(Good); diff --git a/tests/baselines/reference/newOperator.js b/tests/baselines/reference/newOperator.js new file mode 100644 index 00000000000..95dc410142e --- /dev/null +++ b/tests/baselines/reference/newOperator.js @@ -0,0 +1,92 @@ +//// [newOperator.ts] +interface ifc { } +// Attempting to 'new' an interface yields poor error +var i = new ifc(); + +// Parens are optional +var x = new Date; +var y = new Date(); + +// Target is not a class or var, good error +var t1 = new 53(); +var t2 = new ''(); +new string; + +// Use in LHS of expression? +(new Date()).toString(); + +// Various spacing +var t3 = new string[]( ); +var t4 = +new +string +[ + ] + ( + ); + +// Unresolved symbol +var f = new q(); + +// not legal +var t5 = new new Date; + +// Can be an expression +new String; + + +module M { + export class T { + x: number; + } +} + +class S { + public get xs(): M.T[] { + return new M.T[]; + } +} + + +//// [newOperator.js] +// Attempting to 'new' an interface yields poor error +var i = new ifc(); +// Parens are optional +var x = new Date; +var y = new Date(); +// Target is not a class or var, good error +var t1 = new 53(); +var t2 = new ''(); +new string; +// Use in LHS of expression? +(new Date()).toString(); +// Various spacing +var t3 = new string[](); +var t4 = new string[](); +// Unresolved symbol +var f = new q(); +// not legal +var t5 = new new Date; +// Can be an expression +new String; +var M; +(function (M) { + var T = (function () { + function T() { + } + return T; + })(); + M.T = T; +})(M || (M = {})); +var S = (function () { + function S() { + } + Object.defineProperty(S.prototype, "xs", { + get: function () { + return new M.T[]; + }, + enumerable: true, + configurable: true + }); + return S; +})(); diff --git a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInAccessors.js b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInAccessors.js new file mode 100644 index 00000000000..727b1b6087a --- /dev/null +++ b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInAccessors.js @@ -0,0 +1,98 @@ +//// [noCollisionThisExpressionAndLocalVarInAccessors.ts] +class class1 { + get a(): number { + var x2 = { + doStuff: (callback) => () => { + var _this = 2; + return callback(_this); + } + } + + return 10; + } + set a(val: number) { + var x2 = { + doStuff: (callback) => () => { + var _this = 2; + return callback(_this); + } + } + + } +} + +class class2 { + get a(): number { + var _this = 2; + var x2 = { + doStuff: (callback) => () => { + return callback(_this); + } + } + + return 10; + } + set a(val: number) { + var _this = 2; + var x2 = { + doStuff: (callback) => () => { + return callback(_this); + } + } + + } +} + +//// [noCollisionThisExpressionAndLocalVarInAccessors.js] +var class1 = (function () { + function class1() { + } + Object.defineProperty(class1.prototype, "a", { + get: function () { + var x2 = { + doStuff: function (callback) { return function () { + var _this = 2; + return callback(_this); + }; } + }; + return 10; + }, + set: function (val) { + var x2 = { + doStuff: function (callback) { return function () { + var _this = 2; + return callback(_this); + }; } + }; + }, + enumerable: true, + configurable: true + }); + return class1; +})(); +var class2 = (function () { + function class2() { + } + Object.defineProperty(class2.prototype, "a", { + get: function () { + var _this = 2; + var x2 = { + doStuff: function (callback) { return function () { + return callback(_this); + }; } + }; + return 10; + }, + set: function (val) { + var _this = 2; + var x2 = { + doStuff: function (callback) { return function () { + return callback(_this); + }; } + }; + }, + enumerable: true, + configurable: true + }); + return class2; +})(); diff --git a/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.js b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.js new file mode 100644 index 00000000000..339f674b9da --- /dev/null +++ b/tests/baselines/reference/numericIndexerConstrainsPropertyDeclarations.js @@ -0,0 +1,151 @@ +//// [numericIndexerConstrainsPropertyDeclarations.ts] +// String indexer types constrain the types of named properties in their containing type + +interface MyNumber extends Number { + foo: number; +} + +class C { + [x: number]: string; + + constructor() { } // ok + + a: string; // ok + b: number; // ok + c: () => {} // ok + "d": string; // ok + "e": number; // ok + 1.0: string; // ok + 2.0: number; // error + "3.0": string; // ok + "4.0": number; // error + 3.0: MyNumber // error + + get X() { // ok + return ''; + } + set X(v) { } // ok + + foo() { + return ''; + } + + static sa: number; // ok + static sb: string; // ok + + static foo() { } // ok + static get X() { // ok + return 1; + } +} + +interface I { + [x: number]: string; + + a: string; // ok + b: number; // ok + c: () => {} // ok + "d": string; // ok + "e": number; // ok + 1.0: string; // ok + 2.0: number; // error + (): string; // ok + (x): number // ok + foo(): string; // ok + "3.0": string; // ok + "4.0": number; // error + f: MyNumber; // error +} + +var a: { + [x: number]: string; + + a: string; // ok + b: number; // ok + c: () => {} // ok + "d": string; // ok + "e": number; // ok + 1.0: string; // ok + 2.0: number; // error + (): string; // ok + (x): number // ok + foo(): string; // ok + "3.0": string; // ok + "4.0": number; // error + f: MyNumber; // error +} + +// error +var b: { [x: number]: string; } = { + a: '', + b: 1, + c: () => { }, + "d": '', + "e": 1, + 1.0: '', + 2.0: 1, + "3.0": '', + "4.0": 1, + f: null, + + get X() { + return ''; + }, + set X(v) { }, + foo() { + return ''; + } +} + +//// [numericIndexerConstrainsPropertyDeclarations.js] +// String indexer types constrain the types of named properties in their containing type +var C = (function () { + function C() { + } // ok + Object.defineProperty(C.prototype, "X", { + get: function () { + return ''; + }, + set: function (v) { + } // ok + , + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + return ''; + }; + C.foo = function () { + }; // ok + Object.defineProperty(C, "X", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var a; +// error +var b = { + a: '', + b: 1, + c: function () { + }, + "d": '', + "e": 1, + 1.0: '', + 2.0: 1, + "3.0": '', + "4.0": 1, + f: null, + get X() { + return ''; + }, + set X(v) { + }, + foo: function () { + return ''; + } +}; diff --git a/tests/baselines/reference/objectLitPropertyScoping.js b/tests/baselines/reference/objectLitPropertyScoping.js new file mode 100644 index 00000000000..b9615081e3f --- /dev/null +++ b/tests/baselines/reference/objectLitPropertyScoping.js @@ -0,0 +1,33 @@ +//// [objectLitPropertyScoping.ts] +// Should compile, x and y should not be picked up from the properties + +function makePoint(x: number, y: number) { + return { + get x() { + return x; + }, + get y() { + return y; + }, + dist: function () { + return Math.sqrt(x * x + y * y); + } + } +}; + +//// [objectLitPropertyScoping.js] +// Should compile, x and y should not be picked up from the properties +function makePoint(x, y) { + return { + get x() { + return x; + }, + get y() { + return y; + }, + dist: function () { + return Math.sqrt(x * x + y * y); + } + }; +} +; diff --git a/tests/baselines/reference/objectLiteralErrors.js b/tests/baselines/reference/objectLiteralErrors.js new file mode 100644 index 00000000000..2a72e8a2a77 --- /dev/null +++ b/tests/baselines/reference/objectLiteralErrors.js @@ -0,0 +1,138 @@ +//// [objectLiteralErrors.ts] + +// Multiple properties with the same name +var e1 = { a: 0, a: 0 }; +var e2 = { a: '', a: '' }; +var e3 = { a: 0, a: '' }; +var e4 = { a: true, a: false }; +var e5 = { a: {}, a: {} }; +var e6 = { a: 0, 'a': 0 }; +var e7 = { 'a': 0, a: 0 }; +var e8 = { 'a': 0, "a": 0 }; +var e9 = { 'a': 0, 'a': 0 }; +var e10 = { "a": 0, 'a': 0 }; +var e11 = { 1.0: 0, '1': 0 }; +var e12 = { 0: 0, 0: 0 }; +var e13 = { 0: 0, 0: 0 }; +var e14 = { 0: 0, 0x0: 0 }; +var e14 = { 0: 0, 000: 0 }; +var e15 = { "100": 0, 1e2: 0 }; +var e16 = { 0x20: 0, 3.2e1: 0 }; +var e17 = { a: 0, b: 1, a: 0 }; + +// Accessor and property with the same name +var f1 = { a: 0, get a() { return 0; } }; +var f2 = { a: '', get a() { return ''; } }; +var f3 = { a: 0, get a() { return ''; } }; +var f4 = { a: true, get a() { return false; } }; +var f5 = { a: {}, get a() { return {}; } }; +var f6 = { a: 0, get 'a'() { return 0; } }; +var f7 = { 'a': 0, get a() { return 0; } }; +var f8 = { 'a': 0, get "a"() { return 0; } }; +var f9 = { 'a': 0, get 'a'() { return 0; } }; +var f10 = { "a": 0, get 'a'() { return 0; } }; +var f11 = { 1.0: 0, get '1'() { return 0; } }; +var f12 = { 0: 0, get 0() { return 0; } }; +var f13 = { 0: 0, get 0() { return 0; } }; +var f14 = { 0: 0, get 0x0() { return 0; } }; +var f14 = { 0: 0, get 000() { return 0; } }; +var f15 = { "100": 0, get 1e2() { return 0; } }; +var f16 = { 0x20: 0, get 3.2e1() { return 0; } }; +var f17 = { a: 0, get b() { return 1; }, get a() { return 0; } }; + +// Get and set accessor with mismatched type annotations +var g1 = { get a(): number { return 4; }, set a(n: string) { } }; +var g2 = { get a() { return 4; }, set a(n: string) { } }; +var g3 = { get a(): number { return undefined; }, set a(n: string) { } }; + + +//// [objectLiteralErrors.js] +// Multiple properties with the same name +var e1 = { a: 0, a: 0 }; +var e2 = { a: '', a: '' }; +var e3 = { a: 0, a: '' }; +var e4 = { a: true, a: false }; +var e5 = { a: {}, a: {} }; +var e6 = { a: 0, 'a': 0 }; +var e7 = { 'a': 0, a: 0 }; +var e8 = { 'a': 0, "a": 0 }; +var e9 = { 'a': 0, 'a': 0 }; +var e10 = { "a": 0, 'a': 0 }; +var e11 = { 1.0: 0, '1': 0 }; +var e12 = { 0: 0, 0: 0 }; +var e13 = { 0: 0, 0: 0 }; +var e14 = { 0: 0, 0x0: 0 }; +var e14 = { 0: 0, 000: 0 }; +var e15 = { "100": 0, 1e2: 0 }; +var e16 = { 0x20: 0, 3.2e1: 0 }; +var e17 = { a: 0, b: 1, a: 0 }; +// Accessor and property with the same name +var f1 = { a: 0, get a() { + return 0; +} }; +var f2 = { a: '', get a() { + return ''; +} }; +var f3 = { a: 0, get a() { + return ''; +} }; +var f4 = { a: true, get a() { + return false; +} }; +var f5 = { a: {}, get a() { + return {}; +} }; +var f6 = { a: 0, get 'a'() { + return 0; +} }; +var f7 = { 'a': 0, get a() { + return 0; +} }; +var f8 = { 'a': 0, get "a"() { + return 0; +} }; +var f9 = { 'a': 0, get 'a'() { + return 0; +} }; +var f10 = { "a": 0, get 'a'() { + return 0; +} }; +var f11 = { 1.0: 0, get '1'() { + return 0; +} }; +var f12 = { 0: 0, get 0() { + return 0; +} }; +var f13 = { 0: 0, get 0() { + return 0; +} }; +var f14 = { 0: 0, get 0x0() { + return 0; +} }; +var f14 = { 0: 0, get 000() { + return 0; +} }; +var f15 = { "100": 0, get 1e2() { + return 0; +} }; +var f16 = { 0x20: 0, get 3.2e1() { + return 0; +} }; +var f17 = { a: 0, get b() { + return 1; +}, get a() { + return 0; +} }; +// Get and set accessor with mismatched type annotations +var g1 = { get a() { + return 4; +}, set a(n) { +} }; +var g2 = { get a() { + return 4; +}, set a(n) { +} }; +var g3 = { get a() { + return undefined; +}, set a(n) { +} }; diff --git a/tests/baselines/reference/objectLiteralErrorsES3.js b/tests/baselines/reference/objectLiteralErrorsES3.js new file mode 100644 index 00000000000..5b98da0039d --- /dev/null +++ b/tests/baselines/reference/objectLiteralErrorsES3.js @@ -0,0 +1,18 @@ +//// [objectLiteralErrorsES3.ts] + +var e1 = { get a() { return 4; } }; +var e2 = { set a(n) { } }; +var e3 = { get a() { return ''; }, set a(n) { } }; + + + +//// [objectLiteralErrorsES3.js] +var e1 = { get a() { + return 4; +} }; +var e2 = { set a(n) { +} }; +var e3 = { get a() { + return ''; +}, set a(n) { +} }; diff --git a/tests/baselines/reference/objectLiteralGettersAndSetters.js b/tests/baselines/reference/objectLiteralGettersAndSetters.js new file mode 100644 index 00000000000..b602650ef8d --- /dev/null +++ b/tests/baselines/reference/objectLiteralGettersAndSetters.js @@ -0,0 +1,220 @@ +//// [objectLiteralGettersAndSetters.ts] +// Get and set accessor with the same name +var sameName1a = { get 'a'() { return ''; }, set a(n) { var p = n; var p: string; } }; +var sameName2a = { get 0.0() { return ''; }, set 0(n) { var p = n; var p: string; } }; +var sameName3a = { get 0x20() { return ''; }, set 3.2e1(n) { var p = n; var p: string; } }; +var sameName4a = { get ''() { return ''; }, set ""(n) { var p = n; var p: string; } }; +var sameName5a = { get '\t'() { return ''; }, set '\t'(n) { var p = n; var p: string; } }; +var sameName6a = { get 'a'() { return ''; }, set a(n) { var p = n; var p: string; } }; + +// PropertyName CallSignature{FunctionBody} is equivalent to PropertyName:function CallSignature{FunctionBody} +var callSig1 = { num(n: number) { return '' } }; +var callSig1: { num: (n: number) => string; }; +var callSig2 = { num: function (n: number) { return '' } }; +var callSig2: { num: (n: number) => string; }; +var callSig3 = { num: (n: number) => '' }; +var callSig3: { num: (n: number) => string; }; + +// Get accessor only, type of the property is the annotated return type of the get accessor +var getter1 = { get x(): string { return undefined; } }; +var getter1: { x: string; } + +// Get accessor only, type of the property is the inferred return type of the get accessor +var getter2 = { get x() { return ''; } }; +var getter2: { x: string; } + +// Set accessor only, type of the property is the param type of the set accessor +var setter1 = { set x(n: number) { } }; +var setter1: { x: number }; + +// Set accessor only, type of the property is Any for an unannotated set accessor +var setter2 = { set x(n) { } }; +var setter2: { x: any }; + +var anyVar: any; +// Get and set accessor with matching type annotations +var sameType1 = { get x(): string { return undefined; }, set x(n: string) { } }; +var sameType2 = { get x(): Array { return undefined; }, set x(n: number[]) { } }; +var sameType3 = { get x(): any { return undefined; }, set x(n: typeof anyVar) { } }; +var sameType4 = { get x(): Date { return undefined; }, set x(n: Date) { } }; + +// Type of unannotated get accessor return type is the type annotation of the set accessor param +var setParamType1 = { + set n(x: (t: string) => void) { }, + get n() { return (t) => { + var p: string; + var p = t; + } + } +}; +var setParamType2 = { + get n() { return (t) => { + var p: string; + var p = t; + } + }, + set n(x: (t: string) => void) { } +}; + +// Type of unannotated set accessor parameter is the return type annotation of the get accessor +var getParamType1 = { + set n(x) { + var y = x; + var y: string; + }, + get n() { return ''; } +}; +var getParamType2 = { + get n() { return ''; }, + set n(x) { + var y = x; + var y: string; + } +}; + +// Type of unannotated accessors is the inferred return type of the get accessor +var getParamType3 = { + get n() { return ''; }, + set n(x) { + var y = x; + var y: string; + } +}; + + + +//// [objectLiteralGettersAndSetters.js] +// Get and set accessor with the same name +var sameName1a = { get 'a'() { + return ''; +}, set a(n) { + var p = n; + var p; +} }; +var sameName2a = { get 0.0() { + return ''; +}, set 0(n) { + var p = n; + var p; +} }; +var sameName3a = { get 0x20() { + return ''; +}, set 3.2e1(n) { + var p = n; + var p; +} }; +var sameName4a = { get ''() { + return ''; +}, set ""(n) { + var p = n; + var p; +} }; +var sameName5a = { get '\t'() { + return ''; +}, set '\t'(n) { + var p = n; + var p; +} }; +var sameName6a = { get 'a'() { + return ''; +}, set a(n) { + var p = n; + var p; +} }; +// PropertyName CallSignature{FunctionBody} is equivalent to PropertyName:function CallSignature{FunctionBody} +var callSig1 = { num: function (n) { + return ''; +} }; +var callSig1; +var callSig2 = { num: function (n) { + return ''; +} }; +var callSig2; +var callSig3 = { num: function (n) { return ''; } }; +var callSig3; +// Get accessor only, type of the property is the annotated return type of the get accessor +var getter1 = { get x() { + return undefined; +} }; +var getter1; +// Get accessor only, type of the property is the inferred return type of the get accessor +var getter2 = { get x() { + return ''; +} }; +var getter2; +// Set accessor only, type of the property is the param type of the set accessor +var setter1 = { set x(n) { +} }; +var setter1; +// Set accessor only, type of the property is Any for an unannotated set accessor +var setter2 = { set x(n) { +} }; +var setter2; +var anyVar; +// Get and set accessor with matching type annotations +var sameType1 = { get x() { + return undefined; +}, set x(n) { +} }; +var sameType2 = { get x() { + return undefined; +}, set x(n) { +} }; +var sameType3 = { get x() { + return undefined; +}, set x(n) { +} }; +var sameType4 = { get x() { + return undefined; +}, set x(n) { +} }; +// Type of unannotated get accessor return type is the type annotation of the set accessor param +var setParamType1 = { + set n(x) { + }, + get n() { + return function (t) { + var p; + var p = t; + }; + } +}; +var setParamType2 = { + get n() { + return function (t) { + var p; + var p = t; + }; + }, + set n(x) { + } +}; +// Type of unannotated set accessor parameter is the return type annotation of the get accessor +var getParamType1 = { + set n(x) { + var y = x; + var y; + }, + get n() { + return ''; + } +}; +var getParamType2 = { + get n() { + return ''; + }, + set n(x) { + var y = x; + var y; + } +}; +// Type of unannotated accessors is the inferred return type of the get accessor +var getParamType3 = { + get n() { + return ''; + }, + set n(x) { + var y = x; + var y; + } +}; diff --git a/tests/baselines/reference/objectLiteralMemberWithModifiers2.js b/tests/baselines/reference/objectLiteralMemberWithModifiers2.js new file mode 100644 index 00000000000..fd8e0a68430 --- /dev/null +++ b/tests/baselines/reference/objectLiteralMemberWithModifiers2.js @@ -0,0 +1,6 @@ +//// [objectLiteralMemberWithModifiers2.ts] +var v = { public get foo() { } } + +//// [objectLiteralMemberWithModifiers2.js] +var v = { get foo() { +} }; diff --git a/tests/baselines/reference/objectLiteralMemberWithQuestionMark1.js b/tests/baselines/reference/objectLiteralMemberWithQuestionMark1.js new file mode 100644 index 00000000000..7d646cfab8e --- /dev/null +++ b/tests/baselines/reference/objectLiteralMemberWithQuestionMark1.js @@ -0,0 +1,6 @@ +//// [objectLiteralMemberWithQuestionMark1.ts] +var v = { foo?() { } } + +//// [objectLiteralMemberWithQuestionMark1.js] +var v = { foo: function () { +} }; diff --git a/tests/baselines/reference/objectLiteralMemberWithoutBlock1.js b/tests/baselines/reference/objectLiteralMemberWithoutBlock1.js new file mode 100644 index 00000000000..2ad13950b14 --- /dev/null +++ b/tests/baselines/reference/objectLiteralMemberWithoutBlock1.js @@ -0,0 +1,6 @@ +//// [objectLiteralMemberWithoutBlock1.ts] +var v = { foo(); } + +//// [objectLiteralMemberWithoutBlock1.js] +var v = { foo: function () { +} }; diff --git a/tests/baselines/reference/objectLiteralWithGetAccessorInsideFunction.js b/tests/baselines/reference/objectLiteralWithGetAccessorInsideFunction.js new file mode 100644 index 00000000000..58216c786ae --- /dev/null +++ b/tests/baselines/reference/objectLiteralWithGetAccessorInsideFunction.js @@ -0,0 +1,19 @@ +//// [objectLiteralWithGetAccessorInsideFunction.ts] +function bar() { + var x = { + get _extraOccluded() { + var occluded = 0; + return occluded; + }, + } +} + +//// [objectLiteralWithGetAccessorInsideFunction.js] +function bar() { + var x = { + get _extraOccluded() { + var occluded = 0; + return occluded; + } + }; +} diff --git a/tests/baselines/reference/objectTypeWithOptionalProperty1.js b/tests/baselines/reference/objectTypeWithOptionalProperty1.js new file mode 100644 index 00000000000..8f949733a49 --- /dev/null +++ b/tests/baselines/reference/objectTypeWithOptionalProperty1.js @@ -0,0 +1,9 @@ +//// [objectTypeWithOptionalProperty1.ts] + var b = { + x?: 1 // error + } + +//// [objectTypeWithOptionalProperty1.js] +var b = { + x: 1 // error +}; diff --git a/tests/baselines/reference/objectTypesWithOptionalProperties.js b/tests/baselines/reference/objectTypesWithOptionalProperties.js new file mode 100644 index 00000000000..c2177e63762 --- /dev/null +++ b/tests/baselines/reference/objectTypesWithOptionalProperties.js @@ -0,0 +1,43 @@ +//// [objectTypesWithOptionalProperties.ts] +// Basic uses of optional properties + +var a: { + x?: number; // ok +} + +interface I { + x?: number; // ok +} + +class C { + x?: number; // error +} + +interface I2 { + x?: T; // ok +} + +class C2 { + x?: T; // error +} + +var b = { + x?: 1 // error +} + +//// [objectTypesWithOptionalProperties.js] +// Basic uses of optional properties +var a; +var C = (function () { + function C() { + } + return C; +})(); +var C2 = (function () { + function C2() { + } + return C2; +})(); +var b = { + x: 1 // error +}; diff --git a/tests/baselines/reference/octalLiteralInStrictModeES3.js b/tests/baselines/reference/octalLiteralInStrictModeES3.js new file mode 100644 index 00000000000..9519503ed36 --- /dev/null +++ b/tests/baselines/reference/octalLiteralInStrictModeES3.js @@ -0,0 +1,7 @@ +//// [octalLiteralInStrictModeES3.ts] +"use strict"; +03; + +//// [octalLiteralInStrictModeES3.js] +"use strict"; +03; diff --git a/tests/baselines/reference/optionalArgsWithDefaultValues.js b/tests/baselines/reference/optionalArgsWithDefaultValues.js new file mode 100644 index 00000000000..12ab7c9f330 --- /dev/null +++ b/tests/baselines/reference/optionalArgsWithDefaultValues.js @@ -0,0 +1,37 @@ +//// [optionalArgsWithDefaultValues.ts] +function foo(x: number, y?:boolean=false, z?=0) {} + +class CCC { + public foo(x: number, y?:boolean=false, z?=0) {} + static foo2(x: number, y?:boolean=false, z?=0) {} +} + +var a = (x?=0) => { return 1; }; +var b = (x, y?:number = 2) => { x; }; + +//// [optionalArgsWithDefaultValues.js] +function foo(x, y, z) { + if (y === void 0) { y = false; } + if (z === void 0) { z = 0; } +} +var CCC = (function () { + function CCC() { + } + CCC.prototype.foo = function (x, y, z) { + if (y === void 0) { y = false; } + if (z === void 0) { z = 0; } + }; + CCC.foo2 = function (x, y, z) { + if (y === void 0) { y = false; } + if (z === void 0) { z = 0; } + }; + return CCC; +})(); +var a = function (x) { + if (x === void 0) { x = 0; } + return 1; +}; +var b = function (x, y) { + if (y === void 0) { y = 2; } + x; +}; diff --git a/tests/baselines/reference/optionalParamArgsTest.js b/tests/baselines/reference/optionalParamArgsTest.js new file mode 100644 index 00000000000..942b95d245e --- /dev/null +++ b/tests/baselines/reference/optionalParamArgsTest.js @@ -0,0 +1,270 @@ +//// [optionalParamArgsTest.ts] +// Optional parameter and default argument tests + +// Key: +// Cx - "Class x" +// My - "Method x" +// Az - "Argument z" +// E.g., C1M1A1 = "Class 1, Method 1, Argument 1" + +interface I1 { + C1M1():number; + C1M2(C1M2A1:number):number; + C1M3(C1M3A1?:number,C1M3A2?:number):number; + C1M4(C1M4A1:number,C1M4A2?:number):number; +} + +// test basic configurations +class C1 { + constructor(v: number = 1, p: number = 0) { } + public n:number = 0; + + public C1M1() { return 0; } // returning C1M1A1 will result in "Unresolved symbol C1M1A1" + + public C1M2(C1M2A1:number) { return C1M2A1; } // will return C1M1A2 without complaint + + // C1M3 contains all optional parameters + public C1M3(C1M3A1:number=0,C1M3A2:number=C1M3A1) {return C1M3A1 + C1M3A2; } + + // C1M4 contains a mix of optional and non-optional parameters + public C1M4(C1M4A1:number,C1M4A2?:number) { return C1M4A1 + C1M4A2; } + + public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3?:number) { return C1M5A1 + C1M5A2; } + + // Negative test + // "Optional parameters may only be followed by other optional parameters" + public C1M5(C1M5A1:number,C1M5A2:number=0,C1M5A3:number) { return C1M5A1 + C1M5A2; } +} + +class C2 extends C1 { + constructor(v2: number = 6) { + super(v2); + } +} + + +function F1() { return 0; } +function F2(F2A1:number) { return F2A1; } +function F3(F3A1=0,F3A2=F3A1) {return F3A1 + F3A2; } +function F4(F4A1:number,F4A2?:number) { return F4A1 + F4A2; } + +var L1 = function() {return 0;} +var L2 = function (L2A1:number) { return L2A1; } +var L3 = function (L3A1=0,L3A2=L3A1) {return L3A1 + L3A2; } +var L4 = function (L4A1:number,L4A2?:number) { return L4A1 + L4A2; } + +var c1o1:C1 = new C1(5); +var i1o1:I1 = new C1(5); +// Valid +c1o1.C1M1(); +var f1v1=F1(); +var l1v1=L1(); + +// Valid +c1o1.C1M2(1); +i1o1.C1M2(1); +var f2v1=F2(1); +var l2v1=L2(1); + +// Valid +c1o1.C1M3(1,2); +i1o1.C1M3(1,2); +var f3v1=F3(1,2); +var l3v1=L3(1,2); + +// Valid +c1o1.C1M4(1,2); +i1o1.C1M4(1,2); +var f4v1=F4(1,2); +var l4v1=L4(1,2); + +// Valid +c1o1.C1M3(1); +i1o1.C1M3(1); +var f3v2=F3(1); +var l3v2=L3(1); + +// Valid +c1o1.C1M3(); +i1o1.C1M3(); +var f3v3=F3(); +var l3v3=L3(); + +// Valid +c1o1.C1M4(1); +i1o1.C1M4(1); +var f4v2=F4(1); +var l4v2=L4(1); + +// Negative tests - we expect these cases to fail +c1o1.C1M1(1); +i1o1.C1M1(1); +F1(1); +L1(1); +c1o1.C1M2(); +i1o1.C1M2(); +F2(); +L2(); +c1o1.C1M2(1,2); +i1o1.C1M2(1,2); +F2(1,2); +L2(1,2); +c1o1.C1M3(1,2,3); +i1o1.C1M3(1,2,3); +F3(1,2,3); +L3(1,2,3); +c1o1.C1M4(); +i1o1.C1M4(); +F4(); +L4(); + +function fnOpt1(id: number, children: number[] = [], expectedPath: number[] = [], isRoot?: boolean): void {} +function fnOpt2(id: number, children?: number[], expectedPath?: number[], isRoot?: boolean): void {} +fnOpt1(1, [2, 3], [1], true); +fnOpt2(1, [2, 3], [1], true); + + +//// [optionalParamArgsTest.js] +// Optional parameter and default argument tests +var __extends = 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 __(); +}; +// test basic configurations +var C1 = (function () { + function C1(v, p) { + if (v === void 0) { v = 1; } + if (p === void 0) { p = 0; } + this.n = 0; + } + C1.prototype.C1M1 = function () { + return 0; + }; // returning C1M1A1 will result in "Unresolved symbol C1M1A1" + C1.prototype.C1M2 = function (C1M2A1) { + return C1M2A1; + }; // will return C1M1A2 without complaint + // C1M3 contains all optional parameters + C1.prototype.C1M3 = function (C1M3A1, C1M3A2) { + if (C1M3A1 === void 0) { C1M3A1 = 0; } + if (C1M3A2 === void 0) { C1M3A2 = C1M3A1; } + return C1M3A1 + C1M3A2; + }; + // C1M4 contains a mix of optional and non-optional parameters + C1.prototype.C1M4 = function (C1M4A1, C1M4A2) { + return C1M4A1 + C1M4A2; + }; + C1.prototype.C1M5 = function (C1M5A1, C1M5A2, C1M5A3) { + if (C1M5A2 === void 0) { C1M5A2 = 0; } + return C1M5A1 + C1M5A2; + }; + // Negative test + // "Optional parameters may only be followed by other optional parameters" + C1.prototype.C1M5 = function (C1M5A1, C1M5A2, C1M5A3) { + if (C1M5A2 === void 0) { C1M5A2 = 0; } + return C1M5A1 + C1M5A2; + }; + return C1; +})(); +var C2 = (function (_super) { + __extends(C2, _super); + function C2(v2) { + if (v2 === void 0) { v2 = 6; } + _super.call(this, v2); + } + return C2; +})(C1); +function F1() { + return 0; +} +function F2(F2A1) { + return F2A1; +} +function F3(F3A1, F3A2) { + if (F3A1 === void 0) { F3A1 = 0; } + if (F3A2 === void 0) { F3A2 = F3A1; } + return F3A1 + F3A2; +} +function F4(F4A1, F4A2) { + return F4A1 + F4A2; +} +var L1 = function () { + return 0; +}; +var L2 = function (L2A1) { + return L2A1; +}; +var L3 = function (L3A1, L3A2) { + if (L3A1 === void 0) { L3A1 = 0; } + if (L3A2 === void 0) { L3A2 = L3A1; } + return L3A1 + L3A2; +}; +var L4 = function (L4A1, L4A2) { + return L4A1 + L4A2; +}; +var c1o1 = new C1(5); +var i1o1 = new C1(5); +// Valid +c1o1.C1M1(); +var f1v1 = F1(); +var l1v1 = L1(); +// Valid +c1o1.C1M2(1); +i1o1.C1M2(1); +var f2v1 = F2(1); +var l2v1 = L2(1); +// Valid +c1o1.C1M3(1, 2); +i1o1.C1M3(1, 2); +var f3v1 = F3(1, 2); +var l3v1 = L3(1, 2); +// Valid +c1o1.C1M4(1, 2); +i1o1.C1M4(1, 2); +var f4v1 = F4(1, 2); +var l4v1 = L4(1, 2); +// Valid +c1o1.C1M3(1); +i1o1.C1M3(1); +var f3v2 = F3(1); +var l3v2 = L3(1); +// Valid +c1o1.C1M3(); +i1o1.C1M3(); +var f3v3 = F3(); +var l3v3 = L3(); +// Valid +c1o1.C1M4(1); +i1o1.C1M4(1); +var f4v2 = F4(1); +var l4v2 = L4(1); +// Negative tests - we expect these cases to fail +c1o1.C1M1(1); +i1o1.C1M1(1); +F1(1); +L1(1); +c1o1.C1M2(); +i1o1.C1M2(); +F2(); +L2(); +c1o1.C1M2(1, 2); +i1o1.C1M2(1, 2); +F2(1, 2); +L2(1, 2); +c1o1.C1M3(1, 2, 3); +i1o1.C1M3(1, 2, 3); +F3(1, 2, 3); +L3(1, 2, 3); +c1o1.C1M4(); +i1o1.C1M4(); +F4(); +L4(); +function fnOpt1(id, children, expectedPath, isRoot) { + if (children === void 0) { children = []; } + if (expectedPath === void 0) { expectedPath = []; } +} +function fnOpt2(id, children, expectedPath, isRoot) { +} +fnOpt1(1, [2, 3], [1], true); +fnOpt2(1, [2, 3], [1], true); diff --git a/tests/baselines/reference/optionalSetterParam.js b/tests/baselines/reference/optionalSetterParam.js new file mode 100644 index 00000000000..4b9b7f01360 --- /dev/null +++ b/tests/baselines/reference/optionalSetterParam.js @@ -0,0 +1,19 @@ +//// [optionalSetterParam.ts] +class foo { + + public set bar(param?:any) { } +} + + +//// [optionalSetterParam.js] +var foo = (function () { + function foo() { + } + Object.defineProperty(foo.prototype, "bar", { + set: function (param) { + }, + enumerable: true, + configurable: true + }); + return foo; +})(); diff --git a/tests/baselines/reference/parser509618.js b/tests/baselines/reference/parser509618.js new file mode 100644 index 00000000000..d2e894ac364 --- /dev/null +++ b/tests/baselines/reference/parser509618.js @@ -0,0 +1,7 @@ +//// [parser509618.ts] +declare module ambiModule { + interface i1 { }; +} + + +//// [parser509618.js] diff --git a/tests/baselines/reference/parserAccessibilityAfterStatic1.js b/tests/baselines/reference/parserAccessibilityAfterStatic1.js new file mode 100644 index 00000000000..263efaf5dd2 --- /dev/null +++ b/tests/baselines/reference/parserAccessibilityAfterStatic1.js @@ -0,0 +1,13 @@ +//// [parserAccessibilityAfterStatic1.ts] +class Outer +{ +static public intI: number; +} + + +//// [parserAccessibilityAfterStatic1.js] +var Outer = (function () { + function Outer() { + } + return Outer; +})(); diff --git a/tests/baselines/reference/parserAccessibilityAfterStatic10.js b/tests/baselines/reference/parserAccessibilityAfterStatic10.js new file mode 100644 index 00000000000..feded66fe95 --- /dev/null +++ b/tests/baselines/reference/parserAccessibilityAfterStatic10.js @@ -0,0 +1,15 @@ +//// [parserAccessibilityAfterStatic10.ts] +class Outer +{ +static public intI() {} +} + + +//// [parserAccessibilityAfterStatic10.js] +var Outer = (function () { + function Outer() { + } + Outer.intI = function () { + }; + return Outer; +})(); diff --git a/tests/baselines/reference/parserAccessibilityAfterStatic7.js b/tests/baselines/reference/parserAccessibilityAfterStatic7.js new file mode 100644 index 00000000000..a2bc5c7fba3 --- /dev/null +++ b/tests/baselines/reference/parserAccessibilityAfterStatic7.js @@ -0,0 +1,15 @@ +//// [parserAccessibilityAfterStatic7.ts] +class Outer +{ +static public intI() {} +} + + +//// [parserAccessibilityAfterStatic7.js] +var Outer = (function () { + function Outer() { + } + Outer.intI = function () { + }; + return Outer; +})(); diff --git a/tests/baselines/reference/parserAccessors5.js b/tests/baselines/reference/parserAccessors5.js new file mode 100644 index 00000000000..7e96492a392 --- /dev/null +++ b/tests/baselines/reference/parserAccessors5.js @@ -0,0 +1,6 @@ +//// [parserAccessors5.ts] +declare class C { + get foo() { return 0; } +} + +//// [parserAccessors5.js] diff --git a/tests/baselines/reference/parserAccessors6.js b/tests/baselines/reference/parserAccessors6.js new file mode 100644 index 00000000000..3767441a633 --- /dev/null +++ b/tests/baselines/reference/parserAccessors6.js @@ -0,0 +1,6 @@ +//// [parserAccessors6.ts] +declare class C { + set foo(v) { } +} + +//// [parserAccessors6.js] diff --git a/tests/baselines/reference/parserAccessors7.js b/tests/baselines/reference/parserAccessors7.js new file mode 100644 index 00000000000..2703480ef53 --- /dev/null +++ b/tests/baselines/reference/parserAccessors7.js @@ -0,0 +1,6 @@ +//// [parserAccessors7.ts] +var v = { get foo(v: number) { } }; + +//// [parserAccessors7.js] +var v = { get foo(v) { +} }; diff --git a/tests/baselines/reference/parserAccessors8.js b/tests/baselines/reference/parserAccessors8.js new file mode 100644 index 00000000000..609fde320dc --- /dev/null +++ b/tests/baselines/reference/parserAccessors8.js @@ -0,0 +1,6 @@ +//// [parserAccessors8.ts] +var v = { set foo() { } } + +//// [parserAccessors8.js] +var v = { set foo() { +} }; diff --git a/tests/baselines/reference/parserAccessors9.js b/tests/baselines/reference/parserAccessors9.js new file mode 100644 index 00000000000..07c9d5cbc1e --- /dev/null +++ b/tests/baselines/reference/parserAccessors9.js @@ -0,0 +1,6 @@ +//// [parserAccessors9.ts] +var v = { set foo(a, b) { } } + +//// [parserAccessors9.js] +var v = { set foo(a, b) { +} }; diff --git a/tests/baselines/reference/parserAstSpans1.js b/tests/baselines/reference/parserAstSpans1.js new file mode 100644 index 00000000000..64c8f5c0612 --- /dev/null +++ b/tests/baselines/reference/parserAstSpans1.js @@ -0,0 +1,412 @@ +//// [parserAstSpans1.ts] +/** i1 is interface with properties*/ +interface i1 { + /** i1_p1*/ + i1_p1: number; + /** i1_f1*/ + i1_f1(): void; + /** i1_l1*/ + i1_l1: () => void; + i1_nc_p1: number; + i1_nc_f1(): void; + i1_nc_l1: () => void; + p1: number; + f1(): void; + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; +} +class c1 implements i1 { + public i1_p1: number; + public i1_f1() { + } + public i1_l1: () => void; + public i1_nc_p1: number; + public i1_nc_f1() { + } + public i1_nc_l1: () => void; + /** c1_p1*/ + public p1: number; + /** c1_f1*/ + public f1() { + } + /** c1_l1*/ + public l1: () => void; + /** c1_nc_p1*/ + public nc_p1: number; + /** c1_nc_f1*/ + public nc_f1() { + } + /** c1_nc_l1*/ + public nc_l1: () => void; +} +var i1_i: i1; +i1_i.i1_f1(); +i1_i.i1_nc_f1(); +i1_i.f1(); +i1_i.nc_f1(); +i1_i.i1_l1(); +i1_i.i1_nc_l1(); +i1_i.l1(); +i1_i.nc_l1(); +var c1_i = new c1(); +c1_i.i1_f1(); +c1_i.i1_nc_f1(); +c1_i.f1(); +c1_i.nc_f1(); +c1_i.i1_l1(); +c1_i.i1_nc_l1(); +c1_i.l1(); +c1_i.nc_l1(); +// assign to interface +i1_i = c1_i; +i1_i.i1_f1(); +i1_i.i1_nc_f1(); +i1_i.f1(); +i1_i.nc_f1(); +i1_i.i1_l1(); +i1_i.i1_nc_l1(); +i1_i.l1(); +i1_i.nc_l1(); + +class c2 { + /** c2 c2_p1*/ + public c2_p1: number; + /** c2 c2_f1*/ + public c2_f1() { + } + /** c2 c2_prop*/ + public get c2_prop() { + return 10; + } + public c2_nc_p1: number; + public c2_nc_f1() { + } + public get c2_nc_prop() { + return 10; + } + /** c2 p1*/ + public p1: number; + /** c2 f1*/ + public f1() { + } + /** c2 prop*/ + public get prop() { + return 10; + } + public nc_p1: number; + public nc_f1() { + } + public get nc_prop() { + return 10; + } + /** c2 constructor*/ + constructor(a: number) { + this.c2_p1 = a; + } +} +class c3 extends c2 { + constructor() { + super(10); + this.p1 = super.c2_p1; + } + /** c3 p1*/ + public p1: number; + /** c3 f1*/ + public f1() { + } + /** c3 prop*/ + public get prop() { + return 10; + } + public nc_p1: number; + public nc_f1() { + } + public get nc_prop() { + return 10; + } +} +var c2_i = new c2(10); +var c3_i = new c3(); +c2_i.c2_f1(); +c2_i.c2_nc_f1(); +c2_i.f1(); +c2_i.nc_f1(); +c3_i.c2_f1(); +c3_i.c2_nc_f1(); +c3_i.f1(); +c3_i.nc_f1(); +// assign +c2_i = c3_i; +c2_i.c2_f1(); +c2_i.c2_nc_f1(); +c2_i.f1(); +c2_i.nc_f1(); +class c4 extends c2 { +} +var c4_i = new c4(10); + +interface i2 { + /** i2_p1*/ + i2_p1: number; + /** i2_f1*/ + i2_f1(): void; + /** i2_l1*/ + i2_l1: () => void; + i2_nc_p1: number; + i2_nc_f1(): void; + i2_nc_l1: () => void; + /** i2 p1*/ + p1: number; + /** i2 f1*/ + f1(): void; + /** i2 l1*/ + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; +} +interface i3 extends i2 { + /** i3 p1*/ + p1: number; + /** i3 f1*/ + f1(): void; + /** i3 l1*/ + l1: () => void; + nc_p1: number; + nc_f1(): void; + nc_l1: () => void; +} +var i2_i: i2; +var i3_i: i3; +i2_i.i2_f1(); +i2_i.i2_nc_f1(); +i2_i.f1(); +i2_i.nc_f1(); +i2_i.i2_l1(); +i2_i.i2_nc_l1(); +i2_i.l1(); +i2_i.nc_l1(); +i3_i.i2_f1(); +i3_i.i2_nc_f1(); +i3_i.f1(); +i3_i.nc_f1(); +i3_i.i2_l1(); +i3_i.i2_nc_l1(); +i3_i.l1(); +i3_i.nc_l1(); +// assign to interface +i2_i = i3_i; +i2_i.i2_f1(); +i2_i.i2_nc_f1(); +i2_i.f1(); +i2_i.nc_f1(); +i2_i.i2_l1(); +i2_i.i2_nc_l1(); +i2_i.l1(); +i2_i.nc_l1(); + +/**c5 class*/ +class c5 { + public b: number; +} +class c6 extends c5 { + public d; + constructor() { + super(); + this.d = super.b; + } +} + +//// [parserAstSpans1.js] +var __extends = 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 c1 = (function () { + function c1() { + } + c1.prototype.i1_f1 = function () { + }; + c1.prototype.i1_nc_f1 = function () { + }; + /** c1_f1*/ + c1.prototype.f1 = function () { + }; + /** c1_nc_f1*/ + c1.prototype.nc_f1 = function () { + }; + return c1; +})(); +var i1_i; +i1_i.i1_f1(); +i1_i.i1_nc_f1(); +i1_i.f1(); +i1_i.nc_f1(); +i1_i.i1_l1(); +i1_i.i1_nc_l1(); +i1_i.l1(); +i1_i.nc_l1(); +var c1_i = new c1(); +c1_i.i1_f1(); +c1_i.i1_nc_f1(); +c1_i.f1(); +c1_i.nc_f1(); +c1_i.i1_l1(); +c1_i.i1_nc_l1(); +c1_i.l1(); +c1_i.nc_l1(); +// assign to interface +i1_i = c1_i; +i1_i.i1_f1(); +i1_i.i1_nc_f1(); +i1_i.f1(); +i1_i.nc_f1(); +i1_i.i1_l1(); +i1_i.i1_nc_l1(); +i1_i.l1(); +i1_i.nc_l1(); +var c2 = (function () { + /** c2 constructor*/ + function c2(a) { + this.c2_p1 = a; + } + /** c2 c2_f1*/ + c2.prototype.c2_f1 = function () { + }; + Object.defineProperty(c2.prototype, "c2_prop", { + /** c2 c2_prop*/ + get: function () { + return 10; + }, + enumerable: true, + configurable: true + }); + c2.prototype.c2_nc_f1 = function () { + }; + Object.defineProperty(c2.prototype, "c2_nc_prop", { + get: function () { + return 10; + }, + enumerable: true, + configurable: true + }); + /** c2 f1*/ + c2.prototype.f1 = function () { + }; + Object.defineProperty(c2.prototype, "prop", { + /** c2 prop*/ + get: function () { + return 10; + }, + enumerable: true, + configurable: true + }); + c2.prototype.nc_f1 = function () { + }; + Object.defineProperty(c2.prototype, "nc_prop", { + get: function () { + return 10; + }, + enumerable: true, + configurable: true + }); + return c2; +})(); +var c3 = (function (_super) { + __extends(c3, _super); + function c3() { + _super.call(this, 10); + this.p1 = _super.prototype.c2_p1; + } + /** c3 f1*/ + c3.prototype.f1 = function () { + }; + Object.defineProperty(c3.prototype, "prop", { + /** c3 prop*/ + get: function () { + return 10; + }, + enumerable: true, + configurable: true + }); + c3.prototype.nc_f1 = function () { + }; + Object.defineProperty(c3.prototype, "nc_prop", { + get: function () { + return 10; + }, + enumerable: true, + configurable: true + }); + return c3; +})(c2); +var c2_i = new c2(10); +var c3_i = new c3(); +c2_i.c2_f1(); +c2_i.c2_nc_f1(); +c2_i.f1(); +c2_i.nc_f1(); +c3_i.c2_f1(); +c3_i.c2_nc_f1(); +c3_i.f1(); +c3_i.nc_f1(); +// assign +c2_i = c3_i; +c2_i.c2_f1(); +c2_i.c2_nc_f1(); +c2_i.f1(); +c2_i.nc_f1(); +var c4 = (function (_super) { + __extends(c4, _super); + function c4() { + _super.apply(this, arguments); + } + return c4; +})(c2); +var c4_i = new c4(10); +var i2_i; +var i3_i; +i2_i.i2_f1(); +i2_i.i2_nc_f1(); +i2_i.f1(); +i2_i.nc_f1(); +i2_i.i2_l1(); +i2_i.i2_nc_l1(); +i2_i.l1(); +i2_i.nc_l1(); +i3_i.i2_f1(); +i3_i.i2_nc_f1(); +i3_i.f1(); +i3_i.nc_f1(); +i3_i.i2_l1(); +i3_i.i2_nc_l1(); +i3_i.l1(); +i3_i.nc_l1(); +// assign to interface +i2_i = i3_i; +i2_i.i2_f1(); +i2_i.i2_nc_f1(); +i2_i.f1(); +i2_i.nc_f1(); +i2_i.i2_l1(); +i2_i.i2_nc_l1(); +i2_i.l1(); +i2_i.nc_l1(); +/**c5 class*/ +var c5 = (function () { + function c5() { + } + return c5; +})(); +var c6 = (function (_super) { + __extends(c6, _super); + function c6() { + _super.call(this); + this.d = _super.prototype.b; + } + return c6; +})(c5); diff --git a/tests/baselines/reference/parserCatchClauseWithTypeAnnotation1.js b/tests/baselines/reference/parserCatchClauseWithTypeAnnotation1.js new file mode 100644 index 00000000000..e2ca0ae8be6 --- /dev/null +++ b/tests/baselines/reference/parserCatchClauseWithTypeAnnotation1.js @@ -0,0 +1,11 @@ +//// [parserCatchClauseWithTypeAnnotation1.ts] +try { +} catch (e: Error) { +} + + +//// [parserCatchClauseWithTypeAnnotation1.js] +try { +} +catch (e) { +} diff --git a/tests/baselines/reference/parserClassDeclaration1.js b/tests/baselines/reference/parserClassDeclaration1.js new file mode 100644 index 00000000000..1e4fc0d5bcf --- /dev/null +++ b/tests/baselines/reference/parserClassDeclaration1.js @@ -0,0 +1,18 @@ +//// [parserClassDeclaration1.ts] +class C extends A extends B { +} + +//// [parserClassDeclaration1.js] +var __extends = 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 C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/parserClassDeclaration18.js b/tests/baselines/reference/parserClassDeclaration18.js new file mode 100644 index 00000000000..d95c730608e --- /dev/null +++ b/tests/baselines/reference/parserClassDeclaration18.js @@ -0,0 +1,10 @@ +//// [parserClassDeclaration18.ts] +declare class FooBase { + constructor(s: string); + constructor(n: number); + constructor(x: any) { + } + bar1():void; +} + +//// [parserClassDeclaration18.js] diff --git a/tests/baselines/reference/parserClassDeclaration2.js b/tests/baselines/reference/parserClassDeclaration2.js new file mode 100644 index 00000000000..18bb068b23f --- /dev/null +++ b/tests/baselines/reference/parserClassDeclaration2.js @@ -0,0 +1,10 @@ +//// [parserClassDeclaration2.ts] +class C implements A implements B { +} + +//// [parserClassDeclaration2.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserClassDeclaration3.js b/tests/baselines/reference/parserClassDeclaration3.js new file mode 100644 index 00000000000..99d34bedaed --- /dev/null +++ b/tests/baselines/reference/parserClassDeclaration3.js @@ -0,0 +1,18 @@ +//// [parserClassDeclaration3.ts] +class C implements A extends B { +} + +//// [parserClassDeclaration3.js] +var __extends = 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 C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(B); diff --git a/tests/baselines/reference/parserClassDeclaration4.js b/tests/baselines/reference/parserClassDeclaration4.js new file mode 100644 index 00000000000..3552c74f184 --- /dev/null +++ b/tests/baselines/reference/parserClassDeclaration4.js @@ -0,0 +1,18 @@ +//// [parserClassDeclaration4.ts] +class C extends A implements B extends C { +} + +//// [parserClassDeclaration4.js] +var __extends = 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 C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/parserClassDeclaration5.js b/tests/baselines/reference/parserClassDeclaration5.js new file mode 100644 index 00000000000..6a7846fd036 --- /dev/null +++ b/tests/baselines/reference/parserClassDeclaration5.js @@ -0,0 +1,18 @@ +//// [parserClassDeclaration5.ts] +class C extends A implements B implements C { +} + +//// [parserClassDeclaration5.js] +var __extends = 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 C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/parserClassDeclaration6.js b/tests/baselines/reference/parserClassDeclaration6.js new file mode 100644 index 00000000000..24e55a48344 --- /dev/null +++ b/tests/baselines/reference/parserClassDeclaration6.js @@ -0,0 +1,18 @@ +//// [parserClassDeclaration6.ts] +class C extends A, B { +} + +//// [parserClassDeclaration6.js] +var __extends = 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 C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/parserClassDeclaration7.js b/tests/baselines/reference/parserClassDeclaration7.js new file mode 100644 index 00000000000..5418dd38a5f --- /dev/null +++ b/tests/baselines/reference/parserClassDeclaration7.js @@ -0,0 +1,7 @@ +//// [parserClassDeclaration7.ts] +declare module M { + declare class C { + } +} + +//// [parserClassDeclaration7.js] diff --git a/tests/baselines/reference/parserComputedPropertyName10.js b/tests/baselines/reference/parserComputedPropertyName10.js new file mode 100644 index 00000000000..c00d3292f7e --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName10.js @@ -0,0 +1,12 @@ +//// [parserComputedPropertyName10.ts] +class C { + [e] = 1 +} + +//// [parserComputedPropertyName10.js] +var C = (function () { + function C() { + this[e] = 1; + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName11.js b/tests/baselines/reference/parserComputedPropertyName11.js new file mode 100644 index 00000000000..1b9575184f2 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName11.js @@ -0,0 +1,11 @@ +//// [parserComputedPropertyName11.ts] +class C { + [e](); +} + +//// [parserComputedPropertyName11.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName13.js b/tests/baselines/reference/parserComputedPropertyName13.js new file mode 100644 index 00000000000..ccf59b67827 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName13.js @@ -0,0 +1,5 @@ +//// [parserComputedPropertyName13.ts] +var v: { [e]: number }; + +//// [parserComputedPropertyName13.js] +var v; diff --git a/tests/baselines/reference/parserComputedPropertyName14.js b/tests/baselines/reference/parserComputedPropertyName14.js new file mode 100644 index 00000000000..486d9b1a53f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName14.js @@ -0,0 +1,5 @@ +//// [parserComputedPropertyName14.ts] +var v: { [e](): number }; + +//// [parserComputedPropertyName14.js] +var v; diff --git a/tests/baselines/reference/parserComputedPropertyName15.js b/tests/baselines/reference/parserComputedPropertyName15.js new file mode 100644 index 00000000000..ecdb183679e --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName15.js @@ -0,0 +1,5 @@ +//// [parserComputedPropertyName15.ts] +var v: { [e: number]: string; [e]: number }; + +//// [parserComputedPropertyName15.js] +var v; diff --git a/tests/baselines/reference/parserComputedPropertyName16.js b/tests/baselines/reference/parserComputedPropertyName16.js new file mode 100644 index 00000000000..7f0c07e38c2 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName16.js @@ -0,0 +1,10 @@ +//// [parserComputedPropertyName16.ts] +enum E { + [e] = 1 +} + +//// [parserComputedPropertyName16.js] +var E; +(function (E) { + E[E[e] = 1] = e; +})(E || (E = {})); diff --git a/tests/baselines/reference/parserComputedPropertyName18.js b/tests/baselines/reference/parserComputedPropertyName18.js new file mode 100644 index 00000000000..76a88456007 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName18.js @@ -0,0 +1,5 @@ +//// [parserComputedPropertyName18.ts] +var v: { [e]?(): number }; + +//// [parserComputedPropertyName18.js] +var v; diff --git a/tests/baselines/reference/parserComputedPropertyName19.js b/tests/baselines/reference/parserComputedPropertyName19.js new file mode 100644 index 00000000000..caa66d48c52 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName19.js @@ -0,0 +1,5 @@ +//// [parserComputedPropertyName19.ts] +var v: { [e]? }; + +//// [parserComputedPropertyName19.js] +var v; diff --git a/tests/baselines/reference/parserComputedPropertyName20.js b/tests/baselines/reference/parserComputedPropertyName20.js new file mode 100644 index 00000000000..25a912dbcaa --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName20.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName20.ts] +interface I { + [e](): number +} + +//// [parserComputedPropertyName20.js] diff --git a/tests/baselines/reference/parserComputedPropertyName21.js b/tests/baselines/reference/parserComputedPropertyName21.js new file mode 100644 index 00000000000..c3ae1d63d66 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName21.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName21.ts] +interface I { + [e]: number +} + +//// [parserComputedPropertyName21.js] diff --git a/tests/baselines/reference/parserComputedPropertyName22.js b/tests/baselines/reference/parserComputedPropertyName22.js new file mode 100644 index 00000000000..6e29af5239f --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName22.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName22.ts] +declare class C { + [e]: number +} + +//// [parserComputedPropertyName22.js] diff --git a/tests/baselines/reference/parserComputedPropertyName23.js b/tests/baselines/reference/parserComputedPropertyName23.js new file mode 100644 index 00000000000..a29f610290a --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName23.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName23.ts] +declare class C { + get [e](): number +} + +//// [parserComputedPropertyName23.js] diff --git a/tests/baselines/reference/parserComputedPropertyName25.js b/tests/baselines/reference/parserComputedPropertyName25.js new file mode 100644 index 00000000000..a00cec2e6dd --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName25.js @@ -0,0 +1,15 @@ +//// [parserComputedPropertyName25.ts] +class C { + // No ASI + [e] = 0 + [e2] = 1 +} + +//// [parserComputedPropertyName25.js] +var C = (function () { + function C() { + // No ASI + this[e] = 0[e2] = 1; + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName26.js b/tests/baselines/reference/parserComputedPropertyName26.js new file mode 100644 index 00000000000..fe47249a22e --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName26.js @@ -0,0 +1,13 @@ +//// [parserComputedPropertyName26.ts] +enum E { + // No ASI + [e] = 0 + [e2] = 1 +} + +//// [parserComputedPropertyName26.js] +var E; +(function (E) { + // No ASI + E[E[e] = 0[e2] = 1] = e; +})(E || (E = {})); diff --git a/tests/baselines/reference/parserComputedPropertyName28.js b/tests/baselines/reference/parserComputedPropertyName28.js new file mode 100644 index 00000000000..60fb25dfa20 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName28.js @@ -0,0 +1,13 @@ +//// [parserComputedPropertyName28.ts] +class C { + [e]: number = 0; + [e2]: number +} + +//// [parserComputedPropertyName28.js] +var C = (function () { + function C() { + this[e] = 0; + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName29.js b/tests/baselines/reference/parserComputedPropertyName29.js new file mode 100644 index 00000000000..05ced020aff --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName29.js @@ -0,0 +1,15 @@ +//// [parserComputedPropertyName29.ts] +class C { + // yes ASI + [e] = id++ + [e2]: number +} + +//// [parserComputedPropertyName29.js] +var C = (function () { + function C() { + // yes ASI + this[e] = id++; + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName31.js b/tests/baselines/reference/parserComputedPropertyName31.js new file mode 100644 index 00000000000..2a07155a2f0 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName31.js @@ -0,0 +1,13 @@ +//// [parserComputedPropertyName31.ts] +class C { + // yes ASI + [e]: number + [e2]: number +} + +//// [parserComputedPropertyName31.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName32.js b/tests/baselines/reference/parserComputedPropertyName32.js new file mode 100644 index 00000000000..685b215c8f4 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName32.js @@ -0,0 +1,6 @@ +//// [parserComputedPropertyName32.ts] +declare class C { + [e](): number +} + +//// [parserComputedPropertyName32.js] diff --git a/tests/baselines/reference/parserComputedPropertyName34.js b/tests/baselines/reference/parserComputedPropertyName34.js new file mode 100644 index 00000000000..f5a6daa56e5 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName34.js @@ -0,0 +1,14 @@ +//// [parserComputedPropertyName34.ts] +enum E { + // no ASI, comma expected + [e] = id++, + [e2] = 1 +} + +//// [parserComputedPropertyName34.js] +var E; +(function (E) { + // no ASI, comma expected + E[E[e] = id++] = e; + E[E[e2] = 1] = e2; +})(E || (E = {})); diff --git a/tests/baselines/reference/parserComputedPropertyName36.js b/tests/baselines/reference/parserComputedPropertyName36.js new file mode 100644 index 00000000000..264a3512075 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName36.js @@ -0,0 +1,11 @@ +//// [parserComputedPropertyName36.ts] +class C { + [public ]: string; +} + +//// [parserComputedPropertyName36.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName7.js b/tests/baselines/reference/parserComputedPropertyName7.js new file mode 100644 index 00000000000..70ed8b7b073 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName7.js @@ -0,0 +1,11 @@ +//// [parserComputedPropertyName7.ts] +class C { + [e] +} + +//// [parserComputedPropertyName7.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName8.js b/tests/baselines/reference/parserComputedPropertyName8.js new file mode 100644 index 00000000000..4b79c459663 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName8.js @@ -0,0 +1,11 @@ +//// [parserComputedPropertyName8.ts] +class C { + public [e] +} + +//// [parserComputedPropertyName8.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserComputedPropertyName9.js b/tests/baselines/reference/parserComputedPropertyName9.js new file mode 100644 index 00000000000..4b62cc0ecd9 --- /dev/null +++ b/tests/baselines/reference/parserComputedPropertyName9.js @@ -0,0 +1,11 @@ +//// [parserComputedPropertyName9.ts] +class C { + [e]: Type +} + +//// [parserComputedPropertyName9.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration10.js b/tests/baselines/reference/parserConstructorDeclaration10.js new file mode 100644 index 00000000000..9289636e919 --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration10.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration10.ts] +class C { + constructor(): number { } +} + +//// [parserConstructorDeclaration10.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration11.js b/tests/baselines/reference/parserConstructorDeclaration11.js new file mode 100644 index 00000000000..a21fa87f694 --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration11.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration11.ts] +class C { + constructor<>() { } +} + +//// [parserConstructorDeclaration11.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration12.js b/tests/baselines/reference/parserConstructorDeclaration12.js new file mode 100644 index 00000000000..dc540c3323e --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration12.js @@ -0,0 +1,18 @@ +//// [parserConstructorDeclaration12.ts] +class C { + constructor<>() { } + constructor<> () { } + constructor <>() { } + constructor <> () { } + constructor< >() { } + constructor< > () { } + constructor < >() { } + constructor < > () { } +} + +//// [parserConstructorDeclaration12.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration2.js b/tests/baselines/reference/parserConstructorDeclaration2.js new file mode 100644 index 00000000000..142bf5a5314 --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration2.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration2.ts] +class C { + static constructor() { } +} + +//// [parserConstructorDeclaration2.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration3.js b/tests/baselines/reference/parserConstructorDeclaration3.js new file mode 100644 index 00000000000..6e7531f1e66 --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration3.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration3.ts] +class C { + export constructor() { } +} + +//// [parserConstructorDeclaration3.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration4.js b/tests/baselines/reference/parserConstructorDeclaration4.js new file mode 100644 index 00000000000..2b1ae1cdb68 --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration4.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration4.ts] +class C { + declare constructor() { } +} + +//// [parserConstructorDeclaration4.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration5.js b/tests/baselines/reference/parserConstructorDeclaration5.js new file mode 100644 index 00000000000..c0d8c03458e --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration5.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration5.ts] +class C { + private constructor() { } +} + +//// [parserConstructorDeclaration5.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration6.js b/tests/baselines/reference/parserConstructorDeclaration6.js new file mode 100644 index 00000000000..abee73fe0b8 --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration6.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration6.ts] +class C { + public public constructor() { } +} + +//// [parserConstructorDeclaration6.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration7.js b/tests/baselines/reference/parserConstructorDeclaration7.js new file mode 100644 index 00000000000..8c3b4db9d22 --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration7.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration7.ts] +class C { + public private constructor() { } +} + +//// [parserConstructorDeclaration7.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserConstructorDeclaration9.js b/tests/baselines/reference/parserConstructorDeclaration9.js new file mode 100644 index 00000000000..8393d35f5e7 --- /dev/null +++ b/tests/baselines/reference/parserConstructorDeclaration9.js @@ -0,0 +1,11 @@ +//// [parserConstructorDeclaration9.ts] +class C { + constructor() { } +} + +//// [parserConstructorDeclaration9.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserES3Accessors1.js b/tests/baselines/reference/parserES3Accessors1.js new file mode 100644 index 00000000000..4900c1f32d9 --- /dev/null +++ b/tests/baselines/reference/parserES3Accessors1.js @@ -0,0 +1,17 @@ +//// [parserES3Accessors1.ts] +class C { + get Foo() { } +} + +//// [parserES3Accessors1.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserES3Accessors2.js b/tests/baselines/reference/parserES3Accessors2.js new file mode 100644 index 00000000000..08259f2655e --- /dev/null +++ b/tests/baselines/reference/parserES3Accessors2.js @@ -0,0 +1,17 @@ +//// [parserES3Accessors2.ts] +class C { + set Foo(a) { } +} + +//// [parserES3Accessors2.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserES3Accessors3.js b/tests/baselines/reference/parserES3Accessors3.js new file mode 100644 index 00000000000..57ceb566dcb --- /dev/null +++ b/tests/baselines/reference/parserES3Accessors3.js @@ -0,0 +1,6 @@ +//// [parserES3Accessors3.ts] +var v = { get Foo() { } }; + +//// [parserES3Accessors3.js] +var v = { get Foo() { +} }; diff --git a/tests/baselines/reference/parserES3Accessors4.js b/tests/baselines/reference/parserES3Accessors4.js new file mode 100644 index 00000000000..5c87923ed5e --- /dev/null +++ b/tests/baselines/reference/parserES3Accessors4.js @@ -0,0 +1,6 @@ +//// [parserES3Accessors4.ts] +var v = { set Foo(a) { } }; + +//// [parserES3Accessors4.js] +var v = { set Foo(a) { +} }; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName1.js b/tests/baselines/reference/parserES5ComputedPropertyName1.js new file mode 100644 index 00000000000..6eb66b78cec --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName1.js @@ -0,0 +1,6 @@ +//// [parserES5ComputedPropertyName1.ts] +declare class C { + [e]: number +} + +//// [parserES5ComputedPropertyName1.js] diff --git a/tests/baselines/reference/parserES5ComputedPropertyName10.js b/tests/baselines/reference/parserES5ComputedPropertyName10.js new file mode 100644 index 00000000000..a69165a192a --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName10.js @@ -0,0 +1,12 @@ +//// [parserES5ComputedPropertyName10.ts] +class C { + [e] = 1 +} + +//// [parserES5ComputedPropertyName10.js] +var C = (function () { + function C() { + this[e] = 1; + } + return C; +})(); diff --git a/tests/baselines/reference/parserES5ComputedPropertyName11.js b/tests/baselines/reference/parserES5ComputedPropertyName11.js new file mode 100644 index 00000000000..dfa74b03a5f --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName11.js @@ -0,0 +1,11 @@ +//// [parserES5ComputedPropertyName11.ts] +class C { + [e](); +} + +//// [parserES5ComputedPropertyName11.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserES5ComputedPropertyName2.js b/tests/baselines/reference/parserES5ComputedPropertyName2.js new file mode 100644 index 00000000000..861716a3cde --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName2.js @@ -0,0 +1,5 @@ +//// [parserES5ComputedPropertyName2.ts] +var v = { [e]: 1 }; + +//// [parserES5ComputedPropertyName2.js] +var v = { [e]: 1 }; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName3.js b/tests/baselines/reference/parserES5ComputedPropertyName3.js new file mode 100644 index 00000000000..4e07049b29d --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName3.js @@ -0,0 +1,6 @@ +//// [parserES5ComputedPropertyName3.ts] +var v = { [e]() { } }; + +//// [parserES5ComputedPropertyName3.js] +var v = { [e]: function () { +} }; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName4.js b/tests/baselines/reference/parserES5ComputedPropertyName4.js new file mode 100644 index 00000000000..50e240dcf20 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName4.js @@ -0,0 +1,6 @@ +//// [parserES5ComputedPropertyName4.ts] +var v = { get [e]() { } }; + +//// [parserES5ComputedPropertyName4.js] +var v = { get [e]() { +} }; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName5.js b/tests/baselines/reference/parserES5ComputedPropertyName5.js new file mode 100644 index 00000000000..c0eeae9b4aa --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName5.js @@ -0,0 +1,6 @@ +//// [parserES5ComputedPropertyName5.ts] +interface I { + [e]: number +} + +//// [parserES5ComputedPropertyName5.js] diff --git a/tests/baselines/reference/parserES5ComputedPropertyName6.js b/tests/baselines/reference/parserES5ComputedPropertyName6.js new file mode 100644 index 00000000000..a2fdae9c32e --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName6.js @@ -0,0 +1,10 @@ +//// [parserES5ComputedPropertyName6.ts] +enum E { + [e] = 1 +} + +//// [parserES5ComputedPropertyName6.js] +var E; +(function (E) { + E[E[e] = 1] = e; +})(E || (E = {})); diff --git a/tests/baselines/reference/parserES5ComputedPropertyName7.js b/tests/baselines/reference/parserES5ComputedPropertyName7.js new file mode 100644 index 00000000000..8634682c660 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName7.js @@ -0,0 +1,11 @@ +//// [parserES5ComputedPropertyName7.ts] +class C { + [e] +} + +//// [parserES5ComputedPropertyName7.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserES5ComputedPropertyName8.js b/tests/baselines/reference/parserES5ComputedPropertyName8.js new file mode 100644 index 00000000000..3cbf49002f9 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName8.js @@ -0,0 +1,5 @@ +//// [parserES5ComputedPropertyName8.ts] +var v: { [e]: number }; + +//// [parserES5ComputedPropertyName8.js] +var v; diff --git a/tests/baselines/reference/parserES5ComputedPropertyName9.js b/tests/baselines/reference/parserES5ComputedPropertyName9.js new file mode 100644 index 00000000000..fdefc8649d0 --- /dev/null +++ b/tests/baselines/reference/parserES5ComputedPropertyName9.js @@ -0,0 +1,11 @@ +//// [parserES5ComputedPropertyName9.ts] +class C { + [e]: Type +} + +//// [parserES5ComputedPropertyName9.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserEnumDeclaration2.js b/tests/baselines/reference/parserEnumDeclaration2.js new file mode 100644 index 00000000000..a97b8cf9044 --- /dev/null +++ b/tests/baselines/reference/parserEnumDeclaration2.js @@ -0,0 +1,7 @@ +//// [parserEnumDeclaration2.ts] +declare module M { + declare enum E { + } +} + +//// [parserEnumDeclaration2.js] diff --git a/tests/baselines/reference/parserEnumDeclaration6.js b/tests/baselines/reference/parserEnumDeclaration6.js new file mode 100644 index 00000000000..5810ffc0620 --- /dev/null +++ b/tests/baselines/reference/parserEnumDeclaration6.js @@ -0,0 +1,16 @@ +//// [parserEnumDeclaration6.ts] +enum E { + A = 1, + B, + C = 1 << 1, + D, +} + +//// [parserEnumDeclaration6.js] +var E; +(function (E) { + E[E["A"] = 1] = "A"; + E[E["B"] = 2] = "B"; + E[E["C"] = 1 << 1] = "C"; + E[E["D"] = undefined] = "D"; +})(E || (E = {})); diff --git a/tests/baselines/reference/parserErrorRecovery_ArgumentList5.js b/tests/baselines/reference/parserErrorRecovery_ArgumentList5.js new file mode 100644 index 00000000000..bbb65a44e07 --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_ArgumentList5.js @@ -0,0 +1,11 @@ +//// [parserErrorRecovery_ArgumentList5.ts] +function foo() { + bar(a,) + return; +} + +//// [parserErrorRecovery_ArgumentList5.js] +function foo() { + bar(a); + return; +} diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause1.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause1.js new file mode 100644 index 00000000000..b6557221c65 --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause1.js @@ -0,0 +1,10 @@ +//// [parserErrorRecovery_ExtendsOrImplementsClause1.ts] +class C extends { +} + +//// [parserErrorRecovery_ExtendsOrImplementsClause1.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js new file mode 100644 index 00000000000..babceb0f752 --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause2.js @@ -0,0 +1,18 @@ +//// [parserErrorRecovery_ExtendsOrImplementsClause2.ts] +class C extends A, { +} + +//// [parserErrorRecovery_ExtendsOrImplementsClause2.js] +var __extends = 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 C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause3.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause3.js new file mode 100644 index 00000000000..b420e12cccb --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause3.js @@ -0,0 +1,10 @@ +//// [parserErrorRecovery_ExtendsOrImplementsClause3.ts] +class C extends implements A { +} + +//// [parserErrorRecovery_ExtendsOrImplementsClause3.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js new file mode 100644 index 00000000000..5c0e793173a --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause4.js @@ -0,0 +1,18 @@ +//// [parserErrorRecovery_ExtendsOrImplementsClause4.ts] +class C extends A implements { +} + +//// [parserErrorRecovery_ExtendsOrImplementsClause4.js] +var __extends = 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 C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js new file mode 100644 index 00000000000..40dbcf61820 --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause5.js @@ -0,0 +1,18 @@ +//// [parserErrorRecovery_ExtendsOrImplementsClause5.ts] +class C extends A, implements B, { +} + +//// [parserErrorRecovery_ExtendsOrImplementsClause5.js] +var __extends = 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 C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +})(A); diff --git a/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause6.js b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause6.js new file mode 100644 index 00000000000..02c357e5f46 --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_ExtendsOrImplementsClause6.js @@ -0,0 +1,4 @@ +//// [parserErrorRecovery_ExtendsOrImplementsClause6.ts] +interface I extends { } + +//// [parserErrorRecovery_ExtendsOrImplementsClause6.js] diff --git a/tests/baselines/reference/parserErrorRecovery_ParameterList3.js b/tests/baselines/reference/parserErrorRecovery_ParameterList3.js new file mode 100644 index 00000000000..4c20e676f40 --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_ParameterList3.js @@ -0,0 +1,7 @@ +//// [parserErrorRecovery_ParameterList3.ts] +function f(a,) { +} + +//// [parserErrorRecovery_ParameterList3.js] +function f(a) { +} diff --git a/tests/baselines/reference/parserErrorRecovery_VariableList1.js b/tests/baselines/reference/parserErrorRecovery_VariableList1.js new file mode 100644 index 00000000000..acd4451fded --- /dev/null +++ b/tests/baselines/reference/parserErrorRecovery_VariableList1.js @@ -0,0 +1,7 @@ +//// [parserErrorRecovery_VariableList1.ts] +var a, +return; + +//// [parserErrorRecovery_VariableList1.js] +var a; +return; diff --git a/tests/baselines/reference/parserExportAssignment5.js b/tests/baselines/reference/parserExportAssignment5.js new file mode 100644 index 00000000000..ac2a1202e5e --- /dev/null +++ b/tests/baselines/reference/parserExportAssignment5.js @@ -0,0 +1,9 @@ +//// [parserExportAssignment5.ts] +module M { + export = A; +} + +//// [parserExportAssignment5.js] +var M; +(function (M) { +})(M || (M = {})); diff --git a/tests/baselines/reference/parserForInStatement2.js b/tests/baselines/reference/parserForInStatement2.js new file mode 100644 index 00000000000..9f522eadc5d --- /dev/null +++ b/tests/baselines/reference/parserForInStatement2.js @@ -0,0 +1,7 @@ +//// [parserForInStatement2.ts] +for (var in X) { +} + +//// [parserForInStatement2.js] +for ( in X) { +} diff --git a/tests/baselines/reference/parserForInStatement3.js b/tests/baselines/reference/parserForInStatement3.js new file mode 100644 index 00000000000..4964c108ca0 --- /dev/null +++ b/tests/baselines/reference/parserForInStatement3.js @@ -0,0 +1,7 @@ +//// [parserForInStatement3.ts] +for (var a, b in X) { +} + +//// [parserForInStatement3.js] +for (var a in X) { +} diff --git a/tests/baselines/reference/parserForInStatement6.js b/tests/baselines/reference/parserForInStatement6.js new file mode 100644 index 00000000000..b80d13f3184 --- /dev/null +++ b/tests/baselines/reference/parserForInStatement6.js @@ -0,0 +1,7 @@ +//// [parserForInStatement6.ts] +for (var a = 1, b = 2 in X) { +} + +//// [parserForInStatement6.js] +for (var a = 1 in X) { +} diff --git a/tests/baselines/reference/parserForInStatement7.js b/tests/baselines/reference/parserForInStatement7.js new file mode 100644 index 00000000000..5c056abedb6 --- /dev/null +++ b/tests/baselines/reference/parserForInStatement7.js @@ -0,0 +1,7 @@ +//// [parserForInStatement7.ts] +for (var a: number = 1, b: string = "" in X) { +} + +//// [parserForInStatement7.js] +for (var a = 1 in X) { +} diff --git a/tests/baselines/reference/parserFunctionDeclaration1.js b/tests/baselines/reference/parserFunctionDeclaration1.js new file mode 100644 index 00000000000..39bbfe67ca8 --- /dev/null +++ b/tests/baselines/reference/parserFunctionDeclaration1.js @@ -0,0 +1,6 @@ +//// [parserFunctionDeclaration1.ts] +declare module M { + declare function F(); +} + +//// [parserFunctionDeclaration1.js] diff --git a/tests/baselines/reference/parserFunctionDeclaration2.js b/tests/baselines/reference/parserFunctionDeclaration2.js new file mode 100644 index 00000000000..032489bc61c --- /dev/null +++ b/tests/baselines/reference/parserFunctionDeclaration2.js @@ -0,0 +1,5 @@ +//// [parserFunctionDeclaration2.ts] +declare function Foo() { +} + +//// [parserFunctionDeclaration2.js] diff --git a/tests/baselines/reference/parserGetAccessorWithTypeParameters1.js b/tests/baselines/reference/parserGetAccessorWithTypeParameters1.js new file mode 100644 index 00000000000..16daadea82b --- /dev/null +++ b/tests/baselines/reference/parserGetAccessorWithTypeParameters1.js @@ -0,0 +1,17 @@ +//// [parserGetAccessorWithTypeParameters1.ts] +class C { + get foo() { } +} + +//// [parserGetAccessorWithTypeParameters1.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "foo", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserIndexMemberDeclaration10.js b/tests/baselines/reference/parserIndexMemberDeclaration10.js new file mode 100644 index 00000000000..cba928413a3 --- /dev/null +++ b/tests/baselines/reference/parserIndexMemberDeclaration10.js @@ -0,0 +1,11 @@ +//// [parserIndexMemberDeclaration10.ts] +class C { + static static [x: string]: string; +} + +//// [parserIndexMemberDeclaration10.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserIndexMemberDeclaration6.js b/tests/baselines/reference/parserIndexMemberDeclaration6.js new file mode 100644 index 00000000000..9dae6a786b4 --- /dev/null +++ b/tests/baselines/reference/parserIndexMemberDeclaration6.js @@ -0,0 +1,11 @@ +//// [parserIndexMemberDeclaration6.ts] +class C { + static [x: string]: string; +} + +//// [parserIndexMemberDeclaration6.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserIndexMemberDeclaration7.js b/tests/baselines/reference/parserIndexMemberDeclaration7.js new file mode 100644 index 00000000000..550063e6659 --- /dev/null +++ b/tests/baselines/reference/parserIndexMemberDeclaration7.js @@ -0,0 +1,11 @@ +//// [parserIndexMemberDeclaration7.ts] +class C { + public [x: string]: string; +} + +//// [parserIndexMemberDeclaration7.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserIndexMemberDeclaration8.js b/tests/baselines/reference/parserIndexMemberDeclaration8.js new file mode 100644 index 00000000000..c1f40ad0f15 --- /dev/null +++ b/tests/baselines/reference/parserIndexMemberDeclaration8.js @@ -0,0 +1,11 @@ +//// [parserIndexMemberDeclaration8.ts] +class C { + private [x: string]: string; +} + +//// [parserIndexMemberDeclaration8.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserIndexMemberDeclaration9.js b/tests/baselines/reference/parserIndexMemberDeclaration9.js new file mode 100644 index 00000000000..bd547be3bd3 --- /dev/null +++ b/tests/baselines/reference/parserIndexMemberDeclaration9.js @@ -0,0 +1,11 @@ +//// [parserIndexMemberDeclaration9.ts] +class C { + export [x: string]: string; +} + +//// [parserIndexMemberDeclaration9.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserIndexSignature1.js b/tests/baselines/reference/parserIndexSignature1.js new file mode 100644 index 00000000000..65c67444b34 --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature1.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature1.ts] +interface I { + [...a] +} + +//// [parserIndexSignature1.js] diff --git a/tests/baselines/reference/parserIndexSignature10.js b/tests/baselines/reference/parserIndexSignature10.js new file mode 100644 index 00000000000..a8fbccc402b --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature10.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature10.ts] +interface I { + [a, b]: number +} + +//// [parserIndexSignature10.js] diff --git a/tests/baselines/reference/parserIndexSignature11.js b/tests/baselines/reference/parserIndexSignature11.js new file mode 100644 index 00000000000..a78a2179d64 --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature11.js @@ -0,0 +1,8 @@ +//// [parserIndexSignature11.ts] +interface I { + [p]; // Used to be indexer, now it is a computed property + [p1: string]; + [p2: string, p3: number]; +} + +//// [parserIndexSignature11.js] diff --git a/tests/baselines/reference/parserIndexSignature2.js b/tests/baselines/reference/parserIndexSignature2.js new file mode 100644 index 00000000000..606a9c3435c --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature2.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature2.ts] +interface I { + [public a] +} + +//// [parserIndexSignature2.js] diff --git a/tests/baselines/reference/parserIndexSignature3.js b/tests/baselines/reference/parserIndexSignature3.js new file mode 100644 index 00000000000..d513d378fba --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature3.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature3.ts] +interface I { + [a?] +} + +//// [parserIndexSignature3.js] diff --git a/tests/baselines/reference/parserIndexSignature4.js b/tests/baselines/reference/parserIndexSignature4.js new file mode 100644 index 00000000000..fdfcab478b6 --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature4.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature4.ts] +interface I { + [a = 0] // Used to be indexer, now it is a computed property +} + +//// [parserIndexSignature4.js] diff --git a/tests/baselines/reference/parserIndexSignature5.js b/tests/baselines/reference/parserIndexSignature5.js new file mode 100644 index 00000000000..bce7f74f419 --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature5.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature5.ts] +interface I { + [a] // Used to be indexer, now it is a computed property +} + +//// [parserIndexSignature5.js] diff --git a/tests/baselines/reference/parserIndexSignature6.js b/tests/baselines/reference/parserIndexSignature6.js new file mode 100644 index 00000000000..8566faf26c4 --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature6.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature6.ts] +interface I { + [a:boolean] +} + +//// [parserIndexSignature6.js] diff --git a/tests/baselines/reference/parserIndexSignature7.js b/tests/baselines/reference/parserIndexSignature7.js new file mode 100644 index 00000000000..10c784e795a --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature7.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature7.ts] +interface I { + [a:string] +} + +//// [parserIndexSignature7.js] diff --git a/tests/baselines/reference/parserIndexSignature8.js b/tests/baselines/reference/parserIndexSignature8.js new file mode 100644 index 00000000000..40ea03fb245 --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature8.js @@ -0,0 +1,8 @@ +//// [parserIndexSignature8.ts] +var foo: { [index: any]; }; // expect an error here +var foo2: { [index: RegExp]; }; // expect an error here + + +//// [parserIndexSignature8.js] +var foo; // expect an error here +var foo2; // expect an error here diff --git a/tests/baselines/reference/parserIndexSignature9.js b/tests/baselines/reference/parserIndexSignature9.js new file mode 100644 index 00000000000..c2da7906e78 --- /dev/null +++ b/tests/baselines/reference/parserIndexSignature9.js @@ -0,0 +1,6 @@ +//// [parserIndexSignature9.ts] +interface I { + []: number +} + +//// [parserIndexSignature9.js] diff --git a/tests/baselines/reference/parserInterfaceDeclaration1.js b/tests/baselines/reference/parserInterfaceDeclaration1.js new file mode 100644 index 00000000000..61fe3eee877 --- /dev/null +++ b/tests/baselines/reference/parserInterfaceDeclaration1.js @@ -0,0 +1,5 @@ +//// [parserInterfaceDeclaration1.ts] +interface I extends A extends B { +} + +//// [parserInterfaceDeclaration1.js] diff --git a/tests/baselines/reference/parserInterfaceDeclaration2.js b/tests/baselines/reference/parserInterfaceDeclaration2.js new file mode 100644 index 00000000000..a0bbe96bae4 --- /dev/null +++ b/tests/baselines/reference/parserInterfaceDeclaration2.js @@ -0,0 +1,5 @@ +//// [parserInterfaceDeclaration2.ts] +interface I implements A { +} + +//// [parserInterfaceDeclaration2.js] diff --git a/tests/baselines/reference/parserInterfaceDeclaration3.js b/tests/baselines/reference/parserInterfaceDeclaration3.js new file mode 100644 index 00000000000..8281de6db79 --- /dev/null +++ b/tests/baselines/reference/parserInterfaceDeclaration3.js @@ -0,0 +1,5 @@ +//// [parserInterfaceDeclaration3.ts] +public interface I { +} + +//// [parserInterfaceDeclaration3.js] diff --git a/tests/baselines/reference/parserInterfaceDeclaration4.js b/tests/baselines/reference/parserInterfaceDeclaration4.js new file mode 100644 index 00000000000..9385388d81d --- /dev/null +++ b/tests/baselines/reference/parserInterfaceDeclaration4.js @@ -0,0 +1,5 @@ +//// [parserInterfaceDeclaration4.ts] +static interface I { +} + +//// [parserInterfaceDeclaration4.js] diff --git a/tests/baselines/reference/parserInterfaceDeclaration5.js b/tests/baselines/reference/parserInterfaceDeclaration5.js new file mode 100644 index 00000000000..81ad1108f24 --- /dev/null +++ b/tests/baselines/reference/parserInterfaceDeclaration5.js @@ -0,0 +1,5 @@ +//// [parserInterfaceDeclaration5.ts] +declare interface I { +} + +//// [parserInterfaceDeclaration5.js] diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration10.js b/tests/baselines/reference/parserMemberAccessorDeclaration10.js new file mode 100644 index 00000000000..dba06544963 --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration10.js @@ -0,0 +1,18 @@ +//// [parserMemberAccessorDeclaration10.ts] +class C { + export get Foo() { } +} + +//// [parserMemberAccessorDeclaration10.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + get: function () { + } + exports.Foo = Foo;, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration11.js b/tests/baselines/reference/parserMemberAccessorDeclaration11.js new file mode 100644 index 00000000000..2a286b8ca6b --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration11.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration11.ts] +class C { + declare get Foo() { } +} + +//// [parserMemberAccessorDeclaration11.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration12.js b/tests/baselines/reference/parserMemberAccessorDeclaration12.js new file mode 100644 index 00000000000..aea6eccfbc2 --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration12.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration12.ts] +class C { + get Foo(a: number) { } +} + +//// [parserMemberAccessorDeclaration12.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + get: function (a) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration13.js b/tests/baselines/reference/parserMemberAccessorDeclaration13.js new file mode 100644 index 00000000000..f6ca4ee6a02 --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration13.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration13.ts] +class C { + set Foo() { } +} + +//// [parserMemberAccessorDeclaration13.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + set: function () { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration14.js b/tests/baselines/reference/parserMemberAccessorDeclaration14.js new file mode 100644 index 00000000000..62877d402d1 --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration14.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration14.ts] +class C { + set Foo(a: number, b: number) { } +} + +//// [parserMemberAccessorDeclaration14.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + set: function (a, b) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration16.js b/tests/baselines/reference/parserMemberAccessorDeclaration16.js new file mode 100644 index 00000000000..a6cd0aaa7e9 --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration16.js @@ -0,0 +1,18 @@ +//// [parserMemberAccessorDeclaration16.ts] +class C { + set Foo(a = 1) { } +} + +//// [parserMemberAccessorDeclaration16.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + set: function (a) { + if (a === void 0) { a = 1; } + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration17.js b/tests/baselines/reference/parserMemberAccessorDeclaration17.js new file mode 100644 index 00000000000..6c99c7ddae6 --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration17.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration17.ts] +class C { + set Foo(a?: number) { } +} + +//// [parserMemberAccessorDeclaration17.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + set: function (a) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration18.js b/tests/baselines/reference/parserMemberAccessorDeclaration18.js new file mode 100644 index 00000000000..9483a1f2daf --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration18.js @@ -0,0 +1,21 @@ +//// [parserMemberAccessorDeclaration18.ts] +class C { + set Foo(...a) { } +} + +//// [parserMemberAccessorDeclaration18.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + set: function () { + var a = []; + for (var _i = 0; _i < arguments.length; _i++) { + a[_i - 0] = arguments[_i]; + } + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration7.js b/tests/baselines/reference/parserMemberAccessorDeclaration7.js new file mode 100644 index 00000000000..0d2d24092e5 --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration7.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration7.ts] +class C { + public public get Foo() { } +} + +//// [parserMemberAccessorDeclaration7.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "Foo", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration8.js b/tests/baselines/reference/parserMemberAccessorDeclaration8.js new file mode 100644 index 00000000000..dd93fa4852e --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration8.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration8.ts] +class C { + static static get Foo() { } +} + +//// [parserMemberAccessorDeclaration8.js] +var C = (function () { + function C() { + } + Object.defineProperty(C, "Foo", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberAccessorDeclaration9.js b/tests/baselines/reference/parserMemberAccessorDeclaration9.js new file mode 100644 index 00000000000..5fca86f689b --- /dev/null +++ b/tests/baselines/reference/parserMemberAccessorDeclaration9.js @@ -0,0 +1,17 @@ +//// [parserMemberAccessorDeclaration9.ts] +class C { + static public get Foo() { } +} + +//// [parserMemberAccessorDeclaration9.js] +var C = (function () { + function C() { + } + Object.defineProperty(C, "Foo", { + get: function () { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration1.js b/tests/baselines/reference/parserMemberFunctionDeclaration1.js new file mode 100644 index 00000000000..564245157b0 --- /dev/null +++ b/tests/baselines/reference/parserMemberFunctionDeclaration1.js @@ -0,0 +1,13 @@ +//// [parserMemberFunctionDeclaration1.ts] +class C { + public public Foo() { } +} + +//// [parserMemberFunctionDeclaration1.js] +var C = (function () { + function C() { + } + C.prototype.Foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration2.js b/tests/baselines/reference/parserMemberFunctionDeclaration2.js new file mode 100644 index 00000000000..0f103c90b7d --- /dev/null +++ b/tests/baselines/reference/parserMemberFunctionDeclaration2.js @@ -0,0 +1,13 @@ +//// [parserMemberFunctionDeclaration2.ts] +class C { + static static Foo() { } +} + +//// [parserMemberFunctionDeclaration2.js] +var C = (function () { + function C() { + } + C.Foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration3.js b/tests/baselines/reference/parserMemberFunctionDeclaration3.js new file mode 100644 index 00000000000..46243f08dad --- /dev/null +++ b/tests/baselines/reference/parserMemberFunctionDeclaration3.js @@ -0,0 +1,13 @@ +//// [parserMemberFunctionDeclaration3.ts] +class C { + static public Foo() { } +} + +//// [parserMemberFunctionDeclaration3.js] +var C = (function () { + function C() { + } + C.Foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration4.js b/tests/baselines/reference/parserMemberFunctionDeclaration4.js new file mode 100644 index 00000000000..bcf00aeb1bc --- /dev/null +++ b/tests/baselines/reference/parserMemberFunctionDeclaration4.js @@ -0,0 +1,14 @@ +//// [parserMemberFunctionDeclaration4.ts] +class C { + export Foo() { } +} + +//// [parserMemberFunctionDeclaration4.js] +var C = (function () { + function C() { + } + C.prototype.Foo = function () { + } + exports.Foo = Foo;; + return C; +})(); diff --git a/tests/baselines/reference/parserMemberFunctionDeclaration5.js b/tests/baselines/reference/parserMemberFunctionDeclaration5.js new file mode 100644 index 00000000000..da2d2281999 --- /dev/null +++ b/tests/baselines/reference/parserMemberFunctionDeclaration5.js @@ -0,0 +1,13 @@ +//// [parserMemberFunctionDeclaration5.ts] +class C { + declare Foo() { } +} + +//// [parserMemberFunctionDeclaration5.js] +var C = (function () { + function C() { + } + C.prototype.Foo = function () { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserMemberVariableDeclaration1.js b/tests/baselines/reference/parserMemberVariableDeclaration1.js new file mode 100644 index 00000000000..7c59fa7db4c --- /dev/null +++ b/tests/baselines/reference/parserMemberVariableDeclaration1.js @@ -0,0 +1,11 @@ +//// [parserMemberVariableDeclaration1.ts] +class C { + public public Foo; +} + +//// [parserMemberVariableDeclaration1.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserMemberVariableDeclaration2.js b/tests/baselines/reference/parserMemberVariableDeclaration2.js new file mode 100644 index 00000000000..7f4ae15a7ee --- /dev/null +++ b/tests/baselines/reference/parserMemberVariableDeclaration2.js @@ -0,0 +1,11 @@ +//// [parserMemberVariableDeclaration2.ts] +class C { + static static Foo; +} + +//// [parserMemberVariableDeclaration2.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserMemberVariableDeclaration3.js b/tests/baselines/reference/parserMemberVariableDeclaration3.js new file mode 100644 index 00000000000..e03279abed9 --- /dev/null +++ b/tests/baselines/reference/parserMemberVariableDeclaration3.js @@ -0,0 +1,11 @@ +//// [parserMemberVariableDeclaration3.ts] +class C { + static public Foo; +} + +//// [parserMemberVariableDeclaration3.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserMemberVariableDeclaration4.js b/tests/baselines/reference/parserMemberVariableDeclaration4.js new file mode 100644 index 00000000000..d52dd0f4a08 --- /dev/null +++ b/tests/baselines/reference/parserMemberVariableDeclaration4.js @@ -0,0 +1,11 @@ +//// [parserMemberVariableDeclaration4.ts] +class C { + export Foo; +} + +//// [parserMemberVariableDeclaration4.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserMemberVariableDeclaration5.js b/tests/baselines/reference/parserMemberVariableDeclaration5.js new file mode 100644 index 00000000000..bc8a49ff3f5 --- /dev/null +++ b/tests/baselines/reference/parserMemberVariableDeclaration5.js @@ -0,0 +1,11 @@ +//// [parserMemberVariableDeclaration5.ts] +class C { + declare Foo; +} + +//// [parserMemberVariableDeclaration5.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/parserModifierOnStatementInBlock2.js b/tests/baselines/reference/parserModifierOnStatementInBlock2.js new file mode 100644 index 00000000000..7e1c5f8ee50 --- /dev/null +++ b/tests/baselines/reference/parserModifierOnStatementInBlock2.js @@ -0,0 +1,9 @@ +//// [parserModifierOnStatementInBlock2.ts] +{ + declare var x = this; +} + + +//// [parserModifierOnStatementInBlock2.js] +{ +} diff --git a/tests/baselines/reference/parserModuleDeclaration1.js b/tests/baselines/reference/parserModuleDeclaration1.js new file mode 100644 index 00000000000..aef0434f76d --- /dev/null +++ b/tests/baselines/reference/parserModuleDeclaration1.js @@ -0,0 +1,5 @@ +//// [parserModuleDeclaration1.ts] +module "Foo" { +} + +//// [parserModuleDeclaration1.js] diff --git a/tests/baselines/reference/parserModuleDeclaration3.js b/tests/baselines/reference/parserModuleDeclaration3.js new file mode 100644 index 00000000000..c4c46cd1442 --- /dev/null +++ b/tests/baselines/reference/parserModuleDeclaration3.js @@ -0,0 +1,7 @@ +//// [parserModuleDeclaration3.ts] +declare module M { + declare module M2 { + } +} + +//// [parserModuleDeclaration3.js] diff --git a/tests/baselines/reference/parserModuleDeclaration5.js b/tests/baselines/reference/parserModuleDeclaration5.js new file mode 100644 index 00000000000..c6017ba813d --- /dev/null +++ b/tests/baselines/reference/parserModuleDeclaration5.js @@ -0,0 +1,9 @@ +//// [parserModuleDeclaration5.ts] +module M1 { + declare module M2 { + declare module M3 { + } + } +} + +//// [parserModuleDeclaration5.js] diff --git a/tests/baselines/reference/parserNotRegex1.js b/tests/baselines/reference/parserNotRegex1.js new file mode 100644 index 00000000000..1169640d850 --- /dev/null +++ b/tests/baselines/reference/parserNotRegex1.js @@ -0,0 +1,10 @@ +//// [parserNotRegex1.ts] + if (a.indexOf(-(4/3))) // We should not get a regex here becuase of the / in the comment. + { + return true; + } + +//// [parserNotRegex1.js] +if (a.indexOf(-(4 / 3))) { + return true; +} diff --git a/tests/baselines/reference/parserObjectCreationArrayLiteral1.js b/tests/baselines/reference/parserObjectCreationArrayLiteral1.js new file mode 100644 index 00000000000..562f1ada637 --- /dev/null +++ b/tests/baselines/reference/parserObjectCreationArrayLiteral1.js @@ -0,0 +1,5 @@ +//// [parserObjectCreationArrayLiteral1.ts] +new Foo[]; + +//// [parserObjectCreationArrayLiteral1.js] +new Foo[]; diff --git a/tests/baselines/reference/parserObjectCreationArrayLiteral3.js b/tests/baselines/reference/parserObjectCreationArrayLiteral3.js new file mode 100644 index 00000000000..8bb892de41a --- /dev/null +++ b/tests/baselines/reference/parserObjectCreationArrayLiteral3.js @@ -0,0 +1,5 @@ +//// [parserObjectCreationArrayLiteral3.ts] +new Foo[](); + +//// [parserObjectCreationArrayLiteral3.js] +new Foo[](); diff --git a/tests/baselines/reference/parserObjectType6.js b/tests/baselines/reference/parserObjectType6.js new file mode 100644 index 00000000000..96b3c1a8f99 --- /dev/null +++ b/tests/baselines/reference/parserObjectType6.js @@ -0,0 +1,8 @@ +//// [parserObjectType6.ts] +var v: { + a: B + []; +}; + +//// [parserObjectType6.js] +var v; diff --git a/tests/baselines/reference/parserParameterList1.js b/tests/baselines/reference/parserParameterList1.js new file mode 100644 index 00000000000..49af7780b1f --- /dev/null +++ b/tests/baselines/reference/parserParameterList1.js @@ -0,0 +1,13 @@ +//// [parserParameterList1.ts] +class C { + F(...A, B) { } +} + +//// [parserParameterList1.js] +var C = (function () { + function C() { + } + C.prototype.F = function (A, B) { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserParameterList10.js b/tests/baselines/reference/parserParameterList10.js new file mode 100644 index 00000000000..4f85dec801c --- /dev/null +++ b/tests/baselines/reference/parserParameterList10.js @@ -0,0 +1,18 @@ +//// [parserParameterList10.ts] +class C { + foo(...bar = 0) { } +} + +//// [parserParameterList10.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + if (bar === void 0) { bar = 0; } + var bar = []; + for (var _i = 0; _i < arguments.length; _i++) { + bar[_i - 0] = arguments[_i]; + } + }; + return C; +})(); diff --git a/tests/baselines/reference/parserParameterList11.js b/tests/baselines/reference/parserParameterList11.js new file mode 100644 index 00000000000..a56e8b58c20 --- /dev/null +++ b/tests/baselines/reference/parserParameterList11.js @@ -0,0 +1,11 @@ +//// [parserParameterList11.ts] +(...arg?) => 102; + +//// [parserParameterList11.js] +(function () { + var arg = []; + for (var _i = 0; _i < arguments.length; _i++) { + arg[_i - 0] = arguments[_i]; + } + return 102; +}); diff --git a/tests/baselines/reference/parserParameterList12.js b/tests/baselines/reference/parserParameterList12.js new file mode 100644 index 00000000000..ce912f0cdfd --- /dev/null +++ b/tests/baselines/reference/parserParameterList12.js @@ -0,0 +1,7 @@ +//// [parserParameterList12.ts] +function F(a,) { +} + +//// [parserParameterList12.js] +function F(a) { +} diff --git a/tests/baselines/reference/parserParameterList2.js b/tests/baselines/reference/parserParameterList2.js new file mode 100644 index 00000000000..c6a7f48c43e --- /dev/null +++ b/tests/baselines/reference/parserParameterList2.js @@ -0,0 +1,14 @@ +//// [parserParameterList2.ts] +class C { + F(A?= 0) { } +} + +//// [parserParameterList2.js] +var C = (function () { + function C() { + } + C.prototype.F = function (A) { + if (A === void 0) { A = 0; } + }; + return C; +})(); diff --git a/tests/baselines/reference/parserParameterList3.js b/tests/baselines/reference/parserParameterList3.js new file mode 100644 index 00000000000..01135f0ceff --- /dev/null +++ b/tests/baselines/reference/parserParameterList3.js @@ -0,0 +1,13 @@ +//// [parserParameterList3.ts] +class C { + F(A?, B) { } +} + +//// [parserParameterList3.js] +var C = (function () { + function C() { + } + C.prototype.F = function (A, B) { + }; + return C; +})(); diff --git a/tests/baselines/reference/parserParameterList9.js b/tests/baselines/reference/parserParameterList9.js new file mode 100644 index 00000000000..965b92a7ef6 --- /dev/null +++ b/tests/baselines/reference/parserParameterList9.js @@ -0,0 +1,17 @@ +//// [parserParameterList9.ts] +class C { + foo(...bar?) { } +} + +//// [parserParameterList9.js] +var C = (function () { + function C() { + } + C.prototype.foo = function () { + var bar = []; + for (var _i = 0; _i < arguments.length; _i++) { + bar[_i - 0] = arguments[_i]; + } + }; + return C; +})(); diff --git a/tests/baselines/reference/parserRegularExpression1.js b/tests/baselines/reference/parserRegularExpression1.js new file mode 100644 index 00000000000..eb6fe1b7c8a --- /dev/null +++ b/tests/baselines/reference/parserRegularExpression1.js @@ -0,0 +1,5 @@ +//// [parserRegularExpression1.ts] +return /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g; + +//// [parserRegularExpression1.js] +return /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g; diff --git a/tests/baselines/reference/parserReturnStatement1.js b/tests/baselines/reference/parserReturnStatement1.js new file mode 100644 index 00000000000..10ee6d83935 --- /dev/null +++ b/tests/baselines/reference/parserReturnStatement1.js @@ -0,0 +1,5 @@ +//// [parserReturnStatement1.ts] +return; + +//// [parserReturnStatement1.js] +return; diff --git a/tests/baselines/reference/parserReturnStatement2.js b/tests/baselines/reference/parserReturnStatement2.js new file mode 100644 index 00000000000..b54cf2b5acd --- /dev/null +++ b/tests/baselines/reference/parserReturnStatement2.js @@ -0,0 +1,9 @@ +//// [parserReturnStatement2.ts] +{ + return; +} + +//// [parserReturnStatement2.js] +{ + return; +} diff --git a/tests/baselines/reference/parserReturnStatement4.js b/tests/baselines/reference/parserReturnStatement4.js new file mode 100644 index 00000000000..3a993697cc6 --- /dev/null +++ b/tests/baselines/reference/parserReturnStatement4.js @@ -0,0 +1,7 @@ +//// [parserReturnStatement4.ts] +var v = { get foo() { return } }; + +//// [parserReturnStatement4.js] +var v = { get foo() { + return; +} }; diff --git a/tests/baselines/reference/parserSetAccessorWithTypeAnnotation1.js b/tests/baselines/reference/parserSetAccessorWithTypeAnnotation1.js new file mode 100644 index 00000000000..0cbae53aac3 --- /dev/null +++ b/tests/baselines/reference/parserSetAccessorWithTypeAnnotation1.js @@ -0,0 +1,18 @@ +//// [parserSetAccessorWithTypeAnnotation1.ts] +class C { + set foo(v): number { + } +} + +//// [parserSetAccessorWithTypeAnnotation1.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "foo", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserSetAccessorWithTypeParameters1.js b/tests/baselines/reference/parserSetAccessorWithTypeParameters1.js new file mode 100644 index 00000000000..a19675167c8 --- /dev/null +++ b/tests/baselines/reference/parserSetAccessorWithTypeParameters1.js @@ -0,0 +1,17 @@ +//// [parserSetAccessorWithTypeParameters1.ts] +class C { + set foo(v) { } +} + +//// [parserSetAccessorWithTypeParameters1.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "foo", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/parserShorthandPropertyAssignment1.js b/tests/baselines/reference/parserShorthandPropertyAssignment1.js new file mode 100644 index 00000000000..20907eacef2 --- /dev/null +++ b/tests/baselines/reference/parserShorthandPropertyAssignment1.js @@ -0,0 +1,10 @@ +//// [parserShorthandPropertyAssignment1.ts] +function foo(obj: { name?: string; id: number }) { } +var name:any, id: any; +foo({ name?, id? }); + +//// [parserShorthandPropertyAssignment1.js] +function foo(obj) { +} +var name, id; +foo({ name: name, id: id }); diff --git a/tests/baselines/reference/parserShorthandPropertyAssignment5.js b/tests/baselines/reference/parserShorthandPropertyAssignment5.js new file mode 100644 index 00000000000..90d74722a99 --- /dev/null +++ b/tests/baselines/reference/parserShorthandPropertyAssignment5.js @@ -0,0 +1,7 @@ +//// [parserShorthandPropertyAssignment5.ts] +var greet = "hello"; +var obj = { greet? }; + +//// [parserShorthandPropertyAssignment5.js] +var greet = "hello"; +var obj = { greet: greet }; diff --git a/tests/baselines/reference/parserStatementIsNotAMemberVariableDeclaration1.js b/tests/baselines/reference/parserStatementIsNotAMemberVariableDeclaration1.js new file mode 100644 index 00000000000..08c8223bfc4 --- /dev/null +++ b/tests/baselines/reference/parserStatementIsNotAMemberVariableDeclaration1.js @@ -0,0 +1,19 @@ +//// [parserStatementIsNotAMemberVariableDeclaration1.ts] +return { + + "set": function (key, value) { + + // 'private' should not be considered a member variable here. + private[key] = value; + + } + +}; + +//// [parserStatementIsNotAMemberVariableDeclaration1.js] +return { + "set": function (key, value) { + // 'private' should not be considered a member variable here. + private[key] = value; + } +}; diff --git a/tests/baselines/reference/parserStrictMode10.js b/tests/baselines/reference/parserStrictMode10.js new file mode 100644 index 00000000000..53ec7686d0e --- /dev/null +++ b/tests/baselines/reference/parserStrictMode10.js @@ -0,0 +1,9 @@ +//// [parserStrictMode10.ts] +"use strict"; +function f(eval) { +} + +//// [parserStrictMode10.js] +"use strict"; +function f(eval) { +} diff --git a/tests/baselines/reference/parserStrictMode11.js b/tests/baselines/reference/parserStrictMode11.js new file mode 100644 index 00000000000..b34af107f83 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode11.js @@ -0,0 +1,9 @@ +//// [parserStrictMode11.ts] +"use strict"; +var v = function f(eval) { +}; + +//// [parserStrictMode11.js] +"use strict"; +var v = function f(eval) { +}; diff --git a/tests/baselines/reference/parserStrictMode12.js b/tests/baselines/reference/parserStrictMode12.js new file mode 100644 index 00000000000..e0daed9e565 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode12.js @@ -0,0 +1,8 @@ +//// [parserStrictMode12.ts] +"use strict"; +var v = { set foo(eval) { } } + +//// [parserStrictMode12.js] +"use strict"; +var v = { set foo(eval) { +} }; diff --git a/tests/baselines/reference/parserStrictMode13.js b/tests/baselines/reference/parserStrictMode13.js new file mode 100644 index 00000000000..c3ace6981f4 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode13.js @@ -0,0 +1,13 @@ +//// [parserStrictMode13.ts] +"use strict"; +try { +} +catch(eval) { +} + +//// [parserStrictMode13.js] +"use strict"; +try { +} +catch (eval) { +} diff --git a/tests/baselines/reference/parserStrictMode14.js b/tests/baselines/reference/parserStrictMode14.js new file mode 100644 index 00000000000..eda7f285f71 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode14.js @@ -0,0 +1,9 @@ +//// [parserStrictMode14.ts] +"use strict"; +with (a) { +} + +//// [parserStrictMode14.js] +"use strict"; +with (a) { +} diff --git a/tests/baselines/reference/parserStrictMode15.js b/tests/baselines/reference/parserStrictMode15.js new file mode 100644 index 00000000000..5fcf91bbddf --- /dev/null +++ b/tests/baselines/reference/parserStrictMode15.js @@ -0,0 +1,7 @@ +//// [parserStrictMode15.ts] +"use strict"; +delete a; + +//// [parserStrictMode15.js] +"use strict"; +delete a; diff --git a/tests/baselines/reference/parserStrictMode3.js b/tests/baselines/reference/parserStrictMode3.js new file mode 100644 index 00000000000..166d8905a7a --- /dev/null +++ b/tests/baselines/reference/parserStrictMode3.js @@ -0,0 +1,7 @@ +//// [parserStrictMode3.ts] +"use strict"; +eval = 1; + +//// [parserStrictMode3.js] +"use strict"; +eval = 1; diff --git a/tests/baselines/reference/parserStrictMode4.js b/tests/baselines/reference/parserStrictMode4.js new file mode 100644 index 00000000000..ff1ed9b3a8f --- /dev/null +++ b/tests/baselines/reference/parserStrictMode4.js @@ -0,0 +1,7 @@ +//// [parserStrictMode4.ts] +"use strict"; +arguments = 1; + +//// [parserStrictMode4.js] +"use strict"; +arguments = 1; diff --git a/tests/baselines/reference/parserStrictMode5.js b/tests/baselines/reference/parserStrictMode5.js new file mode 100644 index 00000000000..7e01b0f5d72 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode5.js @@ -0,0 +1,7 @@ +//// [parserStrictMode5.ts] +"use strict"; +eval += 1; + +//// [parserStrictMode5.js] +"use strict"; +eval += 1; diff --git a/tests/baselines/reference/parserStrictMode6.js b/tests/baselines/reference/parserStrictMode6.js new file mode 100644 index 00000000000..6a4161c3dab --- /dev/null +++ b/tests/baselines/reference/parserStrictMode6.js @@ -0,0 +1,7 @@ +//// [parserStrictMode6.ts] +"use strict"; +eval++; + +//// [parserStrictMode6.js] +"use strict"; +eval++; diff --git a/tests/baselines/reference/parserStrictMode7.js b/tests/baselines/reference/parserStrictMode7.js new file mode 100644 index 00000000000..fafd603da65 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode7.js @@ -0,0 +1,7 @@ +//// [parserStrictMode7.ts] +"use strict"; +++eval; + +//// [parserStrictMode7.js] +"use strict"; +++eval; diff --git a/tests/baselines/reference/parserStrictMode8.js b/tests/baselines/reference/parserStrictMode8.js new file mode 100644 index 00000000000..3db5349c459 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode8.js @@ -0,0 +1,9 @@ +//// [parserStrictMode8.ts] +"use strict"; +function eval() { +} + +//// [parserStrictMode8.js] +"use strict"; +function eval() { +} diff --git a/tests/baselines/reference/parserStrictMode9.js b/tests/baselines/reference/parserStrictMode9.js new file mode 100644 index 00000000000..a30008634c5 --- /dev/null +++ b/tests/baselines/reference/parserStrictMode9.js @@ -0,0 +1,9 @@ +//// [parserStrictMode9.ts] +"use strict"; +var v = function eval() { +}; + +//// [parserStrictMode9.js] +"use strict"; +var v = function eval() { +}; diff --git a/tests/baselines/reference/parserVariableDeclaration10.js b/tests/baselines/reference/parserVariableDeclaration10.js new file mode 100644 index 00000000000..3cab783a946 --- /dev/null +++ b/tests/baselines/reference/parserVariableDeclaration10.js @@ -0,0 +1,5 @@ +//// [parserVariableDeclaration10.ts] +var a,; + +//// [parserVariableDeclaration10.js] +var a; diff --git a/tests/baselines/reference/parserVariableDeclaration4.js b/tests/baselines/reference/parserVariableDeclaration4.js new file mode 100644 index 00000000000..0fcbb51d02e --- /dev/null +++ b/tests/baselines/reference/parserVariableDeclaration4.js @@ -0,0 +1,6 @@ +//// [parserVariableDeclaration4.ts] +declare module M { + declare var v; +} + +//// [parserVariableDeclaration4.js] diff --git a/tests/baselines/reference/parserVariableDeclaration5.js b/tests/baselines/reference/parserVariableDeclaration5.js new file mode 100644 index 00000000000..a865d18651c --- /dev/null +++ b/tests/baselines/reference/parserVariableDeclaration5.js @@ -0,0 +1,5 @@ +//// [parserVariableDeclaration5.ts] +var a, + +//// [parserVariableDeclaration5.js] +var a; diff --git a/tests/baselines/reference/parserVariableDeclaration6.js b/tests/baselines/reference/parserVariableDeclaration6.js new file mode 100644 index 00000000000..64126d69b92 --- /dev/null +++ b/tests/baselines/reference/parserVariableDeclaration6.js @@ -0,0 +1,5 @@ +//// [parserVariableDeclaration6.ts] +var + +//// [parserVariableDeclaration6.js] +var ; diff --git a/tests/baselines/reference/parserVariableDeclaration8.js b/tests/baselines/reference/parserVariableDeclaration8.js new file mode 100644 index 00000000000..7d77a80dad4 --- /dev/null +++ b/tests/baselines/reference/parserVariableDeclaration8.js @@ -0,0 +1,5 @@ +//// [parserVariableDeclaration8.ts] +var ; + +//// [parserVariableDeclaration8.js] +var ; diff --git a/tests/baselines/reference/parserX_ArrowFunction2.js b/tests/baselines/reference/parserX_ArrowFunction2.js new file mode 100644 index 00000000000..a30294b658b --- /dev/null +++ b/tests/baselines/reference/parserX_ArrowFunction2.js @@ -0,0 +1,8 @@ +//// [parserX_ArrowFunction2.ts] +var v = (a: b,) => { + +}; + +//// [parserX_ArrowFunction2.js] +var v = function (a) { +}; diff --git a/tests/baselines/reference/parser_breakNotInIterationOrSwitchStatement1.js b/tests/baselines/reference/parser_breakNotInIterationOrSwitchStatement1.js new file mode 100644 index 00000000000..9ed3e677f9f --- /dev/null +++ b/tests/baselines/reference/parser_breakNotInIterationOrSwitchStatement1.js @@ -0,0 +1,5 @@ +//// [parser_breakNotInIterationOrSwitchStatement1.ts] +break; + +//// [parser_breakNotInIterationOrSwitchStatement1.js] +break; diff --git a/tests/baselines/reference/parser_breakNotInIterationOrSwitchStatement2.js b/tests/baselines/reference/parser_breakNotInIterationOrSwitchStatement2.js new file mode 100644 index 00000000000..b95bfca8404 --- /dev/null +++ b/tests/baselines/reference/parser_breakNotInIterationOrSwitchStatement2.js @@ -0,0 +1,13 @@ +//// [parser_breakNotInIterationOrSwitchStatement2.ts] +while (true) { + function f() { + break; + } +} + +//// [parser_breakNotInIterationOrSwitchStatement2.js] +while (true) { + function f() { + break; + } +} diff --git a/tests/baselines/reference/parser_breakTarget5.js b/tests/baselines/reference/parser_breakTarget5.js new file mode 100644 index 00000000000..743ad6c2631 --- /dev/null +++ b/tests/baselines/reference/parser_breakTarget5.js @@ -0,0 +1,18 @@ +//// [parser_breakTarget5.ts] +target: +while (true) { + function f() { + while (true) { + break target; + } + } +} + +//// [parser_breakTarget5.js] +target: while (true) { + function f() { + while (true) { + break target; + } + } +} diff --git a/tests/baselines/reference/parser_breakTarget6.js b/tests/baselines/reference/parser_breakTarget6.js new file mode 100644 index 00000000000..93b15ac0362 --- /dev/null +++ b/tests/baselines/reference/parser_breakTarget6.js @@ -0,0 +1,9 @@ +//// [parser_breakTarget6.ts] +while (true) { + break target; +} + +//// [parser_breakTarget6.js] +while (true) { + break target; +} diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement1.js b/tests/baselines/reference/parser_continueNotInIterationStatement1.js new file mode 100644 index 00000000000..824a99d9e37 --- /dev/null +++ b/tests/baselines/reference/parser_continueNotInIterationStatement1.js @@ -0,0 +1,5 @@ +//// [parser_continueNotInIterationStatement1.ts] +continue; + +//// [parser_continueNotInIterationStatement1.js] +continue; diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement2.js b/tests/baselines/reference/parser_continueNotInIterationStatement2.js new file mode 100644 index 00000000000..690c3fd910d --- /dev/null +++ b/tests/baselines/reference/parser_continueNotInIterationStatement2.js @@ -0,0 +1,13 @@ +//// [parser_continueNotInIterationStatement2.ts] +while (true) { + function f() { + continue; + } +} + +//// [parser_continueNotInIterationStatement2.js] +while (true) { + function f() { + continue; + } +} diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement3.js b/tests/baselines/reference/parser_continueNotInIterationStatement3.js new file mode 100644 index 00000000000..d5cf6feb221 --- /dev/null +++ b/tests/baselines/reference/parser_continueNotInIterationStatement3.js @@ -0,0 +1,11 @@ +//// [parser_continueNotInIterationStatement3.ts] +switch (0) { + default: + continue; +} + +//// [parser_continueNotInIterationStatement3.js] +switch (0) { + default: + continue; +} diff --git a/tests/baselines/reference/parser_continueNotInIterationStatement4.js b/tests/baselines/reference/parser_continueNotInIterationStatement4.js new file mode 100644 index 00000000000..af2a4ee61b3 --- /dev/null +++ b/tests/baselines/reference/parser_continueNotInIterationStatement4.js @@ -0,0 +1,15 @@ +//// [parser_continueNotInIterationStatement4.ts] +TWO: +while (true){ + var x = () => { + continue TWO; + } +} + + +//// [parser_continueNotInIterationStatement4.js] +TWO: while (true) { + var x = function () { + continue TWO; + }; +} diff --git a/tests/baselines/reference/parser_continueTarget1.js b/tests/baselines/reference/parser_continueTarget1.js new file mode 100644 index 00000000000..fd6ea5750c6 --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget1.js @@ -0,0 +1,6 @@ +//// [parser_continueTarget1.ts] +target: + continue target; + +//// [parser_continueTarget1.js] +target: continue target; diff --git a/tests/baselines/reference/parser_continueTarget5.js b/tests/baselines/reference/parser_continueTarget5.js new file mode 100644 index 00000000000..7be6997c070 --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget5.js @@ -0,0 +1,18 @@ +//// [parser_continueTarget5.ts] +target: +while (true) { + function f() { + while (true) { + continue target; + } + } +} + +//// [parser_continueTarget5.js] +target: while (true) { + function f() { + while (true) { + continue target; + } + } +} diff --git a/tests/baselines/reference/parser_continueTarget6.js b/tests/baselines/reference/parser_continueTarget6.js new file mode 100644 index 00000000000..56f1b6a485c --- /dev/null +++ b/tests/baselines/reference/parser_continueTarget6.js @@ -0,0 +1,9 @@ +//// [parser_continueTarget6.ts] +while (true) { + continue target; +} + +//// [parser_continueTarget6.js] +while (true) { + continue target; +} diff --git a/tests/baselines/reference/parser_duplicateLabel1.js b/tests/baselines/reference/parser_duplicateLabel1.js new file mode 100644 index 00000000000..0fe1801a099 --- /dev/null +++ b/tests/baselines/reference/parser_duplicateLabel1.js @@ -0,0 +1,9 @@ +//// [parser_duplicateLabel1.ts] +target: +target: +while (true) { +} + +//// [parser_duplicateLabel1.js] +target: target: while (true) { +} diff --git a/tests/baselines/reference/parser_duplicateLabel2.js b/tests/baselines/reference/parser_duplicateLabel2.js new file mode 100644 index 00000000000..00c0e5532e5 --- /dev/null +++ b/tests/baselines/reference/parser_duplicateLabel2.js @@ -0,0 +1,13 @@ +//// [parser_duplicateLabel2.ts] +target: +while (true) { + target: + while (true) { + } +} + +//// [parser_duplicateLabel2.js] +target: while (true) { + target: while (true) { + } +} diff --git a/tests/baselines/reference/privacyGloImportParseErrors.errors.txt b/tests/baselines/reference/privacyGloImportParseErrors.errors.txt index fa3b1bb522d..360259adf7c 100644 --- a/tests/baselines/reference/privacyGloImportParseErrors.errors.txt +++ b/tests/baselines/reference/privacyGloImportParseErrors.errors.txt @@ -5,7 +5,9 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(59,37): error TS2307: Cannot tests/cases/compiler/privacyGloImportParseErrors.ts(69,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyGloImportParseErrors.ts(69,37): error TS2307: Cannot find external module 'm1_M4_private'. tests/cases/compiler/privacyGloImportParseErrors.ts(81,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyGloImportParseErrors.ts(81,43): error TS2307: Cannot find external module 'm1_M3_public'. tests/cases/compiler/privacyGloImportParseErrors.ts(82,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyGloImportParseErrors.ts(82,43): error TS2307: Cannot find external module 'm1_M4_private'. tests/cases/compiler/privacyGloImportParseErrors.ts(121,38): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyGloImportParseErrors.ts(125,45): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyGloImportParseErrors.ts(133,9): error TS1038: A 'declare' modifier cannot be used in an already ambient context. @@ -16,7 +18,7 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(146,25): error TS1147: Impor tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Import declarations in an internal module cannot reference an external module. -==== tests/cases/compiler/privacyGloImportParseErrors.ts (16 errors) ==== +==== tests/cases/compiler/privacyGloImportParseErrors.ts (18 errors) ==== module m1 { export module m1_M1_public { export class c1 { @@ -112,9 +114,13 @@ tests/cases/compiler/privacyGloImportParseErrors.ts(149,29): error TS1147: Impor export import m1_im3_public = require("m1_M3_public"); ~~~~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'm1_M3_public'. export import m1_im4_public = require("m1_M4_private"); ~~~~~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'm1_M4_private'. } module glo_M1_public { diff --git a/tests/baselines/reference/privacyGloImportParseErrors.js b/tests/baselines/reference/privacyGloImportParseErrors.js new file mode 100644 index 00000000000..6812b468882 --- /dev/null +++ b/tests/baselines/reference/privacyGloImportParseErrors.js @@ -0,0 +1,248 @@ +//// [privacyGloImportParseErrors.ts] +module m1 { + export module m1_M1_public { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; + } + + module m1_M2_private { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; + } + + export declare module "m1_M3_public" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; + } + + declare module "m1_M4_private" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; + } + + import m1_im1_private = m1_M1_public; + export var m1_im1_private_v1_public = m1_im1_private.c1; + export var m1_im1_private_v2_public = new m1_im1_private.c1(); + export var m1_im1_private_v3_public = m1_im1_private.f1; + export var m1_im1_private_v4_public = m1_im1_private.f1(); + var m1_im1_private_v1_private = m1_im1_private.c1; + var m1_im1_private_v2_private = new m1_im1_private.c1(); + var m1_im1_private_v3_private = m1_im1_private.f1; + var m1_im1_private_v4_private = m1_im1_private.f1(); + + + import m1_im2_private = m1_M2_private; + export var m1_im2_private_v1_public = m1_im2_private.c1; + export var m1_im2_private_v2_public = new m1_im2_private.c1(); + export var m1_im2_private_v3_public = m1_im2_private.f1; + export var m1_im2_private_v4_public = m1_im2_private.f1(); + var m1_im2_private_v1_private = m1_im2_private.c1; + var m1_im2_private_v2_private = new m1_im2_private.c1(); + var m1_im2_private_v3_private = m1_im2_private.f1; + var m1_im2_private_v4_private = m1_im2_private.f1(); + + import m1_im3_private = require("m1_M3_public"); + export var m1_im3_private_v1_public = m1_im3_private.c1; + export var m1_im3_private_v2_public = new m1_im3_private.c1(); + export var m1_im3_private_v3_public = m1_im3_private.f1; + export var m1_im3_private_v4_public = m1_im3_private.f1(); + var m1_im3_private_v1_private = m1_im3_private.c1; + var m1_im3_private_v2_private = new m1_im3_private.c1(); + var m1_im3_private_v3_private = m1_im3_private.f1; + var m1_im3_private_v4_private = m1_im3_private.f1(); + + import m1_im4_private = require("m1_M4_private"); + export var m1_im4_private_v1_public = m1_im4_private.c1; + export var m1_im4_private_v2_public = new m1_im4_private.c1(); + export var m1_im4_private_v3_public = m1_im4_private.f1; + export var m1_im4_private_v4_public = m1_im4_private.f1(); + var m1_im4_private_v1_private = m1_im4_private.c1; + var m1_im4_private_v2_private = new m1_im4_private.c1(); + var m1_im4_private_v3_private = m1_im4_private.f1; + var m1_im4_private_v4_private = m1_im4_private.f1(); + + export import m1_im1_public = m1_M1_public; + export import m1_im2_public = m1_M2_private; + export import m1_im3_public = require("m1_M3_public"); + export import m1_im4_public = require("m1_M4_private"); +} + +module glo_M1_public { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; +} + +declare module "glo_M2_public" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; +} + +declare module "use_glo_M1_public" { + import use_glo_M1_public = glo_M1_public; + export var use_glo_M1_public_v1_public: { new (): use_glo_M1_public.c1; }; + export var use_glo_M1_public_v2_public: typeof use_glo_M1_public; + export var use_glo_M1_public_v3_public: ()=> use_glo_M1_public.c1; + var use_glo_M1_public_v1_private: { new (): use_glo_M1_public.c1; }; + var use_glo_M1_public_v2_private: typeof use_glo_M1_public; + var use_glo_M1_public_v3_private: () => use_glo_M1_public.c1; + + import use_glo_M2_public = require("glo_M2_public"); + export var use_glo_M2_public_v1_public: { new (): use_glo_M2_public.c1; }; + export var use_glo_M2_public_v2_public: typeof use_glo_M2_public; + export var use_glo_M2_public_v3_public: () => use_glo_M2_public.c1; + var use_glo_M2_public_v1_private: { new (): use_glo_M2_public.c1; }; + var use_glo_M2_public_v2_private: typeof use_glo_M2_public; + var use_glo_M2_public_v3_private: () => use_glo_M2_public.c1; + + module m2 { + import errorImport = require("glo_M2_public"); + import nonerrorImport = glo_M1_public; + + module m5 { + import m5_errorImport = require("glo_M2_public"); + import m5_nonerrorImport = glo_M1_public; + } + } +} + +declare module "anotherParseError" { + module m2 { + declare module "abc" { + } + } + + module m2 { + module "abc2" { + } + } + module "abc3" { + } +} + +module m2 { + import m3 = require("use_glo_M1_public"); + module m4 { + var a = 10; + import m2 = require("use_glo_M1_public"); + } + +} + +//// [privacyGloImportParseErrors.js] +var m1; +(function (m1) { + var m1_M1_public; + (function (m1_M1_public) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + m1_M1_public.c1 = c1; + function f1() { + return new c1; + } + m1_M1_public.f1 = f1; + m1_M1_public.v1 = c1; + m1_M1_public.v2; + })(m1_M1_public = m1.m1_M1_public || (m1.m1_M1_public = {})); + var m1_M2_private; + (function (m1_M2_private) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + m1_M2_private.c1 = c1; + function f1() { + return new c1; + } + m1_M2_private.f1 = f1; + m1_M2_private.v1 = c1; + m1_M2_private.v2; + })(m1_M2_private || (m1_M2_private = {})); + var m1_im1_private = m1_M1_public; + m1.m1_im1_private_v1_public = m1_im1_private.c1; + m1.m1_im1_private_v2_public = new m1_im1_private.c1(); + m1.m1_im1_private_v3_public = m1_im1_private.f1; + m1.m1_im1_private_v4_public = m1_im1_private.f1(); + var m1_im1_private_v1_private = m1_im1_private.c1; + var m1_im1_private_v2_private = new m1_im1_private.c1(); + var m1_im1_private_v3_private = m1_im1_private.f1; + var m1_im1_private_v4_private = m1_im1_private.f1(); + var m1_im2_private = m1_M2_private; + m1.m1_im2_private_v1_public = m1_im2_private.c1; + m1.m1_im2_private_v2_public = new m1_im2_private.c1(); + m1.m1_im2_private_v3_public = m1_im2_private.f1; + m1.m1_im2_private_v4_public = m1_im2_private.f1(); + var m1_im2_private_v1_private = m1_im2_private.c1; + var m1_im2_private_v2_private = new m1_im2_private.c1(); + var m1_im2_private_v3_private = m1_im2_private.f1; + var m1_im2_private_v4_private = m1_im2_private.f1(); + var m1_im3_private = require("m1_M3_public"); + m1.m1_im3_private_v1_public = m1_im3_private.c1; + m1.m1_im3_private_v2_public = new m1_im3_private.c1(); + m1.m1_im3_private_v3_public = m1_im3_private.f1; + m1.m1_im3_private_v4_public = m1_im3_private.f1(); + var m1_im3_private_v1_private = m1_im3_private.c1; + var m1_im3_private_v2_private = new m1_im3_private.c1(); + var m1_im3_private_v3_private = m1_im3_private.f1; + var m1_im3_private_v4_private = m1_im3_private.f1(); + var m1_im4_private = require("m1_M4_private"); + m1.m1_im4_private_v1_public = m1_im4_private.c1; + m1.m1_im4_private_v2_public = new m1_im4_private.c1(); + m1.m1_im4_private_v3_public = m1_im4_private.f1; + m1.m1_im4_private_v4_public = m1_im4_private.f1(); + var m1_im4_private_v1_private = m1_im4_private.c1; + var m1_im4_private_v2_private = new m1_im4_private.c1(); + var m1_im4_private_v3_private = m1_im4_private.f1; + var m1_im4_private_v4_private = m1_im4_private.f1(); + m1.m1_im1_public = m1_M1_public; + m1.m1_im2_public = m1_M2_private; +})(m1 || (m1 = {})); +var glo_M1_public; +(function (glo_M1_public) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + glo_M1_public.c1 = c1; + function f1() { + return new c1; + } + glo_M1_public.f1 = f1; + glo_M1_public.v1 = c1; + glo_M1_public.v2; +})(glo_M1_public || (glo_M1_public = {})); +var m2; +(function (m2) { + var m4; + (function (m4) { + var a = 10; + })(m4 || (m4 = {})); +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/privacyImportParseErrors.errors.txt b/tests/baselines/reference/privacyImportParseErrors.errors.txt index a81bfbe738b..ca2734fe126 100644 --- a/tests/baselines/reference/privacyImportParseErrors.errors.txt +++ b/tests/baselines/reference/privacyImportParseErrors.errors.txt @@ -5,7 +5,9 @@ tests/cases/compiler/privacyImportParseErrors.ts(59,37): error TS2307: Cannot fi tests/cases/compiler/privacyImportParseErrors.ts(69,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(69,37): error TS2307: Cannot find external module 'm1_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(81,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(81,43): error TS2307: Cannot find external module 'm1_M3_public'. tests/cases/compiler/privacyImportParseErrors.ts(82,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(82,43): error TS2307: Cannot find external module 'm1_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(106,27): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(114,20): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(143,37): error TS1147: Import declarations in an internal module cannot reference an external module. @@ -13,7 +15,9 @@ tests/cases/compiler/privacyImportParseErrors.ts(143,37): error TS2307: Cannot f tests/cases/compiler/privacyImportParseErrors.ts(153,37): error TS1147: Import declarations in an internal module cannot reference an external module. tests/cases/compiler/privacyImportParseErrors.ts(153,37): error TS2307: Cannot find external module 'm2_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(166,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(166,43): error TS2307: Cannot find external module 'm2_M3_public'. tests/cases/compiler/privacyImportParseErrors.ts(167,43): error TS1147: Import declarations in an internal module cannot reference an external module. +tests/cases/compiler/privacyImportParseErrors.ts(167,43): error TS2307: Cannot find external module 'm2_M4_private'. tests/cases/compiler/privacyImportParseErrors.ts(180,23): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(198,23): error TS2435: Ambient external modules cannot be nested in other modules. tests/cases/compiler/privacyImportParseErrors.ts(218,34): error TS2307: Cannot find external module 'glo_M2_public'. @@ -49,7 +53,7 @@ tests/cases/compiler/privacyImportParseErrors.ts(350,25): error TS1147: Import d tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import declarations in an internal module cannot reference an external module. -==== tests/cases/compiler/privacyImportParseErrors.ts (49 errors) ==== +==== tests/cases/compiler/privacyImportParseErrors.ts (53 errors) ==== export module m1 { export module m1_M1_public { export class c1 { @@ -145,9 +149,13 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d export import m1_im3_public = require("m1_M3_public"); ~~~~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'm1_M3_public'. export import m1_im4_public = require("m1_M4_private"); ~~~~~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'm1_M4_private'. } module m2 { @@ -246,9 +254,13 @@ tests/cases/compiler/privacyImportParseErrors.ts(353,29): error TS1147: Import d export import m1_im3_public = require("m2_M3_public"); ~~~~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'm2_M3_public'. export import m1_im4_public = require("m2_M4_private"); ~~~~~~~~~~~~~~~ !!! error TS1147: Import declarations in an internal module cannot reference an external module. + ~~~~~~~~~~~~~~~ +!!! error TS2307: Cannot find external module 'm2_M4_private'. } export module glo_M1_public { diff --git a/tests/baselines/reference/privacyImportParseErrors.js b/tests/baselines/reference/privacyImportParseErrors.js new file mode 100644 index 00000000000..d32c0255f78 --- /dev/null +++ b/tests/baselines/reference/privacyImportParseErrors.js @@ -0,0 +1,585 @@ +//// [privacyImportParseErrors.ts] +export module m1 { + export module m1_M1_public { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; + } + + module m1_M2_private { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; + } + + export declare module "m1_M3_public" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; + } + + declare module "m1_M4_private" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; + } + + import m1_im1_private = m1_M1_public; + export var m1_im1_private_v1_public = m1_im1_private.c1; + export var m1_im1_private_v2_public = new m1_im1_private.c1(); + export var m1_im1_private_v3_public = m1_im1_private.f1; + export var m1_im1_private_v4_public = m1_im1_private.f1(); + var m1_im1_private_v1_private = m1_im1_private.c1; + var m1_im1_private_v2_private = new m1_im1_private.c1(); + var m1_im1_private_v3_private = m1_im1_private.f1; + var m1_im1_private_v4_private = m1_im1_private.f1(); + + + import m1_im2_private = m1_M2_private; + export var m1_im2_private_v1_public = m1_im2_private.c1; + export var m1_im2_private_v2_public = new m1_im2_private.c1(); + export var m1_im2_private_v3_public = m1_im2_private.f1; + export var m1_im2_private_v4_public = m1_im2_private.f1(); + var m1_im2_private_v1_private = m1_im2_private.c1; + var m1_im2_private_v2_private = new m1_im2_private.c1(); + var m1_im2_private_v3_private = m1_im2_private.f1; + var m1_im2_private_v4_private = m1_im2_private.f1(); + + import m1_im3_private = require("m1_M3_public"); + export var m1_im3_private_v1_public = m1_im3_private.c1; + export var m1_im3_private_v2_public = new m1_im3_private.c1(); + export var m1_im3_private_v3_public = m1_im3_private.f1; + export var m1_im3_private_v4_public = m1_im3_private.f1(); + var m1_im3_private_v1_private = m1_im3_private.c1; + var m1_im3_private_v2_private = new m1_im3_private.c1(); + var m1_im3_private_v3_private = m1_im3_private.f1; + var m1_im3_private_v4_private = m1_im3_private.f1(); + + import m1_im4_private = require("m1_M4_private"); + export var m1_im4_private_v1_public = m1_im4_private.c1; + export var m1_im4_private_v2_public = new m1_im4_private.c1(); + export var m1_im4_private_v3_public = m1_im4_private.f1; + export var m1_im4_private_v4_public = m1_im4_private.f1(); + var m1_im4_private_v1_private = m1_im4_private.c1; + var m1_im4_private_v2_private = new m1_im4_private.c1(); + var m1_im4_private_v3_private = m1_im4_private.f1; + var m1_im4_private_v4_private = m1_im4_private.f1(); + + export import m1_im1_public = m1_M1_public; + export import m1_im2_public = m1_M2_private; + export import m1_im3_public = require("m1_M3_public"); + export import m1_im4_public = require("m1_M4_private"); +} + +module m2 { + export module m2_M1_public { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; + } + + module m2_M2_private { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; + } + + export declare module "m2_M3_public" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; + } + + declare module "m2_M4_private" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; + } + + import m1_im1_private = m2_M1_public; + export var m1_im1_private_v1_public = m1_im1_private.c1; + export var m1_im1_private_v2_public = new m1_im1_private.c1(); + export var m1_im1_private_v3_public = m1_im1_private.f1; + export var m1_im1_private_v4_public = m1_im1_private.f1(); + var m1_im1_private_v1_private = m1_im1_private.c1; + var m1_im1_private_v2_private = new m1_im1_private.c1(); + var m1_im1_private_v3_private = m1_im1_private.f1; + var m1_im1_private_v4_private = m1_im1_private.f1(); + + + import m1_im2_private = m2_M2_private; + export var m1_im2_private_v1_public = m1_im2_private.c1; + export var m1_im2_private_v2_public = new m1_im2_private.c1(); + export var m1_im2_private_v3_public = m1_im2_private.f1; + export var m1_im2_private_v4_public = m1_im2_private.f1(); + var m1_im2_private_v1_private = m1_im2_private.c1; + var m1_im2_private_v2_private = new m1_im2_private.c1(); + var m1_im2_private_v3_private = m1_im2_private.f1; + var m1_im2_private_v4_private = m1_im2_private.f1(); + + import m1_im3_private = require("m2_M3_public"); + export var m1_im3_private_v1_public = m1_im3_private.c1; + export var m1_im3_private_v2_public = new m1_im3_private.c1(); + export var m1_im3_private_v3_public = m1_im3_private.f1; + export var m1_im3_private_v4_public = m1_im3_private.f1(); + var m1_im3_private_v1_private = m1_im3_private.c1; + var m1_im3_private_v2_private = new m1_im3_private.c1(); + var m1_im3_private_v3_private = m1_im3_private.f1; + var m1_im3_private_v4_private = m1_im3_private.f1(); + + import m1_im4_private = require("m2_M4_private"); + export var m1_im4_private_v1_public = m1_im4_private.c1; + export var m1_im4_private_v2_public = new m1_im4_private.c1(); + export var m1_im4_private_v3_public = m1_im4_private.f1; + export var m1_im4_private_v4_public = m1_im4_private.f1(); + var m1_im4_private_v1_private = m1_im4_private.c1; + var m1_im4_private_v2_private = new m1_im4_private.c1(); + var m1_im4_private_v3_private = m1_im4_private.f1; + var m1_im4_private_v4_private = m1_im4_private.f1(); + + // Parse error to export module + export import m1_im1_public = m2_M1_public; + export import m1_im2_public = m2_M2_private; + export import m1_im3_public = require("m2_M3_public"); + export import m1_im4_public = require("m2_M4_private"); +} + +export module glo_M1_public { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; +} + +export declare module "glo_M2_public" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; +} + +export module glo_M3_private { + export class c1 { + } + export function f1() { + return new c1; + } + export var v1 = c1; + export var v2: c1; +} + +export declare module "glo_M4_private" { + export function f1(); + export class c1 { + } + export var v1: { new (): c1; }; + export var v2: c1; +} + + +import glo_im1_private = glo_M1_public; +export var glo_im1_private_v1_public = glo_im1_private.c1; +export var glo_im1_private_v2_public = new glo_im1_private.c1(); +export var glo_im1_private_v3_public = glo_im1_private.f1; +export var glo_im1_private_v4_public = glo_im1_private.f1(); +var glo_im1_private_v1_private = glo_im1_private.c1; +var glo_im1_private_v2_private = new glo_im1_private.c1(); +var glo_im1_private_v3_private = glo_im1_private.f1; +var glo_im1_private_v4_private = glo_im1_private.f1(); + + +import glo_im2_private = require("glo_M2_public"); +export var glo_im2_private_v1_public = glo_im2_private.c1; +export var glo_im2_private_v2_public = new glo_im2_private.c1(); +export var glo_im2_private_v3_public = glo_im2_private.f1; +export var glo_im2_private_v4_public = glo_im2_private.f1(); +var glo_im2_private_v1_private = glo_im2_private.c1; +var glo_im2_private_v2_private = new glo_im2_private.c1(); +var glo_im2_private_v3_private = glo_im2_private.f1; +var glo_im2_private_v4_private = glo_im2_private.f1(); + +import glo_im3_private = glo_M3_private; +export var glo_im3_private_v1_public = glo_im3_private.c1; +export var glo_im3_private_v2_public = new glo_im3_private.c1(); +export var glo_im3_private_v3_public = glo_im3_private.f1; +export var glo_im3_private_v4_public = glo_im3_private.f1(); +var glo_im3_private_v1_private = glo_im3_private.c1; +var glo_im3_private_v2_private = new glo_im3_private.c1(); +var glo_im3_private_v3_private = glo_im3_private.f1; +var glo_im3_private_v4_private = glo_im3_private.f1(); + +import glo_im4_private = require("glo_M4_private"); +export var glo_im4_private_v1_public = glo_im4_private.c1; +export var glo_im4_private_v2_public = new glo_im4_private.c1(); +export var glo_im4_private_v3_public = glo_im4_private.f1; +export var glo_im4_private_v4_public = glo_im4_private.f1(); +var glo_im4_private_v1_private = glo_im4_private.c1; +var glo_im4_private_v2_private = new glo_im4_private.c1(); +var glo_im4_private_v3_private = glo_im4_private.f1; +var glo_im4_private_v4_private = glo_im4_private.f1(); + +// Parse error to export module +export import glo_im1_public = glo_M1_public; +export import glo_im2_public = glo_M3_private; +export import glo_im3_public = require("glo_M2_public"); +export import glo_im4_public = require("glo_M4_private"); + + +export declare module "use_glo_M1_public" { + import use_glo_M1_public = glo_M1_public; + export var use_glo_M1_public_v1_public: { new (): use_glo_M1_public.c1; }; + export var use_glo_M1_public_v2_public: use_glo_M1_public; + export var use_glo_M1_public_v3_public: () => use_glo_M1_public.c1; + var use_glo_M1_public_v1_private: { new (): use_glo_M1_public.c1; }; + var use_glo_M1_public_v2_private: use_glo_M1_public; + var use_glo_M1_public_v3_private: () => use_glo_M1_public.c1; + + import use_glo_M2_public = require("glo_M2_public"); + export var use_glo_M2_public_v1_public: { new (): use_glo_M2_public.c1; }; + export var use_glo_M2_public_v2_public: use_glo_M2_public; + export var use_glo_M2_public_v3_public: () => use_glo_M2_public.c1; + var use_glo_M2_public_v1_private: { new (): use_glo_M2_public.c1; }; + var use_glo_M2_public_v2_private: use_glo_M2_public; + var use_glo_M2_public_v3_private: () => use_glo_M2_public.c1; + + module m2 { + import errorImport = require("glo_M2_public"); + import nonerrorImport = glo_M1_public; + + module m5 { + import m5_errorImport = require("glo_M2_public"); + import m5_nonerrorImport = glo_M1_public; + } + } +} + + +declare module "use_glo_M3_private" { + import use_glo_M3_private = glo_M3_private; + export var use_glo_M3_private_v1_public: { new (): use_glo_M3_private.c1; }; + export var use_glo_M3_private_v2_public: use_glo_M3_private; + export var use_glo_M3_private_v3_public: () => use_glo_M3_private.c1; + var use_glo_M3_private_v1_private: { new (): use_glo_M3_private.c1; }; + var use_glo_M3_private_v2_private: use_glo_M3_private; + var use_glo_M3_private_v3_private: () => use_glo_M3_private.c1; + + import use_glo_M4_private = require("glo_M4_private"); + export var use_glo_M4_private_v1_public: { new (): use_glo_M4_private.c1; }; + export var use_glo_M4_private_v2_public: use_glo_M4_private; + export var use_glo_M4_private_v3_public: () => use_glo_M4_private.c1; + var use_glo_M4_private_v1_private: { new (): use_glo_M4_private.c1; }; + var use_glo_M4_private_v2_private: use_glo_M4_private; + var use_glo_M4_private_v3_private: () => use_glo_M4_private.c1; + + module m2 { + import errorImport = require("glo_M4_private"); + import nonerrorImport = glo_M3_private; + + module m5 { + import m5_errorImport = require("glo_M4_private"); + import m5_nonerrorImport = glo_M3_private; + } + } +} + +declare module "anotherParseError" { + module m2 { + declare module "abc" { + } + } + + module m2 { + module "abc2" { + } + } + module "abc3" { + } +} + +declare export module "anotherParseError2" { + module m2 { + declare module "abc" { + } + } + + module m2 { + module "abc2" { + } + } + module "abc3" { + } +} + +module m2 { + import m3 = require("use_glo_M1_public"); + module m4 { + var a = 10; + import m2 = require("use_glo_M1_public"); + } + +} + +export module m3 { + import m3 = require("use_glo_M1_public"); + module m4 { + var a = 10; + import m2 = require("use_glo_M1_public"); + } + +} + +//// [privacyImportParseErrors.js] +var m1; +(function (m1) { + var m1_M1_public; + (function (m1_M1_public) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + m1_M1_public.c1 = c1; + function f1() { + return new c1; + } + m1_M1_public.f1 = f1; + m1_M1_public.v1 = c1; + m1_M1_public.v2; + })(m1_M1_public = m1.m1_M1_public || (m1.m1_M1_public = {})); + var m1_M2_private; + (function (m1_M2_private) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + m1_M2_private.c1 = c1; + function f1() { + return new c1; + } + m1_M2_private.f1 = f1; + m1_M2_private.v1 = c1; + m1_M2_private.v2; + })(m1_M2_private || (m1_M2_private = {})); + var m1_im1_private = m1_M1_public; + m1.m1_im1_private_v1_public = m1_im1_private.c1; + m1.m1_im1_private_v2_public = new m1_im1_private.c1(); + m1.m1_im1_private_v3_public = m1_im1_private.f1; + m1.m1_im1_private_v4_public = m1_im1_private.f1(); + var m1_im1_private_v1_private = m1_im1_private.c1; + var m1_im1_private_v2_private = new m1_im1_private.c1(); + var m1_im1_private_v3_private = m1_im1_private.f1; + var m1_im1_private_v4_private = m1_im1_private.f1(); + var m1_im2_private = m1_M2_private; + m1.m1_im2_private_v1_public = m1_im2_private.c1; + m1.m1_im2_private_v2_public = new m1_im2_private.c1(); + m1.m1_im2_private_v3_public = m1_im2_private.f1; + m1.m1_im2_private_v4_public = m1_im2_private.f1(); + var m1_im2_private_v1_private = m1_im2_private.c1; + var m1_im2_private_v2_private = new m1_im2_private.c1(); + var m1_im2_private_v3_private = m1_im2_private.f1; + var m1_im2_private_v4_private = m1_im2_private.f1(); + var m1_im3_private = require("m1_M3_public"); + m1.m1_im3_private_v1_public = m1_im3_private.c1; + m1.m1_im3_private_v2_public = new m1_im3_private.c1(); + m1.m1_im3_private_v3_public = m1_im3_private.f1; + m1.m1_im3_private_v4_public = m1_im3_private.f1(); + var m1_im3_private_v1_private = m1_im3_private.c1; + var m1_im3_private_v2_private = new m1_im3_private.c1(); + var m1_im3_private_v3_private = m1_im3_private.f1; + var m1_im3_private_v4_private = m1_im3_private.f1(); + var m1_im4_private = require("m1_M4_private"); + m1.m1_im4_private_v1_public = m1_im4_private.c1; + m1.m1_im4_private_v2_public = new m1_im4_private.c1(); + m1.m1_im4_private_v3_public = m1_im4_private.f1; + m1.m1_im4_private_v4_public = m1_im4_private.f1(); + var m1_im4_private_v1_private = m1_im4_private.c1; + var m1_im4_private_v2_private = new m1_im4_private.c1(); + var m1_im4_private_v3_private = m1_im4_private.f1; + var m1_im4_private_v4_private = m1_im4_private.f1(); + m1.m1_im1_public = m1_M1_public; + m1.m1_im2_public = m1_M2_private; +})(m1 = exports.m1 || (exports.m1 = {})); +var m2; +(function (m2) { + var m2_M1_public; + (function (m2_M1_public) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + m2_M1_public.c1 = c1; + function f1() { + return new c1; + } + m2_M1_public.f1 = f1; + m2_M1_public.v1 = c1; + m2_M1_public.v2; + })(m2_M1_public = m2.m2_M1_public || (m2.m2_M1_public = {})); + var m2_M2_private; + (function (m2_M2_private) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + m2_M2_private.c1 = c1; + function f1() { + return new c1; + } + m2_M2_private.f1 = f1; + m2_M2_private.v1 = c1; + m2_M2_private.v2; + })(m2_M2_private || (m2_M2_private = {})); + var m1_im1_private = m2_M1_public; + m2.m1_im1_private_v1_public = m1_im1_private.c1; + m2.m1_im1_private_v2_public = new m1_im1_private.c1(); + m2.m1_im1_private_v3_public = m1_im1_private.f1; + m2.m1_im1_private_v4_public = m1_im1_private.f1(); + var m1_im1_private_v1_private = m1_im1_private.c1; + var m1_im1_private_v2_private = new m1_im1_private.c1(); + var m1_im1_private_v3_private = m1_im1_private.f1; + var m1_im1_private_v4_private = m1_im1_private.f1(); + var m1_im2_private = m2_M2_private; + m2.m1_im2_private_v1_public = m1_im2_private.c1; + m2.m1_im2_private_v2_public = new m1_im2_private.c1(); + m2.m1_im2_private_v3_public = m1_im2_private.f1; + m2.m1_im2_private_v4_public = m1_im2_private.f1(); + var m1_im2_private_v1_private = m1_im2_private.c1; + var m1_im2_private_v2_private = new m1_im2_private.c1(); + var m1_im2_private_v3_private = m1_im2_private.f1; + var m1_im2_private_v4_private = m1_im2_private.f1(); + var m1_im3_private = require("m2_M3_public"); + m2.m1_im3_private_v1_public = m1_im3_private.c1; + m2.m1_im3_private_v2_public = new m1_im3_private.c1(); + m2.m1_im3_private_v3_public = m1_im3_private.f1; + m2.m1_im3_private_v4_public = m1_im3_private.f1(); + var m1_im3_private_v1_private = m1_im3_private.c1; + var m1_im3_private_v2_private = new m1_im3_private.c1(); + var m1_im3_private_v3_private = m1_im3_private.f1; + var m1_im3_private_v4_private = m1_im3_private.f1(); + var m1_im4_private = require("m2_M4_private"); + m2.m1_im4_private_v1_public = m1_im4_private.c1; + m2.m1_im4_private_v2_public = new m1_im4_private.c1(); + m2.m1_im4_private_v3_public = m1_im4_private.f1; + m2.m1_im4_private_v4_public = m1_im4_private.f1(); + var m1_im4_private_v1_private = m1_im4_private.c1; + var m1_im4_private_v2_private = new m1_im4_private.c1(); + var m1_im4_private_v3_private = m1_im4_private.f1; + var m1_im4_private_v4_private = m1_im4_private.f1(); + // Parse error to export module + m2.m1_im1_public = m2_M1_public; + m2.m1_im2_public = m2_M2_private; +})(m2 || (m2 = {})); +var glo_M1_public; +(function (glo_M1_public) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + glo_M1_public.c1 = c1; + function f1() { + return new c1; + } + glo_M1_public.f1 = f1; + glo_M1_public.v1 = c1; + glo_M1_public.v2; +})(glo_M1_public = exports.glo_M1_public || (exports.glo_M1_public = {})); +var glo_M3_private; +(function (glo_M3_private) { + var c1 = (function () { + function c1() { + } + return c1; + })(); + glo_M3_private.c1 = c1; + function f1() { + return new c1; + } + glo_M3_private.f1 = f1; + glo_M3_private.v1 = c1; + glo_M3_private.v2; +})(glo_M3_private = exports.glo_M3_private || (exports.glo_M3_private = {})); +var glo_im1_private = glo_M1_public; +exports.glo_im1_private_v1_public = glo_im1_private.c1; +exports.glo_im1_private_v2_public = new glo_im1_private.c1(); +exports.glo_im1_private_v3_public = glo_im1_private.f1; +exports.glo_im1_private_v4_public = glo_im1_private.f1(); +var glo_im1_private_v1_private = glo_im1_private.c1; +var glo_im1_private_v2_private = new glo_im1_private.c1(); +var glo_im1_private_v3_private = glo_im1_private.f1; +var glo_im1_private_v4_private = glo_im1_private.f1(); +var glo_im2_private = require("glo_M2_public"); +exports.glo_im2_private_v1_public = glo_im2_private.c1; +exports.glo_im2_private_v2_public = new glo_im2_private.c1(); +exports.glo_im2_private_v3_public = glo_im2_private.f1; +exports.glo_im2_private_v4_public = glo_im2_private.f1(); +var glo_im2_private_v1_private = glo_im2_private.c1; +var glo_im2_private_v2_private = new glo_im2_private.c1(); +var glo_im2_private_v3_private = glo_im2_private.f1; +var glo_im2_private_v4_private = glo_im2_private.f1(); +var glo_im3_private = glo_M3_private; +exports.glo_im3_private_v1_public = glo_im3_private.c1; +exports.glo_im3_private_v2_public = new glo_im3_private.c1(); +exports.glo_im3_private_v3_public = glo_im3_private.f1; +exports.glo_im3_private_v4_public = glo_im3_private.f1(); +var glo_im3_private_v1_private = glo_im3_private.c1; +var glo_im3_private_v2_private = new glo_im3_private.c1(); +var glo_im3_private_v3_private = glo_im3_private.f1; +var glo_im3_private_v4_private = glo_im3_private.f1(); +var glo_im4_private = require("glo_M4_private"); +exports.glo_im4_private_v1_public = glo_im4_private.c1; +exports.glo_im4_private_v2_public = new glo_im4_private.c1(); +exports.glo_im4_private_v3_public = glo_im4_private.f1; +exports.glo_im4_private_v4_public = glo_im4_private.f1(); +var glo_im4_private_v1_private = glo_im4_private.c1; +var glo_im4_private_v2_private = new glo_im4_private.c1(); +var glo_im4_private_v3_private = glo_im4_private.f1; +var glo_im4_private_v4_private = glo_im4_private.f1(); +// Parse error to export module +exports.glo_im1_public = glo_M1_public; +exports.glo_im2_public = glo_M3_private; +var m2; +(function (m2) { + var m4; + (function (m4) { + var a = 10; + })(m4 || (m4 = {})); +})(m2 || (m2 = {})); +var m3; +(function (m3) { + var m4; + (function (m4) { + var a = 10; + })(m4 || (m4 = {})); +})(m3 = exports.m3 || (exports.m3 = {})); diff --git a/tests/baselines/reference/privateClassPropertyAccessibleWithinClass.js b/tests/baselines/reference/privateClassPropertyAccessibleWithinClass.js new file mode 100644 index 00000000000..61d1a44b121 --- /dev/null +++ b/tests/baselines/reference/privateClassPropertyAccessibleWithinClass.js @@ -0,0 +1,117 @@ +//// [privateClassPropertyAccessibleWithinClass.ts] +// no errors + +class C { + private x: string; + private get y() { return this.x; } + private set y(x) { this.y = this.x; } + private foo() { return this.foo; } + + private static x: string; + private static get y() { return this.x; } + private static set y(x) { this.y = this.x; } + private static foo() { return this.foo; } + private static bar() { this.foo(); } +} + +// added level of function nesting +class C2 { + private x: string; + private get y() { () => this.x; return null; } + private set y(x) { () => { this.y = this.x; } } + private foo() { () => this.foo; } + + private static x: string; + private static get y() { () => this.x; return null; } + private static set y(x) { + () => { this.y = this.x; } + } + private static foo() { () => this.foo; } + private static bar() { () => this.foo(); } +} + + +//// [privateClassPropertyAccessibleWithinClass.js] +// no errors +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "y", { + get: function () { + return this.x; + }, + set: function (x) { + this.y = this.x; + }, + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + return this.foo; + }; + Object.defineProperty(C, "y", { + get: function () { + return this.x; + }, + set: function (x) { + this.y = this.x; + }, + enumerable: true, + configurable: true + }); + C.foo = function () { + return this.foo; + }; + C.bar = function () { + this.foo(); + }; + return C; +})(); +// added level of function nesting +var C2 = (function () { + function C2() { + } + Object.defineProperty(C2.prototype, "y", { + get: function () { + var _this = this; + (function () { return _this.x; }); + return null; + }, + set: function (x) { + var _this = this; + (function () { + _this.y = _this.x; + }); + }, + enumerable: true, + configurable: true + }); + C2.prototype.foo = function () { + var _this = this; + (function () { return _this.foo; }); + }; + Object.defineProperty(C2, "y", { + get: function () { + var _this = this; + (function () { return _this.x; }); + return null; + }, + set: function (x) { + var _this = this; + (function () { + _this.y = _this.x; + }); + }, + enumerable: true, + configurable: true + }); + C2.foo = function () { + var _this = this; + (function () { return _this.foo; }); + }; + C2.bar = function () { + var _this = this; + (function () { return _this.foo(); }); + }; + return C2; +})(); diff --git a/tests/baselines/reference/privateIndexer.js b/tests/baselines/reference/privateIndexer.js new file mode 100644 index 00000000000..09f0c85ea5b --- /dev/null +++ b/tests/baselines/reference/privateIndexer.js @@ -0,0 +1,32 @@ +//// [privateIndexer.ts] +// private indexers not allowed + +class C { + private [x: string]: string; +} + +class D { + private [x: number]: string; +} + +class E { + private [x: string]: T; +} + +//// [privateIndexer.js] +// private indexers not allowed +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + return D; +})(); +var E = (function () { + function E() { + } + return E; +})(); diff --git a/tests/baselines/reference/project/intReferencingExtAndInt/amd/intReferencingExtAndInt.json b/tests/baselines/reference/project/intReferencingExtAndInt/amd/intReferencingExtAndInt.json index 0f1a27234f6..8febea7a2eb 100644 --- a/tests/baselines/reference/project/intReferencingExtAndInt/amd/intReferencingExtAndInt.json +++ b/tests/baselines/reference/project/intReferencingExtAndInt/amd/intReferencingExtAndInt.json @@ -8,5 +8,7 @@ "lib.d.ts", "internal2.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "internal2.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/intReferencingExtAndInt/node/intReferencingExtAndInt.json b/tests/baselines/reference/project/intReferencingExtAndInt/node/intReferencingExtAndInt.json index 0f1a27234f6..8febea7a2eb 100644 --- a/tests/baselines/reference/project/intReferencingExtAndInt/node/intReferencingExtAndInt.json +++ b/tests/baselines/reference/project/intReferencingExtAndInt/node/intReferencingExtAndInt.json @@ -8,5 +8,7 @@ "lib.d.ts", "internal2.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "internal2.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/nestedLocalModuleSimpleCase/amd/nestedLocalModuleSimpleCase.json b/tests/baselines/reference/project/nestedLocalModuleSimpleCase/amd/nestedLocalModuleSimpleCase.json index 7dfcd59ac7b..70843a6a43b 100644 --- a/tests/baselines/reference/project/nestedLocalModuleSimpleCase/amd/nestedLocalModuleSimpleCase.json +++ b/tests/baselines/reference/project/nestedLocalModuleSimpleCase/amd/nestedLocalModuleSimpleCase.json @@ -8,5 +8,7 @@ "lib.d.ts", "test1.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "test1.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/nestedLocalModuleSimpleCase/node/nestedLocalModuleSimpleCase.json b/tests/baselines/reference/project/nestedLocalModuleSimpleCase/node/nestedLocalModuleSimpleCase.json index 7dfcd59ac7b..70843a6a43b 100644 --- a/tests/baselines/reference/project/nestedLocalModuleSimpleCase/node/nestedLocalModuleSimpleCase.json +++ b/tests/baselines/reference/project/nestedLocalModuleSimpleCase/node/nestedLocalModuleSimpleCase.json @@ -8,5 +8,7 @@ "lib.d.ts", "test1.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "test1.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/amd/nestedLocalModuleWithRecursiveTypecheck.json b/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/amd/nestedLocalModuleWithRecursiveTypecheck.json index f871a22eae3..e31d3ce8a33 100644 --- a/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/amd/nestedLocalModuleWithRecursiveTypecheck.json +++ b/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/amd/nestedLocalModuleWithRecursiveTypecheck.json @@ -8,5 +8,7 @@ "lib.d.ts", "test1.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "test1.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/node/nestedLocalModuleWithRecursiveTypecheck.json b/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/node/nestedLocalModuleWithRecursiveTypecheck.json index f871a22eae3..e31d3ce8a33 100644 --- a/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/node/nestedLocalModuleWithRecursiveTypecheck.json +++ b/tests/baselines/reference/project/nestedLocalModuleWithRecursiveTypecheck/node/nestedLocalModuleWithRecursiveTypecheck.json @@ -8,5 +8,7 @@ "lib.d.ts", "test1.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "test1.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/privacyCheckOnImportedModuleDeclarationsInsideModule.json b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/privacyCheckOnImportedModuleDeclarationsInsideModule.json index b706c856acf..7c2ab06498a 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/privacyCheckOnImportedModuleDeclarationsInsideModule.json +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/privacyCheckOnImportedModuleDeclarationsInsideModule.json @@ -9,5 +9,7 @@ "lib.d.ts", "testGlo.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "testGlo.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js new file mode 100644 index 00000000000..ecbd4af1f59 --- /dev/null +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/amd/testGlo.js @@ -0,0 +1,63 @@ +var __extends = 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 m2; +(function (m2) { + m2.mExported = require("mExported"); + m2.c1 = new m2.mExported.me.class1; + function f1() { + return new m2.mExported.me.class1(); + } + m2.f1 = f1; + m2.x1 = m2.mExported.me.x; + var class1 = (function (_super) { + __extends(class1, _super); + function class1() { + _super.apply(this, arguments); + } + return class1; + })(mExported.me.class1); + m2.class1 = class1; + var c2 = new m2.mExported.me.class1; + function f2() { + return new m2.mExported.me.class1(); + } + var x2 = m2.mExported.me.x; + var class2 = (function (_super) { + __extends(class2, _super); + function class2() { + _super.apply(this, arguments); + } + return class2; + })(mExported.me.class1); + var mNonExported = require("mNonExported"); + m2.c3 = new mNonExported.mne.class1; + function f3() { + return new mNonExported.mne.class1(); + } + m2.f3 = f3; + m2.x3 = mNonExported.mne.x; + var class3 = (function (_super) { + __extends(class3, _super); + function class3() { + _super.apply(this, arguments); + } + return class3; + })(mNonExported.mne.class1); + m2.class3 = class3; + var c4 = new mNonExported.mne.class1; + function f4() { + return new mNonExported.mne.class1(); + } + var x4 = mNonExported.mne.x; + var class4 = (function (_super) { + __extends(class4, _super); + function class4() { + _super.apply(this, arguments); + } + return class4; + })(mNonExported.mne.class1); +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/privacyCheckOnImportedModuleDeclarationsInsideModule.json b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/privacyCheckOnImportedModuleDeclarationsInsideModule.json index b706c856acf..7c2ab06498a 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/privacyCheckOnImportedModuleDeclarationsInsideModule.json +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/privacyCheckOnImportedModuleDeclarationsInsideModule.json @@ -9,5 +9,7 @@ "lib.d.ts", "testGlo.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "testGlo.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js new file mode 100644 index 00000000000..ecbd4af1f59 --- /dev/null +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideModule/node/testGlo.js @@ -0,0 +1,63 @@ +var __extends = 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 m2; +(function (m2) { + m2.mExported = require("mExported"); + m2.c1 = new m2.mExported.me.class1; + function f1() { + return new m2.mExported.me.class1(); + } + m2.f1 = f1; + m2.x1 = m2.mExported.me.x; + var class1 = (function (_super) { + __extends(class1, _super); + function class1() { + _super.apply(this, arguments); + } + return class1; + })(mExported.me.class1); + m2.class1 = class1; + var c2 = new m2.mExported.me.class1; + function f2() { + return new m2.mExported.me.class1(); + } + var x2 = m2.mExported.me.x; + var class2 = (function (_super) { + __extends(class2, _super); + function class2() { + _super.apply(this, arguments); + } + return class2; + })(mExported.me.class1); + var mNonExported = require("mNonExported"); + m2.c3 = new mNonExported.mne.class1; + function f3() { + return new mNonExported.mne.class1(); + } + m2.f3 = f3; + m2.x3 = mNonExported.mne.x; + var class3 = (function (_super) { + __extends(class3, _super); + function class3() { + _super.apply(this, arguments); + } + return class3; + })(mNonExported.mne.class1); + m2.class3 = class3; + var c4 = new mNonExported.mne.class1; + function f4() { + return new mNonExported.mne.class1(); + } + var x4 = mNonExported.mne.x; + var class4 = (function (_super) { + __extends(class4, _super); + function class4() { + _super.apply(this, arguments); + } + return class4; + })(mNonExported.mne.class1); +})(m2 || (m2 = {})); diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/amd/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.json b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/amd/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.json index a82fe1088ef..3d6f6839114 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/amd/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.json +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/amd/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.json @@ -8,5 +8,7 @@ "lib.d.ts", "test.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "test.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/node/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.json b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/node/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.json index a82fe1088ef..3d6f6839114 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/node/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.json +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule/node/privacyCheckOnImportedModuleDeclarationsInsideNonExportedModule.json @@ -8,5 +8,7 @@ "lib.d.ts", "test.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "test.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/amd/privacyCheckOnImportedModuleImportStatementInParentModule.json b/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/amd/privacyCheckOnImportedModuleImportStatementInParentModule.json index 7da6f764326..6b6e79d9c0d 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/amd/privacyCheckOnImportedModuleImportStatementInParentModule.json +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/amd/privacyCheckOnImportedModuleImportStatementInParentModule.json @@ -8,5 +8,7 @@ "lib.d.ts", "test.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "test.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/node/privacyCheckOnImportedModuleImportStatementInParentModule.json b/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/node/privacyCheckOnImportedModuleImportStatementInParentModule.json index 7da6f764326..6b6e79d9c0d 100644 --- a/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/node/privacyCheckOnImportedModuleImportStatementInParentModule.json +++ b/tests/baselines/reference/project/privacyCheckOnImportedModuleImportStatementInParentModule/node/privacyCheckOnImportedModuleImportStatementInParentModule.json @@ -8,5 +8,7 @@ "lib.d.ts", "test.ts" ], - "emittedFiles": [] + "emittedFiles": [ + "test.js" + ] } \ No newline at end of file diff --git a/tests/baselines/reference/propertyAndAccessorWithSameName.js b/tests/baselines/reference/propertyAndAccessorWithSameName.js new file mode 100644 index 00000000000..f466483cede --- /dev/null +++ b/tests/baselines/reference/propertyAndAccessorWithSameName.js @@ -0,0 +1,60 @@ +//// [propertyAndAccessorWithSameName.ts] +class C { + x: number; + get x() { // error + return 1; + } +} + +class D { + x: number; + set x(v) { } // error +} + +class E { + private x: number; + get x() { // error + return 1; + } + set x(v) { } +} + +//// [propertyAndAccessorWithSameName.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var D = (function () { + function D() { + } + Object.defineProperty(D.prototype, "x", { + set: function (v) { + } // error + , + enumerable: true, + configurable: true + }); + return D; +})(); +var E = (function () { + function E() { + } + Object.defineProperty(E.prototype, "x", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return E; +})(); diff --git a/tests/baselines/reference/propertyAssignment.js b/tests/baselines/reference/propertyAssignment.js new file mode 100644 index 00000000000..9aa99c8b561 --- /dev/null +++ b/tests/baselines/reference/propertyAssignment.js @@ -0,0 +1,28 @@ +//// [propertyAssignment.ts] + + +var foo1: { new ():any; } +var bar1: { x : number; } + +var foo2: { [index]; } // should be an error, used to be indexer, now it is a computed property +var bar2: { x : number; } + +var foo3: { ():void; } +var bar3: { x : number; } + + + +foo1 = bar1; // should be an error +foo2 = bar2; +foo3 = bar3; // should be an error + +//// [propertyAssignment.js] +var foo1; +var bar1; +var foo2; // should be an error, used to be indexer, now it is a computed property +var bar2; +var foo3; +var bar3; +foo1 = bar1; // should be an error +foo2 = bar2; +foo3 = bar3; // should be an error diff --git a/tests/baselines/reference/protectedMembers.js b/tests/baselines/reference/protectedMembers.js new file mode 100644 index 00000000000..dd2e113d665 --- /dev/null +++ b/tests/baselines/reference/protectedMembers.js @@ -0,0 +1,261 @@ +//// [protectedMembers.ts] +// Class with protected members +class C1 { + protected x: number; + protected static sx: number; + protected f() { + return this.x; + } + protected static sf() { + return this.sx; + } +} + +// Derived class accessing protected members +class C2 extends C1 { + protected f() { + return super.f() + this.x; + } + protected static sf() { + return super.sf() + this.sx; + } +} + +// Derived class making protected members public +class C3 extends C2 { + x: number; + static sx: number; + f() { + return super.f(); + } + static sf() { + return super.sf(); + } +} + +var c1: C1; +var c2: C2; +var c3: C3; + +// All of these should be errors +c1.x; +c1.f(); +C1.sx; +C1.sf(); + +// All of these should be errors +c2.x; +c2.f(); +C2.sx; +C2.sf(); + +// All of these should be ok +c3.x; +c3.f(); +C3.sx; +C3.sf(); + +class A { + protected x; +} + +class B extends A { + y; +} + +class C extends A { + z; + static foo(a: A, b: B, c: C, d: D, e: E) { + a.x = 1; // Error, access must be through C or type derived from C + b.x = 1; // Error, access must be through C or type derived from C + c.x = 1; + d.x = 1; + e.x = 1; + } +} + +class D extends C { + d; +} + +interface E extends C { + e; +} + +class CC { + // Error, constructor cannot be protected + protected constructor() { + } +} + +class A1 { + protected x; +} +class B1 { + x; +} +var a1: A1; +var b1: B1; +a1 = b1; // Error, B1 doesn't derive from A1 +b1 = a1; // Error, x is protected in A1 but public in B1 + +class A2 { + protected x; +} +class B2 extends A2 { + x; +} + +class A3 { + x; +} +// Error x is protected in B3 but public in A3 +class B3 extends A3 { + protected x; +} + + + +//// [protectedMembers.js] +var __extends = 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 __(); +}; +// Class with protected members +var C1 = (function () { + function C1() { + } + C1.prototype.f = function () { + return this.x; + }; + C1.sf = function () { + return this.sx; + }; + return C1; +})(); +// Derived class accessing protected members +var C2 = (function (_super) { + __extends(C2, _super); + function C2() { + _super.apply(this, arguments); + } + C2.prototype.f = function () { + return _super.prototype.f.call(this) + this.x; + }; + C2.sf = function () { + return _super.sf.call(this) + this.sx; + }; + return C2; +})(C1); +// Derived class making protected members public +var C3 = (function (_super) { + __extends(C3, _super); + function C3() { + _super.apply(this, arguments); + } + C3.prototype.f = function () { + return _super.prototype.f.call(this); + }; + C3.sf = function () { + return _super.sf.call(this); + }; + return C3; +})(C2); +var c1; +var c2; +var c3; +// All of these should be errors +c1.x; +c1.f(); +C1.sx; +C1.sf(); +// All of these should be errors +c2.x; +c2.f(); +C2.sx; +C2.sf(); +// All of these should be ok +c3.x; +c3.f(); +C3.sx; +C3.sf(); +var A = (function () { + function A() { + } + return A; +})(); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +})(A); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + C.foo = function (a, b, c, d, e) { + a.x = 1; // Error, access must be through C or type derived from C + b.x = 1; // Error, access must be through C or type derived from C + c.x = 1; + d.x = 1; + e.x = 1; + }; + return C; +})(A); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.apply(this, arguments); + } + return D; +})(C); +var CC = (function () { + // Error, constructor cannot be protected + function CC() { + } + return CC; +})(); +var A1 = (function () { + function A1() { + } + return A1; +})(); +var B1 = (function () { + function B1() { + } + return B1; +})(); +var a1; +var b1; +a1 = b1; // Error, B1 doesn't derive from A1 +b1 = a1; // Error, x is protected in A1 but public in B1 +var A2 = (function () { + function A2() { + } + return A2; +})(); +var B2 = (function (_super) { + __extends(B2, _super); + function B2() { + _super.apply(this, arguments); + } + return B2; +})(A2); +var A3 = (function () { + function A3() { + } + return A3; +})(); +// Error x is protected in B3 but public in A3 +var B3 = (function (_super) { + __extends(B3, _super); + function B3() { + _super.apply(this, arguments); + } + return B3; +})(A3); diff --git a/tests/baselines/reference/publicIndexer.js b/tests/baselines/reference/publicIndexer.js new file mode 100644 index 00000000000..6fc5d81b62f --- /dev/null +++ b/tests/baselines/reference/publicIndexer.js @@ -0,0 +1,32 @@ +//// [publicIndexer.ts] +// public indexers not allowed + +class C { + public [x: string]: string; +} + +class D { + public [x: number]: string; +} + +class E { + public [x: string]: T; +} + +//// [publicIndexer.js] +// public indexers not allowed +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + return D; +})(); +var E = (function () { + function E() { + } + return E; +})(); diff --git a/tests/baselines/reference/quotedAccessorName1.js b/tests/baselines/reference/quotedAccessorName1.js new file mode 100644 index 00000000000..93fd5b8dd6b --- /dev/null +++ b/tests/baselines/reference/quotedAccessorName1.js @@ -0,0 +1,18 @@ +//// [quotedAccessorName1.ts] +class C { + get "foo"() { return 0; } +} + +//// [quotedAccessorName1.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "foo", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/quotedAccessorName2.js b/tests/baselines/reference/quotedAccessorName2.js new file mode 100644 index 00000000000..43041a29bf4 --- /dev/null +++ b/tests/baselines/reference/quotedAccessorName2.js @@ -0,0 +1,18 @@ +//// [quotedAccessorName2.ts] +class C { + static get "foo"() { return 0; } +} + +//// [quotedAccessorName2.js] +var C = (function () { + function C() { + } + Object.defineProperty(C, "foo", { + get: function () { + return 0; + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/quotedModuleNameMustBeAmbient.js b/tests/baselines/reference/quotedModuleNameMustBeAmbient.js new file mode 100644 index 00000000000..03973bb64a2 --- /dev/null +++ b/tests/baselines/reference/quotedModuleNameMustBeAmbient.js @@ -0,0 +1,6 @@ +//// [quotedModuleNameMustBeAmbient.ts] +module 'M' {} + +declare module 'M2' {} + +//// [quotedModuleNameMustBeAmbient.js] diff --git a/tests/baselines/reference/recursiveGetterAccess.js b/tests/baselines/reference/recursiveGetterAccess.js new file mode 100644 index 00000000000..cf042c2c1a0 --- /dev/null +++ b/tests/baselines/reference/recursiveGetterAccess.js @@ -0,0 +1,20 @@ +//// [recursiveGetterAccess.ts] +class MyClass { +get testProp() { return this.testProp; } +} + + + +//// [recursiveGetterAccess.js] +var MyClass = (function () { + function MyClass() { + } + Object.defineProperty(MyClass.prototype, "testProp", { + get: function () { + return this.testProp; + }, + enumerable: true, + configurable: true + }); + return MyClass; +})(); diff --git a/tests/baselines/reference/recursiveInferenceBug.js b/tests/baselines/reference/recursiveInferenceBug.js new file mode 100644 index 00000000000..cffa96415dc --- /dev/null +++ b/tests/baselines/reference/recursiveInferenceBug.js @@ -0,0 +1,25 @@ +//// [recursiveInferenceBug.ts] +function f(x: number) { + var z = f(x); + return x; +} + + +var zz = { + g: () =>{ }, + get f() { return "abc"; }, +}; + + +//// [recursiveInferenceBug.js] +function f(x) { + var z = f(x); + return x; +} +var zz = { + g: function () { + }, + get f() { + return "abc"; + } +}; diff --git a/tests/baselines/reference/recursiveSpecializationOfSignatures.js b/tests/baselines/reference/recursiveSpecializationOfSignatures.js new file mode 100644 index 00000000000..7542e85616a --- /dev/null +++ b/tests/baselines/reference/recursiveSpecializationOfSignatures.js @@ -0,0 +1,21 @@ +//// [recursiveSpecializationOfSignatures.ts] +class S0 { +set S1(S2: S0) { +} +constructor(public S17: S0 A>) { } +} + + +//// [recursiveSpecializationOfSignatures.js] +var S0 = (function () { + function S0(S17) { + this.S17 = S17; + } + Object.defineProperty(S0.prototype, "S1", { + set: function (S2) { + }, + enumerable: true, + configurable: true + }); + return S0; +})(); diff --git a/tests/baselines/reference/restParamAsOptional.js b/tests/baselines/reference/restParamAsOptional.js new file mode 100644 index 00000000000..59aea1cc9c4 --- /dev/null +++ b/tests/baselines/reference/restParamAsOptional.js @@ -0,0 +1,18 @@ +//// [restParamAsOptional.ts] +function f(...x?) { } +function f2(...x = []) { } + +//// [restParamAsOptional.js] +function f() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} +function f2() { + if (x === void 0) { x = []; } + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} diff --git a/tests/baselines/reference/restParameterNotLast.js b/tests/baselines/reference/restParameterNotLast.js new file mode 100644 index 00000000000..791d83849a1 --- /dev/null +++ b/tests/baselines/reference/restParameterNotLast.js @@ -0,0 +1,6 @@ +//// [restParameterNotLast.ts] +function f(...x, y) { } + +//// [restParameterNotLast.js] +function f(x, y) { +} diff --git a/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.js b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.js new file mode 100644 index 00000000000..c800c628c9c --- /dev/null +++ b/tests/baselines/reference/restParameterWithoutAnnotationIsAnyArray.js @@ -0,0 +1,80 @@ +//// [restParameterWithoutAnnotationIsAnyArray.ts] +// Rest parameters without type annotations are 'any', errors only for the functions with 2 rest params + +function foo(...x) { } +var f = function foo(...x) { } +var f2 = (...x, ...y) => { } + +class C { + foo(...x) { } +} + +interface I { + (...x); + foo(...x, ...y); +} + +var a: { + (...x); + foo(...x); +} + +var b = { + foo(...x) { }, + a: function foo(...x, ...y) { }, + b: (...x) => { } +} + + +//// [restParameterWithoutAnnotationIsAnyArray.js] +// Rest parameters without type annotations are 'any', errors only for the functions with 2 rest params +function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} +var f = function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +}; +var f2 = function (x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } +}; +var C = (function () { + function C() { + } + C.prototype.foo = function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }; + return C; +})(); +var a; +var b = { + foo: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }, + a: function foo(x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } + }, + b: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + } +}; diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes.js b/tests/baselines/reference/restParametersOfNonArrayTypes.js new file mode 100644 index 00000000000..f6f6a8af44d --- /dev/null +++ b/tests/baselines/reference/restParametersOfNonArrayTypes.js @@ -0,0 +1,79 @@ +//// [restParametersOfNonArrayTypes.ts] +// Rest parameters must be an array type if they have a type annotation, so all these are errors + +function foo(...x: string) { } +var f = function foo(...x: number) { } +var f2 = (...x: Date, ...y: boolean) => { } + +class C { + foo(...x: C) { } +} + +interface I { + (...x: string); + foo(...x: number, ...y: number); +} + +var a: { + (...x: string); + foo(...x: string); +} + +var b = { + foo(...x: string) { }, + a: function foo(...x: number, ...y: Date) { }, + b: (...x: string) => { } +} + +//// [restParametersOfNonArrayTypes.js] +// Rest parameters must be an array type if they have a type annotation, so all these are errors +function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} +var f = function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +}; +var f2 = function (x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } +}; +var C = (function () { + function C() { + } + C.prototype.foo = function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }; + return C; +})(); +var a; +var b = { + foo: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }, + a: function foo(x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } + }, + b: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + } +}; diff --git a/tests/baselines/reference/restParametersOfNonArrayTypes2.js b/tests/baselines/reference/restParametersOfNonArrayTypes2.js new file mode 100644 index 00000000000..73d0ddaeef2 --- /dev/null +++ b/tests/baselines/reference/restParametersOfNonArrayTypes2.js @@ -0,0 +1,161 @@ +//// [restParametersOfNonArrayTypes2.ts] +// Rest parameters must be an array type if they have a type annotation, +// user defined subtypes of array do not count, all of these are errors + +interface MyThing extends Array { } +interface MyThing2 extends Array { } + +function foo(...x: MyThing) { } +var f = function foo(...x: MyThing) { } +var f2 = (...x: MyThing, ...y: MyThing) => { } + +class C { + foo(...x: MyThing) { } +} + +interface I { + (...x: MyThing); + foo(...x: MyThing, ...y: MyThing); +} + +var a: { + (...x: MyThing); + foo(...x: MyThing); +} + +var b = { + foo(...x: MyThing) { }, + a: function foo(...x: MyThing, ...y: MyThing) { }, + b: (...x: MyThing) => { } +} + + + + +function foo2(...x: MyThing2) { } +var f3 = function foo(...x: MyThing2) { } +var f4 = (...x: MyThing2, ...y: MyThing2) => { } + +class C2 { + foo(...x: MyThing2) { } +} + +interface I2 { + (...x: MyThing2); + foo(...x: MyThing2, ...y: MyThing2); +} + +var a2: { + (...x: MyThing2); + foo(...x: MyThing2); +} + +var b2 = { + foo(...x: MyThing2) { }, + a: function foo(...x: MyThing2, ...y: MyThing2) { }, + b: (...x: MyThing2) => { } +} + +//// [restParametersOfNonArrayTypes2.js] +// Rest parameters must be an array type if they have a type annotation, +// user defined subtypes of array do not count, all of these are errors +function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} +var f = function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +}; +var f2 = function (x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } +}; +var C = (function () { + function C() { + } + C.prototype.foo = function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }; + return C; +})(); +var a; +var b = { + foo: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }, + a: function foo(x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } + }, + b: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + } +}; +function foo2() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} +var f3 = function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +}; +var f4 = function (x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } +}; +var C2 = (function () { + function C2() { + } + C2.prototype.foo = function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }; + return C2; +})(); +var a2; +var b2 = { + foo: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }, + a: function foo(x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } + }, + b: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + } +}; diff --git a/tests/baselines/reference/restParametersWithArrayTypeAnnotations.js b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.js new file mode 100644 index 00000000000..c7d1dee9295 --- /dev/null +++ b/tests/baselines/reference/restParametersWithArrayTypeAnnotations.js @@ -0,0 +1,156 @@ +//// [restParametersWithArrayTypeAnnotations.ts] +// Rest parameters must be an array type if they have a type annotation, errors only for the functions with 2 rest params + +function foo(...x: number[]) { } +var f = function foo(...x: number[]) { } +var f2 = (...x: number[], ...y: number[]) => { } + +class C { + foo(...x: number[]) { } +} + +interface I { + (...x: number[]); + foo(...x: number[], ...y: number[]); +} + +var a: { + (...x: number[]); + foo(...x: number[]); +} + +var b = { + foo(...x: number[]) { }, + a: function foo(...x: number[], ...y: number[]) { }, + b: (...x: number[]) => { } +} + + + + +function foo2(...x: Array) { } +var f3 = function foo(...x: Array) { } +var f4 = (...x: Array, ...y: Array) => { } + +class C2 { + foo(...x: Array) { } +} + +interface I2 { + (...x: Array); + foo(...x: Array, ...y: Array); +} + +var a2: { + (...x: Array); + foo(...x: Array); +} + +var b2 = { + foo(...x: Array) { }, + a: function foo(...x: Array, ...y: Array) { }, + b: (...x: Array) => { } +} + +//// [restParametersWithArrayTypeAnnotations.js] +// Rest parameters must be an array type if they have a type annotation, errors only for the functions with 2 rest params +function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} +var f = function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +}; +var f2 = function (x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } +}; +var C = (function () { + function C() { + } + C.prototype.foo = function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }; + return C; +})(); +var a; +var b = { + foo: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }, + a: function foo(x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } + }, + b: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + } +}; +function foo2() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +} +var f3 = function foo() { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } +}; +var f4 = function (x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } +}; +var C2 = (function () { + function C2() { + } + C2.prototype.foo = function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }; + return C2; +})(); +var a2; +var b2 = { + foo: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + }, + a: function foo(x) { + var y = []; + for (var _i = 1; _i < arguments.length; _i++) { + y[_i - 1] = arguments[_i]; + } + }, + b: function () { + var x = []; + for (var _i = 0; _i < arguments.length; _i++) { + x[_i - 0] = arguments[_i]; + } + } +}; diff --git a/tests/baselines/reference/returnValueInSetter.js b/tests/baselines/reference/returnValueInSetter.js new file mode 100644 index 00000000000..6774bab6c4e --- /dev/null +++ b/tests/baselines/reference/returnValueInSetter.js @@ -0,0 +1,22 @@ +//// [returnValueInSetter.ts] +class f { + set x(value) { + return null; // Should be an error + } +} + + + +//// [returnValueInSetter.js] +var f = (function () { + function f() { + } + Object.defineProperty(f.prototype, "x", { + set: function (value) { + return null; // Should be an error + }, + enumerable: true, + configurable: true + }); + return f; +})(); diff --git a/tests/baselines/reference/scannerNumericLiteral2.js b/tests/baselines/reference/scannerNumericLiteral2.js new file mode 100644 index 00000000000..382f1e6e4df --- /dev/null +++ b/tests/baselines/reference/scannerNumericLiteral2.js @@ -0,0 +1,5 @@ +//// [scannerNumericLiteral2.ts] +01 + +//// [scannerNumericLiteral2.js] +01; diff --git a/tests/baselines/reference/scannerNumericLiteral8.js b/tests/baselines/reference/scannerNumericLiteral8.js new file mode 100644 index 00000000000..6d5cf860d6c --- /dev/null +++ b/tests/baselines/reference/scannerNumericLiteral8.js @@ -0,0 +1,5 @@ +//// [scannerNumericLiteral8.ts] +-03 + +//// [scannerNumericLiteral8.js] +-03; diff --git a/tests/baselines/reference/semicolonsInModuleDeclarations.js b/tests/baselines/reference/semicolonsInModuleDeclarations.js new file mode 100644 index 00000000000..327fcbcde2f --- /dev/null +++ b/tests/baselines/reference/semicolonsInModuleDeclarations.js @@ -0,0 +1,13 @@ +//// [semicolonsInModuleDeclarations.ts] +declare module ambiModule { + export interface i1 { }; + export interface i2 { } +} + +var n1: ambiModule.i1; +var n2: ambiModule.i2; + + +//// [semicolonsInModuleDeclarations.js] +var n1; +var n2; diff --git a/tests/baselines/reference/setterBeforeGetter.js b/tests/baselines/reference/setterBeforeGetter.js new file mode 100644 index 00000000000..c897198c2dd --- /dev/null +++ b/tests/baselines/reference/setterBeforeGetter.js @@ -0,0 +1,31 @@ +//// [setterBeforeGetter.ts] +class Foo { + + private _bar: { a: string; }; + // should not be an error to order them this way + set bar(thing: { a: string; }) { + this._bar = thing; + } + get bar(): { a: string; } { + return this._bar; + } +} + + +//// [setterBeforeGetter.js] +var Foo = (function () { + function Foo() { + } + Object.defineProperty(Foo.prototype, "bar", { + get: function () { + return this._bar; + }, + // should not be an error to order them this way + set: function (thing) { + this._bar = thing; + }, + enumerable: true, + configurable: true + }); + return Foo; +})(); diff --git a/tests/baselines/reference/setterWithReturn.js b/tests/baselines/reference/setterWithReturn.js new file mode 100644 index 00000000000..995cde87509 --- /dev/null +++ b/tests/baselines/reference/setterWithReturn.js @@ -0,0 +1,30 @@ +//// [setterWithReturn.ts] +class C234 { + public set p1(arg1) { + if (true) { + return arg1; + } + else { + return 0; + } + } +} + +//// [setterWithReturn.js] +var C234 = (function () { + function C234() { + } + Object.defineProperty(C234.prototype, "p1", { + set: function (arg1) { + if (true) { + return arg1; + } + else { + return 0; + } + }, + enumerable: true, + configurable: true + }); + return C234; +})(); diff --git a/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.js b/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.js new file mode 100644 index 00000000000..d439cc3b020 --- /dev/null +++ b/tests/baselines/reference/spaceBeforeQuestionMarkInPropertyAssignment.js @@ -0,0 +1,5 @@ +//// [spaceBeforeQuestionMarkInPropertyAssignment.ts] +var x = {x ?: 1} // should not crash + +//// [spaceBeforeQuestionMarkInPropertyAssignment.js] +var x = { x: 1 }; // should not crash diff --git a/tests/baselines/reference/standaloneBreak.js b/tests/baselines/reference/standaloneBreak.js new file mode 100644 index 00000000000..aed2f7d666f --- /dev/null +++ b/tests/baselines/reference/standaloneBreak.js @@ -0,0 +1,5 @@ +//// [standaloneBreak.ts] +break; + +//// [standaloneBreak.js] +break; diff --git a/tests/baselines/reference/staticAsIdentifier.js b/tests/baselines/reference/staticAsIdentifier.js new file mode 100644 index 00000000000..36e317b2875 --- /dev/null +++ b/tests/baselines/reference/staticAsIdentifier.js @@ -0,0 +1,12 @@ +//// [staticAsIdentifier.ts] +class C { + static static + [x: string]: string; +} + +//// [staticAsIdentifier.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/staticGetter1.js b/tests/baselines/reference/staticGetter1.js new file mode 100644 index 00000000000..3772364804a --- /dev/null +++ b/tests/baselines/reference/staticGetter1.js @@ -0,0 +1,23 @@ +//// [staticGetter1.ts] +// once caused stack overflow +class C { + static get x() { + return this; + } +} + + +//// [staticGetter1.js] +// once caused stack overflow +var C = (function () { + function C() { + } + Object.defineProperty(C, "x", { + get: function () { + return this; + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/staticGetterAndSetter.js b/tests/baselines/reference/staticGetterAndSetter.js new file mode 100644 index 00000000000..7c6ef26e739 --- /dev/null +++ b/tests/baselines/reference/staticGetterAndSetter.js @@ -0,0 +1,22 @@ +//// [staticGetterAndSetter.ts] +class Foo { + static get Foo():number { return 0; } + static set Foo(n: number) {} +} + + +//// [staticGetterAndSetter.js] +var Foo = (function () { + function Foo() { + } + Object.defineProperty(Foo, "Foo", { + get: function () { + return 0; + }, + set: function (n) { + }, + enumerable: true, + configurable: true + }); + return Foo; +})(); diff --git a/tests/baselines/reference/staticIndexer.js b/tests/baselines/reference/staticIndexer.js new file mode 100644 index 00000000000..f945cf686b0 --- /dev/null +++ b/tests/baselines/reference/staticIndexer.js @@ -0,0 +1,11 @@ +//// [staticIndexer.ts] +class C { + static [s: string]: number; +} + +//// [staticIndexer.js] +var C = (function () { + function C() { + } + return C; +})(); diff --git a/tests/baselines/reference/staticIndexers.js b/tests/baselines/reference/staticIndexers.js new file mode 100644 index 00000000000..4c8a0bc1ec8 --- /dev/null +++ b/tests/baselines/reference/staticIndexers.js @@ -0,0 +1,32 @@ +//// [staticIndexers.ts] +// static indexers not allowed + +class C { + static [x: string]: string; +} + +class D { + static [x: number]: string; +} + +class E { + static [x: string]: T; +} + +//// [staticIndexers.js] +// static indexers not allowed +var C = (function () { + function C() { + } + return C; +})(); +var D = (function () { + function D() { + } + return D; +})(); +var E = (function () { + function E() { + } + return E; +})(); diff --git a/tests/baselines/reference/staticModifierAlreadySeen.js b/tests/baselines/reference/staticModifierAlreadySeen.js new file mode 100644 index 00000000000..b097f3924e4 --- /dev/null +++ b/tests/baselines/reference/staticModifierAlreadySeen.js @@ -0,0 +1,15 @@ +//// [staticModifierAlreadySeen.ts] +class C { + static static foo = 1; + public static static bar() { } +} + +//// [staticModifierAlreadySeen.js] +var C = (function () { + function C() { + } + C.bar = function () { + }; + C.foo = 1; + return C; +})(); diff --git a/tests/baselines/reference/staticMustPrecedePublic.js b/tests/baselines/reference/staticMustPrecedePublic.js new file mode 100644 index 00000000000..45882488e72 --- /dev/null +++ b/tests/baselines/reference/staticMustPrecedePublic.js @@ -0,0 +1,13 @@ +//// [staticMustPrecedePublic.ts] +class Outer { + static public intI: number; + static private stringF: string; +} + + +//// [staticMustPrecedePublic.js] +var Outer = (function () { + function Outer() { + } + return Outer; +})(); diff --git a/tests/baselines/reference/staticPropertyNotInClassType.js b/tests/baselines/reference/staticPropertyNotInClassType.js new file mode 100644 index 00000000000..22ff4276deb --- /dev/null +++ b/tests/baselines/reference/staticPropertyNotInClassType.js @@ -0,0 +1,104 @@ +//// [staticPropertyNotInClassType.ts] +module NonGeneric { + class C { + fn() { return this; } + static get x() { return 1; } + static set x(v) { } + constructor(public a: number, private b: number) { } + static foo: string; // not reflected in class type + } + + module C { + export var bar = ''; // not reflected in class type + } + + var c = new C(1, 2); + var r = c.fn(); + var r4 = c.foo; // error + var r5 = c.bar; // error + var r6 = c.x; // error +} + +module Generic { + class C { + fn() { return this; } + static get x() { return 1; } + static set x(v) { } + constructor(public a: T, private b: U) { } + static foo: T; // not reflected in class type + } + + module C { + export var bar = ''; // not reflected in class type + } + + var c = new C(1, ''); + var r = c.fn(); + var r4 = c.foo; // error + var r5 = c.bar; // error + var r6 = c.x; // error +} + +//// [staticPropertyNotInClassType.js] +var NonGeneric; +(function (NonGeneric) { + var C = (function () { + function C(a, b) { + this.a = a; + this.b = b; + } + C.prototype.fn = function () { + return this; + }; + Object.defineProperty(C, "x", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; + })(); + var C; + (function (C) { + C.bar = ''; // not reflected in class type + })(C || (C = {})); + var c = new C(1, 2); + var r = c.fn(); + var r4 = c.foo; // error + var r5 = c.bar; // error + var r6 = c.x; // error +})(NonGeneric || (NonGeneric = {})); +var Generic; +(function (Generic) { + var C = (function () { + function C(a, b) { + this.a = a; + this.b = b; + } + C.prototype.fn = function () { + return this; + }; + Object.defineProperty(C, "x", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return C; + })(); + var C; + (function (C) { + C.bar = ''; // not reflected in class type + })(C || (C = {})); + var c = new C(1, ''); + var r = c.fn(); + var r4 = c.foo; // error + var r5 = c.bar; // error + var r6 = c.x; // error +})(Generic || (Generic = {})); diff --git a/tests/baselines/reference/staticVisibility.js b/tests/baselines/reference/staticVisibility.js new file mode 100644 index 00000000000..0da2e3dbe2c --- /dev/null +++ b/tests/baselines/reference/staticVisibility.js @@ -0,0 +1,73 @@ +//// [staticVisibility.ts] + +class C1 { + + p: any; + static s: any; + + constructor() { + var v = 0; + + s = 1; // should be error + C1.s = 1; // should be ok + + b(); // should be error + C1.b(); // should be ok + } + + static b() { + v = 1; // should be error + this.p = 0; // should be error + C1.s = 1; // should be ok + } +} + +class C2 { + +barback:string = ""; + + + + +static get Bar() {return "bar";} // ok + +static set Bar(bar:string) {barback = bar;} // not ok + +} + + + +//// [staticVisibility.js] +var C1 = (function () { + function C1() { + var v = 0; + s = 1; // should be error + C1.s = 1; // should be ok + b(); // should be error + C1.b(); // should be ok + } + C1.b = function () { + v = 1; // should be error + this.p = 0; // should be error + C1.s = 1; // should be ok + }; + return C1; +})(); +var C2 = (function () { + function C2() { + this.barback = ""; + } + Object.defineProperty(C2, "Bar", { + get: function () { + return "bar"; + } // ok + , + set: function (bar) { + barback = bar; + } // not ok + , + enumerable: true, + configurable: true + }); + return C2; +})(); diff --git a/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.js b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.js new file mode 100644 index 00000000000..ed96311f526 --- /dev/null +++ b/tests/baselines/reference/stringIndexerConstrainsPropertyDeclarations.js @@ -0,0 +1,151 @@ +//// [stringIndexerConstrainsPropertyDeclarations.ts] +// String indexer types constrain the types of named properties in their containing type + +interface MyString extends String { + foo: number; +} + +class C { + [x: string]: string; + + constructor() { } // ok + + a: string; // ok + b: number; // error + c: () => {} // error + "d": string; // ok + "e": number; // error + 1.0: string; // ok + 2.0: number; // error + "3.0": string; // ok + "4.0": number; // error + f: MyString; // error + + get X() { // ok + return ''; + } + set X(v) { } // ok + + foo() { // error + return ''; + } + + static sa: number; // ok + static sb: string; // ok + + static foo() { } // ok + static get X() { // ok + return 1; + } +} + +interface I { + [x: string]: string; + + a: string; // ok + b: number; // error + c: () => {} // error + "d": string; // ok + "e": number; // error + 1.0: string; // ok + 2.0: number; // error + (): string; // ok + (x): number // ok + foo(): string; // error + "3.0": string; // ok + "4.0": number; // error + f: MyString; // error +} + +var a: { + [x: string]: string; + + a: string; // ok + b: number; // error + c: () => {} // error + "d": string; // ok + "e": number; // error + 1.0: string; // ok + 2.0: number; // error + (): string; // ok + (x): number // ok + foo(): string; // error + "3.0": string; // ok + "4.0": number; // error + f: MyString; // error +} + +// error +var b: { [x: string]: string; } = { + a: '', + b: 1, + c: () => { }, + "d": '', + "e": 1, + 1.0: '', + 2.0: 1, + "3.0": '', + "4.0": 1, + f: null, + + get X() { + return ''; + }, + set X(v) { }, + foo() { + return ''; + } +} + +//// [stringIndexerConstrainsPropertyDeclarations.js] +// String indexer types constrain the types of named properties in their containing type +var C = (function () { + function C() { + } // ok + Object.defineProperty(C.prototype, "X", { + get: function () { + return ''; + }, + set: function (v) { + } // ok + , + enumerable: true, + configurable: true + }); + C.prototype.foo = function () { + return ''; + }; + C.foo = function () { + }; // ok + Object.defineProperty(C, "X", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var a; +// error +var b = { + a: '', + b: 1, + c: function () { + }, + "d": '', + "e": 1, + 1.0: '', + 2.0: 1, + "3.0": '', + "4.0": 1, + f: null, + get X() { + return ''; + }, + set X(v) { + }, + foo: function () { + return ''; + } +}; diff --git a/tests/baselines/reference/superCallInNonStaticMethod.js b/tests/baselines/reference/superCallInNonStaticMethod.js new file mode 100644 index 00000000000..cf29ac3b1a4 --- /dev/null +++ b/tests/baselines/reference/superCallInNonStaticMethod.js @@ -0,0 +1,113 @@ +//// [superCallInNonStaticMethod.ts] +class Doing { + public instanceMethod() { + } +} + +class Other extends Doing { + // in instance method + public instanceMethod() { + super.instanceMethod(); + } + + // in a lambda inside a instance method + public lambdaInsideAnInstanceMethod() { + () => { + super.instanceMethod(); + } + } + + // in an object literal inside a instance method + public objectLiteralInsideAnInstanceMethod() { + return { + a: () => { + super.instanceMethod(); + }, + b: super.instanceMethod() + }; + } + + // in a getter + public get accessor() { + super.instanceMethod(); + + return 0; + } + + // in a setter + public set accessor(value: number) { + super.instanceMethod(); + } + + constructor() { + super(); + super.instanceMethod(); + } + + public propertyInitializer = super.instanceMethod(); + + public functionProperty = () => {super.instanceMethod(); }; +} + + +//// [superCallInNonStaticMethod.js] +var __extends = 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 Doing = (function () { + function Doing() { + } + Doing.prototype.instanceMethod = function () { + }; + return Doing; +})(); +var Other = (function (_super) { + __extends(Other, _super); + function Other() { + var _this = this; + _super.call(this); + this.propertyInitializer = _super.prototype.instanceMethod.call(this); + this.functionProperty = function () { + _super.prototype.instanceMethod.call(_this); + }; + _super.prototype.instanceMethod.call(this); + } + // in instance method + Other.prototype.instanceMethod = function () { + _super.prototype.instanceMethod.call(this); + }; + // in a lambda inside a instance method + Other.prototype.lambdaInsideAnInstanceMethod = function () { + var _this = this; + (function () { + _super.prototype.instanceMethod.call(_this); + }); + }; + // in an object literal inside a instance method + Other.prototype.objectLiteralInsideAnInstanceMethod = function () { + var _this = this; + return { + a: function () { + _super.prototype.instanceMethod.call(_this); + }, + b: _super.prototype.instanceMethod.call(this) + }; + }; + Object.defineProperty(Other.prototype, "accessor", { + // in a getter + get: function () { + _super.prototype.instanceMethod.call(this); + return 0; + }, + // in a setter + set: function (value) { + _super.prototype.instanceMethod.call(this); + }, + enumerable: true, + configurable: true + }); + return Other; +})(Doing); diff --git a/tests/baselines/reference/superCallInStaticMethod.js b/tests/baselines/reference/superCallInStaticMethod.js new file mode 100644 index 00000000000..820551724ac --- /dev/null +++ b/tests/baselines/reference/superCallInStaticMethod.js @@ -0,0 +1,108 @@ +//// [superCallInStaticMethod.ts] +class Doing { + public static staticMethod() { + } +} + +class Other extends Doing { + // in static method + public static staticMethod() { + super.staticMethod(); + } + + // in a lambda inside a static method + public static lambdaInsideAStaticMethod() { + () => { + super.staticMethod(); + } + } + + // in an object literal inside a static method + public static objectLiteralInsideAStaticMethod() { + return { + a: () => { + super.staticMethod(); + }, + b: super.staticMethod() + }; + } + + // in a getter + public static get staticGetter() { + super.staticMethod(); + + return 0; + } + + // in a setter + public static set staticGetter(value: number) { + super.staticMethod(); + } + + // in static method + public static initializerInAStaticMethod(a = super.staticMethod()) { + super.staticMethod(); + } +} + + +//// [superCallInStaticMethod.js] +var __extends = 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 Doing = (function () { + function Doing() { + } + Doing.staticMethod = function () { + }; + return Doing; +})(); +var Other = (function (_super) { + __extends(Other, _super); + function Other() { + _super.apply(this, arguments); + } + // in static method + Other.staticMethod = function () { + _super.staticMethod.call(this); + }; + // in a lambda inside a static method + Other.lambdaInsideAStaticMethod = function () { + var _this = this; + (function () { + _super.staticMethod.call(_this); + }); + }; + // in an object literal inside a static method + Other.objectLiteralInsideAStaticMethod = function () { + var _this = this; + return { + a: function () { + _super.staticMethod.call(_this); + }, + b: _super.staticMethod.call(this) + }; + }; + Object.defineProperty(Other, "staticGetter", { + // in a getter + get: function () { + _super.staticMethod.call(this); + return 0; + }, + // in a setter + set: function (value) { + _super.staticMethod.call(this); + }, + enumerable: true, + configurable: true + }); + // in static method + Other.initializerInAStaticMethod = function (a) { + if (a === void 0) { a = _super.staticMethod.call(this); } + _super.staticMethod.call(this); + }; + return Other; +})(Doing); diff --git a/tests/baselines/reference/superPropertyAccess.js b/tests/baselines/reference/superPropertyAccess.js new file mode 100644 index 00000000000..a9ee2352c76 --- /dev/null +++ b/tests/baselines/reference/superPropertyAccess.js @@ -0,0 +1,89 @@ +//// [superPropertyAccess.ts] + +class MyBase { + m1(a: string) { return a; } + private p1() { } + m2: () => void = function () { } + d1: number = 42; + private d2: number = 42; + get value() {return 0 } + set value(v: number) { } +} + + +class MyDerived extends MyBase { + + foo() { + super.m1("hi"); // Should be allowed, method on base prototype + + var l2 = super.m1.bind(this); // Should be allowed, can access properties as well as invoke + + var x: (a: string) => string = super.m1; // Should be allowed, can assign to var with compatible signature + + super.m2.bind(this); // Should error, instance property, not a public instance member function + + super.p1(); // Should error, private not public instance member function + + var l1 = super.d1; // Should error, instance data property not a public instance member function + + var l1 = super.d2; // Should error, instance data property not a public instance member function + + super.m1 = function (a: string) { return ""; }; // Should be allowed, we will not restrict assignment + + super.value = 0; // Should error, instance data property not a public instance member function + + var z = super.value; // Should error, instance data property not a public instance member function + } +} + +//// [superPropertyAccess.js] +var __extends = 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 MyBase = (function () { + function MyBase() { + this.m2 = function () { + }; + this.d1 = 42; + this.d2 = 42; + } + MyBase.prototype.m1 = function (a) { + return a; + }; + MyBase.prototype.p1 = function () { + }; + Object.defineProperty(MyBase.prototype, "value", { + get: function () { + return 0; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return MyBase; +})(); +var MyDerived = (function (_super) { + __extends(MyDerived, _super); + function MyDerived() { + _super.apply(this, arguments); + } + MyDerived.prototype.foo = function () { + _super.prototype.m1.call(this, "hi"); // Should be allowed, method on base prototype + var l2 = _super.prototype.m1.bind(this); // Should be allowed, can access properties as well as invoke + var x = _super.prototype.m1; // Should be allowed, can assign to var with compatible signature + _super.prototype.m2.bind(this); // Should error, instance property, not a public instance member function + _super.prototype.p1.call(this); // Should error, private not public instance member function + var l1 = _super.prototype.d1; // Should error, instance data property not a public instance member function + var l1 = _super.prototype.d2; // Should error, instance data property not a public instance member function + _super.prototype.m1 = function (a) { + return ""; + }; // Should be allowed, we will not restrict assignment + _super.prototype.value = 0; // Should error, instance data property not a public instance member function + var z = _super.prototype.value; // Should error, instance data property not a public instance member function + }; + return MyDerived; +})(MyBase); diff --git a/tests/baselines/reference/superPropertyAccess1.js b/tests/baselines/reference/superPropertyAccess1.js new file mode 100644 index 00000000000..8b1e855e0a3 --- /dev/null +++ b/tests/baselines/reference/superPropertyAccess1.js @@ -0,0 +1,74 @@ +//// [superPropertyAccess1.ts] +class C { + public foo() { } + public get x() { + return 1; + } + + public bar() { } +} + +class D extends C { + public foo() { + super.bar(); + super.x; // error + } + + constructor() { + super(); + super.bar(); + super.x; // error + } + + public get y() { + super.bar(); + super.x; // error + return 1; + } +} + +//// [superPropertyAccess1.js] +var __extends = 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 C = (function () { + function C() { + } + C.prototype.foo = function () { + }; + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + C.prototype.bar = function () { + }; + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.call(this); + _super.prototype.bar.call(this); + _super.prototype.x; // error + } + D.prototype.foo = function () { + _super.prototype.bar.call(this); + _super.prototype.x; // error + }; + Object.defineProperty(D.prototype, "y", { + get: function () { + _super.prototype.bar.call(this); + _super.prototype.x; // error + return 1; + }, + enumerable: true, + configurable: true + }); + return D; +})(C); diff --git a/tests/baselines/reference/superPropertyAccess2.js b/tests/baselines/reference/superPropertyAccess2.js new file mode 100644 index 00000000000..98beb078e2f --- /dev/null +++ b/tests/baselines/reference/superPropertyAccess2.js @@ -0,0 +1,74 @@ +//// [superPropertyAccess2.ts] +class C { + public static foo() { } + public get x() { + return 1; + } + + public static bar() { } +} + +class D extends C { + public static foo() { + super.bar(); // OK + super.x; // error + } + + constructor() { + super(); + super.bar(); // error + super.x; // error + } + + public static get y() { + super.bar(); // OK + super.x; // error + return 1; + } +} + +//// [superPropertyAccess2.js] +var __extends = 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 C = (function () { + function C() { + } + C.foo = function () { + }; + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + C.bar = function () { + }; + return C; +})(); +var D = (function (_super) { + __extends(D, _super); + function D() { + _super.call(this); + _super.prototype.bar.call(this); // error + _super.prototype.x; // error + } + D.foo = function () { + _super.bar.call(this); // OK + _super.x; // error + }; + Object.defineProperty(D, "y", { + get: function () { + _super.bar.call(this); // OK + _super.x; // error + return 1; + }, + enumerable: true, + configurable: true + }); + return D; +})(C); diff --git a/tests/baselines/reference/superPropertyAccessNoError.js b/tests/baselines/reference/superPropertyAccessNoError.js new file mode 100644 index 00000000000..e49a2c6b719 --- /dev/null +++ b/tests/baselines/reference/superPropertyAccessNoError.js @@ -0,0 +1,131 @@ +//// [superPropertyAccessNoError.ts] +//super.publicInstanceMemberFunction in constructor of derived class +//super.publicInstanceMemberFunction in instance member function of derived class +//super.publicInstanceMemberFunction in instance member accessor(get and set) of derived class +//super.publicInstanceMemberFunction in lambda in member function +//super.publicStaticMemberFunction in static member function of derived class +//super.publicStaticMemberFunction in static member accessor(get and set) of derived class + + +class SomeBaseClass { + public func() { + return ''; + } + + static func() { + return 3; + } + +} + +class SomeDerivedClass extends SomeBaseClass { + constructor() { + super(); + var x = super.func(); + var x: string; + } + + fn() { + var x = super.func(); + var x: string; + var y = () => super.func(); + } + + get a() { + var x = super.func(); + var x: string; + return null; + } + + set a(n) { + var x = super.func(); + var x: string; + } + + static fn() { + var x = super.func(); + var x: number; + } + + static get a() { + var x = super.func(); + var x: number; + return null; + } + + static set a(n) { + var x = super.func(); + var x: number; + } + +} + +//// [superPropertyAccessNoError.js] +//super.publicInstanceMemberFunction in constructor of derived class +//super.publicInstanceMemberFunction in instance member function of derived class +//super.publicInstanceMemberFunction in instance member accessor(get and set) of derived class +//super.publicInstanceMemberFunction in lambda in member function +//super.publicStaticMemberFunction in static member function of derived class +//super.publicStaticMemberFunction in static member accessor(get and set) of derived class +var __extends = 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 SomeBaseClass = (function () { + function SomeBaseClass() { + } + SomeBaseClass.prototype.func = function () { + return ''; + }; + SomeBaseClass.func = function () { + return 3; + }; + return SomeBaseClass; +})(); +var SomeDerivedClass = (function (_super) { + __extends(SomeDerivedClass, _super); + function SomeDerivedClass() { + _super.call(this); + var x = _super.prototype.func.call(this); + var x; + } + SomeDerivedClass.prototype.fn = function () { + var _this = this; + var x = _super.prototype.func.call(this); + var x; + var y = function () { return _super.prototype.func.call(_this); }; + }; + Object.defineProperty(SomeDerivedClass.prototype, "a", { + get: function () { + var x = _super.prototype.func.call(this); + var x; + return null; + }, + set: function (n) { + var x = _super.prototype.func.call(this); + var x; + }, + enumerable: true, + configurable: true + }); + SomeDerivedClass.fn = function () { + var x = _super.func.call(this); + var x; + }; + Object.defineProperty(SomeDerivedClass, "a", { + get: function () { + var x = _super.func.call(this); + var x; + return null; + }, + set: function (n) { + var x = _super.func.call(this); + var x; + }, + enumerable: true, + configurable: true + }); + return SomeDerivedClass; +})(SomeBaseClass); diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js new file mode 100644 index 00000000000..48ae609cdc6 --- /dev/null +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js @@ -0,0 +1,73 @@ +//// [super_inside-object-literal-getters-and-setters.ts] +module ObjectLiteral { + var ThisInObjectLiteral = { + _foo: '1', + get foo(): string { + return super._foo; + }, + set foo(value: string) { + super._foo = value; + }, + test: function () { + return super._foo; + } + } +} + +class F { public test(): string { return ""; } } +class SuperObjectTest extends F { + public testing() { + var test = { + get F() { + return super.test(); + } + }; + } +} + + + +//// [super_inside-object-literal-getters-and-setters.js] +var __extends = 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 ObjectLiteral; +(function (ObjectLiteral) { + var ThisInObjectLiteral = { + _foo: '1', + get foo() { + return super._foo; + }, + set foo(value) { + super._foo = value; + }, + test: function () { + return super._foo; + } + }; +})(ObjectLiteral || (ObjectLiteral = {})); +var F = (function () { + function F() { + } + F.prototype.test = function () { + return ""; + }; + return F; +})(); +var SuperObjectTest = (function (_super) { + __extends(SuperObjectTest, _super); + function SuperObjectTest() { + _super.apply(this, arguments); + } + SuperObjectTest.prototype.testing = function () { + var test = { + get F() { + return super.test.call(this); + } + }; + }; + return SuperObjectTest; +})(F); diff --git a/tests/baselines/reference/switchStatementsWithMultipleDefaults.js b/tests/baselines/reference/switchStatementsWithMultipleDefaults.js new file mode 100644 index 00000000000..a17abe5711d --- /dev/null +++ b/tests/baselines/reference/switchStatementsWithMultipleDefaults.js @@ -0,0 +1,63 @@ +//// [switchStatementsWithMultipleDefaults.ts] + +var x = 10; + +switch (x) { + case 1: + case 2: + default: // No issues. + break; + default: // Error; second 'default' clause. + default: // Error; third 'default' clause. + case 3: + x *= x; +} + +switch (x) { + default: // No issues. + break; + case 100: + switch (x * x) { + default: // No issues. + default: // Error; second 'default' clause. + break; + case 10000: + x /= x; + default: // Error, third 'default' clause + def\u0061ult: // Error, fourth 'default' clause. + // Errors on fifth-seventh + default: return; + default: default: + } +} + +//// [switchStatementsWithMultipleDefaults.js] +var x = 10; +switch (x) { + case 1: + case 2: + default: + break; + default: // Error; second 'default' clause. + default: // Error; third 'default' clause. + case 3: + x *= x; +} +switch (x) { + default: + break; + case 100: + switch (x * x) { + default: // No issues. + default: + break; + case 10000: + x /= x; + default: // Error, third 'default' clause + default: // Error, fourth 'default' clause. + // Errors on fifth-seventh + default: return; + default: + default: + } +} diff --git a/tests/baselines/reference/switchStatementsWithMultipleDefaults1.js b/tests/baselines/reference/switchStatementsWithMultipleDefaults1.js new file mode 100644 index 00000000000..2d52dd761cc --- /dev/null +++ b/tests/baselines/reference/switchStatementsWithMultipleDefaults1.js @@ -0,0 +1,26 @@ +//// [switchStatementsWithMultipleDefaults1.ts] + var x = 10; + + switch (x) { + case 1: + case 2: + default: // No issues. + break; + default: // Error; second 'default' clause. + default: // Error; third 'default' clause. + case 3: + x *= x; + } + +//// [switchStatementsWithMultipleDefaults1.js] +var x = 10; +switch (x) { + case 1: + case 2: + default: + break; + default: // Error; second 'default' clause. + default: // Error; third 'default' clause. + case 3: + x *= x; +} diff --git a/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js new file mode 100644 index 00000000000..6f3d4ed803a --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsTypeArgumentInference.js @@ -0,0 +1,172 @@ +//// [taggedTemplateStringsTypeArgumentInference.ts] + + +// Generic tag with one parameter +function noParams(n: T) { } +noParams ``; + +// Generic tag with parameter which does not use type parameter +function noGenericParams(n: string[]) { } +noGenericParams ``; + +// Generic tag with multiple type parameters and only one used in parameter type annotation +function someGenerics1a(n: T, m: number) { } +someGenerics1a `${3}`; + +function someGenerics1b(n: string[], m: U) { } +someGenerics1b `${3}`; + +// Generic tag with argument of function type whose parameter is of type parameter type +function someGenerics2a(strs: string[], n: (x: T) => void) { } +someGenerics2a `${(n: string) => n}`; + +function someGenerics2b(strs: string[], n: (x: T, y: U) => void) { } +someGenerics2b `${ (n: string, x: number) => n }`; + +// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter +function someGenerics3(strs: string[], producer: () => T) { } +someGenerics3 `${() => ''}`; +someGenerics3 `${() => undefined}`; +someGenerics3 `${() => 3}`; + +// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type +function someGenerics4(strs: string[], n: T, f: (x: U) => void) { } +someGenerics4 `${4}${ () => null }`; +someGenerics4 `${''}${ () => 3 }`; +someGenerics4 `${ null }${ null }`; + +// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type +function someGenerics5(strs: string[], n: T, f: (x: U) => void) { } +someGenerics5 `${ 4 } ${ () => null }`; +someGenerics5 `${ '' }${ () => 3 }`; +someGenerics5 `${null}${null}`; + +// Generic tag with multiple arguments of function types that each have parameters of the same generic type +function someGenerics6(strs: string[], a: (a: A) => A, b: (b: A) => A, c: (c: A) => A) { } +someGenerics6 `${ n => n }${ n => n}${ n => n}`; +someGenerics6 `${ n => n }${ n => n}${ n => n}`; +someGenerics6 `${ (n: number) => n }${ (n: number) => n }${ (n: number) => n }`; + +// Generic tag with multiple arguments of function types that each have parameters of different generic type +function someGenerics7(strs: string[], a: (a: A) => A, b: (b: B) => B, c: (c: C) => C) { } +someGenerics7 `${ n => n }${ n => n }${ n => n }`; +someGenerics7 `${ n => n }${ n => n }${ n => n }`; +someGenerics7 `${(n: number) => n}${ (n: string) => n}${ (n: number) => n}`; + +// Generic tag with argument of generic function type +function someGenerics8(strs: string[], n: T): T { return n; } +var x = someGenerics8 `${ someGenerics7 }`; +x `${null}${null}${null}`; + +// Generic tag with multiple parameters of generic type passed arguments with no best common type +function someGenerics9(strs: string[], a: T, b: T, c: T): T { + return null; +} +var a9a = someGenerics9 `${ '' }${ 0 }${ [] }`; +var a9a: {}; + +// Generic tag with multiple parameters of generic type passed arguments with multiple best common types +interface A91 { + x: number; + y?: string; +} +interface A92 { + x: number; + z?: Date; +} + +var a9e = someGenerics9 `${ undefined }${ { x: 6, z: new Date() } }${ { x: 6, y: '' } }`; +var a9e: {}; + +// Generic tag with multiple parameters of generic type passed arguments with a single best common type +var a9d = someGenerics9 `${ { x: 3 }}${ { x: 6 }}${ { x: 6 } }`; +var a9d: { x: number; }; + +// Generic tag with multiple parameters of generic type where one argument is of type 'any' +var anyVar: any; +var a = someGenerics9 `${ 7 }${ anyVar }${ 4 }`; +var a: any; + +// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any' +var arr = someGenerics9 `${ [] }${ null }${ undefined }`; +var arr: any[]; + + + +//// [taggedTemplateStringsTypeArgumentInference.js] +// Generic tag with one parameter +function noParams(n) { +} +noParams ""; +// Generic tag with parameter which does not use type parameter +function noGenericParams(n) { +} +noGenericParams ""; +// Generic tag with multiple type parameters and only one used in parameter type annotation +function someGenerics1a(n, m) { +} +someGenerics1a "" + 3; +function someGenerics1b(n, m) { +} +someGenerics1b "" + 3; +// Generic tag with argument of function type whose parameter is of type parameter type +function someGenerics2a(strs, n) { +} +someGenerics2a "" + function (n) { return n; }; +function someGenerics2b(strs, n) { +} +someGenerics2b "" + function (n, x) { return n; }; +// Generic tag with argument of function type whose parameter is not of type parameter type but body/return type uses type parameter +function someGenerics3(strs, producer) { +} +someGenerics3 "" + function () { return ''; }; +someGenerics3 "" + function () { return undefined; }; +someGenerics3 "" + function () { return 3; }; +// 2 parameter generic tag with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type +function someGenerics4(strs, n, f) { +} +someGenerics4 "" + 4 + function () { return null; }; +someGenerics4 "" + '' + function () { return 3; }; +someGenerics4 "" + null + null; +// 2 parameter generic tag with argument 2 of type parameter type and argument 1 of function type whose parameter is of type parameter type +function someGenerics5(strs, n, f) { +} +someGenerics5 4 + " " + function () { return null; }; +someGenerics5 "" + '' + function () { return 3; }; +someGenerics5 "" + null + null; +// Generic tag with multiple arguments of function types that each have parameters of the same generic type +function someGenerics6(strs, a, b, c) { +} +someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; +someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; +someGenerics6 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; +// Generic tag with multiple arguments of function types that each have parameters of different generic type +function someGenerics7(strs, a, b, c) { +} +someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; +someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; +someGenerics7 "" + function (n) { return n; } + function (n) { return n; } + function (n) { return n; }; +// Generic tag with argument of generic function type +function someGenerics8(strs, n) { + return n; +} +var x = someGenerics8 "" + someGenerics7; +x "" + null + null + null; +// Generic tag with multiple parameters of generic type passed arguments with no best common type +function someGenerics9(strs, a, b, c) { + return null; +} +var a9a = someGenerics9 "" + '' + 0 + []; +var a9a; +var a9e = someGenerics9 "" + undefined + { x: 6, z: new Date() } + { x: 6, y: '' }; +var a9e; +// Generic tag with multiple parameters of generic type passed arguments with a single best common type +var a9d = someGenerics9 "" + { x: 3 } + { x: 6 } + { x: 6 }; +var a9d; +// Generic tag with multiple parameters of generic type where one argument is of type 'any' +var anyVar; +var a = someGenerics9 "" + 7 + anyVar + 4; +var a; +// Generic tag with multiple parameters of generic type where one argument is [] and the other is not 'any' +var arr = someGenerics9 "" + [] + null + undefined; +var arr; diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.js b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.js new file mode 100644 index 00000000000..c3e145afb2b --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.js @@ -0,0 +1,48 @@ +//// [taggedTemplateStringsWithIncompatibleTypedTags.ts] +interface I { + (stringParts: string[], ...rest: boolean[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; +} + +var f: I; + +f `abc` + +f `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`[0].member `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + +f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); + + +//// [taggedTemplateStringsWithIncompatibleTypedTags.js] +var f; +f "abc"; +f "abc" + 1 + "def" + 2 + "ghi"; +f "abc".member; +f "abc" + 1 + "def" + 2 + "ghi".member; +f "abc"["member"]; +f "abc" + 1 + "def" + 2 + "ghi"["member"]; +f "abc"[0].member "abc" + 1 + "def" + 2 + "ghi"; +f "abc" + 1 + "def" + 2 + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi"; +f "abc" + true + "def" + true + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi"; +f.thisIsNotATag("abc"); +f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi"); diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.js b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.js new file mode 100644 index 00000000000..d507e951721 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.js @@ -0,0 +1,20 @@ +//// [taggedTemplateStringsWithManyCallAndMemberExpressions.ts] +interface I { + (strs: string[], ...subs: number[]): I; + member: { + new (s: string): { + new (n: number): { + new (): boolean; + } + } + }; +} +var f: I; + +var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; + + + +//// [taggedTemplateStringsWithManyCallAndMemberExpressions.js] +var f; +var x = new new new f "abc" + 0 + "def".member("hello")(42) === true; diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.js b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.js new file mode 100644 index 00000000000..23298e1df13 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.js @@ -0,0 +1,44 @@ +//// [taggedTemplateStringsWithOverloadResolution1.ts] +function foo(strs: string[]): number; +function foo(strs: string[], x: number): string; +function foo(strs: string[], x: number, y: number): boolean; +function foo(strs: string[], x: number, y: string): {}; +function foo(...stuff: any[]): any { + return undefined; +} + +var a = foo([]); // number +var b = foo([], 1); // string +var c = foo([], 1, 2); // boolean +var d = foo([], 1, true); // boolean (with error) +var e = foo([], 1, "2"); // {} +var f = foo([], 1, 2, 3); // any (with error) + +var u = foo ``; // number +var v = foo `${1}`; // string +var w = foo `${1}${2}`; // boolean +var x = foo `${1}${true}`; // boolean (with error) +var y = foo `${1}${"2"}`; // {} +var z = foo `${1}${2}${3}`; // any (with error) + + +//// [taggedTemplateStringsWithOverloadResolution1.js] +function foo() { + var stuff = []; + for (var _i = 0; _i < arguments.length; _i++) { + stuff[_i - 0] = arguments[_i]; + } + return undefined; +} +var a = foo([]); // number +var b = foo([], 1); // string +var c = foo([], 1, 2); // boolean +var d = foo([], 1, true); // boolean (with error) +var e = foo([], 1, "2"); // {} +var f = foo([], 1, 2, 3); // any (with error) +var u = foo ""; // number +var v = foo "" + 1; // string +var w = foo "" + 1 + 2; // boolean +var x = foo "" + 1 + true; // boolean (with error) +var y = foo "" + 1 + "2"; // {} +var z = foo "" + 1 + 2 + 3; // any (with error) diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.js b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.js new file mode 100644 index 00000000000..0b1447a3d3f --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.js @@ -0,0 +1,39 @@ +//// [taggedTemplateStringsWithOverloadResolution2.ts] + +function foo1(strs: TemplateStringsArray, x: number): string; +function foo1(strs: string[], x: number): number; +function foo1(...stuff: any[]): any { + return undefined; +} + +var a = foo1 `${1}`; // string +var b = foo1([], 1); // number + +function foo2(strs: string[], x: number): number; +function foo2(strs: TemplateStringsArray, x: number): string; +function foo2(...stuff: any[]): any { + return undefined; +} + +var c = foo2 `${1}`; // number +var d = foo2([], 1); // number + +//// [taggedTemplateStringsWithOverloadResolution2.js] +function foo1() { + var stuff = []; + for (var _i = 0; _i < arguments.length; _i++) { + stuff[_i - 0] = arguments[_i]; + } + return undefined; +} +var a = foo1 "" + 1; // string +var b = foo1([], 1); // number +function foo2() { + var stuff = []; + for (var _i = 0; _i < arguments.length; _i++) { + stuff[_i - 0] = arguments[_i]; + } + return undefined; +} +var c = foo2 "" + 1; // number +var d = foo2([], 1); // number diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js new file mode 100644 index 00000000000..dc8a08b4fc4 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.js @@ -0,0 +1,123 @@ +//// [taggedTemplateStringsWithOverloadResolution3.ts] + +// Ambiguous call picks the first overload in declaration order +function fn1(strs: TemplateStringsArray, s: string): string; +function fn1(strs: TemplateStringsArray, n: number): number; +function fn1() { return null; } + +var s: string = fn1 `${ undefined }`; + +// No candidate overloads found +fn1 `${ {} }`; // Error + +function fn2(strs: TemplateStringsArray, s: string, n: number): number; +function fn2(strs: TemplateStringsArray, n: number, t: T): T; +function fn2() { return undefined; } + +var d1: Date = fn2 `${ 0 }${ undefined }`; // contextually typed +var d2 = fn2 `${ 0 }${ undefined }`; // any + +d1.foo(); // error +d2(); // no error (typed as any) + +// Generic and non-generic overload where generic overload is the only candidate +fn2 `${ 0 }${ '' }`; // OK + +// Generic and non-generic overload where non-generic overload is the only candidate +fn2 `${ '' }${ 0 }`; // OK + +// Generic overloads with differing arity +function fn3(strs: TemplateStringsArray, n: T): string; +function fn3(strs: TemplateStringsArray, s: string, t: T, u: U): U; +function fn3(strs: TemplateStringsArray, v: V, u: U, t: T): number; +function fn3() { return null; } + +var s = fn3 `${ 3 }`; +var s = fn3 `${'' }${ 3 }${ '' }`; +var n = fn3 `${ 5 }${ 5 }${ 5 }`; +var n: number; + +// Generic overloads with differing arity tagging with arguments matching each overload type parameter count +var s = fn3 `${ 4 }` +var s = fn3 `${ '' }${ '' }${ '' }`; +var n = fn3 `${ '' }${ '' }${ 3 }`; + +// Generic overloads with differing arity tagging with argument count that doesn't match any overload +fn3 ``; // Error + +// Generic overloads with constraints +function fn4(strs: TemplateStringsArray, n: T, m: U); +function fn4(strs: TemplateStringsArray, n: T, m: U); +function fn4(strs: TemplateStringsArray) +function fn4() { } + +// Generic overloads with constraints tagged with types that satisfy the constraints +fn4 `${ '' }${ 3 }`; +fn4 `${ 3 }${ '' }`; +fn4 `${ 3 }${ undefined }`; +fn4 `${ '' }${ null }`; + +// Generic overloads with constraints called with type arguments that do not satisfy the constraints +fn4 `${ null }${ null }`; // Error + +// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints +fn4 `${ true }${ null }`; +fn4 `${ null }${ true }`; + +// Non - generic overloads where contextual typing of function arguments has errors +function fn5(strs: TemplateStringsArray, f: (n: string) => void): string; +function fn5(strs: TemplateStringsArray, f: (n: number) => void): number; +function fn5() { return undefined; } +fn5 `${ (n) => n.toFixed() }`; // will error; 'n' should have type 'string'. +fn5 `${ (n) => n.substr(0) }`; + + + +//// [taggedTemplateStringsWithOverloadResolution3.js] +function fn1() { + return null; +} +var s = fn1 "" + undefined; +// No candidate overloads found +fn1 "" + {}; // Error +function fn2() { + return undefined; +} +var d1 = fn2 "" + 0 + undefined; // contextually typed +var d2 = fn2 "" + 0 + undefined; // any +d1.foo(); // error +d2(); // no error (typed as any) +// Generic and non-generic overload where generic overload is the only candidate +fn2 "" + 0 + ''; // OK +// Generic and non-generic overload where non-generic overload is the only candidate +fn2 "" + '' + 0; // OK +function fn3() { + return null; +} +var s = fn3 "" + 3; +var s = fn3 "" + '' + 3 + ''; +var n = fn3 "" + 5 + 5 + 5; +var n; +// Generic overloads with differing arity tagging with arguments matching each overload type parameter count +var s = fn3 "" + 4; +var s = fn3 "" + '' + '' + ''; +var n = fn3 "" + '' + '' + 3; +// Generic overloads with differing arity tagging with argument count that doesn't match any overload +fn3 ""; // Error +function fn4() { +} +// Generic overloads with constraints tagged with types that satisfy the constraints +fn4 "" + '' + 3; +fn4 "" + 3 + ''; +fn4 "" + 3 + undefined; +fn4 "" + '' + null; +// Generic overloads with constraints called with type arguments that do not satisfy the constraints +fn4 "" + null + null; // Error +// Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints +fn4 "" + true + null; +fn4 "" + null + true; +function fn5() { + return undefined; +} +fn5 "" + function (n) { return n.toFixed(); }; // will error; 'n' should have type 'string'. +fn5 "" + function (n) { return n.substr(0); }; diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.js b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.js new file mode 100644 index 00000000000..d5c6b8b31f6 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.js @@ -0,0 +1,41 @@ +//// [taggedTemplateStringsWithTagsTypedAsAny.ts] +var f: any; + +f `abc` + +f `abc${1}def${2}ghi`; + +f.g.h `abc` + +f.g.h `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); + +//// [taggedTemplateStringsWithTagsTypedAsAny.js] +var f; +f "abc"; +f "abc" + 1 + "def" + 2 + "ghi"; +f.g.h "abc"; +f.g.h "abc" + 1 + "def" + 2 + "ghi"; +f "abc".member; +f "abc" + 1 + "def" + 2 + "ghi".member; +f "abc"["member"]; +f "abc" + 1 + "def" + 2 + "ghi"["member"]; +f "abc"["member"].someOtherTag "abc" + 1 + "def" + 2 + "ghi"; +f "abc" + 1 + "def" + 2 + "ghi"["member"].someOtherTag "abc" + 1 + "def" + 2 + "ghi"; +f.thisIsNotATag("abc"); +f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi"); diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js new file mode 100644 index 00000000000..eb46f4b603f --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js @@ -0,0 +1,18 @@ +//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts] + + +function foo(...rest: any[]) { +} + +foo `${function (x: number) { x = "bad"; } }`; + +//// [taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.js] +function foo() { + var rest = []; + for (var _i = 0; _i < arguments.length; _i++) { + rest[_i - 0] = arguments[_i]; + } +} +foo "" + function (x) { + x = "bad"; +}; diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.js b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.js new file mode 100644 index 00000000000..c2424a07a47 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.js @@ -0,0 +1,45 @@ +//// [taggedTemplateStringsWithTypedTags.ts] +interface I { + (stringParts: string[], ...rest: number[]): I; + g: I; + h: I; + member: I; + thisIsNotATag(x: string): void + [x: number]: I; +} + +var f: I; + +f `abc` + +f `abc${1}def${2}ghi`; + +f `abc`.member + +f `abc${1}def${2}ghi`.member; + +f `abc`["member"]; + +f `abc${1}def${2}ghi`["member"]; + +f `abc`[0].member `abc${1}def${2}ghi`; + +f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; + +f.thisIsNotATag(`abc`); + +f.thisIsNotATag(`abc${1}def${2}ghi`); + + +//// [taggedTemplateStringsWithTypedTags.js] +var f; +f "abc"; +f "abc" + 1 + "def" + 2 + "ghi"; +f "abc".member; +f "abc" + 1 + "def" + 2 + "ghi".member; +f "abc"["member"]; +f "abc" + 1 + "def" + 2 + "ghi"["member"]; +f "abc"[0].member "abc" + 1 + "def" + 2 + "ghi"; +f "abc" + 1 + "def" + 2 + "ghi"["member"].member "abc" + 1 + "def" + 2 + "ghi"; +f.thisIsNotATag("abc"); +f.thisIsNotATag("abc" + 1 + "def" + 2 + "ghi"); diff --git a/tests/baselines/reference/templateStringInTaggedTemplate.js b/tests/baselines/reference/templateStringInTaggedTemplate.js new file mode 100644 index 00000000000..c6d98b0f826 --- /dev/null +++ b/tests/baselines/reference/templateStringInTaggedTemplate.js @@ -0,0 +1,5 @@ +//// [templateStringInTaggedTemplate.ts] +`I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION` + +//// [templateStringInTaggedTemplate.js] +"I AM THE " + "TAG" + " " + " PORTION" "I " + "AM" + " THE TEMPLATE PORTION"; diff --git a/tests/baselines/reference/templateStringInYieldKeyword.js b/tests/baselines/reference/templateStringInYieldKeyword.js new file mode 100644 index 00000000000..8e98b269cd0 --- /dev/null +++ b/tests/baselines/reference/templateStringInYieldKeyword.js @@ -0,0 +1,12 @@ +//// [templateStringInYieldKeyword.ts] +function* gen() { + // Once this is supported, the inner expression does not need to be parenthesized. + var x = yield `abc${ x }def`; +} + + +//// [templateStringInYieldKeyword.js] +function gen() { + // Once this is supported, the inner expression does not need to be parenthesized. + var x = ; +} diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.js b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.js new file mode 100644 index 00000000000..80021ecae2e --- /dev/null +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.js @@ -0,0 +1,12 @@ +//// [templateStringWithEmbeddedYieldKeywordES6.ts] +function* gen() { + // Once this is supported, yield *must* be parenthesized. + var x = `abc${ yield 10 }def`; +} + + +//// [templateStringWithEmbeddedYieldKeywordES6.js] +function gen() { + // Once this is supported, yield *must* be parenthesized. + var x = `abc${}def`; +} diff --git a/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.js b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.js new file mode 100644 index 00000000000..a724943c0f3 --- /dev/null +++ b/tests/baselines/reference/templateStringsArrayTypeDefinedInES5Mode.js @@ -0,0 +1,22 @@ +//// [templateStringsArrayTypeDefinedInES5Mode.ts] + +class TemplateStringsArray { +} + +function f(x: TemplateStringsArray, y: number, z: number) { +} + +f({}, 10, 10); + +f `abcdef${ 1234 }${ 5678 }ghijkl`; + +//// [templateStringsArrayTypeDefinedInES5Mode.js] +var TemplateStringsArray = (function () { + function TemplateStringsArray() { + } + return TemplateStringsArray; +})(); +function f(x, y, z) { +} +f({}, 10, 10); +f "abcdef" + 1234 + 5678 + "ghijkl"; diff --git a/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.js b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.js new file mode 100644 index 00000000000..c6cc4ee8408 --- /dev/null +++ b/tests/baselines/reference/templateStringsArrayTypeNotDefinedES5Mode.js @@ -0,0 +1,14 @@ +//// [templateStringsArrayTypeNotDefinedES5Mode.ts] + +function f(x: TemplateStringsArray, y: number, z: number) { +} + +f({}, 10, 10); + +f `abcdef${ 1234 }${ 5678 }ghijkl`; + +//// [templateStringsArrayTypeNotDefinedES5Mode.js] +function f(x, y, z) { +} +f({}, 10, 10); +f "abcdef" + 1234 + 5678 + "ghijkl"; diff --git a/tests/baselines/reference/thisInAccessors.js b/tests/baselines/reference/thisInAccessors.js new file mode 100644 index 00000000000..ab521649292 --- /dev/null +++ b/tests/baselines/reference/thisInAccessors.js @@ -0,0 +1,86 @@ +//// [thisInAccessors.ts] +// this capture only in getter +class GetterOnly { + get Value() { + var fn = () => this; + return ''; + } + set Value(val) { + } +} + +// this capture only in setter +class SetterOnly { + get Value() { + return ''; + } + set Value(val) { + var fn = () => this; + } +} + +// this capture only in both setter and getter +class GetterAndSetter { + get Value() { + var fn = () => this; + return ''; + } + set Value(val) { + var fn = () => this; + } +} + +//// [thisInAccessors.js] +// this capture only in getter +var GetterOnly = (function () { + function GetterOnly() { + } + Object.defineProperty(GetterOnly.prototype, "Value", { + get: function () { + var _this = this; + var fn = function () { return _this; }; + return ''; + }, + set: function (val) { + }, + enumerable: true, + configurable: true + }); + return GetterOnly; +})(); +// this capture only in setter +var SetterOnly = (function () { + function SetterOnly() { + } + Object.defineProperty(SetterOnly.prototype, "Value", { + get: function () { + return ''; + }, + set: function (val) { + var _this = this; + var fn = function () { return _this; }; + }, + enumerable: true, + configurable: true + }); + return SetterOnly; +})(); +// this capture only in both setter and getter +var GetterAndSetter = (function () { + function GetterAndSetter() { + } + Object.defineProperty(GetterAndSetter.prototype, "Value", { + get: function () { + var _this = this; + var fn = function () { return _this; }; + return ''; + }, + set: function (val) { + var _this = this; + var fn = function () { return _this; }; + }, + enumerable: true, + configurable: true + }); + return GetterAndSetter; +})(); diff --git a/tests/baselines/reference/thisInStatics.js b/tests/baselines/reference/thisInStatics.js new file mode 100644 index 00000000000..a7d6a5890cc --- /dev/null +++ b/tests/baselines/reference/thisInStatics.js @@ -0,0 +1,29 @@ +//// [thisInStatics.ts] +class C { + static f() { + var y/*1*/ = this; + } + + static get x() { + var y/*2*/ = this; + return y; + } +} + +//// [thisInStatics.js] +var C = (function () { + function C() { + } + C.f = function () { + var y /*1*/ = this; + }; + Object.defineProperty(C, "x", { + get: function () { + var y /*2*/ = this; + return y; + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/this_inside-object-literal-getters-and-setters.js b/tests/baselines/reference/this_inside-object-literal-getters-and-setters.js new file mode 100644 index 00000000000..7b175935f39 --- /dev/null +++ b/tests/baselines/reference/this_inside-object-literal-getters-and-setters.js @@ -0,0 +1,34 @@ +//// [this_inside-object-literal-getters-and-setters.ts] +module ObjectLiteral { + var ThisInObjectLiteral = { + _foo: '1', + get foo(): string { + return this._foo; + }, + set foo(value: string) { + this._foo = value; + }, + test: function () { + return this._foo; + } + } +} + + + +//// [this_inside-object-literal-getters-and-setters.js] +var ObjectLiteral; +(function (ObjectLiteral) { + var ThisInObjectLiteral = { + _foo: '1', + get foo() { + return this._foo; + }, + set foo(value) { + this._foo = value; + }, + test: function () { + return this._foo; + } + }; +})(ObjectLiteral || (ObjectLiteral = {})); diff --git a/tests/baselines/reference/throwWithoutNewLine2.js b/tests/baselines/reference/throwWithoutNewLine2.js new file mode 100644 index 00000000000..868e4e3d844 --- /dev/null +++ b/tests/baselines/reference/throwWithoutNewLine2.js @@ -0,0 +1,7 @@ +//// [throwWithoutNewLine2.ts] +throw +a; + +//// [throwWithoutNewLine2.js] +throw ; +a; diff --git a/tests/baselines/reference/trailingSeparatorInFunctionCall.js b/tests/baselines/reference/trailingSeparatorInFunctionCall.js new file mode 100644 index 00000000000..4b531479837 --- /dev/null +++ b/tests/baselines/reference/trailingSeparatorInFunctionCall.js @@ -0,0 +1,18 @@ +//// [trailingSeparatorInFunctionCall.ts] +function f(x, y) { +} + +f(1, 2, ); + +function f2(x: T, y: T) { +} + +f2(1, 2, ); + +//// [trailingSeparatorInFunctionCall.js] +function f(x, y) { +} +f(1, 2); +function f2(x, y) { +} +f2(1, 2); diff --git a/tests/baselines/reference/tupleTypes.js b/tests/baselines/reference/tupleTypes.js new file mode 100644 index 00000000000..451aeb5eb09 --- /dev/null +++ b/tests/baselines/reference/tupleTypes.js @@ -0,0 +1,101 @@ +//// [tupleTypes.ts] +var v1: []; // Error +var v2: [number]; +var v3: [number, string]; +var v4: [number, [string, string]]; + +var t: [number, string]; +var t0 = t[0]; // number +var t0: number; +var t1 = t[1]; // string +var t1: string; +var t2 = t[2]; // number|string +var t2: number|string; + +t = []; // Error +t = [1]; // Error +t = [1, "hello"]; // Ok +t = ["hello", 1]; // Error +t = [1, "hello", 2]; // Ok + +var tf: [string, (x: string) => number] = ["hello", x => x.length]; + +declare function ff(a: T, b: [T, (x: T) => U]): U; +var ff1 = ff("hello", ["foo", x => x.length]); +var ff1: number; + +function tuple2(item0: T0, item1: T1): [T0, T1]{ + return [item0, item1]; +} + +var tt = tuple2(1, "string"); +var tt0 = tt[0]; +var tt0: number; +var tt1 = tt[1]; +var tt1: string; +var tt2 = tt[2]; +var tt2: number | string; + +tt = tuple2(1, undefined); +tt = [1, undefined]; +tt = [undefined, undefined]; +tt = []; // Error + +var a: number[]; +var a1: [number, string]; +var a2: [number, number]; +var a3: [number, {}]; +a = a1; // Error +a = a2; +a = a3; // Error +a1 = a2; // Error +a1 = a3; // Error +a3 = a1; +a3 = a2; + + +//// [tupleTypes.js] +var v1; // Error +var v2; +var v3; +var v4; +var t; +var t0 = t[0]; // number +var t0; +var t1 = t[1]; // string +var t1; +var t2 = t[2]; // number|string +var t2; +t = []; // Error +t = [1]; // Error +t = [1, "hello"]; // Ok +t = ["hello", 1]; // Error +t = [1, "hello", 2]; // Ok +var tf = ["hello", function (x) { return x.length; }]; +var ff1 = ff("hello", ["foo", function (x) { return x.length; }]); +var ff1; +function tuple2(item0, item1) { + return [item0, item1]; +} +var tt = tuple2(1, "string"); +var tt0 = tt[0]; +var tt0; +var tt1 = tt[1]; +var tt1; +var tt2 = tt[2]; +var tt2; +tt = tuple2(1, undefined); +tt = [1, undefined]; +tt = [undefined, undefined]; +tt = []; // Error +var a; +var a1; +var a2; +var a3; +a = a1; // Error +a = a2; +a = a3; // Error +a1 = a2; // Error +a1 = a3; // Error +a3 = a1; +a3 = a2; diff --git a/tests/baselines/reference/twoAccessorsWithSameName.js b/tests/baselines/reference/twoAccessorsWithSameName.js new file mode 100644 index 00000000000..7ae4d3bd1f9 --- /dev/null +++ b/tests/baselines/reference/twoAccessorsWithSameName.js @@ -0,0 +1,90 @@ +//// [twoAccessorsWithSameName.ts] +class C { + get x() { return 1; } + get x() { return 1; } // error +} + +class D { + set x(v) { } + set x(v) { } // error +} + +class E { + get x() { + return 1; + } + set x(v) { } +} + +var x = { + get x() { + return 1; + }, + + // error + get x() { + return 1; + } +} + +var y = { + get x() { + return 1; + }, + set x(v) { } +} + +//// [twoAccessorsWithSameName.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var D = (function () { + function D() { + } + Object.defineProperty(D.prototype, "x", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return D; +})(); +var E = (function () { + function E() { + } + Object.defineProperty(E.prototype, "x", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return E; +})(); +var x = { + get x() { + return 1; + }, + // error + get x() { + return 1; + } +}; +var y = { + get x() { + return 1; + }, + set x(v) { + } +}; diff --git a/tests/baselines/reference/twoAccessorsWithSameName2.js b/tests/baselines/reference/twoAccessorsWithSameName2.js new file mode 100644 index 00000000000..437fe16cea5 --- /dev/null +++ b/tests/baselines/reference/twoAccessorsWithSameName2.js @@ -0,0 +1,56 @@ +//// [twoAccessorsWithSameName2.ts] +class C { + static get x() { return 1; } + static get x() { return 1; } // error +} + +class D { + static set x(v) { } + static set x(v) { } // error +} + +class E { + static get x() { + return 1; + } + static set x(v) { } +} + +//// [twoAccessorsWithSameName2.js] +var C = (function () { + function C() { + } + Object.defineProperty(C, "x", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var D = (function () { + function D() { + } + Object.defineProperty(D, "x", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return D; +})(); +var E = (function () { + function E() { + } + Object.defineProperty(E, "x", { + get: function () { + return 1; + }, + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return E; +})(); diff --git a/tests/baselines/reference/typeOfThis.js b/tests/baselines/reference/typeOfThis.js new file mode 100644 index 00000000000..7de34712e15 --- /dev/null +++ b/tests/baselines/reference/typeOfThis.js @@ -0,0 +1,355 @@ +//// [typeOfThis.ts] +class MyTestClass { + private canary: number; + static staticCanary: number; + + constructor() { + //type of 'this' in constructor body is the class instance type + var p = this.canary; + var p: number; + this.canary = 3; + } + + //type of 'this' in member function param list is the class instance type + memberFunc(t = this) { + var t: MyTestClass; + + //type of 'this' in member function body is the class instance type + var p = this; + var p: MyTestClass; + } + + //type of 'this' in member accessor(get and set) body is the class instance type + get prop() { + var p = this; + var p: MyTestClass; + return this; + } + set prop(v) { + var p = this; + var p: MyTestClass; + p = v; + v = p; + } + + someFunc = () => { + //type of 'this' in member variable initializer is the class instance type + var t = this; + var t: MyTestClass; + }; + + //type of 'this' in static function param list is constructor function type + static staticFn(t = this) { + var t: typeof MyTestClass; + var t = MyTestClass; + t.staticCanary; + + //type of 'this' in static function body is constructor function type + var p = this; + var p: typeof MyTestClass; + var p = MyTestClass; + p.staticCanary; + } + + static get staticProp() { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p: typeof MyTestClass; + var p = MyTestClass; + p.staticCanary; + return this; + } + static set staticProp(v: typeof MyTestClass) { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p: typeof MyTestClass; + var p = MyTestClass; + p.staticCanary; + } +} + +class MyGenericTestClass { + private canary: number; + static staticCanary: number; + + constructor() { + //type of 'this' in constructor body is the class instance type + var p = this.canary; + var p: number; + this.canary = 3; + } + + //type of 'this' in member function param list is the class instance type + memberFunc(t = this) { + var t: MyGenericTestClass; + + //type of 'this' in member function body is the class instance type + var p = this; + var p: MyGenericTestClass; + } + + //type of 'this' in member accessor(get and set) body is the class instance type + get prop() { + var p = this; + var p: MyGenericTestClass; + return this; + } + set prop(v) { + var p = this; + var p: MyGenericTestClass; + p = v; + v = p; + } + + someFunc = () => { + //type of 'this' in member variable initializer is the class instance type + var t = this; + var t: MyGenericTestClass; + }; + + //type of 'this' in static function param list is constructor function type + static staticFn(t = this) { + var t: typeof MyGenericTestClass; + var t = MyGenericTestClass; + t.staticCanary; + + //type of 'this' in static function body is constructor function type + var p = this; + var p: typeof MyGenericTestClass; + var p = MyGenericTestClass; + p.staticCanary; + } + + static get staticProp() { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p: typeof MyGenericTestClass; + var p = MyGenericTestClass; + p.staticCanary; + return this; + } + static set staticProp(v: typeof MyGenericTestClass) { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p: typeof MyGenericTestClass; + var p = MyGenericTestClass; + p.staticCanary; + } +} + +//type of 'this' in a function declaration param list is Any +function fn(s = this) { + var s: any; + s.spaaaaaaace = 4; + + //type of 'this' in a function declaration body is Any + var t: any; + var t = this; + this.spaaaaace = 4; +} + +//type of 'this' in a function expression param list list is Any +var q1 = function (s = this) { + var s: any; + s.spaaaaaaace = 4; + + //type of 'this' in a function expression body is Any + var t: any; + var t = this; + this.spaaaaace = 4; +} + +//type of 'this' in a fat arrow expression param list is Any +var q2 = (s = this) => { + var s: any; + s.spaaaaaaace = 4; + + //type of 'this' in a fat arrow expression body is Any + var t: any; + var t = this; + this.spaaaaace = 4; +} + +//type of 'this' in global module is Any +var t: any; +var t = this; +this.spaaaaace = 4; + + + +//// [typeOfThis.js] +var _this = this; +var MyTestClass = (function () { + function MyTestClass() { + var _this = this; + this.someFunc = function () { + //type of 'this' in member variable initializer is the class instance type + var t = _this; + var t; + }; + //type of 'this' in constructor body is the class instance type + var p = this.canary; + var p; + this.canary = 3; + } + //type of 'this' in member function param list is the class instance type + MyTestClass.prototype.memberFunc = function (t) { + if (t === void 0) { t = this; } + var t; + //type of 'this' in member function body is the class instance type + var p = this; + var p; + }; + Object.defineProperty(MyTestClass.prototype, "prop", { + //type of 'this' in member accessor(get and set) body is the class instance type + get: function () { + var p = this; + var p; + return this; + }, + set: function (v) { + var p = this; + var p; + p = v; + v = p; + }, + enumerable: true, + configurable: true + }); + //type of 'this' in static function param list is constructor function type + MyTestClass.staticFn = function (t) { + if (t === void 0) { t = this; } + var t; + var t = MyTestClass; + t.staticCanary; + //type of 'this' in static function body is constructor function type + var p = this; + var p; + var p = MyTestClass; + p.staticCanary; + }; + Object.defineProperty(MyTestClass, "staticProp", { + get: function () { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p; + var p = MyTestClass; + p.staticCanary; + return this; + }, + set: function (v) { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p; + var p = MyTestClass; + p.staticCanary; + }, + enumerable: true, + configurable: true + }); + return MyTestClass; +})(); +var MyGenericTestClass = (function () { + function MyGenericTestClass() { + var _this = this; + this.someFunc = function () { + //type of 'this' in member variable initializer is the class instance type + var t = _this; + var t; + }; + //type of 'this' in constructor body is the class instance type + var p = this.canary; + var p; + this.canary = 3; + } + //type of 'this' in member function param list is the class instance type + MyGenericTestClass.prototype.memberFunc = function (t) { + if (t === void 0) { t = this; } + var t; + //type of 'this' in member function body is the class instance type + var p = this; + var p; + }; + Object.defineProperty(MyGenericTestClass.prototype, "prop", { + //type of 'this' in member accessor(get and set) body is the class instance type + get: function () { + var p = this; + var p; + return this; + }, + set: function (v) { + var p = this; + var p; + p = v; + v = p; + }, + enumerable: true, + configurable: true + }); + //type of 'this' in static function param list is constructor function type + MyGenericTestClass.staticFn = function (t) { + if (t === void 0) { t = this; } + var t; + var t = MyGenericTestClass; + t.staticCanary; + //type of 'this' in static function body is constructor function type + var p = this; + var p; + var p = MyGenericTestClass; + p.staticCanary; + }; + Object.defineProperty(MyGenericTestClass, "staticProp", { + get: function () { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p; + var p = MyGenericTestClass; + p.staticCanary; + return this; + }, + set: function (v) { + //type of 'this' in static accessor body is constructor function type + var p = this; + var p; + var p = MyGenericTestClass; + p.staticCanary; + }, + enumerable: true, + configurable: true + }); + return MyGenericTestClass; +})(); +//type of 'this' in a function declaration param list is Any +function fn(s) { + if (s === void 0) { s = this; } + var s; + s.spaaaaaaace = 4; + //type of 'this' in a function declaration body is Any + var t; + var t = this; + this.spaaaaace = 4; +} +//type of 'this' in a function expression param list list is Any +var q1 = function (s) { + if (s === void 0) { s = this; } + var s; + s.spaaaaaaace = 4; + //type of 'this' in a function expression body is Any + var t; + var t = this; + this.spaaaaace = 4; +}; +//type of 'this' in a fat arrow expression param list is Any +var q2 = function (s) { + if (s === void 0) { s = _this; } + var s; + s.spaaaaaaace = 4; + //type of 'this' in a fat arrow expression body is Any + var t; + var t = _this; + _this.spaaaaace = 4; +}; +//type of 'this' in global module is Any +var t; +var t = this; +this.spaaaaace = 4; diff --git a/tests/baselines/reference/typeOfThisInAccessor.js b/tests/baselines/reference/typeOfThisInAccessor.js new file mode 100644 index 00000000000..34d1bfaf2d0 --- /dev/null +++ b/tests/baselines/reference/typeOfThisInAccessor.js @@ -0,0 +1,82 @@ +//// [typeOfThisInAccessor.ts] +class C { + get x() { + var r = this; // C + return 1; + } + + static get y() { + var r2 = this; // typeof C + return 1; + } +} + +class D { + a: T; + get x() { + var r = this; // D + return 1; + } + + static get y() { + var r2 = this; // typeof D + return 1; + } +} + +var x = { + get a() { + var r3 = this; // any + return 1; + } +} + +//// [typeOfThisInAccessor.js] +var C = (function () { + function C() { + } + Object.defineProperty(C.prototype, "x", { + get: function () { + var r = this; // C + return 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "y", { + get: function () { + var r2 = this; // typeof C + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var D = (function () { + function D() { + } + Object.defineProperty(D.prototype, "x", { + get: function () { + var r = this; // D + return 1; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(D, "y", { + get: function () { + var r2 = this; // typeof D + return 1; + }, + enumerable: true, + configurable: true + }); + return D; +})(); +var x = { + get a() { + var r3 = this; // any + return 1; + } +}; diff --git a/tests/baselines/reference/typeOfThisInInstanceMember.js b/tests/baselines/reference/typeOfThisInInstanceMember.js new file mode 100644 index 00000000000..5e4b4f2970d --- /dev/null +++ b/tests/baselines/reference/typeOfThisInInstanceMember.js @@ -0,0 +1,67 @@ +//// [typeOfThisInInstanceMember.ts] +class C { + x = this; + foo() { + return this; + } + constructor(x: number) { + var t = this; + t.x; + t.y; + t.z; + var r = t.foo(); + } + + get y() { + return this; + } +} + +var c: C; +// all ok +var r = c.x; +var ra = c.x.x.x; +var r2 = c.y; +var r3 = c.foo(); +var rs = [r, r2, r3]; + +rs.forEach(x => { + x.foo; + x.x; + x.y; +}); + +//// [typeOfThisInInstanceMember.js] +var C = (function () { + function C(x) { + this.x = this; + var t = this; + t.x; + t.y; + t.z; + var r = t.foo(); + } + C.prototype.foo = function () { + return this; + }; + Object.defineProperty(C.prototype, "y", { + get: function () { + return this; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var c; +// all ok +var r = c.x; +var ra = c.x.x.x; +var r2 = c.y; +var r3 = c.foo(); +var rs = [r, r2, r3]; +rs.forEach(function (x) { + x.foo; + x.x; + x.y; +}); diff --git a/tests/baselines/reference/typeOfThisInInstanceMember2.js b/tests/baselines/reference/typeOfThisInInstanceMember2.js new file mode 100644 index 00000000000..b2b81ce3a23 --- /dev/null +++ b/tests/baselines/reference/typeOfThisInInstanceMember2.js @@ -0,0 +1,73 @@ +//// [typeOfThisInInstanceMember2.ts] +class C { + x = this; + foo() { + return this; + } + constructor(x: T) { + var t = this; + t.x; + t.y; + t.z; + var r = t.foo(); + } + + get y() { + return this; + } + + z: T; +} + +var c: C; +// all ok +var r = c.x; +var ra = c.x.x.x; +var r2 = c.y; +var r3 = c.foo(); +var r4 = c.z; +var rs = [r, r2, r3]; + +rs.forEach(x => { + x.foo; + x.x; + x.y; + x.z; +}); + +//// [typeOfThisInInstanceMember2.js] +var C = (function () { + function C(x) { + this.x = this; + var t = this; + t.x; + t.y; + t.z; + var r = t.foo(); + } + C.prototype.foo = function () { + return this; + }; + Object.defineProperty(C.prototype, "y", { + get: function () { + return this; + }, + enumerable: true, + configurable: true + }); + return C; +})(); +var c; +// all ok +var r = c.x; +var ra = c.x.x.x; +var r2 = c.y; +var r3 = c.foo(); +var r4 = c.z; +var rs = [r, r2, r3]; +rs.forEach(function (x) { + x.foo; + x.x; + x.y; + x.z; +}); diff --git a/tests/baselines/reference/typeOfThisInStatics.js b/tests/baselines/reference/typeOfThisInStatics.js new file mode 100644 index 00000000000..5d59f6d7eb9 --- /dev/null +++ b/tests/baselines/reference/typeOfThisInStatics.js @@ -0,0 +1,29 @@ +//// [typeOfThisInStatics.ts] +class C { + static foo() { + var r = this; + } + static get x() { + var r = this; + return 1; + } +} + + +//// [typeOfThisInStatics.js] +var C = (function () { + function C() { + } + C.foo = function () { + var r = this; + }; + Object.defineProperty(C, "x", { + get: function () { + var r = this; + return 1; + }, + enumerable: true, + configurable: true + }); + return C; +})(); diff --git a/tests/baselines/reference/typeParameterConstraints1.js b/tests/baselines/reference/typeParameterConstraints1.js new file mode 100644 index 00000000000..49d347f576b --- /dev/null +++ b/tests/baselines/reference/typeParameterConstraints1.js @@ -0,0 +1,42 @@ +//// [typeParameterConstraints1.ts] +function foo1(test: T) { } +function foo2(test: T) { } +function foo3(test: T) { } +function foo4(test: T) { } // valid +function foo5(test: T) { } // valid +function foo6(test: T) { } +function foo7(test: T) { } // valid +function foo8(test: T) { } +function foo9 (test: T) { } +function foo10 (test: T) { } +function foo11 (test: T) { } +function foo12(test: T) { } +function foo13(test: T) { } + +//// [typeParameterConstraints1.js] +function foo1(test) { +} +function foo2(test) { +} +function foo3(test) { +} +function foo4(test) { +} // valid +function foo5(test) { +} // valid +function foo6(test) { +} +function foo7(test) { +} // valid +function foo8(test) { +} +function foo9(test) { +} +function foo10(test) { +} +function foo11(test) { +} +function foo12(test) { +} +function foo13(test) { +} diff --git a/tests/baselines/reference/typeParametersInStaticAccessors.js b/tests/baselines/reference/typeParametersInStaticAccessors.js new file mode 100644 index 00000000000..411a4eac69d --- /dev/null +++ b/tests/baselines/reference/typeParametersInStaticAccessors.js @@ -0,0 +1,25 @@ +//// [typeParametersInStaticAccessors.ts] +class foo { + static get Foo(): () => T { return null; } + static set Bar(v: { v: T }) { } +} + +//// [typeParametersInStaticAccessors.js] +var foo = (function () { + function foo() { + } + Object.defineProperty(foo, "Foo", { + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(foo, "Bar", { + set: function (v) { + }, + enumerable: true, + configurable: true + }); + return foo; +})(); diff --git a/tests/baselines/reference/typeQueryOnClass.js b/tests/baselines/reference/typeQueryOnClass.js new file mode 100644 index 00000000000..08fea6567fc --- /dev/null +++ b/tests/baselines/reference/typeQueryOnClass.js @@ -0,0 +1,124 @@ +//// [typeQueryOnClass.ts] +class C { + constructor(x: number); + constructor(x: string); + constructor(public x) { } + + static foo(x: number); + static foo(x: {}); + static foo(x) { } + + static bar(x) { } + + static sa = 1; + static sb = () => 1; + + static get sc() { + return 1; + } + static set sc(x) { + } + + static get sd() { + return 1; + } + + baz(x): string { return ''; } + + ia = 1; + ib = () => this.ia; + + get ic() { + return 1; + } + set ic(x) { + } + + get id() { + return 1; + } + +} + +var c: C; + +// BUG 820454 +var r1: typeof C; +var r2: typeof c; + +class D { + constructor(public y?) { } + x: T; + foo() { } +} + +var d: D; +var r3: typeof D; +var r4: typeof d; + +//// [typeQueryOnClass.js] +var C = (function () { + function C(x) { + var _this = this; + this.x = x; + this.ia = 1; + this.ib = function () { return _this.ia; }; + } + C.foo = function (x) { + }; + C.bar = function (x) { + }; + Object.defineProperty(C, "sc", { + get: function () { + return 1; + }, + set: function (x) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C, "sd", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + C.prototype.baz = function (x) { + return ''; + }; + Object.defineProperty(C.prototype, "ic", { + get: function () { + return 1; + }, + set: function (x) { + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(C.prototype, "id", { + get: function () { + return 1; + }, + enumerable: true, + configurable: true + }); + C.sa = 1; + C.sb = function () { return 1; }; + return C; +})(); +var c; +// BUG 820454 +var r1; +var r2; +var D = (function () { + function D(y) { + this.y = y; + } + D.prototype.foo = function () { + }; + return D; +})(); +var d; +var r3; +var r4; diff --git a/tests/baselines/reference/typesWithPrivateConstructor.js b/tests/baselines/reference/typesWithPrivateConstructor.js new file mode 100644 index 00000000000..0faaa4428b5 --- /dev/null +++ b/tests/baselines/reference/typesWithPrivateConstructor.js @@ -0,0 +1,34 @@ +//// [typesWithPrivateConstructor.ts] +// private constructors are not allowed + +class C { + private constructor() { } +} + +var c = new C(); +var r: () => void = c.constructor; + +class C2 { + private constructor(x: number); + private constructor(x: any) { } +} + +var c2 = new C2(); +var r2: (x: number) => void = c2.constructor; + +//// [typesWithPrivateConstructor.js] +// private constructors are not allowed +var C = (function () { + function C() { + } + return C; +})(); +var c = new C(); +var r = c.constructor; +var C2 = (function () { + function C2(x) { + } + return C2; +})(); +var c2 = new C2(); +var r2 = c2.constructor; diff --git a/tests/baselines/reference/unaryOperatorsInStrictMode.js b/tests/baselines/reference/unaryOperatorsInStrictMode.js new file mode 100644 index 00000000000..b766bd3afef --- /dev/null +++ b/tests/baselines/reference/unaryOperatorsInStrictMode.js @@ -0,0 +1,23 @@ +//// [unaryOperatorsInStrictMode.ts] +"use strict" + +++eval; +--eval; +++arguments; +--arguments; +eval++; +eval--; +arguments++; +arguments--; + + +//// [unaryOperatorsInStrictMode.js] +"use strict"; +++eval; +--eval; +++arguments; +--arguments; +eval++; +eval--; +arguments++; +arguments--; diff --git a/tests/baselines/reference/varBlock.js b/tests/baselines/reference/varBlock.js new file mode 100644 index 00000000000..25ee5001d70 --- /dev/null +++ b/tests/baselines/reference/varBlock.js @@ -0,0 +1,49 @@ +//// [varBlock.ts] +module m2 { + + export var a, b2: number = 10, b; +} + +declare module m3 { + var a, b, c; + var a1, b1 = 10; + + class C { + constructor (public c = 10); + } +} + +declare var b = 10; + +declare var a2, b2, c2; + + + +declare var da = 10; +declare var d3, d4 = 10; + +module m3 { + declare var d = 10; + declare var d2, d3 = 10, d4 = 10; + export declare var dE = 10; + export declare var d2E, d3E = 10, d4E = 10; +} + +declare module m4 { + var d = 10; + var d2, d3 = 10, d4 =10; + export var dE = 10; + export var d2E, d3E = 10, d4E = 10; +} + +declare var c; +declare var c = 10; + +//// [varBlock.js] +var m2; +(function (m2) { + m2.a, m2.b2 = 10, m2.b; +})(m2 || (m2 = {})); +var m3; +(function (m3) { +})(m3 || (m3 = {})); diff --git a/tests/baselines/reference/variableDeclarationInStrictMode1.js b/tests/baselines/reference/variableDeclarationInStrictMode1.js new file mode 100644 index 00000000000..3eba8fa3d17 --- /dev/null +++ b/tests/baselines/reference/variableDeclarationInStrictMode1.js @@ -0,0 +1,7 @@ +//// [variableDeclarationInStrictMode1.ts] +"use strict"; +var eval; + +//// [variableDeclarationInStrictMode1.js] +"use strict"; +var eval; diff --git a/tests/baselines/reference/withExportDecl.js b/tests/baselines/reference/withExportDecl.js new file mode 100644 index 00000000000..7fbaa603c31 --- /dev/null +++ b/tests/baselines/reference/withExportDecl.js @@ -0,0 +1,103 @@ +//// [withExportDecl.ts] +var simpleVar; +export var exportedSimpleVar; + +var anotherVar: any; +var varWithSimpleType: number; +var varWithArrayType: number[]; + +var varWithInitialValue = 30; +export var exportedVarWithInitialValue = 70; + +var withComplicatedValue = { x: 30, y: 70, desc: "position" }; +export var exportedWithComplicatedValue = { x: 30, y: 70, desc: "position" }; + +declare var declaredVar; +declare var declareVar2 + +declare var declaredVar; +declare var deckareVarWithType: number; +export declare var exportedDeclaredVar: number; + +var arrayVar: string[] = ['a', 'b']; + +export var exportedArrayVar: { x: number; y: string; }[] ; +exportedArrayVar.push({ x: 30, y : 'hello world' }); + +function simpleFunction() { + return { + x: "Hello", + y: "word", + n: 2 + }; +} + +export function exportedFunction() { + return simpleFunction(); +} + +module m1 { + export function foo() { + return "Hello"; + } +} +declare export module m2 { + + export var a: number; +} + + +export module m3 { + + export function foo() { + return m1.foo(); + } +} + +export var eVar1, eVar2 = 10; +var eVar22; +export var eVar3 = 10, eVar4, eVar5; + +//// [withExportDecl.js] +define(["require", "exports"], function (require, exports) { + var simpleVar; + exports.exportedSimpleVar; + var anotherVar; + var varWithSimpleType; + var varWithArrayType; + var varWithInitialValue = 30; + exports.exportedVarWithInitialValue = 70; + var withComplicatedValue = { x: 30, y: 70, desc: "position" }; + exports.exportedWithComplicatedValue = { x: 30, y: 70, desc: "position" }; + var arrayVar = ['a', 'b']; + exports.exportedArrayVar; + exports.exportedArrayVar.push({ x: 30, y: 'hello world' }); + function simpleFunction() { + return { + x: "Hello", + y: "word", + n: 2 + }; + } + function exportedFunction() { + return simpleFunction(); + } + exports.exportedFunction = exportedFunction; + var m1; + (function (m1) { + function foo() { + return "Hello"; + } + m1.foo = foo; + })(m1 || (m1 = {})); + var m3; + (function (m3) { + function foo() { + return m1.foo(); + } + m3.foo = foo; + })(m3 = exports.m3 || (exports.m3 = {})); + exports.eVar1, exports.eVar2 = 10; + var eVar22; + exports.eVar3 = 10, exports.eVar4, exports.eVar5; +}); diff --git a/tests/baselines/reference/yieldExpression1.js b/tests/baselines/reference/yieldExpression1.js new file mode 100644 index 00000000000..70ed3cc455a --- /dev/null +++ b/tests/baselines/reference/yieldExpression1.js @@ -0,0 +1,9 @@ +//// [yieldExpression1.ts] +function* foo() { + yield +} + +//// [yieldExpression1.js] +function foo() { + ; +} diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index a3875cf8e8c..b639fb29e04 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -39,7 +39,6 @@ module ts { assert.equal(d1.messageText, d2.messageText, "d1.messageText !== d2.messageText"); assert.equal(d1.category, d2.category, "d1.category !== d2.category"); assert.equal(d1.code, d2.code, "d1.code !== d2.code"); - assert.equal(d1.isEarly, d2.isEarly, "d1.isEarly !== d2.isEarly"); } }