From ff0961b85e33f6dd6f876df5c5ed2777ea309bde Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Fri, 8 Sep 2017 15:02:59 -0700 Subject: [PATCH 01/69] Remove trailing space from emitLeadingComment This will prevent emiting an extraneous trailing space on comments to match https://eslint.org/docs/rules/no-trailing-spaces This also removes a space that may have been originally there after a comment but isn't necessary syntactically. --- src/compiler/comments.ts | 3 --- .../baselines/reference/ambientDeclarationsExternal.js | 2 +- tests/baselines/reference/anyAssignableToEveryType.js | 2 +- tests/baselines/reference/augmentedTypesClass3.js | 2 +- tests/baselines/reference/augmentedTypesEnum.js | 2 +- tests/baselines/reference/augmentedTypesEnum2.js | 2 +- tests/baselines/reference/augmentedTypesFunction.js | 2 +- tests/baselines/reference/augmentedTypesInterface.js | 2 +- .../reference/baseIndexSignatureResolution.js | 2 +- tests/baselines/reference/commentEmitAtEndOfFile1.js | 2 +- .../reference/commentEmitWithCommentOnLastLine.js | 2 +- tests/baselines/reference/commentOnArrayElement1.js | 2 +- tests/baselines/reference/commentOnArrayElement3.js | 4 ++-- tests/baselines/reference/commentOnBlock1.js | 2 +- .../reference/commentsArgumentsOfCallExpression1.js | 2 +- .../reference/commentsArgumentsOfCallExpression2.js | 6 +++--- tests/baselines/reference/commentsCommentParsing.js | 10 +++++----- tests/baselines/reference/commentsFunction.js | 4 ++-- .../reference/commentsOnPropertyOfObjectLiteral1.js | 2 +- ...mparisonOperatorWithSubtypeObjectOnCallSignature.js | 2 +- ...nOperatorWithSubtypeObjectOnConstructorSignature.js | 2 +- ...atorWithSubtypeObjectOnInstantiatedCallSignature.js | 2 +- ...hSubtypeObjectOnInstantiatedConstructorSignature.js | 2 +- tests/baselines/reference/concatError.js | 2 +- tests/baselines/reference/errorSupression1.js | 2 +- tests/baselines/reference/everyTypeAssignableToAny.js | 2 +- .../reference/functionConstraintSatisfaction.js | 2 +- .../genericCallWithObjectTypeArgsAndNumericIndexer.js | 2 +- .../genericCallWithObjectTypeArgsAndStringIndexer.js | 2 +- .../baselines/reference/heterogeneousArrayLiterals.js | 2 +- .../reference/innerTypeParameterShadowingOuterOne.js | 2 +- .../reference/innerTypeParameterShadowingOuterOne2.js | 2 +- .../reference/literalsInComputedProperties1.js | 2 +- tests/baselines/reference/moduleIdentifiers.js | 2 +- .../reference/moduleResolutionWithExtensions.js | 4 ++-- tests/baselines/reference/nullAssignableToEveryType.js | 2 +- tests/baselines/reference/parserSkippedTokens10.js | 2 +- .../recursivelySpecializedConstructorDeclaration.js | 2 +- tests/baselines/reference/scannerS7.4_A2_T2.js | 2 +- tests/baselines/reference/sourceMap-Comment1.js | 2 +- .../reference/sourceMap-Comment1.sourcemap.txt | 2 +- .../reference/systemDefaultExportCommentValidity.js | 2 +- .../reference/systemModuleTrailingComments.js | 2 +- .../typeParameterUsedAsTypeParameterConstraint3.js | 2 +- .../reference/undefinedAssignableToEveryType.js | 2 +- 45 files changed, 53 insertions(+), 56 deletions(-) diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index 025a4f36d26..b936c0655e1 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -274,9 +274,6 @@ namespace ts { if (hasTrailingNewLine) { writer.writeLine(); } - else { - writer.write(" "); - } } function emitLeadingCommentsOfPosition(pos: number) { diff --git a/tests/baselines/reference/ambientDeclarationsExternal.js b/tests/baselines/reference/ambientDeclarationsExternal.js index fb531586467..ed413fb0d8e 100644 --- a/tests/baselines/reference/ambientDeclarationsExternal.js +++ b/tests/baselines/reference/ambientDeclarationsExternal.js @@ -24,7 +24,7 @@ var n: number; //// [decls.js] -// Ambient external import declaration referencing ambient external module using top level module name +// Ambient external import declaration referencing ambient external module using top level module name //// [consumer.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/anyAssignableToEveryType.js b/tests/baselines/reference/anyAssignableToEveryType.js index d6b2303de48..eff97905e4f 100644 --- a/tests/baselines/reference/anyAssignableToEveryType.js +++ b/tests/baselines/reference/anyAssignableToEveryType.js @@ -87,4 +87,4 @@ function foo(x, y, z) { // x = a; // y = a; // z = a; -//} +//} diff --git a/tests/baselines/reference/augmentedTypesClass3.js b/tests/baselines/reference/augmentedTypesClass3.js index d2ad63161b5..045109f8587 100644 --- a/tests/baselines/reference/augmentedTypesClass3.js +++ b/tests/baselines/reference/augmentedTypesClass3.js @@ -46,4 +46,4 @@ var c5c = /** @class */ (function () { c5c.prototype.foo = function () { }; return c5c; }()); -//import c5c = require(''); +//import c5c = require(''); diff --git a/tests/baselines/reference/augmentedTypesEnum.js b/tests/baselines/reference/augmentedTypesEnum.js index ff0ad93f817..edd4a92d767 100644 --- a/tests/baselines/reference/augmentedTypesEnum.js +++ b/tests/baselines/reference/augmentedTypesEnum.js @@ -100,4 +100,4 @@ var e6b; })(e6b || (e6b = {})); // should be error // enum then import, messes with error reporting //enum e7 { One } -//import e7 = require(''); // should be error +//import e7 = require(''); // should be error diff --git a/tests/baselines/reference/augmentedTypesEnum2.js b/tests/baselines/reference/augmentedTypesEnum2.js index 66fc96b62a0..0e6e70df263 100644 --- a/tests/baselines/reference/augmentedTypesEnum2.js +++ b/tests/baselines/reference/augmentedTypesEnum2.js @@ -41,4 +41,4 @@ var e2 = /** @class */ (function () { return e2; }()); //enum then enum - covered -//enum then import - covered +//enum then import - covered diff --git a/tests/baselines/reference/augmentedTypesFunction.js b/tests/baselines/reference/augmentedTypesFunction.js index 3c6066e5bb4..a2dd4a664a3 100644 --- a/tests/baselines/reference/augmentedTypesFunction.js +++ b/tests/baselines/reference/augmentedTypesFunction.js @@ -79,4 +79,4 @@ function y5b() { } function y5c() { } // function then import, messes with other errors //function y6() { } -//import y6 = require(''); +//import y6 = require(''); diff --git a/tests/baselines/reference/augmentedTypesInterface.js b/tests/baselines/reference/augmentedTypesInterface.js index b74da5bbfee..0409e157584 100644 --- a/tests/baselines/reference/augmentedTypesInterface.js +++ b/tests/baselines/reference/augmentedTypesInterface.js @@ -48,4 +48,4 @@ var i3; i3[i3["One"] = 0] = "One"; })(i3 || (i3 = {})); ; // error -//import i4 = require(''); // error +//import i4 = require(''); // error diff --git a/tests/baselines/reference/baseIndexSignatureResolution.js b/tests/baselines/reference/baseIndexSignatureResolution.js index 4053e588e44..3fdeecf78f6 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -59,4 +59,4 @@ interface B extends A { } var b: B = null; var z: Derived = b.foo(); -*/ +*/ diff --git a/tests/baselines/reference/commentEmitAtEndOfFile1.js b/tests/baselines/reference/commentEmitAtEndOfFile1.js index 1be031fa84a..d6ba7b158d6 100644 --- a/tests/baselines/reference/commentEmitAtEndOfFile1.js +++ b/tests/baselines/reference/commentEmitAtEndOfFile1.js @@ -18,4 +18,4 @@ var foo; (function (foo) { function bar() { } })(foo || (foo = {})); -// test #4 +// test #4 diff --git a/tests/baselines/reference/commentEmitWithCommentOnLastLine.js b/tests/baselines/reference/commentEmitWithCommentOnLastLine.js index ffd4addb264..077286a7364 100644 --- a/tests/baselines/reference/commentEmitWithCommentOnLastLine.js +++ b/tests/baselines/reference/commentEmitWithCommentOnLastLine.js @@ -8,4 +8,4 @@ var bar; var x; /* var bar; -*/ +*/ diff --git a/tests/baselines/reference/commentOnArrayElement1.js b/tests/baselines/reference/commentOnArrayElement1.js index 960df336dbb..c93cf634096 100644 --- a/tests/baselines/reference/commentOnArrayElement1.js +++ b/tests/baselines/reference/commentOnArrayElement1.js @@ -11,7 +11,7 @@ var array = [ var array = [ /* element 1*/ 1 - /* end of element 1 */ , + /* end of element 1 */, 2 /* end of element 2 */ ]; diff --git a/tests/baselines/reference/commentOnArrayElement3.js b/tests/baselines/reference/commentOnArrayElement3.js index e31f8adf26a..f19ef5d6050 100644 --- a/tests/baselines/reference/commentOnArrayElement3.js +++ b/tests/baselines/reference/commentOnArrayElement3.js @@ -12,8 +12,8 @@ var array = [ var array = [ /* element 1*/ 1 - /* end of element 1 */ , + /* end of element 1 */, 2 - /* end of element 2 */ , + /* end of element 2 */, , ]; diff --git a/tests/baselines/reference/commentOnBlock1.js b/tests/baselines/reference/commentOnBlock1.js index ed5437c1f66..20df3764b77 100644 --- a/tests/baselines/reference/commentOnBlock1.js +++ b/tests/baselines/reference/commentOnBlock1.js @@ -7,5 +7,5 @@ function f() { //// [commentOnBlock1.js] // asdf function f() { - /*asdf*/ { } + /*asdf*/{ } } diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression1.js b/tests/baselines/reference/commentsArgumentsOfCallExpression1.js index 4e6d693c5c2..f32e0bb8098 100644 --- a/tests/baselines/reference/commentsArgumentsOfCallExpression1.js +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression1.js @@ -29,4 +29,4 @@ function () { }); foo(/*c7*/ function () { }); foo( /*c7*/ -/*c8*/ function () { }); +/*c8*/function () { }); diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression2.js b/tests/baselines/reference/commentsArgumentsOfCallExpression2.js index f89e67ef3d8..1e1079a4d22 100644 --- a/tests/baselines/reference/commentsArgumentsOfCallExpression2.js +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression2.js @@ -17,7 +17,7 @@ foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); foo(/*c3*/ function () { }, /*d2*/ function () { }, /*e2*/ a + /*e3*/ b); foo(/*c3*/ function () { }, /*d3*/ function () { }, /*e3*/ (a + b)); foo( -/*c4*/ function () { }, -/*d4*/ function () { }, +/*c4*/function () { }, +/*d4*/function () { }, /*e4*/ -/*e5*/ "hello"); +/*e5*/"hello"); diff --git a/tests/baselines/reference/commentsCommentParsing.js b/tests/baselines/reference/commentsCommentParsing.js index 889067a3c05..c39bf05e556 100644 --- a/tests/baselines/reference/commentsCommentParsing.js +++ b/tests/baselines/reference/commentsCommentParsing.js @@ -178,7 +178,7 @@ jsDocMultiLine(); *New line1 *New Line2*/ /** Shoul mege this line as well -* and this too*/ /** Another this one too*/ +* and this too*//** Another this one too*/ function jsDocMultiLineMerge() { } jsDocMultiLineMerge(); @@ -188,23 +188,23 @@ function jsDocMixedComments1() { } jsDocMixedComments1(); /// Triple slash comment -/** jsdoc comment */ /*** another jsDocComment*/ +/** jsdoc comment *//*** another jsDocComment*/ function jsDocMixedComments2() { } jsDocMixedComments2(); -/** jsdoc comment */ /*** another jsDocComment*/ +/** jsdoc comment *//*** another jsDocComment*/ /// Triple slash comment function jsDocMixedComments3() { } jsDocMixedComments3(); -/** jsdoc comment */ /*** another jsDocComment*/ +/** jsdoc comment *//*** another jsDocComment*/ /// Triple slash comment /// Triple slash comment 2 function jsDocMixedComments4() { } jsDocMixedComments4(); /// Triple slash comment 1 -/** jsdoc comment */ /*** another jsDocComment*/ +/** jsdoc comment *//*** another jsDocComment*/ /// Triple slash comment /// Triple slash comment 2 function jsDocMixedComments5() { diff --git a/tests/baselines/reference/commentsFunction.js b/tests/baselines/reference/commentsFunction.js index ad31aa47b91..a02ffb3b364 100644 --- a/tests/baselines/reference/commentsFunction.js +++ b/tests/baselines/reference/commentsFunction.js @@ -86,8 +86,8 @@ function blah3(a // trailing commen single line ) { } lambdaFoo = function (a, b) { return a * b; }; // This is trailing comment -/*leading comment*/ (function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration) -/*leading comment*/ (function () { return 0; }); //trailing comment +/*leading comment*/(function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration) +/*leading comment*/(function () { return 0; }); //trailing comment function blah4(/*1*/ a /*2*/, /*3*/ b /*4*/) { } function foo1() { diff --git a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js index fa7790443ac..39190d9173a 100644 --- a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js +++ b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js @@ -18,7 +18,7 @@ var resolve = { id: /*! @ngInject */ function (details) { return details.id; }, id1: /* c1 */ "hello", id2: - /*! @ngInject */ function (details) { return details.id; }, + /*! @ngInject */function (details) { return details.id; }, id3: /*! @ngInject */ function (details) { return details.id; }, diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js index 079a1e276fb..bcd87998f83 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnCallSignature.js @@ -505,4 +505,4 @@ var r8b8 = b8 !== a8; var r8b9 = b9 !== a9; var r8b10 = b10 !== a10; var r8b11 = b11 !== a11; -//var r8b12 = b12 !== a12; +//var r8b12 = b12 !== a12; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js index 38097a936e3..1721f564865 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnConstructorSignature.js @@ -431,4 +431,4 @@ var r8b6 = b6 !== a6; var r8b7 = b7 !== a7; var r8b8 = b8 !== a8; var r8b9 = b9 !== a9; -//var r8b10 = b10 !== a10; +//var r8b10 = b10 !== a10; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js index 87359ea0074..72dd4be0afc 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedCallSignature.js @@ -320,4 +320,4 @@ var r8b3 = b3 !== a3; var r8b4 = b4 !== a4; var r8b5 = b5 !== a5; var r8b6 = b6 !== a6; -//var r8b7 = b7 !== a7; +//var r8b7 = b7 !== a7; diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js index fcfbfa4bfbc..19183773406 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeObjectOnInstantiatedConstructorSignature.js @@ -320,4 +320,4 @@ var r8b3 = b3 !== a3; var r8b4 = b4 !== a4; var r8b5 = b5 !== a5; var r8b6 = b6 !== a6; -//var r8b7 = b7 !== a7; +//var r8b7 = b7 !== a7; diff --git a/tests/baselines/reference/concatError.js b/tests/baselines/reference/concatError.js index 67361719702..d2b30218e50 100644 --- a/tests/baselines/reference/concatError.js +++ b/tests/baselines/reference/concatError.js @@ -56,4 +56,4 @@ var c: C; var cc: C>; c = c.m(cc); -*/ +*/ diff --git a/tests/baselines/reference/errorSupression1.js b/tests/baselines/reference/errorSupression1.js index 2f467871434..4b635a0d660 100644 --- a/tests/baselines/reference/errorSupression1.js +++ b/tests/baselines/reference/errorSupression1.js @@ -17,4 +17,4 @@ var Foo = /** @class */ (function () { var baz = Foo.b; // Foo.b won't bind. baz.concat("y"); -// So we don't want an error on 'concat'. +// So we don't want an error on 'concat'. diff --git a/tests/baselines/reference/everyTypeAssignableToAny.js b/tests/baselines/reference/everyTypeAssignableToAny.js index 7f02badca00..fd71ec624be 100644 --- a/tests/baselines/reference/everyTypeAssignableToAny.js +++ b/tests/baselines/reference/everyTypeAssignableToAny.js @@ -117,4 +117,4 @@ function foo(x, y, z) { // a = x; // a = y; // a = z; -//} +//} diff --git a/tests/baselines/reference/functionConstraintSatisfaction.js b/tests/baselines/reference/functionConstraintSatisfaction.js index fc8a2be88a7..f24fd32aff6 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction.js +++ b/tests/baselines/reference/functionConstraintSatisfaction.js @@ -108,4 +108,4 @@ function foo2(x, y) { //function foo2(x: T, y: U) { // foo(x); // foo(y); -//} +//} diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.js index f300e3a8093..27e4093d9c7 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.js @@ -63,4 +63,4 @@ function other3(arg) { // var d = r2[1]; // // BUG 821629 // //var u: U = r2[1]; // ok -//} +//} diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.js b/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.js index eee87caf3de..ee33746b152 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.js +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.js @@ -64,4 +64,4 @@ function other3(arg) { // var d: Date = r2['hm']; // ok // // BUG 821629 // //var u: U = r2['hm']; // ok -//} +//} diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.js b/tests/baselines/reference/heterogeneousArrayLiterals.js index 499aa7e7818..46dee284ae9 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.js +++ b/tests/baselines/reference/heterogeneousArrayLiterals.js @@ -268,4 +268,4 @@ function foo4(t, u) { // var i = [u, base]; // Base[] // var j = [u, derived]; // Derived[] // var k: Base[] = [t, u]; -//} +//} diff --git a/tests/baselines/reference/innerTypeParameterShadowingOuterOne.js b/tests/baselines/reference/innerTypeParameterShadowingOuterOne.js index 74354468e32..f566bbdd878 100644 --- a/tests/baselines/reference/innerTypeParameterShadowingOuterOne.js +++ b/tests/baselines/reference/innerTypeParameterShadowingOuterOne.js @@ -54,4 +54,4 @@ function f2() { // } // var x: U; // x.getDate(); -//} +//} diff --git a/tests/baselines/reference/innerTypeParameterShadowingOuterOne2.js b/tests/baselines/reference/innerTypeParameterShadowingOuterOne2.js index 984584389f6..824061fce1f 100644 --- a/tests/baselines/reference/innerTypeParameterShadowingOuterOne2.js +++ b/tests/baselines/reference/innerTypeParameterShadowingOuterOne2.js @@ -75,4 +75,4 @@ var C2 = /** @class */ (function () { // var x: U; // x.getDate(); // } -//} +//} diff --git a/tests/baselines/reference/literalsInComputedProperties1.js b/tests/baselines/reference/literalsInComputedProperties1.js index c5b0060f626..4611925f2d4 100644 --- a/tests/baselines/reference/literalsInComputedProperties1.js +++ b/tests/baselines/reference/literalsInComputedProperties1.js @@ -89,4 +89,4 @@ var X; var a = X["foo"]; var a0 = X["bar"]; var _a; -// TODO: make sure that enum still disallow template literals as member names +// TODO: make sure that enum still disallow template literals as member names diff --git a/tests/baselines/reference/moduleIdentifiers.js b/tests/baselines/reference/moduleIdentifiers.js index 04d39019482..d3a654b8670 100644 --- a/tests/baselines/reference/moduleIdentifiers.js +++ b/tests/baselines/reference/moduleIdentifiers.js @@ -19,4 +19,4 @@ var M; //var m: M = M; var x1 = M.a; //var x2 = m.a; -//var q: m.P; +//var q: m.P; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.js b/tests/baselines/reference/moduleResolutionWithExtensions.js index c1e0310e995..3406bb0adae 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions.js @@ -28,11 +28,11 @@ import j from "./jquery.js" "use strict"; exports.__esModule = true; exports["default"] = 0; -// No extension: '.ts' added +// No extension: '.ts' added //// [b.js] "use strict"; exports.__esModule = true; -// '.js' extension: stripped and replaced with '.ts' +// '.js' extension: stripped and replaced with '.ts' //// [d.js] "use strict"; exports.__esModule = true; diff --git a/tests/baselines/reference/nullAssignableToEveryType.js b/tests/baselines/reference/nullAssignableToEveryType.js index f04ae865692..50914b366f8 100644 --- a/tests/baselines/reference/nullAssignableToEveryType.js +++ b/tests/baselines/reference/nullAssignableToEveryType.js @@ -84,4 +84,4 @@ function foo(x, y, z) { // x = null; // y = null; // z = null; -//} +//} diff --git a/tests/baselines/reference/parserSkippedTokens10.js b/tests/baselines/reference/parserSkippedTokens10.js index cfacb2e21bd..3af628a2e1e 100644 --- a/tests/baselines/reference/parserSkippedTokens10.js +++ b/tests/baselines/reference/parserSkippedTokens10.js @@ -5,4 +5,4 @@ //// [parserSkippedTokens10.js] -/*existing trivia*/ ; +/*existing trivia*/; diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js index beff303c540..dbf4b6b27d1 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js @@ -78,4 +78,4 @@ declare module MsPortal.Controls.Base.ItemList { class ViewModel extends ItemValue { } } -*/ +*/ diff --git a/tests/baselines/reference/scannerS7.4_A2_T2.js b/tests/baselines/reference/scannerS7.4_A2_T2.js index 9cfc0b03bd8..4a446b520ad 100644 --- a/tests/baselines/reference/scannerS7.4_A2_T2.js +++ b/tests/baselines/reference/scannerS7.4_A2_T2.js @@ -26,4 +26,4 @@ */ /*CHECK#1/ - + diff --git a/tests/baselines/reference/sourceMap-Comment1.js b/tests/baselines/reference/sourceMap-Comment1.js index 071e54b5716..6f1f43cd8e2 100644 --- a/tests/baselines/reference/sourceMap-Comment1.js +++ b/tests/baselines/reference/sourceMap-Comment1.js @@ -2,5 +2,5 @@ // Comment //// [sourceMap-Comment1.js] -// Comment +// Comment //# sourceMappingURL=sourceMap-Comment1.js.map \ No newline at end of file diff --git a/tests/baselines/reference/sourceMap-Comment1.sourcemap.txt b/tests/baselines/reference/sourceMap-Comment1.sourcemap.txt index 4d427d1de89..e2f9174a45f 100644 --- a/tests/baselines/reference/sourceMap-Comment1.sourcemap.txt +++ b/tests/baselines/reference/sourceMap-Comment1.sourcemap.txt @@ -8,7 +8,7 @@ sources: sourceMap-Comment1.ts emittedFile:tests/cases/compiler/sourceMap-Comment1.js sourceFile:sourceMap-Comment1.ts ------------------------------------------------------------------- ->>>// Comment +>>>// Comment 1 > 2 >^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> diff --git a/tests/baselines/reference/systemDefaultExportCommentValidity.js b/tests/baselines/reference/systemDefaultExportCommentValidity.js index a56110b0de9..45fe1df3ccd 100644 --- a/tests/baselines/reference/systemDefaultExportCommentValidity.js +++ b/tests/baselines/reference/systemDefaultExportCommentValidity.js @@ -14,7 +14,7 @@ System.register([], function (exports_1, context_1) { execute: function () { Home = {}; exports_1("default", Home); - // There is intentionally no semicolon on the prior line, this comment should not break emit + // There is intentionally no semicolon on the prior line, this comment should not break emit } }; }); diff --git a/tests/baselines/reference/systemModuleTrailingComments.js b/tests/baselines/reference/systemModuleTrailingComments.js index 41b0bd299a0..01f17d1facf 100644 --- a/tests/baselines/reference/systemModuleTrailingComments.js +++ b/tests/baselines/reference/systemModuleTrailingComments.js @@ -12,7 +12,7 @@ System.register([], function (exports_1, context_1) { setters: [], execute: function () { exports_1("test", test = "TEST"); - //some comment + //some comment } }; }); diff --git a/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint3.js b/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint3.js index 95c65d5f3a9..0655ad17138 100644 --- a/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint3.js +++ b/tests/baselines/reference/typeParameterUsedAsTypeParameterConstraint3.js @@ -64,4 +64,4 @@ interface I2 { // y: U; // z: V; // foo(x: W): T; -//} +//} diff --git a/tests/baselines/reference/undefinedAssignableToEveryType.js b/tests/baselines/reference/undefinedAssignableToEveryType.js index 507f647763a..de64f97f70b 100644 --- a/tests/baselines/reference/undefinedAssignableToEveryType.js +++ b/tests/baselines/reference/undefinedAssignableToEveryType.js @@ -83,4 +83,4 @@ function foo(x, y, z) { // x = undefined; // y = undefined; // z = undefined; -//} +//} From dcd2ddd0b71f6682c3d020ada0e9ac482b9b3d33 Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Tue, 26 Sep 2017 12:09:58 -0700 Subject: [PATCH 02/69] Yes space after multiline comments --- src/compiler/comments.ts | 3 +++ .../reference/baseIndexSignatureResolution.js | 2 +- .../reference/commentEmitWithCommentOnLastLine.js | 2 +- tests/baselines/reference/commentOnArrayElement1.js | 2 +- tests/baselines/reference/commentOnArrayElement3.js | 4 ++-- tests/baselines/reference/commentOnBlock1.js | 2 +- .../reference/commentsArgumentsOfCallExpression1.js | 2 +- .../reference/commentsArgumentsOfCallExpression2.js | 6 +++--- tests/baselines/reference/commentsCommentParsing.js | 10 +++++----- tests/baselines/reference/commentsFunction.js | 4 ++-- .../reference/commentsOnPropertyOfObjectLiteral1.js | 2 +- tests/baselines/reference/concatError.js | 2 +- tests/baselines/reference/parserSkippedTokens10.js | 2 +- .../recursivelySpecializedConstructorDeclaration.js | 2 +- tests/baselines/reference/scannerS7.4_A2_T2.js | 2 +- 15 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index b936c0655e1..bb8ec9bf3e7 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -274,6 +274,9 @@ namespace ts { if (hasTrailingNewLine) { writer.writeLine(); } + else if (_kind === SyntaxKind.MultiLineCommentTrivia) { + writer.write(" "); + } } function emitLeadingCommentsOfPosition(pos: number) { diff --git a/tests/baselines/reference/baseIndexSignatureResolution.js b/tests/baselines/reference/baseIndexSignatureResolution.js index 3fdeecf78f6..4053e588e44 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.js +++ b/tests/baselines/reference/baseIndexSignatureResolution.js @@ -59,4 +59,4 @@ interface B extends A { } var b: B = null; var z: Derived = b.foo(); -*/ +*/ diff --git a/tests/baselines/reference/commentEmitWithCommentOnLastLine.js b/tests/baselines/reference/commentEmitWithCommentOnLastLine.js index 077286a7364..ffd4addb264 100644 --- a/tests/baselines/reference/commentEmitWithCommentOnLastLine.js +++ b/tests/baselines/reference/commentEmitWithCommentOnLastLine.js @@ -8,4 +8,4 @@ var bar; var x; /* var bar; -*/ +*/ diff --git a/tests/baselines/reference/commentOnArrayElement1.js b/tests/baselines/reference/commentOnArrayElement1.js index c93cf634096..960df336dbb 100644 --- a/tests/baselines/reference/commentOnArrayElement1.js +++ b/tests/baselines/reference/commentOnArrayElement1.js @@ -11,7 +11,7 @@ var array = [ var array = [ /* element 1*/ 1 - /* end of element 1 */, + /* end of element 1 */ , 2 /* end of element 2 */ ]; diff --git a/tests/baselines/reference/commentOnArrayElement3.js b/tests/baselines/reference/commentOnArrayElement3.js index f19ef5d6050..e31f8adf26a 100644 --- a/tests/baselines/reference/commentOnArrayElement3.js +++ b/tests/baselines/reference/commentOnArrayElement3.js @@ -12,8 +12,8 @@ var array = [ var array = [ /* element 1*/ 1 - /* end of element 1 */, + /* end of element 1 */ , 2 - /* end of element 2 */, + /* end of element 2 */ , , ]; diff --git a/tests/baselines/reference/commentOnBlock1.js b/tests/baselines/reference/commentOnBlock1.js index 20df3764b77..ed5437c1f66 100644 --- a/tests/baselines/reference/commentOnBlock1.js +++ b/tests/baselines/reference/commentOnBlock1.js @@ -7,5 +7,5 @@ function f() { //// [commentOnBlock1.js] // asdf function f() { - /*asdf*/{ } + /*asdf*/ { } } diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression1.js b/tests/baselines/reference/commentsArgumentsOfCallExpression1.js index f32e0bb8098..4e6d693c5c2 100644 --- a/tests/baselines/reference/commentsArgumentsOfCallExpression1.js +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression1.js @@ -29,4 +29,4 @@ function () { }); foo(/*c7*/ function () { }); foo( /*c7*/ -/*c8*/function () { }); +/*c8*/ function () { }); diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression2.js b/tests/baselines/reference/commentsArgumentsOfCallExpression2.js index 1e1079a4d22..f89e67ef3d8 100644 --- a/tests/baselines/reference/commentsArgumentsOfCallExpression2.js +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression2.js @@ -17,7 +17,7 @@ foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); foo(/*c3*/ function () { }, /*d2*/ function () { }, /*e2*/ a + /*e3*/ b); foo(/*c3*/ function () { }, /*d3*/ function () { }, /*e3*/ (a + b)); foo( -/*c4*/function () { }, -/*d4*/function () { }, +/*c4*/ function () { }, +/*d4*/ function () { }, /*e4*/ -/*e5*/"hello"); +/*e5*/ "hello"); diff --git a/tests/baselines/reference/commentsCommentParsing.js b/tests/baselines/reference/commentsCommentParsing.js index c39bf05e556..889067a3c05 100644 --- a/tests/baselines/reference/commentsCommentParsing.js +++ b/tests/baselines/reference/commentsCommentParsing.js @@ -178,7 +178,7 @@ jsDocMultiLine(); *New line1 *New Line2*/ /** Shoul mege this line as well -* and this too*//** Another this one too*/ +* and this too*/ /** Another this one too*/ function jsDocMultiLineMerge() { } jsDocMultiLineMerge(); @@ -188,23 +188,23 @@ function jsDocMixedComments1() { } jsDocMixedComments1(); /// Triple slash comment -/** jsdoc comment *//*** another jsDocComment*/ +/** jsdoc comment */ /*** another jsDocComment*/ function jsDocMixedComments2() { } jsDocMixedComments2(); -/** jsdoc comment *//*** another jsDocComment*/ +/** jsdoc comment */ /*** another jsDocComment*/ /// Triple slash comment function jsDocMixedComments3() { } jsDocMixedComments3(); -/** jsdoc comment *//*** another jsDocComment*/ +/** jsdoc comment */ /*** another jsDocComment*/ /// Triple slash comment /// Triple slash comment 2 function jsDocMixedComments4() { } jsDocMixedComments4(); /// Triple slash comment 1 -/** jsdoc comment *//*** another jsDocComment*/ +/** jsdoc comment */ /*** another jsDocComment*/ /// Triple slash comment /// Triple slash comment 2 function jsDocMixedComments5() { diff --git a/tests/baselines/reference/commentsFunction.js b/tests/baselines/reference/commentsFunction.js index a02ffb3b364..ad31aa47b91 100644 --- a/tests/baselines/reference/commentsFunction.js +++ b/tests/baselines/reference/commentsFunction.js @@ -86,8 +86,8 @@ function blah3(a // trailing commen single line ) { } lambdaFoo = function (a, b) { return a * b; }; // This is trailing comment -/*leading comment*/(function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration) -/*leading comment*/(function () { return 0; }); //trailing comment +/*leading comment*/ (function () { return 0; }); // Needs to be wrapped in parens to be a valid expression (not declaration) +/*leading comment*/ (function () { return 0; }); //trailing comment function blah4(/*1*/ a /*2*/, /*3*/ b /*4*/) { } function foo1() { diff --git a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js index 39190d9173a..fa7790443ac 100644 --- a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js +++ b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.js @@ -18,7 +18,7 @@ var resolve = { id: /*! @ngInject */ function (details) { return details.id; }, id1: /* c1 */ "hello", id2: - /*! @ngInject */function (details) { return details.id; }, + /*! @ngInject */ function (details) { return details.id; }, id3: /*! @ngInject */ function (details) { return details.id; }, diff --git a/tests/baselines/reference/concatError.js b/tests/baselines/reference/concatError.js index d2b30218e50..67361719702 100644 --- a/tests/baselines/reference/concatError.js +++ b/tests/baselines/reference/concatError.js @@ -56,4 +56,4 @@ var c: C; var cc: C>; c = c.m(cc); -*/ +*/ diff --git a/tests/baselines/reference/parserSkippedTokens10.js b/tests/baselines/reference/parserSkippedTokens10.js index 3af628a2e1e..cfacb2e21bd 100644 --- a/tests/baselines/reference/parserSkippedTokens10.js +++ b/tests/baselines/reference/parserSkippedTokens10.js @@ -5,4 +5,4 @@ //// [parserSkippedTokens10.js] -/*existing trivia*/; +/*existing trivia*/ ; diff --git a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js index dbf4b6b27d1..beff303c540 100644 --- a/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js +++ b/tests/baselines/reference/recursivelySpecializedConstructorDeclaration.js @@ -78,4 +78,4 @@ declare module MsPortal.Controls.Base.ItemList { class ViewModel extends ItemValue { } } -*/ +*/ diff --git a/tests/baselines/reference/scannerS7.4_A2_T2.js b/tests/baselines/reference/scannerS7.4_A2_T2.js index 4a446b520ad..9cfc0b03bd8 100644 --- a/tests/baselines/reference/scannerS7.4_A2_T2.js +++ b/tests/baselines/reference/scannerS7.4_A2_T2.js @@ -26,4 +26,4 @@ */ /*CHECK#1/ - + From 7b0e74d91a02f0da8993f6dec401cf4cad6bc8bf Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 3 Oct 2017 12:41:33 -0700 Subject: [PATCH 03/69] Binding pattern contextual type checks spread type The spread type can contain properties that have been built up during the construction of the object literal. --- src/compiler/checker.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c9b818cd79..6cdad32751c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13890,7 +13890,7 @@ namespace ts { // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { for (const prop of getPropertiesOfType(contextualType)) { - if (!propertiesTable.get(prop.escapedName)) { + if (!propertiesTable.get(prop.escapedName) && !(spread && getPropertyOfType(spread, prop.escapedName))) { if (!(prop.flags & SymbolFlags.Optional)) { error(prop.valueDeclaration || (prop).bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); From 2c04b5510fcf735775a0891cab7283864e923ca1 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 3 Oct 2017 12:43:23 -0700 Subject: [PATCH 04/69] Test:spread contextually typed by binding pattern --- .../spreadContextualTypedBindingPattern.js | 25 +++++++++++++++++ ...preadContextualTypedBindingPattern.symbols | 27 ++++++++++++++++++ .../spreadContextualTypedBindingPattern.types | 28 +++++++++++++++++++ .../spreadContextualTypedBindingPattern.ts | 11 ++++++++ 4 files changed, 91 insertions(+) create mode 100644 tests/baselines/reference/spreadContextualTypedBindingPattern.js create mode 100644 tests/baselines/reference/spreadContextualTypedBindingPattern.symbols create mode 100644 tests/baselines/reference/spreadContextualTypedBindingPattern.types create mode 100644 tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts diff --git a/tests/baselines/reference/spreadContextualTypedBindingPattern.js b/tests/baselines/reference/spreadContextualTypedBindingPattern.js new file mode 100644 index 00000000000..a97a3124886 --- /dev/null +++ b/tests/baselines/reference/spreadContextualTypedBindingPattern.js @@ -0,0 +1,25 @@ +//// [spreadContextualTypedBindingPattern.ts] +// #18308 +interface Person { + naam: string, + age: number +} + +declare const bob: Person +declare const alice: Person + +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +const { naam, age } = {...bob, ...alice} + + +//// [spreadContextualTypedBindingPattern.js] +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +var _a = __assign({}, bob, alice), naam = _a.naam, age = _a.age; diff --git a/tests/baselines/reference/spreadContextualTypedBindingPattern.symbols b/tests/baselines/reference/spreadContextualTypedBindingPattern.symbols new file mode 100644 index 00000000000..260ac282b07 --- /dev/null +++ b/tests/baselines/reference/spreadContextualTypedBindingPattern.symbols @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts === +// #18308 +interface Person { +>Person : Symbol(Person, Decl(spreadContextualTypedBindingPattern.ts, 0, 0)) + + naam: string, +>naam : Symbol(Person.naam, Decl(spreadContextualTypedBindingPattern.ts, 1, 18)) + + age: number +>age : Symbol(Person.age, Decl(spreadContextualTypedBindingPattern.ts, 2, 15)) +} + +declare const bob: Person +>bob : Symbol(bob, Decl(spreadContextualTypedBindingPattern.ts, 6, 13)) +>Person : Symbol(Person, Decl(spreadContextualTypedBindingPattern.ts, 0, 0)) + +declare const alice: Person +>alice : Symbol(alice, Decl(spreadContextualTypedBindingPattern.ts, 7, 13)) +>Person : Symbol(Person, Decl(spreadContextualTypedBindingPattern.ts, 0, 0)) + +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +const { naam, age } = {...bob, ...alice} +>naam : Symbol(naam, Decl(spreadContextualTypedBindingPattern.ts, 10, 7)) +>age : Symbol(age, Decl(spreadContextualTypedBindingPattern.ts, 10, 13)) +>bob : Symbol(bob, Decl(spreadContextualTypedBindingPattern.ts, 6, 13)) +>alice : Symbol(alice, Decl(spreadContextualTypedBindingPattern.ts, 7, 13)) + diff --git a/tests/baselines/reference/spreadContextualTypedBindingPattern.types b/tests/baselines/reference/spreadContextualTypedBindingPattern.types new file mode 100644 index 00000000000..c58fb9e357e --- /dev/null +++ b/tests/baselines/reference/spreadContextualTypedBindingPattern.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts === +// #18308 +interface Person { +>Person : Person + + naam: string, +>naam : string + + age: number +>age : number +} + +declare const bob: Person +>bob : Person +>Person : Person + +declare const alice: Person +>alice : Person +>Person : Person + +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +const { naam, age } = {...bob, ...alice} +>naam : string +>age : number +>{...bob, ...alice} : { naam: string; age: number; } +>bob : Person +>alice : Person + diff --git a/tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts b/tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts new file mode 100644 index 00000000000..1414c5f278b --- /dev/null +++ b/tests/cases/conformance/types/spread/spreadContextualTypedBindingPattern.ts @@ -0,0 +1,11 @@ +// #18308 +interface Person { + naam: string, + age: number +} + +declare const bob: Person +declare const alice: Person + +// [ts] Initializer provides no value for this binding element and the binding element has no default value. +const { naam, age } = {...bob, ...alice} From da63c2c57977840cf0b349c84ab139a92e6f4787 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 27 Oct 2017 16:24:12 -0700 Subject: [PATCH 05/69] Exclude legacy safelist files in external projects --- src/compiler/core.ts | 7 ++++ src/server/editorServices.ts | 33 +++++++++++++++---- src/services/jsTyping.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 7 ++-- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 12b8dd2f87e..c9b644b22ce 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2413,6 +2413,13 @@ namespace ts { return (removeFileExtension(path) + newExtension); } + /** + * Takes a string like "jquery-min.4.2.3" and returns "jquery" + */ + export function removeMinAndVersionNumbers(fileName: string) { + return fileName.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); + } + export interface ObjectAllocator { getNodeConstructor(): new (kind: SyntaxKind, pos?: number, end?: number) => Node; getTokenConstructor(): new (kind: TKind, pos?: number, end?: number) => Token; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index b7617e1fa17..eb2ae0f3cd9 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -110,7 +110,7 @@ namespace ts.server { export interface TypesMapFile { typesMap: SafeList; - simpleMap: string[]; + simpleMap: { [libName: string]: string }; } /** @@ -374,6 +374,7 @@ namespace ts.server { private readonly hostConfiguration: HostConfiguration; private safelist: SafeList = defaultTypeSafeList; + private legacySafelist: { [key: string]: string } = {}; private changedFiles: ScriptInfo[]; private pendingProjectUpdates = createMap(); @@ -426,9 +427,12 @@ namespace ts.server { this.toCanonicalFileName = createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); this.throttledOperations = new ThrottledOperations(this.host, this.logger); - if (opts.typesMapLocation) { + if (this.typesMapLocation) { this.loadTypesMap(); } + else { + this.logger.info("No types map provided; using the default"); + } this.typingsInstaller.attach(this); @@ -518,10 +522,12 @@ namespace ts.server { } // raw is now fixed and ready this.safelist = raw.typesMap; + this.legacySafelist = raw.simpleMap; } catch (e) { this.logger.info(`Error loading types map: ${e}`); this.safelist = defaultTypeSafeList; + this.legacySafelist = {}; } } @@ -1393,7 +1399,7 @@ namespace ts.server { return false; } - private createExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typeAcquisition: TypeAcquisition) { + private createExternalProject(projectFileName: string, files: protocol.ExternalFile[], options: protocol.ExternalProjectCompilerOptions, typeAcquisition: TypeAcquisition, excludedFiles: NormalizedPath[]) { const compilerOptions = convertCompilerOptions(options); const project = new ExternalProject( projectFileName, @@ -1402,6 +1408,7 @@ namespace ts.server { compilerOptions, /*languageServiceEnabled*/ !this.exceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + project.excludedFiles = excludedFiles; this.addFilesToNonInferredProjectAndUpdateGraph(project, files, externalFilePropertyReader, typeAcquisition); this.externalProjects.push(project); @@ -2204,7 +2211,22 @@ namespace ts.server { excludedFiles.push(normalizedNames[i]); } else { - filesToKeep.push(proj.rootFiles[i]); + let exclude = false; + if (typeAcquisition && (typeAcquisition.enable || typeAcquisition.enableAutoDiscovery)) { + const baseName = getBaseFileName(normalizedNames[i].toLowerCase()); + if (fileExtensionIs(baseName, "js")) { + const inferredTypingName = removeFileExtension(baseName); + const cleanedTypingName = removeMinAndVersionNumbers(inferredTypingName); + if (this.legacySafelist[cleanedTypingName]) { + this.logger.info(`Excluded '${normalizedNames[i]}'`); + excludedFiles.push(normalizedNames[i]); + exclude = true; + } + } + } + if (!exclude) { + filesToKeep.push(proj.rootFiles[i]); + } } } proj.rootFiles = filesToKeep; @@ -2312,8 +2334,7 @@ namespace ts.server { else { // no config files - remove the item from the collection this.externalProjectToConfiguredProjectMap.delete(proj.projectFileName); - const newProj = this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition); - newProj.excludedFiles = excludedFiles; + this.createExternalProject(proj.projectFileName, rootFiles, proj.options, proj.typeAcquisition, excludedFiles); } if (!suppressRefreshOfInferredProjects) { this.ensureProjectStructuresUptoDate(/*refreshInferredProjects*/ true); diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 572858dd2fd..e31201b951f 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -180,7 +180,7 @@ namespace ts.JsTyping { if (!hasJavaScriptFileExtension(j)) return undefined; const inferredTypingName = removeFileExtension(getBaseFileName(j.toLowerCase())); - const cleanedTypingName = inferredTypingName.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); + const cleanedTypingName = removeMinAndVersionNumbers(inferredTypingName); return safeList.get(cleanedTypingName); }); if (fromFileNames.length) { diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5d439e840b0..44c8095b9fb 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -7391,7 +7391,9 @@ declare namespace ts.server { } interface TypesMapFile { typesMap: SafeList; - simpleMap: string[]; + simpleMap: { + [libName: string]: string; + }; } function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; @@ -7468,6 +7470,7 @@ declare namespace ts.server { private readonly throttledOperations; private readonly hostConfiguration; private safelist; + private legacySafelist; private changedFiles; private pendingProjectUpdates; private pendingInferredProjectUpdate; @@ -7576,7 +7579,7 @@ declare namespace ts.server { private findExternalProjectByProjectName(projectFileName); private convertConfigFileContentToProjectOptions(configFilename, cachedDirectoryStructureHost); private exceededTotalSizeLimitForNonTsFiles(name, options, fileNames, propertyReader); - private createExternalProject(projectFileName, files, options, typeAcquisition); + private createExternalProject(projectFileName, files, options, typeAcquisition, excludedFiles); private sendProjectTelemetry(projectKey, project, projectOptions?); private addFilesToNonInferredProjectAndUpdateGraph(project, files, propertyReader, typeAcquisition); private createConfiguredProject(configFileName); From 5830bb9b19f400994f77bdb1df0b5aff888dbdc3 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 27 Oct 2017 17:07:04 -0700 Subject: [PATCH 06/69] Improved logging --- src/server/editorServices.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index eb2ae0f3cd9..0bd02f32d95 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -2152,7 +2152,7 @@ namespace ts.server { const rule = this.safelist[name]; for (const root of normalizedNames) { if (rule.match.test(root)) { - this.logger.info(`Excluding files based on rule ${name}`); + this.logger.info(`Excluding files based on rule ${name} matching file '${root}'`); // If the file matches, collect its types packages and exclude rules if (rule.types) { @@ -2218,7 +2218,7 @@ namespace ts.server { const inferredTypingName = removeFileExtension(baseName); const cleanedTypingName = removeMinAndVersionNumbers(inferredTypingName); if (this.legacySafelist[cleanedTypingName]) { - this.logger.info(`Excluded '${normalizedNames[i]}'`); + this.logger.info(`Excluded '${normalizedNames[i]}' because it matched ${cleanedTypingName} from the legacy safelist`); excludedFiles.push(normalizedNames[i]); exclude = true; } From 5395d0ddb872acb83c2cca3ec31240572082db05 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 30 Oct 2017 10:44:51 -0700 Subject: [PATCH 07/69] Add test --- .../unittests/tsserverProjectSystem.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index bc8b476ceb9..fb2bbec6741 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1496,6 +1496,26 @@ namespace ts.projectSystem { } }); + it("ignores files excluded by a legacy safe type list", () => { + const file1 = { + path: "/a/b/bliss.js", + content: "let x = 5" + }; + const file2 = { + path: "/a/b/foo.js", + content: "" + }; + const host = createServerHost([file1, file2, customTypesMap]); + const projectService = createProjectService(host); + try { + projectService.openExternalProject({ projectFileName: "project", options: {}, rootFiles: toExternalFiles([file1.path, file2.path]), typeAcquisition: { enable: true } }); + const proj = projectService.externalProjects[0]; + assert.deepEqual(proj.getFileNames(), [file2.path]); + } finally { + projectService.resetSafeList(); + } + }); + it("open file become a part of configured project if it is referenced from root file", () => { const file1 = { path: "/a/b/f1.ts", From 5dc02ef5ccf267c0f4a07f4571d0b8d603a9eefa Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 31 Oct 2017 18:38:00 -0700 Subject: [PATCH 08/69] Use a different RegEx --- src/compiler/core.ts | 8 ++++++- .../unittests/tsserverProjectSystem.ts | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index c9b644b22ce..626480035b1 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2417,7 +2417,13 @@ namespace ts { * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ export function removeMinAndVersionNumbers(fileName: string) { - return fileName.replace(/((?:\.|-)min(?=\.|$))|((?:-|\.)\d+)/g, ""); + const match = /((\w|(-(?!min)))+)(\.|-)?.*/.exec(fileName); + if (match) { + return match[1]; + } + else { + return fileName; + } } export interface ObjectAllocator { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index fb2bbec6741..c72a27e173e 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1496,6 +1496,28 @@ namespace ts.projectSystem { } }); + it("removes version numbers correctly", () => { + const testData: [string, string][] = [ + ["jquery-max", "jquery-max"], + ["jquery.min", "jquery"], + ["jquery-min.4.2.3", "jquery"], + ["jquery.4.2-test.js", "jquery"], + ["jquery.min.4.2.1", "jquery"], + ["jquery.7.min.js", "jquery"], + ["jquery.7.min-beta", "jquery"], + ["minimum", "minimum"], + ["min", "min"], + ["min.3.2", "min"], + ["jquery", "jquery"] + ]; + const suffixes = [".js", ".jsx", ""]; + for (const t of testData) { + for (const suf of suffixes) { + assert.equal(removeMinAndVersionNumbers(t[0] + suf), t[1]); + } + } + }); + it("ignores files excluded by a legacy safe type list", () => { const file1 = { path: "/a/b/bliss.js", From db88c8eac29aba048403e2a8a7ab868c79b99b00 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 1 Nov 2017 09:12:01 -0700 Subject: [PATCH 09/69] Check function type parameters for this references Previously, when checking for this references, the compiler did not check type parameters. This caused it to miss some instantiations that were necessary. Also some cleanup: 1. Rename isIndependent* to is*FreeOfThisReference. 'Independent' was a one-off concept that was unique to Typescript (and isn't referenced in the spec), so I think the new name is friendlier to new readers. 2. Use `Array.every` whenever possible, since Typescript added a dependency on ES5 since the code was first written. 3. Switch to JSDoc so that it shows up nicely in editors. --- src/compiler/checker.ts | 101 +++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 49 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 09354d957a3..ccb7c869137 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5108,10 +5108,14 @@ namespace ts { } } - // Returns true if the interface given by the symbol is free of "this" references. Specifically, the result is - // true if the interface itself contains no references to "this" in its body, if all base types are interfaces, - // and if none of the base interfaces have a "this" type. - function isIndependentInterface(symbol: Symbol): boolean { + /** + * Returns true if the interface given by the symbol is free of "this" references. + * + * Specifically, the result is true if the interface itself contains no references + * to "this" in its body, if all base types are interfaces, + * and if none of the base interfaces have a "this" type. + */ + function isInterfaceFreeOfThisReference(symbol: Symbol): boolean { for (const declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration) { if (declaration.flags & NodeFlags.ContainsThis) { @@ -5145,7 +5149,7 @@ namespace ts { // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isIndependentInterface(symbol)) { + if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isInterfaceFreeOfThisReference(symbol)) { type.objectFlags |= ObjectFlags.Reference; type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -5327,22 +5331,17 @@ namespace ts { return undefined; } - // A type reference is considered independent if each type argument is considered independent. - function isIndependentTypeReference(node: TypeReferenceNode): boolean { - if (node.typeArguments) { - for (const typeNode of node.typeArguments) { - if (!isIndependentType(typeNode)) { - return false; - } - } - } - return true; + /** A type reference is free of this references if each type argument is free of this references. */ + function isTypeReferenceFreeOfThisReference(node: TypeReferenceNode): boolean { + return !node.typeArguments || node.typeArguments.every(isTypeFreeOfThisReference); } - // A type is considered independent if it the any, string, number, boolean, symbol, or void keyword, a string - // literal type, an array with an element type that is considered independent, or a type reference that is - // considered independent. - function isIndependentType(node: TypeNode): boolean { + /** + * A type is free of this references if it's the any, string, number, boolean, symbol, or void keyword, a string + * literal type, an array with an element type that is free of this references, or a type reference that is + * free of this references. + */ + function isTypeFreeOfThisReference(node: TypeNode): boolean { switch (node.kind) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -5357,54 +5356,58 @@ namespace ts { case SyntaxKind.LiteralType: return true; case SyntaxKind.ArrayType: - return isIndependentType((node).elementType); + return isTypeFreeOfThisReference((node).elementType); case SyntaxKind.TypeReference: - return isIndependentTypeReference(node); + return isTypeReferenceFreeOfThisReference(node); } return false; } - // A variable-like declaration is considered independent (free of this references) if it has a type annotation - // that specifies an independent type, or if it has no type annotation and no initializer (and thus of type any). - function isIndependentVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { + /** A type parameter is this-free if its contraint is this-free, or if it has no constraint. */ + function isTypeParameterFreeOfThisReference(node: TypeParameterDeclaration) { + return !node.constraint || isTypeFreeOfThisReference(node.constraint); + } + + /** + * A variable-like declaration is free of this references if it has a type annotation + * that is this-free, or if it has no type annotation and no initializer (and is thus of type any). + */ + function isVariableLikeDeclarationFreeOfThisReference(node: VariableLikeDeclaration): boolean { const typeNode = getEffectiveTypeAnnotationNode(node); - return typeNode ? isIndependentType(typeNode) : !node.initializer; + return typeNode ? isTypeFreeOfThisReference(typeNode) : !node.initializer; } - // A function-like declaration is considered independent (free of this references) if it has a return type - // annotation that is considered independent and if each parameter is considered independent. - function isIndependentFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { - if (node.kind !== SyntaxKind.Constructor) { - const typeNode = getEffectiveReturnTypeNode(node); - if (!typeNode || !isIndependentType(typeNode)) { - return false; - } - } - for (const parameter of node.parameters) { - if (!isIndependentVariableLikeDeclaration(parameter)) { - return false; - } - } - return true; + /** + * A function-like declaration is considered free of `this` references if it has a return type + * annotation that is free of this references and if each parameter is this-free and if + * each type parameter (if present) is this-free. + */ + function isFunctionLikeDeclarationFreeOfThisReference(node: FunctionLikeDeclaration): boolean { + const returnType = getEffectiveReturnTypeNode(node); + return (node.kind === SyntaxKind.Constructor || (returnType && isTypeFreeOfThisReference(returnType))) && + node.parameters.every(isVariableLikeDeclarationFreeOfThisReference) && + (!node.typeParameters || node.typeParameters.every(isTypeParameterFreeOfThisReference)); } - // Returns true if the class or interface member given by the symbol is free of "this" references. The - // function may return false for symbols that are actually free of "this" references because it is not - // feasible to perform a complete analysis in all cases. In particular, property members with types - // inferred from their initializers and function members with inferred return types are conservatively - // assumed not to be free of "this" references. - function isIndependentMember(symbol: Symbol): boolean { + /** + * Returns true if the class or interface member given by the symbol is free of "this" references. The + * function may return false for symbols that are actually free of "this" references because it is not + * feasible to perform a complete analysis in all cases. In particular, property members with types + * inferred from their initializers and function members with inferred return types are conservatively + * assumed not to be free of "this" references. + */ + function isFreeOfThisReference(symbol: Symbol): boolean { if (symbol.declarations && symbol.declarations.length === 1) { const declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - return isIndependentVariableLikeDeclaration(declaration); + return isVariableLikeDeclarationFreeOfThisReference(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: - return isIndependentFunctionLikeDeclaration(declaration); + return isFunctionLikeDeclarationFreeOfThisReference(declaration); } } } @@ -5416,7 +5419,7 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createSymbolTable(); for (const symbol of symbols) { - result.set(symbol.escapedName, mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper)); + result.set(symbol.escapedName, mappingThisOnly && isFreeOfThisReference(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; } From e0e1a3b078723333ebdee629ebdea7ac9c9f4c1d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 1 Nov 2017 09:17:52 -0700 Subject: [PATCH 10/69] Test:this instantiation in type parameters Make sure that `this` gets instantiated when it's used as a constraint of a type parameter, and nowhere else in a signature. --- .../reference/thisTypeInFunctions3.js | 33 +++++++++++++++++++ .../reference/thisTypeInFunctions3.symbols | 26 +++++++++++++++ .../reference/thisTypeInFunctions3.types | 27 +++++++++++++++ .../types/thisType/thisTypeInFunctions3.ts | 9 +++++ 4 files changed, 95 insertions(+) create mode 100644 tests/baselines/reference/thisTypeInFunctions3.js create mode 100644 tests/baselines/reference/thisTypeInFunctions3.symbols create mode 100644 tests/baselines/reference/thisTypeInFunctions3.types create mode 100644 tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts diff --git a/tests/baselines/reference/thisTypeInFunctions3.js b/tests/baselines/reference/thisTypeInFunctions3.js new file mode 100644 index 00000000000..68af387c251 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.js @@ -0,0 +1,33 @@ +//// [thisTypeInFunctions3.ts] +declare class Base { + check(prop: TProp): boolean; +} + +class Test extends Base { + m() { + this.check(this); + } +} + + +//// [thisTypeInFunctions3.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var Test = /** @class */ (function (_super) { + __extends(Test, _super); + function Test() { + return _super !== null && _super.apply(this, arguments) || this; + } + Test.prototype.m = function () { + this.check(this); + }; + return Test; +}(Base)); diff --git a/tests/baselines/reference/thisTypeInFunctions3.symbols b/tests/baselines/reference/thisTypeInFunctions3.symbols new file mode 100644 index 00000000000..061a33fd63d --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts === +declare class Base { +>Base : Symbol(Base, Decl(thisTypeInFunctions3.ts, 0, 0)) + + check(prop: TProp): boolean; +>check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>TProp : Symbol(TProp, Decl(thisTypeInFunctions3.ts, 1, 10)) +>prop : Symbol(prop, Decl(thisTypeInFunctions3.ts, 1, 30)) +>TProp : Symbol(TProp, Decl(thisTypeInFunctions3.ts, 1, 10)) +} + +class Test extends Base { +>Test : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) +>Base : Symbol(Base, Decl(thisTypeInFunctions3.ts, 0, 0)) + + m() { +>m : Symbol(Test.m, Decl(thisTypeInFunctions3.ts, 4, 25)) + + this.check(this); +>this.check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>this : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) +>check : Symbol(Base.check, Decl(thisTypeInFunctions3.ts, 0, 20)) +>this : Symbol(Test, Decl(thisTypeInFunctions3.ts, 2, 1)) + } +} + diff --git a/tests/baselines/reference/thisTypeInFunctions3.types b/tests/baselines/reference/thisTypeInFunctions3.types new file mode 100644 index 00000000000..563d6488704 --- /dev/null +++ b/tests/baselines/reference/thisTypeInFunctions3.types @@ -0,0 +1,27 @@ +=== tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts === +declare class Base { +>Base : Base + + check(prop: TProp): boolean; +>check : (prop: TProp) => boolean +>TProp : TProp +>prop : TProp +>TProp : TProp +} + +class Test extends Base { +>Test : Test +>Base : Base + + m() { +>m : () => void + + this.check(this); +>this.check(this) : boolean +>this.check : (prop: TProp) => boolean +>this : this +>check : (prop: TProp) => boolean +>this : this + } +} + diff --git a/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts b/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts new file mode 100644 index 00000000000..01d7fd0430b --- /dev/null +++ b/tests/cases/conformance/types/thisType/thisTypeInFunctions3.ts @@ -0,0 +1,9 @@ +declare class Base { + check(prop: TProp): boolean; +} + +class Test extends Base { + m() { + this.check(this); + } +} From 1408a4d2b7604931687273169374f6a9d2c80c12 Mon Sep 17 00:00:00 2001 From: Adrian Leonhard Date: Thu, 9 Nov 2017 02:27:02 +0100 Subject: [PATCH 11/69] Add Symbol.species to ArrayConstructor, MapConstructor, SetConstructor, ArrayBufferConstructor. (#18652) Fix Symbol.species in RegExpConstructor and PromiseConstructor. See https://github.com/Microsoft/TypeScript/issues/2881 . --- src/lib/es2015.symbol.wellknown.d.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/es2015.symbol.wellknown.d.ts b/src/lib/es2015.symbol.wellknown.d.ts index 268570ff232..23d836c6515 100644 --- a/src/lib/es2015.symbol.wellknown.d.ts +++ b/src/lib/es2015.symbol.wellknown.d.ts @@ -150,7 +150,7 @@ interface Promise { } interface PromiseConstructor { - readonly [Symbol.species]: Function; + readonly [Symbol.species]: PromiseConstructor; } interface RegExp { @@ -202,7 +202,7 @@ interface RegExp { } interface RegExpConstructor { - [Symbol.species](): RegExpConstructor; + readonly [Symbol.species]: RegExpConstructor; } interface String { @@ -283,3 +283,16 @@ interface Float32Array { interface Float64Array { readonly [Symbol.toStringTag]: "Float64Array"; } + +interface ArrayConstructor { + readonly [Symbol.species]: ArrayConstructor; +} +interface MapConstructor { + readonly [Symbol.species]: MapConstructor; +} +interface SetConstructor { + readonly [Symbol.species]: SetConstructor; +} +interface ArrayBufferConstructor { + readonly [Symbol.species]: ArrayBufferConstructor; +} \ No newline at end of file From e9841f3899ddba2052e5e68e68adfc9268afd891 Mon Sep 17 00:00:00 2001 From: "wenlu.wang" <805037171@163.com> Date: Wed, 8 Nov 2017 19:44:12 -0600 Subject: [PATCH 12/69] fix completions protected members in recursive generic types (#19192) (#19242) --- src/compiler/checker.ts | 7 +++---- ...ompletionsForRecursiveGenericTypesMember.ts | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 38bc617c650..6f75bfa0d46 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -15162,12 +15162,11 @@ namespace ts { if (flags & ModifierFlags.Static) { return true; } - // An instance property must be accessed through an instance of the enclosing class - if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { + if (type.flags & TypeFlags.TypeParameter) { // get the original type -- represented as the type constraint of the 'this' type - type = getConstraintOfTypeParameter(type); + type = (type as TypeParameter).isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); } - if (!(getObjectFlags(getTargetType(type)) & ObjectFlags.ClassOrInterface && hasBaseType(type, enclosingClass))) { + if (!type || !hasBaseType(type, enclosingClass)) { error(errorNode, Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass)); return false; } diff --git a/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts b/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts new file mode 100644 index 00000000000..993b9eb73ac --- /dev/null +++ b/tests/cases/fourslash/completionsForRecursiveGenericTypesMember.ts @@ -0,0 +1,18 @@ +/// + +//// export class TestBase> +//// { +//// public publicMethod(p: any): void {} +//// private privateMethod(p: any): void {} +//// protected protectedMethod(p: any): void {} +//// public test(t: T): void +//// { +//// t./**/ +//// } +//// } + +goTo.marker(); + +verify.completionListContains('publicMethod'); +verify.completionListContains('privateMethod'); +verify.completionListContains('protectedMethod'); From 235356e6ffb9d9ad365758ab46ee245ec6df08d3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 8 Nov 2017 18:15:23 -0800 Subject: [PATCH 13/69] Handle synthetic nodes correctly as namespace identifiers in system transform (#19623) * Handle synthetic nodes correctly as namespace identifiers in system transform * Add ref to issue in comment * Lock newline for ci --- src/compiler/factory.ts | 2 +- src/harness/unittests/transform.ts | 32 +++++++++++++++++++ ...nsformsCorrectly.transformAddImportStar.js | 13 ++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/transformApi/transformsCorrectly.transformAddImportStar.js diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 6a56b6da049..e8dfcbc1e94 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -4319,7 +4319,7 @@ namespace ts { const namespaceDeclaration = getNamespaceDeclarationNode(node); if (namespaceDeclaration && !isDefaultImport(node)) { const name = namespaceDeclaration.name; - return isGeneratedIdentifier(name) ? name : createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); + return isGeneratedIdentifier(name) ? name : createIdentifier(getSourceTextOfNodeFromSourceFile(sourceFile, name) || idText(name)); } if (node.kind === SyntaxKind.ImportDeclaration && (node).importClause) { return getGeneratedNameForNode(node); diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index 72f7072535c..a39249bb225 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -192,6 +192,38 @@ namespace ts { }; } }); + + // https://github.com/Microsoft/TypeScript/issues/19618 + testBaseline("transformAddImportStar", () => { + return ts.transpileModule("", { + transformers: { + before: [transformAddImportStar], + }, + compilerOptions: { + target: ts.ScriptTarget.ES5, + module: ts.ModuleKind.System, + newLine: NewLineKind.CarriageReturnLineFeed, + } + }).outputText; + + function transformAddImportStar(_context: ts.TransformationContext) { + return (sourceFile: ts.SourceFile): ts.SourceFile => { + return visitNode(sourceFile); + }; + function visitNode(sf: ts.SourceFile) { + // produce `import * as i0 from './comp'; + const importStar = ts.createImportDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*importClause*/ ts.createImportClause( + /*name*/ undefined, + ts.createNamespaceImport(ts.createIdentifier("i0")) + ), + /*moduleSpecifier*/ ts.createLiteral("./comp1")); + return ts.updateSourceFileNode(sf, [importStar]); + } + } + }); }); } diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddImportStar.js b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddImportStar.js new file mode 100644 index 00000000000..167e8eaee09 --- /dev/null +++ b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddImportStar.js @@ -0,0 +1,13 @@ +System.register(["./comp1"], function (exports_1, context_1) { + var __moduleName = context_1 && context_1.id; + var i0; + return { + setters: [ + function (i0_1) { + i0 = i0_1; + } + ], + execute: function () { + } + }; +}); From bfe74de0176f7eaabaf09674f5fcb9cb7248226e Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Wed, 8 Nov 2017 18:20:58 -0800 Subject: [PATCH 14/69] Only ignored params need underscores --- src/compiler/comments.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index bb8ec9bf3e7..1fec1e9562f 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -260,7 +260,7 @@ namespace ts { } } - function emitLeadingComment(commentPos: number, commentEnd: number, _kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { + function emitLeadingComment(commentPos: number, commentEnd: number, kind: SyntaxKind, hasTrailingNewLine: boolean, rangePos: number) { if (!hasWrittenComment) { emitNewLineBeforeLeadingCommentOfPosition(currentLineMap, writer, rangePos, commentPos); hasWrittenComment = true; @@ -274,7 +274,7 @@ namespace ts { if (hasTrailingNewLine) { writer.writeLine(); } - else if (_kind === SyntaxKind.MultiLineCommentTrivia) { + else if (kind === SyntaxKind.MultiLineCommentTrivia) { writer.write(" "); } } From ceaeffa3ab2024aa4a8ff11a7a5d6826d1bd2bf3 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 8 Nov 2017 18:44:46 -0800 Subject: [PATCH 15/69] Fix declaration emit for imported export alias specifiers (#19852) * Badness * Revert #3641, whose original bug has been fixed by other means * Add another repro --- src/compiler/checker.ts | 1 - .../declarationEmitOfTypeofAliasedExport.js | 35 +++++++++ ...clarationEmitOfTypeofAliasedExport.symbols | 17 +++++ ...declarationEmitOfTypeofAliasedExport.types | 17 +++++ ...s6ExportClauseWithoutModuleSpecifier.types | 4 +- ...ortClauseWithoutModuleSpecifierInEs5.types | 4 +- .../exportSpecifierForAGlobal.errors.txt | 5 +- .../reference/exportSpecifierForAGlobal.js | 5 -- .../reference/exportsAndImports3-amd.symbols | 12 ++-- .../reference/exportsAndImports3-es6.symbols | 12 ++-- .../reference/exportsAndImports3.symbols | 12 ++-- .../reexportWrittenCorrectlyInDeclaration.js | 72 +++++++++++++++++++ ...xportWrittenCorrectlyInDeclaration.symbols | 29 ++++++++ ...eexportWrittenCorrectlyInDeclaration.types | 30 ++++++++ .../baselines/reference/systemModule15.types | 4 +- .../declarationEmitOfTypeofAliasedExport.ts | 8 +++ .../reexportWrittenCorrectlyInDeclaration.ts | 18 +++++ 17 files changed, 254 insertions(+), 31 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitOfTypeofAliasedExport.js create mode 100644 tests/baselines/reference/declarationEmitOfTypeofAliasedExport.symbols create mode 100644 tests/baselines/reference/declarationEmitOfTypeofAliasedExport.types create mode 100644 tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js create mode 100644 tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.symbols create mode 100644 tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types create mode 100644 tests/cases/compiler/declarationEmitOfTypeofAliasedExport.ts create mode 100644 tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6f75bfa0d46..f619805628a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2161,7 +2161,6 @@ namespace ts { return forEachEntry(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.escapedName !== "export=" - && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier) && !(isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && isExternalModule(getSourceFileOfNode(enclosingDeclaration))) // If `!useOnlyExternalAliasing`, we can use any type of alias to get the name && (!useOnlyExternalAliasing || some(symbolFromSymbolTable.declarations, isExternalModuleImportEqualsDeclaration))) { diff --git a/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.js b/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.js new file mode 100644 index 00000000000..5f1f5743201 --- /dev/null +++ b/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/declarationEmitOfTypeofAliasedExport.ts] //// + +//// [a.ts] +class C {} +export { C as D } + +//// [b.ts] +import * as a from "./a"; +export default a.D; + + +//// [a.js] +"use strict"; +exports.__esModule = true; +var C = /** @class */ (function () { + function C() { + } + return C; +}()); +exports.D = C; +//// [b.js] +"use strict"; +exports.__esModule = true; +var a = require("./a"); +exports["default"] = a.D; + + +//// [a.d.ts] +declare class C { +} +export { C as D }; +//// [b.d.ts] +import * as a from "./a"; +declare const _default: typeof a.D; +export default _default; diff --git a/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.symbols b/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.symbols new file mode 100644 index 00000000000..d13d242105b --- /dev/null +++ b/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.symbols @@ -0,0 +1,17 @@ +=== /a.ts === +class C {} +>C : Symbol(C, Decl(a.ts, 0, 0)) + +export { C as D } +>C : Symbol(D, Decl(a.ts, 1, 8)) +>D : Symbol(D, Decl(a.ts, 1, 8)) + +=== /b.ts === +import * as a from "./a"; +>a : Symbol(a, Decl(b.ts, 0, 6)) + +export default a.D; +>a.D : Symbol(a.D, Decl(a.ts, 1, 8)) +>a : Symbol(a, Decl(b.ts, 0, 6)) +>D : Symbol(a.D, Decl(a.ts, 1, 8)) + diff --git a/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.types b/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.types new file mode 100644 index 00000000000..ccd13107166 --- /dev/null +++ b/tests/baselines/reference/declarationEmitOfTypeofAliasedExport.types @@ -0,0 +1,17 @@ +=== /a.ts === +class C {} +>C : C + +export { C as D } +>C : typeof C +>D : typeof C + +=== /b.ts === +import * as a from "./a"; +>a : typeof a + +export default a.D; +>a.D : typeof a.D +>a : typeof a +>D : typeof a.D + diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types index abb1c3b69e2..acbe40fb9ab 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types @@ -30,8 +30,8 @@ export { c as c2 } from "server"; export { i, m as instantiatedModule } from "server"; >i : any ->m : typeof m ->instantiatedModule : typeof m +>m : typeof instantiatedModule +>instantiatedModule : typeof instantiatedModule export { uninstantiated } from "server"; >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types index b407d9b16f5..8a7e9c29b10 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -30,8 +30,8 @@ export { c as c2 } from "./server"; export { i, m as instantiatedModule } from "./server"; >i : any ->m : typeof m ->instantiatedModule : typeof m +>m : typeof instantiatedModule +>instantiatedModule : typeof instantiatedModule export { uninstantiated } from "./server"; >uninstantiated : any diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt b/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt index d2f103a91fa..20a1c9a7d41 100644 --- a/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt +++ b/tests/baselines/reference/exportSpecifierForAGlobal.errors.txt @@ -1,14 +1,17 @@ tests/cases/compiler/b.ts(1,9): error TS2661: Cannot export 'X'. Only local declarations can be exported from a module. +tests/cases/compiler/b.ts(2,17): error TS4060: Return type of exported function has or is using private name 'X'. ==== tests/cases/compiler/a.d.ts (0 errors) ==== declare class X { } -==== tests/cases/compiler/b.ts (1 errors) ==== +==== tests/cases/compiler/b.ts (2 errors) ==== export {X}; ~ !!! error TS2661: Cannot export 'X'. Only local declarations can be exported from a module. export function f() { + ~ +!!! error TS4060: Return type of exported function has or is using private name 'X'. var x: X; return x; } diff --git a/tests/baselines/reference/exportSpecifierForAGlobal.js b/tests/baselines/reference/exportSpecifierForAGlobal.js index 6023b7c7f14..9f12241cbd1 100644 --- a/tests/baselines/reference/exportSpecifierForAGlobal.js +++ b/tests/baselines/reference/exportSpecifierForAGlobal.js @@ -19,8 +19,3 @@ function f() { return x; } exports.f = f; - - -//// [b.d.ts] -export { X }; -export declare function f(): X; diff --git a/tests/baselines/reference/exportsAndImports3-amd.symbols b/tests/baselines/reference/exportsAndImports3-amd.symbols index f71014281c2..edc5d5c2e4e 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.symbols +++ b/tests/baselines/reference/exportsAndImports3-amd.symbols @@ -15,17 +15,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 5, 1)) A, B, C ->A : Symbol(E.A, Decl(t1.ts, 6, 15)) ->B : Symbol(E.B, Decl(t1.ts, 7, 6)) ->C : Symbol(E.C, Decl(t1.ts, 7, 9)) +>A : Symbol(E1.A, Decl(t1.ts, 6, 15)) +>B : Symbol(E1.B, Decl(t1.ts, 7, 6)) +>C : Symbol(E1.C, Decl(t1.ts, 7, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 8, 1)) A, B, C ->A : Symbol(D.A, Decl(t1.ts, 9, 21)) ->B : Symbol(D.B, Decl(t1.ts, 10, 6)) ->C : Symbol(D.C, Decl(t1.ts, 10, 9)) +>A : Symbol(D1.A, Decl(t1.ts, 9, 21)) +>B : Symbol(D1.B, Decl(t1.ts, 10, 6)) +>C : Symbol(D1.C, Decl(t1.ts, 10, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 11, 1)) diff --git a/tests/baselines/reference/exportsAndImports3-es6.symbols b/tests/baselines/reference/exportsAndImports3-es6.symbols index f71014281c2..edc5d5c2e4e 100644 --- a/tests/baselines/reference/exportsAndImports3-es6.symbols +++ b/tests/baselines/reference/exportsAndImports3-es6.symbols @@ -15,17 +15,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 5, 1)) A, B, C ->A : Symbol(E.A, Decl(t1.ts, 6, 15)) ->B : Symbol(E.B, Decl(t1.ts, 7, 6)) ->C : Symbol(E.C, Decl(t1.ts, 7, 9)) +>A : Symbol(E1.A, Decl(t1.ts, 6, 15)) +>B : Symbol(E1.B, Decl(t1.ts, 7, 6)) +>C : Symbol(E1.C, Decl(t1.ts, 7, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 8, 1)) A, B, C ->A : Symbol(D.A, Decl(t1.ts, 9, 21)) ->B : Symbol(D.B, Decl(t1.ts, 10, 6)) ->C : Symbol(D.C, Decl(t1.ts, 10, 9)) +>A : Symbol(D1.A, Decl(t1.ts, 9, 21)) +>B : Symbol(D1.B, Decl(t1.ts, 10, 6)) +>C : Symbol(D1.C, Decl(t1.ts, 10, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 11, 1)) diff --git a/tests/baselines/reference/exportsAndImports3.symbols b/tests/baselines/reference/exportsAndImports3.symbols index f71014281c2..edc5d5c2e4e 100644 --- a/tests/baselines/reference/exportsAndImports3.symbols +++ b/tests/baselines/reference/exportsAndImports3.symbols @@ -15,17 +15,17 @@ export enum E { >E : Symbol(E, Decl(t1.ts, 5, 1)) A, B, C ->A : Symbol(E.A, Decl(t1.ts, 6, 15)) ->B : Symbol(E.B, Decl(t1.ts, 7, 6)) ->C : Symbol(E.C, Decl(t1.ts, 7, 9)) +>A : Symbol(E1.A, Decl(t1.ts, 6, 15)) +>B : Symbol(E1.B, Decl(t1.ts, 7, 6)) +>C : Symbol(E1.C, Decl(t1.ts, 7, 9)) } export const enum D { >D : Symbol(D, Decl(t1.ts, 8, 1)) A, B, C ->A : Symbol(D.A, Decl(t1.ts, 9, 21)) ->B : Symbol(D.B, Decl(t1.ts, 10, 6)) ->C : Symbol(D.C, Decl(t1.ts, 10, 9)) +>A : Symbol(D1.A, Decl(t1.ts, 9, 21)) +>B : Symbol(D1.B, Decl(t1.ts, 10, 6)) +>C : Symbol(D1.C, Decl(t1.ts, 10, 9)) } export module M { >M : Symbol(M, Decl(t1.ts, 11, 1)) diff --git a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js new file mode 100644 index 00000000000..ae3ce21ff49 --- /dev/null +++ b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.js @@ -0,0 +1,72 @@ +//// [tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts] //// + +//// [ThingA.ts] +// https://github.com/Microsoft/TypeScript/issues/8612 +export class ThingA { } + +//// [ThingB.ts] +export class ThingB { } + +//// [Things.ts] +export {ThingA} from "./ThingA"; +export {ThingB} from "./ThingB"; + +//// [Test.ts] +import * as things from "./Things"; + +export class Test { + public method = (input: things.ThingA) => { }; +} + +//// [ThingA.js] +"use strict"; +exports.__esModule = true; +// https://github.com/Microsoft/TypeScript/issues/8612 +var ThingA = /** @class */ (function () { + function ThingA() { + } + return ThingA; +}()); +exports.ThingA = ThingA; +//// [ThingB.js] +"use strict"; +exports.__esModule = true; +var ThingB = /** @class */ (function () { + function ThingB() { + } + return ThingB; +}()); +exports.ThingB = ThingB; +//// [Things.js] +"use strict"; +exports.__esModule = true; +var ThingA_1 = require("./ThingA"); +exports.ThingA = ThingA_1.ThingA; +var ThingB_1 = require("./ThingB"); +exports.ThingB = ThingB_1.ThingB; +//// [Test.js] +"use strict"; +exports.__esModule = true; +var Test = /** @class */ (function () { + function Test() { + this.method = function (input) { }; + } + return Test; +}()); +exports.Test = Test; + + +//// [ThingA.d.ts] +export declare class ThingA { +} +//// [ThingB.d.ts] +export declare class ThingB { +} +//// [Things.d.ts] +export { ThingA } from "./ThingA"; +export { ThingB } from "./ThingB"; +//// [Test.d.ts] +import * as things from "./Things"; +export declare class Test { + method: (input: things.ThingA) => void; +} diff --git a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.symbols b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.symbols new file mode 100644 index 00000000000..347ff41cc71 --- /dev/null +++ b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/ThingA.ts === +// https://github.com/Microsoft/TypeScript/issues/8612 +export class ThingA { } +>ThingA : Symbol(ThingA, Decl(ThingA.ts, 0, 0)) + +=== tests/cases/compiler/ThingB.ts === +export class ThingB { } +>ThingB : Symbol(ThingB, Decl(ThingB.ts, 0, 0)) + +=== tests/cases/compiler/Things.ts === +export {ThingA} from "./ThingA"; +>ThingA : Symbol(ThingA, Decl(Things.ts, 0, 8)) + +export {ThingB} from "./ThingB"; +>ThingB : Symbol(ThingB, Decl(Things.ts, 1, 8)) + +=== tests/cases/compiler/Test.ts === +import * as things from "./Things"; +>things : Symbol(things, Decl(Test.ts, 0, 6)) + +export class Test { +>Test : Symbol(Test, Decl(Test.ts, 0, 35)) + + public method = (input: things.ThingA) => { }; +>method : Symbol(Test.method, Decl(Test.ts, 2, 19)) +>input : Symbol(input, Decl(Test.ts, 3, 21)) +>things : Symbol(things, Decl(Test.ts, 0, 6)) +>ThingA : Symbol(things.ThingA, Decl(Things.ts, 0, 8)) +} diff --git a/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types new file mode 100644 index 00000000000..515ad0f5ac9 --- /dev/null +++ b/tests/baselines/reference/reexportWrittenCorrectlyInDeclaration.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/ThingA.ts === +// https://github.com/Microsoft/TypeScript/issues/8612 +export class ThingA { } +>ThingA : ThingA + +=== tests/cases/compiler/ThingB.ts === +export class ThingB { } +>ThingB : ThingB + +=== tests/cases/compiler/Things.ts === +export {ThingA} from "./ThingA"; +>ThingA : typeof ThingA + +export {ThingB} from "./ThingB"; +>ThingB : typeof ThingB + +=== tests/cases/compiler/Test.ts === +import * as things from "./Things"; +>things : typeof things + +export class Test { +>Test : Test + + public method = (input: things.ThingA) => { }; +>method : (input: things.ThingA) => void +>(input: things.ThingA) => { } : (input: things.ThingA) => void +>input : things.ThingA +>things : any +>ThingA : things.ThingA +} diff --git a/tests/baselines/reference/systemModule15.types b/tests/baselines/reference/systemModule15.types index 747583323ad..ac24678e568 100644 --- a/tests/baselines/reference/systemModule15.types +++ b/tests/baselines/reference/systemModule15.types @@ -23,9 +23,9 @@ use(moduleB.moduleC); use(moduleB.moduleCStar); >use(moduleB.moduleCStar) : void >use : (v: any) => void ->moduleB.moduleCStar : typeof "tests/cases/compiler/file3" +>moduleB.moduleCStar : typeof moduleB.moduleCStar >moduleB : typeof moduleB ->moduleCStar : typeof "tests/cases/compiler/file3" +>moduleCStar : typeof moduleB.moduleCStar === tests/cases/compiler/file2.ts === import * as moduleCStar from "./file3" diff --git a/tests/cases/compiler/declarationEmitOfTypeofAliasedExport.ts b/tests/cases/compiler/declarationEmitOfTypeofAliasedExport.ts new file mode 100644 index 00000000000..ab2912a0f1c --- /dev/null +++ b/tests/cases/compiler/declarationEmitOfTypeofAliasedExport.ts @@ -0,0 +1,8 @@ +// @declaration: true +// @filename: /a.ts +class C {} +export { C as D } + +// @filename: /b.ts +import * as a from "./a"; +export default a.D; diff --git a/tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts b/tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts new file mode 100644 index 00000000000..71947ca80c1 --- /dev/null +++ b/tests/cases/compiler/reexportWrittenCorrectlyInDeclaration.ts @@ -0,0 +1,18 @@ +// https://github.com/Microsoft/TypeScript/issues/8612 +// @declaration: true +// @filename: ThingA.ts +export class ThingA { } + +// @filename: ThingB.ts +export class ThingB { } + +// @filename: Things.ts +export {ThingA} from "./ThingA"; +export {ThingB} from "./ThingB"; + +// @filename: Test.ts +import * as things from "./Things"; + +export class Test { + public method = (input: things.ThingA) => { }; +} \ No newline at end of file From a1014b2b13f6662205876046e1c2c01d9d3367ed Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 9 Nov 2017 00:26:33 -0800 Subject: [PATCH 16/69] Mark all parameters as needed for metadata when one is decorated (#19849) * Mark all properties as needed for metadata when one is decorated * Add restarg test --- src/compiler/checker.ts | 4 + .../decoratorReferenceOnOtherProperty.js | 109 ++++++++++++++++++ .../decoratorReferenceOnOtherProperty.symbols | 46 ++++++++ .../decoratorReferenceOnOtherProperty.types | 46 ++++++++ .../decoratorReferenceOnOtherProperty.ts | 25 ++++ 5 files changed, 230 insertions(+) create mode 100644 tests/baselines/reference/decoratorReferenceOnOtherProperty.js create mode 100644 tests/baselines/reference/decoratorReferenceOnOtherProperty.symbols create mode 100644 tests/baselines/reference/decoratorReferenceOnOtherProperty.types create mode 100644 tests/cases/compiler/decoratorReferenceOnOtherProperty.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f619805628a..a9aaa77fa74 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20262,6 +20262,10 @@ namespace ts { case SyntaxKind.Parameter: markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); + const containingSignature = (node as ParameterDeclaration).parent; + for (const parameter of containingSignature.parameters) { + markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); + } break; } } diff --git a/tests/baselines/reference/decoratorReferenceOnOtherProperty.js b/tests/baselines/reference/decoratorReferenceOnOtherProperty.js new file mode 100644 index 00000000000..6313f339ba9 --- /dev/null +++ b/tests/baselines/reference/decoratorReferenceOnOtherProperty.js @@ -0,0 +1,109 @@ +//// [tests/cases/compiler/decoratorReferenceOnOtherProperty.ts] //// + +//// [yoha.ts] +// https://github.com/Microsoft/TypeScript/issues/19799 +export class Yoha {} + +//// [index.ts] +import {Yoha} from './yoha'; + +function foo(...args: any[]) {} + +class Bar { + yoha(@foo yoha, bar: Yoha) {} + // ^^^^ +} + +//// [index2.ts] +import {Yoha} from './yoha'; + +function foo(...args: any[]) {} + +class Bar { + yoha(@foo yoha, ...bar: Yoha[]) {} + // ^^^^ +} + +//// [yoha.js] +"use strict"; +exports.__esModule = true; +// https://github.com/Microsoft/TypeScript/issues/19799 +var Yoha = /** @class */ (function () { + function Yoha() { + } + return Yoha; +}()); +exports.Yoha = Yoha; +//// [index.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +exports.__esModule = true; +var yoha_1 = require("./yoha"); +function foo() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } +} +var Bar = /** @class */ (function () { + function Bar() { + } + Bar.prototype.yoha = function (yoha, bar) { }; + __decorate([ + __param(0, foo), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object, yoha_1.Yoha]), + __metadata("design:returntype", void 0) + ], Bar.prototype, "yoha"); + return Bar; +}()); +//// [index2.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +exports.__esModule = true; +var yoha_1 = require("./yoha"); +function foo() { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } +} +var Bar = /** @class */ (function () { + function Bar() { + } + Bar.prototype.yoha = function (yoha) { + var bar = []; + for (var _i = 1; _i < arguments.length; _i++) { + bar[_i - 1] = arguments[_i]; + } + }; + __decorate([ + __param(0, foo), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object, yoha_1.Yoha]), + __metadata("design:returntype", void 0) + ], Bar.prototype, "yoha"); + return Bar; +}()); diff --git a/tests/baselines/reference/decoratorReferenceOnOtherProperty.symbols b/tests/baselines/reference/decoratorReferenceOnOtherProperty.symbols new file mode 100644 index 00000000000..619e2afe4e9 --- /dev/null +++ b/tests/baselines/reference/decoratorReferenceOnOtherProperty.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/yoha.ts === +// https://github.com/Microsoft/TypeScript/issues/19799 +export class Yoha {} +>Yoha : Symbol(Yoha, Decl(yoha.ts, 0, 0)) + +=== tests/cases/compiler/index.ts === +import {Yoha} from './yoha'; +>Yoha : Symbol(Yoha, Decl(index.ts, 0, 8)) + +function foo(...args: any[]) {} +>foo : Symbol(foo, Decl(index.ts, 0, 28)) +>args : Symbol(args, Decl(index.ts, 2, 13)) + +class Bar { +>Bar : Symbol(Bar, Decl(index.ts, 2, 31)) + + yoha(@foo yoha, bar: Yoha) {} +>yoha : Symbol(Bar.yoha, Decl(index.ts, 4, 11)) +>foo : Symbol(foo, Decl(index.ts, 0, 28)) +>yoha : Symbol(yoha, Decl(index.ts, 5, 7)) +>bar : Symbol(bar, Decl(index.ts, 5, 17)) +>Yoha : Symbol(Yoha, Decl(index.ts, 0, 8)) + + // ^^^^ +} + +=== tests/cases/compiler/index2.ts === +import {Yoha} from './yoha'; +>Yoha : Symbol(Yoha, Decl(index2.ts, 0, 8)) + +function foo(...args: any[]) {} +>foo : Symbol(foo, Decl(index2.ts, 0, 28)) +>args : Symbol(args, Decl(index2.ts, 2, 13)) + +class Bar { +>Bar : Symbol(Bar, Decl(index2.ts, 2, 31)) + + yoha(@foo yoha, ...bar: Yoha[]) {} +>yoha : Symbol(Bar.yoha, Decl(index2.ts, 4, 11)) +>foo : Symbol(foo, Decl(index2.ts, 0, 28)) +>yoha : Symbol(yoha, Decl(index2.ts, 5, 7)) +>bar : Symbol(bar, Decl(index2.ts, 5, 17)) +>Yoha : Symbol(Yoha, Decl(index2.ts, 0, 8)) + + // ^^^^ +} diff --git a/tests/baselines/reference/decoratorReferenceOnOtherProperty.types b/tests/baselines/reference/decoratorReferenceOnOtherProperty.types new file mode 100644 index 00000000000..5994657aa31 --- /dev/null +++ b/tests/baselines/reference/decoratorReferenceOnOtherProperty.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/yoha.ts === +// https://github.com/Microsoft/TypeScript/issues/19799 +export class Yoha {} +>Yoha : Yoha + +=== tests/cases/compiler/index.ts === +import {Yoha} from './yoha'; +>Yoha : typeof Yoha + +function foo(...args: any[]) {} +>foo : (...args: any[]) => void +>args : any[] + +class Bar { +>Bar : Bar + + yoha(@foo yoha, bar: Yoha) {} +>yoha : (yoha: any, bar: Yoha) => void +>foo : (...args: any[]) => void +>yoha : any +>bar : Yoha +>Yoha : Yoha + + // ^^^^ +} + +=== tests/cases/compiler/index2.ts === +import {Yoha} from './yoha'; +>Yoha : typeof Yoha + +function foo(...args: any[]) {} +>foo : (...args: any[]) => void +>args : any[] + +class Bar { +>Bar : Bar + + yoha(@foo yoha, ...bar: Yoha[]) {} +>yoha : (yoha: any, ...bar: Yoha[]) => void +>foo : (...args: any[]) => void +>yoha : any +>bar : Yoha[] +>Yoha : Yoha + + // ^^^^ +} diff --git a/tests/cases/compiler/decoratorReferenceOnOtherProperty.ts b/tests/cases/compiler/decoratorReferenceOnOtherProperty.ts new file mode 100644 index 00000000000..c7465471ed8 --- /dev/null +++ b/tests/cases/compiler/decoratorReferenceOnOtherProperty.ts @@ -0,0 +1,25 @@ +// https://github.com/Microsoft/TypeScript/issues/19799 +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @filename: yoha.ts +export class Yoha {} + +// @filename: index.ts +import {Yoha} from './yoha'; + +function foo(...args: any[]) {} + +class Bar { + yoha(@foo yoha, bar: Yoha) {} + // ^^^^ +} + +// @filename: index2.ts +import {Yoha} from './yoha'; + +function foo(...args: any[]) {} + +class Bar { + yoha(@foo yoha, ...bar: Yoha[]) {} + // ^^^^ +} \ No newline at end of file From 90ae9ffe6ed92ab9d3478cc620e5752c658cf121 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 9 Nov 2017 12:21:37 -0800 Subject: [PATCH 17/69] If there is an `export default x;` alias declaration, disallow other default exports (#19872) --- src/compiler/binder.ts | 9 ++++----- src/compiler/types.ts | 4 ++++ ...exportDefaultAlias_excludesEverything.errors.txt | 13 +++++++++++++ .../exportDefaultAlias_excludesEverything.js | 9 +++++++++ .../exportDefaultAlias_excludesEverything.symbols | 10 ++++++++++ .../exportDefaultAlias_excludesEverything.types | 10 ++++++++++ .../exportDefaultAlias_excludesEverything.ts | 3 +++ 7 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/exportDefaultAlias_excludesEverything.errors.txt create mode 100644 tests/baselines/reference/exportDefaultAlias_excludesEverything.js create mode 100644 tests/baselines/reference/exportDefaultAlias_excludesEverything.symbols create mode 100644 tests/baselines/reference/exportDefaultAlias_excludesEverything.types create mode 100644 tests/cases/compiler/exportDefaultAlias_excludesEverything.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index cf8b3eefde8..4e89abde780 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -2205,15 +2205,14 @@ namespace ts { bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)); } else { - // An export default clause with an expression exports a value - // We want to exclude both class and function here, this is necessary to issue an error when there are both - // default export-assignment and default export function and class declaration. - const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node) + const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node) // An export default clause with an EntityNameExpression exports all meanings of that identifier ? SymbolFlags.Alias // An export default clause with any other expression exports a value : SymbolFlags.Property; - declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.Property | SymbolFlags.AliasExcludes | SymbolFlags.Class | SymbolFlags.Function); + // If there is an `export default x;` alias declaration, can't `export default` anything else. + // (In contrast, you can still have `export default function f() {}` and `export default interface I {}`.) + declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.All); } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1874821727c..d2107572ab4 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3021,6 +3021,10 @@ namespace ts { Optional = 1 << 24, // Optional property Transient = 1 << 25, // Transient symbol (created during type check) + /* @internal */ + All = FunctionScopedVariable | BlockScopedVariable | Property | EnumMember | Function | Class | Interface | ConstEnum | RegularEnum | ValueModule | NamespaceModule | TypeLiteral + | ObjectLiteral | Method | Constructor | GetAccessor | SetAccessor | Signature | TypeParameter | TypeAlias | ExportValue | Alias | Prototype | ExportStar | Optional | Transient, + Enum = RegularEnum | ConstEnum, Variable = FunctionScopedVariable | BlockScopedVariable, Value = Variable | Property | EnumMember | Function | Class | Enum | ValueModule | Method | GetAccessor | SetAccessor, diff --git a/tests/baselines/reference/exportDefaultAlias_excludesEverything.errors.txt b/tests/baselines/reference/exportDefaultAlias_excludesEverything.errors.txt new file mode 100644 index 00000000000..9181278db20 --- /dev/null +++ b/tests/baselines/reference/exportDefaultAlias_excludesEverything.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/exportDefaultAlias_excludesEverything.ts(1,26): error TS2528: A module cannot have multiple default exports. +tests/cases/compiler/exportDefaultAlias_excludesEverything.ts(3,16): error TS2528: A module cannot have multiple default exports. + + +==== tests/cases/compiler/exportDefaultAlias_excludesEverything.ts (2 errors) ==== + export default interface A {} + ~ +!!! error TS2528: A module cannot have multiple default exports. + interface B {} + export default B; + ~ +!!! error TS2528: A module cannot have multiple default exports. + \ No newline at end of file diff --git a/tests/baselines/reference/exportDefaultAlias_excludesEverything.js b/tests/baselines/reference/exportDefaultAlias_excludesEverything.js new file mode 100644 index 00000000000..27f75954c14 --- /dev/null +++ b/tests/baselines/reference/exportDefaultAlias_excludesEverything.js @@ -0,0 +1,9 @@ +//// [exportDefaultAlias_excludesEverything.ts] +export default interface A {} +interface B {} +export default B; + + +//// [exportDefaultAlias_excludesEverything.js] +"use strict"; +exports.__esModule = true; diff --git a/tests/baselines/reference/exportDefaultAlias_excludesEverything.symbols b/tests/baselines/reference/exportDefaultAlias_excludesEverything.symbols new file mode 100644 index 00000000000..73b403e0da1 --- /dev/null +++ b/tests/baselines/reference/exportDefaultAlias_excludesEverything.symbols @@ -0,0 +1,10 @@ +=== tests/cases/compiler/exportDefaultAlias_excludesEverything.ts === +export default interface A {} +>A : Symbol(A, Decl(exportDefaultAlias_excludesEverything.ts, 0, 0)) + +interface B {} +>B : Symbol(B, Decl(exportDefaultAlias_excludesEverything.ts, 0, 29)) + +export default B; +>B : Symbol(B, Decl(exportDefaultAlias_excludesEverything.ts, 0, 29)) + diff --git a/tests/baselines/reference/exportDefaultAlias_excludesEverything.types b/tests/baselines/reference/exportDefaultAlias_excludesEverything.types new file mode 100644 index 00000000000..cd9dd06f817 --- /dev/null +++ b/tests/baselines/reference/exportDefaultAlias_excludesEverything.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/exportDefaultAlias_excludesEverything.ts === +export default interface A {} +>A : A + +interface B {} +>B : B + +export default B; +>B : B + diff --git a/tests/cases/compiler/exportDefaultAlias_excludesEverything.ts b/tests/cases/compiler/exportDefaultAlias_excludesEverything.ts new file mode 100644 index 00000000000..eea8cb1e698 --- /dev/null +++ b/tests/cases/compiler/exportDefaultAlias_excludesEverything.ts @@ -0,0 +1,3 @@ +export default interface A {} +interface B {} +export default B; From ddd8c95c63766d2eb321404213bb7a999193aef8 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 9 Nov 2017 12:30:29 -0800 Subject: [PATCH 18/69] Remove testcases we don't like --- src/harness/unittests/tsserverProjectSystem.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index c72a27e173e..5b6c36d071f 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1501,20 +1501,17 @@ namespace ts.projectSystem { ["jquery-max", "jquery-max"], ["jquery.min", "jquery"], ["jquery-min.4.2.3", "jquery"], - ["jquery.4.2-test.js", "jquery"], + // ["jquery.4.2-test.js", "jquery"], ["jquery.min.4.2.1", "jquery"], - ["jquery.7.min.js", "jquery"], - ["jquery.7.min-beta", "jquery"], + // ["jquery.7.min.js", "jquery"], + // ["jquery.7.min-beta", "jquery"], ["minimum", "minimum"], ["min", "min"], ["min.3.2", "min"], ["jquery", "jquery"] ]; - const suffixes = [".js", ".jsx", ""]; for (const t of testData) { - for (const suf of suffixes) { - assert.equal(removeMinAndVersionNumbers(t[0] + suf), t[1]); - } + assert.equal(removeMinAndVersionNumbers(t[0]), t[1], t[0]); } }); From 19cc42782b1abe17fdd3911505f8afe36689d053 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 9 Nov 2017 12:30:36 -0800 Subject: [PATCH 19/69] Format + new regex --- src/compiler/core.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 626480035b1..657f362067b 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -74,13 +74,13 @@ namespace ts { } // The global Map object. This may not be available, so we must test for it. - declare const Map: { new(): Map } | undefined; + declare const Map: { new (): Map } | undefined; // Internet Explorer's Map doesn't support iteration, so don't use it. // tslint:disable-next-line:no-in-operator const MapCtr = typeof Map !== "undefined" && "entries" in Map.prototype ? Map : shimMap(); // Keep the class inside a function so it doesn't get compiled if it's not used. - function shimMap(): { new(): Map } { + function shimMap(): { new (): Map } { class MapIterator { private data: MapLike; @@ -103,7 +103,7 @@ namespace ts { } } - return class implements Map { + return class implements Map { private data = createDictionaryObject(); public size = 0; @@ -166,8 +166,8 @@ namespace ts { } export const enum Comparison { - LessThan = -1, - EqualTo = 0, + LessThan = -1, + EqualTo = 0, GreaterThan = 1 } @@ -2417,13 +2417,11 @@ namespace ts { * Takes a string like "jquery-min.4.2.3" and returns "jquery" */ export function removeMinAndVersionNumbers(fileName: string) { - const match = /((\w|(-(?!min)))+)(\.|-)?.*/.exec(fileName); - if (match) { - return match[1]; - } - else { - return fileName; - } + // Match a "." or "-" followed by a version number or 'min' at the end of the name + const trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/; + + // The "min" or version may both be present, in either order, so try applying the above twice. + return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, ""); } export interface ObjectAllocator { @@ -2627,7 +2625,7 @@ namespace ts { return findBestPatternMatch(patterns, _ => _, candidate); } - export function patternText({prefix, suffix}: Pattern): string { + export function patternText({ prefix, suffix }: Pattern): string { return `${prefix}*${suffix}`; } @@ -2657,7 +2655,7 @@ namespace ts { return matchedValue; } - function isPatternMatch({prefix, suffix}: Pattern, candidate: string) { + function isPatternMatch({ prefix, suffix }: Pattern, candidate: string) { return candidate.length >= prefix.length + suffix.length && startsWith(candidate, prefix) && endsWith(candidate, suffix); From 0e105ad8de2b64a262b978b78ebca6c465a45bbf Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 9 Nov 2017 12:30:44 -0800 Subject: [PATCH 20/69] Log more usefully when this test fails --- src/harness/unittests/typingsInstaller.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/harness/unittests/typingsInstaller.ts b/src/harness/unittests/typingsInstaller.ts index fb1a7a26a7a..65d904940b3 100644 --- a/src/harness/unittests/typingsInstaller.ts +++ b/src/harness/unittests/typingsInstaller.ts @@ -1057,11 +1057,12 @@ namespace ts.projectSystem { const host = createServerHost([app, jquery, chroma]); const logger = trackingLogger(); const result = JsTyping.discoverTypings(host, logger.log, [app.path, jquery.path, chroma.path], getDirectoryPath(app.path), safeList, emptyMap, { enable: true }, emptyArray); - assert.deepEqual(logger.finish(), [ + const finish = logger.finish(); + assert.deepEqual(finish, [ 'Inferred typings from file names: ["jquery","chroma-js"]', "Inferred typings from unresolved imports: []", 'Result: {"cachedTypingPaths":[],"newTypingNames":["jquery","chroma-js"],"filesToWatch":["/a/b/bower_components","/a/b/node_modules"]}', - ]); + ], finish.join("\r\n")); assert.deepEqual(result.newTypingNames, ["jquery", "chroma-js"]); }); From 65a191fa2b0d6671d4ce0b1eec5affd426e74739 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 9 Nov 2017 13:13:23 -0800 Subject: [PATCH 21/69] For import completion of default import, convert module name to identifier (#19875) * For import completion of default import, convert module name to identifier * Suggestions from code review --- src/compiler/scanner.ts | 2 +- src/compiler/types.ts | 6 ++-- src/compiler/utilities.ts | 8 +++++ src/harness/fourslash.ts | 2 +- src/services/codefixes/importFixes.ts | 36 +++++++++++++++++-- src/services/completions.ts | 34 +++++++++++------- .../completionsImport_default_anonymous.ts | 26 ++++++++++++++ .../importNameCodeFixDefaultExport.ts | 12 +++++++ 8 files changed, 108 insertions(+), 18 deletions(-) create mode 100644 tests/cases/fourslash/completionsImport_default_anonymous.ts create mode 100644 tests/cases/fourslash/importNameCodeFixDefaultExport.ts diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index fd8c54a18cc..9fddece11d0 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -294,7 +294,7 @@ namespace ts { } /* @internal */ - export function stringToToken(s: string): SyntaxKind { + export function stringToToken(s: string): SyntaxKind | undefined { return textToToken.get(s); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d2107572ab4..bb62bead00b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -214,7 +214,7 @@ namespace ts { UndefinedKeyword, FromKeyword, GlobalKeyword, - OfKeyword, // LastKeyword and LastToken + OfKeyword, // LastKeyword and LastToken and LastContextualKeyword // Parse tree nodes @@ -431,7 +431,9 @@ namespace ts { FirstJSDocNode = JSDocTypeExpression, LastJSDocNode = JSDocPropertyTag, FirstJSDocTagNode = JSDocTag, - LastJSDocTagNode = JSDocPropertyTag + LastJSDocTagNode = JSDocPropertyTag, + /* @internal */ FirstContextualKeyword = AbstractKeyword, + /* @internal */ LastContextualKeyword = OfKeyword, } export const enum NodeFlags { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 41a5512cb2a..1931c397ae7 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1905,6 +1905,14 @@ namespace ts { return SyntaxKind.FirstKeyword <= token && token <= SyntaxKind.LastKeyword; } + export function isContextualKeyword(token: SyntaxKind): boolean { + return SyntaxKind.FirstContextualKeyword <= token && token <= SyntaxKind.LastContextualKeyword; + } + + export function isNonContextualKeyword(token: SyntaxKind): boolean { + return isKeyword(token) && !isContextualKeyword(token); + } + export function isTrivia(token: SyntaxKind) { return SyntaxKind.FirstTriviaToken <= token && token <= SyntaxKind.LastTriviaToken; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index c9aa1c6403d..2687a660ca8 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -3102,7 +3102,7 @@ Actual: ${stringify(fullActual)}`); } } - const itemsString = items.map(item => stringify({ name: item.name, kind: item.kind })).join(",\n"); + const itemsString = items.map(item => stringify({ name: item.name, source: item.source, kind: item.kind })).join(",\n"); this.raiseError(`Expected "${stringify({ entryId, text, documentation, kind })}" to be in list [${itemsString}]`); } diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index a0c7ffd75ea..838e19fa35d 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -699,9 +699,10 @@ namespace ts.codefix { const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); if (defaultExport) { const localSymbol = getLocalSymbolForExportDefault(defaultExport); - if (localSymbol && localSymbol.escapedName === symbolName && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { + if ((localSymbol && localSymbol.escapedName === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, context.compilerOptions.target) === symbolName) + && checkSymbolHasMeaning(localSymbol || defaultExport, currentTokenMeaning)) { // check if this symbol is already used - const symbolId = getUniqueSymbolId(localSymbol, checker); + const symbolId = getUniqueSymbolId(localSymbol || defaultExport, checker); symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, { ...context, kind: ImportKind.Default })); } } @@ -731,4 +732,35 @@ namespace ts.codefix { } } } + + export function moduleSymbolToValidIdentifier(moduleSymbol: Symbol, target: ScriptTarget): string { + return moduleSpecifierToValidIdentifier(removeFileExtension(getBaseFileName(moduleSymbol.name)), target); + } + + function moduleSpecifierToValidIdentifier(moduleSpecifier: string, target: ScriptTarget): string { + let res = ""; + let lastCharWasValid = true; + const firstCharCode = moduleSpecifier.charCodeAt(0); + if (isIdentifierStart(firstCharCode, target)) { + res += String.fromCharCode(firstCharCode); + } + else { + lastCharWasValid = false; + } + for (let i = 1; i < moduleSpecifier.length; i++) { + const ch = moduleSpecifier.charCodeAt(i); + const isValid = isIdentifierPart(ch, target); + if (isValid) { + let char = String.fromCharCode(ch); + if (!lastCharWasValid) { + char = char.toUpperCase(); + } + res += char; + } + lastCharWasValid = isValid; + } + // Need `|| "_"` to ensure result isn't empty. + const token = stringToToken(res); + return token === undefined || !isNonContextualKeyword(token) ? res || "_" : `_${res}`; + } } diff --git a/src/services/completions.ts b/src/services/completions.ts index f66242ca864..6a9af1e1941 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -39,7 +39,7 @@ namespace ts.Completions { return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); } - const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles, options); + const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles, options, compilerOptions.target); if (!completionData) { return undefined; } @@ -136,12 +136,12 @@ namespace ts.Completions { typeChecker: TypeChecker, target: ScriptTarget, allowStringLiteral: boolean, - origin: SymbolOriginInfo, + origin: SymbolOriginInfo | undefined, ): CompletionEntry | undefined { // Try to get a valid display name for this symbol, if we could not find one, then ignore it. // We would like to only show things that can be added after a dot, so for instance numeric properties can // not be accessed with a dot (a.1 <- invalid) - const displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral); + const displayName = getCompletionEntryDisplayNameForSymbol(symbol, target, performCharacterChecks, allowStringLiteral, origin); if (!displayName) { return undefined; } @@ -381,7 +381,7 @@ namespace ts.Completions { { name, source }: CompletionEntryIdentifier, allSourceFiles: ReadonlyArray, ): { type: "symbol", symbol: Symbol, location: Node, symbolToOriginInfoMap: SymbolOriginInfoMap } | { type: "request", request: Request } | { type: "none" } { - const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles, { includeExternalModuleExports: true }); + const completionData = getCompletionData(typeChecker, log, sourceFile, position, allSourceFiles, { includeExternalModuleExports: true }, compilerOptions.target); if (!completionData) { return { type: "none" }; } @@ -395,12 +395,18 @@ namespace ts.Completions { // We don't need to perform character checks here because we're only comparing the // name against 'entryName' (which is known to be good), not building a new // completion entry. - const symbol = find(symbols, s => - getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral) === name - && getSourceFromOrigin(symbolToOriginInfoMap[getSymbolId(s)]) === source); + const symbol = find(symbols, s => { + const origin = symbolToOriginInfoMap[getSymbolId(s)]; + return getCompletionEntryDisplayNameForSymbol(s, compilerOptions.target, /*performCharacterChecks*/ false, allowStringLiteral, origin) === name + && getSourceFromOrigin(origin) === source; + }); return symbol ? { type: "symbol", symbol, location, symbolToOriginInfoMap } : { type: "none" }; } + function getSymbolName(symbol: Symbol, origin: SymbolOriginInfo | undefined, target: ScriptTarget): string { + return origin && origin.isDefaultExport && symbol.name === "default" ? codefix.moduleSymbolToValidIdentifier(origin.moduleSymbol, target) : symbol.name; + } + export interface CompletionEntryIdentifier { name: string; source?: string; @@ -482,7 +488,7 @@ namespace ts.Completions { compilerOptions, sourceFile, formatContext, - symbolName: symbol.name, + symbolName: getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), getCanonicalFileName: createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false), symbolToken: undefined, kind: isDefaultExport ? codefix.ImportKind.Default : codefix.ImportKind.Named, @@ -523,6 +529,7 @@ namespace ts.Completions { position: number, allSourceFiles: ReadonlyArray, options: GetCompletionsAtPositionOptions, + target: ScriptTarget, ): CompletionData | undefined { const isJavaScriptFile = isSourceFileJavaScript(sourceFile); @@ -921,7 +928,7 @@ namespace ts.Completions { symbols = typeChecker.getSymbolsInScope(scopeNode, symbolMeanings); if (options.includeExternalModuleExports) { - getSymbolsFromOtherSourceFileExports(symbols, previousToken && isIdentifier(previousToken) ? previousToken.text : ""); + getSymbolsFromOtherSourceFileExports(symbols, previousToken && isIdentifier(previousToken) ? previousToken.text : "", target); } filterGlobalCompletion(symbols); @@ -1003,7 +1010,7 @@ namespace ts.Completions { } } - function getSymbolsFromOtherSourceFileExports(symbols: Symbol[], tokenText: string): void { + function getSymbolsFromOtherSourceFileExports(symbols: Symbol[], tokenText: string, target: ScriptTarget): void { const tokenTextLowerCase = tokenText.toLowerCase(); codefix.forEachExternalModule(typeChecker, allSourceFiles, moduleSymbol => { @@ -1020,6 +1027,9 @@ namespace ts.Completions { symbol = localSymbol; name = localSymbol.name; } + else { + name = codefix.moduleSymbolToValidIdentifier(moduleSymbol, target); + } } if (symbol.declarations && symbol.declarations.some(d => isExportSpecifier(d) && !!d.parent.parent.moduleSpecifier)) { @@ -1847,8 +1857,8 @@ namespace ts.Completions { * * @return undefined if the name is of external module */ - function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean, allowStringLiteral: boolean): string | undefined { - const name = symbol.name; + function getCompletionEntryDisplayNameForSymbol(symbol: Symbol, target: ScriptTarget, performCharacterChecks: boolean, allowStringLiteral: boolean, origin: SymbolOriginInfo | undefined): string | undefined { + const name = getSymbolName(symbol, origin, target); if (!name) return undefined; // First check of the displayName is not external module; if it is an external module, it is not valid entry diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts new file mode 100644 index 00000000000..7c0697584f9 --- /dev/null +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -0,0 +1,26 @@ +/// + +// Use `/src` to test that directory names are not included in conversion from module path to identifier. + +// @Filename: /src/foo-bar.ts +////export default 0; + +// @Filename: /src/b.ts +////def/*0*/ +////fooB/*1*/ + +goTo.marker("0"); +verify.not.completionListContains({ name: "default", source: "/src/foo-bar" }, undefined, undefined, undefined, undefined, undefined, { includeExternalModuleExports: true }); + +goTo.marker("1"); +verify.completionListContains({ name: "fooBar", source: "/src/foo-bar" }, "(property) default: 0", "", "property", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.applyCodeActionFromCompletion("1", { + name: "fooBar", + source: "/src/foo-bar", + description: `Import 'fooBar' from "./foo-bar".`, + // TODO: GH#18445 + newFileContent: `import fooBar from "./foo-bar";\r +\r +def +fooB`, +}); diff --git a/tests/cases/fourslash/importNameCodeFixDefaultExport.ts b/tests/cases/fourslash/importNameCodeFixDefaultExport.ts new file mode 100644 index 00000000000..2f502aa66fa --- /dev/null +++ b/tests/cases/fourslash/importNameCodeFixDefaultExport.ts @@ -0,0 +1,12 @@ +/// + +// @Filename: /foo-bar.ts +////export default 0; + +// @Filename: /b.ts +////[|foo/**/Bar|] + +goTo.file("/b.ts"); +verify.importFixAtPosition([`import fooBar from "./foo-bar"; + +fooBar`]); From b94940525b77f31a8e7782c92fe3ea53371c93fb Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 9 Nov 2017 13:17:47 -0800 Subject: [PATCH 22/69] Allow applyCodeActionCommand to take an array (#19870) * Allow applyCodeActionCommand to take an array * Use this.host.newLine --- src/server/protocol.ts | 1 + src/server/session.ts | 7 +++++-- src/services/services.ts | 10 ++++++++-- src/services/types.ts | 2 ++ src/services/utilities.ts | 1 + tests/baselines/reference/api/tsserverlibrary.d.ts | 3 +++ tests/baselines/reference/api/typescript.d.ts | 2 ++ 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/server/protocol.ts b/src/server/protocol.ts index f44efa0db21..3761049017d 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -586,6 +586,7 @@ namespace ts.server.protocol { } export interface ApplyCodeActionCommandRequestArgs extends FileRequestArgs { + /** May also be an array of commands. */ command: {}; } diff --git a/src/server/session.ts b/src/server/session.ts index 6c97c3c8bd4..f9a145d16fd 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1571,9 +1571,12 @@ namespace ts.server { private applyCodeActionCommand(commandName: string, requestSeq: number, args: protocol.ApplyCodeActionCommandRequestArgs): void { const { file, project } = this.getFileAndProject(args); const output = (success: boolean, message: string) => this.doOutput({}, commandName, requestSeq, success, message); - const command = args.command as CodeActionCommand; // They should be sending back the command we sent them. + const command = args.command as CodeActionCommand | CodeActionCommand[]; // They should be sending back the command we sent them. + project.getLanguageService().applyCodeActionCommand(file, command).then( - ({ successMessage }) => { output(/*success*/ true, successMessage); }, + result => { + output(/*success*/ true, isArray(result) ? result.map(res => res.successMessage).join(`${this.host.newLine}${this.host.newLine}`) : result.successMessage); + }, error => { output(/*success*/ false, error); }); } diff --git a/src/services/services.ts b/src/services/services.ts index 37298c8eba8..06358d3a720 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1868,8 +1868,14 @@ namespace ts { }); } - function applyCodeActionCommand(fileName: Path, action: CodeActionCommand): Promise { - fileName = toPath(fileName, currentDirectory, getCanonicalFileName); + function applyCodeActionCommand(fileName: Path, action: CodeActionCommand): Promise; + function applyCodeActionCommand(fileName: Path, action: CodeActionCommand[]): Promise; + function applyCodeActionCommand(fileName: Path, action: CodeActionCommand | CodeActionCommand[]): Promise { + const path = toPath(fileName, currentDirectory, getCanonicalFileName); + return isArray(action) ? Promise.all(action.map(a => applySingleCodeActionCommand(path, a))) : applySingleCodeActionCommand(path, action); + } + + function applySingleCodeActionCommand(fileName: Path, action: CodeActionCommand): Promise { switch (action.type) { case "install package": return host.installPackage diff --git a/src/services/types.ts b/src/services/types.ts index a9244982fbb..bcebc437892 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -294,6 +294,8 @@ namespace ts { getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; applyCodeActionCommand(fileName: string, action: CodeActionCommand): Promise; + applyCodeActionCommand(fileName: string, action: CodeActionCommand[]): Promise; + applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined; diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 1ed44d29f95..cf71118292a 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -3,6 +3,7 @@ interface PromiseConstructor { new (executor: (resolve: (value?: T | PromiseLike) => void, reject: (reason?: any) => void) => void): Promise; reject(reason: any): Promise; + all(values: (T | PromiseLike)[]): Promise; } /* @internal */ declare var Promise: PromiseConstructor; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index a3499de08ab..78e8a377ec0 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -3965,6 +3965,8 @@ declare namespace ts { getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; applyCodeActionCommand(fileName: string, action: CodeActionCommand): Promise; + applyCodeActionCommand(fileName: string, action: CodeActionCommand[]): Promise; + applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; @@ -5263,6 +5265,7 @@ declare namespace ts.server.protocol { errorCodes?: number[]; } interface ApplyCodeActionCommandRequestArgs extends FileRequestArgs { + /** May also be an array of commands. */ command: {}; } /** diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 98d7137ddeb..3344193d0ce 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -3965,6 +3965,8 @@ declare namespace ts { getSpanOfEnclosingComment(fileName: string, position: number, onlyMultiLine: boolean): TextSpan; getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; applyCodeActionCommand(fileName: string, action: CodeActionCommand): Promise; + applyCodeActionCommand(fileName: string, action: CodeActionCommand[]): Promise; + applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; getApplicableRefactors(fileName: string, positionOrRaneg: number | TextRange): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string): RefactorEditInfo | undefined; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; From 0d5dec9a9870637cb4602cd7eb05683d97d0dcda Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Thu, 9 Nov 2017 13:55:20 -0800 Subject: [PATCH 23/69] Remove commented tests --- src/harness/unittests/tsserverProjectSystem.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 018934e9d7d..ea573726eb8 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -1544,10 +1544,7 @@ namespace ts.projectSystem { ["jquery-max", "jquery-max"], ["jquery.min", "jquery"], ["jquery-min.4.2.3", "jquery"], - // ["jquery.4.2-test.js", "jquery"], ["jquery.min.4.2.1", "jquery"], - // ["jquery.7.min.js", "jquery"], - // ["jquery.7.min-beta", "jquery"], ["minimum", "minimum"], ["min", "min"], ["min.3.2", "min"], From a5fa75a0cd095702d41e259cd2eb73d2c777b162 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 9 Nov 2017 14:21:08 -0800 Subject: [PATCH 24/69] DefinitelyTypedRunner skips ExpectErrors If all errors were ExpectErrors, then it does not fail. --- src/harness/externalCompileRunner.ts | 91 +++++++++++++++++++++++----- 1 file changed, 75 insertions(+), 16 deletions(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 9b8fc8c4fc5..ec8acf4872e 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -1,14 +1,17 @@ /// /// +const fs = require("fs"); +const path = require("path"); abstract class ExternalCompileRunnerBase extends RunnerBase { abstract testDir: string; - public enumerateTestFiles() { + abstract report(result: any, cwd: string): string; + enumerateTestFiles() { return Harness.IO.getDirectories(this.testDir); } /** Setup the runner's tests so that they are ready to be executed by the harness * The first test should be a describe/it block that sets up the harness's compiler instance appropriately */ - public initializeTests(): void { + initializeTests(): void { // Read in and evaluate the test list const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles(); @@ -36,15 +39,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed!`); } Harness.Baseline.runBaseline(`${this.kind()}/${directoryName}.log`, () => { - const result = cp.spawnSync(`node`, [path.join(__dirname, "tsc.js")], { cwd, timeout, shell: true }); - // tslint:disable-next-line:no-null-keyword - return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status} -Standard output: -${result.stdout.toString().replace(/\r\n/g, "\n")} - - -Standard error: -${result.stderr.toString().replace(/\r\n/g, "\n")}`; + return this.report(cp.spawnSync(`node`, [path.join(__dirname, "tsc.js")], { cwd, timeout, shell: true }), cwd); }); }); }); @@ -52,16 +47,80 @@ ${result.stderr.toString().replace(/\r\n/g, "\n")}`; } class UserCodeRunner extends ExternalCompileRunnerBase { - public readonly testDir = "tests/cases/user/"; - public kind(): TestRunnerKind { + readonly testDir = "tests/cases/user/"; + kind(): TestRunnerKind { return "user"; } + report(result: any) { + // tslint:disable-next-line:no-null-keyword + return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status} +Standard output: +${result.stdout.toString().replace(/\r\n/g, "\n")} + + +Standard error: +${result.stderr.toString().replace(/\r\n/g, "\n")}`; + } } class DefinitelyTypedRunner extends ExternalCompileRunnerBase { - public readonly testDir = "../DefinitelyTyped/types/"; - public workingDirectory = this.testDir; - public kind(): TestRunnerKind { + readonly testDir = "../DefinitelyTyped/types/"; + workingDirectory = this.testDir; + kind(): TestRunnerKind { return "dt"; } + report(result: any, cwd: string) { + const stdout = filterExpectedErrors(result.stdout.toString(), cwd) + const stderr = result.stderr.toString() + // tslint:disable-next-line:no-null-keyword + return !stdout.length && !stderr.length ? null : `Exit Code: ${result.status} +Standard output: +${stdout.replace(/\r\n/g, "\n")} + + +Standard error: +${stderr.replace(/\r\n/g, "\n")}`; + } +} + +function filterExpectedErrors(errors: string, cwd: string): string { + return breaks(errors.split("\n"), s => /^\w+/.test(s)).filter(isExpectedError(cwd)).map(lines => lines.join("\n")).join("\n"); +} +function isExpectedError(cwd: string) { + return (error: string[]) => { + if (error.length === 0) { + return true; + } + const match = error[0].match(/(.+\.ts)\((\d+),\d+\): error TS/); + if (!match) { + return true; + } + const errlines = fs.readFileSync(path.join(cwd, match[1]), { encoding: "utf8" }).split("\n"); + const index = parseInt(match[2]); + const errline = index < errlines.length ? errlines[index] : ""; + const prevline = index - 1 < errlines.length && index > 0 ? errlines[index - 1] : ""; + if (errline.indexOf("$ExpectError") > -1 || prevline.indexOf("$ExpectError") > -1) { + return false; + } + return true; + } +} +function breaks(xs: T[], isStart: (T: any) => boolean): T[][] { + const result = []; + let group: T[] = []; + for (const x of xs) { + if (isStart(x)) { + if (group.length) { + result.push(group); + } + group = [x]; + } + else { + group.push(x); + } + } + if (group.length) { + result.push(group); + } + return result; } From 2372ffcddc22c567d81f7667cd3ae8451f82e6ca Mon Sep 17 00:00:00 2001 From: csigs Date: Thu, 9 Nov 2017 23:10:34 +0000 Subject: [PATCH 25/69] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- 1 file changed, 77 insertions(+), 83 deletions(-) diff --git a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl index 8dab90a1ba2..3bb9642d207 100644 --- a/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/csy/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1620,12 +1620,9 @@ - + - - - - + @@ -3735,6 +3732,24 @@ + + + + + + + + + + + + + + + + + + @@ -3966,6 +3981,15 @@ + + + + + + + + + @@ -5211,24 +5235,6 @@ - - - - - - - - - - - - - - - - - - @@ -5256,24 +5262,6 @@ - - - - - - - - - - - - - - - - - - @@ -5292,6 +5280,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5997,6 +6009,24 @@ + + + + + + + + + + + + + + + + + + @@ -6024,30 +6054,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6078,33 +6099,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - From 16efae24338f09c9059c8ec1525166f521110935 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 9 Nov 2017 16:49:04 -0800 Subject: [PATCH 26/69] Consider the commonjs module indicator as a module indicator (#18490) * Consider the commonjs module indicator as an indicator that something is effectively an external module * Only use commonjs module indicator when targeting commonjs --- src/compiler/transformers/module/module.ts | 2 +- src/compiler/utilities.ts | 2 +- .../reference/javascriptCommonjsModule.js | 23 +++++++++++++++++++ .../javascriptCommonjsModule.symbols | 13 +++++++++++ .../reference/javascriptCommonjsModule.types | 15 ++++++++++++ .../compiler/javascriptCommonjsModule.ts | 11 +++++++++ 6 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/javascriptCommonjsModule.js create mode 100644 tests/baselines/reference/javascriptCommonjsModule.symbols create mode 100644 tests/baselines/reference/javascriptCommonjsModule.types create mode 100644 tests/cases/compiler/javascriptCommonjsModule.ts diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index f60e50ea365..0c8e2cda0f5 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -57,7 +57,7 @@ namespace ts { * @param node The SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules || node.transformFlags & TransformFlags.ContainsDynamicImport)) { + if (node.isDeclarationFile || !(isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & TransformFlags.ContainsDynamicImport)) { return node; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 1931c397ae7..e67635cba04 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -461,7 +461,7 @@ namespace ts { } export function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions) { - return isExternalModule(node) || compilerOptions.isolatedModules; + return isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ModuleKind.CommonJS) && !!node.commonJsModuleIndicator); } /* @internal */ diff --git a/tests/baselines/reference/javascriptCommonjsModule.js b/tests/baselines/reference/javascriptCommonjsModule.js new file mode 100644 index 00000000000..ab517f63805 --- /dev/null +++ b/tests/baselines/reference/javascriptCommonjsModule.js @@ -0,0 +1,23 @@ +//// [index.js] +class Foo {} + +class Bar extends Foo {} + +module.exports = Bar; + + +//// [index.js] +var tslib_1 = require("tslib"); +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +var Bar = /** @class */ (function (_super) { + tslib_1.__extends(Bar, _super); + function Bar() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Bar; +}(Foo)); +module.exports = Bar; diff --git a/tests/baselines/reference/javascriptCommonjsModule.symbols b/tests/baselines/reference/javascriptCommonjsModule.symbols new file mode 100644 index 00000000000..923e0b3467b --- /dev/null +++ b/tests/baselines/reference/javascriptCommonjsModule.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/index.js === +class Foo {} +>Foo : Symbol(Foo, Decl(index.js, 0, 0)) + +class Bar extends Foo {} +>Bar : Symbol(Bar, Decl(index.js, 0, 12)) +>Foo : Symbol(Foo, Decl(index.js, 0, 0)) + +module.exports = Bar; +>module : Symbol(export=, Decl(index.js, 2, 24)) +>exports : Symbol(export=, Decl(index.js, 2, 24)) +>Bar : Symbol(Bar, Decl(index.js, 0, 12)) + diff --git a/tests/baselines/reference/javascriptCommonjsModule.types b/tests/baselines/reference/javascriptCommonjsModule.types new file mode 100644 index 00000000000..88126ce4737 --- /dev/null +++ b/tests/baselines/reference/javascriptCommonjsModule.types @@ -0,0 +1,15 @@ +=== tests/cases/compiler/index.js === +class Foo {} +>Foo : Foo + +class Bar extends Foo {} +>Bar : Bar +>Foo : Foo + +module.exports = Bar; +>module.exports = Bar : typeof Bar +>module.exports : any +>module : any +>exports : any +>Bar : typeof Bar + diff --git a/tests/cases/compiler/javascriptCommonjsModule.ts b/tests/cases/compiler/javascriptCommonjsModule.ts new file mode 100644 index 00000000000..dde30580f70 --- /dev/null +++ b/tests/cases/compiler/javascriptCommonjsModule.ts @@ -0,0 +1,11 @@ +// @allowJS: true +// @outDir: ./out +// @module: commonjs +// @noEmitHelpers: true +// @importHelpers: true +// @filename: index.js +class Foo {} + +class Bar extends Foo {} + +module.exports = Bar; From 2010c4cda1097697390d981d63d31600d1fe9808 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 10 Nov 2017 08:30:59 -0800 Subject: [PATCH 27/69] Give lowest priority to inferences made from empty array literals --- src/compiler/checker.ts | 17 ++++++++++------- src/compiler/types.ts | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a9aaa77fa74..fedc0c77c8f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10898,22 +10898,25 @@ namespace ts { // it as an inference candidate. Hopefully, a better candidate will come along that does // not contain anyFunctionType when we come back to this argument for its second round // of inference. Also, we exclude inferences for silentNeverType (which is used as a wildcard - // when constructing types from type parameters that had no inference candidates) and - // implicitNeverType (which is used as the element type for empty array literals). - if (source.flags & TypeFlags.ContainsAnyFunctionType || source === silentNeverType || source === implicitNeverType) { + // when constructing types from type parameters that had no inference candidates). + if (source.flags & TypeFlags.ContainsAnyFunctionType || source === silentNeverType) { return; } const inference = getInferenceInfoForType(target); if (inference) { if (!inference.isFixed) { - if (!inference.candidates || priority < inference.priority) { + // We give lowest priority to inferences of implicitNeverType (which is used as the + // element type for empty array literals). Thus, inferences from empty array literals + // only matter when no other inferences are made. + const p = priority | (source === implicitNeverType ? InferencePriority.NeverType : 0); + if (!inference.candidates || p < inference.priority) { inference.candidates = [source]; - inference.priority = priority; + inference.priority = p; } - else if (priority === inference.priority) { + else if (p === inference.priority) { inference.candidates.push(source); } - if (!(priority & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && !isTypeParameterAtTopLevel(originalTarget, target)) { + if (!(p & InferencePriority.ReturnType) && target.flags & TypeFlags.TypeParameter && !isTypeParameterAtTopLevel(originalTarget, target)) { inference.topLevel = false; } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index bb62bead00b..3141e3f22d9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3613,6 +3613,7 @@ namespace ts { NakedTypeVariable = 1 << 1, // Naked type variable in union or intersection type MappedType = 1 << 2, // Reverse inference for mapped type ReturnType = 1 << 3, // Inference made from return type of generic function + NeverType = 1 << 4, // Inference made from the never type } export interface InferenceInfo { From 197c635994a5d02c50d6066f05f4382da446a8fa Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 10 Nov 2017 08:36:50 -0800 Subject: [PATCH 28/69] Update tests --- .../cases/conformance/types/never/neverInference.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/cases/conformance/types/never/neverInference.ts b/tests/cases/conformance/types/never/neverInference.ts index 1258a35e3d3..c28d30d92c2 100644 --- a/tests/cases/conformance/types/never/neverInference.ts +++ b/tests/cases/conformance/types/never/neverInference.ts @@ -1,11 +1,11 @@ // @strict: true -declare function f(x: T[]): T; +declare function f1(x: T[]): T; let neverArray: never[] = []; -let a1 = f([]); // {} -let a2 = f(neverArray); // never +let a1 = f1([]); // never +let a2 = f1(neverArray); // never // Repro from #19576 @@ -22,3 +22,9 @@ declare function compareNumbers(x: number, y: number): number; declare function mkList(items: T[], comparator: Comparator): LinkedList; const list: LinkedList = mkList([], compareNumbers); + +// Repro from #19858 + +declare function f2(as1: a[], as2: a[], cmp: (a1: a, a2: a) => number): void; +f2(Array.from([0]), [], (a1, a2) => a1 - a2); +f2(Array.from([]), [0], (a1, a2) => a1 - a2); From afec1e1fa154e1a51ec60ef15433f93ace5b74b9 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 10 Nov 2017 08:39:29 -0800 Subject: [PATCH 29/69] Update test --- tests/cases/conformance/types/never/neverInference.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/cases/conformance/types/never/neverInference.ts b/tests/cases/conformance/types/never/neverInference.ts index c28d30d92c2..549d27ae109 100644 --- a/tests/cases/conformance/types/never/neverInference.ts +++ b/tests/cases/conformance/types/never/neverInference.ts @@ -1,4 +1,5 @@ // @strict: true +// @target: es2015 declare function f1(x: T[]): T; From 2c43ef1e9b262477ced59124f2541a5102d0894d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 10 Nov 2017 08:39:49 -0800 Subject: [PATCH 30/69] Accept new baselines --- tests/baselines/reference/neverInference.js | 22 ++++-- .../reference/neverInference.symbols | 61 +++++++++++++---- .../baselines/reference/neverInference.types | 67 ++++++++++++++++--- 3 files changed, 121 insertions(+), 29 deletions(-) diff --git a/tests/baselines/reference/neverInference.js b/tests/baselines/reference/neverInference.js index d13e537eba4..3b570599772 100644 --- a/tests/baselines/reference/neverInference.js +++ b/tests/baselines/reference/neverInference.js @@ -1,10 +1,10 @@ //// [neverInference.ts] -declare function f(x: T[]): T; +declare function f1(x: T[]): T; let neverArray: never[] = []; -let a1 = f([]); // {} -let a2 = f(neverArray); // never +let a1 = f1([]); // never +let a2 = f1(neverArray); // never // Repro from #19576 @@ -21,11 +21,19 @@ declare function compareNumbers(x: number, y: number): number; declare function mkList(items: T[], comparator: Comparator): LinkedList; const list: LinkedList = mkList([], compareNumbers); + +// Repro from #19858 + +declare function f2(as1: a[], as2: a[], cmp: (a1: a, a2: a) => number): void; +f2(Array.from([0]), [], (a1, a2) => a1 - a2); +f2(Array.from([]), [0], (a1, a2) => a1 - a2); //// [neverInference.js] "use strict"; -var neverArray = []; -var a1 = f([]); // {} -var a2 = f(neverArray); // never -var list = mkList([], compareNumbers); +let neverArray = []; +let a1 = f1([]); // never +let a2 = f1(neverArray); // never +const list = mkList([], compareNumbers); +f2(Array.from([0]), [], (a1, a2) => a1 - a2); +f2(Array.from([]), [0], (a1, a2) => a1 - a2); diff --git a/tests/baselines/reference/neverInference.symbols b/tests/baselines/reference/neverInference.symbols index 683e079b2f8..0441770dd3f 100644 --- a/tests/baselines/reference/neverInference.symbols +++ b/tests/baselines/reference/neverInference.symbols @@ -1,27 +1,27 @@ === tests/cases/conformance/types/never/neverInference.ts === -declare function f(x: T[]): T; ->f : Symbol(f, Decl(neverInference.ts, 0, 0)) ->T : Symbol(T, Decl(neverInference.ts, 0, 19)) ->x : Symbol(x, Decl(neverInference.ts, 0, 22)) ->T : Symbol(T, Decl(neverInference.ts, 0, 19)) ->T : Symbol(T, Decl(neverInference.ts, 0, 19)) +declare function f1(x: T[]): T; +>f1 : Symbol(f1, Decl(neverInference.ts, 0, 0)) +>T : Symbol(T, Decl(neverInference.ts, 0, 20)) +>x : Symbol(x, Decl(neverInference.ts, 0, 23)) +>T : Symbol(T, Decl(neverInference.ts, 0, 20)) +>T : Symbol(T, Decl(neverInference.ts, 0, 20)) let neverArray: never[] = []; >neverArray : Symbol(neverArray, Decl(neverInference.ts, 2, 3)) -let a1 = f([]); // {} +let a1 = f1([]); // never >a1 : Symbol(a1, Decl(neverInference.ts, 4, 3)) ->f : Symbol(f, Decl(neverInference.ts, 0, 0)) +>f1 : Symbol(f1, Decl(neverInference.ts, 0, 0)) -let a2 = f(neverArray); // never +let a2 = f1(neverArray); // never >a2 : Symbol(a2, Decl(neverInference.ts, 5, 3)) ->f : Symbol(f, Decl(neverInference.ts, 0, 0)) +>f1 : Symbol(f1, Decl(neverInference.ts, 0, 0)) >neverArray : Symbol(neverArray, Decl(neverInference.ts, 2, 3)) // Repro from #19576 type Comparator = (x: T, y: T) => number; ->Comparator : Symbol(Comparator, Decl(neverInference.ts, 5, 23)) +>Comparator : Symbol(Comparator, Decl(neverInference.ts, 5, 24)) >T : Symbol(T, Decl(neverInference.ts, 9, 16)) >x : Symbol(x, Decl(neverInference.ts, 9, 22)) >T : Symbol(T, Decl(neverInference.ts, 9, 16)) @@ -34,7 +34,7 @@ interface LinkedList { comparator: Comparator, >comparator : Symbol(LinkedList.comparator, Decl(neverInference.ts, 11, 25)) ->Comparator : Symbol(Comparator, Decl(neverInference.ts, 5, 23)) +>Comparator : Symbol(Comparator, Decl(neverInference.ts, 5, 24)) >T : Symbol(T, Decl(neverInference.ts, 11, 21)) nodes: Node @@ -63,7 +63,7 @@ declare function mkList(items: T[], comparator: Comparator): LinkedList >items : Symbol(items, Decl(neverInference.ts, 19, 27)) >T : Symbol(T, Decl(neverInference.ts, 19, 24)) >comparator : Symbol(comparator, Decl(neverInference.ts, 19, 38)) ->Comparator : Symbol(Comparator, Decl(neverInference.ts, 5, 23)) +>Comparator : Symbol(Comparator, Decl(neverInference.ts, 5, 24)) >T : Symbol(T, Decl(neverInference.ts, 19, 24)) >LinkedList : Symbol(LinkedList, Decl(neverInference.ts, 9, 44)) >T : Symbol(T, Decl(neverInference.ts, 19, 24)) @@ -74,3 +74,38 @@ const list: LinkedList = mkList([], compareNumbers); >mkList : Symbol(mkList, Decl(neverInference.ts, 18, 62)) >compareNumbers : Symbol(compareNumbers, Decl(neverInference.ts, 16, 49)) +// Repro from #19858 + +declare function f2(as1: a[], as2: a[], cmp: (a1: a, a2: a) => number): void; +>f2 : Symbol(f2, Decl(neverInference.ts, 21, 60)) +>a : Symbol(a, Decl(neverInference.ts, 25, 20)) +>as1 : Symbol(as1, Decl(neverInference.ts, 25, 23)) +>a : Symbol(a, Decl(neverInference.ts, 25, 20)) +>as2 : Symbol(as2, Decl(neverInference.ts, 25, 32)) +>a : Symbol(a, Decl(neverInference.ts, 25, 20)) +>cmp : Symbol(cmp, Decl(neverInference.ts, 25, 42)) +>a1 : Symbol(a1, Decl(neverInference.ts, 25, 49)) +>a : Symbol(a, Decl(neverInference.ts, 25, 20)) +>a2 : Symbol(a2, Decl(neverInference.ts, 25, 55)) +>a : Symbol(a, Decl(neverInference.ts, 25, 20)) + +f2(Array.from([0]), [], (a1, a2) => a1 - a2); +>f2 : Symbol(f2, Decl(neverInference.ts, 21, 60)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>a1 : Symbol(a1, Decl(neverInference.ts, 26, 25)) +>a2 : Symbol(a2, Decl(neverInference.ts, 26, 28)) +>a1 : Symbol(a1, Decl(neverInference.ts, 26, 25)) +>a2 : Symbol(a2, Decl(neverInference.ts, 26, 28)) + +f2(Array.from([]), [0], (a1, a2) => a1 - a2); +>f2 : Symbol(f2, Decl(neverInference.ts, 21, 60)) +>Array.from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>from : Symbol(ArrayConstructor.from, Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) +>a1 : Symbol(a1, Decl(neverInference.ts, 27, 25)) +>a2 : Symbol(a2, Decl(neverInference.ts, 27, 28)) +>a1 : Symbol(a1, Decl(neverInference.ts, 27, 25)) +>a2 : Symbol(a2, Decl(neverInference.ts, 27, 28)) + diff --git a/tests/baselines/reference/neverInference.types b/tests/baselines/reference/neverInference.types index a7dd05a3f8b..2f4b9e0cc1e 100644 --- a/tests/baselines/reference/neverInference.types +++ b/tests/baselines/reference/neverInference.types @@ -1,6 +1,6 @@ === tests/cases/conformance/types/never/neverInference.ts === -declare function f(x: T[]): T; ->f : (x: T[]) => T +declare function f1(x: T[]): T; +>f1 : (x: T[]) => T >T : T >x : T[] >T : T @@ -10,16 +10,16 @@ let neverArray: never[] = []; >neverArray : never[] >[] : never[] -let a1 = f([]); // {} ->a1 : {} ->f([]) : {} ->f : (x: T[]) => T +let a1 = f1([]); // never +>a1 : never +>f1([]) : never +>f1 : (x: T[]) => T >[] : never[] -let a2 = f(neverArray); // never +let a2 = f1(neverArray); // never >a2 : never ->f(neverArray) : never ->f : (x: T[]) => T +>f1(neverArray) : never +>f1 : (x: T[]) => T >neverArray : never[] // Repro from #19576 @@ -81,3 +81,52 @@ const list: LinkedList = mkList([], compareNumbers); >[] : never[] >compareNumbers : (x: number, y: number) => number +// Repro from #19858 + +declare function f2(as1: a[], as2: a[], cmp: (a1: a, a2: a) => number): void; +>f2 : (as1: a[], as2: a[], cmp: (a1: a, a2: a) => number) => void +>a : a +>as1 : a[] +>a : a +>as2 : a[] +>a : a +>cmp : (a1: a, a2: a) => number +>a1 : a +>a : a +>a2 : a +>a : a + +f2(Array.from([0]), [], (a1, a2) => a1 - a2); +>f2(Array.from([0]), [], (a1, a2) => a1 - a2) : void +>f2 : (as1: a[], as2: a[], cmp: (a1: a, a2: a) => number) => void +>Array.from([0]) : number[] +>Array.from : { (iterable: Iterable): T[]; (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable): T[]; (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } +>[0] : number[] +>0 : 0 +>[] : never[] +>(a1, a2) => a1 - a2 : (a1: number, a2: number) => number +>a1 : number +>a2 : number +>a1 - a2 : number +>a1 : number +>a2 : number + +f2(Array.from([]), [0], (a1, a2) => a1 - a2); +>f2(Array.from([]), [0], (a1, a2) => a1 - a2) : void +>f2 : (as1: a[], as2: a[], cmp: (a1: a, a2: a) => number) => void +>Array.from([]) : never[] +>Array.from : { (iterable: Iterable): T[]; (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } +>Array : ArrayConstructor +>from : { (iterable: Iterable): T[]; (iterable: Iterable, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; (arrayLike: ArrayLike): T[]; (arrayLike: ArrayLike, mapfn: (v: T, k: number) => U, thisArg?: any): U[]; } +>[] : never[] +>[0] : number[] +>0 : 0 +>(a1, a2) => a1 - a2 : (a1: number, a2: number) => number +>a1 : number +>a2 : number +>a1 - a2 : number +>a1 : number +>a2 : number + From c3b650fb38eaba314301edc0a6ce64a7b122acd2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 10 Nov 2017 08:44:38 -0800 Subject: [PATCH 31/69] Accept API baseline changes --- tests/baselines/reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 78e8a377ec0..ffca9ca6c5a 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2142,6 +2142,7 @@ declare namespace ts { NakedTypeVariable = 2, MappedType = 4, ReturnType = 8, + NeverType = 16, } interface InferenceInfo { typeParameter: TypeParameter; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 3344193d0ce..dcc077d2cd7 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2142,6 +2142,7 @@ declare namespace ts { NakedTypeVariable = 2, MappedType = 4, ReturnType = 8, + NeverType = 16, } interface InferenceInfo { typeParameter: TypeParameter; From d6614447fd0d02f71580fd74e4ad33bb3cc08d56 Mon Sep 17 00:00:00 2001 From: csigs Date: Fri, 10 Nov 2017 17:10:05 +0000 Subject: [PATCH 32/69] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- 3 files changed, 231 insertions(+), 249 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index c59e9c20060..292a20a49bf 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1611,12 +1611,9 @@ - + - - - - + @@ -3726,6 +3723,24 @@ + + + + + + + + + + + + + + + + + + @@ -3957,6 +3972,15 @@ + + + + + + + + + @@ -5202,24 +5226,6 @@ - - - - - - - - - - - - - - - - - - @@ -5247,24 +5253,6 @@ - - - - - - - - - - - - - - - - - - @@ -5283,6 +5271,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5988,6 +6000,24 @@ + + + + + + + + + + + + + + + + + + @@ -6015,30 +6045,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6069,33 +6090,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl index b2ae023f5a4..6ea7ba86fc7 100644 --- a/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/jpn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1611,12 +1611,9 @@ - + - - - - + @@ -3726,6 +3723,24 @@ + + + + + + + + + + + + + + + + + + @@ -3957,6 +3972,15 @@ + + + + + + + + + @@ -5202,24 +5226,6 @@ - - - - - - - - - - - - - - - - - - @@ -5247,24 +5253,6 @@ - - - - - - - - - - - - - - - - - - @@ -5283,6 +5271,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5988,6 +6000,24 @@ + + + + + + + + + + + + + + + + + + @@ -6015,30 +6045,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6069,33 +6090,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2693d7cce27..80c5f4e15d2 100644 --- a/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/kor/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1611,12 +1611,9 @@ - + - - - - + @@ -3726,6 +3723,24 @@ + + + + + + + + + + + + + + + + + + @@ -3957,6 +3972,15 @@ + + + + + + + + + @@ -5202,24 +5226,6 @@ - - - - - - - - - - - - - - - - - - @@ -5247,24 +5253,6 @@ - - - - - - - - - - - - - - - - - - @@ -5283,6 +5271,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5988,6 +6000,24 @@ + + + + + + + + + + + + + + + + + + @@ -6015,30 +6045,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6069,33 +6090,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - From 5ffcc421696a11e3db9398629d84fcfb4305826b Mon Sep 17 00:00:00 2001 From: Andy Date: Fri, 10 Nov 2017 09:34:20 -0800 Subject: [PATCH 33/69] Simplify setting constEnumOnlyModule (#19735) --- src/compiler/binder.ts | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4e89abde780..a0146740678 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1570,7 +1570,7 @@ namespace ts { else { let pattern: Pattern | undefined; if (node.name.kind === SyntaxKind.StringLiteral) { - const text = (node.name).text; + const { text } = node.name; if (hasZeroOrOneAsteriskCharacter(text)) { pattern = tryParsePattern(text); } @@ -1589,22 +1589,13 @@ namespace ts { else { const state = declareModuleSymbol(node); if (state !== ModuleInstanceState.NonInstantiated) { - if (node.symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum)) { - // if module was already merged with some function, class or non-const enum - // treat is a non-const-enum-only - node.symbol.constEnumOnlyModule = false; - } - else { - const currentModuleIsConstEnumOnly = state === ModuleInstanceState.ConstEnumOnly; - if (node.symbol.constEnumOnlyModule === undefined) { - // non-merged case - use the current state - node.symbol.constEnumOnlyModule = currentModuleIsConstEnumOnly; - } - else { - // merged case: module is const enum only if all its pieces are non-instantiated or const enum - node.symbol.constEnumOnlyModule = node.symbol.constEnumOnlyModule && currentModuleIsConstEnumOnly; - } - } + const { symbol } = node; + // if module was already merged with some function, class or non-const enum, treat it as non-const-enum-only + symbol.constEnumOnlyModule = (!(symbol.flags & (SymbolFlags.Function | SymbolFlags.Class | SymbolFlags.RegularEnum))) + // Current must be `const enum` only + && state === ModuleInstanceState.ConstEnumOnly + // Can't have been set to 'false' in a previous merged symbol. ('undefined' OK) + && symbol.constEnumOnlyModule !== false; } } } From 0d5800a17bc0ed88094b5dc3e8190128f4f71446 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 09:37:06 -0800 Subject: [PATCH 34/69] Address PR comments --- src/harness/externalCompileRunner.ts | 62 +++++++++++++++++----------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index ec8acf4872e..5730c5c3c83 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -2,9 +2,16 @@ /// const fs = require("fs"); const path = require("path"); + +interface ExecResult { + stdout: Buffer; + stderr: Buffer; + status: number; +} + abstract class ExternalCompileRunnerBase extends RunnerBase { abstract testDir: string; - abstract report(result: any, cwd: string): string; + abstract report(result: ExecResult, cwd: string): string; enumerateTestFiles() { return Harness.IO.getDirectories(this.testDir); } @@ -24,8 +31,6 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { private runTest(directoryName: string) { describe(directoryName, () => { const cp = require("child_process"); - const path = require("path"); - const fs = require("fs"); it("should build successfully", () => { const cwd = path.join(__dirname, "../../", this.testDir, directoryName); @@ -51,7 +56,7 @@ class UserCodeRunner extends ExternalCompileRunnerBase { kind(): TestRunnerKind { return "user"; } - report(result: any) { + report(result: ExecResult) { // tslint:disable-next-line:no-null-keyword return result.status === 0 && !result.stdout.length && !result.stderr.length ? null : `Exit Code: ${result.status} Standard output: @@ -69,9 +74,9 @@ class DefinitelyTypedRunner extends ExternalCompileRunnerBase { kind(): TestRunnerKind { return "dt"; } - report(result: any, cwd: string) { - const stdout = filterExpectedErrors(result.stdout.toString(), cwd) - const stderr = result.stderr.toString() + report(result: ExecResult, cwd: string) { + const stdout = removeExpectedErrors(result.stdout.toString(), cwd); + const stderr = result.stderr.toString(); // tslint:disable-next-line:no-null-keyword return !stdout.length && !stderr.length ? null : `Exit Code: ${result.status} Standard output: @@ -83,29 +88,40 @@ ${stderr.replace(/\r\n/g, "\n")}`; } } -function filterExpectedErrors(errors: string, cwd: string): string { - return breaks(errors.split("\n"), s => /^\w+/.test(s)).filter(isExpectedError(cwd)).map(lines => lines.join("\n")).join("\n"); +function removeExpectedErrors(errors: string, cwd: string): string { + return ts.flatten(splitBy(errors.split("\n"), s => /^\S+/.test(s)).filter(isUnexpectedError(cwd))).join("\n"); } -function isExpectedError(cwd: string) { +/** + * Returns true if the line that caused the error contains '$ExpectError', + * or if the line before that one contains '$ExpectError'. + * '$ExpectError' is a marker used in Definitely Typed tests, + * meaning that the error should not contribute toward our error baslines. + */ +function isUnexpectedError(cwd: string) { return (error: string[]) => { - if (error.length === 0) { - return true; - } + ts.Debug.assertGreaterThanOrEqual(error.length, 1); const match = error[0].match(/(.+\.ts)\((\d+),\d+\): error TS/); if (!match) { return true; } - const errlines = fs.readFileSync(path.join(cwd, match[1]), { encoding: "utf8" }).split("\n"); - const index = parseInt(match[2]); - const errline = index < errlines.length ? errlines[index] : ""; - const prevline = index - 1 < errlines.length && index > 0 ? errlines[index - 1] : ""; - if (errline.indexOf("$ExpectError") > -1 || prevline.indexOf("$ExpectError") > -1) { - return false; - } - return true; - } + const [, errorFile, lineNumberString] = match; + const lines = fs.readFileSync(path.join(cwd, errorFile), { encoding: "utf8" }).split("\n"); + const lineNumber = parseInt(lineNumberString); + ts.Debug.assertGreaterThanOrEqual(lineNumber, 0); + ts.Debug.assertLessThan(lineNumber, lines.length); + const previousLine = lineNumber - 1 > 0 ? lines[lineNumber - 1] : ""; + return lines[lineNumber].indexOf("$ExpectError") === -1 && previousLine.indexOf("$ExpectError") === -1; + }; } -function breaks(xs: T[], isStart: (T: any) => boolean): T[][] { +/** + * Split an array into multiple arrays whenever `isStart` returns true. + * @example + * splitBy([1,2,3,4,5,6], isOdd) + * ==> [[1, 2], [3, 4], [5, 6]] + * where + * const isOdd = n => !!(n % 2) + */ +function splitBy(xs: T[], isStart: (x: T) => boolean): T[][] { const result = []; let group: T[] = []; for (const x of xs) { From 5fff71742b019be600b5bfe4c60e03afc73fe594 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 10:11:44 -0800 Subject: [PATCH 35/69] Use ts.stringContains instead of String.indexOf --- src/harness/externalCompileRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 5730c5c3c83..33803752f94 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -110,7 +110,7 @@ function isUnexpectedError(cwd: string) { ts.Debug.assertGreaterThanOrEqual(lineNumber, 0); ts.Debug.assertLessThan(lineNumber, lines.length); const previousLine = lineNumber - 1 > 0 ? lines[lineNumber - 1] : ""; - return lines[lineNumber].indexOf("$ExpectError") === -1 && previousLine.indexOf("$ExpectError") === -1; + return !ts.stringContains(lines[lineNumber], "$ExpectError") && !ts.stringContains(previousLine, "$ExpectError"); }; } /** From 06dd3f246f56c763d2df0eb8bcdccdb55cca869a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 10 Nov 2017 12:55:07 -0800 Subject: [PATCH 36/69] Fail fast on synthetic nodes in services (#19894) --- src/services/services.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/services/services.ts b/src/services/services.ts index 06358d3a720..95e23a708a3 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -62,39 +62,52 @@ namespace ts { this.kind = kind; } + private assertHasRealPosition(message?: string) { + // tslint:disable-next-line:debug-assert + Debug.assert(!positionIsSynthesized(this.pos) && !positionIsSynthesized(this.end), message || "Node must have a real position for this operation"); + } + public getSourceFile(): SourceFile { return getSourceFileOfNode(this); } public getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number { + this.assertHasRealPosition(); return getTokenPosOfNode(this, sourceFile, includeJsDocComment); } public getFullStart(): number { + this.assertHasRealPosition(); return this.pos; } public getEnd(): number { + this.assertHasRealPosition(); return this.end; } public getWidth(sourceFile?: SourceFile): number { + this.assertHasRealPosition(); return this.getEnd() - this.getStart(sourceFile); } public getFullWidth(): number { + this.assertHasRealPosition(); return this.end - this.pos; } public getLeadingTriviaWidth(sourceFile?: SourceFile): number { + this.assertHasRealPosition(); return this.getStart(sourceFile) - this.pos; } public getFullText(sourceFile?: SourceFile): string { + this.assertHasRealPosition(); return (sourceFile || this.getSourceFile()).text.substring(this.pos, this.end); } public getText(sourceFile?: SourceFile): string { + this.assertHasRealPosition(); if (!sourceFile) { sourceFile = this.getSourceFile(); } @@ -183,21 +196,25 @@ namespace ts { } public getChildCount(sourceFile?: SourceFile): number { + this.assertHasRealPosition(); if (!this._children) this.createChildren(sourceFile); return this._children.length; } public getChildAt(index: number, sourceFile?: SourceFile): Node { + this.assertHasRealPosition(); if (!this._children) this.createChildren(sourceFile); return this._children[index]; } public getChildren(sourceFile?: SourceFileLike): Node[] { + this.assertHasRealPosition("Node without a real position cannot be scanned and thus has no token nodes - use forEachChild and collect the result if that's fine"); if (!this._children) this.createChildren(sourceFile); return this._children; } public getFirstToken(sourceFile?: SourceFile): Node { + this.assertHasRealPosition(); const children = this.getChildren(sourceFile); if (!children.length) { return undefined; @@ -210,6 +227,7 @@ namespace ts { } public getLastToken(sourceFile?: SourceFile): Node { + this.assertHasRealPosition(); const children = this.getChildren(sourceFile); const child = lastOrUndefined(children); From 1579f2f7bf1d6b5d1716876ad3b2d41f4f4b9842 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 14 Jul 2017 16:26:37 -0700 Subject: [PATCH 37/69] Add 'scripthost' to 'lib' for the 'generate-spec' target. --- Jakefile.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index c2d0717641f..4f39d6af5c6 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -731,7 +731,10 @@ compileFile(word2mdJs, [word2mdTs], [word2mdTs], [], - /*useBuiltCompiler*/ false); + /*useBuiltCompiler*/ false, + { + lib: "scripthost,es5" + }); // The generated spec.md; built for the 'generate-spec' task file(specMd, [word2mdJs, specWord], function () { From 7d5f5fd5556339311b2bf41de9edb92d1a53585c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 10 Nov 2017 13:13:21 -0800 Subject: [PATCH 38/69] Make comparable relationship bidirectional for primitive types --- src/compiler/checker.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a9aaa77fa74..19cc2351e39 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8907,7 +8907,9 @@ namespace ts { if (target.flags & TypeFlags.StringOrNumberLiteral && target.flags & TypeFlags.FreshLiteral) { target = (target).regularType; } - if (source === target || relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { + if (source === target || + relation === comparableRelation && !(target.flags & TypeFlags.Never) && isSimpleTypeRelatedTo(target, source, relation) || + relation !== identityRelation && isSimpleTypeRelatedTo(source, target, relation)) { return true; } if (source.flags & TypeFlags.Object && target.flags & TypeFlags.Object) { @@ -9050,7 +9052,8 @@ namespace ts { return isIdenticalTo(source, target); } - if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True; + if (relation === comparableRelation && !(target.flags & TypeFlags.Never) && isSimpleTypeRelatedTo(target, source, relation) || + isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True; if (isObjectLiteralType(source) && source.flags & TypeFlags.FreshLiteral) { if (hasExcessProperties(source, target, reportErrors)) { From d15926d9c7bdef8efc4c671914777304695e316f Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 10 Nov 2017 13:13:32 -0800 Subject: [PATCH 39/69] Add test --- .../reference/independentPropertyVariance.js | 13 +++++++++++++ .../independentPropertyVariance.symbols | 17 +++++++++++++++++ .../independentPropertyVariance.types | 18 ++++++++++++++++++ .../comparable/independentPropertyVariance.ts | 8 ++++++++ 4 files changed, 56 insertions(+) create mode 100644 tests/baselines/reference/independentPropertyVariance.js create mode 100644 tests/baselines/reference/independentPropertyVariance.symbols create mode 100644 tests/baselines/reference/independentPropertyVariance.types create mode 100644 tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts diff --git a/tests/baselines/reference/independentPropertyVariance.js b/tests/baselines/reference/independentPropertyVariance.js new file mode 100644 index 00000000000..612877bd973 --- /dev/null +++ b/tests/baselines/reference/independentPropertyVariance.js @@ -0,0 +1,13 @@ +//// [independentPropertyVariance.ts] +// Verify that properties can vary idependently in comparable relationship + +declare const x: { a: 1, b: string }; +declare const y: { a: number, b: 'a' }; + +x === y; + + +//// [independentPropertyVariance.js] +"use strict"; +// Verify that properties can vary idependently in comparable relationship +x === y; diff --git a/tests/baselines/reference/independentPropertyVariance.symbols b/tests/baselines/reference/independentPropertyVariance.symbols new file mode 100644 index 00000000000..19c691e6348 --- /dev/null +++ b/tests/baselines/reference/independentPropertyVariance.symbols @@ -0,0 +1,17 @@ +=== tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts === +// Verify that properties can vary idependently in comparable relationship + +declare const x: { a: 1, b: string }; +>x : Symbol(x, Decl(independentPropertyVariance.ts, 2, 13)) +>a : Symbol(a, Decl(independentPropertyVariance.ts, 2, 18)) +>b : Symbol(b, Decl(independentPropertyVariance.ts, 2, 24)) + +declare const y: { a: number, b: 'a' }; +>y : Symbol(y, Decl(independentPropertyVariance.ts, 3, 13)) +>a : Symbol(a, Decl(independentPropertyVariance.ts, 3, 18)) +>b : Symbol(b, Decl(independentPropertyVariance.ts, 3, 29)) + +x === y; +>x : Symbol(x, Decl(independentPropertyVariance.ts, 2, 13)) +>y : Symbol(y, Decl(independentPropertyVariance.ts, 3, 13)) + diff --git a/tests/baselines/reference/independentPropertyVariance.types b/tests/baselines/reference/independentPropertyVariance.types new file mode 100644 index 00000000000..cb5261a2114 --- /dev/null +++ b/tests/baselines/reference/independentPropertyVariance.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts === +// Verify that properties can vary idependently in comparable relationship + +declare const x: { a: 1, b: string }; +>x : { a: 1; b: string; } +>a : 1 +>b : string + +declare const y: { a: number, b: 'a' }; +>y : { a: number; b: "a"; } +>a : number +>b : "a" + +x === y; +>x === y : boolean +>x : { a: 1; b: string; } +>y : { a: number; b: "a"; } + diff --git a/tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts b/tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts new file mode 100644 index 00000000000..9f71a0c656d --- /dev/null +++ b/tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts @@ -0,0 +1,8 @@ +// @strict: true + +// Verify that properties can vary idependently in comparable relationship + +declare const x: { a: 1, b: string }; +declare const y: { a: number, b: 'a' }; + +x === y; From 16b68ff25b538bb233a8e7f3dd8092c91bf9f3c5 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 10 Nov 2017 13:46:51 -0800 Subject: [PATCH 40/69] Fix typo --- tests/baselines/reference/independentPropertyVariance.js | 4 ++-- tests/baselines/reference/independentPropertyVariance.symbols | 2 +- tests/baselines/reference/independentPropertyVariance.types | 2 +- .../comparable/independentPropertyVariance.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/baselines/reference/independentPropertyVariance.js b/tests/baselines/reference/independentPropertyVariance.js index 612877bd973..2439d8140fa 100644 --- a/tests/baselines/reference/independentPropertyVariance.js +++ b/tests/baselines/reference/independentPropertyVariance.js @@ -1,5 +1,5 @@ //// [independentPropertyVariance.ts] -// Verify that properties can vary idependently in comparable relationship +// Verify that properties can vary independently in comparable relationship declare const x: { a: 1, b: string }; declare const y: { a: number, b: 'a' }; @@ -9,5 +9,5 @@ x === y; //// [independentPropertyVariance.js] "use strict"; -// Verify that properties can vary idependently in comparable relationship +// Verify that properties can vary independently in comparable relationship x === y; diff --git a/tests/baselines/reference/independentPropertyVariance.symbols b/tests/baselines/reference/independentPropertyVariance.symbols index 19c691e6348..cf503476008 100644 --- a/tests/baselines/reference/independentPropertyVariance.symbols +++ b/tests/baselines/reference/independentPropertyVariance.symbols @@ -1,5 +1,5 @@ === tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts === -// Verify that properties can vary idependently in comparable relationship +// Verify that properties can vary independently in comparable relationship declare const x: { a: 1, b: string }; >x : Symbol(x, Decl(independentPropertyVariance.ts, 2, 13)) diff --git a/tests/baselines/reference/independentPropertyVariance.types b/tests/baselines/reference/independentPropertyVariance.types index cb5261a2114..d2808166e01 100644 --- a/tests/baselines/reference/independentPropertyVariance.types +++ b/tests/baselines/reference/independentPropertyVariance.types @@ -1,5 +1,5 @@ === tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts === -// Verify that properties can vary idependently in comparable relationship +// Verify that properties can vary independently in comparable relationship declare const x: { a: 1, b: string }; >x : { a: 1; b: string; } diff --git a/tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts b/tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts index 9f71a0c656d..cec30104c49 100644 --- a/tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts +++ b/tests/cases/conformance/types/typeRelationships/comparable/independentPropertyVariance.ts @@ -1,6 +1,6 @@ // @strict: true -// Verify that properties can vary idependently in comparable relationship +// Verify that properties can vary independently in comparable relationship declare const x: { a: 1, b: string }; declare const y: { a: number, b: 'a' }; From d66e94d09e6e66574b06a8fe01d1db63eb7b6a74 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 13:50:18 -0800 Subject: [PATCH 41/69] ExternalCompileRunner works with submodules If there is a test.json in the directory, it expects to find a submodule in the directory. The submodule should have the same name as the directory itself. test.json contains a list of global types that need to be available, or the empty list if none. --- .gitmodules | 6 +++++ src/harness/externalCompileRunner.ts | 26 ++++++++++++++++--- .../TypeScript-Node-Starter | 1 + .../TypeScript-React-Starter | 1 + 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 .gitmodules create mode 160000 tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter create mode 160000 tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..1a1c6e193fd --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter"] + path = tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter + url = https://github.com/Microsoft/TypeScript-React-Starter +[submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"] + path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter + url = https://github.com/Microsoft/TypeScript-Node-Starter.git diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 33803752f94..0f9386ddb0f 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -9,6 +9,10 @@ interface ExecResult { status: number; } +interface UserConfig { + types: string[]; +} + abstract class ExternalCompileRunnerBase extends RunnerBase { abstract testDir: string; abstract report(result: ExecResult, cwd: string): string; @@ -33,18 +37,34 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { const cp = require("child_process"); it("should build successfully", () => { - const cwd = path.join(__dirname, "../../", this.testDir, directoryName); + let cwd = path.join(__dirname, "../../", this.testDir, directoryName); const timeout = 600000; // 600s = 10 minutes + const stdio = isWorker ? "pipe" : "inherit"; + let types: string[]; + if (fs.existsSync(path.join(cwd, "test.json"))) { + const update = cp.spawnSync('git', ["submodule", "update", "--remote"], { cwd, timeout, shell: true, stdio }) + if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed!`); + + const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig; + ts.Debug.assert(!!config.types, "Git is the only reason for using test.json right now"); + types = config.types; + + cwd = path.join(cwd, directoryName); + } if (fs.existsSync(path.join(cwd, "package.json"))) { if (fs.existsSync(path.join(cwd, "package-lock.json"))) { fs.unlinkSync(path.join(cwd, "package-lock.json")); } - const stdio = isWorker ? "pipe" : "inherit"; const install = cp.spawnSync(`npm`, ["i"], { cwd, timeout, shell: true, stdio }); if (install.status !== 0) throw new Error(`NPM Install for ${directoryName} failed!`); } + const args = [path.join(__dirname, "tsc.js")]; + if (types) { + args.push("--types", types.join(",")); + } + args.push("--noEmit"); Harness.Baseline.runBaseline(`${this.kind()}/${directoryName}.log`, () => { - return this.report(cp.spawnSync(`node`, [path.join(__dirname, "tsc.js")], { cwd, timeout, shell: true }), cwd); + return this.report(cp.spawnSync(`node`, args, { cwd, timeout, shell: true }), cwd); }); }); }); diff --git a/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter new file mode 160000 index 00000000000..ed149eb0c78 --- /dev/null +++ b/tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter @@ -0,0 +1 @@ +Subproject commit ed149eb0c787b1195a95b44105822c64bb6eb636 diff --git a/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter b/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter new file mode 160000 index 00000000000..96fb6237a9d --- /dev/null +++ b/tests/cases/user/TypeScript-React-Starter/TypeScript-React-Starter @@ -0,0 +1 @@ +Subproject commit 96fb6237a9dda8d17059eea7fa7c22dd7db82c97 From c82c6f21cb0305ec1dc18a6118895444b05489d1 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 10 Nov 2017 14:03:41 -0800 Subject: [PATCH 42/69] Ensure that enum member value is computed before using it Fixes #19898 --- src/compiler/checker.ts | 2 +- src/harness/unittests/tscWatchMode.ts | 30 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a9aaa77fa74..664d93d57ed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -22412,7 +22412,7 @@ namespace ts { const declaration = memberSymbol.valueDeclaration; if (declaration !== member) { if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) { - return getNodeLinks(declaration).enumMemberValue; + return getEnumMemberValue(declaration as EnumMember); } error(expr, Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums); return 0; diff --git a/src/harness/unittests/tscWatchMode.ts b/src/harness/unittests/tscWatchMode.ts index fc80a6f39ef..4e2d63cec90 100644 --- a/src/harness/unittests/tscWatchMode.ts +++ b/src/harness/unittests/tscWatchMode.ts @@ -1616,6 +1616,36 @@ namespace ts.tscWatch { return files.slice(0, 2); } }); + + it("Elides const enums correctly in incremental compilation", () => { + const currentDirectory = "/user/someone/projects/myproject"; + const file1: FileOrFolder = { + path: `${currentDirectory}/file1.ts`, + content: "export const enum E1 { V = 1 }" + }; + const file2: FileOrFolder = { + path: `${currentDirectory}/file2.ts`, + content: `import { E1 } from "./file1"; export const enum E2 { V = E1.V }` + }; + const file3: FileOrFolder = { + path: `${currentDirectory}/file3.ts`, + content: `import { E2 } from "./file2"; const v: E2 = E2.V;` + }; + const strictAndEsModule = `"use strict";\nexports.__esModule = true;\n`; + verifyEmittedFileContents("\n", [file3, file2, file1], [ + `${strictAndEsModule}var v = 1 /* V */;\n`, + strictAndEsModule, + strictAndEsModule + ], modifyFiles); + + function modifyFiles(files: FileOrFolderEmit[], emittedFiles: EmittedFile[]) { + files[0].content += `function foo2() { return 2; }`; + emittedFiles[0].content += `function foo2() { return 2; }\n`; + emittedFiles[1].shouldBeWritten = false; + emittedFiles[2].shouldBeWritten = false; + return [files[0]]; + } + }); }); describe("tsc-watch module resolution caching", () => { From d4c001d47c90d14a1ca020d2877babf58fffeb90 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 14:20:55 -0800 Subject: [PATCH 43/69] Add test w/submodules for our starter kits --- .gitmodules | 9 +++++++++ tests/cases/user/TypeScript-Node-Starter/test.json | 3 +++ .../TypeScript-React-Native-Starter | 1 + .../cases/user/TypeScript-React-Native-Starter/test.json | 3 +++ tests/cases/user/TypeScript-React-Starter/test.json | 3 +++ .../user/TypeScript-Vue-Starter/TypeScript-Vue-Starter | 1 + tests/cases/user/TypeScript-Vue-Starter/test.json | 3 +++ .../TypeScript-WeChat-Starter/TypeScript-WeChat-Starter | 1 + tests/cases/user/TypeScript-WeChat-Starter/test.json | 3 +++ 9 files changed, 27 insertions(+) create mode 100644 tests/cases/user/TypeScript-Node-Starter/test.json create mode 160000 tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter create mode 100644 tests/cases/user/TypeScript-React-Native-Starter/test.json create mode 100644 tests/cases/user/TypeScript-React-Starter/test.json create mode 160000 tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter create mode 100644 tests/cases/user/TypeScript-Vue-Starter/test.json create mode 160000 tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter create mode 100644 tests/cases/user/TypeScript-WeChat-Starter/test.json diff --git a/.gitmodules b/.gitmodules index 1a1c6e193fd..f83d0f77c9e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,12 @@ [submodule "tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter"] path = tests/cases/user/TypeScript-Node-Starter/TypeScript-Node-Starter url = https://github.com/Microsoft/TypeScript-Node-Starter.git +[submodule "tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter"] + path = tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter + url = https://github.com/Microsoft/TypeScript-React-Native-Starter.git +[submodule "tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter"] + path = tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter + url = https://github.com/Microsoft/TypeScript-Vue-Starter.git +[submodule "tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter"] + path = tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter + url = https://github.com/Microsoft/TypeScript-WeChat-Starter.git diff --git a/tests/cases/user/TypeScript-Node-Starter/test.json b/tests/cases/user/TypeScript-Node-Starter/test.json new file mode 100644 index 00000000000..11d2aa87c59 --- /dev/null +++ b/tests/cases/user/TypeScript-Node-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": ["jquery"] +} diff --git a/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter b/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter new file mode 160000 index 00000000000..2c62f5a4ea5 --- /dev/null +++ b/tests/cases/user/TypeScript-React-Native-Starter/TypeScript-React-Native-Starter @@ -0,0 +1 @@ +Subproject commit 2c62f5a4ea51978e3715b475e17962cdeca75e38 diff --git a/tests/cases/user/TypeScript-React-Native-Starter/test.json b/tests/cases/user/TypeScript-React-Native-Starter/test.json new file mode 100644 index 00000000000..8b177c575aa --- /dev/null +++ b/tests/cases/user/TypeScript-React-Native-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": ["jest"] +} diff --git a/tests/cases/user/TypeScript-React-Starter/test.json b/tests/cases/user/TypeScript-React-Starter/test.json new file mode 100644 index 00000000000..8b177c575aa --- /dev/null +++ b/tests/cases/user/TypeScript-React-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": ["jest"] +} diff --git a/tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter b/tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter new file mode 160000 index 00000000000..713c6986f04 --- /dev/null +++ b/tests/cases/user/TypeScript-Vue-Starter/TypeScript-Vue-Starter @@ -0,0 +1 @@ +Subproject commit 713c6986f043f2c31976b8bc2c03aa0a2b05590b diff --git a/tests/cases/user/TypeScript-Vue-Starter/test.json b/tests/cases/user/TypeScript-Vue-Starter/test.json new file mode 100644 index 00000000000..e0d4d26bdca --- /dev/null +++ b/tests/cases/user/TypeScript-Vue-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": [] +} diff --git a/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter b/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter new file mode 160000 index 00000000000..5fca1032eda --- /dev/null +++ b/tests/cases/user/TypeScript-WeChat-Starter/TypeScript-WeChat-Starter @@ -0,0 +1 @@ +Subproject commit 5fca1032edaab5414ec1c167f42d3dc59220d9aa diff --git a/tests/cases/user/TypeScript-WeChat-Starter/test.json b/tests/cases/user/TypeScript-WeChat-Starter/test.json new file mode 100644 index 00000000000..e0d4d26bdca --- /dev/null +++ b/tests/cases/user/TypeScript-WeChat-Starter/test.json @@ -0,0 +1,3 @@ +{ + "types": [] +} From 0d63589fb2da23c0a243a8fd47cb0c96df6deac7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 14:21:53 -0800 Subject: [PATCH 44/69] Fix quote lint --- src/harness/externalCompileRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 0f9386ddb0f..75ccecb047d 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -42,7 +42,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { const stdio = isWorker ? "pipe" : "inherit"; let types: string[]; if (fs.existsSync(path.join(cwd, "test.json"))) { - const update = cp.spawnSync('git', ["submodule", "update", "--remote"], { cwd, timeout, shell: true, stdio }) + const update = cp.spawnSync("git", ["submodule", "update", "--remote"], { cwd, timeout, shell: true, stdio }); if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed!`); const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig; From ba232b2164e7d0789bdc668e6b750696f8f7a8e2 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 14:36:49 -0800 Subject: [PATCH 45/69] Update baselines --- tests/baselines/reference/user/electron.log | 2 +- tests/baselines/reference/user/leveldown.log | 2 +- tests/baselines/reference/user/rxjs.log | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/baselines/reference/user/electron.log b/tests/baselines/reference/user/electron.log index e5eef689d49..7ba43481c3b 100644 --- a/tests/baselines/reference/user/electron.log +++ b/tests/baselines/reference/user/electron.log @@ -1,4 +1,4 @@ -Exit Code: 2 +Exit Code: 1 Standard output: node_modules/electron/electron.d.ts(5390,13): error TS2430: Interface 'WebviewTag' incorrectly extends interface 'HTMLElement'. Types of property 'addEventListener' are incompatible. diff --git a/tests/baselines/reference/user/leveldown.log b/tests/baselines/reference/user/leveldown.log index c37a983f73d..011071ebc52 100644 --- a/tests/baselines/reference/user/leveldown.log +++ b/tests/baselines/reference/user/leveldown.log @@ -1,4 +1,4 @@ -Exit Code: 2 +Exit Code: 1 Standard output: node_modules/abstract-leveldown/index.d.ts(2,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type. node_modules/abstract-leveldown/index.d.ts(3,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type. diff --git a/tests/baselines/reference/user/rxjs.log b/tests/baselines/reference/user/rxjs.log index 73058119ce9..c17014c5c13 100644 --- a/tests/baselines/reference/user/rxjs.log +++ b/tests/baselines/reference/user/rxjs.log @@ -1,4 +1,4 @@ -Exit Code: 2 +Exit Code: 1 Standard output: node_modules/rxjs/scheduler/VirtualTimeScheduler.d.ts(22,22): error TS2415: Class 'VirtualAction' incorrectly extends base class 'AsyncAction'. Types of property 'work' are incompatible. From 19b26c564cf18a3a76d00204d8fa92979f20e1f9 Mon Sep 17 00:00:00 2001 From: csigs Date: Fri, 10 Nov 2017 23:10:42 +0000 Subject: [PATCH 46/69] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- .../diagnosticMessages.generated.json.lcl | 142 +++++++--------- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- 6 files changed, 444 insertions(+), 498 deletions(-) diff --git a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2bf61430d60..803d5940ac2 100644 --- a/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/fra/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1620,12 +1620,9 @@ - + - - - - + @@ -3735,6 +3732,24 @@ + + + + + + + + + + + + + + + + + + @@ -3966,6 +3981,15 @@ + + + + + + + + + @@ -5211,24 +5235,6 @@ - - - - - - - - - - - - - - - - - - @@ -5256,24 +5262,6 @@ - - - - - - - - - - - - - - - - - - @@ -5292,6 +5280,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5997,6 +6009,24 @@ + + + + + + + + + + + + + + + + + + @@ -6024,30 +6054,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6078,33 +6099,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 31f3bfdefd5..2e603f114b6 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1611,12 +1611,9 @@ - + - - - - + @@ -3726,6 +3723,24 @@ + + + + + + + + + + + + + + + + + + @@ -3957,6 +3972,15 @@ + + + + + + + + + @@ -5202,24 +5226,6 @@ - - - - - - - - - - - - - - - - - - @@ -5247,24 +5253,6 @@ - - - - - - - - - - - - - - - - - - @@ -5283,6 +5271,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5988,6 +6000,24 @@ + + + + + + + + + + + + + + + + + + @@ -6015,30 +6045,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6069,33 +6090,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl index b9d115872b6..0badf531a75 100644 --- a/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/plk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1598,12 +1598,9 @@ - + - - - - + @@ -3707,6 +3704,24 @@ + + + + + + + + + + + + + + + + + + @@ -3938,6 +3953,15 @@ + + + + + + + + + @@ -5183,24 +5207,6 @@ - - - - - - - - - - - - - - - - - - @@ -5228,24 +5234,6 @@ - - - - - - - - - - - - - - - - - - @@ -5264,6 +5252,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5963,6 +5975,24 @@ + + + + + + + + + + + + + + + + + + @@ -5990,30 +6020,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6044,33 +6065,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 1e480ff2a08..7677920dd1d 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1598,12 +1598,9 @@ - + - - - - + @@ -3707,6 +3704,24 @@ + + + + + + + + + + + + + + + + + + @@ -3938,6 +3953,15 @@ + + + + + + + + + @@ -5183,24 +5207,6 @@ - - - - - - - - - - - - - - - - - - @@ -5228,24 +5234,6 @@ - - - - - - - - - - - - - - - - - - @@ -5264,6 +5252,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5963,6 +5975,24 @@ + + + + + + + + + + + + + + + + + + @@ -5990,30 +6020,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6044,33 +6065,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl index bd78324f196..b71915fbd67 100644 --- a/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/rus/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1610,12 +1610,9 @@ - + - - - - + @@ -3728,12 +3725,18 @@ + + + + + + @@ -3971,6 +3974,9 @@ + + + @@ -5219,24 +5225,6 @@ - - - - - - - - - - - - - - - - - - @@ -5264,24 +5252,6 @@ - - - - - - - - - - - - - - - - - - @@ -5300,6 +5270,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -6005,6 +5999,24 @@ + + + + + + + + + + + + + + + + + + @@ -6032,30 +6044,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6086,33 +6089,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl index 0eafa4da0b2..6c92a1c0bd1 100644 --- a/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/trk/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1604,12 +1604,9 @@ - + - - - - + @@ -3719,6 +3716,24 @@ + + + + + + + + + + + + + + + + + + @@ -3950,6 +3965,15 @@ + + + + + + + + + @@ -5195,24 +5219,6 @@ - - - - - - - - - - - - - - - - - - @@ -5240,24 +5246,6 @@ - - - - - - - - - - - - - - - - - - @@ -5276,6 +5264,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5981,6 +5993,24 @@ + + + + + + + + + + + + + + + + + + @@ -6008,30 +6038,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6062,33 +6083,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - From 4d0139084596a18a2ba0af583bd2cc3bad164aab Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Nov 2017 15:55:29 -0800 Subject: [PATCH 47/69] Improve assert message --- src/harness/externalCompileRunner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/externalCompileRunner.ts b/src/harness/externalCompileRunner.ts index 75ccecb047d..2a44badd813 100644 --- a/src/harness/externalCompileRunner.ts +++ b/src/harness/externalCompileRunner.ts @@ -46,7 +46,7 @@ abstract class ExternalCompileRunnerBase extends RunnerBase { if (update.status !== 0) throw new Error(`git submodule update for ${directoryName} failed!`); const config = JSON.parse(fs.readFileSync(path.join(cwd, "test.json"), { encoding: "utf8" })) as UserConfig; - ts.Debug.assert(!!config.types, "Git is the only reason for using test.json right now"); + ts.Debug.assert(!!config.types, "Bad format from test.json: Types field must be present."); types = config.types; cwd = path.join(cwd, directoryName); From 59fca7fc30bfbcdde8d5b3e544bdf09da5fa9e9a Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 10 Nov 2017 16:26:16 -0800 Subject: [PATCH 48/69] Fix crash when running tsc with -diagnostics --- src/compiler/performance.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index 225b34de9cf..104148ed4ab 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -10,7 +10,8 @@ namespace ts { namespace ts.performance { declare const onProfilerEvent: { (markName: string): void; profiler: boolean; }; - const profilerEvent: (markName: string) => void = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent : noop; + // NOTE: cannot use ts.noop as core.ts loads after this + const profilerEvent: (markName: string) => void = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true ? onProfilerEvent : () => { /*empty*/ }; let enabled = false; let profilerStart = 0; From cba2e966a37f843150809659e0f762985f988bcd Mon Sep 17 00:00:00 2001 From: csigs Date: Sat, 11 Nov 2017 05:10:06 +0000 Subject: [PATCH 49/69] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- 1 file changed, 77 insertions(+), 83 deletions(-) diff --git a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl index c00e5a2a2e7..d362101e51f 100644 --- a/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/deu/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1605,12 +1605,9 @@ - + - - - - + @@ -3714,6 +3711,24 @@ + + + + + + + + + + + + + + + + + + @@ -3945,6 +3960,15 @@ + + + + + + + + + @@ -5190,24 +5214,6 @@ - - - - - - - - - - - - - - - - - - @@ -5235,24 +5241,6 @@ - - - - - - - - - - - - - - - - - - @@ -5271,6 +5259,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5970,6 +5982,24 @@ + + + + + + + + + + + + + + + + + + @@ -5997,30 +6027,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6051,33 +6072,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - From 74fe5c5b74983a2b152b4fe3e23b2e450431128b Mon Sep 17 00:00:00 2001 From: csigs Date: Mon, 13 Nov 2017 17:10:16 +0000 Subject: [PATCH 50/69] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- .../diagnosticMessages.generated.json.lcl | 160 +++++++++--------- 2 files changed, 154 insertions(+), 166 deletions(-) diff --git a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl index 929b7edf058..a55da48f2c2 100644 --- a/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/cht/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1611,12 +1611,9 @@ - + - - - - + @@ -3726,6 +3723,24 @@ + + + + + + + + + + + + + + + + + + @@ -3957,6 +3972,15 @@ + + + + + + + + + @@ -5202,24 +5226,6 @@ - - - - - - - - - - - - - - - - - - @@ -5247,24 +5253,6 @@ - - - - - - - - - - - - - - - - - - @@ -5283,6 +5271,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5988,6 +6000,24 @@ + + + + + + + + + + + + + + + + + + @@ -6015,30 +6045,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6069,33 +6090,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl index 4865cf6c508..58a00519e04 100644 --- a/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/esn/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1620,12 +1620,9 @@ - + - - - - + @@ -3735,6 +3732,24 @@ + + + + + + + + + + + + + + + + + + @@ -3966,6 +3981,15 @@ + + + + + + + + + @@ -5211,24 +5235,6 @@ - - - - - - - - - - - - - - - - - - @@ -5256,24 +5262,6 @@ - - - - - - - - - - - - - - - - - - @@ -5292,6 +5280,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -5997,6 +6009,24 @@ + + + + + + + + + + + + + + + + + + @@ -6024,30 +6054,21 @@ - + - - - - + - + - - - - + - + - - - - + @@ -6078,33 +6099,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - From e7df83263df9433d2b27a2b86e9d198fca68bd92 Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 13 Nov 2017 09:18:36 -0800 Subject: [PATCH 51/69] Break out of speculative parsing on bad parameter initializer (#19158) * Break out of speculative parsing on bad parameter initializer * Remove uses of 'finally' * give up -> stop * Do without exceptions * Remove `resetAfterSpeculation` * Use Fail and FailList objects * Remove `inSpeculation` parameter to parseDelimitedList * Don't use `createNodeArray`, it's not always in scope * Move Fail and FailList inside initializeState * More code review * More code review --- src/compiler/parser.ts | 180 +++++++++++++----- .../parserArrowFunctionExpression7.js | 16 ++ .../parserArrowFunctionExpression7.symbols | 10 + .../parserArrowFunctionExpression7.types | 13 ++ .../parserArrowFunctionExpression7.ts | 7 + 5 files changed, 176 insertions(+), 50 deletions(-) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.js create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.symbols create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.types create mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 79b5eb30c49..64cd8219a01 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -531,6 +531,18 @@ namespace ts { let TokenConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; let IdentifierConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; + interface Fail extends Node { kind: SyntaxKind.Unknown; } + interface FailList extends NodeArray { pos: -1; } + let Fail: Fail; + let FailList: FailList; + function isFail(x: Node | undefined): x is Fail { + Debug.assert(Fail !== undefined); + return x === Fail; + } + function isFailList(x: NodeArray | undefined): x is FailList { + Debug.assert(Fail !== undefined); + return x === FailList; + } // tslint:enable variable-name let sourceFile: SourceFile; @@ -681,6 +693,9 @@ namespace ts { IdentifierConstructor = objectAllocator.getIdentifierConstructor(); SourceFileConstructor = objectAllocator.getSourceFileConstructor(); + Fail = createNode(SyntaxKind.Unknown) as Fail; + FailList = createNodeArray([], -1) as FailList; + sourceText = _sourceText; syntaxCursor = _syntaxCursor; @@ -736,7 +751,7 @@ namespace ts { processReferenceComments(sourceFile); sourceFile.statements = parseList(ParsingContext.SourceElements, parseStatement); - Debug.assert(token() === SyntaxKind.EndOfFileToken); + Debug.assertEqual(token(), SyntaxKind.EndOfFileToken); sourceFile.endOfFileToken = addJSDocComment(parseTokenNode() as EndOfFileToken); setExternalModuleIndicator(sourceFile); @@ -1003,7 +1018,7 @@ namespace ts { return currentToken = scanner.scanJsxAttributeValue(); } - function speculationHelper(callback: () => T, isLookAhead: boolean): T { + function speculationHelper(callback: () => T, isLookAhead: boolean): T | undefined { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). const saveToken = currentToken; @@ -1015,6 +1030,7 @@ namespace ts { // descent nature of our parser. However, we still store this here just so we can // assert that invariant holds. const saveContextFlags = contextFlags; + const saveParsingContext = parsingContext; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the @@ -1023,7 +1039,8 @@ namespace ts { ? scanner.lookAhead(callback) : scanner.tryScan(callback); - Debug.assert(saveContextFlags === contextFlags); + Debug.assertEqual(saveContextFlags, contextFlags); + Debug.assertEqual(saveParsingContext, parsingContext); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. @@ -1577,7 +1594,7 @@ namespace ts { return createNodeArray(list, listPos); } - function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { + function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { const node = currentNode(parsingContext); if (node) { return consumeNode(node); @@ -1901,17 +1918,24 @@ namespace ts { } // Parses a comma-delimited list of elements - function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray { + function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray; + function parseDelimitedList(kind: ParsingContext, parseElement: () => T | Fail, considerSemicolonAsDelimiter?: boolean): NodeArray | FailList; + function parseDelimitedList(kind: ParsingContext, parseElement: () => T | Fail, considerSemicolonAsDelimiter?: boolean): NodeArray | FailList { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - const list = []; + const list: T[] = []; const listPos = getNodePos(); let commaStart = -1; // Meaning the previous token was not a comma while (true) { if (isListElement(kind, /*inErrorRecovery*/ false)) { const startPos = scanner.getStartPos(); - list.push(parseListElement(kind, parseElement)); + const elem = parseListElement(kind, parseElement); + if (isFail(elem)) { + parsingContext = saveParsingContext; + return FailList; + } + list.push(elem); commaStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.CommaToken)) { @@ -2271,7 +2295,13 @@ namespace ts { isStartOfType(/*inStartOfParameter*/ true); } - function parseParameter(requireEqualsToken?: boolean): ParameterDeclaration { + function tryParseParameter(): ParameterDeclaration | Fail { + return parseParameterWorker(/*inSpeculation*/ true); + } + function parseParameter(): ParameterDeclaration { + return parseParameterWorker(/*inSpeculation*/ false) as ParameterDeclaration; + } + function parseParameterWorker(inSpeculation: boolean): ParameterDeclaration | Fail { const node = createNode(SyntaxKind.Parameter); if (token() === SyntaxKind.ThisKeyword) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -2285,7 +2315,11 @@ namespace ts { // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] - node.name = parseIdentifierOrPattern(); + const name = parseIdentifierOrPattern(inSpeculation); + if (isFail(name)) { + return Fail; + } + node.name = name; if (getFullWidth(node.name) === 0 && !hasModifiers(node) && isModifierKind(token())) { // in cases like // 'use strict' @@ -2300,20 +2334,27 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); + const initializer = parseInitializer(/*inParameter*/ true, inSpeculation); + if (isFail(initializer)) { + return Fail; + } + node.initializer = initializer; return addJSDocComment(finishNode(node)); } - function fillSignature( - returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, - flags: SignatureFlags, - signature: SignatureDeclaration): void { + /** @return 'true' on success. */ + function fillSignature(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, flags: SignatureFlags, signature: SignatureDeclaration, inSpeculation?: boolean): boolean { if (!(flags & SignatureFlags.JSDoc)) { signature.typeParameters = parseTypeParameters(); } - signature.parameters = parseParameterList(flags); + const parameters = parseParameterList(flags, inSpeculation); + if (isFailList(parameters)) { + return false; + } + signature.parameters = parameters; signature.type = parseReturnType(returnToken, !!(flags & SignatureFlags.Type)); + return true; } function parseReturnType(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, isType: boolean): TypeNode | undefined { @@ -2336,7 +2377,7 @@ namespace ts { return false; } - function parseParameterList(flags: SignatureFlags) { + function parseParameterList(flags: SignatureFlags, inSpeculation: boolean): NodeArray | FailList { // FormalParameters [Yield,Await]: (modified) // [empty] // FormalParameterList[?Yield,Await] @@ -2357,9 +2398,9 @@ namespace ts { setYieldContext(!!(flags & SignatureFlags.Yield)); setAwaitContext(!!(flags & SignatureFlags.Await)); - const result = parseDelimitedList(ParsingContext.Parameters, - flags & SignatureFlags.JSDoc ? parseJSDocParameter : () => parseParameter(!!(flags & SignatureFlags.RequireCompleteParameterList))); - + const result = parseDelimitedList( + ParsingContext.Parameters, + flags & SignatureFlags.JSDoc ? parseJSDocParameter : inSpeculation ? tryParseParameter : parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -3032,14 +3073,16 @@ namespace ts { while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } - if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } + return expr; } - function parseInitializer(inParameter: boolean, requireEqualsToken?: boolean): Expression { + function parseInitializer(inParameter: boolean): Expression | undefined; + function parseInitializer(inParameter: boolean, inSpeculation?: boolean): Expression | Fail | undefined; + function parseInitializer(inParameter: boolean, inSpeculation?: boolean): Expression | Fail | undefined { if (token() !== SyntaxKind.EqualsToken) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse @@ -3054,12 +3097,8 @@ namespace ts { // do not try to parse initializer return undefined; } - if (inParameter && requireEqualsToken) { - // = is required when speculatively parsing arrow function parameters, - // so return a fake initializer as a signal that the equals token was missing - const result = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics._0_expected, "=") as Identifier; - result.escapedText = "= not found" as __String; - return result; + if (inSpeculation) { + return Fail; } } @@ -3225,7 +3264,7 @@ namespace ts { // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. const arrowFunction = triState === Tristate.True - ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) + ? parseParenthesizedArrowFunctionExpressionHead(/*inSpeculation*/ false) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { @@ -3373,7 +3412,7 @@ namespace ts { } function parsePossibleParenthesizedArrowFunctionExpressionHead(): ArrowFunction { - return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); + return parseParenthesizedArrowFunctionExpressionHead(/*inSpeculation*/ true); } function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction | undefined { @@ -3409,7 +3448,7 @@ namespace ts { return Tristate.False; } - function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { + function parseParenthesizedArrowFunctionExpressionHead(inSpeculation: boolean): ArrowFunction | undefined { const node = createNode(SyntaxKind.ArrowFunction); node.modifiers = parseModifiersForArrowFunction(); const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; @@ -3420,7 +3459,10 @@ namespace ts { // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(SyntaxKind.ColonToken, isAsync | (allowAmbiguity ? SignatureFlags.None : SignatureFlags.RequireCompleteParameterList), node); + + if (!fillSignature(SyntaxKind.ColonToken, isAsync | (inSpeculation ? SignatureFlags.RequireCompleteParameterList : SignatureFlags.None), node, inSpeculation)) { + return undefined; + } // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { @@ -3435,8 +3477,7 @@ namespace ts { // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && ((token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) || - find(node.parameters, p => p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"))) { + if (inSpeculation && token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -4574,7 +4615,6 @@ namespace ts { if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - const node = createNode(SyntaxKind.FunctionExpression); node.modifiers = parseModifiers(); parseExpected(SyntaxKind.FunctionKeyword); @@ -4590,7 +4630,6 @@ namespace ts { fillSignature(SyntaxKind.ColonToken, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); - if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -4653,7 +4692,6 @@ namespace ts { } const block = parseBlock(!!(flags & SignatureFlags.IgnoreMissingOpenBrace), diagnosticMessage); - if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -5227,18 +5265,38 @@ namespace ts { // DECLARATIONS + function tryParseArrayBindingElement(): ArrayBindingElement | Fail { + return parseArrayBindingElementWorker(/*inSpeculation*/ true); + } function parseArrayBindingElement(): ArrayBindingElement { + return parseArrayBindingElementWorker(/*inSpeculation*/ false) as ArrayBindingElement; + } + function parseArrayBindingElementWorker(inSpeculation: boolean): ArrayBindingElement | Fail { if (token() === SyntaxKind.CommaToken) { return createNode(SyntaxKind.OmittedExpression); } const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(/*inParameter*/ false); + const name = parseIdentifierOrPattern(inSpeculation); + if (isFail(name)) { + return Fail; + } + node.name = name; + const init = parseInitializer(/*inParameter*/ false, inSpeculation); + if (isFail(init)) { + return Fail; + } + node.initializer = init; return finishNode(node); } + function tryParseObjectBindingElement(): BindingElement | Fail { + return parseObjectBindingElementWorker(/*inSpeculation*/ true); + } function parseObjectBindingElement(): BindingElement { + return parseObjectBindingElementWorker(/*inSpeculation*/ false) as BindingElement; + } + function parseObjectBindingElementWorker(inSpeculation: boolean): BindingElement | Fail { const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); const tokenIsIdentifier = isIdentifier(); @@ -5249,24 +5307,46 @@ namespace ts { else { parseExpected(SyntaxKind.ColonToken); node.propertyName = propertyName; - node.name = parseIdentifierOrPattern(); + const name = parseIdentifierOrPattern(inSpeculation); + if (isFail(name)) { + return Fail; + } + node.name = name; } - node.initializer = parseInitializer(/*inParameter*/ false); + const init = parseInitializer(/*inParameter*/ false, inSpeculation); + if (isFail(init)) { + return Fail; + } + node.initializer = init; return finishNode(node); } - function parseObjectBindingPattern(): ObjectBindingPattern { + function parseObjectBindingPattern(inSpeculation: boolean): ObjectBindingPattern | Fail { const node = createNode(SyntaxKind.ObjectBindingPattern); parseExpected(SyntaxKind.OpenBraceToken); - node.elements = parseDelimitedList(ParsingContext.ObjectBindingElements, parseObjectBindingElement); + const elements = parseDelimitedList( + ParsingContext.ObjectBindingElements, + inSpeculation ? tryParseObjectBindingElement : parseObjectBindingElement, + /*considerSemicolonAsDelimiter*/ undefined); + if (isFailList(elements)) { + return Fail; + } + node.elements = elements; parseExpected(SyntaxKind.CloseBraceToken); return finishNode(node); } - function parseArrayBindingPattern(): ArrayBindingPattern { + function parseArrayBindingPattern(inSpeculation: boolean): ArrayBindingPattern | Fail { const node = createNode(SyntaxKind.ArrayBindingPattern); parseExpected(SyntaxKind.OpenBracketToken); - node.elements = parseDelimitedList(ParsingContext.ArrayBindingElements, parseArrayBindingElement); + const elements = parseDelimitedList( + ParsingContext.ArrayBindingElements, + inSpeculation ? tryParseArrayBindingElement : parseArrayBindingElement, + /*considerSemicolonAsDelimiter*/ undefined); + if (isFailList(elements)) { + return Fail; + } + node.elements = elements; parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); } @@ -5275,12 +5355,14 @@ namespace ts { return token() === SyntaxKind.OpenBraceToken || token() === SyntaxKind.OpenBracketToken || isIdentifier(); } - function parseIdentifierOrPattern(): Identifier | BindingPattern { + function parseIdentifierOrPattern(): Identifier | BindingPattern; + function parseIdentifierOrPattern(inSpeculation: boolean): Identifier | BindingPattern | Fail; + function parseIdentifierOrPattern(inSpeculation?: boolean): Identifier | BindingPattern | Fail { if (token() === SyntaxKind.OpenBracketToken) { - return parseArrayBindingPattern(); + return parseArrayBindingPattern(inSpeculation); } if (token() === SyntaxKind.OpenBraceToken) { - return parseObjectBindingPattern(); + return parseObjectBindingPattern(inSpeculation); } return parseIdentifier(); } @@ -5328,9 +5410,7 @@ namespace ts { else { const savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); - node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration); - setDisallowInContext(savedDisallowIn); } @@ -5428,7 +5508,7 @@ namespace ts { } } - function parseNonParameterInitializer() { + function parseNonParameterInitializer(): Expression | undefined { return parseInitializer(/*inParameter*/ false); } diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.js b/tests/baselines/reference/parserArrowFunctionExpression7.js new file mode 100644 index 00000000000..0646a1bf438 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.js @@ -0,0 +1,16 @@ +//// [parserArrowFunctionExpression7.ts] +({ + async m() { + for (;;) { + } + } +}); + + +//// [parserArrowFunctionExpression7.js] +({ + async m() { + for (;;) { + } + } +}); diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.symbols b/tests/baselines/reference/parserArrowFunctionExpression7.symbols new file mode 100644 index 00000000000..0dbc2cf05a1 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === +({ + async m() { +>m : Symbol(m, Decl(parserArrowFunctionExpression7.ts, 0, 2)) + + for (;;) { + } + } +}); + diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.types b/tests/baselines/reference/parserArrowFunctionExpression7.types new file mode 100644 index 00000000000..072a1548bd2 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === +({ +>({ async m() { for (;;) { } }}) : { m(): Promise; } +>{ async m() { for (;;) { } }} : { m(): Promise; } + + async m() { +>m : () => Promise + + for (;;) { + } + } +}); + diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts new file mode 100644 index 00000000000..65911cf0fc6 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts @@ -0,0 +1,7 @@ +// @target: esnext +({ + async m() { + for (;;) { + } + } +}); From 52e8e47cfbc8dbac41e75bb9d95a5a06ff9e1f38 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 13 Nov 2017 10:17:35 -0800 Subject: [PATCH 52/69] Extract JSXChildren checking --- src/compiler/checker.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 981380c70de..85033816766 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14378,19 +14378,7 @@ namespace ts { const parent = openingLikeElement.parent.kind === SyntaxKind.JsxElement ? openingLikeElement.parent as JsxElement : undefined; // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { - const childrenTypes: Type[] = []; - for (const child of (parent as JsxElement).children) { - // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that - // because then type of children property will have constituent of string type. - if (child.kind === SyntaxKind.JsxText) { - if (!child.containsOnlyWhiteSpaces) { - childrenTypes.push(stringType); - } - } - else { - childrenTypes.push(checkExpression(child, checkMode)); - } - } + const childrenTypes: Type[] = checkJsxChildren(parent as JsxElement, checkMode); if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { // Error if there is a attribute named "children" explicitly specified and children element. @@ -14430,6 +14418,23 @@ namespace ts { } } + function checkJsxChildren(node: JsxElement | JsxFragment, checkMode?: CheckMode) { + const childrenTypes: Type[] = []; + for (const child of node.children) { + // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that + // because then type of children property will have constituent of string type. + if (child.kind === SyntaxKind.JsxText) { + if (!child.containsOnlyWhiteSpaces) { + childrenTypes.push(stringType); + } + } + else { + childrenTypes.push(checkExpression(child, checkMode)); + } + } + return childrenTypes; + } + /** * Check attributes property of opening-like element. This function is called during chooseOverload to get call signature of a JSX opening-like element. * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) @@ -14964,6 +14969,9 @@ namespace ts { if (isNodeOpeningLikeElement) { checkJsxAttributesAssignableToTagNameAttributes(node); } + else { + checkJsxChildren((node as JsxOpeningFragment).parent); + } } /** From c2f0c580dbfec93f6d00a449faa60760469918ea Mon Sep 17 00:00:00 2001 From: Wilson Hobbs Date: Mon, 13 Nov 2017 13:37:54 -0500 Subject: [PATCH 53/69] add types for escape and unescape methods #18813 (#19015) * add types for escape and unescape methods #18813 although the issue is marked working as expected, it is important to mention that most major browsers maintain support for escape and unescape, and some javascript codebases moving to typescript may have escape and unescape in them. They are valid JavaScript, and thus they should be included in the global definition. * add escape and unescape types to lib in tests * update tests to turn CI green --- src/lib/es5.d.ts | 12 + .../fourslash/completionInJSDocFunctionNew.ts | 2 +- .../completionInJSDocFunctionThis.ts | 2 +- .../tsxCompletionOnOpeningTagWithoutJSX1.ts | 2 +- tests/lib/lib.d.ts | 1652 +++++++++-------- 5 files changed, 847 insertions(+), 823 deletions(-) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index fd2ae5b3fdf..aaefeec7d1a 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -62,6 +62,18 @@ declare function encodeURI(uri: string): string; */ declare function encodeURIComponent(uriComponent: string): string; +/** + * Computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. + * @param string A string value + */ +declare function escape(string: string): string; + +/** + * Computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. + * @param string A string value + */ +declare function unescape(string: string): string; + interface PropertyDescriptor { configurable?: boolean; enumerable?: boolean; diff --git a/tests/cases/fourslash/completionInJSDocFunctionNew.ts b/tests/cases/fourslash/completionInJSDocFunctionNew.ts index 0d3391cf774..742627974bd 100644 --- a/tests/cases/fourslash/completionInJSDocFunctionNew.ts +++ b/tests/cases/fourslash/completionInJSDocFunctionNew.ts @@ -6,5 +6,5 @@ ////var f = function () { return new/**/; } goTo.marker(); -verify.completionListCount(115); +verify.completionListCount(117); verify.completionListContains('new'); diff --git a/tests/cases/fourslash/completionInJSDocFunctionThis.ts b/tests/cases/fourslash/completionInJSDocFunctionThis.ts index c28eeeb397f..e22180aab52 100644 --- a/tests/cases/fourslash/completionInJSDocFunctionThis.ts +++ b/tests/cases/fourslash/completionInJSDocFunctionThis.ts @@ -5,6 +5,6 @@ ////var f = function (s) { return this/**/; } goTo.marker(); -verify.completionListCount(116); +verify.completionListCount(118); verify.completionListContains('this'); diff --git a/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts b/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts index f208b0a44a4..85cae83288a 100644 --- a/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts +++ b/tests/cases/fourslash/tsxCompletionOnOpeningTagWithoutJSX1.ts @@ -4,4 +4,4 @@ //// var x = (o: T): T; @@ -189,25 +201,25 @@ interface ObjectConstructor { /** * Prevents the addition of new properties to an object. - * @param o Object to make non-extensible. + * @param o Object to make non-extensible. */ preventExtensions(o: T): T; /** * Returns true if existing property attributes cannot be modified in an object and new properties cannot be added to the object. - * @param o Object to test. + * @param o Object to test. */ isSealed(o: any): boolean; /** * Returns true if existing property attributes and values cannot be modified in an object, and new properties cannot be added to the object. - * @param o Object to test. + * @param o Object to test. */ isFrozen(o: any): boolean; /** * Returns a value that indicates whether new properties can be added to an object. - * @param o Object to test. + * @param o Object to test. */ isExtensible(o: any): boolean; @@ -242,7 +254,7 @@ interface Function { call(thisArg: any, ...argArray: any[]): any; /** - * For a given function, creates a bound function that has the same body as the original function. + * For a given function, creates a bound function that has the same body as the original function. * The this object of the bound function is associated with the specified object, and has the specified initial parameters. * @param thisArg An object to which the this keyword can refer inside the new function. * @param argArray A list of arguments to be passed to the new function. @@ -285,7 +297,7 @@ interface String { */ charAt(pos: number): string; - /** + /** * Returns the Unicode value of the character at the specified location. * @param index The zero-based index of the desired character. If there is no character at the specified index, NaN is returned. */ @@ -293,12 +305,12 @@ interface String { /** * Returns a string that contains the concatenation of two or more strings. - * @param strings The strings to append to the end of the string. + * @param strings The strings to append to the end of the string. */ concat(...strings: string[]): string; /** - * Returns the position of the first occurrence of a substring. + * Returns the position of the first occurrence of a substring. * @param searchString The substring to search for in the string * @param position The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. */ @@ -317,15 +329,15 @@ interface String { */ localeCompare(that: string): number; - /** + /** * Matches a string with a regular expression, and returns an array containing the results of that search. * @param regexp A variable name or string literal containing the regular expression pattern and flags. */ match(regexp: string): RegExpMatchArray; - /** + /** * Matches a string with a regular expression, and returns an array containing the results of that search. - * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. + * @param regexp A regular expression object that contains the regular expression pattern and applicable flags. */ match(regexp: RegExp): RegExpMatchArray; @@ -359,40 +371,40 @@ interface String { /** * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. + * @param regexp The regular expression pattern and applicable flags. */ search(regexp: string): number; /** * Finds the first substring match in a regular expression search. - * @param regexp The regular expression pattern and applicable flags. + * @param regexp The regular expression pattern and applicable flags. */ search(regexp: RegExp): number; /** * Returns a section of a string. - * @param start The index to the beginning of the specified portion of stringObj. - * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. + * @param start The index to the beginning of the specified portion of stringObj. + * @param end The index to the end of the specified portion of stringObj. The substring includes the characters up to, but not including, the character indicated by end. * If this value is not specified, the substring continues to the end of stringObj. */ slice(start?: number, end?: number): string; /** * Split a string into substrings using the specified separator and return them as an array. - * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param separator A string that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. * @param limit A value used to limit the number of elements returned in the array. */ split(separator: string, limit?: number): string[]; /** * Split a string into substrings using the specified separator and return them as an array. - * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. + * @param separator A Regular Express that identifies character or characters to use in separating the string. If omitted, a single-element array containing the entire string is returned. * @param limit A value used to limit the number of elements returned in the array. */ split(separator: RegExp, limit?: number): string[]; /** - * Returns the substring at the specified location within a String object. + * Returns the substring at the specified location within a String object. * @param start The zero-based index number indicating the beginning of the substring. * @param end Zero-based index number indicating the end of the substring. The substring includes the characters up to, but not including, the character indicated by end. * If end is omitted, the characters from start through the end of the original string are returned. @@ -438,8 +450,8 @@ interface StringConstructor { fromCharCode(...codes: number[]): string; } -/** - * Allows manipulation and formatting of text strings and determination and location of substrings within strings. +/** + * Allows manipulation and formatting of text strings and determination and location of substrings within strings. */ declare var String: StringConstructor; @@ -463,7 +475,7 @@ interface Number { */ toString(radix?: number): string; - /** + /** * Returns a string representing a number in fixed-point notation. * @param fractionDigits Number of digits after the decimal point. Must be in the range 0 - 20, inclusive. */ @@ -496,21 +508,21 @@ interface NumberConstructor { /** The closest number to zero that can be represented in JavaScript. Equal to approximately 5.00E-324. */ MIN_VALUE: number; - /** + /** * A value that is not a number. * In equality comparisons, NaN does not equal any value, including itself. To test whether a value is equivalent to NaN, use the isNaN function. */ NaN: number; - /** + /** * A value that is less than the largest negative number that can be represented in JavaScript. - * JavaScript displays NEGATIVE_INFINITY values as -infinity. + * JavaScript displays NEGATIVE_INFINITY values as -infinity. */ NEGATIVE_INFINITY: number; /** - * A value greater than the largest number that can be represented in JavaScript. - * JavaScript displays POSITIVE_INFINITY values as infinity. + * A value greater than the largest number that can be represented in JavaScript. + * JavaScript displays POSITIVE_INFINITY values as infinity. */ POSITIVE_INFINITY: number; } @@ -540,23 +552,23 @@ interface Math { /** The square root of 2. */ SQRT2: number; /** - * Returns the absolute value of a number (the value without regard to whether it is positive or negative). + * Returns the absolute value of a number (the value without regard to whether it is positive or negative). * For example, the absolute value of -5 is the same as the absolute value of 5. * @param x A numeric expression for which the absolute value is needed. */ abs(x: number): number; /** - * Returns the arc cosine (or inverse cosine) of a number. + * Returns the arc cosine (or inverse cosine) of a number. * @param x A numeric expression. */ acos(x: number): number; - /** - * Returns the arcsine of a number. + /** + * Returns the arcsine of a number. * @param x A numeric expression. */ asin(x: number): number; /** - * Returns the arctangent of a number. + * Returns the arctangent of a number. * @param x A numeric expression for which the arctangent is needed. */ atan(x: number): number; @@ -567,49 +579,49 @@ interface Math { */ atan2(y: number, x: number): number; /** - * Returns the smallest number greater than or equal to its numeric argument. + * Returns the smallest number greater than or equal to its numeric argument. * @param x A numeric expression. */ ceil(x: number): number; /** - * Returns the cosine of a number. + * Returns the cosine of a number. * @param x A numeric expression that contains an angle measured in radians. */ cos(x: number): number; /** - * Returns e (the base of natural logarithms) raised to a power. + * Returns e (the base of natural logarithms) raised to a power. * @param x A numeric expression representing the power of e. */ exp(x: number): number; /** - * Returns the greatest number less than or equal to its numeric argument. + * Returns the greatest number less than or equal to its numeric argument. * @param x A numeric expression. */ floor(x: number): number; /** - * Returns the natural logarithm (base e) of a number. + * Returns the natural logarithm (base e) of a number. * @param x A numeric expression. */ log(x: number): number; /** - * Returns the larger of a set of supplied numeric expressions. + * Returns the larger of a set of supplied numeric expressions. * @param values Numeric expressions to be evaluated. */ max(...values: number[]): number; /** - * Returns the smaller of a set of supplied numeric expressions. + * Returns the smaller of a set of supplied numeric expressions. * @param values Numeric expressions to be evaluated. */ min(...values: number[]): number; /** - * Returns the value of a base expression taken to a specified power. + * Returns the value of a base expression taken to a specified power. * @param x The base value of the expression. * @param y The exponent value of the expression. */ pow(x: number, y: number): number; /** Returns a pseudorandom number between 0 and 1. */ random(): number; - /** + /** * Returns a supplied numeric expression rounded to the nearest number. * @param x The value to be rounded to the nearest number. */ @@ -685,24 +697,24 @@ interface Date { getUTCMilliseconds(): number; /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ getTimezoneOffset(): number; - /** + /** * Sets the date and time value in the Date object. - * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. + * @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT. */ setTime(time: number): number; /** - * Sets the milliseconds value in the Date object using local time. + * Sets the milliseconds value in the Date object using local time. * @param ms A numeric value equal to the millisecond value. */ setMilliseconds(ms: number): number; - /** + /** * Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). - * @param ms A numeric value equal to the millisecond value. + * @param ms A numeric value equal to the millisecond value. */ setUTCMilliseconds(ms: number): number; /** - * Sets the seconds value in the Date object using local time. + * Sets the seconds value in the Date object using local time. * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ @@ -714,16 +726,16 @@ interface Date { */ setUTCSeconds(sec: number, ms?: number): number; /** - * Sets the minutes value in the Date object using local time. - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. + * Sets the minutes value in the Date object using local time. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ setMinutes(min: number, sec?: number, ms?: number): number; /** * Sets the minutes value in the Date object using Universal Coordinated Time (UTC). - * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. + * @param min A numeric value equal to the minutes value. + * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ setUTCMinutes(min: number, sec?: number, ms?: number): number; @@ -731,7 +743,7 @@ interface Date { * Sets the hour value in the Date object using local time. * @param hours A numeric value equal to the hours value. * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. + * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ setHours(hours: number, min?: number, sec?: number, ms?: number): number; @@ -739,23 +751,23 @@ interface Date { * Sets the hours value in the Date object using Universal Coordinated Time (UTC). * @param hours A numeric value equal to the hours value. * @param min A numeric value equal to the minutes value. - * @param sec A numeric value equal to the seconds value. + * @param sec A numeric value equal to the seconds value. * @param ms A numeric value equal to the milliseconds value. */ setUTCHours(hours: number, min?: number, sec?: number, ms?: number): number; /** - * Sets the numeric day-of-the-month value of the Date object using local time. + * Sets the numeric day-of-the-month value of the Date object using local time. * @param date A numeric value equal to the day of the month. */ setDate(date: number): number; - /** + /** * Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). - * @param date A numeric value equal to the day of the month. + * @param date A numeric value equal to the day of the month. */ setUTCDate(date: number): number; - /** - * Sets the month value in the Date object using local time. - * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. + /** + * Sets the month value in the Date object using local time. + * @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. * @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used. */ setMonth(month: number, date?: number): number; @@ -800,7 +812,7 @@ interface DateConstructor { */ parse(s: string): number; /** - * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. + * Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date. * @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year. * @param month The month as an number between 0 and 11 (January to December). * @param date The date as an number between 1 and 31. @@ -826,13 +838,13 @@ interface RegExpExecArray extends Array { } interface RegExp { - /** + /** * Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search. * @param string The String object or string literal on which to perform the search. */ exec(string: string): RegExpExecArray; - /** + /** * Returns a Boolean value that indicates whether or not a pattern exists in a searched string. * @param string String on which to perform the search. */ @@ -959,8 +971,8 @@ interface JSON { /** * Converts a JavaScript Object Notation (JSON) string into an object. * @param text A valid JSON string. - * @param reviver A function that transforms the results. This function is called for each member of the object. - * If a member contains nested objects, the nested objects are transformed before the parent object is. + * @param reviver A function that transforms the results. This function is called for each member of the object. + * If a member contains nested objects, the nested objects are transformed before the parent object is. */ parse(text: string, reviver?: (key: any, value: any) => any): any; /** @@ -1040,14 +1052,14 @@ interface Array { */ join(separator?: string): string; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): T[]; /** * Removes the first element from an array and returns it. */ shift(): T; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -1110,21 +1122,21 @@ interface Array { /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void; /** * Calls a defined callback function on each element of an array, and returns an array that contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[]; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): T[]; @@ -1142,15 +1154,15 @@ interface Array { */ reduce(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; - /** + /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): T; - /** + /** * Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array. * @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U; @@ -1205,10 +1217,10 @@ interface ArrayLike { /** - * Represents a raw buffer of binary data, which is used to store data for the - * different typed arrays. ArrayBuffers cannot be read from or written to directly, - * but can be passed to a typed array or DataView Object to interpret the raw - * buffer as needed. + * Represents a raw buffer of binary data, which is used to store data for the + * different typed arrays. ArrayBuffers cannot be read from or written to directly, + * but can be passed to a typed array or DataView Object to interpret the raw + * buffer as needed. */ interface ArrayBuffer { /** @@ -1231,7 +1243,7 @@ declare var ArrayBuffer: ArrayBufferConstructor; interface ArrayBufferView { /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -1251,124 +1263,124 @@ interface DataView { byteLength: number; byteOffset: number; /** - * Gets the Float32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Float32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getFloat32(byteOffset: number, littleEndian?: boolean): number; /** * Gets the Float64 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getFloat64(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Int8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt8(byteOffset: number): number; /** - * Gets the Int16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Int16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Int32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Int32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getInt32(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint8 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Uint8 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint8(byteOffset: number): number; /** - * Gets the Uint16 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Uint16 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint16(byteOffset: number, littleEndian?: boolean): number; /** - * Gets the Uint32 value at the specified byte offset from the start of the view. There is - * no alignment constraint; multi-byte values may be fetched from any offset. + * Gets the Uint32 value at the specified byte offset from the start of the view. There is + * no alignment constraint; multi-byte values may be fetched from any offset. * @param byteOffset The place in the buffer at which the value should be retrieved. */ getUint32(byteOffset: number, littleEndian?: boolean): number; /** - * Stores an Float32 value at the specified byte offset from the start of the view. + * Stores an Float32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setFloat32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Float64 value at the specified byte offset from the start of the view. + * Stores an Float64 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setFloat64(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int8 value at the specified byte offset from the start of the view. + * Stores an Int8 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. */ setInt8(byteOffset: number, value: number): void; /** - * Stores an Int16 value at the specified byte offset from the start of the view. + * Stores an Int16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setInt16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Int32 value at the specified byte offset from the start of the view. + * Stores an Int32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setInt32(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint8 value at the specified byte offset from the start of the view. + * Stores an Uint8 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. */ setUint8(byteOffset: number, value: number): void; /** - * Stores an Uint16 value at the specified byte offset from the start of the view. + * Stores an Uint16 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setUint16(byteOffset: number, value: number, littleEndian?: boolean): void; /** - * Stores an Uint32 value at the specified byte offset from the start of the view. + * Stores an Uint32 value at the specified byte offset from the start of the view. * @param byteOffset The place in the buffer at which the value should be set. * @param value The value to set. - * @param littleEndian If false or undefined, a big-endian value should be written, + * @param littleEndian If false or undefined, a big-endian value should be written, * otherwise a little-endian value should be written. */ setUint32(byteOffset: number, value: number, littleEndian?: boolean): void; @@ -1380,17 +1392,17 @@ interface DataViewConstructor { declare var DataView: DataViewConstructor; /** - * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested + * A typed array of 8-bit integer values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Int8Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -1404,21 +1416,21 @@ interface Int8Array { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Int8Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -1428,49 +1440,49 @@ interface Int8Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Int8Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): Int8Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Int8Array) => void, thisArg?: any): void; @@ -1485,7 +1497,7 @@ interface Int8Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -1493,7 +1505,7 @@ interface Int8Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -1504,65 +1516,65 @@ interface Int8Array { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Int8Array) => number, thisArg?: any): Int8Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int8Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Int8Array; @@ -1580,7 +1592,7 @@ interface Int8Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -1589,31 +1601,31 @@ interface Int8Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Int8Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Int8Array; /** * Gets a new Int8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Int8Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -1631,7 +1643,7 @@ interface Int8ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -1640,7 +1652,7 @@ interface Int8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int8Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -1653,17 +1665,17 @@ interface Int8ArrayConstructor { declare var Int8Array: Int8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 8-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint8Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -1677,21 +1689,21 @@ interface Uint8Array { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Uint8Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -1701,49 +1713,49 @@ interface Uint8Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Uint8Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): Uint8Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Uint8Array) => void, thisArg?: any): void; @@ -1758,7 +1770,7 @@ interface Uint8Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -1766,7 +1778,7 @@ interface Uint8Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -1777,65 +1789,65 @@ interface Uint8Array { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Uint8Array) => number, thisArg?: any): Uint8Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Uint8Array; @@ -1853,7 +1865,7 @@ interface Uint8Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -1862,31 +1874,31 @@ interface Uint8Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Uint8Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Uint8Array; /** * Gets a new Uint8Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Uint8Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -1905,7 +1917,7 @@ interface Uint8ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -1914,7 +1926,7 @@ interface Uint8ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint8Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -1927,17 +1939,17 @@ interface Uint8ArrayConstructor { declare var Uint8Array: Uint8ArrayConstructor; /** - * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. + * A typed array of 8-bit unsigned integer (clamped) values. The contents are initialized to 0. * If the requested number of bytes could not be allocated an exception is raised. */ interface Uint8ClampedArray { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -1951,21 +1963,21 @@ interface Uint8ClampedArray { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Uint8ClampedArray; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -1975,49 +1987,49 @@ interface Uint8ClampedArray { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Uint8ClampedArray; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): Uint8ClampedArray; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => void, thisArg?: any): void; @@ -2032,7 +2044,7 @@ interface Uint8ClampedArray { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -2040,7 +2052,7 @@ interface Uint8ClampedArray { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -2051,65 +2063,65 @@ interface Uint8ClampedArray { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => number, thisArg?: any): Uint8ClampedArray; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint8ClampedArray) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Uint8ClampedArray; @@ -2127,7 +2139,7 @@ interface Uint8ClampedArray { */ set(array: Uint8ClampedArray, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -2136,31 +2148,31 @@ interface Uint8ClampedArray { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Uint8ClampedArray; /** * Gets a new Uint8ClampedArray view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Uint8ClampedArray; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -2179,7 +2191,7 @@ interface Uint8ClampedArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -2200,17 +2212,17 @@ interface Uint8ClampedArrayConstructor { declare var Uint8ClampedArray: Uint8ClampedArrayConstructor; /** - * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 16-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int16Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -2224,21 +2236,21 @@ interface Int16Array { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Int16Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -2248,49 +2260,49 @@ interface Int16Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Int16Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): Int16Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Int16Array) => void, thisArg?: any): void; @@ -2305,7 +2317,7 @@ interface Int16Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -2313,7 +2325,7 @@ interface Int16Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -2324,65 +2336,65 @@ interface Int16Array { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Int16Array) => number, thisArg?: any): Int16Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int16Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Int16Array; @@ -2400,7 +2412,7 @@ interface Int16Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -2409,31 +2421,31 @@ interface Int16Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Int16Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Int16Array; /** * Gets a new Int16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Int16Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -2452,7 +2464,7 @@ interface Int16ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -2461,7 +2473,7 @@ interface Int16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int16Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -2474,17 +2486,17 @@ interface Int16ArrayConstructor { declare var Int16Array: Int16ArrayConstructor; /** - * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 16-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint16Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -2498,21 +2510,21 @@ interface Uint16Array { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Uint16Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -2522,49 +2534,49 @@ interface Uint16Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Uint16Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): Uint16Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Uint16Array) => void, thisArg?: any): void; @@ -2579,7 +2591,7 @@ interface Uint16Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -2587,7 +2599,7 @@ interface Uint16Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -2598,65 +2610,65 @@ interface Uint16Array { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Uint16Array) => number, thisArg?: any): Uint16Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint16Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint16Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Uint16Array; @@ -2674,7 +2686,7 @@ interface Uint16Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -2683,31 +2695,31 @@ interface Uint16Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Uint16Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Uint16Array; /** * Gets a new Uint16Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Uint16Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -2726,7 +2738,7 @@ interface Uint16ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -2735,7 +2747,7 @@ interface Uint16ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint16Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -2747,17 +2759,17 @@ interface Uint16ArrayConstructor { } declare var Uint16Array: Uint16ArrayConstructor; /** - * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the + * A typed array of 32-bit signed integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Int32Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -2771,21 +2783,21 @@ interface Int32Array { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Int32Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -2795,49 +2807,49 @@ interface Int32Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Int32Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): Int32Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Int32Array) => void, thisArg?: any): void; @@ -2852,7 +2864,7 @@ interface Int32Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -2860,7 +2872,7 @@ interface Int32Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -2871,65 +2883,65 @@ interface Int32Array { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Int32Array) => number, thisArg?: any): Int32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Int32Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Int32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Int32Array; @@ -2947,7 +2959,7 @@ interface Int32Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -2956,31 +2968,31 @@ interface Int32Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Int32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Int32Array; /** * Gets a new Int32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Int32Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -2999,7 +3011,7 @@ interface Int32ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -3008,7 +3020,7 @@ interface Int32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Int32Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -3020,17 +3032,17 @@ interface Int32ArrayConstructor { declare var Int32Array: Int32ArrayConstructor; /** - * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the + * A typed array of 32-bit unsigned integer values. The contents are initialized to 0. If the * requested number of bytes could not be allocated an exception is raised. */ interface Uint32Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -3044,21 +3056,21 @@ interface Uint32Array { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Uint32Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -3068,49 +3080,49 @@ interface Uint32Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Uint32Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): Uint32Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Uint32Array) => void, thisArg?: any): void; @@ -3125,7 +3137,7 @@ interface Uint32Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -3133,7 +3145,7 @@ interface Uint32Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -3144,65 +3156,65 @@ interface Uint32Array { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Uint32Array) => number, thisArg?: any): Uint32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Uint32Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Uint32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Uint32Array; @@ -3220,7 +3232,7 @@ interface Uint32Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -3229,31 +3241,31 @@ interface Uint32Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Uint32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Uint32Array; /** * Gets a new Uint32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Uint32Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -3272,7 +3284,7 @@ interface Uint32ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -3281,7 +3293,7 @@ interface Uint32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Uint32Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -3298,12 +3310,12 @@ declare var Uint32Array: Uint32ArrayConstructor; */ interface Float32Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -3317,21 +3329,21 @@ interface Float32Array { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Float32Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -3341,49 +3353,49 @@ interface Float32Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Float32Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): Float32Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Float32Array) => void, thisArg?: any): void; @@ -3398,7 +3410,7 @@ interface Float32Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -3406,7 +3418,7 @@ interface Float32Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -3417,65 +3429,65 @@ interface Float32Array { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Float32Array) => number, thisArg?: any): Float32Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float32Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float32Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Float32Array; @@ -3493,7 +3505,7 @@ interface Float32Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -3502,31 +3514,31 @@ interface Float32Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Float32Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Float32Array; /** * Gets a new Float32Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Float32Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -3545,7 +3557,7 @@ interface Float32ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -3554,7 +3566,7 @@ interface Float32ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float32Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -3567,17 +3579,17 @@ interface Float32ArrayConstructor { declare var Float32Array: Float32ArrayConstructor; /** - * A typed array of 64-bit float values. The contents are initialized to 0. If the requested + * A typed array of 64-bit float values. The contents are initialized to 0. If the requested * number of bytes could not be allocated an exception is raised. */ interface Float64Array { /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; /** - * The ArrayBuffer instance referenced by the array. + * The ArrayBuffer instance referenced by the array. */ buffer: ArrayBuffer; @@ -3591,21 +3603,21 @@ interface Float64Array { */ byteOffset: number; - /** + /** * Returns the this object after copying a section of the array identified by start and end * to the same array starting at position target - * @param target If target is negative, it is treated as length+target where length is the - * length of the array. - * @param start If start is negative, it is treated as length+start. If end is negative, it + * @param target If target is negative, it is treated as length+target where length is the + * length of the array. + * @param start If start is negative, it is treated as length+start. If end is negative, it * is treated as length+end. - * @param end If not specified, length of the this object is used as its default value. + * @param end If not specified, length of the this object is used as its default value. */ copyWithin(target: number, start: number, end?: number): Float64Array; /** * Determines whether all the members of an array satisfy the specified test. - * @param callbackfn A function that accepts up to three arguments. The every method calls - * the callbackfn function for each element in array1 until the callbackfn returns false, + * @param callbackfn A function that accepts up to three arguments. The every method calls + * the callbackfn function for each element in array1 until the callbackfn returns false, * or until the end of the array. * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. @@ -3615,49 +3627,49 @@ interface Float64Array { /** * Returns the this object after filling the section identified by start and end with value * @param value value to fill array section with - * @param start index to start filling the array at. If start is negative, it is treated as - * length+start where length is the length of the array. - * @param end index to stop filling the array at. If end is negative, it is treated as + * @param start index to start filling the array at. If start is negative, it is treated as + * length+start where length is the length of the array. + * @param end index to stop filling the array at. If end is negative, it is treated as * length+end. */ fill(value: number, start?: number, end?: number): Float64Array; /** - * Returns the elements of an array that meet the condition specified in a callback function. - * @param callbackfn A function that accepts up to three arguments. The filter method calls - * the callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls + * the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ filter(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): Float64Array; - /** - * Returns the value of the first element in the array where predicate is true, and undefined + /** + * Returns the value of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ find(predicate: (value: number, index: number, obj: Array) => boolean, thisArg?: any): number; - /** - * Returns the index of the first element in the array where predicate is true, and undefined + /** + * Returns the index of the first element in the array where predicate is true, and undefined * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, find + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find * immediately returns that element value. Otherwise, find returns undefined. - * @param thisArg If provided, it will be used as the this value for each invocation of + * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ findIndex(predicate: (value: number) => boolean, thisArg?: any): number; /** * Performs the specified action for each element in an array. - * @param callbackfn A function that accepts up to three arguments. forEach calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. forEach calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ forEach(callbackfn: (value: number, index: number, array: Float64Array) => void, thisArg?: any): void; @@ -3672,7 +3684,7 @@ interface Float64Array { /** * Adds all the elements of an array separated by the specified separator string. - * @param separator A string used to separate one element of an array from the next in the + * @param separator A string used to separate one element of an array from the next in the * resulting String. If omitted, the array elements are separated with a comma. */ join(separator?: string): string; @@ -3680,7 +3692,7 @@ interface Float64Array { /** * Returns the index of the last occurrence of a value in an array. * @param searchElement The value to locate in the array. - * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the + * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the * search starts at index 0. */ lastIndexOf(searchElement: number, fromIndex?: number): number; @@ -3691,65 +3703,65 @@ interface Float64Array { length: number; /** - * Calls a defined callback function on each element of an array, and returns an array that + * Calls a defined callback function on each element of an array, and returns an array that * contains the results. - * @param callbackfn A function that accepts up to three arguments. The map method calls the - * callbackfn function one time for each element in the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param callbackfn A function that accepts up to three arguments. The map method calls the + * callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: number, index: number, array: Float64Array) => number, thisArg?: any): Float64Array; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; /** - * Calls the specified callback function for all the elements in an array. The return value of - * the callback function is the accumulated result, and is provided as an argument in the next + * Calls the specified callback function for all the elements in an array. The return value of + * the callback function is the accumulated result, and is provided as an argument in the next * call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduce method calls the + * @param callbackfn A function that accepts up to four arguments. The reduce method calls the * callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an argument + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduce(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. - * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start - * the accumulation. The first call to the callbackfn function provides this value as an + * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start + * the accumulation. The first call to the callbackfn function provides this value as an * argument instead of an array value. */ reduceRight(callbackfn: (previousValue: number, currentValue: number, currentIndex: number, array: Float64Array) => number, initialValue?: number): number; - /** - * Calls the specified callback function for all the elements in an array, in descending order. - * The return value of the callback function is the accumulated result, and is provided as an + /** + * Calls the specified callback function for all the elements in an array, in descending order. + * The return value of the callback function is the accumulated result, and is provided as an * argument in the next call to the callback function. * @param callbackfn A function that accepts up to four arguments. The reduceRight method calls - * the callbackfn function one time for each element in the array. - * @param initialValue If initialValue is specified, it is used as the initial value to start + * the callbackfn function one time for each element in the array. + * @param initialValue If initialValue is specified, it is used as the initial value to start * the accumulation. The first call to the callbackfn function provides this value as an argument * instead of an array value. */ reduceRight(callbackfn: (previousValue: U, currentValue: number, currentIndex: number, array: Float64Array) => U, initialValue: U): U; /** - * Reverses the elements in an Array. + * Reverses the elements in an Array. */ reverse(): Float64Array; @@ -3767,7 +3779,7 @@ interface Float64Array { */ set(array: ArrayLike, offset?: number): void; - /** + /** * Returns a section of an array. * @param start The beginning of the specified portion of the array. * @param end The end of the specified portion of the array. @@ -3776,31 +3788,31 @@ interface Float64Array { /** * Determines whether the specified callback function returns true for any element of an array. - * @param callbackfn A function that accepts up to three arguments. The some method calls the - * callbackfn function for each element in array1 until the callbackfn returns true, or until + * @param callbackfn A function that accepts up to three arguments. The some method calls the + * callbackfn function for each element in array1 until the callbackfn returns true, or until * the end of the array. - * @param thisArg An object to which the this keyword can refer in the callbackfn function. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. * If thisArg is omitted, undefined is used as the this value. */ some(callbackfn: (value: number, index: number, array: Float64Array) => boolean, thisArg?: any): boolean; /** * Sorts an array. - * @param compareFn The name of the function used to determine the order of the elements. If + * @param compareFn The name of the function used to determine the order of the elements. If * omitted, the elements are sorted in ascending, ASCII character order. */ sort(compareFn?: (a: number, b: number) => number): Float64Array; /** * Gets a new Float64Array view of the ArrayBuffer store for this array, referencing the elements - * at begin, inclusive, up to end, exclusive. + * at begin, inclusive, up to end, exclusive. * @param begin The index of the beginning of the array. * @param end The index of the end of the array. */ subarray(begin: number, end?: number): Float64Array; /** - * Converts a number to a string by using the current locale. + * Converts a number to a string by using the current locale. */ toLocaleString(): string; @@ -3819,7 +3831,7 @@ interface Float64ArrayConstructor { new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; /** - * The size in bytes of each element in the array. + * The size in bytes of each element in the array. */ BYTES_PER_ELEMENT: number; @@ -3828,7 +3840,7 @@ interface Float64ArrayConstructor { * @param items A set of elements to include in the new array object. */ of(...items: number[]): Float64Array; - + /** * Creates an array from an array-like or iterable object. * @param arrayLike An array-like or iterable object to convert to an array. @@ -3839,7 +3851,7 @@ interface Float64ArrayConstructor { } declare var Float64Array: Float64ArrayConstructor; ///////////////////////////// -/// ECMAScript Internationalization API +/// ECMAScript Internationalization API ///////////////////////////// declare module Intl { @@ -3982,14 +3994,14 @@ interface String { interface Number { /** - * Converts a number to a string by using the current or specified locale. + * Converts a number to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.NumberFormatOptions): string; /** - * Converts a number to a string by using the current or specified locale. + * Converts a number to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ @@ -3998,41 +4010,41 @@ interface Number { interface Date { /** - * Converts a date and time to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a date to a string by using the current or specified locale. + * Converts a date to a string by using the current or specified locale. * @param locales An array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleDateString(locales?: string[], options?: Intl.DateTimeFormatOptions): string; /** - * Converts a time to a string by using the current or specified locale. + * Converts a time to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleTimeString(locale?: string[], options?: Intl.DateTimeFormatOptions): string; - + /** - * Converts a date and time to a string by using the current or specified locale. + * Converts a date and time to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleString(locale?: string, options?: Intl.DateTimeFormatOptions): string; - + /** - * Converts a date to a string by using the current or specified locale. + * Converts a date to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ toLocaleDateString(locale?: string, options?: Intl.DateTimeFormatOptions): string; /** - * Converts a time to a string by using the current or specified locale. + * Converts a time to a string by using the current or specified locale. * @param locale Locale tag. If you omit this parameter, the default locale of the JavaScript runtime is used. * @param options An object that contains one or more properties that specify comparison options. */ @@ -5636,7 +5648,7 @@ declare var DeviceRotationRate: { interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent { /** - * Sets or gets the URL for the current document. + * Sets or gets the URL for the current document. */ URL: string; /** @@ -5664,7 +5676,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ applets: HTMLCollection; /** - * Deprecated. Sets or retrieves a value that indicates the background color behind the object. + * Deprecated. Sets or retrieves a value that indicates the background color behind the object. */ bgColor: string; /** @@ -5691,19 +5703,19 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ designMode: string; /** - * Sets or retrieves a value that indicates the reading order of the object. + * Sets or retrieves a value that indicates the reading order of the object. */ dir: string; /** - * Gets an object representing the document type declaration associated with the current document. + * Gets an object representing the document type declaration associated with the current document. */ doctype: DocumentType; /** - * Gets a reference to the root node of the document. + * Gets a reference to the root node of the document. */ documentElement: HTMLElement; /** - * Sets or gets the security domain of the document. + * Sets or gets the security domain of the document. */ domain: string; /** @@ -5727,7 +5739,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ images: HTMLCollection; /** - * Gets the implementation object of the current document. + * Gets the implementation object of the current document. */ implementation: DOMImplementation; /** @@ -5735,11 +5747,11 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ inputEncoding: string; /** - * Gets the date that the page was last modified, if the page supplies one. + * Gets the date that the page was last modified, if the page supplies one. */ lastModified: string; /** - * Sets or gets the color of the document links. + * Sets or gets the color of the document links. */ linkColor: string; /** @@ -5747,7 +5759,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ links: HTMLCollection; /** - * Contains information about the current URL. + * Contains information about the current URL. */ location: Location; media: string; @@ -5775,19 +5787,19 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param ev The event. */ onbeforedeactivate: (ev: UIEvent) => any; - /** - * Fires when the object loses the input focus. + /** + * Fires when the object loses the input focus. * @param ev The focus event. */ onblur: (ev: FocusEvent) => any; /** - * Occurs when playback is possible, but would require further buffering. + * Occurs when playback is possible, but would require further buffering. * @param ev The event. */ oncanplay: (ev: Event) => any; oncanplaythrough: (ev: Event) => any; /** - * Fires when the contents of the object or selection have changed. + * Fires when the contents of the object or selection have changed. * @param ev The event. */ onchange: (ev: Event) => any; @@ -5797,7 +5809,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ onclick: (ev: MouseEvent) => any; /** - * Fires when the user clicks the right mouse button in the client area, opening the context menu. + * Fires when the user clicks the right mouse button in the client area, opening the context menu. * @param ev The mouse event. */ oncontextmenu: (ev: PointerEvent) => any; @@ -5821,12 +5833,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param ev The event. */ ondragend: (ev: DragEvent) => any; - /** + /** * Fires on the target element when the user drags the object to a valid drop target. * @param ev The drag event. */ ondragenter: (ev: DragEvent) => any; - /** + /** * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation. * @param ev The drag event. */ @@ -5837,23 +5849,23 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ ondragover: (ev: DragEvent) => any; /** - * Fires on the source object when the user starts to drag a text selection or selected object. + * Fires on the source object when the user starts to drag a text selection or selected object. * @param ev The event. */ ondragstart: (ev: DragEvent) => any; ondrop: (ev: DragEvent) => any; /** - * Occurs when the duration attribute is updated. + * Occurs when the duration attribute is updated. * @param ev The event. */ ondurationchange: (ev: Event) => any; /** - * Occurs when the media element is reset to its initial state. + * Occurs when the media element is reset to its initial state. * @param ev The event. */ onemptied: (ev: Event) => any; /** - * Occurs when the end of playback is reached. + * Occurs when the end of playback is reached. * @param ev The event */ onended: (ev: Event) => any; @@ -5863,7 +5875,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ onerror: (ev: Event) => any; /** - * Fires when the object receives focus. + * Fires when the object receives focus. * @param ev The event. */ onfocus: (ev: FocusEvent) => any; @@ -5886,12 +5898,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ onkeyup: (ev: KeyboardEvent) => any; /** - * Fires immediately after the browser loads the object. + * Fires immediately after the browser loads the object. * @param ev The event. */ onload: (ev: Event) => any; /** - * Occurs when media data is loaded at the current playback position. + * Occurs when media data is loaded at the current playback position. * @param ev The event. */ onloadeddata: (ev: Event) => any; @@ -5901,22 +5913,22 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ onloadedmetadata: (ev: Event) => any; /** - * Occurs when Internet Explorer begins looking for media data. + * Occurs when Internet Explorer begins looking for media data. * @param ev The event. */ onloadstart: (ev: Event) => any; /** - * Fires when the user clicks the object with either mouse button. + * Fires when the user clicks the object with either mouse button. * @param ev The mouse event. */ onmousedown: (ev: MouseEvent) => any; /** - * Fires when the user moves the mouse over the object. + * Fires when the user moves the mouse over the object. * @param ev The mouse event. */ onmousemove: (ev: MouseEvent) => any; /** - * Fires when the user moves the mouse pointer outside the boundaries of the object. + * Fires when the user moves the mouse pointer outside the boundaries of the object. * @param ev The mouse event. */ onmouseout: (ev: MouseEvent) => any; @@ -5926,12 +5938,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ onmouseover: (ev: MouseEvent) => any; /** - * Fires when the user releases a mouse button while the mouse is over the object. + * Fires when the user releases a mouse button while the mouse is over the object. * @param ev The mouse event. */ onmouseup: (ev: MouseEvent) => any; /** - * Fires when the wheel button is rotated. + * Fires when the wheel button is rotated. * @param ev The mouse event */ onmousewheel: (ev: MouseWheelEvent) => any; @@ -5953,7 +5965,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven onmspointerover: (ev: MSPointerEvent) => any; onmspointerup: (ev: MSPointerEvent) => any; /** - * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. + * Occurs when an item is removed from a Jump List of a webpage running in Site Mode. * @param ev The event. */ onmssitemodejumplistitemremoved: (ev: MSSiteModeEvent) => any; @@ -5968,24 +5980,24 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ onpause: (ev: Event) => any; /** - * Occurs when the play method is requested. + * Occurs when the play method is requested. * @param ev The event. */ onplay: (ev: Event) => any; /** - * Occurs when the audio or video has started playing. + * Occurs when the audio or video has started playing. * @param ev The event. */ onplaying: (ev: Event) => any; onpointerlockchange: (ev: Event) => any; onpointerlockerror: (ev: Event) => any; /** - * Occurs to indicate progress while downloading media data. + * Occurs to indicate progress while downloading media data. * @param ev The event. */ onprogress: (ev: ProgressEvent) => any; /** - * Occurs when the playback rate is increased or decreased. + * Occurs when the playback rate is increased or decreased. * @param ev The event. */ onratechange: (ev: Event) => any; @@ -5995,22 +6007,22 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ onreadystatechange: (ev: ProgressEvent) => any; /** - * Fires when the user resets a form. + * Fires when the user resets a form. * @param ev The event. */ onreset: (ev: Event) => any; /** - * Fires when the user repositions the scroll box in the scroll bar on the object. + * Fires when the user repositions the scroll box in the scroll bar on the object. * @param ev The event. */ onscroll: (ev: UIEvent) => any; /** - * Occurs when the seek operation ends. + * Occurs when the seek operation ends. * @param ev The event. */ onseeked: (ev: Event) => any; /** - * Occurs when the current playback position is moved. + * Occurs when the current playback position is moved. * @param ev The event. */ onseeking: (ev: Event) => any; @@ -6021,7 +6033,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven onselect: (ev: UIEvent) => any; onselectstart: (ev: Event) => any; /** - * Occurs when the download has stopped. + * Occurs when the download has stopped. * @param ev The event. */ onstalled: (ev: Event) => any; @@ -6032,7 +6044,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven onstop: (ev: Event) => any; onsubmit: (ev: Event) => any; /** - * Occurs if the load operation has been intentionally halted. + * Occurs if the load operation has been intentionally halted. * @param ev The event. */ onsuspend: (ev: Event) => any; @@ -6051,7 +6063,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ onvolumechange: (ev: Event) => any; /** - * Occurs when playback stops because the next frame of a video resource is not available. + * Occurs when playback stops because the next frame of a video resource is not available. * @param ev The event. */ onwaiting: (ev: Event) => any; @@ -6085,7 +6097,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ title: string; visibilityState: string; - /** + /** * Sets or gets the color of the links that the user has visited. */ vlinkColor: string; @@ -6300,7 +6312,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createExpression(expression: string, resolver: XPathNSResolver): XPathExpression; createNSResolver(nodeResolver: Node): XPathNSResolver; /** - * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. + * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document. * @param root The root element or node to start traversing on. * @param whatToShow The type of nodes or elements to appear in the node list * @param filter A custom NodeFilter function to use. For more information, see filter. Use null for no filter. @@ -6309,11 +6321,11 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven createNodeIterator(root: Node, whatToShow?: number, filter?: NodeFilter, entityReferenceExpansion?: boolean): NodeIterator; createProcessingInstruction(target: string, data: string): ProcessingInstruction; /** - * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. + * Returns an empty range object that has both of its boundary points positioned at the beginning of the document. */ createRange(): Range; /** - * Creates a text string from the specified value. + * Creates a text string from the specified value. * @param data String that specifies the nodeValue property of the text node. */ createTextNode(data: string): Text; @@ -6328,7 +6340,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven */ createTreeWalker(root: Node, whatToShow?: number, filter?: NodeFilter, entityReferenceExpansion?: boolean): TreeWalker; /** - * Returns the element for the specified x coordinate and the specified y coordinate. + * Returns the element for the specified x coordinate and the specified y coordinate. * @param x The x-offset * @param y The y-offset */ @@ -6561,7 +6573,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * @param replace Specifies whether the existing entry for the document is replaced in the history list. */ open(url?: string, name?: string, features?: string, replace?: boolean): Document; - /** + /** * Returns a Boolean value that indicates whether a specified command can be successfully executed using execCommand, given the current state of the document. * @param commandId Specifies a command identifier. */ @@ -6583,7 +6595,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven queryCommandSupported(commandId: string): boolean; /** * Retrieves the string associated with a command. - * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. + * @param commandId String that contains the identifier of a command. This can be any command identifier given in the list of Command Identifiers. */ queryCommandText(commandId: string): string; /** @@ -6599,12 +6611,12 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven webkitCancelFullScreen(): void; webkitExitFullscreen(): void; /** - * Writes one or more HTML expressions to a document in the specified window. + * Writes one or more HTML expressions to a document in the specified window. * @param content Specifies the text and HTML tags to write. */ write(...content: string[]): void; /** - * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. + * Writes one or more HTML expressions, followed by a carriage return, to a document in the specified window. * @param content The text and HTML tags to write. */ writeln(...content: string[]): void; @@ -7312,12 +7324,12 @@ interface HTMLAnchorElement extends HTMLElement { */ target: string; /** - * Retrieves or sets the text of the object as a string. + * Retrieves or sets the text of the object as a string. */ text: string; type: string; urn: string; - /** + /** * Returns a string representation of an object. */ toString(): string; @@ -7418,7 +7430,7 @@ interface HTMLAreaElement extends HTMLElement { */ host: string; /** - * Sets or retrieves the host name part of the location or URL. + * Sets or retrieves the host name part of the location or URL. */ hostname: string; /** @@ -7454,7 +7466,7 @@ interface HTMLAreaElement extends HTMLElement { * Sets or retrieves the window or frame at which to target content. */ target: string; - /** + /** * Returns a string representation of an object. */ toString(): string; @@ -7737,7 +7749,7 @@ interface HTMLButtonElement extends HTMLElement { * Overrides the target attribute on a form element. */ formTarget: string; - /** + /** * Sets or retrieves the name of the object. */ name: string; @@ -7754,7 +7766,7 @@ interface HTMLButtonElement extends HTMLElement { * Returns a ValidityState object that represents the validity states of an element. */ validity: ValidityState; - /** + /** * Sets or retrieves the default or selected value of the control. */ value: string; @@ -7888,7 +7900,7 @@ declare var HTMLDirectoryElement: { interface HTMLDivElement extends HTMLElement { /** - * Sets or retrieves how the object is aligned with adjacent text. + * Sets or retrieves how the object is aligned with adjacent text. */ align: string; /** @@ -9034,7 +9046,7 @@ interface HTMLInputElement extends HTMLElement { */ files: FileList; /** - * Retrieves a reference to the form that the object is embedded in. + * Retrieves a reference to the form that the object is embedded in. */ form: HTMLFormElement; /** @@ -9204,7 +9216,7 @@ interface HTMLIsIndexElement extends HTMLElement { */ action: string; /** - * Retrieves a reference to the form that the object is embedded in. + * Retrieves a reference to the form that the object is embedded in. */ form: HTMLFormElement; prompt: string; @@ -9763,7 +9775,7 @@ interface HTMLMetaElement extends HTMLElement { */ scheme: string; /** - * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. + * Sets or retrieves the URL property that will be loaded after the specified time has elapsed. */ url: string; } @@ -10009,7 +10021,7 @@ declare var HTMLOptionElement: { interface HTMLParagraphElement extends HTMLElement { /** - * Sets or retrieves how the object is aligned with adjacent text. + * Sets or retrieves how the object is aligned with adjacent text. */ align: string; clear: string; @@ -10128,10 +10140,10 @@ interface HTMLScriptElement extends HTMLElement { */ defer: boolean; /** - * Sets or retrieves the event for which the script is written. + * Sets or retrieves the event for which the script is written. */ event: string; - /** + /** * Sets or retrieves the object that is bound to the event script. */ htmlFor: string; @@ -10140,7 +10152,7 @@ interface HTMLScriptElement extends HTMLElement { */ src: string; /** - * Retrieves or sets the text of the object as a string. + * Retrieves or sets the text of the object as a string. */ text: string; /** @@ -10161,7 +10173,7 @@ interface HTMLSelectElement extends HTMLElement { autofocus: boolean; disabled: boolean; /** - * Retrieves a reference to the form that the object is embedded in. + * Retrieves a reference to the form that the object is embedded in. */ form: HTMLFormElement; /** @@ -10186,7 +10198,7 @@ interface HTMLSelectElement extends HTMLElement { */ selectedIndex: number; /** - * Sets or retrieves the number of rows in the list box. + * Sets or retrieves the number of rows in the list box. */ size: number; /** @@ -10212,7 +10224,7 @@ interface HTMLSelectElement extends HTMLElement { /** * Adds an element to the areas, controlRange, or options collection. * @param element Variant of type Number that specifies the index position in the collection where the element is placed. If no value is given, the method places the element at the end of the collection. - * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. + * @param before Variant of type Object that specifies an element to insert before, or null to append the object to the collection. */ add(element: HTMLElement, before?: HTMLElement | number): void; /** @@ -10404,7 +10416,7 @@ interface HTMLTableElement extends HTMLElement { */ border: string; /** - * Sets or retrieves the border color of the object. + * Sets or retrieves the border color of the object. */ borderColor: any; /** @@ -10693,7 +10705,7 @@ declare var HTMLTextAreaElement: { interface HTMLTitleElement extends HTMLElement { /** - * Retrieves or sets the text of the object as a string. + * Retrieves or sets the text of the object as a string. */ text: string; } @@ -16980,9 +16992,9 @@ declare function addEventListener(type: "waiting", listener: (ev: Event) => any, declare function addEventListener(type: "wheel", listener: (ev: WheelEvent) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; ///////////////////////////// -/// WorkerGlobalScope APIs +/// WorkerGlobalScope APIs ///////////////////////////// -// These are only available in a Web Worker +// These are only available in a Web Worker declare function importScripts(...urls: string[]): void; @@ -17015,7 +17027,7 @@ interface TextStreamBase { /** * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If + * It is not necessary to close standard streams; they close automatically when the process ends. If * you close a standard stream, be aware that any other pointers to that standard stream become invalid. */ Close(): void; From 0fe0ff79436201727fce6b47ccb923d21d145ad8 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 13 Nov 2017 10:55:33 -0800 Subject: [PATCH 54/69] Add test --- .../reference/tsxFragmentChildrenCheck.js | 68 +++++++++++++++++++ .../tsxFragmentChildrenCheck.symbols | 58 ++++++++++++++++ .../reference/tsxFragmentChildrenCheck.types | 68 +++++++++++++++++++ .../compiler/tsxFragmentChildrenCheck.ts | 34 ++++++++++ 4 files changed, 228 insertions(+) create mode 100644 tests/baselines/reference/tsxFragmentChildrenCheck.js create mode 100644 tests/baselines/reference/tsxFragmentChildrenCheck.symbols create mode 100644 tests/baselines/reference/tsxFragmentChildrenCheck.types create mode 100644 tests/cases/compiler/tsxFragmentChildrenCheck.ts diff --git a/tests/baselines/reference/tsxFragmentChildrenCheck.js b/tests/baselines/reference/tsxFragmentChildrenCheck.js new file mode 100644 index 00000000000..bca4527cffe --- /dev/null +++ b/tests/baselines/reference/tsxFragmentChildrenCheck.js @@ -0,0 +1,68 @@ +//// [tests/cases/compiler/tsxFragmentChildrenCheck.ts] //// + +//// [my-component.tsx] +declare var React: any; + +export function MyComponent(props: any) { + return my component; +} + +//// [file1.tsx] +import * as React from 'react' +import { MyComponent } from './my-component' + +const MY_STRING: string = 'Ceci n\'est pas une string.' +const MY_CLASSNAME: string = 'jeclass' + +class RenderString extends React.PureComponent { + render() { + return ( + <> + + { MY_STRING } + + + ) + } +} + +export default RenderString + +//// [my-component.js] +"use strict"; +exports.__esModule = true; +function MyComponent(props) { + return React.createElement("span", null, "my component"); +} +exports.MyComponent = MyComponent; +//// [file1.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var React = require("react"); +var my_component_1 = require("./my-component"); +var MY_STRING = 'Ceci n\'est pas une string.'; +var MY_CLASSNAME = 'jeclass'; +var RenderString = /** @class */ (function (_super) { + __extends(RenderString, _super); + function RenderString() { + return _super !== null && _super.apply(this, arguments) || this; + } + RenderString.prototype.render = function () { + return (React.createElement(React.Fragment, null, + React.createElement(my_component_1.MyComponent, null), + React.createElement("span", null, MY_STRING), + React.createElement("span", { className: MY_CLASSNAME }))); + }; + return RenderString; +}(React.PureComponent)); +exports["default"] = RenderString; diff --git a/tests/baselines/reference/tsxFragmentChildrenCheck.symbols b/tests/baselines/reference/tsxFragmentChildrenCheck.symbols new file mode 100644 index 00000000000..cb00046a233 --- /dev/null +++ b/tests/baselines/reference/tsxFragmentChildrenCheck.symbols @@ -0,0 +1,58 @@ +=== tests/cases/compiler/my-component.tsx === +declare var React: any; +>React : Symbol(React, Decl(my-component.tsx, 0, 11)) + +export function MyComponent(props: any) { +>MyComponent : Symbol(MyComponent, Decl(my-component.tsx, 0, 23)) +>props : Symbol(props, Decl(my-component.tsx, 2, 28)) + + return my component; +>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2461, 51)) +>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2461, 51)) +} + +=== tests/cases/compiler/file1.tsx === +import * as React from 'react' +>React : Symbol(React, Decl(file1.tsx, 0, 6)) + +import { MyComponent } from './my-component' +>MyComponent : Symbol(MyComponent, Decl(file1.tsx, 1, 8)) + +const MY_STRING: string = 'Ceci n\'est pas une string.' +>MY_STRING : Symbol(MY_STRING, Decl(file1.tsx, 3, 5)) + +const MY_CLASSNAME: string = 'jeclass' +>MY_CLASSNAME : Symbol(MY_CLASSNAME, Decl(file1.tsx, 4, 5)) + +class RenderString extends React.PureComponent { +>RenderString : Symbol(RenderString, Decl(file1.tsx, 4, 38)) +>React.PureComponent : Symbol(React.PureComponent, Decl(react.d.ts, 180, 5)) +>React : Symbol(React, Decl(file1.tsx, 0, 6)) +>PureComponent : Symbol(React.PureComponent, Decl(react.d.ts, 180, 5)) + + render() { +>render : Symbol(RenderString.render, Decl(file1.tsx, 6, 58)) + + return ( + <> + +>MyComponent : Symbol(MyComponent, Decl(file1.tsx, 1, 8)) + + { MY_STRING } +>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2461, 51)) +>MY_STRING : Symbol(MY_STRING, Decl(file1.tsx, 3, 5)) +>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2461, 51)) + + +>span : Symbol(JSX.IntrinsicElements.span, Decl(react.d.ts, 2461, 51)) +>className : Symbol(className, Decl(file1.tsx, 12, 13)) +>MY_CLASSNAME : Symbol(MY_CLASSNAME, Decl(file1.tsx, 4, 5)) + + + ) + } +} + +export default RenderString +>RenderString : Symbol(RenderString, Decl(file1.tsx, 4, 38)) + diff --git a/tests/baselines/reference/tsxFragmentChildrenCheck.types b/tests/baselines/reference/tsxFragmentChildrenCheck.types new file mode 100644 index 00000000000..c746b4012fb --- /dev/null +++ b/tests/baselines/reference/tsxFragmentChildrenCheck.types @@ -0,0 +1,68 @@ +=== tests/cases/compiler/my-component.tsx === +declare var React: any; +>React : any + +export function MyComponent(props: any) { +>MyComponent : (props: any) => JSX.Element +>props : any + + return my component; +>my component : JSX.Element +>span : any +>span : any +} + +=== tests/cases/compiler/file1.tsx === +import * as React from 'react' +>React : typeof React + +import { MyComponent } from './my-component' +>MyComponent : (props: any) => JSX.Element + +const MY_STRING: string = 'Ceci n\'est pas une string.' +>MY_STRING : string +>'Ceci n\'est pas une string.' : "Ceci n'est pas une string." + +const MY_CLASSNAME: string = 'jeclass' +>MY_CLASSNAME : string +>'jeclass' : "jeclass" + +class RenderString extends React.PureComponent { +>RenderString : RenderString +>React.PureComponent : React.PureComponent +>React : typeof React +>PureComponent : typeof React.PureComponent + + render() { +>render : () => JSX.Element + + return ( +>( <> { MY_STRING } ) : JSX.Element + + <> +><> { MY_STRING } : JSX.Element + + +> : JSX.Element +>MyComponent : (props: any) => JSX.Element + + { MY_STRING } +>{ MY_STRING } : JSX.Element +>span : any +>MY_STRING : string +>span : any + + +> : JSX.Element +>span : any +>className : string +>MY_CLASSNAME : string + + + ) + } +} + +export default RenderString +>RenderString : RenderString + diff --git a/tests/cases/compiler/tsxFragmentChildrenCheck.ts b/tests/cases/compiler/tsxFragmentChildrenCheck.ts new file mode 100644 index 00000000000..f49835404b4 --- /dev/null +++ b/tests/cases/compiler/tsxFragmentChildrenCheck.ts @@ -0,0 +1,34 @@ +// @jsx: react +// @noUnusedLocals: true +// @noLib: true +// @skipLibCheck: true +// @libFiles: react.d.ts,lib.d.ts + +// @Filename: my-component.tsx +declare var React: any; + +export function MyComponent(props: any) { + return my component; +} + +// @Filename: file1.tsx + +import * as React from 'react' +import { MyComponent } from './my-component' + +const MY_STRING: string = 'Ceci n\'est pas une string.' +const MY_CLASSNAME: string = 'jeclass' + +class RenderString extends React.PureComponent { + render() { + return ( + <> + + { MY_STRING } + + + ) + } +} + +export default RenderString \ No newline at end of file From 4c26426a6931a96d7b311d2c9310d4192ac11842 Mon Sep 17 00:00:00 2001 From: uniqueiniquity Date: Mon, 13 Nov 2017 11:06:05 -0800 Subject: [PATCH 55/69] Update baseline --- tests/baselines/reference/jsxFactoryAndFragment.errors.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/jsxFactoryAndFragment.errors.txt b/tests/baselines/reference/jsxFactoryAndFragment.errors.txt index d5dcffb152a..bec2ea5cc0f 100644 --- a/tests/baselines/reference/jsxFactoryAndFragment.errors.txt +++ b/tests/baselines/reference/jsxFactoryAndFragment.errors.txt @@ -1,8 +1,9 @@ tests/cases/compiler/jsxFactoryAndFragment.tsx(3,1): error TS17016: JSX fragment is not supported when using --jsxFactory tests/cases/compiler/jsxFactoryAndFragment.tsx(4,1): error TS17016: JSX fragment is not supported when using --jsxFactory +tests/cases/compiler/jsxFactoryAndFragment.tsx(4,17): error TS17016: JSX fragment is not supported when using --jsxFactory -==== tests/cases/compiler/jsxFactoryAndFragment.tsx (2 errors) ==== +==== tests/cases/compiler/jsxFactoryAndFragment.tsx (3 errors) ==== declare var h: any; <>; @@ -10,4 +11,6 @@ tests/cases/compiler/jsxFactoryAndFragment.tsx(4,1): error TS17016: JSX fragment !!! error TS17016: JSX fragment is not supported when using --jsxFactory <>1<>2.12.2; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS17016: JSX fragment is not supported when using --jsxFactory + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS17016: JSX fragment is not supported when using --jsxFactory \ No newline at end of file From 9d8a854ea295a470d7cc95921804f5f9d642facb Mon Sep 17 00:00:00 2001 From: Andy Date: Mon, 13 Nov 2017 13:22:09 -0800 Subject: [PATCH 56/69] Revert "Break out of speculative parsing on bad parameter initializer (#19158)" (#19975) This reverts commit e7df83263df9433d2b27a2b86e9d198fca68bd92. --- src/compiler/parser.ts | 180 +++++------------- .../parserArrowFunctionExpression7.js | 16 -- .../parserArrowFunctionExpression7.symbols | 10 - .../parserArrowFunctionExpression7.types | 13 -- .../parserArrowFunctionExpression7.ts | 7 - 5 files changed, 50 insertions(+), 176 deletions(-) delete mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.js delete mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.symbols delete mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.types delete mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 64cd8219a01..79b5eb30c49 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -531,18 +531,6 @@ namespace ts { let TokenConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; let IdentifierConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; let SourceFileConstructor: new (kind: SyntaxKind, pos: number, end: number) => Node; - interface Fail extends Node { kind: SyntaxKind.Unknown; } - interface FailList extends NodeArray { pos: -1; } - let Fail: Fail; - let FailList: FailList; - function isFail(x: Node | undefined): x is Fail { - Debug.assert(Fail !== undefined); - return x === Fail; - } - function isFailList(x: NodeArray | undefined): x is FailList { - Debug.assert(Fail !== undefined); - return x === FailList; - } // tslint:enable variable-name let sourceFile: SourceFile; @@ -693,9 +681,6 @@ namespace ts { IdentifierConstructor = objectAllocator.getIdentifierConstructor(); SourceFileConstructor = objectAllocator.getSourceFileConstructor(); - Fail = createNode(SyntaxKind.Unknown) as Fail; - FailList = createNodeArray([], -1) as FailList; - sourceText = _sourceText; syntaxCursor = _syntaxCursor; @@ -751,7 +736,7 @@ namespace ts { processReferenceComments(sourceFile); sourceFile.statements = parseList(ParsingContext.SourceElements, parseStatement); - Debug.assertEqual(token(), SyntaxKind.EndOfFileToken); + Debug.assert(token() === SyntaxKind.EndOfFileToken); sourceFile.endOfFileToken = addJSDocComment(parseTokenNode() as EndOfFileToken); setExternalModuleIndicator(sourceFile); @@ -1018,7 +1003,7 @@ namespace ts { return currentToken = scanner.scanJsxAttributeValue(); } - function speculationHelper(callback: () => T, isLookAhead: boolean): T | undefined { + function speculationHelper(callback: () => T, isLookAhead: boolean): T { // Keep track of the state we'll need to rollback to if lookahead fails (or if the // caller asked us to always reset our state). const saveToken = currentToken; @@ -1030,7 +1015,6 @@ namespace ts { // descent nature of our parser. However, we still store this here just so we can // assert that invariant holds. const saveContextFlags = contextFlags; - const saveParsingContext = parsingContext; // If we're only looking ahead, then tell the scanner to only lookahead as well. // Otherwise, if we're actually speculatively parsing, then tell the scanner to do the @@ -1039,8 +1023,7 @@ namespace ts { ? scanner.lookAhead(callback) : scanner.tryScan(callback); - Debug.assertEqual(saveContextFlags, contextFlags); - Debug.assertEqual(saveParsingContext, parsingContext); + Debug.assert(saveContextFlags === contextFlags); // If our callback returned something 'falsy' or we're just looking ahead, // then unconditionally restore us to where we were. @@ -1594,7 +1577,7 @@ namespace ts { return createNodeArray(list, listPos); } - function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { + function parseListElement(parsingContext: ParsingContext, parseElement: () => T): T { const node = currentNode(parsingContext); if (node) { return consumeNode(node); @@ -1918,24 +1901,17 @@ namespace ts { } // Parses a comma-delimited list of elements - function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray; - function parseDelimitedList(kind: ParsingContext, parseElement: () => T | Fail, considerSemicolonAsDelimiter?: boolean): NodeArray | FailList; - function parseDelimitedList(kind: ParsingContext, parseElement: () => T | Fail, considerSemicolonAsDelimiter?: boolean): NodeArray | FailList { + function parseDelimitedList(kind: ParsingContext, parseElement: () => T, considerSemicolonAsDelimiter?: boolean): NodeArray { const saveParsingContext = parsingContext; parsingContext |= 1 << kind; - const list: T[] = []; + const list = []; const listPos = getNodePos(); let commaStart = -1; // Meaning the previous token was not a comma while (true) { if (isListElement(kind, /*inErrorRecovery*/ false)) { const startPos = scanner.getStartPos(); - const elem = parseListElement(kind, parseElement); - if (isFail(elem)) { - parsingContext = saveParsingContext; - return FailList; - } - list.push(elem); + list.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); if (parseOptional(SyntaxKind.CommaToken)) { @@ -2295,13 +2271,7 @@ namespace ts { isStartOfType(/*inStartOfParameter*/ true); } - function tryParseParameter(): ParameterDeclaration | Fail { - return parseParameterWorker(/*inSpeculation*/ true); - } - function parseParameter(): ParameterDeclaration { - return parseParameterWorker(/*inSpeculation*/ false) as ParameterDeclaration; - } - function parseParameterWorker(inSpeculation: boolean): ParameterDeclaration | Fail { + function parseParameter(requireEqualsToken?: boolean): ParameterDeclaration { const node = createNode(SyntaxKind.Parameter); if (token() === SyntaxKind.ThisKeyword) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -2315,11 +2285,7 @@ namespace ts { // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] - const name = parseIdentifierOrPattern(inSpeculation); - if (isFail(name)) { - return Fail; - } - node.name = name; + node.name = parseIdentifierOrPattern(); if (getFullWidth(node.name) === 0 && !hasModifiers(node) && isModifierKind(token())) { // in cases like // 'use strict' @@ -2334,27 +2300,20 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - const initializer = parseInitializer(/*inParameter*/ true, inSpeculation); - if (isFail(initializer)) { - return Fail; - } - node.initializer = initializer; + node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); return addJSDocComment(finishNode(node)); } - /** @return 'true' on success. */ - function fillSignature(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, flags: SignatureFlags, signature: SignatureDeclaration, inSpeculation?: boolean): boolean { + function fillSignature( + returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, + flags: SignatureFlags, + signature: SignatureDeclaration): void { if (!(flags & SignatureFlags.JSDoc)) { signature.typeParameters = parseTypeParameters(); } - const parameters = parseParameterList(flags, inSpeculation); - if (isFailList(parameters)) { - return false; - } - signature.parameters = parameters; + signature.parameters = parseParameterList(flags); signature.type = parseReturnType(returnToken, !!(flags & SignatureFlags.Type)); - return true; } function parseReturnType(returnToken: SyntaxKind.ColonToken | SyntaxKind.EqualsGreaterThanToken, isType: boolean): TypeNode | undefined { @@ -2377,7 +2336,7 @@ namespace ts { return false; } - function parseParameterList(flags: SignatureFlags, inSpeculation: boolean): NodeArray | FailList { + function parseParameterList(flags: SignatureFlags) { // FormalParameters [Yield,Await]: (modified) // [empty] // FormalParameterList[?Yield,Await] @@ -2398,9 +2357,9 @@ namespace ts { setYieldContext(!!(flags & SignatureFlags.Yield)); setAwaitContext(!!(flags & SignatureFlags.Await)); - const result = parseDelimitedList( - ParsingContext.Parameters, - flags & SignatureFlags.JSDoc ? parseJSDocParameter : inSpeculation ? tryParseParameter : parseParameter); + const result = parseDelimitedList(ParsingContext.Parameters, + flags & SignatureFlags.JSDoc ? parseJSDocParameter : () => parseParameter(!!(flags & SignatureFlags.RequireCompleteParameterList))); + setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -3073,16 +3032,14 @@ namespace ts { while ((operatorToken = parseOptionalToken(SyntaxKind.CommaToken))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } + if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } - return expr; } - function parseInitializer(inParameter: boolean): Expression | undefined; - function parseInitializer(inParameter: boolean, inSpeculation?: boolean): Expression | Fail | undefined; - function parseInitializer(inParameter: boolean, inSpeculation?: boolean): Expression | Fail | undefined { + function parseInitializer(inParameter: boolean, requireEqualsToken?: boolean): Expression { if (token() !== SyntaxKind.EqualsToken) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse @@ -3097,8 +3054,12 @@ namespace ts { // do not try to parse initializer return undefined; } - if (inSpeculation) { - return Fail; + if (inParameter && requireEqualsToken) { + // = is required when speculatively parsing arrow function parameters, + // so return a fake initializer as a signal that the equals token was missing + const result = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics._0_expected, "=") as Identifier; + result.escapedText = "= not found" as __String; + return result; } } @@ -3264,7 +3225,7 @@ namespace ts { // it out, but don't allow any ambiguity, and return 'undefined' if this could be an // expression instead. const arrowFunction = triState === Tristate.True - ? parseParenthesizedArrowFunctionExpressionHead(/*inSpeculation*/ false) + ? parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ true) : tryParse(parsePossibleParenthesizedArrowFunctionExpressionHead); if (!arrowFunction) { @@ -3412,7 +3373,7 @@ namespace ts { } function parsePossibleParenthesizedArrowFunctionExpressionHead(): ArrowFunction { - return parseParenthesizedArrowFunctionExpressionHead(/*inSpeculation*/ true); + return parseParenthesizedArrowFunctionExpressionHead(/*allowAmbiguity*/ false); } function tryParseAsyncSimpleArrowFunctionExpression(): ArrowFunction | undefined { @@ -3448,7 +3409,7 @@ namespace ts { return Tristate.False; } - function parseParenthesizedArrowFunctionExpressionHead(inSpeculation: boolean): ArrowFunction | undefined { + function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { const node = createNode(SyntaxKind.ArrowFunction); node.modifiers = parseModifiersForArrowFunction(); const isAsync = hasModifier(node, ModifierFlags.Async) ? SignatureFlags.Await : SignatureFlags.None; @@ -3459,10 +3420,7 @@ namespace ts { // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - - if (!fillSignature(SyntaxKind.ColonToken, isAsync | (inSpeculation ? SignatureFlags.RequireCompleteParameterList : SignatureFlags.None), node, inSpeculation)) { - return undefined; - } + fillSignature(SyntaxKind.ColonToken, isAsync | (allowAmbiguity ? SignatureFlags.None : SignatureFlags.RequireCompleteParameterList), node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { @@ -3477,7 +3435,8 @@ namespace ts { // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (inSpeculation && token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) { + if (!allowAmbiguity && ((token() !== SyntaxKind.EqualsGreaterThanToken && token() !== SyntaxKind.OpenBraceToken) || + find(node.parameters, p => p.initializer && ts.isIdentifier(p.initializer) && p.initializer.escapedText === "= not found"))) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } @@ -4615,6 +4574,7 @@ namespace ts { if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } + const node = createNode(SyntaxKind.FunctionExpression); node.modifiers = parseModifiers(); parseExpected(SyntaxKind.FunctionKeyword); @@ -4630,6 +4590,7 @@ namespace ts { fillSignature(SyntaxKind.ColonToken, isGenerator | isAsync, node); node.body = parseFunctionBlock(isGenerator | isAsync); + if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -4692,6 +4653,7 @@ namespace ts { } const block = parseBlock(!!(flags & SignatureFlags.IgnoreMissingOpenBrace), diagnosticMessage); + if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); } @@ -5265,38 +5227,18 @@ namespace ts { // DECLARATIONS - function tryParseArrayBindingElement(): ArrayBindingElement | Fail { - return parseArrayBindingElementWorker(/*inSpeculation*/ true); - } function parseArrayBindingElement(): ArrayBindingElement { - return parseArrayBindingElementWorker(/*inSpeculation*/ false) as ArrayBindingElement; - } - function parseArrayBindingElementWorker(inSpeculation: boolean): ArrayBindingElement | Fail { if (token() === SyntaxKind.CommaToken) { return createNode(SyntaxKind.OmittedExpression); } const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); - const name = parseIdentifierOrPattern(inSpeculation); - if (isFail(name)) { - return Fail; - } - node.name = name; - const init = parseInitializer(/*inParameter*/ false, inSpeculation); - if (isFail(init)) { - return Fail; - } - node.initializer = init; + node.name = parseIdentifierOrPattern(); + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } - function tryParseObjectBindingElement(): BindingElement | Fail { - return parseObjectBindingElementWorker(/*inSpeculation*/ true); - } function parseObjectBindingElement(): BindingElement { - return parseObjectBindingElementWorker(/*inSpeculation*/ false) as BindingElement; - } - function parseObjectBindingElementWorker(inSpeculation: boolean): BindingElement | Fail { const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); const tokenIsIdentifier = isIdentifier(); @@ -5307,46 +5249,24 @@ namespace ts { else { parseExpected(SyntaxKind.ColonToken); node.propertyName = propertyName; - const name = parseIdentifierOrPattern(inSpeculation); - if (isFail(name)) { - return Fail; - } - node.name = name; + node.name = parseIdentifierOrPattern(); } - const init = parseInitializer(/*inParameter*/ false, inSpeculation); - if (isFail(init)) { - return Fail; - } - node.initializer = init; + node.initializer = parseInitializer(/*inParameter*/ false); return finishNode(node); } - function parseObjectBindingPattern(inSpeculation: boolean): ObjectBindingPattern | Fail { + function parseObjectBindingPattern(): ObjectBindingPattern { const node = createNode(SyntaxKind.ObjectBindingPattern); parseExpected(SyntaxKind.OpenBraceToken); - const elements = parseDelimitedList( - ParsingContext.ObjectBindingElements, - inSpeculation ? tryParseObjectBindingElement : parseObjectBindingElement, - /*considerSemicolonAsDelimiter*/ undefined); - if (isFailList(elements)) { - return Fail; - } - node.elements = elements; + node.elements = parseDelimitedList(ParsingContext.ObjectBindingElements, parseObjectBindingElement); parseExpected(SyntaxKind.CloseBraceToken); return finishNode(node); } - function parseArrayBindingPattern(inSpeculation: boolean): ArrayBindingPattern | Fail { + function parseArrayBindingPattern(): ArrayBindingPattern { const node = createNode(SyntaxKind.ArrayBindingPattern); parseExpected(SyntaxKind.OpenBracketToken); - const elements = parseDelimitedList( - ParsingContext.ArrayBindingElements, - inSpeculation ? tryParseArrayBindingElement : parseArrayBindingElement, - /*considerSemicolonAsDelimiter*/ undefined); - if (isFailList(elements)) { - return Fail; - } - node.elements = elements; + node.elements = parseDelimitedList(ParsingContext.ArrayBindingElements, parseArrayBindingElement); parseExpected(SyntaxKind.CloseBracketToken); return finishNode(node); } @@ -5355,14 +5275,12 @@ namespace ts { return token() === SyntaxKind.OpenBraceToken || token() === SyntaxKind.OpenBracketToken || isIdentifier(); } - function parseIdentifierOrPattern(): Identifier | BindingPattern; - function parseIdentifierOrPattern(inSpeculation: boolean): Identifier | BindingPattern | Fail; - function parseIdentifierOrPattern(inSpeculation?: boolean): Identifier | BindingPattern | Fail { + function parseIdentifierOrPattern(): Identifier | BindingPattern { if (token() === SyntaxKind.OpenBracketToken) { - return parseArrayBindingPattern(inSpeculation); + return parseArrayBindingPattern(); } if (token() === SyntaxKind.OpenBraceToken) { - return parseObjectBindingPattern(inSpeculation); + return parseObjectBindingPattern(); } return parseIdentifier(); } @@ -5410,7 +5328,9 @@ namespace ts { else { const savedDisallowIn = inDisallowInContext(); setDisallowInContext(inForStatementInitializer); + node.declarations = parseDelimitedList(ParsingContext.VariableDeclarations, parseVariableDeclaration); + setDisallowInContext(savedDisallowIn); } @@ -5508,7 +5428,7 @@ namespace ts { } } - function parseNonParameterInitializer(): Expression | undefined { + function parseNonParameterInitializer() { return parseInitializer(/*inParameter*/ false); } diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.js b/tests/baselines/reference/parserArrowFunctionExpression7.js deleted file mode 100644 index 0646a1bf438..00000000000 --- a/tests/baselines/reference/parserArrowFunctionExpression7.js +++ /dev/null @@ -1,16 +0,0 @@ -//// [parserArrowFunctionExpression7.ts] -({ - async m() { - for (;;) { - } - } -}); - - -//// [parserArrowFunctionExpression7.js] -({ - async m() { - for (;;) { - } - } -}); diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.symbols b/tests/baselines/reference/parserArrowFunctionExpression7.symbols deleted file mode 100644 index 0dbc2cf05a1..00000000000 --- a/tests/baselines/reference/parserArrowFunctionExpression7.symbols +++ /dev/null @@ -1,10 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === -({ - async m() { ->m : Symbol(m, Decl(parserArrowFunctionExpression7.ts, 0, 2)) - - for (;;) { - } - } -}); - diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.types b/tests/baselines/reference/parserArrowFunctionExpression7.types deleted file mode 100644 index 072a1548bd2..00000000000 --- a/tests/baselines/reference/parserArrowFunctionExpression7.types +++ /dev/null @@ -1,13 +0,0 @@ -=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === -({ ->({ async m() { for (;;) { } }}) : { m(): Promise; } ->{ async m() { for (;;) { } }} : { m(): Promise; } - - async m() { ->m : () => Promise - - for (;;) { - } - } -}); - diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts deleted file mode 100644 index 65911cf0fc6..00000000000 --- a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts +++ /dev/null @@ -1,7 +0,0 @@ -// @target: esnext -({ - async m() { - for (;;) { - } - } -}); From ce29b4c36d04cc22b8b513b4ff1fc84e084f6628 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 13 Nov 2017 14:38:14 -0800 Subject: [PATCH 57/69] Use UTF8 BOM in emit --- src/compiler/sys.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 529ece36fa6..a6e5cd7a392 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -348,7 +348,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { // If a BOM is required, emit one if (writeByteOrderMark) { - data = "\uFEFF" + data; + data = "\u00EF\u00BB\u00BF" + data; } let fd: number; @@ -549,7 +549,7 @@ namespace ts { writeFile(path: string, data: string, writeByteOrderMark?: boolean) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = "\uFEFF" + data; + data = "\u00EF\u00BB\u00BF" + data; } ChakraHost.writeFile(path, data); From b3d3b781ab9effea0bcbd0ba8689e4f8aee85669 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 15:39:08 -0800 Subject: [PATCH 58/69] Treat `{}` in `T = {}` as `any` in JS files (#19977) --- src/compiler/checker.ts | 5 +- .../defaultPropsEmptyCurlyBecomesAnyForJs.js | 76 +++++++++++++++++ ...aultPropsEmptyCurlyBecomesAnyForJs.symbols | 70 ++++++++++++++++ ...efaultPropsEmptyCurlyBecomesAnyForJs.types | 81 +++++++++++++++++++ .../defaultPropsEmptyCurlyBecomesAnyForJs.ts | 26 ++++++ 5 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.js create mode 100644 tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.symbols create mode 100644 tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.types create mode 100644 tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 85033816766..f983abc9cfe 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6454,7 +6454,10 @@ namespace ts { } for (let i = numTypeArguments; i < numTypeParameters; i++) { const mapper = createTypeMapper(typeParameters, typeArguments); - const defaultType = getDefaultFromTypeParameter(typeParameters[i]); + let defaultType = getDefaultFromTypeParameter(typeParameters[i]); + if (defaultType && isTypeIdenticalTo(defaultType, emptyObjectType) && isJavaScriptImplicitAny) { + defaultType = anyType; + } typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : getDefaultTypeArgumentType(isJavaScriptImplicitAny); } } diff --git a/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.js b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.js new file mode 100644 index 00000000000..63e45ff68b0 --- /dev/null +++ b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.js @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts] //// + +//// [library.d.ts] +export class Foo { + props: T; + state: U; + constructor(props: T, state: U); +} + +//// [component.js] +import { Foo } from "./library"; +export class MyFoo extends Foo { + member; +} + +//// [typed_component.ts] +import { MyFoo } from "./component"; +export class TypedFoo extends MyFoo { + constructor() { + super({x: "string", y: 42}, { value: undefined }); + this.props.x; + this.props.y; + this.state.value; + this.member; + } +} + +//// [component.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var library_1 = require("./library"); +var MyFoo = /** @class */ (function (_super) { + __extends(MyFoo, _super); + function MyFoo() { + return _super !== null && _super.apply(this, arguments) || this; + } + return MyFoo; +}(library_1.Foo)); +exports.MyFoo = MyFoo; +//// [typed_component.js] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var component_1 = require("./component"); +var TypedFoo = /** @class */ (function (_super) { + __extends(TypedFoo, _super); + function TypedFoo() { + var _this = _super.call(this, { x: "string", y: 42 }, { value: undefined }) || this; + _this.props.x; + _this.props.y; + _this.state.value; + _this.member; + return _this; + } + return TypedFoo; +}(component_1.MyFoo)); +exports.TypedFoo = TypedFoo; diff --git a/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.symbols b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.symbols new file mode 100644 index 00000000000..ba18a4ecca9 --- /dev/null +++ b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.symbols @@ -0,0 +1,70 @@ +=== tests/cases/compiler/library.d.ts === +export class Foo { +>Foo : Symbol(Foo, Decl(library.d.ts, --, --)) +>T : Symbol(T, Decl(library.d.ts, --, --)) +>U : Symbol(U, Decl(library.d.ts, --, --)) + + props: T; +>props : Symbol(Foo.props, Decl(library.d.ts, --, --)) +>T : Symbol(T, Decl(library.d.ts, --, --)) + + state: U; +>state : Symbol(Foo.state, Decl(library.d.ts, --, --)) +>U : Symbol(U, Decl(library.d.ts, --, --)) + + constructor(props: T, state: U); +>props : Symbol(props, Decl(library.d.ts, --, --)) +>T : Symbol(T, Decl(library.d.ts, --, --)) +>state : Symbol(state, Decl(library.d.ts, --, --)) +>U : Symbol(U, Decl(library.d.ts, --, --)) +} + +=== tests/cases/compiler/component.js === +import { Foo } from "./library"; +>Foo : Symbol(Foo, Decl(component.js, 0, 8)) + +export class MyFoo extends Foo { +>MyFoo : Symbol(MyFoo, Decl(component.js, 0, 32)) +>Foo : Symbol(Foo, Decl(component.js, 0, 8)) + + member; +>member : Symbol(MyFoo.member, Decl(component.js, 1, 32)) +} + +=== tests/cases/compiler/typed_component.ts === +import { MyFoo } from "./component"; +>MyFoo : Symbol(MyFoo, Decl(typed_component.ts, 0, 8)) + +export class TypedFoo extends MyFoo { +>TypedFoo : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>MyFoo : Symbol(MyFoo, Decl(typed_component.ts, 0, 8)) + + constructor() { + super({x: "string", y: 42}, { value: undefined }); +>super : Symbol(MyFoo, Decl(component.js, 0, 32)) +>x : Symbol(x, Decl(typed_component.ts, 3, 15)) +>y : Symbol(y, Decl(typed_component.ts, 3, 27)) +>value : Symbol(value, Decl(typed_component.ts, 3, 37)) +>undefined : Symbol(undefined) + + this.props.x; +>this.props : Symbol(Foo.props, Decl(library.d.ts, --, --)) +>this : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>props : Symbol(Foo.props, Decl(library.d.ts, --, --)) + + this.props.y; +>this.props : Symbol(Foo.props, Decl(library.d.ts, --, --)) +>this : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>props : Symbol(Foo.props, Decl(library.d.ts, --, --)) + + this.state.value; +>this.state : Symbol(Foo.state, Decl(library.d.ts, --, --)) +>this : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>state : Symbol(Foo.state, Decl(library.d.ts, --, --)) + + this.member; +>this.member : Symbol(MyFoo.member, Decl(component.js, 1, 32)) +>this : Symbol(TypedFoo, Decl(typed_component.ts, 0, 36)) +>member : Symbol(MyFoo.member, Decl(component.js, 1, 32)) + } +} diff --git a/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.types b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.types new file mode 100644 index 00000000000..4e4bab57696 --- /dev/null +++ b/tests/baselines/reference/defaultPropsEmptyCurlyBecomesAnyForJs.types @@ -0,0 +1,81 @@ +=== tests/cases/compiler/library.d.ts === +export class Foo { +>Foo : Foo +>T : T +>U : U + + props: T; +>props : T +>T : T + + state: U; +>state : U +>U : U + + constructor(props: T, state: U); +>props : T +>T : T +>state : U +>U : U +} + +=== tests/cases/compiler/component.js === +import { Foo } from "./library"; +>Foo : typeof Foo + +export class MyFoo extends Foo { +>MyFoo : MyFoo +>Foo : Foo + + member; +>member : any +} + +=== tests/cases/compiler/typed_component.ts === +import { MyFoo } from "./component"; +>MyFoo : typeof MyFoo + +export class TypedFoo extends MyFoo { +>TypedFoo : TypedFoo +>MyFoo : MyFoo + + constructor() { + super({x: "string", y: 42}, { value: undefined }); +>super({x: "string", y: 42}, { value: undefined }) : void +>super : typeof MyFoo +>{x: "string", y: 42} : { x: string; y: number; } +>x : string +>"string" : "string" +>y : number +>42 : 42 +>{ value: undefined } : { value: undefined; } +>value : undefined +>undefined : undefined + + this.props.x; +>this.props.x : any +>this.props : any +>this : this +>props : any +>x : any + + this.props.y; +>this.props.y : any +>this.props : any +>this : this +>props : any +>y : any + + this.state.value; +>this.state.value : any +>this.state : any +>this : this +>state : any +>value : any + + this.member; +>this.member : any +>this : this +>member : any + } +} diff --git a/tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts b/tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts new file mode 100644 index 00000000000..2375ed2a5ba --- /dev/null +++ b/tests/cases/compiler/defaultPropsEmptyCurlyBecomesAnyForJs.ts @@ -0,0 +1,26 @@ +// @allowJs: true +// @outDir: ./built +// @filename: library.d.ts +export class Foo { + props: T; + state: U; + constructor(props: T, state: U); +} + +// @filename: component.js +import { Foo } from "./library"; +export class MyFoo extends Foo { + member; +} + +// @filename: typed_component.ts +import { MyFoo } from "./component"; +export class TypedFoo extends MyFoo { + constructor() { + super({x: "string", y: 42}, { value: undefined }); + this.props.x; + this.props.y; + this.state.value; + this.member; + } +} \ No newline at end of file From 2f941f33e238e5fb25e710cb74c35549cd694eb6 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 13 Nov 2017 16:36:13 -0800 Subject: [PATCH 59/69] Make BOM a constant --- src/compiler/sys.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index a6e5cd7a392..aa928cdaacd 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -125,6 +125,8 @@ namespace ts { }; export let sys: System = (() => { + const utf8ByteOrderMark = "\u00EF\u00BB\u00BF"; + function getNodeSystem(): System { const _fs = require("fs"); const _path = require("path"); @@ -348,7 +350,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark?: boolean): void { // If a BOM is required, emit one if (writeByteOrderMark) { - data = "\u00EF\u00BB\u00BF" + data; + data = utf8ByteOrderMark + data; } let fd: number; @@ -549,7 +551,7 @@ namespace ts { writeFile(path: string, data: string, writeByteOrderMark?: boolean) { // If a BOM is required, emit one if (writeByteOrderMark) { - data = "\u00EF\u00BB\u00BF" + data; + data = utf8ByteOrderMark + data; } ChakraHost.writeFile(path, data); From 3d602936e01a9f19f0f4eba2141837c349aeafd5 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 16:40:08 -0800 Subject: [PATCH 60/69] Handle binding elements while looking for invalid `await` and `yield` (#19972) * Handle omitting a node in addCustomPrologue, account for binding elemnts in isInParameterInitializerBeforeContainingFunction * Use append * Fix lint --- src/compiler/checker.ts | 6 +- src/compiler/factory.ts | 2 +- ...orbiddenInParameterInitializers.errors.txt | 15 ++++ ...essionsForbiddenInParameterInitializers.js | 76 +++++++++++++++++++ ...nsForbiddenInParameterInitializers.symbols | 12 +++ ...ionsForbiddenInParameterInitializers.types | 16 ++++ ...essionsForbiddenInParameterInitializers.ts | 7 ++ 7 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt create mode 100644 tests/baselines/reference/expressionsForbiddenInParameterInitializers.js create mode 100644 tests/baselines/reference/expressionsForbiddenInParameterInitializers.symbols create mode 100644 tests/baselines/reference/expressionsForbiddenInParameterInitializers.types create mode 100644 tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 37905e1047c..a8ba45b8825 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13472,10 +13472,14 @@ namespace ts { } function isInParameterInitializerBeforeContainingFunction(node: Node) { + let inBindingInitializer = false; while (node.parent && !isFunctionLike(node.parent)) { - if (node.parent.kind === SyntaxKind.Parameter && (node.parent).initializer === node) { + if (isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) { return true; } + if (isBindingElement(node.parent) && node.parent.initializer === node) { + inBindingInitializer = true; + } node = node.parent; } diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index e8dfcbc1e94..35d35b40826 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -3709,7 +3709,7 @@ namespace ts { while (statementOffset < numStatements) { const statement = source[statementOffset]; if (getEmitFlags(statement) & EmitFlags.CustomPrologue) { - target.push(visitor ? visitNode(statement, visitor, isStatement) : statement); + append(target, visitor ? visitNode(statement, visitor, isStatement) : statement); } else { break; diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt new file mode 100644 index 00000000000..605b6d78ea3 --- /dev/null +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.errors.txt @@ -0,0 +1,15 @@ +tests/cases/compiler/bar.ts(1,35): error TS2524: 'await' expressions cannot be used in a parameter initializer. +tests/cases/compiler/bar.ts(4,31): error TS2523: 'yield' expressions cannot be used in a parameter initializer. + + +==== tests/cases/compiler/bar.ts (2 errors) ==== + export async function foo({ foo = await import("./bar") }) { + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2524: 'await' expressions cannot be used in a parameter initializer. + } + + export function* foo2({ foo = yield "a" }) { + ~~~~~~~~~ +!!! error TS2523: 'yield' expressions cannot be used in a parameter initializer. + } + \ No newline at end of file diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.js b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.js new file mode 100644 index 00000000000..d66b3c8e06d --- /dev/null +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.js @@ -0,0 +1,76 @@ +//// [bar.ts] +export async function foo({ foo = await import("./bar") }) { +} + +export function* foo2({ foo = yield "a" }) { +} + + +//// [bar.js] +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [0, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +exports.__esModule = true; +function foo(_a) { + var _b = _a.foo, foo = _b === void 0 ? yield Promise.resolve().then(function () { return require("./bar"); }) : _b; + return __awaiter(this, void 0, void 0, function () { + return __generator(this, function (_c) { + return [2 /*return*/]; + }); + }); +} +exports.foo = foo; +function foo2(_a) { + var _b, foo, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + _b = _a.foo; + if (!(_b === void 0)) return [3 /*break*/, 2]; + return [4 /*yield*/, "a"]; + case 1: + _c = _d.sent(); + return [3 /*break*/, 3]; + case 2: + _c = _b; + _d.label = 3; + case 3: + foo = _c; + return [2 /*return*/]; + } + }); +} +exports.foo2 = foo2; diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.symbols b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.symbols new file mode 100644 index 00000000000..6ad101f3c17 --- /dev/null +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/bar.ts === +export async function foo({ foo = await import("./bar") }) { +>foo : Symbol(foo, Decl(bar.ts, 0, 0)) +>foo : Symbol(foo, Decl(bar.ts, 0, 27)) +>"./bar" : Symbol("tests/cases/compiler/bar", Decl(bar.ts, 0, 0)) +} + +export function* foo2({ foo = yield "a" }) { +>foo2 : Symbol(foo2, Decl(bar.ts, 1, 1)) +>foo : Symbol(foo, Decl(bar.ts, 3, 23)) +} + diff --git a/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types new file mode 100644 index 00000000000..1fd11b0513b --- /dev/null +++ b/tests/baselines/reference/expressionsForbiddenInParameterInitializers.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/bar.ts === +export async function foo({ foo = await import("./bar") }) { +>foo : ({ foo }: { foo?: typeof "tests/cases/compiler/bar"; }) => Promise +>foo : typeof "tests/cases/compiler/bar" +>await import("./bar") : typeof "tests/cases/compiler/bar" +>import("./bar") : Promise +>"./bar" : "./bar" +} + +export function* foo2({ foo = yield "a" }) { +>foo2 : ({ foo }: { foo?: any; }) => IterableIterator +>foo : any +>yield "a" : any +>"a" : "a" +} + diff --git a/tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts b/tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts new file mode 100644 index 00000000000..ea4dce15408 --- /dev/null +++ b/tests/cases/compiler/expressionsForbiddenInParameterInitializers.ts @@ -0,0 +1,7 @@ +// @lib: es6 +// @filename: bar.ts +export async function foo({ foo = await import("./bar") }) { +} + +export function* foo2({ foo = yield "a" }) { +} From 7d93434f2cbf2e246a48398423059d7d7fffe07b Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 16:41:29 -0800 Subject: [PATCH 61/69] Fix crash on non-dts-require (#19980) --- src/compiler/checker.ts | 2 +- .../noCrashOnParameterNamedRequire.js | 11 ++++++++ .../noCrashOnParameterNamedRequire.symbols | 14 +++++++++++ .../noCrashOnParameterNamedRequire.types | 25 +++++++++++++++++++ .../noCrashOnParameterNamedRequire.ts | 8 ++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/noCrashOnParameterNamedRequire.js create mode 100644 tests/baselines/reference/noCrashOnParameterNamedRequire.symbols create mode 100644 tests/baselines/reference/noCrashOnParameterNamedRequire.types create mode 100644 tests/cases/compiler/noCrashOnParameterNamedRequire.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a8ba45b8825..0ae9486aa4e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17179,7 +17179,7 @@ namespace ts { if (targetDeclarationKind !== SyntaxKind.Unknown) { const decl = getDeclarationOfKind(resolvedRequire, targetDeclarationKind); // function/variable declaration should be ambient - return !!(decl.flags & NodeFlags.Ambient); + return !!decl && !!(decl.flags & NodeFlags.Ambient); } return false; } diff --git a/tests/baselines/reference/noCrashOnParameterNamedRequire.js b/tests/baselines/reference/noCrashOnParameterNamedRequire.js new file mode 100644 index 00000000000..beb7429a47c --- /dev/null +++ b/tests/baselines/reference/noCrashOnParameterNamedRequire.js @@ -0,0 +1,11 @@ +//// [index.js] +(function(require, module, exports){ + const mod = require("./mod"); + mod.foo; +})(null, null, null); + +//// [index.js] +(function (require, module, exports) { + var mod = require("./mod"); + mod.foo; +})(null, null, null); diff --git a/tests/baselines/reference/noCrashOnParameterNamedRequire.symbols b/tests/baselines/reference/noCrashOnParameterNamedRequire.symbols new file mode 100644 index 00000000000..824a61db10f --- /dev/null +++ b/tests/baselines/reference/noCrashOnParameterNamedRequire.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/index.js === +(function(require, module, exports){ +>require : Symbol(require, Decl(index.js, 0, 10)) +>module : Symbol(module, Decl(index.js, 0, 18)) +>exports : Symbol(exports, Decl(index.js, 0, 26)) + + const mod = require("./mod"); +>mod : Symbol(mod, Decl(index.js, 1, 9)) +>require : Symbol(require, Decl(index.js, 0, 10)) + + mod.foo; +>mod : Symbol(mod, Decl(index.js, 1, 9)) + +})(null, null, null); diff --git a/tests/baselines/reference/noCrashOnParameterNamedRequire.types b/tests/baselines/reference/noCrashOnParameterNamedRequire.types new file mode 100644 index 00000000000..2fe629f9d51 --- /dev/null +++ b/tests/baselines/reference/noCrashOnParameterNamedRequire.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/index.js === +(function(require, module, exports){ +>(function(require, module, exports){ const mod = require("./mod"); mod.foo;})(null, null, null) : void +>(function(require, module, exports){ const mod = require("./mod"); mod.foo;}) : (require: any, module: any, exports: any) => void +>function(require, module, exports){ const mod = require("./mod"); mod.foo;} : (require: any, module: any, exports: any) => void +>require : any +>module : any +>exports : any + + const mod = require("./mod"); +>mod : any +>require("./mod") : any +>require : any +>"./mod" : "./mod" + + mod.foo; +>mod.foo : any +>mod : any +>foo : any + +})(null, null, null); +>null : null +>null : null +>null : null + diff --git a/tests/cases/compiler/noCrashOnParameterNamedRequire.ts b/tests/cases/compiler/noCrashOnParameterNamedRequire.ts new file mode 100644 index 00000000000..bb4b9d53460 --- /dev/null +++ b/tests/cases/compiler/noCrashOnParameterNamedRequire.ts @@ -0,0 +1,8 @@ +// @allowJs: true +// @checkJs: true +// @outDir: ./built +// @filename: index.js +(function(require, module, exports){ + const mod = require("./mod"); + mod.foo; +})(null, null, null); \ No newline at end of file From 9be4d601b2119bb1c82f10f532250e89c617bf18 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 13 Nov 2017 16:44:09 -0800 Subject: [PATCH 62/69] react starter needs node ref, accept fixed leveldown (#19994) --- tests/baselines/reference/user/leveldown.log | 20 ------------------- .../user/TypeScript-React-Starter/test.json | 2 +- 2 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 tests/baselines/reference/user/leveldown.log diff --git a/tests/baselines/reference/user/leveldown.log b/tests/baselines/reference/user/leveldown.log deleted file mode 100644 index 011071ebc52..00000000000 --- a/tests/baselines/reference/user/leveldown.log +++ /dev/null @@ -1,20 +0,0 @@ -Exit Code: 1 -Standard output: -node_modules/abstract-leveldown/index.d.ts(2,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(3,3): error TS7010: 'open', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(5,3): error TS7010: 'close', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(7,3): error TS7010: 'get', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(7,26): error TS7006: Parameter 'err' implicitly has an 'any' type. -node_modules/abstract-leveldown/index.d.ts(8,3): error TS7010: 'get', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(8,39): error TS7006: Parameter 'err' implicitly has an 'any' type. -node_modules/abstract-leveldown/index.d.ts(10,3): error TS7010: 'put', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(11,3): error TS7010: 'put', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(13,3): error TS7010: 'del', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(14,3): error TS7010: 'del', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(17,3): error TS7010: 'batch', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/abstract-leveldown/index.d.ts(18,3): error TS7010: 'batch', which lacks return-type annotation, implicitly has an 'any' return type. -node_modules/leveldown/leveldown.d.ts(66,3): error TS7010: 'seek', which lacks return-type annotation, implicitly has an 'any' return type. - - - -Standard error: diff --git a/tests/cases/user/TypeScript-React-Starter/test.json b/tests/cases/user/TypeScript-React-Starter/test.json index 8b177c575aa..f3613bf3b01 100644 --- a/tests/cases/user/TypeScript-React-Starter/test.json +++ b/tests/cases/user/TypeScript-React-Starter/test.json @@ -1,3 +1,3 @@ { - "types": ["jest"] + "types": ["jest", "node"] } From 492cd15e61049c3efaa7b0a420d54bd6b0f22a4b Mon Sep 17 00:00:00 2001 From: csigs Date: Tue, 14 Nov 2017 05:10:09 +0000 Subject: [PATCH 63/69] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ .../diagnosticMessages.generated.json.lcl | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl index 2e603f114b6..c4de80ab4c8 100644 --- a/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ita/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + diff --git a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl index 7677920dd1d..e3c3a1d379a 100644 --- a/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/ptb/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1601,6 +1601,9 @@ + + + @@ -5255,24 +5258,36 @@ + + + + + + + + + + + + @@ -5978,18 +5993,27 @@ + + + + + + + + + @@ -6023,18 +6047,27 @@ + + + + + + + + + From 7e8851e65ba97f2d1c56087e4149eb1c33afd9f3 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Nov 2017 07:15:59 -0800 Subject: [PATCH 64/69] Always require '=' before parsing an initializer (#19979) * Always require '=' before parsing an initializer * Fix fourslash tests --- src/compiler/parser.ts | 55 +++------- .../reference/ClassDeclaration26.errors.txt | 4 +- .../baselines/reference/ClassDeclaration26.js | 3 +- .../reference/ClassDeclaration26.types | 2 +- .../FunctionDeclaration12_es6.errors.txt | 4 +- .../reference/FunctionDeclaration12_es6.js | 3 +- .../reference/FunctionDeclaration12_es6.types | 2 +- .../VariableDeclaration13_es6.errors.txt | 13 +-- .../reference/VariableDeclaration13_es6.js | 3 +- .../reference/arrayTypeOfTypeOf.errors.txt | 16 +-- .../baselines/reference/arrayTypeOfTypeOf.js | 6 +- .../asyncArrowFunction5_es2017.errors.txt | 8 +- .../reference/asyncArrowFunction5_es2017.js | 3 +- .../asyncArrowFunction5_es5.errors.txt | 8 +- .../reference/asyncArrowFunction5_es5.js | 3 +- .../asyncArrowFunction5_es6.errors.txt | 8 +- .../reference/asyncArrowFunction5_es6.js | 3 +- .../asyncArrowFunction9_es2017.errors.txt | 8 +- .../reference/asyncArrowFunction9_es2017.js | 3 +- .../asyncArrowFunction9_es5.errors.txt | 8 +- .../reference/asyncArrowFunction9_es5.js | 3 +- .../asyncArrowFunction9_es6.errors.txt | 8 +- .../reference/asyncArrowFunction9_es6.js | 3 +- ...yncFunctionDeclaration12_es2017.errors.txt | 4 +- .../asyncFunctionDeclaration12_es2017.js | 3 +- .../asyncFunctionDeclaration12_es2017.types | 2 +- .../asyncFunctionDeclaration12_es5.errors.txt | 4 +- .../asyncFunctionDeclaration12_es5.js | 3 +- .../asyncFunctionDeclaration12_es5.types | 2 +- .../asyncFunctionDeclaration12_es6.errors.txt | 4 +- .../asyncFunctionDeclaration12_es6.js | 3 +- .../asyncFunctionDeclaration12_es6.types | 2 +- ...lassMemberWithMissingIdentifier.errors.txt | 11 +- .../classMemberWithMissingIdentifier.js | 3 +- .../classMemberWithMissingIdentifier.types | 3 +- ...assMemberWithMissingIdentifier2.errors.txt | 20 ++-- .../classMemberWithMissingIdentifier2.js | 7 +- .../classMemberWithMissingIdentifier2.symbols | 1 - .../classMemberWithMissingIdentifier2.types | 4 +- ...torWithIncompleteTypeAnnotation.errors.txt | 34 +++--- ...constructorWithIncompleteTypeAnnotation.js | 39 +++---- ...ructorWithIncompleteTypeAnnotation.symbols | 7 -- ...structorWithIncompleteTypeAnnotation.types | 13 ++- ...perCallsInNonConstructorMembers.errors.txt | 102 +++++++++++++++--- ...dClassSuperCallsInNonConstructorMembers.js | 65 +++++------ ...sSuperCallsInNonConstructorMembers.symbols | 16 --- ...assSuperCallsInNonConstructorMembers.types | 31 ++++-- ...ontShowCompilerGeneratedMembers.errors.txt | 5 +- .../dontShowCompilerGeneratedMembers.js | 3 +- .../expressionTypeNodeShouldError.errors.txt | 4 +- .../expressionTypeNodeShouldError.types | 2 +- ...hSyntacticErrorsForMultipleFiles2.baseline | 2 +- .../invalidLetInForOfAndForIn_ES5.errors.txt | 25 +++-- .../invalidLetInForOfAndForIn_ES5.js | 6 +- .../invalidLetInForOfAndForIn_ES5.types | 9 +- .../invalidLetInForOfAndForIn_ES6.errors.txt | 25 +++-- .../invalidLetInForOfAndForIn_ES6.js | 6 +- .../invalidLetInForOfAndForIn_ES6.types | 9 +- .../reference/invalidTypeOfTarget.errors.txt | 14 +-- .../reference/invalidTypeOfTarget.js | 17 +-- .../reference/invalidTypeOfTarget.symbols | 1 + .../reference/invalidTypeOfTarget.types | 3 +- ...negateOperatorInvalidOperations.errors.txt | 9 +- .../negateOperatorInvalidOperations.js | 3 +- .../negateOperatorInvalidOperations.types | 4 +- ...ralsWithTrailingDecimalPoints01.errors.txt | 4 +- ...ericLiteralsWithTrailingDecimalPoints01.js | 3 +- ...tors.functionExpressions.esnext.errors.txt | 8 +- ...enerators.functionExpressions.esnext.types | 4 +- .../parserArrowFunctionExpression6.errors.txt | 37 +++++++ .../parserArrowFunctionExpression6.js | 3 +- .../parserArrowFunctionExpression6.symbols | 10 +- .../parserArrowFunctionExpression6.types | 26 ++--- .../parserArrowFunctionExpression7.js | 16 +++ .../parserArrowFunctionExpression7.symbols | 10 ++ .../parserArrowFunctionExpression7.types | 13 +++ ...overy_IncompleteMemberVariable2.errors.txt | 4 +- ...ErrorRecovery_IncompleteMemberVariable2.js | 1 - ...orRecovery_IncompleteMemberVariable2.types | 1 - .../reference/parserTypeQuery8.errors.txt | 4 +- tests/baselines/reference/parserTypeQuery8.js | 3 +- .../reference/restParamModifier.errors.txt | 16 +-- .../baselines/reference/restParamModifier.js | 3 +- .../reference/restParamModifier.symbols | 2 +- .../reference/restParamModifier.types | 6 +- .../thisTypeInFunctionsNegative.errors.txt | 44 +++++--- .../reference/thisTypeInFunctionsNegative.js | 20 ++-- .../thisTypeInFunctionsNegative.symbols | 14 +-- .../thisTypeInFunctionsNegative.types | 36 ++++--- .../typeGuardFunctionErrors.errors.txt | 25 +---- .../reference/typeGuardFunctionErrors.js | 6 +- .../reference/typeGuardFunctionErrors.symbols | 5 + .../reference/typeGuardFunctionErrors.types | 2 +- ...redicateOnVariableDeclaration02.errors.txt | 9 +- .../typePredicateOnVariableDeclaration02.js | 2 +- ...pePredicateOnVariableDeclaration02.symbols | 1 + .../parserArrowFunctionExpression7.ts | 7 ++ ...etionListImplementingInterfaceFunctions.ts | 4 +- tests/cases/fourslash/formattingReadonly.ts | 8 +- 99 files changed, 609 insertions(+), 455 deletions(-) create mode 100644 tests/baselines/reference/parserArrowFunctionExpression6.errors.txt create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.js create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.symbols create mode 100644 tests/baselines/reference/parserArrowFunctionExpression7.types create mode 100644 tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 79b5eb30c49..5456e889353 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2271,7 +2271,7 @@ namespace ts { isStartOfType(/*inStartOfParameter*/ true); } - function parseParameter(requireEqualsToken?: boolean): ParameterDeclaration { + function parseParameter(): ParameterDeclaration { const node = createNode(SyntaxKind.Parameter); if (token() === SyntaxKind.ThisKeyword) { node.name = createIdentifier(/*isIdentifier*/ true); @@ -2300,7 +2300,7 @@ namespace ts { node.questionToken = parseOptionalToken(SyntaxKind.QuestionToken); node.type = parseParameterType(); - node.initializer = parseInitializer(/*inParameter*/ true, requireEqualsToken); + node.initializer = parseInitializer(); return addJSDocComment(finishNode(node)); } @@ -2357,8 +2357,7 @@ namespace ts { setYieldContext(!!(flags & SignatureFlags.Yield)); setAwaitContext(!!(flags & SignatureFlags.Await)); - const result = parseDelimitedList(ParsingContext.Parameters, - flags & SignatureFlags.JSDoc ? parseJSDocParameter : () => parseParameter(!!(flags & SignatureFlags.RequireCompleteParameterList))); + const result = parseDelimitedList(ParsingContext.Parameters, flags & SignatureFlags.JSDoc ? parseJSDocParameter : parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); @@ -2499,7 +2498,7 @@ namespace ts { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - property.initializer = parseNonParameterInitializer(); + property.initializer = parseInitializer(); } parseTypeMemberSemicolon(); @@ -3039,34 +3038,8 @@ namespace ts { return expr; } - function parseInitializer(inParameter: boolean, requireEqualsToken?: boolean): Expression { - if (token() !== SyntaxKind.EqualsToken) { - // It's not uncommon during typing for the user to miss writing the '=' token. Check if - // there is no newline after the last token and if we're on an expression. If so, parse - // this as an equals-value clause with a missing equals. - // NOTE: There are two places where we allow equals-value clauses. The first is in a - // variable declarator. The second is with a parameter. For variable declarators - // it's more likely that a { would be a allowed (as an object literal). While this - // is also allowed for parameters, the risk is that we consume the { as an object - // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === SyntaxKind.OpenBraceToken) || !isStartOfExpression()) { - // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - - // do not try to parse initializer - return undefined; - } - if (inParameter && requireEqualsToken) { - // = is required when speculatively parsing arrow function parameters, - // so return a fake initializer as a signal that the equals token was missing - const result = createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ true, Diagnostics._0_expected, "=") as Identifier; - result.escapedText = "= not found" as __String; - return result; - } - } - - // Initializer[In, Yield] : - // = AssignmentExpression[?In, ?Yield] - parseExpected(SyntaxKind.EqualsToken); - return parseAssignmentExpressionOrHigher(); + function parseInitializer(): Expression | undefined { + return parseOptional(SyntaxKind.EqualsToken) ? parseAssignmentExpressionOrHigher() : undefined; } function parseAssignmentExpressionOrHigher(): Expression { @@ -5234,7 +5207,7 @@ namespace ts { const node = createNode(SyntaxKind.BindingElement); node.dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); node.name = parseIdentifierOrPattern(); - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(); return finishNode(node); } @@ -5251,7 +5224,7 @@ namespace ts { node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } - node.initializer = parseInitializer(/*inParameter*/ false); + node.initializer = parseInitializer(); return finishNode(node); } @@ -5290,7 +5263,7 @@ namespace ts { node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { - node.initializer = parseNonParameterInitializer(); + node.initializer = parseInitializer(); } return finishNode(node); } @@ -5406,8 +5379,8 @@ namespace ts { // // The checker may still error in the static case to explicitly disallow the yield expression. property.initializer = hasModifier(property, ModifierFlags.Static) - ? allowInAnd(parseNonParameterInitializer) - : doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseNonParameterInitializer); + ? allowInAnd(parseInitializer) + : doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseInitializer); parseSemicolon(); return addJSDocComment(finishNode(property)); @@ -5428,10 +5401,6 @@ namespace ts { } } - function parseNonParameterInitializer() { - return parseInitializer(/*inParameter*/ false); - } - function parseAccessorDeclaration(kind: SyntaxKind, fullStart: number, decorators: NodeArray, modifiers: NodeArray): AccessorDeclaration { const node = createNode(kind, fullStart); node.decorators = decorators; @@ -5755,7 +5724,7 @@ namespace ts { function parseEnumMember(): EnumMember { const node = createNode(SyntaxKind.EnumMember, scanner.getStartPos()); node.name = parsePropertyName(); - node.initializer = allowInAnd(parseNonParameterInitializer); + node.initializer = allowInAnd(parseInitializer); return addJSDocComment(finishNode(node)); } diff --git a/tests/baselines/reference/ClassDeclaration26.errors.txt b/tests/baselines/reference/ClassDeclaration26.errors.txt index 5e2d570b801..0972a287de3 100644 --- a/tests/baselines/reference/ClassDeclaration26.errors.txt +++ b/tests/baselines/reference/ClassDeclaration26.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/ClassDeclaration26.ts(2,22): error TS1005: ';' expected. tests/cases/compiler/ClassDeclaration26.ts(4,5): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -tests/cases/compiler/ClassDeclaration26.ts(4,20): error TS1005: '=' expected. +tests/cases/compiler/ClassDeclaration26.ts(4,20): error TS1005: ',' expected. tests/cases/compiler/ClassDeclaration26.ts(4,23): error TS1005: '=>' expected. tests/cases/compiler/ClassDeclaration26.ts(5,1): error TS1128: Declaration or statement expected. @@ -15,7 +15,7 @@ tests/cases/compiler/ClassDeclaration26.ts(5,1): error TS1128: Declaration or st ~~~ !!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1005: '=>' expected. } diff --git a/tests/baselines/reference/ClassDeclaration26.js b/tests/baselines/reference/ClassDeclaration26.js index 40be8d7baeb..8a240f696a4 100644 --- a/tests/baselines/reference/ClassDeclaration26.js +++ b/tests/baselines/reference/ClassDeclaration26.js @@ -12,4 +12,5 @@ var C = /** @class */ (function () { } return C; }()); -var constructor = function () { }; +var constructor; +(function () { }); diff --git a/tests/baselines/reference/ClassDeclaration26.types b/tests/baselines/reference/ClassDeclaration26.types index acdc0d56ab1..62879552349 100644 --- a/tests/baselines/reference/ClassDeclaration26.types +++ b/tests/baselines/reference/ClassDeclaration26.types @@ -8,6 +8,6 @@ class C { >10 : 10 var constructor() { } ->constructor : () => void +>constructor : any >() { } : () => void } diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt index 358ec5ea041..425536f8781 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt +++ b/tests/baselines/reference/FunctionDeclaration12_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,20): error TS1005: '(' expected. -tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,25): error TS1005: '=' expected. +tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,25): error TS1005: ',' expected. tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1,28): error TS1005: '=>' expected. @@ -8,6 +8,6 @@ tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration12_es6.ts(1, ~~~~~ !!! error TS1005: '(' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1005: '=>' expected. \ No newline at end of file diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.js b/tests/baselines/reference/FunctionDeclaration12_es6.js index 5d55d3231b0..d2f490ef5e8 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.js +++ b/tests/baselines/reference/FunctionDeclaration12_es6.js @@ -2,4 +2,5 @@ var v = function * yield() { } //// [FunctionDeclaration12_es6.js] -var v = function* () { }, yield = () => { }; +var v = function* () { }, yield; +() => { }; diff --git a/tests/baselines/reference/FunctionDeclaration12_es6.types b/tests/baselines/reference/FunctionDeclaration12_es6.types index 5d413f99d07..336bde7a947 100644 --- a/tests/baselines/reference/FunctionDeclaration12_es6.types +++ b/tests/baselines/reference/FunctionDeclaration12_es6.types @@ -2,6 +2,6 @@ var v = function * yield() { } >v : () => any >function * : () => any ->yield : () => void +>yield : any >() { } : () => void diff --git a/tests/baselines/reference/VariableDeclaration13_es6.errors.txt b/tests/baselines/reference/VariableDeclaration13_es6.errors.txt index 1780e06e2af..c954969f19d 100644 --- a/tests/baselines/reference/VariableDeclaration13_es6.errors.txt +++ b/tests/baselines/reference/VariableDeclaration13_es6.errors.txt @@ -1,10 +1,9 @@ tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,5): error TS1181: Array element destructuring pattern expected. -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,6): error TS1005: ',' expected. -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,8): error TS1134: Variable declaration expected. -tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,10): error TS1134: Variable declaration expected. +tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,6): error TS1005: ';' expected. +tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4,8): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts (4 errors) ==== +==== tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts (3 errors) ==== // An ExpressionStatement cannot start with the two token sequence `let [` because // that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern. var let: any; @@ -12,8 +11,6 @@ tests/cases/conformance/es6/variableDeclarations/VariableDeclaration13_es6.ts(4, ~ !!! error TS1181: Array element destructuring pattern expected. ~ -!!! error TS1005: ',' expected. +!!! error TS1005: ';' expected. ~ -!!! error TS1134: Variable declaration expected. - ~~~ -!!! error TS1134: Variable declaration expected. \ No newline at end of file +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/VariableDeclaration13_es6.js b/tests/baselines/reference/VariableDeclaration13_es6.js index 1acd0fdbe02..152ca6a26d6 100644 --- a/tests/baselines/reference/VariableDeclaration13_es6.js +++ b/tests/baselines/reference/VariableDeclaration13_es6.js @@ -8,5 +8,6 @@ let[0] = 100; // An ExpressionStatement cannot start with the two token sequence `let [` because // that would make it ambiguous with a `let` LexicalDeclaration whose first LexicalBinding was an ArrayBindingPattern. var let; -let [] = 0; +let []; +0; 100; diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt index 1c37f04be72..2726492f36d 100644 --- a/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt +++ b/tests/baselines/reference/arrayTypeOfTypeOf.errors.txt @@ -1,28 +1,22 @@ -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,22): error TS1005: '=' expected. +tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,22): error TS1005: ',' expected. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(6,30): error TS1109: Expression expected. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,5): error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. -tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,22): error TS1005: '=' expected. +tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,22): error TS1005: ',' expected. tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts(7,32): error TS1109: Expression expected. -==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts (6 errors) ==== +==== tests/cases/conformance/types/specifyingTypes/typeLiterals/arrayTypeOfTypeOf.ts (4 errors) ==== // array type cannot use typeof. var x = 1; var xs: typeof x[]; // Not an error. This is equivalent to Array var xs2: typeof Array; var xs3: typeof Array; - ~~~ -!!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1109: Expression expected. var xs4: typeof Array; - ~~~ -!!! error TS2322: Type 'number' is not assignable to type 'ArrayConstructor'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/arrayTypeOfTypeOf.js b/tests/baselines/reference/arrayTypeOfTypeOf.js index f3653346be4..ced62a73a07 100644 --- a/tests/baselines/reference/arrayTypeOfTypeOf.js +++ b/tests/baselines/reference/arrayTypeOfTypeOf.js @@ -12,5 +12,7 @@ var xs4: typeof Array; var x = 1; var xs; // Not an error. This is equivalent to Array var xs2; -var xs3 = ; -var xs4 = ; +var xs3; +; +var xs4; +; diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt index 594786d3005..1d3e9222ace 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,18): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,33): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,33): error TS1005: ',' expected. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es2017.ts(1,40): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction5_es20 ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es2017.js b/tests/baselines/reference/asyncArrowFunction5_es2017.js index b12d06e6e32..c3ce23ad103 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es2017.js +++ b/tests/baselines/reference/asyncArrowFunction5_es2017.js @@ -3,6 +3,7 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es2017.js] -var foo = async(await), Promise = ; +var foo = async(await), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt index 949e2401d35..03c98f0707c 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es5.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,18): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,33): error TS1005: '=' expected. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,33): error TS1005: ',' expected. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts(1,40): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction5_es5.ts( ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es5.js b/tests/baselines/reference/asyncArrowFunction5_es5.js index 2e15f99e297..ac1e8801551 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es5.js +++ b/tests/baselines/reference/asyncArrowFunction5_es5.js @@ -3,6 +3,7 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es5.js] -var foo = async(await), Promise = ; +var foo = async(await), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt index b3cb60c95ca..9fd82b6cc06 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction5_es6.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,18): error TS2304: Cannot find name 'await'. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,24): error TS1005: ',' expected. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,33): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,26): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,33): error TS1005: ',' expected. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts(1,40): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction5_es6.ts( ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction5_es6.js b/tests/baselines/reference/asyncArrowFunction5_es6.js index b5ae55a8f48..170962c6fd5 100644 --- a/tests/baselines/reference/asyncArrowFunction5_es6.js +++ b/tests/baselines/reference/asyncArrowFunction5_es6.js @@ -3,6 +3,7 @@ var foo = async (await): Promise => { } //// [asyncArrowFunction5_es6.js] -var foo = async(await), Promise = ; +var foo = async(await), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt index c888995f1fb..a14b3f44303 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,18): error TS2304: Cannot find name 'a'. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,37): error TS1005: ',' expected. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,46): error TS1005: ',' expected. tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es2017.ts(1,53): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/asyncArrowFunction9_es20 ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es2017.js b/tests/baselines/reference/asyncArrowFunction9_es2017.js index c1fec991ec1..a101892eb16 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es2017.js +++ b/tests/baselines/reference/asyncArrowFunction9_es2017.js @@ -3,6 +3,7 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es2017.js] -var foo = async(a = await => await), Promise = ; +var foo = async(a = await => await), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction9_es5.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es5.errors.txt index e215259245e..a9e03eb897d 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es5.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction9_es5.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,18): error TS2304: Cannot find name 'a'. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,37): error TS1005: ',' expected. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,46): error TS1005: ',' expected. tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts(1,53): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es5/asyncArrowFunction/asyncArrowFunction9_es5.ts( ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es5.js b/tests/baselines/reference/asyncArrowFunction9_es5.js index 2506024f326..457d5ddc4c4 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es5.js +++ b/tests/baselines/reference/asyncArrowFunction9_es5.js @@ -3,6 +3,7 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es5.js] -var foo = async(a = function (await) { return await; }), Promise = ; +var foo = async(a = function (await) { return await; }), Promise; +; { } diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt index 8d974d75dd3..123f07c020c 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction9_es6.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,11): error TS2304: Cannot find name 'async'. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,18): error TS2304: Cannot find name 'a'. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,37): error TS1005: ',' expected. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. -tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: '=' expected. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,39): error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. +tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,46): error TS1005: ',' expected. tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts(1,53): error TS1109: Expression expected. @@ -15,9 +15,9 @@ tests/cases/conformance/async/es6/asyncArrowFunction/asyncArrowFunction9_es6.ts( ~ !!! error TS1005: ',' expected. ~~~~~~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'void'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'Promise' has type 'PromiseConstructor' at lib.es2015.promise.d.ts 222:12, but here has type 'any'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~ !!! error TS1109: Expression expected. } \ No newline at end of file diff --git a/tests/baselines/reference/asyncArrowFunction9_es6.js b/tests/baselines/reference/asyncArrowFunction9_es6.js index fb2f9d28a17..d7d5a167583 100644 --- a/tests/baselines/reference/asyncArrowFunction9_es6.js +++ b/tests/baselines/reference/asyncArrowFunction9_es6.js @@ -3,6 +3,7 @@ var foo = async (a = await => await): Promise => { } //// [asyncArrowFunction9_es6.js] -var foo = async(a = await => await), Promise = ; +var foo = async(a = await => await), Promise; +; { } diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt index f951bee715c..37e2c3f847f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,24): error TS1005: '(' expected. -tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,29): error TS1005: ',' expected. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclaration12_es2017.ts(1,47): error TS1005: '=>' expected. @@ -9,7 +9,7 @@ tests/cases/conformance/async/es2017/functionDeclarations/asyncFunctionDeclarati ~~~~~ !!! error TS1005: '(' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~~~~~~~~~~~~ !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js index 93fbb061023..2ed6cf3191f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.js @@ -2,4 +2,5 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es2017.js] -var v = async function () { }, await = () => { }; +var v = async function () { }, await; +() => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types index 1881a3cb4fd..5f4155c4975 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es2017.types @@ -2,7 +2,7 @@ var v = async function await(): Promise { } >v : () => any >async function : () => any ->await : () => Promise +>await : any >(): Promise { } : () => Promise >Promise : Promise diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt index 6468ec69716..353e75ca6d5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,24): error TS1005: '(' expected. -tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,29): error TS1005: ',' expected. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration12_es5.ts(1,47): error TS1005: '=>' expected. @@ -9,7 +9,7 @@ tests/cases/conformance/async/es5/functionDeclarations/asyncFunctionDeclaration1 ~~~~~ !!! error TS1005: '(' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~~~~~~~~~~~~ !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js index 21651a42796..19bca54f524 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.js @@ -6,4 +6,5 @@ var v = function () { return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { return [2 /*return*/]; }); }); -}, await = function () { }; +}, await; +(function () { }); diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es5.types b/tests/baselines/reference/asyncFunctionDeclaration12_es5.types index 242eca7c5a4..c7e3a6feeb5 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es5.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es5.types @@ -2,7 +2,7 @@ var v = async function await(): Promise { } >v : () => any >async function : () => any ->await : () => Promise +>await : any >(): Promise { } : () => Promise >Promise : Promise diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt index 43df8e21659..ffe7227344f 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,24): error TS1005: '(' expected. -tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,29): error TS1005: '=' expected. +tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,29): error TS1005: ',' expected. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,33): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration12_es6.ts(1,47): error TS1005: '=>' expected. @@ -9,7 +9,7 @@ tests/cases/conformance/async/es6/functionDeclarations/asyncFunctionDeclaration1 ~~~~~ !!! error TS1005: '(' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~~~~~~~~~~~~~ !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. ~ diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js index 9943c3896b6..17829af6f20 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.js +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.js @@ -4,4 +4,5 @@ var v = async function await(): Promise { } //// [asyncFunctionDeclaration12_es6.js] var v = function () { return __awaiter(this, void 0, void 0, function* () { }); -}, await = () => { }; +}, await; +() => { }; diff --git a/tests/baselines/reference/asyncFunctionDeclaration12_es6.types b/tests/baselines/reference/asyncFunctionDeclaration12_es6.types index acf108d9761..4eb4fcde054 100644 --- a/tests/baselines/reference/asyncFunctionDeclaration12_es6.types +++ b/tests/baselines/reference/asyncFunctionDeclaration12_es6.types @@ -2,7 +2,7 @@ var v = async function await(): Promise { } >v : () => any >async function : () => any ->await : () => Promise +>await : any >(): Promise { } : () => Promise >Promise : Promise diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt index 4bbc2d8167d..2cd21b0e4f0 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.errors.txt @@ -1,12 +1,15 @@ tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,11): error TS1146: Declaration expected. -tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/classMemberWithMissingIdentifier.ts(2,12): error TS1005: ';' expected. +tests/cases/compiler/classMemberWithMissingIdentifier.ts(3,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/classMemberWithMissingIdentifier.ts (2 errors) ==== +==== tests/cases/compiler/classMemberWithMissingIdentifier.ts (3 errors) ==== class C { public {}; !!! error TS1146: Declaration expected. ~ -!!! error TS1005: '=' expected. - } \ No newline at end of file +!!! error TS1005: ';' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.js b/tests/baselines/reference/classMemberWithMissingIdentifier.js index 39582a670a4..55596754f20 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier.js +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.js @@ -6,7 +6,8 @@ class C { //// [classMemberWithMissingIdentifier.js] var C = /** @class */ (function () { function C() { - this. = {}; } return C; }()); +{ } +; diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier.types b/tests/baselines/reference/classMemberWithMissingIdentifier.types index d0fb4dddd12..ebc14e9e8a6 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier.types +++ b/tests/baselines/reference/classMemberWithMissingIdentifier.types @@ -3,6 +3,5 @@ class C { >C : C public {}; -> : {} ->{} : {} +> : any } diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt index 9854a115aa6..65a9eac77a3 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt @@ -1,11 +1,11 @@ tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,11): error TS1146: Declaration expected. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,12): error TS1005: '=' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,12): error TS1005: ';' expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,14): error TS2304: Cannot find name 'name'. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,18): error TS1005: ']' expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,18): error TS1005: ',' expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,19): error TS2693: 'string' only refers to a type, but is being used as a value here. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,25): error TS1005: ',' expected. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,26): error TS1136: Property assignment expected. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,26): error TS1005: ';' expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: Cannot find name 'VariableDeclaration'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(3,1): error TS1128: Declaration or statement expected. ==== tests/cases/compiler/classMemberWithMissingIdentifier2.ts (8 errors) ==== @@ -14,17 +14,17 @@ tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: C !!! error TS1146: Declaration expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ';' expected. ~~~~ !!! error TS2304: Cannot find name 'name'. ~ -!!! error TS1005: ']' expected. +!!! error TS1005: ',' expected. ~~~~~~ !!! error TS2693: 'string' only refers to a type, but is being used as a value here. - ~ -!!! error TS1005: ',' expected. ~ -!!! error TS1136: Property assignment expected. +!!! error TS1005: ';' expected. ~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'VariableDeclaration'. - } \ No newline at end of file + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.js b/tests/baselines/reference/classMemberWithMissingIdentifier2.js index 798774af12c..f4cd26302c4 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.js +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.js @@ -6,8 +6,11 @@ class C { //// [classMemberWithMissingIdentifier2.js] var C = /** @class */ (function () { function C() { - this. = (_a = {}, _a[name] = string, _a.VariableDeclaration = VariableDeclaration, _a); - var _a; } return C; }()); +{ + [name, string]; + VariableDeclaration; +} +; diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.symbols b/tests/baselines/reference/classMemberWithMissingIdentifier2.symbols index 2b1d1a521e1..1ac5b055178 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.symbols +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.symbols @@ -4,5 +4,4 @@ class C { public {[name:string]:VariableDeclaration}; > : Symbol(C[(Missing)], Decl(classMemberWithMissingIdentifier2.ts, 0, 9)) ->VariableDeclaration : Symbol(VariableDeclaration, Decl(classMemberWithMissingIdentifier2.ts, 1, 26)) } diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.types b/tests/baselines/reference/classMemberWithMissingIdentifier2.types index 9b5e6cd64c1..8f9f62818a4 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.types +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.types @@ -3,8 +3,8 @@ class C { >C : C public {[name:string]:VariableDeclaration}; -> : { [x: number]: any; VariableDeclaration: any; } ->{[name:string]:VariableDeclaration} : { [x: number]: any; VariableDeclaration: any; } +> : any +>[name:string] : any[] >name : any >string : any >VariableDeclaration : any diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index 708f175c002..1150fe0ff29 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -7,19 +7,21 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,28): error TS tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(24,29): error TS1005: ',' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,18): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(27,26): error TS2304: Cannot find name 'bfs'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,30): error TS1005: '=' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,30): error TS1005: ',' expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(28,34): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(31,18): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,17): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,17): error TS2304: Cannot find name 'retValue'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,26): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(34,28): error TS2304: Cannot find name 'bfs'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(35,21): error TS2304: Cannot find name 'retValue'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(38,17): error TS1109: Expression expected. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,17): error TS2304: Cannot find name 'retValue'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,28): error TS2304: Cannot find name 'bfs'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,41): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(40,45): error TS1002: Unterminated string literal. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,21): error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(41,21): error TS2304: Cannot find name 'retValue'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(46,13): error TS1005: 'try' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(47,17): error TS2304: Cannot find name 'console'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(49,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(53,13): error TS2304: Cannot find name 'console'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(58,5): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(69,13): error TS1109: Expression expected. @@ -87,7 +89,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (87 errors) ==== +==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (89 errors) ==== declare module "fs" { export class File { constructor(filename: string); @@ -138,7 +140,9 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS2304: Cannot find name 'bfs'. if (retValue != 0) { ~~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: ';' expected. return 1; ^ @@ -148,14 +152,14 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS retValue = bfs.TYPES(); ~~~~~~~~ -!!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. +!!! error TS2304: Cannot find name 'retValue'. ~ !!! error TS1005: ';' expected. ~~~ !!! error TS2304: Cannot find name 'bfs'. if (retValue != 0) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'retValue'. return 1 && } @@ -163,6 +167,8 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS1109: Expression expected. retValue = bfs.OPERATOR ' ); + ~~~~~~~~ +!!! error TS2304: Cannot find name 'retValue'. ~~~ !!! error TS2304: Cannot find name 'bfs'. ~~~~ @@ -170,20 +176,20 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS !!! error TS1002: Unterminated string literal. if (retValue != 0) { - ~~~~~~~~~~~~~ -!!! error TS2365: Operator '!=' cannot be applied to types 'boolean' and '0'. + ~~~~~~~~ +!!! error TS2304: Cannot find name 'retValue'. return 1; } } catch (e) { + ~~~~~ +!!! error TS1005: 'try' expected. console.log(e); ~~~~~~~ !!! error TS2304: Cannot find name 'console'. } finally { - ~~~~~~~ -!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js index 7a109888497..24a0f8f01c6 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.js @@ -315,30 +315,31 @@ var TypeScriptAllInOne; finally { } }; - Program.prototype["if"] = function (retValue) { - if (retValue === void 0) { retValue = != 0; } - return 1; - ^ - retValue; - bfs.TYPES(); - if (retValue != 0) { - return 1 && - ; - } - retValue = bfs.OPERATOR; - ' );; - if (retValue != 0) { - return 1; - } - }; - Program.prototype["catch"] = function (e) { - console.log(e); - }; + Program.prototype["if"] = function (retValue) { }; return Program; }()); TypeScriptAllInOne.Program = Program; + != 0; + { + return 1; + ^ + retValue; + bfs.TYPES(); + if (retValue != 0) { + return 1 && + ; + } + retValue = bfs.OPERATOR; + ' );; + if (retValue != 0) { + return 1; + } + } try { } + catch (e) { + console.log(e); + } finally { } console.log('Done'); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols index 7374c67325d..45a894d8895 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.symbols @@ -64,25 +64,18 @@ module TypeScriptAllInOne { retValue = bfs.TYPES(); ->retValue : Symbol(retValue, Decl(constructorWithIncompleteTypeAnnotation.ts, 27, 20)) - if (retValue != 0) { ->retValue : Symbol(retValue, Decl(constructorWithIncompleteTypeAnnotation.ts, 27, 20)) return 1 && } retValue = bfs.OPERATOR ' ); ->retValue : Symbol(retValue, Decl(constructorWithIncompleteTypeAnnotation.ts, 27, 20)) - if (retValue != 0) { ->retValue : Symbol(retValue, Decl(constructorWithIncompleteTypeAnnotation.ts, 27, 20)) return 1; } } catch (e) { ->catch : Symbol(Program.catch, Decl(constructorWithIncompleteTypeAnnotation.ts, 44, 13)) >e : Symbol(e, Decl(constructorWithIncompleteTypeAnnotation.ts, 45, 19)) console.log(e); diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types index a0c5f95cbbd..d8217600a66 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.types @@ -74,8 +74,8 @@ module TypeScriptAllInOne { >4 : 4 if (retValue != 0) { ->if : (retValue?: boolean) => any ->retValue : boolean +>if : (retValue: any) => any +>retValue : any >!= 0 : boolean > : any >0 : 0 @@ -89,7 +89,7 @@ module TypeScriptAllInOne { retValue = bfs.TYPES(); ->retValue : boolean +>retValue : any >bfs.TYPES() : any >bfs.TYPES : any >bfs : any @@ -97,7 +97,7 @@ module TypeScriptAllInOne { if (retValue != 0) { >retValue != 0 : boolean ->retValue : boolean +>retValue : any >0 : 0 return 1 && @@ -108,7 +108,7 @@ module TypeScriptAllInOne { retValue = bfs.OPERATOR ' ); >retValue = bfs.OPERATOR : any ->retValue : boolean +>retValue : any >bfs.OPERATOR : any >bfs : any >OPERATOR : any @@ -116,7 +116,7 @@ module TypeScriptAllInOne { if (retValue != 0) { >retValue != 0 : boolean ->retValue : boolean +>retValue : any >0 : 0 return 1; @@ -124,7 +124,6 @@ module TypeScriptAllInOne { } } catch (e) { ->catch : (e: any) => void >e : any console.log(e); diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt index 84d9c313995..1e471f9970c 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.errors.txt @@ -1,18 +1,44 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,8): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1005: '=' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,13): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(8,14): error TS1109: Expression expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(9,5): error TS2304: Cannot find name 'b'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(9,9): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(10,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,5): error TS2304: Cannot find name 'get'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,9): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,9): error TS2304: Cannot find name 'C'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(12,13): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(13,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,5): error TS2304: Cannot find name 'set'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,5): error TS7027: Unreachable code detected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,9): error TS2304: Cannot find name 'C'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,11): error TS2304: Cannot find name 'v'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(16,14): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(17,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2304: Cannot find name 'super'. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,20): error TS1005: '=' expected. -tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,21): error TS1109: Expression expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,5): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(20,15): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(21,5): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(21,12): error TS2304: Cannot find name 'b'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(21,16): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(22,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,5): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,12): error TS2304: Cannot find name 'get'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,16): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,16): error TS2304: Cannot find name 'C'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(24,20): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(25,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,5): error TS1128: Declaration or statement expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,12): error TS2304: Cannot find name 'set'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,16): error TS1005: ';' expected. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,16): error TS2304: Cannot find name 'C'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,18): error TS2304: Cannot find name 'v'. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(28,21): error TS1005: ';' expected. tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(29,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. +tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts(31,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (12 errors) ==== +==== tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassSuperCallsInNonConstructorMembers.ts (38 errors) ==== // error to use super calls outside a constructor class Base { @@ -24,47 +50,99 @@ tests/cases/conformance/classes/constructorDeclarations/superCalls/derivedClassS ~~~~~ !!! error TS2304: Cannot find name 'super'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ';' expected. ~ !!! error TS1109: Expression expected. b() { + ~ +!!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } get C() { + ~~~ +!!! error TS2304: Cannot find name 'get'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'C'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } set C(v) { + ~~~ +!!! error TS2304: Cannot find name 'set'. + ~~~ +!!! error TS7027: Unreachable code detected. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'C'. + ~ +!!! error TS2304: Cannot find name 'v'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static a: super(); + ~~~~~~ +!!! error TS1128: Declaration or statement expected. ~~~~~ -!!! error TS2304: Cannot find name 'super'. - ~ -!!! error TS1005: '=' expected. - ~ -!!! error TS1109: Expression expected. +!!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. static b() { + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~ +!!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } static get C() { + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~ +!!! error TS2304: Cannot find name 'get'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'C'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. return 1; } static set C(v) { + ~~~~~~ +!!! error TS1128: Declaration or statement expected. + ~~~ +!!! error TS2304: Cannot find name 'set'. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS2304: Cannot find name 'C'. + ~ +!!! error TS2304: Cannot find name 'v'. + ~ +!!! error TS1005: ';' expected. super(); ~~~~~ !!! error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. } - } \ No newline at end of file + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js index 019e29f1940..cddd8e6c52c 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.js @@ -51,38 +51,39 @@ var Base = /** @class */ (function () { var Derived = /** @class */ (function (_super) { __extends(Derived, _super); function Derived() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.a = (); - return _this; + return _super !== null && _super.apply(this, arguments) || this; } - Derived.prototype.b = function () { - _this = _super.call(this) || this; - }; - Object.defineProperty(Derived.prototype, "C", { - get: function () { - _this = _super.call(this) || this; - return 1; - }, - set: function (v) { - _this = _super.call(this) || this; - }, - enumerable: true, - configurable: true - }); - Derived.b = function () { - _this = _super.call(this) || this; - }; - Object.defineProperty(Derived, "C", { - get: function () { - _this = _super.call(this) || this; - return 1; - }, - set: function (v) { - _this = _super.call(this) || this; - }, - enumerable: true, - configurable: true - }); - Derived.a = (); return Derived; }(Base)); +(); +b(); +{ + _this = _super.call(this) || this; +} +get; +C(); +{ + _this = _super.call(this) || this; + return 1; +} +set; +C(v); +{ + _this = _super.call(this) || this; +} +a: _this = _super.call(this) || this; +b(); +{ + _this = _super.call(this) || this; +} +get; +C(); +{ + _this = _super.call(this) || this; + return 1; +} +set; +C(v); +{ + _this = _super.call(this) || this; +} diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols index 0d5c10321cd..8a394e9d659 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.symbols @@ -16,41 +16,25 @@ class Derived extends Base { >a : Symbol(Derived.a, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 6, 28)) b() { ->b : Symbol(Derived.b, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 7, 15)) - super(); } get C() { ->C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 10, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 14, 5)) - super(); return 1; } set C(v) { ->C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 10, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 14, 5)) ->v : Symbol(v, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 15, 10)) - super(); } static a: super(); ->a : Symbol(Derived.a, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 17, 5)) - static b() { ->b : Symbol(Derived.b, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 19, 22)) - super(); } static get C() { ->C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 22, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 26, 5)) - super(); return 1; } static set C(v) { ->C : Symbol(Derived.C, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 22, 5), Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 26, 5)) ->v : Symbol(v, Decl(derivedClassSuperCallsInNonConstructorMembers.ts, 27, 17)) - super(); } } diff --git a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types index 5964a25f6d4..ebefa744753 100644 --- a/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types +++ b/tests/baselines/reference/derivedClassSuperCallsInNonConstructorMembers.types @@ -19,14 +19,17 @@ class Derived extends Base { > : any b() { ->b : () => void +>b() : any +>b : any super(); >super() : void >super : any } get C() { ->C : number +>get : any +>C() : any +>C : any super(); >super() : void @@ -36,8 +39,10 @@ class Derived extends Base { >1 : 1 } set C(v) { ->C : number ->v : number +>set : any +>C(v) : any +>C : any +>v : any super(); >super() : void @@ -46,19 +51,21 @@ class Derived extends Base { static a: super(); >a : any ->super : No type information available! ->() : any -> : any +>super() : void +>super : any static b() { ->b : () => void +>b() : any +>b : any super(); >super() : void >super : any } static get C() { ->C : number +>get : any +>C() : any +>C : any super(); >super() : void @@ -68,8 +75,10 @@ class Derived extends Base { >1 : 1 } static set C(v) { ->C : number ->v : number +>set : any +>C(v) : any +>C : any +>v : any super(); >super() : void diff --git a/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt b/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt index d53571cc4a8..708cc37701f 100644 --- a/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt +++ b/tests/baselines/reference/dontShowCompilerGeneratedMembers.errors.txt @@ -1,12 +1,9 @@ -tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(1,5): error TS2322: Type 'number' is not assignable to type '{ (): any; x: number; }'. tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(3,6): error TS1139: Type parameter declaration expected. tests/cases/compiler/dontShowCompilerGeneratedMembers.ts(4,1): error TS1109: Expression expected. -==== tests/cases/compiler/dontShowCompilerGeneratedMembers.ts (3 errors) ==== +==== tests/cases/compiler/dontShowCompilerGeneratedMembers.ts (2 errors) ==== var f: { - ~ -!!! error TS2322: Type 'number' is not assignable to type '{ (): any; x: number; }'. x: number; <- ~ diff --git a/tests/baselines/reference/dontShowCompilerGeneratedMembers.js b/tests/baselines/reference/dontShowCompilerGeneratedMembers.js index 5815e49c893..f9d732e8786 100644 --- a/tests/baselines/reference/dontShowCompilerGeneratedMembers.js +++ b/tests/baselines/reference/dontShowCompilerGeneratedMembers.js @@ -5,5 +5,6 @@ var f: { }; //// [dontShowCompilerGeneratedMembers.js] -var f = -; +var f; +-; ; diff --git a/tests/baselines/reference/expressionTypeNodeShouldError.errors.txt b/tests/baselines/reference/expressionTypeNodeShouldError.errors.txt index 86a592779ca..2d655a59b9c 100644 --- a/tests/baselines/reference/expressionTypeNodeShouldError.errors.txt +++ b/tests/baselines/reference/expressionTypeNodeShouldError.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/base.d.ts(1,23): error TS1005: ',' expected. -tests/cases/compiler/base.d.ts(1,34): error TS1005: '=' expected. +tests/cases/compiler/base.d.ts(1,34): error TS1005: ',' expected. tests/cases/compiler/boolean.ts(7,23): error TS1005: ',' expected. tests/cases/compiler/boolean.ts(7,24): error TS1134: Variable declaration expected. tests/cases/compiler/boolean.ts(11,16): error TS2304: Cannot find name 'document'. @@ -19,7 +19,7 @@ tests/cases/compiler/string.ts(12,19): error TS1005: ';' expected. ~ !!! error TS1005: ',' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ==== tests/cases/compiler/string.ts (4 errors) ==== interface String { diff --git a/tests/baselines/reference/expressionTypeNodeShouldError.types b/tests/baselines/reference/expressionTypeNodeShouldError.types index 67a44d061d1..907614aa7cd 100644 --- a/tests/baselines/reference/expressionTypeNodeShouldError.types +++ b/tests/baselines/reference/expressionTypeNodeShouldError.types @@ -1,7 +1,7 @@ === tests/cases/compiler/base.d.ts === declare const x: "foo".charCodeAt(0); >x : "foo" ->charCodeAt : 0 +>charCodeAt : any >(0) : 0 >0 : 0 diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline index b66f83dc6b6..0f526b85b4f 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles2.baseline @@ -4,5 +4,5 @@ FileName : out.js // expected to not generate outputs because of the syntactic errors in the other file. var noErrors = true; // File not emitted, and contains syntactic errors -var syntactic = Error; +var syntactic, Error; diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt index c31b03bae4c..d8168b14895 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.errors.txt @@ -1,22 +1,31 @@ -tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,13): error TS1005: '=' expected. -tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,20): error TS1005: ',' expected. -tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(7,1): error TS1005: ';' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,13): error TS1005: ',' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,14): error TS1181: Array element destructuring pattern expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,14): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,14): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,19): error TS1005: ';' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts(5,20): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts (3 errors) ==== +==== tests/cases/compiler/invalidLetInForOfAndForIn_ES5.ts (6 errors) ==== // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; for (let of [1,2,3]) {} ~ -!!! error TS1005: '=' expected. - ~ !!! error TS1005: ',' expected. + ~ +!!! error TS1181: Array element destructuring pattern expected. + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. for (let in [1,2,3]) {} - ~~~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js index b9f4c126015..0f35b405df3 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.js @@ -14,5 +14,7 @@ for (let in [1,2,3]) {} // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; -for (let of = [1, 2, 3], {}; ; ) - for (let in [1, 2, 3]) { } +for (let of, []; 1, 2, 3; ) + ; +{ } +for (let in [1, 2, 3]) { } diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.types b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.types index 26a9f24aead..66f070e1ce5 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.types +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES5.types @@ -7,15 +7,16 @@ var let = 10; >10 : 10 for (let of [1,2,3]) {} ->of : number[] ->[1,2,3] : number[] +>of : any +>1,2,3 : 3 +>1,2 : 2 >1 : 1 >2 : 2 >3 : 3 +> : any +> : any for (let in [1,2,3]) {} -> : any -> : any >[1,2,3] : number[] >1 : 1 >2 : 2 diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt index c126e8b7443..b484a573b1e 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.errors.txt @@ -1,22 +1,31 @@ -tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,13): error TS1005: '=' expected. -tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,20): error TS1005: ',' expected. -tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(7,1): error TS1005: ';' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,13): error TS1005: ',' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,14): error TS1181: Array element destructuring pattern expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,14): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,14): error TS2695: Left side of comma operator is unused and has no side effects. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,19): error TS1005: ';' expected. +tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts(5,20): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts (3 errors) ==== +==== tests/cases/compiler/invalidLetInForOfAndForIn_ES6.ts (6 errors) ==== // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; for (let of [1,2,3]) {} ~ -!!! error TS1005: '=' expected. - ~ !!! error TS1005: ',' expected. + ~ +!!! error TS1181: Array element destructuring pattern expected. + ~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~~~ +!!! error TS2695: Left side of comma operator is unused and has no side effects. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. for (let in [1,2,3]) {} - ~~~ -!!! error TS1005: ';' expected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js index be59a37d1a8..3cbadbabe37 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.js @@ -14,5 +14,7 @@ for (let in [1,2,3]) {} // This should be an error // More details: http://www.ecma-international.org/ecma-262/6.0/#sec-iteration-statements var let = 10; -for (let of = [1, 2, 3], {}; ; ) - for (let in [1, 2, 3]) { } +for (let of, []; 1, 2, 3; ) + ; +{ } +for (let in [1, 2, 3]) { } diff --git a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.types b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.types index ff980012702..1473e01ba1a 100644 --- a/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.types +++ b/tests/baselines/reference/invalidLetInForOfAndForIn_ES6.types @@ -7,15 +7,16 @@ var let = 10; >10 : 10 for (let of [1,2,3]) {} ->of : number[] ->[1,2,3] : number[] +>of : any +>1,2,3 : 3 +>1,2 : 2 >1 : 1 >2 : 2 >3 : 3 +> : any +> : any for (let in [1,2,3]) {} -> : any -> : any >[1,2,3] : number[] >1 : 1 >2 : 2 diff --git a/tests/baselines/reference/invalidTypeOfTarget.errors.txt b/tests/baselines/reference/invalidTypeOfTarget.errors.txt index e658ab68c81..04bf724e4b9 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.errors.txt +++ b/tests/baselines/reference/invalidTypeOfTarget.errors.txt @@ -6,9 +6,9 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(5,16): error TS1003: Identifier expected. tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(6,16): error TS2304: Cannot find name 'null'. tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,16): error TS2552: Cannot find name 'function'. Did you mean 'Function'? -tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,25): error TS1005: '=' expected. -tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,25): error TS2304: Cannot find name 'f'. -tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,29): error TS1005: ',' expected. +tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,25): error TS1005: ',' expected. +tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,26): error TS1005: ',' expected. +tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(7,29): error TS1005: '=>' expected. tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts(8,16): error TS1003: Identifier expected. @@ -37,11 +37,11 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/invalidTypeOfTarget.ts ~~~~~~~~ !!! error TS2552: Cannot find name 'function'. Did you mean 'Function'? ~ -!!! error TS1005: '=' expected. - ~ -!!! error TS2304: Cannot find name 'f'. - ~ !!! error TS1005: ',' expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1005: '=>' expected. var x8: typeof /123/; ~ !!! error TS1003: Identifier expected. \ No newline at end of file diff --git a/tests/baselines/reference/invalidTypeOfTarget.js b/tests/baselines/reference/invalidTypeOfTarget.js index ebc5bb70875..78d31c91809 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.js +++ b/tests/baselines/reference/invalidTypeOfTarget.js @@ -9,11 +9,16 @@ var x7: typeof function f() { }; var x8: typeof /123/; //// [invalidTypeOfTarget.js] -var x1 = {}; -var x2 = function () { return ; }; -var x3 = 1; -var x4 = ''; +var x1, _a = void 0; +var x2; +(function () { return ; }); +var x3; +1; +var x4; +''; var x5; var x6; -var x7 = f(), _a = void 0; -var x8 = /123/; +var x7, f; +(function () { }); +var x8; +/123/; diff --git a/tests/baselines/reference/invalidTypeOfTarget.symbols b/tests/baselines/reference/invalidTypeOfTarget.symbols index 007f7fafed8..273abba72de 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.symbols +++ b/tests/baselines/reference/invalidTypeOfTarget.symbols @@ -19,6 +19,7 @@ var x6: typeof null; var x7: typeof function f() { }; >x7 : Symbol(x7, Decl(invalidTypeOfTarget.ts, 6, 3)) +>f : Symbol(f, Decl(invalidTypeOfTarget.ts, 6, 23)) var x8: typeof /123/; >x8 : Symbol(x8, Decl(invalidTypeOfTarget.ts, 7, 3)) diff --git a/tests/baselines/reference/invalidTypeOfTarget.types b/tests/baselines/reference/invalidTypeOfTarget.types index 159a2531cfb..554e6959ec2 100644 --- a/tests/baselines/reference/invalidTypeOfTarget.types +++ b/tests/baselines/reference/invalidTypeOfTarget.types @@ -2,7 +2,6 @@ var x1: typeof {}; >x1 : any > : any ->{} : {} var x2: typeof (): void; >x2 : any @@ -31,8 +30,8 @@ var x6: typeof null; var x7: typeof function f() { }; >x7 : any >function : any ->f() : any >f : any +>() { } : () => void var x8: typeof /123/; >x8 : any diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt index e0f818ba9c1..d91d0fea02d 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt +++ b/tests/baselines/reference/negateOperatorInvalidOperations.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,15): error TS1109: Expression expected. -tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,25): error TS1005: '=' expected. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,25): error TS1005: ',' expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(4,26): error TS1109: Expression expected. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,17): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(7,24): error TS2532: Object is possibly 'undefined'. @@ -7,10 +7,11 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(8,24): error TS2531: Object is possibly 'null'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,17): error TS2532: Object is possibly 'undefined'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(9,29): error TS2532: Object is possibly 'undefined'. +tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(12,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'NUMBER' has type 'any' at tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts 3:18, but here has type 'number'. tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts(12,14): error TS1109: Expression expected. -==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts (10 errors) ==== +==== tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts (11 errors) ==== // Unary operator - // operand before - @@ -18,7 +19,7 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator ~~~ !!! error TS1109: Expression expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1109: Expression expected. @@ -41,5 +42,7 @@ tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperator // miss operand var NUMBER =-; + ~~~~~~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'NUMBER' has type 'any' at tests/cases/conformance/expressions/unaryOperators/negateOperator/negateOperatorInvalidOperations.ts 3:18, but here has type 'number'. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.js b/tests/baselines/reference/negateOperatorInvalidOperations.js index d7aa6154eb2..f905cc28793 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.js +++ b/tests/baselines/reference/negateOperatorInvalidOperations.js @@ -16,7 +16,8 @@ var NUMBER =-; // Unary operator - // operand before - var NUMBER1 = ; -var NUMBER = -; //expect error +var NUMBER; +-; //expect error // invalid expressions var NUMBER2 = -(null - undefined); var NUMBER3 = -(null - null); diff --git a/tests/baselines/reference/negateOperatorInvalidOperations.types b/tests/baselines/reference/negateOperatorInvalidOperations.types index a39bd2b9a1b..bce6fd7e180 100644 --- a/tests/baselines/reference/negateOperatorInvalidOperations.types +++ b/tests/baselines/reference/negateOperatorInvalidOperations.types @@ -5,7 +5,7 @@ var NUMBER1 = var NUMBER-; //expect error >NUMBER1 : any > : any ->NUMBER : number +>NUMBER : any >- : number > : any @@ -36,7 +36,7 @@ var NUMBER4 = -(undefined - undefined); // miss operand var NUMBER =-; ->NUMBER : number +>NUMBER : any >- : number > : any diff --git a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt index f08750ff0a6..ca85c992fa4 100644 --- a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt +++ b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(3,3): error TS1005: ';' expected. tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,15): error TS1005: ',' expected. -tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,23): error TS1005: '=' expected. +tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,23): error TS1005: ',' expected. tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,24): error TS1109: Expression expected. @@ -19,7 +19,7 @@ tests/cases/compiler/numericLiteralsWithTrailingDecimalPoints01.ts(9,24): error ~~~~~~~~ !!! error TS1005: ',' expected. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1109: Expression expected. var test3 = 3 .toString(); diff --git a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js index 54a0328c27c..efa7ae96cf2 100644 --- a/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js +++ b/tests/baselines/reference/numericLiteralsWithTrailingDecimalPoints01.js @@ -27,7 +27,8 @@ toString(); // Preserve whitespace where important for JS compatibility var i = 1; var test1 = i.toString(); -var test2 = 2., toString = (); +var test2 = 2., toString; +(); var test3 = 3..toString(); var test4 = 3..toString(); var test5 = 3..toString(); diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt index 0eed47d2039..20bf52d1ca4 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitInParameterIn tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitMissingValueIsError.ts(2,10): error TS1109: Expression expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,29): error TS1005: '(' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,29): error TS2451: Cannot redeclare block-scoped variable 'await'. -tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,34): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,34): error TS1005: ',' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitNameIsError.ts(1,37): error TS1005: '=>' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,30): error TS1138: Parameter declaration expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/awaitParameterIsError.ts(1,30): error TS2451: Cannot redeclare block-scoped variable 'await'. @@ -20,7 +20,7 @@ tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/nestedFunctionExpr tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldInParameterInitializerIsError.ts(1,34): error TS2523: 'yield' expressions cannot be used in a parameter initializer. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,29): error TS1005: '(' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,29): error TS2451: Cannot redeclare block-scoped variable 'yield'. -tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,34): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,34): error TS1005: ',' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldNameIsError.ts(1,37): error TS1005: '=>' expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,30): error TS1138: Parameter declaration expected. tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldParameterIsError.ts(1,30): error TS2451: Cannot redeclare block-scoped variable 'yield'. @@ -38,7 +38,7 @@ tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingVa ~~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'await'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1005: '=>' expected. }; @@ -49,7 +49,7 @@ tests/cases/conformance/parser/ecmascriptnext/asyncGenerators/yieldStarMissingVa ~~~~~ !!! error TS2451: Cannot redeclare block-scoped variable 'yield'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS1005: '=>' expected. }; diff --git a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types index 557956a3344..6524ee9008c 100644 --- a/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types +++ b/tests/baselines/reference/parser.asyncGenerators.functionExpressions.esnext.types @@ -9,7 +9,7 @@ const f1 = async function * f() { const f2 = async function * await() { >f2 : () => any >async function * : () => any ->await : () => void +>await : any >() {} : () => void }; @@ -17,7 +17,7 @@ const f2 = async function * await() { const f3 = async function * yield() { >f3 : () => any >async function * : () => any ->yield : () => void +>yield : any >() {} : () => void }; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt b/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt new file mode 100644 index 00000000000..03312b63438 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression6.errors.txt @@ -0,0 +1,37 @@ +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,23): error TS2300: Duplicate identifier '(Missing)'. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,24): error TS1005: ',' expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,29): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,30): error TS2300: Duplicate identifier '(Missing)'. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,31): error TS1003: Identifier expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,40): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,41): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,55): error TS1138: Parameter declaration expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,66): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts(2,69): error TS1005: ':' expected. + + +==== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts (10 errors) ==== + function foo(q: string, b: number) { + return true ? (q ? true : false) : (b = q.length, function() { }); + +!!! error TS2300: Duplicate identifier '(Missing)'. + ~~~~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1138: Parameter declaration expected. + +!!! error TS2300: Duplicate identifier '(Missing)'. + ~~~~~ +!!! error TS1003: Identifier expected. + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. + ~~~~~~~~~~~~ +!!! error TS2371: A parameter initializer is only allowed in a function or constructor implementation. + ~~~~~~~~ +!!! error TS1138: Parameter declaration expected. + ~ +!!! error TS1005: '=>' expected. + ~ +!!! error TS1005: ':' expected. + }; + \ No newline at end of file diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.js b/tests/baselines/reference/parserArrowFunctionExpression6.js index 1de3035cc76..75824704b16 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.js +++ b/tests/baselines/reference/parserArrowFunctionExpression6.js @@ -6,6 +6,7 @@ function foo(q: string, b: number) { //// [parserArrowFunctionExpression6.js] function foo(q, b) { - return true ? (q ? true : false) : (b = q.length, function () { }); + return true ? function (q, , ) { } : ; + ; } ; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.symbols b/tests/baselines/reference/parserArrowFunctionExpression6.symbols index 9b3afdbb950..3cf5f44877f 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.symbols +++ b/tests/baselines/reference/parserArrowFunctionExpression6.symbols @@ -5,11 +5,11 @@ function foo(q: string, b: number) { >b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) return true ? (q ? true : false) : (b = q.length, function() { }); ->q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) ->b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 0, 23)) ->q.length : Symbol(String.length, Decl(lib.d.ts, --, --)) ->q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 0, 13)) ->length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 1, 19)) +> : Symbol((Missing), Decl(parserArrowFunctionExpression6.ts, 1, 22)) +> : Symbol((Missing), Decl(parserArrowFunctionExpression6.ts, 1, 29)) +>b : Symbol(b, Decl(parserArrowFunctionExpression6.ts, 1, 40)) +>q : Symbol(q, Decl(parserArrowFunctionExpression6.ts, 1, 19)) }; diff --git a/tests/baselines/reference/parserArrowFunctionExpression6.types b/tests/baselines/reference/parserArrowFunctionExpression6.types index 6cc4f16e216..990670eea63 100644 --- a/tests/baselines/reference/parserArrowFunctionExpression6.types +++ b/tests/baselines/reference/parserArrowFunctionExpression6.types @@ -1,25 +1,21 @@ === tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression6.ts === function foo(q: string, b: number) { ->foo : (q: string, b: number) => boolean | (() => void) +>foo : (q: string, b: number) => any >q : string >b : number return true ? (q ? true : false) : (b = q.length, function() { }); ->true ? (q ? true : false) : (b = q.length, function() { }) : boolean | (() => void) +>true ? (q ? true : false) : (b = q.length, function() { } : any >true : true ->(q ? true : false) : boolean ->q ? true : false : boolean ->q : string ->true : true ->false : false ->(b = q.length, function() { }) : () => void ->b = q.length, function() { } : () => void ->b = q.length : number ->b : number ->q.length : number ->q : string ->length : number ->function() { } : () => void +>(q ? true : false) : (b = q.length, function() { } : (q?: any, : any, : any) => (b?: any) => () => any +>q : any +> : any +> : any +>b : any +>q.length : any +>q : any +>length : any +> : any }; diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.js b/tests/baselines/reference/parserArrowFunctionExpression7.js new file mode 100644 index 00000000000..0646a1bf438 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.js @@ -0,0 +1,16 @@ +//// [parserArrowFunctionExpression7.ts] +({ + async m() { + for (;;) { + } + } +}); + + +//// [parserArrowFunctionExpression7.js] +({ + async m() { + for (;;) { + } + } +}); diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.symbols b/tests/baselines/reference/parserArrowFunctionExpression7.symbols new file mode 100644 index 00000000000..0dbc2cf05a1 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === +({ + async m() { +>m : Symbol(m, Decl(parserArrowFunctionExpression7.ts, 0, 2)) + + for (;;) { + } + } +}); + diff --git a/tests/baselines/reference/parserArrowFunctionExpression7.types b/tests/baselines/reference/parserArrowFunctionExpression7.types new file mode 100644 index 00000000000..072a1548bd2 --- /dev/null +++ b/tests/baselines/reference/parserArrowFunctionExpression7.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts === +({ +>({ async m() { for (;;) { } }}) : { m(): Promise; } +>{ async m() { for (;;) { } }} : { m(): Promise; } + + async m() { +>m : () => Promise + + for (;;) { + } + } +}); + diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt index 6dec4e33c80..0a5ab5e26e6 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,20): error TS2304: Cannot find name 'C'. -tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,22): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts(12,22): error TS1005: ';' expected. ==== tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariables/parserErrorRecovery_IncompleteMemberVariable2.ts (2 errors) ==== @@ -18,7 +18,7 @@ tests/cases/conformance/parser/ecmascript5/ErrorRecovery/IncompleteMemberVariabl ~ !!! error TS2304: Cannot find name 'C'. ~~~~~~~ -!!! error TS1005: '=' expected. +!!! error TS1005: ';' expected. // Constructor constructor (public x: number, public y: number) { } diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js index 757ec40cffb..2ff2b371822 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.js @@ -38,7 +38,6 @@ var Shapes; function Point(x, y) { this.x = x; this.y = y; - this.con = "hello"; } // Instance member Point.prototype.getDist = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.types b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.types index 964df6ddb1c..c83c4dcdd19 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.types +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable2.types @@ -19,7 +19,6 @@ module Shapes { public con:C "hello"; >con : any >C : No type information available! ->"hello" : "hello" // Constructor constructor (public x: number, public y: number) { } diff --git a/tests/baselines/reference/parserTypeQuery8.errors.txt b/tests/baselines/reference/parserTypeQuery8.errors.txt index 4a7098ea8fd..49582f8d1dd 100644 --- a/tests/baselines/reference/parserTypeQuery8.errors.txt +++ b/tests/baselines/reference/parserTypeQuery8.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,15): error TS2304: Cannot find name 'A'. -tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,16): error TS1005: '=' expected. +tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,16): error TS1005: ',' expected. tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,17): error TS2304: Cannot find name 'B'. tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,19): error TS1109: Expression expected. @@ -9,7 +9,7 @@ tests/cases/conformance/parser/ecmascript5/Types/parserTypeQuery8.ts(1,19): erro ~ !!! error TS2304: Cannot find name 'A'. ~ -!!! error TS1005: '=' expected. +!!! error TS1005: ',' expected. ~ !!! error TS2304: Cannot find name 'B'. diff --git a/tests/baselines/reference/parserTypeQuery8.js b/tests/baselines/reference/parserTypeQuery8.js index 995ad013c1f..0600a038db0 100644 --- a/tests/baselines/reference/parserTypeQuery8.js +++ b/tests/baselines/reference/parserTypeQuery8.js @@ -2,4 +2,5 @@ var v: typeof A //// [parserTypeQuery8.js] -var v = ; +var v; +; diff --git a/tests/baselines/reference/restParamModifier.errors.txt b/tests/baselines/reference/restParamModifier.errors.txt index 87c73fcdc71..6b0da564e68 100644 --- a/tests/baselines/reference/restParamModifier.errors.txt +++ b/tests/baselines/reference/restParamModifier.errors.txt @@ -1,21 +1,9 @@ -tests/cases/compiler/restParamModifier.ts(2,17): error TS2370: A rest parameter must be of an array type. -tests/cases/compiler/restParamModifier.ts(2,27): error TS1005: '=' expected. -tests/cases/compiler/restParamModifier.ts(2,27): error TS2304: Cannot find name 'rest'. -tests/cases/compiler/restParamModifier.ts(2,31): error TS1005: ',' expected. -tests/cases/compiler/restParamModifier.ts(2,39): error TS1005: '=' expected. +tests/cases/compiler/restParamModifier.ts(2,27): error TS1005: ',' expected. -==== tests/cases/compiler/restParamModifier.ts (5 errors) ==== +==== tests/cases/compiler/restParamModifier.ts (1 errors) ==== class C { constructor(...public rest: string[]) {} - ~~~~~~~~~~~~~~ -!!! error TS2370: A rest parameter must be of an array type. ~~~~ -!!! error TS1005: '=' expected. - ~~~~ -!!! error TS2304: Cannot find name 'rest'. - ~ !!! error TS1005: ',' expected. - ~ -!!! error TS1005: '=' expected. } \ No newline at end of file diff --git a/tests/baselines/reference/restParamModifier.js b/tests/baselines/reference/restParamModifier.js index 6e7ef6375bc..a8457d40c20 100644 --- a/tests/baselines/reference/restParamModifier.js +++ b/tests/baselines/reference/restParamModifier.js @@ -5,8 +5,7 @@ class C { //// [restParamModifier.js] var C = /** @class */ (function () { - function C(string) { - if (string === void 0) { string = []; } + function C(rest) { } return C; }()); diff --git a/tests/baselines/reference/restParamModifier.symbols b/tests/baselines/reference/restParamModifier.symbols index bd71f92bf2a..d5af28d3e88 100644 --- a/tests/baselines/reference/restParamModifier.symbols +++ b/tests/baselines/reference/restParamModifier.symbols @@ -4,5 +4,5 @@ class C { constructor(...public rest: string[]) {} >public : Symbol(public, Decl(restParamModifier.ts, 1, 16)) ->string : Symbol(string, Decl(restParamModifier.ts, 1, 31)) +>rest : Symbol(rest, Decl(restParamModifier.ts, 1, 25)) } diff --git a/tests/baselines/reference/restParamModifier.types b/tests/baselines/reference/restParamModifier.types index e758a26aea3..d2cbdf3664c 100644 --- a/tests/baselines/reference/restParamModifier.types +++ b/tests/baselines/reference/restParamModifier.types @@ -3,8 +3,6 @@ class C { >C : C constructor(...public rest: string[]) {} ->public : any ->rest : any ->string : any[] ->[] : undefined[] +>public : any[] +>rest : string[] } diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index b813c08705b..56ac090c02c 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -79,21 +79,27 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(162,9): er tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(164,31): error TS2681: A constructor cannot have a 'this' parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(165,30): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,26): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,30): error TS1005: ',' expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,20): error TS2370: A rest parameter must be of an array type. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(168,26): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,23): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,27): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(169,23): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(170,23): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,28): error TS1003: Identifier expected. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,32): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(171,28): error TS2680: A 'this' parameter must be the first parameter. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,30): error TS1005: ',' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,32): error TS1003: Identifier expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,37): error TS1005: ',' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,38): error TS1109: Expression expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,39): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,40): error TS1128: Declaration or statement expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,42): error TS2693: 'number' only refers to a type, but is being used as a value here. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(172,49): error TS1005: ';' expected. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,1): error TS7027: Unreachable code detected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,29): error TS2304: Cannot find name 'm'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,32): error TS1005: ';' expected. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): error TS2304: Cannot find name 'm'. -==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (59 errors) ==== +==== tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts (65 errors) ==== class C { n: number; explicitThis(this: this, m: number): number { @@ -390,31 +396,43 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e function modifiers(async this: C): number { return this.n; } ~~~~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2680: A 'this' parameter must be the first parameter. function restParam(...this: C): number { return this.n; } - ~~~~~~~ -!!! error TS2370: A rest parameter must be of an array type. ~~~~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2680: A 'this' parameter must be the first parameter. function optional(this?: C): number { return this.n; } ~ !!! error TS1005: ',' expected. function decorated(@deco() this: C): number { return this.n; } ~~~~ !!! error TS1003: Identifier expected. - ~ -!!! error TS1005: ',' expected. + ~~~~~~~ +!!! error TS2680: A 'this' parameter must be the first parameter. function initializer(this: C = new C()): number { return this.n; } ~ !!! error TS1005: ',' expected. ~~~ !!! error TS1003: Identifier expected. + ~ +!!! error TS1005: ',' expected. + ~ +!!! error TS1109: Expression expected. + ~ +!!! error TS1005: ';' expected. + ~ +!!! error TS1128: Declaration or statement expected. + ~~~~~~ +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. + ~ +!!! error TS1005: ';' expected. // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; + ~ +!!! error TS7027: Unreachable code detected. ~ !!! error TS2304: Cannot find name 'm'. ~~ diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.js b/tests/baselines/reference/thisTypeInFunctionsNegative.js index 94a0565e237..541bcd2ad36 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.js +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.js @@ -340,18 +340,20 @@ var ThisConstructor = /** @class */ (function () { var thisConstructorType; function notFirst(a) { return this.n; } ///// parse errors ///// -function modifiers(, C) { - if ( === void 0) { = this; } +function modifiers() { return this.n; } +function restParam() { + var = []; + for (var _i = 0; _i < arguments.length; _i++) { + [_i] = arguments[_i]; + } return this.n; } -function restParam(C) { return this.n; } function optional() { return this.n; } -function decorated(, C) { - if ( === void 0) { = this; } - return this.n; -} -function initializer() { - if ( === void 0) { = new C(); } +function decorated() { return this.n; } +function initializer(, C) { } +(); +number; +{ return this.n; } // can't name parameters 'this' in a lambda. diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols index 207af4688f3..61b4274d99f 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.symbols +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.symbols @@ -627,12 +627,14 @@ function notFirst(a: number, this: C): number { return this.n; } function modifiers(async this: C): number { return this.n; } >modifiers : Symbol(modifiers, Decl(thisTypeInFunctionsNegative.ts, 164, 64)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 167, 19)) ->C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 167, 30)) +>this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 167, 24)) +>C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) function restParam(...this: C): number { return this.n; } >restParam : Symbol(restParam, Decl(thisTypeInFunctionsNegative.ts, 167, 60)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 168, 19)) ->C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 168, 27)) +>this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 168, 22)) +>C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) function optional(this?: C): number { return this.n; } >optional : Symbol(optional, Decl(thisTypeInFunctionsNegative.ts, 168, 57)) @@ -644,17 +646,15 @@ function optional(this?: C): number { return this.n; } function decorated(@deco() this: C): number { return this.n; } >decorated : Symbol(decorated, Decl(thisTypeInFunctionsNegative.ts, 169, 54)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 170, 19)) ->C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 170, 32)) +>this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 170, 26)) +>C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) function initializer(this: C = new C()): number { return this.n; } >initializer : Symbol(initializer, Decl(thisTypeInFunctionsNegative.ts, 170, 62)) >this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 171, 21)) >C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) > : Symbol((Missing), Decl(thisTypeInFunctionsNegative.ts, 171, 30)) ->C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 0, 0)) ->this.n : Symbol(C.n, Decl(thisTypeInFunctionsNegative.ts, 0, 9)) ->this : Symbol(this, Decl(thisTypeInFunctionsNegative.ts, 171, 21)) ->n : Symbol(C.n, Decl(thisTypeInFunctionsNegative.ts, 0, 9)) +>C : Symbol(C, Decl(thisTypeInFunctionsNegative.ts, 171, 34)) // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.types b/tests/baselines/reference/thisTypeInFunctionsNegative.types index 12d838c8012..a5a8db3e2ee 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.types +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.types @@ -725,19 +725,19 @@ function notFirst(a: number, this: C): number { return this.n; } ///// parse errors ///// function modifiers(async this: C): number { return this.n; } ->modifiers : (async : any, C: any) => number +>modifiers : (async : any, this: C) => number > : any ->this : any ->C : any +>this : C +>C : C >this.n : any >this : any >n : any function restParam(...this: C): number { return this.n; } ->restParam : (...: any, C: any) => number -> : any ->this : any ->C : any +>restParam : (...: any[], this: C) => number +> : any[] +>this : C +>C : C >this.n : any >this : any >n : any @@ -752,26 +752,28 @@ function optional(this?: C): number { return this.n; } >n : any function decorated(@deco() this: C): number { return this.n; } ->decorated : (: any, C: any) => number +>decorated : (: any, this: C) => number >deco() : any >deco : any > : any ->this : any ->C : any +>this : C +>C : C >this.n : any >this : any >n : any function initializer(this: C = new C()): number { return this.n; } ->initializer : (this: C, ?: C) => number +>initializer : (this: C, : any, C: any) => any >this : C >C : C -> : C ->new C() : C ->C : typeof C ->this.n : number ->this : C ->n : number +> : any +>C : any +>() : any +> : any +>number : any +>this.n : any +>this : any +>n : any // can't name parameters 'this' in a lambda. c.explicitProperty = (this, m) => m + this.n; diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index 46455687af2..52e8b3bf81b 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -2,7 +2,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(1,7): tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(14,5): error TS2322: Type '""' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,55): error TS2304: Cannot find name 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,57): error TS1144: '{' or ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,57): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,60): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(17,62): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(21,33): error TS2304: Cannot find name 'x'. @@ -33,17 +32,14 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(84,1): Parameter 'p2' is not in the same position as parameter 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(90,1): error TS2322: Type '(p1: any, p2: any, p3: any) => p1 is A' is not assignable to type '(p1: any, p2: any) => p1 is A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,9): error TS2304: Cannot find name 'b'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,11): error TS1005: '=' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,11): error TS2304: Cannot find name 'is'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,11): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,14): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(95,14): error TS2300: Duplicate identifier 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,16): error TS2304: Cannot find name 'b'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,18): error TS1005: '=' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,18): error TS2304: Cannot find name 'is'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,18): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(96,21): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,20): error TS2304: Cannot find name 'b'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,22): error TS1144: '{' or ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,22): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(97,27): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(103,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. @@ -55,7 +51,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,9) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(115,18): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,22): error TS2304: Cannot find name 'p1'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,25): error TS1005: ';' expected. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,25): error TS2304: Cannot find name 'is'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(119,28): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(120,1): error TS1128: Declaration or statement expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(123,20): error TS1229: A type predicate cannot reference a rest parameter. @@ -76,7 +71,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,45 tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54): error TS2344: Type 'number' does not satisfy the constraint 'Foo'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (62 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts (57 errors) ==== class A { ~ !!! error TS2300: Duplicate identifier 'A'. @@ -102,8 +97,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 !!! error TS2304: Cannot find name 'x'. ~~ !!! error TS1144: '{' or ';' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. ~ !!! error TS1005: ';' expected. ~ @@ -233,9 +226,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 ~ !!! error TS2304: Cannot find name 'b'. ~~ -!!! error TS1005: '=' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. +!!! error TS1005: ',' expected. ~ !!! error TS1005: ',' expected. ~ @@ -244,9 +235,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 ~ !!! error TS2304: Cannot find name 'b'. ~~ -!!! error TS1005: '=' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. +!!! error TS1005: ',' expected. ~ !!! error TS1005: ',' expected. function b3(): A | b is A { @@ -254,8 +243,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 !!! error TS2304: Cannot find name 'b'. ~~ !!! error TS1144: '{' or ';' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. ~ !!! error TS1005: ';' expected. ~ @@ -300,8 +287,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(166,54 !!! error TS2304: Cannot find name 'p1'. ~~ !!! error TS1005: ';' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. ~ !!! error TS1005: ';' expected. } diff --git a/tests/baselines/reference/typeGuardFunctionErrors.js b/tests/baselines/reference/typeGuardFunctionErrors.js index 32f8244c48e..38e22248d7e 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.js +++ b/tests/baselines/reference/typeGuardFunctionErrors.js @@ -253,10 +253,8 @@ assign3 = function (p1, p2, p3) { return true; }; // Type predicates in non-return type positions -var b1 = is, A; -function b2(a, A) { - if (a === void 0) { a = is; } -} +var b1, is, A; +function b2(a, is, A) { } ; is; A; diff --git a/tests/baselines/reference/typeGuardFunctionErrors.symbols b/tests/baselines/reference/typeGuardFunctionErrors.symbols index 176a79a5855..59f30533674 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.symbols +++ b/tests/baselines/reference/typeGuardFunctionErrors.symbols @@ -34,6 +34,7 @@ function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A { >hasTypeGuardTypeInsideTypeGuardType : Symbol(hasTypeGuardTypeInsideTypeGuardType, Decl(typeGuardFunctionErrors.ts, 14, 1)) >x : Symbol(x, Decl(typeGuardFunctionErrors.ts, 16, 45)) >x : Symbol(x, Decl(typeGuardFunctionErrors.ts, 16, 45)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 94, 9)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0)) return true; @@ -224,16 +225,19 @@ assign3 = function(p1, p2, p3): p1 is A { // Type predicates in non-return type positions var b1: b is A; >b1 : Symbol(b1, Decl(typeGuardFunctionErrors.ts, 94, 3)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 94, 9)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 94, 12)) function b2(a: b is A) {}; >b2 : Symbol(b2, Decl(typeGuardFunctionErrors.ts, 94, 15)) >a : Symbol(a, Decl(typeGuardFunctionErrors.ts, 95, 12)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 95, 16)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 95, 19)) function b3(): A | b is A { >b3 : Symbol(b3, Decl(typeGuardFunctionErrors.ts, 95, 26)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 94, 9)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0)) return true; @@ -286,6 +290,7 @@ interface I2 { [index: number]: p1 is C; >index : Symbol(index, Decl(typeGuardFunctionErrors.ts, 118, 5)) +>is : Symbol(is, Decl(typeGuardFunctionErrors.ts, 94, 9)) >C : Symbol(C, Decl(typeGuardFunctionErrors.ts, 6, 1)) } diff --git a/tests/baselines/reference/typeGuardFunctionErrors.types b/tests/baselines/reference/typeGuardFunctionErrors.types index b4d19baaa18..d8add236887 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.types +++ b/tests/baselines/reference/typeGuardFunctionErrors.types @@ -264,7 +264,7 @@ var b1: b is A; >A : any function b2(a: b is A) {}; ->b2 : (a: any, A: any) => void +>b2 : (a: any, is: any, A: any) => void >a : any >b : No type information available! >is : any diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt b/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt index 30a9a2e49a9..7ce23b916d1 100644 --- a/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration02.errors.txt @@ -1,19 +1,16 @@ tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,8): error TS2304: Cannot find name 'z'. tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,8): error TS4025: Exported variable 'y' has or is using private name 'z'. -tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,10): error TS1005: '=' expected. -tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,10): error TS2304: Cannot find name 'is'. +tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,10): error TS1005: ',' expected. tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts(1,13): error TS1005: ',' expected. -==== tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts (5 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts (4 errors) ==== var y: z is number; ~ !!! error TS2304: Cannot find name 'z'. ~ !!! error TS4025: Exported variable 'y' has or is using private name 'z'. ~~ -!!! error TS1005: '=' expected. - ~~ -!!! error TS2304: Cannot find name 'is'. +!!! error TS1005: ',' expected. ~~~~~~ !!! error TS1005: ',' expected. \ No newline at end of file diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration02.js b/tests/baselines/reference/typePredicateOnVariableDeclaration02.js index 02c4333d43b..c8f376f0d00 100644 --- a/tests/baselines/reference/typePredicateOnVariableDeclaration02.js +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration02.js @@ -2,4 +2,4 @@ var y: z is number; //// [typePredicateOnVariableDeclaration02.js] -var y = is, number; +var y, is, number; diff --git a/tests/baselines/reference/typePredicateOnVariableDeclaration02.symbols b/tests/baselines/reference/typePredicateOnVariableDeclaration02.symbols index 09cb4059d71..7353b734183 100644 --- a/tests/baselines/reference/typePredicateOnVariableDeclaration02.symbols +++ b/tests/baselines/reference/typePredicateOnVariableDeclaration02.symbols @@ -1,5 +1,6 @@ === tests/cases/conformance/expressions/typeGuards/typePredicateOnVariableDeclaration02.ts === var y: z is number; >y : Symbol(y, Decl(typePredicateOnVariableDeclaration02.ts, 0, 3)) +>is : Symbol(is, Decl(typePredicateOnVariableDeclaration02.ts, 0, 8)) >number : Symbol(number, Decl(typePredicateOnVariableDeclaration02.ts, 0, 11)) diff --git a/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts new file mode 100644 index 00000000000..65911cf0fc6 --- /dev/null +++ b/tests/cases/conformance/parser/ecmascript5/ArrowFunctionExpressions/parserArrowFunctionExpression7.ts @@ -0,0 +1,7 @@ +// @target: esnext +({ + async m() { + for (;;) { + } + } +}); diff --git a/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts b/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts index 06a1c24230c..42be3a51618 100644 --- a/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts +++ b/tests/cases/fourslash/completionListImplementingInterfaceFunctions.ts @@ -5,12 +5,12 @@ //// b(): void; ////} //// -////var imp1: I1 { +////var imp1: I1 = { //// a() {}, //// /*0*/ ////} //// -////var imp2: I1 { +////var imp2: I1 = { //// a: () => {}, //// /*1*/ ////} diff --git a/tests/cases/fourslash/formattingReadonly.ts b/tests/cases/fourslash/formattingReadonly.ts index e9ec9860032..cb67b3daf38 100644 --- a/tests/cases/fourslash/formattingReadonly.ts +++ b/tests/cases/fourslash/formattingReadonly.ts @@ -1,12 +1,12 @@ /// ////class C { -//// readonly property1 {};/*1*/ -//// public readonly property2 {};/*2*/ +//// readonly property1: {};/*1*/ +//// public readonly property2: {};/*2*/ ////} format.document(); goTo.marker("1"); -verify.currentLineContentIs(" readonly property1 {};"); +verify.currentLineContentIs(" readonly property1: {};"); goTo.marker("2"); -verify.currentLineContentIs(" public readonly property2 {};"); \ No newline at end of file +verify.currentLineContentIs(" public readonly property2: {};"); From 96dcf398bf319775e96ed96a213026ee8ca0eb09 Mon Sep 17 00:00:00 2001 From: csigs Date: Tue, 14 Nov 2017 17:10:10 +0000 Subject: [PATCH 65/69] LEGO: check in for master to temporary branch. --- .../diagnosticMessages.generated.json.lcl | 45 ++++++++++++++++--- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl index 292a20a49bf..2ab6f838ccd 100644 --- a/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl +++ b/src/loc/lcl/chs/diagnosticMessages/diagnosticMessages.generated.json.lcl @@ -1614,6 +1614,9 @@ + + + @@ -3181,7 +3184,7 @@ - + @@ -3190,7 +3193,7 @@ - + @@ -3199,7 +3202,7 @@ - + @@ -3208,7 +3211,7 @@ - + @@ -3217,7 +3220,7 @@ - + @@ -3226,7 +3229,7 @@ - + @@ -5274,24 +5277,36 @@ + + + + + + + + + + + + @@ -6003,18 +6018,27 @@ + + + + + + + + + @@ -6048,18 +6072,27 @@ + + + + + + + + + From 36ce7eac5a6ae47937b38f4ba53d0a7f87b4ce22 Mon Sep 17 00:00:00 2001 From: meyer Date: Tue, 14 Nov 2017 09:40:32 -0800 Subject: [PATCH 66/69] =?UTF-8?q?Update=20JSX=20intrinsic=20element=20test?= =?UTF-8?q?=20to=20match=20babel=E2=80=99s=20(#19946)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update JSX intrinsic element test to match babel’s * Update baseline * Move regex out of isIntrinsicJsxName * Switch to non-regex intrinsic name test --- src/compiler/utilities.ts | 6 ++--- .../doubleUnderscoreReactNamespace.js | 13 ++++------ .../doubleUnderscoreReactNamespace.symbols | 24 +++++++------------ .../doubleUnderscoreReactNamespace.types | 20 +++++----------- .../reference/jsxEsprimaFbTestSuite.symbols | 4 ++-- .../reference/jsxFactoryIdentifier.js | 3 ++- .../reference/jsxFactoryIdentifier.symbols | 1 + .../reference/jsxFactoryIdentifier.types | 1 + .../reference/reactNamespaceJSXEmit.js | 3 +++ .../reference/reactNamespaceJSXEmit.symbols | 21 ++++++++++------ .../reference/reactNamespaceJSXEmit.types | 8 +++++++ .../doubleUnderscoreReactNamespace.ts | 10 +++----- tests/cases/compiler/jsxFactoryIdentifier.ts | 22 ++++++++--------- .../cases/compiler/reactNamespaceJSXEmit.tsx | 2 ++ 14 files changed, 68 insertions(+), 70 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index e67635cba04..e488cdcc601 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2434,10 +2434,8 @@ namespace ts { } export function isIntrinsicJsxName(name: __String | string) { - // An escaped identifier had a leading underscore prior to being escaped, which would return true - // The escape adds an extra underscore which does not change the result - const ch = (name as string).substr(0, 1); - return ch.toLowerCase() === ch; + const ch = (name as string).charCodeAt(0); + return (ch >= CharacterCodes.a && ch <= CharacterCodes.z) || (name as string).indexOf("-") > -1; } function get16BitUnicodeEscapeSequence(charCode: number): string { diff --git a/tests/baselines/reference/doubleUnderscoreReactNamespace.js b/tests/baselines/reference/doubleUnderscoreReactNamespace.js index de2997d53a6..376a75d0e72 100644 --- a/tests/baselines/reference/doubleUnderscoreReactNamespace.js +++ b/tests/baselines/reference/doubleUnderscoreReactNamespace.js @@ -1,19 +1,16 @@ //// [index.tsx] declare global { - namespace JSX { - interface IntrinsicElements { - __foot: any; - } - } function __make (params: object): any; } +declare var __foot: any; -const thing = <__foot>; +const thing = <__foot />; -export {} +export {} + //// [index.js] "use strict"; exports.__esModule = true; -var thing = __make("__foot", null); +var thing = __make(__foot, null); diff --git a/tests/baselines/reference/doubleUnderscoreReactNamespace.symbols b/tests/baselines/reference/doubleUnderscoreReactNamespace.symbols index 3f942c5f69d..055fb7361e6 100644 --- a/tests/baselines/reference/doubleUnderscoreReactNamespace.symbols +++ b/tests/baselines/reference/doubleUnderscoreReactNamespace.symbols @@ -2,25 +2,17 @@ declare global { >global : Symbol(global, Decl(index.tsx, 0, 0)) - namespace JSX { ->JSX : Symbol(JSX, Decl(index.tsx, 0, 16)) - - interface IntrinsicElements { ->IntrinsicElements : Symbol(IntrinsicElements, Decl(index.tsx, 1, 19)) - - __foot: any; ->__foot : Symbol(IntrinsicElements.__foot, Decl(index.tsx, 2, 37)) - } - } function __make (params: object): any; ->__make : Symbol(__make, Decl(index.tsx, 5, 5)) ->params : Symbol(params, Decl(index.tsx, 6, 21)) +>__make : Symbol(__make, Decl(index.tsx, 0, 16)) +>params : Symbol(params, Decl(index.tsx, 1, 21)) } +declare var __foot: any; +>__foot : Symbol(__foot, Decl(index.tsx, 4, 11)) -const thing = <__foot>; ->thing : Symbol(thing, Decl(index.tsx, 10, 5)) ->__foot : Symbol(JSX.IntrinsicElements.__foot, Decl(index.tsx, 2, 37)) ->__foot : Symbol(JSX.IntrinsicElements.__foot, Decl(index.tsx, 2, 37)) +const thing = <__foot />; +>thing : Symbol(thing, Decl(index.tsx, 6, 5)) +>__foot : Symbol(__foot, Decl(index.tsx, 4, 11)) export {} + diff --git a/tests/baselines/reference/doubleUnderscoreReactNamespace.types b/tests/baselines/reference/doubleUnderscoreReactNamespace.types index 6a9b6d4c984..04382944d86 100644 --- a/tests/baselines/reference/doubleUnderscoreReactNamespace.types +++ b/tests/baselines/reference/doubleUnderscoreReactNamespace.types @@ -2,26 +2,18 @@ declare global { >global : typeof global - namespace JSX { ->JSX : any - - interface IntrinsicElements { ->IntrinsicElements : IntrinsicElements - - __foot: any; ->__foot : any - } - } function __make (params: object): any; >__make : (params: object) => any >params : object } - -const thing = <__foot>; ->thing : any -><__foot> : any +declare var __foot: any; >__foot : any + +const thing = <__foot />; +>thing : any +><__foot /> : any >__foot : any export {} + diff --git a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols index f8f3dfa28dc..969071e4350 100644 --- a/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols +++ b/tests/baselines/reference/jsxEsprimaFbTestSuite.symbols @@ -47,8 +47,8 @@ declare var props; />; <日本語>; ->日本語 : Symbol(unknown) ->日本語 : Symbol(unknown) +>日本語 : Symbol(日本語, Decl(jsxEsprimaFbTestSuite.tsx, 1, 11)) +>日本語 : Symbol(日本語, Decl(jsxEsprimaFbTestSuite.tsx, 1, 11)) AbC_def : Symbol(AbC_def, Decl(jsxEsprimaFbTestSuite.tsx, 2, 11)) diff --git a/tests/baselines/reference/jsxFactoryIdentifier.js b/tests/baselines/reference/jsxFactoryIdentifier.js index 3a3c360a8f1..817ef769d53 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.js +++ b/tests/baselines/reference/jsxFactoryIdentifier.js @@ -47,7 +47,8 @@ class A { ]; } -} +} + //// [Element.js] "use strict"; diff --git a/tests/baselines/reference/jsxFactoryIdentifier.symbols b/tests/baselines/reference/jsxFactoryIdentifier.symbols index b66976f8884..7c8ad0c97cf 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.symbols +++ b/tests/baselines/reference/jsxFactoryIdentifier.symbols @@ -122,3 +122,4 @@ class A { ]; } } + diff --git a/tests/baselines/reference/jsxFactoryIdentifier.types b/tests/baselines/reference/jsxFactoryIdentifier.types index 76f49568531..f6faa0784cd 100644 --- a/tests/baselines/reference/jsxFactoryIdentifier.types +++ b/tests/baselines/reference/jsxFactoryIdentifier.types @@ -137,3 +137,4 @@ class A { ]; } } + diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.js b/tests/baselines/reference/reactNamespaceJSXEmit.js index fc30f7f7bfa..3feaea15b01 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.js +++ b/tests/baselines/reference/reactNamespaceJSXEmit.js @@ -2,6 +2,7 @@ declare var myReactLib: any; declare var foo: any; declare var Bar: any; +declare var _Bar: any; declare var x: any; ; @@ -9,6 +10,7 @@ declare var x: any; ; ; ; +<_Bar { ...x } />; //// [reactNamespaceJSXEmit.js] @@ -25,3 +27,4 @@ myReactLib.createElement(Bar, { x: x }); myReactLib.createElement("x-component", null); myReactLib.createElement(Bar, __assign({}, x)); myReactLib.createElement(Bar, __assign({}, x, { y: 2 })); +myReactLib.createElement(_Bar, __assign({}, x)); diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.symbols b/tests/baselines/reference/reactNamespaceJSXEmit.symbols index b8e58fb1702..ff52f0bff87 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.symbols +++ b/tests/baselines/reference/reactNamespaceJSXEmit.symbols @@ -8,27 +8,34 @@ declare var foo: any; declare var Bar: any; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 2, 11)) +declare var _Bar: any; +>_Bar : Symbol(_Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) + declare var x: any; ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) ; >foo : Symbol(unknown) ->data : Symbol(data, Decl(reactNamespaceJSXEmit.tsx, 5, 4)) +>data : Symbol(data, Decl(reactNamespaceJSXEmit.tsx, 6, 4)) ; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 2, 11)) ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 6, 4)) ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 7, 4)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) ; >x-component : Symbol(unknown) ; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 2, 11)) ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) ; >Bar : Symbol(Bar, Decl(reactNamespaceJSXEmit.tsx, 2, 11)) ->x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) ->y : Symbol(y, Decl(reactNamespaceJSXEmit.tsx, 9, 13)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) +>y : Symbol(y, Decl(reactNamespaceJSXEmit.tsx, 10, 13)) + +<_Bar { ...x } />; +>_Bar : Symbol(_Bar, Decl(reactNamespaceJSXEmit.tsx, 3, 11)) +>x : Symbol(x, Decl(reactNamespaceJSXEmit.tsx, 4, 11)) diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.types b/tests/baselines/reference/reactNamespaceJSXEmit.types index 0c1200b362b..e1d76dbfcec 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.types +++ b/tests/baselines/reference/reactNamespaceJSXEmit.types @@ -8,6 +8,9 @@ declare var foo: any; declare var Bar: any; >Bar : any +declare var _Bar: any; +>_Bar : any + declare var x: any; >x : any @@ -38,3 +41,8 @@ declare var x: any; >y : number >2 : 2 +<_Bar { ...x } />; +><_Bar { ...x } /> : any +>_Bar : any +>x : any + diff --git a/tests/cases/compiler/doubleUnderscoreReactNamespace.ts b/tests/cases/compiler/doubleUnderscoreReactNamespace.ts index bd7789ab1d9..0b718b48e2b 100644 --- a/tests/cases/compiler/doubleUnderscoreReactNamespace.ts +++ b/tests/cases/compiler/doubleUnderscoreReactNamespace.ts @@ -4,15 +4,11 @@ // @filename: index.tsx declare global { - namespace JSX { - interface IntrinsicElements { - __foot: any; - } - } function __make (params: object): any; } +declare var __foot: any; -const thing = <__foot>; +const thing = <__foot />; -export {} \ No newline at end of file +export {} diff --git a/tests/cases/compiler/jsxFactoryIdentifier.ts b/tests/cases/compiler/jsxFactoryIdentifier.ts index 88caf27482e..0ea5c7e850d 100644 --- a/tests/cases/compiler/jsxFactoryIdentifier.ts +++ b/tests/cases/compiler/jsxFactoryIdentifier.ts @@ -1,10 +1,10 @@ -//@jsx: react -//@target: es6 -//@module: commonjs -//@jsxFactory: createElement -//@sourcemap: true - -// @filename: Element.ts +//@jsx: react +//@target: es6 +//@module: commonjs +//@jsxFactory: createElement +//@sourcemap: true + +// @filename: Element.ts declare namespace JSX { interface Element { name: string; @@ -33,9 +33,9 @@ export let createElement = Element.createElement; function toCamelCase(text: string): string { return text[0].toLowerCase() + text.substring(1); -} - -// @filename: test.tsx +} + +// @filename: test.tsx import { Element} from './Element'; let createElement = Element.createElement; let c: { @@ -51,4 +51,4 @@ class A { ]; } -} \ No newline at end of file +} diff --git a/tests/cases/compiler/reactNamespaceJSXEmit.tsx b/tests/cases/compiler/reactNamespaceJSXEmit.tsx index f5ec957a78b..0d11789a275 100644 --- a/tests/cases/compiler/reactNamespaceJSXEmit.tsx +++ b/tests/cases/compiler/reactNamespaceJSXEmit.tsx @@ -4,6 +4,7 @@ declare var myReactLib: any; declare var foo: any; declare var Bar: any; +declare var _Bar: any; declare var x: any; ; @@ -11,3 +12,4 @@ declare var x: any; ; ; ; +<_Bar { ...x } />; From 9c51a8534e1578893c6e5b8e97a0e75b3e970626 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 14 Nov 2017 14:20:18 -0800 Subject: [PATCH 67/69] Synchronize getEntityNameForDecoratorMetadata and serializeUnionOrIntersectionType (#19879) --- src/compiler/checker.ts | 11 +++- .../reference/metadataOfClassFromAlias.js | 1 + .../metadataReferencedWithinFilteredUnion.js | 60 +++++++++++++++++++ ...adataReferencedWithinFilteredUnion.symbols | 28 +++++++++ ...etadataReferencedWithinFilteredUnion.types | 28 +++++++++ .../metadataReferencedWithinFilteredUnion.ts | 18 ++++++ 6 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion.js create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols create mode 100644 tests/baselines/reference/metadataReferencedWithinFilteredUnion.types create mode 100644 tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0ae9486aa4e..6edce1036cb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -20191,7 +20191,16 @@ namespace ts { case SyntaxKind.IntersectionType: case SyntaxKind.UnionType: let commonEntityName: EntityName; - for (const typeNode of (node).types) { + for (let typeNode of (node).types) { + while (typeNode.kind === SyntaxKind.ParenthesizedType) { + typeNode = (typeNode as ParenthesizedTypeNode).type; // Skip parens if need be + } + if (typeNode.kind === SyntaxKind.NeverKeyword) { + continue; // Always elide `never` from the union/intersection if possible + } + if (!strictNullChecks && (typeNode.kind === SyntaxKind.NullKeyword || typeNode.kind === SyntaxKind.UndefinedKeyword)) { + continue; // Elide null and undefined from unions for metadata, just like what we did prior to the implementation of strict null checks + } const individualEntityName = getEntityNameForDecoratorMetadata(typeNode); if (!individualEntityName) { // Individual is something like string number diff --git a/tests/baselines/reference/metadataOfClassFromAlias.js b/tests/baselines/reference/metadataOfClassFromAlias.js index 77ae5c33898..1a8b6b8523c 100644 --- a/tests/baselines/reference/metadataOfClassFromAlias.js +++ b/tests/baselines/reference/metadataOfClassFromAlias.js @@ -35,6 +35,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); +var auxiliry_1 = require("./auxiliry"); function annotation() { return function (target) { }; } diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js new file mode 100644 index 00000000000..6192ac3c0fd --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js @@ -0,0 +1,60 @@ +//// [tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts] //// + +//// [Class1.ts] +export class Class1 { +} +//// [Class2.ts] +import { Class1 } from './Class1'; + +function decorate(target: any, propertyKey: string) { +} + +export class Class2 { + @decorate + get prop(): Class1 | undefined { + return undefined; + } +} + +//// [Class1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var Class1 = /** @class */ (function () { + function Class1() { + } + return Class1; +}()); +exports.Class1 = Class1; +//// [Class2.js] +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var Class1_1 = require("./Class1"); +function decorate(target, propertyKey) { +} +var Class2 = /** @class */ (function () { + function Class2() { + } + Object.defineProperty(Class2.prototype, "prop", { + get: function () { + return undefined; + }, + enumerable: true, + configurable: true + }); + __decorate([ + decorate, + __metadata("design:type", Class1_1.Class1), + __metadata("design:paramtypes", []) + ], Class2.prototype, "prop", null); + return Class2; +}()); +exports.Class2 = Class2; diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols new file mode 100644 index 00000000000..22a198daeca --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.symbols @@ -0,0 +1,28 @@ +=== tests/cases/compiler/Class1.ts === +export class Class1 { +>Class1 : Symbol(Class1, Decl(Class1.ts, 0, 0)) +} +=== tests/cases/compiler/Class2.ts === +import { Class1 } from './Class1'; +>Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) + +function decorate(target: any, propertyKey: string) { +>decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) +>target : Symbol(target, Decl(Class2.ts, 2, 18)) +>propertyKey : Symbol(propertyKey, Decl(Class2.ts, 2, 30)) +} + +export class Class2 { +>Class2 : Symbol(Class2, Decl(Class2.ts, 3, 1)) + + @decorate +>decorate : Symbol(decorate, Decl(Class2.ts, 0, 34)) + + get prop(): Class1 | undefined { +>prop : Symbol(Class2.prop, Decl(Class2.ts, 5, 21)) +>Class1 : Symbol(Class1, Decl(Class2.ts, 0, 8)) + + return undefined; +>undefined : Symbol(undefined) + } +} diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.types b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.types new file mode 100644 index 00000000000..834d490d951 --- /dev/null +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/Class1.ts === +export class Class1 { +>Class1 : Class1 +} +=== tests/cases/compiler/Class2.ts === +import { Class1 } from './Class1'; +>Class1 : typeof Class1 + +function decorate(target: any, propertyKey: string) { +>decorate : (target: any, propertyKey: string) => void +>target : any +>propertyKey : string +} + +export class Class2 { +>Class2 : Class2 + + @decorate +>decorate : (target: any, propertyKey: string) => void + + get prop(): Class1 | undefined { +>prop : Class1 +>Class1 : Class1 + + return undefined; +>undefined : undefined + } +} diff --git a/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts b/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts new file mode 100644 index 00000000000..6fd19622f88 --- /dev/null +++ b/tests/cases/compiler/metadataReferencedWithinFilteredUnion.ts @@ -0,0 +1,18 @@ +// @experimentalDecorators: true +// @emitDecoratorMetadata: true +// @target: es5 +// @filename: Class1.ts +export class Class1 { +} +// @filename: Class2.ts +import { Class1 } from './Class1'; + +function decorate(target: any, propertyKey: string) { +} + +export class Class2 { + @decorate + get prop(): Class1 | undefined { + return undefined; + } +} \ No newline at end of file From 592ee00906557ed313f7692fe6662251e65f915d Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Nov 2017 14:26:49 -0800 Subject: [PATCH 68/69] Have CompletionEntryDetails source use a relative path (#19917) * Have CompletionEntryDetails source use a relative path * Use getCanonicalFileName from services Instead of creating a new one --- src/compiler/builder.ts | 2 +- src/compiler/commandLineParser.ts | 10 ++++----- src/compiler/core.ts | 5 +++-- src/compiler/program.ts | 2 +- src/harness/fourslash.ts | 18 ++++++++++++---- src/services/codefixes/importFixes.ts | 10 ++++----- src/services/completions.ts | 21 ++++++++++++------- src/services/rename.ts | 2 +- src/services/services.ts | 5 +++-- ...letionsImport_default_addToNamedImports.ts | 5 ++++- ...ionsImport_default_addToNamespaceImport.ts | 5 ++++- ...Import_default_alreadyExistedWithRename.ts | 5 ++++- .../completionsImport_default_anonymous.ts | 8 +++++-- ...letionsImport_default_didNotExistBefore.ts | 5 ++++- .../fourslash/completionsImport_matching.ts | 2 +- .../completionsImport_multipleWithSameName.ts | 6 +++--- ...mpletionsImport_named_addToNamedImports.ts | 5 ++++- ...mpletionsImport_named_didNotExistBefore.ts | 4 ++-- ...tionsImport_named_namespaceImportExists.ts | 5 ++++- .../fourslash/completionsImport_ofAlias.ts | 2 +- ...pletionsImport_previousTokenIsSemicolon.ts | 5 ++++- .../fourslash/completionsImport_require.ts | 10 +++++++-- .../completionsImport_shadowedByLocal.ts | 2 +- tests/cases/fourslash/fourslash.ts | 2 +- 24 files changed, 97 insertions(+), 49 deletions(-) diff --git a/src/compiler/builder.ts b/src/compiler/builder.ts index 635855083c0..34ca1bdf0e9 100644 --- a/src/compiler/builder.ts +++ b/src/compiler/builder.ts @@ -77,7 +77,7 @@ namespace ts { } export interface BuilderOptions { - getCanonicalFileName: (fileName: string) => string; + getCanonicalFileName: GetCanonicalFileName; computeHash: (data: string) => string; } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 43ea77c8020..8cec21113c8 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1540,7 +1540,7 @@ namespace ts { host: ParseConfigHost, basePath: string, configFileName: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, resolutionStack: Path[], errors: Push, ): ParsedTsconfig { @@ -1588,7 +1588,7 @@ namespace ts { json: any, host: ParseConfigHost, basePath: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, configFileName: string | undefined, errors: Push ): ParsedTsconfig { @@ -1619,7 +1619,7 @@ namespace ts { sourceFile: JsonSourceFile, host: ParseConfigHost, basePath: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, configFileName: string | undefined, errors: Push ): ParsedTsconfig { @@ -1688,7 +1688,7 @@ namespace ts { extendedConfig: string, host: ParseConfigHost, basePath: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, errors: Push, createDiagnostic: (message: DiagnosticMessage, arg1?: string) => Diagnostic) { extendedConfig = normalizeSlashes(extendedConfig); @@ -1713,7 +1713,7 @@ namespace ts { extendedConfigPath: Path, host: ts.ParseConfigHost, basePath: string, - getCanonicalFileName: (fileName: string) => string, + getCanonicalFileName: GetCanonicalFileName, resolutionStack: Path[], errors: Push, ): ParsedTsconfig | undefined { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f3dd99ee5bf..9f839923e7d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -2033,7 +2033,7 @@ namespace ts { } } - export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: (fileName: string) => string, isAbsolutePathAnUrl: boolean) { + export function getRelativePathToDirectoryOrUrl(directoryPathOrUrl: string, relativeOrAbsolutePath: string, currentDirectory: string, getCanonicalFileName: GetCanonicalFileName, isAbsolutePathAnUrl: boolean) { const pathComponents = getNormalizedPathOrUrlComponents(relativeOrAbsolutePath, currentDirectory); const directoryComponents = getNormalizedPathOrUrlComponents(directoryPathOrUrl, currentDirectory); if (directoryComponents.length > 1 && lastOrUndefined(directoryComponents) === "") { @@ -2819,7 +2819,8 @@ namespace ts { } } - export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string { + export type GetCanonicalFileName = (fileName: string) => string; + export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): GetCanonicalFileName { return useCaseSensitiveFileNames ? ((fileName) => fileName) : ((fileName) => fileName.toLowerCase()); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index cf7c03556f1..6a8c88c3014 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -20,7 +20,7 @@ namespace ts { } /* @internal */ - export function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: (fileName: string) => string): string { + export function computeCommonSourceDirectoryOfFilenames(fileNames: string[], currentDirectory: string, getCanonicalFileName: GetCanonicalFileName): string { let commonPathComponents: string[]; const failed = forEach(fileNames, sourceFile => { // Each file contributes into common source file path diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2687a660ca8..6f08b900ec3 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -867,10 +867,10 @@ namespace FourSlash { }); } - public verifyCompletionListContains(entryId: ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string, spanIndex?: number, hasAction?: boolean, options?: ts.GetCompletionsAtPositionOptions) { + public verifyCompletionListContains(entryId: ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string, spanIndex?: number, hasAction?: boolean, options?: FourSlashInterface.VerifyCompletionListContainsOptions) { const completions = this.getCompletionListAtCaret(options); if (completions) { - this.assertItemInCompletionList(completions.entries, entryId, text, documentation, kind, spanIndex, hasAction); + this.assertItemInCompletionList(completions.entries, entryId, text, documentation, kind, spanIndex, hasAction, options); } else { this.raiseError(`No completions at position '${this.currentCaretPosition}' when looking for '${JSON.stringify(entryId)}'.`); @@ -3071,6 +3071,7 @@ Actual: ${stringify(fullActual)}`); kind: string | undefined, spanIndex: number | undefined, hasAction: boolean | undefined, + options: FourSlashInterface.VerifyCompletionListContainsOptions | undefined, ) { for (const item of items) { if (item.name === entryId.name && item.source === entryId.source) { @@ -3084,7 +3085,12 @@ Actual: ${stringify(fullActual)}`); assert.equal(ts.displayPartsToString(details.displayParts), text, this.assertionMessageAtLastKnownMarker("completion item detail text for " + entryId)); } - assert.deepEqual(details.source, entryId.source === undefined ? undefined : [ts.textPart(entryId.source)]); + if (entryId.source === undefined) { + assert.equal(options && options.sourceDisplay, undefined); + } + else { + assert.deepEqual(details.source, [ts.textPart(options!.sourceDisplay)]); + } } if (kind !== undefined) { @@ -3811,7 +3817,7 @@ namespace FourSlashInterface { // Verifies the completion list contains the specified symbol. The // completion list is brought up if necessary - public completionListContains(entryId: string | ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string, spanIndex?: number, hasAction?: boolean, options?: ts.GetCompletionsAtPositionOptions) { + public completionListContains(entryId: string | ts.Completions.CompletionEntryIdentifier, text?: string, documentation?: string, kind?: string, spanIndex?: number, hasAction?: boolean, options?: VerifyCompletionListContainsOptions) { if (typeof entryId === "string") { entryId = { name: entryId, source: undefined }; } @@ -4547,6 +4553,10 @@ namespace FourSlashInterface { isNewIdentifierLocation?: boolean; } + export interface VerifyCompletionListContainsOptions extends ts.GetCompletionsAtPositionOptions { + sourceDisplay: string; + } + export interface NewContentOptions { // Exactly one of these should be defined. newFileContent?: string; diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 838e19fa35d..8971d1aa75e 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -34,7 +34,7 @@ namespace ts.codefix { host: LanguageServiceHost; checker: TypeChecker; compilerOptions: CompilerOptions; - getCanonicalFileName(fileName: string): string; + getCanonicalFileName: GetCanonicalFileName; cachedImportDeclarations?: ImportDeclarationMap; } @@ -313,7 +313,7 @@ namespace ts.codefix { } } - function getModuleSpecifierForNewImport(sourceFile: SourceFile, moduleSymbol: Symbol, options: CompilerOptions, getCanonicalFileName: (file: string) => string, host: LanguageServiceHost): string | undefined { + export function getModuleSpecifierForNewImport(sourceFile: SourceFile, moduleSymbol: Symbol, options: CompilerOptions, getCanonicalFileName: (file: string) => string, host: LanguageServiceHost): string | undefined { const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; const sourceDirectory = getDirectoryPath(sourceFile.fileName); @@ -523,7 +523,7 @@ namespace ts.codefix { return state > States.NodeModules ? { topLevelNodeModulesIndex, topLevelPackageNameIndex, packageRootIndex, fileNameIndex } : undefined; } - function getPathRelativeToRootDirs(path: string, rootDirs: ReadonlyArray, getCanonicalFileName: (fileName: string) => string): string | undefined { + function getPathRelativeToRootDirs(path: string, rootDirs: ReadonlyArray, getCanonicalFileName: GetCanonicalFileName): string | undefined { return firstDefined(rootDirs, rootDir => getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName)); } @@ -535,12 +535,12 @@ namespace ts.codefix { return fileName; } - function getRelativePathIfInDirectory(path: string, directoryPath: string, getCanonicalFileName: (fileName: string) => string): string | undefined { + function getRelativePathIfInDirectory(path: string, directoryPath: string, getCanonicalFileName: GetCanonicalFileName): string | undefined { const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return isRootedDiskPath(relativePath) || startsWith(relativePath, "..") ? undefined : relativePath; } - function getRelativePath(path: string, directoryPath: string, getCanonicalFileName: (fileName: string) => string) { + function getRelativePath(path: string, directoryPath: string, getCanonicalFileName: GetCanonicalFileName) { const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return !pathIsRelative(relativePath) ? "./" + relativePath : relativePath; } diff --git a/src/services/completions.ts b/src/services/completions.ts index 6a9af1e1941..423919f5353 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -422,8 +422,9 @@ namespace ts.Completions { allSourceFiles: ReadonlyArray, host: LanguageServiceHost, formatContext: formatting.FormatContext, + getCanonicalFileName: GetCanonicalFileName, ): CompletionEntryDetails { - const { name, source } = entryId; + const { name } = entryId; // Compute all the completion symbols again. const symbolCompletion = getSymbolCompletionFromEntryId(typeChecker, log, compilerOptions, sourceFile, position, entryId, allSourceFiles); switch (symbolCompletion.type) { @@ -442,10 +443,10 @@ namespace ts.Completions { } case "symbol": { const { symbol, location, symbolToOriginInfoMap } = symbolCompletion; - const codeActions = getCompletionEntryCodeActions(symbolToOriginInfoMap, symbol, typeChecker, host, compilerOptions, sourceFile, formatContext); + const { codeActions, sourceDisplay } = getCompletionEntryCodeActionsAndSourceDisplay(symbolToOriginInfoMap, symbol, typeChecker, host, compilerOptions, sourceFile, formatContext, getCanonicalFileName); const kindModifiers = SymbolDisplay.getSymbolModifiers(symbol); const { displayParts, documentation, symbolKind, tags } = SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location, location, SemanticMeaning.All); - return { name, kindModifiers, kind: symbolKind, displayParts, documentation, tags, codeActions, source: source === undefined ? undefined : [textPart(source)] }; + return { name, kindModifiers, kind: symbolKind, displayParts, documentation, tags, codeActions, source: sourceDisplay }; } case "none": { // Didn't find a symbol with this name. See if we can find a keyword instead. @@ -466,7 +467,7 @@ namespace ts.Completions { } } - function getCompletionEntryCodeActions( + function getCompletionEntryCodeActionsAndSourceDisplay( symbolToOriginInfoMap: SymbolOriginInfoMap, symbol: Symbol, checker: TypeChecker, @@ -474,14 +475,17 @@ namespace ts.Completions { compilerOptions: CompilerOptions, sourceFile: SourceFile, formatContext: formatting.FormatContext, - ): CodeAction[] | undefined { + getCanonicalFileName: GetCanonicalFileName, + ): { codeActions: CodeAction[] | undefined, sourceDisplay: SymbolDisplayPart[] | undefined } { const symbolOriginInfo = symbolToOriginInfoMap[getSymbolId(symbol)]; if (!symbolOriginInfo) { - return undefined; + return { codeActions: undefined, sourceDisplay: undefined }; } const { moduleSymbol, isDefaultExport } = symbolOriginInfo; - return codefix.getCodeActionForImport(moduleSymbol, { + + const sourceDisplay = [textPart(codefix.getModuleSpecifierForNewImport(sourceFile, moduleSymbol, compilerOptions, getCanonicalFileName, host))]; + const codeActions = codefix.getCodeActionForImport(moduleSymbol, { host, checker, newLineCharacter: host.getNewLine(), @@ -489,10 +493,11 @@ namespace ts.Completions { sourceFile, formatContext, symbolName: getSymbolName(symbol, symbolOriginInfo, compilerOptions.target), - getCanonicalFileName: createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false), + getCanonicalFileName, symbolToken: undefined, kind: isDefaultExport ? codefix.ImportKind.Default : codefix.ImportKind.Named, }); + return { sourceDisplay, codeActions }; } export function getCompletionEntrySymbol( diff --git a/src/services/rename.ts b/src/services/rename.ts index 8411e8200a3..cfe79679fba 100644 --- a/src/services/rename.ts +++ b/src/services/rename.ts @@ -1,6 +1,6 @@ /* @internal */ namespace ts.Rename { - export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: (fileName: string) => string, sourceFile: SourceFile, position: number): RenameInfo { + export function getRenameInfo(typeChecker: TypeChecker, defaultLibFileName: string, getCanonicalFileName: GetCanonicalFileName, sourceFile: SourceFile, position: number): RenameInfo { const getCanonicalDefaultLibName = memoize(() => getCanonicalFileName(ts.normalizePath(defaultLibFileName))); const node = getTouchingWord(sourceFile, position, /*includeJsDocComment*/ true); const renameInfo = node && nodeIsEligibleForRename(node) diff --git a/src/services/services.ts b/src/services/services.ts index 95e23a708a3..8fcd7ef13b8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -938,7 +938,7 @@ namespace ts { private _compilationSettings: CompilerOptions; private currentDirectory: string; - constructor(private host: LanguageServiceHost, getCanonicalFileName: (fileName: string) => string) { + constructor(private host: LanguageServiceHost, getCanonicalFileName: GetCanonicalFileName) { // script id => script index this.currentDirectory = host.getCurrentDirectory(); this.fileNameToEntry = createMap(); @@ -1447,7 +1447,8 @@ namespace ts { { name, source }, program.getSourceFiles(), host, - formattingOptions && formatting.getFormatContext(formattingOptions)); + formattingOptions && formatting.getFormatContext(formattingOptions), + getCanonicalFileName); } function getCompletionEntrySymbol(fileName: string, position: number, name: string, source?: string): Symbol { diff --git a/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts b/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts index 7a7a220ca77..fb561355c36 100644 --- a/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts +++ b/tests/cases/fourslash/completionsImport_default_addToNamedImports.ts @@ -9,7 +9,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts b/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts index 43e3854c5e3..986c2550572 100644 --- a/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts +++ b/tests/cases/fourslash/completionsImport_default_addToNamespaceImport.ts @@ -8,7 +8,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts index ed34d5e4e9c..d8cb53167f5 100644 --- a/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts +++ b/tests/cases/fourslash/completionsImport_default_alreadyExistedWithRename.ts @@ -8,7 +8,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_default_anonymous.ts b/tests/cases/fourslash/completionsImport_default_anonymous.ts index 7c0697584f9..4be0184d9fa 100644 --- a/tests/cases/fourslash/completionsImport_default_anonymous.ts +++ b/tests/cases/fourslash/completionsImport_default_anonymous.ts @@ -10,10 +10,14 @@ ////fooB/*1*/ goTo.marker("0"); -verify.not.completionListContains({ name: "default", source: "/src/foo-bar" }, undefined, undefined, undefined, undefined, undefined, { includeExternalModuleExports: true }); +const options = { + includeExternalModuleExports: true, + sourceDisplay: "./foo-bar", +}; +verify.not.completionListContains({ name: "default", source: "/src/foo-bar" }, undefined, undefined, undefined, undefined, undefined, options); goTo.marker("1"); -verify.completionListContains({ name: "fooBar", source: "/src/foo-bar" }, "(property) default: 0", "", "property", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "fooBar", source: "/src/foo-bar" }, "(property) default: 0", "", "property", /*spanIndex*/ undefined, /*hasAction*/ true, options); verify.applyCodeActionFromCompletion("1", { name: "fooBar", source: "/src/foo-bar", diff --git a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts index 82b8e92a570..a36e4336e61 100644 --- a/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_default_didNotExistBefore.ts @@ -7,7 +7,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_matching.ts b/tests/cases/fourslash/completionsImport_matching.ts index f5f9108fa6c..d8979e18bd9 100644 --- a/tests/cases/fourslash/completionsImport_matching.ts +++ b/tests/cases/fourslash/completionsImport_matching.ts @@ -14,7 +14,7 @@ goTo.marker(""); -const options = { includeExternalModuleExports: true }; +const options = { includeExternalModuleExports: true, sourceDisplay: "./a" }; verify.not.completionListContains({ name: "abcde", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options); verify.not.completionListContains({ name: "dbf", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options); diff --git a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts index c9bb33d6c79..81a054e3d23 100644 --- a/tests/cases/fourslash/completionsImport_multipleWithSameName.ts +++ b/tests/cases/fourslash/completionsImport_multipleWithSameName.ts @@ -14,10 +14,10 @@ ////fo/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true }; +const options = { includeExternalModuleExports: true, sourceDisplay: undefined }; verify.completionListContains("foo", "var foo: number", "", "var", undefined, undefined, options); -verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, options); -verify.completionListContains({ name: "foo", source: "/b" }, "const foo: 1", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, options); +verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./a" }); +verify.completionListContains({ name: "foo", source: "/b" }, "const foo: 1", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./b" }); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts b/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts index b11552d0327..8c0beb058fb 100644 --- a/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts +++ b/tests/cases/fourslash/completionsImport_named_addToNamedImports.ts @@ -9,7 +9,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts index 9397ee004c2..c13fb27f16b 100644 --- a/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts +++ b/tests/cases/fourslash/completionsImport_named_didNotExistBefore.ts @@ -9,8 +9,8 @@ ////t/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true }; -verify.completionListContains({ name: "Test1", source: "/a" }, "function Test1(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, options); +const options = { includeExternalModuleExports: true, sourceDisplay: undefined }; +verify.completionListContains({ name: "Test1", source: "/a" }, "function Test1(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { ...options, sourceDisplay: "./a" }); verify.completionListContains("Test2", "import Test2", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ undefined, options); verify.not.completionListContains({ name: "Test2", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options); diff --git a/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts b/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts index d4602795280..17b909b48ed 100644 --- a/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts +++ b/tests/cases/fourslash/completionsImport_named_namespaceImportExists.ts @@ -8,7 +8,10 @@ ////f/**/; goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_ofAlias.ts b/tests/cases/fourslash/completionsImport_ofAlias.ts index e7cdb366497..69c5041f94f 100644 --- a/tests/cases/fourslash/completionsImport_ofAlias.ts +++ b/tests/cases/fourslash/completionsImport_ofAlias.ts @@ -15,7 +15,7 @@ ////fo/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true }; +const options = { includeExternalModuleExports: true, sourceDisplay: "./a" }; // TODO: https://github.com/Microsoft/TypeScript/issues/14003 verify.completionListContains({ name: "foo", source: "/a" }, "import foo", "", "alias", /*spanIndex*/ undefined, /*hasAction*/ true, options); verify.not.completionListContains({ name: "foo", source: "/a_reexport" }, undefined, undefined, undefined, undefined, undefined, options); diff --git a/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts b/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts index 93c2cc01b0b..06fb93283ee 100644 --- a/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts +++ b/tests/cases/fourslash/completionsImport_previousTokenIsSemicolon.ts @@ -8,4 +8,7 @@ /////**/ goTo.marker(""); -verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "function foo(): void", "", "function", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); diff --git a/tests/cases/fourslash/completionsImport_require.ts b/tests/cases/fourslash/completionsImport_require.ts index e0a6b00d462..8ec750d2c48 100644 --- a/tests/cases/fourslash/completionsImport_require.ts +++ b/tests/cases/fourslash/completionsImport_require.ts @@ -14,7 +14,10 @@ ////fo/*c*/ goTo.marker("b"); -verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("b", { name: "foo", @@ -28,7 +31,10 @@ fo`, }); goTo.marker("c"); -verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { includeExternalModuleExports: true }); +verify.completionListContains({ name: "foo", source: "/a" }, "const foo: 0", "", "const", /*spanIndex*/ undefined, /*hasAction*/ true, { + includeExternalModuleExports: true, + sourceDisplay: "./a", +}); verify.applyCodeActionFromCompletion("c", { name: "foo", diff --git a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts index 20e8c4a4bc8..622f21a2fc7 100644 --- a/tests/cases/fourslash/completionsImport_shadowedByLocal.ts +++ b/tests/cases/fourslash/completionsImport_shadowedByLocal.ts @@ -8,6 +8,6 @@ ////fo/**/ goTo.marker(""); -const options = { includeExternalModuleExports: true }; +const options = { includeExternalModuleExports: true, sourceDisplay: undefined }; verify.completionListContains("foo", "const foo: 1", "", "const", undefined, undefined, options); verify.not.completionListContains({ name: "foo", source: "/a" }, undefined, undefined, undefined, undefined, undefined, options); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index a0ee392a82e..f5984712648 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -148,7 +148,7 @@ declare namespace FourSlashInterface { kind?: string, spanIndex?: number, hasAction?: boolean, - options?: { includeExternalModuleExports: boolean }, + options?: { includeExternalModuleExports: boolean, sourceDisplay: string }, ): void; completionListItemsCountIsGreaterThan(count: number): void; completionListIsEmpty(): void; From 0c77b776ce23eac210f3ef094b055c210c15bf7c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Tue, 14 Nov 2017 16:06:48 -0800 Subject: [PATCH 69/69] Rename and inline functions --- src/compiler/checker.ts | 47 ++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 26 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4f261fbff2c..be57daf6fea 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5111,7 +5111,7 @@ namespace ts { * to "this" in its body, if all base types are interfaces, * and if none of the base interfaces have a "this" type. */ - function isInterfaceFreeOfThisReference(symbol: Symbol): boolean { + function isThislessInterface(symbol: Symbol): boolean { for (const declaration of symbol.declarations) { if (declaration.kind === SyntaxKind.InterfaceDeclaration) { if (declaration.flags & NodeFlags.ContainsThis) { @@ -5145,7 +5145,7 @@ namespace ts { // property types inferred from initializers and method return types inferred from return statements are very hard // to exhaustively analyze). We give interfaces a "this" type if we can't definitely determine that they are free of // "this" references. - if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isInterfaceFreeOfThisReference(symbol)) { + if (outerTypeParameters || localTypeParameters || kind === ObjectFlags.Class || !isThislessInterface(symbol)) { type.objectFlags |= ObjectFlags.Reference; type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; @@ -5327,17 +5327,12 @@ namespace ts { return undefined; } - /** A type reference is free of this references if each type argument is free of this references. */ - function isTypeReferenceFreeOfThisReference(node: TypeReferenceNode): boolean { - return !node.typeArguments || node.typeArguments.every(isTypeFreeOfThisReference); - } - /** * A type is free of this references if it's the any, string, number, boolean, symbol, or void keyword, a string * literal type, an array with an element type that is free of this references, or a type reference that is * free of this references. */ - function isTypeFreeOfThisReference(node: TypeNode): boolean { + function isThislessType(node: TypeNode): boolean { switch (node.kind) { case SyntaxKind.AnyKeyword: case SyntaxKind.StringKeyword: @@ -5352,37 +5347,37 @@ namespace ts { case SyntaxKind.LiteralType: return true; case SyntaxKind.ArrayType: - return isTypeFreeOfThisReference((node).elementType); + return isThislessType((node).elementType); case SyntaxKind.TypeReference: - return isTypeReferenceFreeOfThisReference(node); + return !(node as TypeReferenceNode).typeArguments || (node as TypeReferenceNode).typeArguments.every(isThislessType); } return false; } - /** A type parameter is this-free if its contraint is this-free, or if it has no constraint. */ - function isTypeParameterFreeOfThisReference(node: TypeParameterDeclaration) { - return !node.constraint || isTypeFreeOfThisReference(node.constraint); + /** A type parameter is thisless if its contraint is thisless, or if it has no constraint. */ + function isThislessTypeParameter(node: TypeParameterDeclaration) { + return !node.constraint || isThislessType(node.constraint); } /** * A variable-like declaration is free of this references if it has a type annotation - * that is this-free, or if it has no type annotation and no initializer (and is thus of type any). + * that is thisless, or if it has no type annotation and no initializer (and is thus of type any). */ - function isVariableLikeDeclarationFreeOfThisReference(node: VariableLikeDeclaration): boolean { + function isThislessVariableLikeDeclaration(node: VariableLikeDeclaration): boolean { const typeNode = getEffectiveTypeAnnotationNode(node); - return typeNode ? isTypeFreeOfThisReference(typeNode) : !node.initializer; + return typeNode ? isThislessType(typeNode) : !node.initializer; } /** * A function-like declaration is considered free of `this` references if it has a return type - * annotation that is free of this references and if each parameter is this-free and if - * each type parameter (if present) is this-free. + * annotation that is free of this references and if each parameter is thisless and if + * each type parameter (if present) is thisless. */ - function isFunctionLikeDeclarationFreeOfThisReference(node: FunctionLikeDeclaration): boolean { + function isThislessFunctionLikeDeclaration(node: FunctionLikeDeclaration): boolean { const returnType = getEffectiveReturnTypeNode(node); - return (node.kind === SyntaxKind.Constructor || (returnType && isTypeFreeOfThisReference(returnType))) && - node.parameters.every(isVariableLikeDeclarationFreeOfThisReference) && - (!node.typeParameters || node.typeParameters.every(isTypeParameterFreeOfThisReference)); + return (node.kind === SyntaxKind.Constructor || (returnType && isThislessType(returnType))) && + node.parameters.every(isThislessVariableLikeDeclaration) && + (!node.typeParameters || node.typeParameters.every(isThislessTypeParameter)); } /** @@ -5392,18 +5387,18 @@ namespace ts { * inferred from their initializers and function members with inferred return types are conservatively * assumed not to be free of "this" references. */ - function isFreeOfThisReference(symbol: Symbol): boolean { + function isThisless(symbol: Symbol): boolean { if (symbol.declarations && symbol.declarations.length === 1) { const declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertySignature: - return isVariableLikeDeclarationFreeOfThisReference(declaration); + return isThislessVariableLikeDeclaration(declaration); case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: - return isFunctionLikeDeclarationFreeOfThisReference(declaration); + return isThislessFunctionLikeDeclaration(declaration); } } } @@ -5415,7 +5410,7 @@ namespace ts { function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { const result = createSymbolTable(); for (const symbol of symbols) { - result.set(symbol.escapedName, mappingThisOnly && isFreeOfThisReference(symbol) ? symbol : instantiateSymbol(symbol, mapper)); + result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper)); } return result; }