From e9b48e78c7ba51c7722aeef574548e3e0fe7a327 Mon Sep 17 00:00:00 2001 From: Dhruv Rajvanshi Date: Thu, 16 May 2019 01:37:24 +0530 Subject: [PATCH 01/26] Improve error spans on chained method calls --- src/compiler/checker.ts | 20 +++++++++---- .../reference/methodChainError.errors.txt | 16 +++++++++++ tests/baselines/reference/methodChainError.js | 23 +++++++++++++++ .../reference/methodChainError.symbols | 25 +++++++++++++++++ .../reference/methodChainError.types | 28 +++++++++++++++++++ tests/cases/compiler/methodChainError.ts | 9 ++++++ 6 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/methodChainError.errors.txt create mode 100644 tests/baselines/reference/methodChainError.js create mode 100644 tests/baselines/reference/methodChainError.symbols create mode 100644 tests/baselines/reference/methodChainError.types create mode 100644 tests/cases/compiler/methodChainError.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9f5673af3ee..cfe7a7cdec2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21223,7 +21223,8 @@ namespace ts { reorderCandidates(signatures, candidates); if (!candidates.length) { if (reportErrors) { - diagnostics.add(createDiagnosticForNode(node, Diagnostics.Call_target_does_not_contain_any_signatures)); + const errorNode = getCallErrorNode(node); + diagnostics.add(createDiagnosticForNode(errorNode, Diagnostics.Call_target_does_not_contain_any_signatures)); } return resolveErrorCall(node); } @@ -21301,11 +21302,13 @@ namespace ts { // If candidate is undefined, it means that no candidates had a suitable arity. In that case, // skip the checkApplicableSignature check. if (reportErrors) { + const errorNode = getCallErrorNode(node); + if (candidateForArgumentError) { checkApplicableSignature(node, args, candidateForArgumentError, assignableRelation, CheckMode.Normal, /*reportErrors*/ true); } else if (candidateForArgumentArityError) { - diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args)); + diagnostics.add(getArgumentArityError(errorNode, [candidateForArgumentArityError], args)); } else if (candidateForTypeArgumentError) { checkTypeArguments(candidateForTypeArgumentError, (node as CallExpression | TaggedTemplateExpression | JsxOpeningLikeElement).typeArguments!, /*reportErrors*/ true, fallbackError); @@ -21313,19 +21316,26 @@ namespace ts { else { const signaturesWithCorrectTypeArgumentArity = filter(signatures, s => hasCorrectTypeArgumentArity(s, typeArguments)); if (signaturesWithCorrectTypeArgumentArity.length === 0) { - diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments!)); + diagnostics.add(getTypeArgumentArityError(errorNode, signatures, typeArguments!)); } else if (!isDecorator) { - diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args)); + diagnostics.add(getArgumentArityError(errorNode, signaturesWithCorrectTypeArgumentArity, args)); } else if (fallbackError) { - diagnostics.add(createDiagnosticForNode(node, fallbackError)); + diagnostics.add(createDiagnosticForNode(errorNode, fallbackError)); } } } return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); + function getCallErrorNode(node: CallLikeExpression): Node { + if (isCallExpression(node) && isPropertyAccessExpression(node.expression)) { + return node.expression.name; + } + return node; + } + function chooseOverload(candidates: Signature[], relation: Map, signatureHelpTrailingComma = false) { candidateForArgumentError = undefined; candidateForArgumentArityError = undefined; diff --git a/tests/baselines/reference/methodChainError.errors.txt b/tests/baselines/reference/methodChainError.errors.txt new file mode 100644 index 00000000000..7cd4df95d40 --- /dev/null +++ b/tests/baselines/reference/methodChainError.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/methodChainError.ts(9,6): error TS2554: Expected 1 arguments, but got 0. + + +==== tests/cases/compiler/methodChainError.ts (1 errors) ==== + class Builder { + method(param: string): Builder { + return this; + } + } + + new Builder() + .method("a") + .method(); + ~~~~~~ +!!! error TS2554: Expected 1 arguments, but got 0. +!!! related TS6210 tests/cases/compiler/methodChainError.ts:2:12: An argument for 'param' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/methodChainError.js b/tests/baselines/reference/methodChainError.js new file mode 100644 index 00000000000..648ae505c7a --- /dev/null +++ b/tests/baselines/reference/methodChainError.js @@ -0,0 +1,23 @@ +//// [methodChainError.ts] +class Builder { + method(param: string): Builder { + return this; + } +} + +new Builder() + .method("a") + .method(); + +//// [methodChainError.js] +var Builder = /** @class */ (function () { + function Builder() { + } + Builder.prototype.method = function (param) { + return this; + }; + return Builder; +}()); +new Builder() + .method("a") + .method(); diff --git a/tests/baselines/reference/methodChainError.symbols b/tests/baselines/reference/methodChainError.symbols new file mode 100644 index 00000000000..e73024c784d --- /dev/null +++ b/tests/baselines/reference/methodChainError.symbols @@ -0,0 +1,25 @@ +=== tests/cases/compiler/methodChainError.ts === +class Builder { +>Builder : Symbol(Builder, Decl(methodChainError.ts, 0, 0)) + + method(param: string): Builder { +>method : Symbol(Builder.method, Decl(methodChainError.ts, 0, 15)) +>param : Symbol(param, Decl(methodChainError.ts, 1, 11)) +>Builder : Symbol(Builder, Decl(methodChainError.ts, 0, 0)) + + return this; +>this : Symbol(Builder, Decl(methodChainError.ts, 0, 0)) + } +} + +new Builder() +>new Builder() .method("a") .method : Symbol(Builder.method, Decl(methodChainError.ts, 0, 15)) +>new Builder() .method : Symbol(Builder.method, Decl(methodChainError.ts, 0, 15)) +>Builder : Symbol(Builder, Decl(methodChainError.ts, 0, 0)) + + .method("a") +>method : Symbol(Builder.method, Decl(methodChainError.ts, 0, 15)) + + .method(); +>method : Symbol(Builder.method, Decl(methodChainError.ts, 0, 15)) + diff --git a/tests/baselines/reference/methodChainError.types b/tests/baselines/reference/methodChainError.types new file mode 100644 index 00000000000..e66f6c54b45 --- /dev/null +++ b/tests/baselines/reference/methodChainError.types @@ -0,0 +1,28 @@ +=== tests/cases/compiler/methodChainError.ts === +class Builder { +>Builder : Builder + + method(param: string): Builder { +>method : (param: string) => Builder +>param : string + + return this; +>this : this + } +} + +new Builder() +>new Builder() .method("a") .method() : Builder +>new Builder() .method("a") .method : (param: string) => Builder +>new Builder() .method("a") : Builder +>new Builder() .method : (param: string) => Builder +>new Builder() : Builder +>Builder : typeof Builder + + .method("a") +>method : (param: string) => Builder +>"a" : "a" + + .method(); +>method : (param: string) => Builder + diff --git a/tests/cases/compiler/methodChainError.ts b/tests/cases/compiler/methodChainError.ts new file mode 100644 index 00000000000..657d9a634a5 --- /dev/null +++ b/tests/cases/compiler/methodChainError.ts @@ -0,0 +1,9 @@ +class Builder { + method(param: string): Builder { + return this; + } +} + +new Builder() + .method("a") + .method(); \ No newline at end of file From 3fa111e6c50da4342aeca05e1bc53f71cef83b6c Mon Sep 17 00:00:00 2001 From: Dhruv Rajvanshi Date: Thu, 16 May 2019 01:47:48 +0530 Subject: [PATCH 02/26] Accept new baselines --- .../reference/callWithMissingVoid.errors.txt | 12 +++++------ ...llingBaseImplWithOptionalParams.errors.txt | 4 ++-- ...unctionsWithOptionalParameters2.errors.txt | 4 ++-- ...ortWithExportPropertyAssignment.errors.txt | 4 ++-- .../optionalParamArgsTest.errors.txt | 16 +++++++-------- .../baselines/reference/overload1.errors.txt | 4 ++-- .../reference/strictBindCallApply1.errors.txt | 12 +++++------ .../thisTypeInFunctionsNegative.errors.txt | 20 +++++++++---------- ...eAssertionToGenericFunctionType.errors.txt | 4 ++-- 9 files changed, 40 insertions(+), 40 deletions(-) diff --git a/tests/baselines/reference/callWithMissingVoid.errors.txt b/tests/baselines/reference/callWithMissingVoid.errors.txt index 7ad2a481f2e..67d380be662 100644 --- a/tests/baselines/reference/callWithMissingVoid.errors.txt +++ b/tests/baselines/reference/callWithMissingVoid.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(16,1): error TS2554: Expected 1 arguments, but got 0. -tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(19,1): error TS2554: Expected 1 arguments, but got 0. -tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(22,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(16,6): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(19,10): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(22,8): error TS2554: Expected 1 arguments, but got 0. tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(35,31): error TS2554: Expected 1 arguments, but got 0. tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(36,35): error TS2554: Expected 1 arguments, but got 0. tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(37,33): error TS2554: Expected 1 arguments, but got 0. @@ -28,19 +28,19 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1): declare const xAny: X; xAny.f() // error, any still expects an argument - ~~~~~~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:3:7: An argument for 't' was not provided. declare const xUnknown: X; xUnknown.f() // error, unknown still expects an argument - ~~~~~~~~~~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:3:7: An argument for 't' was not provided. declare const xNever: X; xNever.f() // error, never still expects an argument - ~~~~~~~~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:3:7: An argument for 't' was not provided. diff --git a/tests/baselines/reference/derivedTypeCallingBaseImplWithOptionalParams.errors.txt b/tests/baselines/reference/derivedTypeCallingBaseImplWithOptionalParams.errors.txt index 3dd001eb82c..54c58bd40b5 100644 --- a/tests/baselines/reference/derivedTypeCallingBaseImplWithOptionalParams.errors.txt +++ b/tests/baselines/reference/derivedTypeCallingBaseImplWithOptionalParams.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/derivedTypeCallingBaseImplWithOptionalParams.ts(13,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/compiler/derivedTypeCallingBaseImplWithOptionalParams.ts(13,3): error TS2554: Expected 1 arguments, but got 0. ==== tests/cases/compiler/derivedTypeCallingBaseImplWithOptionalParams.ts (1 errors) ==== @@ -15,6 +15,6 @@ tests/cases/compiler/derivedTypeCallingBaseImplWithOptionalParams.ts(13,1): erro var y: MyClass = new MyClass(); y.myMethod(); // error - ~~~~~~~~~~~~ + ~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/derivedTypeCallingBaseImplWithOptionalParams.ts:5:14: An argument for 'myList' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/genericFunctionsWithOptionalParameters2.errors.txt b/tests/baselines/reference/genericFunctionsWithOptionalParameters2.errors.txt index c4c1ce048c2..9eb49dbf9ba 100644 --- a/tests/baselines/reference/genericFunctionsWithOptionalParameters2.errors.txt +++ b/tests/baselines/reference/genericFunctionsWithOptionalParameters2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericFunctionsWithOptionalParameters2.ts(7,1): error TS2554: Expected 1-3 arguments, but got 0. +tests/cases/compiler/genericFunctionsWithOptionalParameters2.ts(7,7): error TS2554: Expected 1-3 arguments, but got 0. ==== tests/cases/compiler/genericFunctionsWithOptionalParameters2.ts (1 errors) ==== @@ -9,7 +9,7 @@ tests/cases/compiler/genericFunctionsWithOptionalParameters2.ts(7,1): error TS25 var utils: Utils; utils.fold(); // error - ~~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 1-3 arguments, but got 0. !!! related TS6210 tests/cases/compiler/genericFunctionsWithOptionalParameters2.ts:2:15: An argument for 'c' was not provided. utils.fold(null); // no error diff --git a/tests/baselines/reference/moduleExportWithExportPropertyAssignment.errors.txt b/tests/baselines/reference/moduleExportWithExportPropertyAssignment.errors.txt index e40138407d8..009022bdfe3 100644 --- a/tests/baselines/reference/moduleExportWithExportPropertyAssignment.errors.txt +++ b/tests/baselines/reference/moduleExportWithExportPropertyAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/salsa/a.js(4,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/salsa/a.js(4,6): error TS2554: Expected 1 arguments, but got 0. ==== tests/cases/conformance/salsa/a.js (1 errors) ==== @@ -6,7 +6,7 @@ tests/cases/conformance/salsa/a.js(4,1): error TS2554: Expected 1 arguments, but var mod1 = require('./mod1') mod1() mod1.f() // error, not enough arguments - ~~~~~~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 /.src/tests/cases/conformance/salsa/mod1.js:4:30: An argument for 'a' was not provided. diff --git a/tests/baselines/reference/optionalParamArgsTest.errors.txt b/tests/baselines/reference/optionalParamArgsTest.errors.txt index dd53f5eeca1..139c83f7141 100644 --- a/tests/baselines/reference/optionalParamArgsTest.errors.txt +++ b/tests/baselines/reference/optionalParamArgsTest.errors.txt @@ -4,8 +4,8 @@ tests/cases/compiler/optionalParamArgsTest.ts(98,11): error TS2554: Expected 0 a tests/cases/compiler/optionalParamArgsTest.ts(99,11): error TS2554: Expected 0 arguments, but got 1. tests/cases/compiler/optionalParamArgsTest.ts(100,4): error TS2554: Expected 0 arguments, but got 1. tests/cases/compiler/optionalParamArgsTest.ts(101,4): error TS2554: Expected 0 arguments, but got 1. -tests/cases/compiler/optionalParamArgsTest.ts(102,1): error TS2554: Expected 1 arguments, but got 0. -tests/cases/compiler/optionalParamArgsTest.ts(103,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/compiler/optionalParamArgsTest.ts(102,6): error TS2554: Expected 1 arguments, but got 0. +tests/cases/compiler/optionalParamArgsTest.ts(103,6): error TS2554: Expected 1 arguments, but got 0. tests/cases/compiler/optionalParamArgsTest.ts(104,1): error TS2554: Expected 1 arguments, but got 0. tests/cases/compiler/optionalParamArgsTest.ts(105,1): error TS2554: Expected 1 arguments, but got 0. tests/cases/compiler/optionalParamArgsTest.ts(106,13): error TS2554: Expected 1 arguments, but got 2. @@ -16,8 +16,8 @@ tests/cases/compiler/optionalParamArgsTest.ts(110,15): error TS2554: Expected 0- tests/cases/compiler/optionalParamArgsTest.ts(111,15): error TS2554: Expected 0-2 arguments, but got 3. tests/cases/compiler/optionalParamArgsTest.ts(112,8): error TS2554: Expected 0-2 arguments, but got 3. tests/cases/compiler/optionalParamArgsTest.ts(113,8): error TS2554: Expected 0-2 arguments, but got 3. -tests/cases/compiler/optionalParamArgsTest.ts(114,1): error TS2554: Expected 1-2 arguments, but got 0. -tests/cases/compiler/optionalParamArgsTest.ts(115,1): error TS2554: Expected 1-2 arguments, but got 0. +tests/cases/compiler/optionalParamArgsTest.ts(114,6): error TS2554: Expected 1-2 arguments, but got 0. +tests/cases/compiler/optionalParamArgsTest.ts(115,6): error TS2554: Expected 1-2 arguments, but got 0. tests/cases/compiler/optionalParamArgsTest.ts(116,1): error TS2554: Expected 1-2 arguments, but got 0. tests/cases/compiler/optionalParamArgsTest.ts(117,1): error TS2554: Expected 1-2 arguments, but got 0. @@ -137,11 +137,11 @@ tests/cases/compiler/optionalParamArgsTest.ts(117,1): error TS2554: Expected 1-2 ~ !!! error TS2554: Expected 0 arguments, but got 1. c1o1.C1M2(); - ~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:23:17: An argument for 'C1M2A1' was not provided. i1o1.C1M2(); - ~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:11:10: An argument for 'C1M2A1' was not provided. F2(); @@ -177,11 +177,11 @@ tests/cases/compiler/optionalParamArgsTest.ts(117,1): error TS2554: Expected 1-2 ~ !!! error TS2554: Expected 0-2 arguments, but got 3. c1o1.C1M4(); - ~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:29:17: An argument for 'C1M4A1' was not provided. i1o1.C1M4(); - ~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:13:10: An argument for 'C1M4A1' was not provided. F4(); diff --git a/tests/baselines/reference/overload1.errors.txt b/tests/baselines/reference/overload1.errors.txt index aa58f23b95a..6adc8b8b579 100644 --- a/tests/baselines/reference/overload1.errors.txt +++ b/tests/baselines/reference/overload1.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/overload1.ts(27,5): error TS2322: Type 'C' is not assignable to type 'string'. tests/cases/compiler/overload1.ts(29,1): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/compiler/overload1.ts(31,11): error TS2554: Expected 1-2 arguments, but got 3. -tests/cases/compiler/overload1.ts(32,3): error TS2554: Expected 1-2 arguments, but got 0. +tests/cases/compiler/overload1.ts(32,5): error TS2554: Expected 1-2 arguments, but got 0. tests/cases/compiler/overload1.ts(33,1): error TS2322: Type 'C' is not assignable to type 'string'. tests/cases/compiler/overload1.ts(34,9): error TS2345: Argument of type '2' is not assignable to parameter of type 'string'. @@ -45,7 +45,7 @@ tests/cases/compiler/overload1.ts(34,9): error TS2345: Argument of type '2' is n ~ !!! error TS2554: Expected 1-2 arguments, but got 3. z=x.g(); // no match - ~~~~~ + ~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/compiler/overload1.ts:17:11: An argument for 'n' was not provided. z=x.g(new O.B()); // ambiguous (up and down conversion) diff --git a/tests/baselines/reference/strictBindCallApply1.errors.txt b/tests/baselines/reference/strictBindCallApply1.errors.txt index 7b13d5e3181..98d8a19db06 100644 --- a/tests/baselines/reference/strictBindCallApply1.errors.txt +++ b/tests/baselines/reference/strictBindCallApply1.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(11,35): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'. -tests/cases/conformance/functions/strictBindCallApply1.ts(17,11): error TS2554: Expected 3 arguments, but got 2. +tests/cases/conformance/functions/strictBindCallApply1.ts(17,15): error TS2554: Expected 3 arguments, but got 2. tests/cases/conformance/functions/strictBindCallApply1.ts(18,35): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'. tests/cases/conformance/functions/strictBindCallApply1.ts(19,44): error TS2554: Expected 3 arguments, but got 4. tests/cases/conformance/functions/strictBindCallApply1.ts(22,32): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'. @@ -10,7 +10,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(24,32): error TS2345: Type '3' is not assignable to type '2'. tests/cases/conformance/functions/strictBindCallApply1.ts(41,29): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'. tests/cases/conformance/functions/strictBindCallApply1.ts(42,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'. -tests/cases/conformance/functions/strictBindCallApply1.ts(48,11): error TS2554: Expected 3 arguments, but got 2. +tests/cases/conformance/functions/strictBindCallApply1.ts(48,17): error TS2554: Expected 3 arguments, but got 2. tests/cases/conformance/functions/strictBindCallApply1.ts(49,29): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'. tests/cases/conformance/functions/strictBindCallApply1.ts(50,38): error TS2554: Expected 3 arguments, but got 4. tests/cases/conformance/functions/strictBindCallApply1.ts(51,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'. @@ -19,7 +19,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(55,31): error TS2322: tests/cases/conformance/functions/strictBindCallApply1.ts(56,26): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'. tests/cases/conformance/functions/strictBindCallApply1.ts(57,23): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'. tests/cases/conformance/functions/strictBindCallApply1.ts(62,33): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'. -tests/cases/conformance/functions/strictBindCallApply1.ts(65,1): error TS2554: Expected 3 arguments, but got 2. +tests/cases/conformance/functions/strictBindCallApply1.ts(65,3): error TS2554: Expected 3 arguments, but got 2. tests/cases/conformance/functions/strictBindCallApply1.ts(66,15): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'. tests/cases/conformance/functions/strictBindCallApply1.ts(67,24): error TS2554: Expected 3 arguments, but got 4. tests/cases/conformance/functions/strictBindCallApply1.ts(70,12): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'. @@ -47,7 +47,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: let c00 = foo.call(undefined, 10, "hello"); let c01 = foo.call(undefined, 10); // Error - ~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 3 arguments, but got 2. let c02 = foo.call(undefined, 10, 20); // Error ~~ @@ -97,7 +97,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: let c10 = c.foo.call(c, 10, "hello"); let c11 = c.foo.call(c, 10); // Error - ~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 3 arguments, but got 2. let c12 = c.foo.call(c, 10, 20); // Error ~~ @@ -132,7 +132,7 @@ tests/cases/conformance/functions/strictBindCallApply1.ts(72,12): error TS2345: C.call(c, 10, "hello"); C.call(c, 10); // Error - ~~~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 3 arguments, but got 2. C.call(c, 10, 20); // Error ~~ diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 0cf86610f80..4720b4556a4 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -10,7 +10,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(62,97): er Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ y: string; f: (this: { y: number; }, x: number) => number; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(63,110): error TS2322: Type '{ wrongName: number; explicitStructural: (this: { y: number; }, x: number) => number; }' is not assignable to type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(65,4): error TS2554: Expected 1 arguments, but got 0. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type '"wrong type"' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(67,10): error TS2554: Expected 1 arguments, but got 2. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): error TS2684: The 'this' context of type '{ y: string; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. @@ -18,16 +18,16 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): err Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(69,1): error TS2684: The 'this' context of type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' is not assignable to method's 'this' of type '{ y: number; }'. Property 'y' is missing in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }' but required in type '{ y: number; }'. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,3): error TS2554: Expected 1 arguments, but got 0. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type '"wrong type"' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(74,17): error TS2554: Expected 1 arguments, but got 2. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(75,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(75,3): error TS2554: Expected 1 arguments, but got 0. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(76,16): error TS2345: Argument of type '"wrong type 2"' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(77,20): error TS2554: Expected 1 arguments, but got 2. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(78,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(78,3): error TS2554: Expected 1 arguments, but got 0. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(79,16): error TS2345: Argument of type '"wrong type 2"' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(80,20): error TS2554: Expected 1 arguments, but got 2. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,3): error TS2554: Expected 1 arguments, but got 0. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,20): error TS2345: Argument of type '"wrong type 3"' is not assignable to parameter of type 'number'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(83,24): error TS2554: Expected 1 arguments, but got 2. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(86,5): error TS2322: Type '(this: { y: number; }, x: number) => number' is not assignable to type '(this: void, x: number) => number'. @@ -182,7 +182,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(178,22): e !!! error TS2322: Object literal may only specify known properties, and 'explicitStructural' does not exist in type '{ wrongName: number; f: (this: { y: number; }, x: number) => number; }'. ok.f(); // not enough arguments - ~~~~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts:61:46: An argument for 'x' was not provided. ok.f('wrong type'); @@ -204,7 +204,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(178,22): e let c = new C(); c.explicitC(); // not enough arguments - ~~~~~~~~~~~~~ + ~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts:9:24: An argument for 'm' was not provided. c.explicitC('wrong type'); @@ -214,7 +214,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(178,22): e ~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 2. c.explicitThis(); // not enough arguments - ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts:3:30: An argument for 'm' was not provided. c.explicitThis('wrong type 2'); @@ -224,7 +224,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(178,22): e ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 2. c.implicitThis(); // not enough arguments - ~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts:6:18: An argument for 'm' was not provided. c.implicitThis('wrong type 2'); @@ -234,7 +234,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(178,22): e ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 2. c.explicitProperty(); // not enough arguments - ~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts:12:41: An argument for 'm' was not provided. c.explicitProperty('wrong type 3'); diff --git a/tests/baselines/reference/typeAssertionToGenericFunctionType.errors.txt b/tests/baselines/reference/typeAssertionToGenericFunctionType.errors.txt index 551b863c604..ae8a5cb6897 100644 --- a/tests/baselines/reference/typeAssertionToGenericFunctionType.errors.txt +++ b/tests/baselines/reference/typeAssertionToGenericFunctionType.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeAssertionToGenericFunctionType.ts(5,13): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. -tests/cases/compiler/typeAssertionToGenericFunctionType.ts(6,1): error TS2554: Expected 1 arguments, but got 0. +tests/cases/compiler/typeAssertionToGenericFunctionType.ts(6,3): error TS2554: Expected 1 arguments, but got 0. ==== tests/cases/compiler/typeAssertionToGenericFunctionType.ts (2 errors) ==== @@ -11,6 +11,6 @@ tests/cases/compiler/typeAssertionToGenericFunctionType.ts(6,1): error TS2554: E ~ !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. x.b(); // error - ~~~~~~~~~~~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/typeAssertionToGenericFunctionType.ts:3:12: An argument for 'x' was not provided. \ No newline at end of file From 273617cc8873b91b030c8d4e7279c2e331bc46ee Mon Sep 17 00:00:00 2001 From: Dhruv Rajvanshi Date: Mon, 27 May 2019 17:16:05 +0530 Subject: [PATCH 03/26] Use node.expression as error node for call diagnostics --- src/compiler/checker.ts | 8 ++++-- ...yErrorRelatedSpanBindingPattern.errors.txt | 4 +-- .../baselines/reference/baseCheck.errors.txt | 2 +- ...dSameNameFunctionDeclarationES5.errors.txt | 2 +- ...dSameNameFunctionDeclarationES6.errors.txt | 2 +- ...ameFunctionDeclarationStrictES5.errors.txt | 4 +-- ...ameFunctionDeclarationStrictES6.errors.txt | 4 +-- .../reference/callOverload.errors.txt | 2 +- .../reference/callWithMissingVoid.errors.txt | 16 +++++------ ...assCanExtendConstructorFunction.errors.txt | 2 +- .../reference/functionCall11.errors.txt | 2 +- .../reference/functionCall12.errors.txt | 2 +- .../reference/functionCall13.errors.txt | 2 +- .../reference/functionCall16.errors.txt | 2 +- .../reference/functionCall17.errors.txt | 2 +- .../reference/functionCall18.errors.txt | 2 +- .../reference/functionCall6.errors.txt | 2 +- .../reference/functionCall7.errors.txt | 2 +- .../reference/functionOverloads29.errors.txt | 2 +- .../reference/functionOverloads34.errors.txt | 2 +- .../reference/functionOverloads37.errors.txt | 2 +- .../functionParameterArityMismatch.errors.txt | 10 +++---- .../reference/genericRestArity.errors.txt | 2 +- .../genericRestArityStrict.errors.txt | 2 +- .../genericRestParameters3.errors.txt | 2 +- .../iterableArrayPattern25.errors.txt | 2 +- ...leFunctionParametersAsOptional2.errors.txt | 6 ++-- .../jsdocTypeTagRequiredParameters.errors.txt | 6 ++-- .../optionalParamArgsTest.errors.txt | 8 +++--- ...loadsAndTypeArgumentArityErrors.errors.txt | 2 +- .../requiredInitializedParameter1.errors.txt | 4 +-- .../restParamsWithNonRestParams.errors.txt | 2 +- ...romGeneratorMakesRequiredParams.errors.txt | 2 +- .../unionTypeCallSignatures.errors.txt | 28 +++++++++---------- .../unionTypeCallSignatures4.errors.txt | 2 +- 35 files changed, 75 insertions(+), 71 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2cdeaec2cee..44b3b4dc862 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21354,8 +21354,12 @@ namespace ts { return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray); function getCallErrorNode(node: CallLikeExpression): Node { - if (isCallExpression(node) && isPropertyAccessExpression(node.expression)) { - return node.expression.name; + if (isCallExpression(node)) { + if (isPropertyAccessExpression(node.expression)) { + return node.expression.name; + } else { + return node.expression; + } } return node; } diff --git a/tests/baselines/reference/arityErrorRelatedSpanBindingPattern.errors.txt b/tests/baselines/reference/arityErrorRelatedSpanBindingPattern.errors.txt index 788ff30c58f..3ebaaa1004f 100644 --- a/tests/baselines/reference/arityErrorRelatedSpanBindingPattern.errors.txt +++ b/tests/baselines/reference/arityErrorRelatedSpanBindingPattern.errors.txt @@ -8,12 +8,12 @@ tests/cases/compiler/arityErrorRelatedSpanBindingPattern.ts(7,1): error TS2554: function bar(a, b, [c]): void {} foo("", 0); - ~~~~~~~~~~ + ~~~ !!! error TS2554: Expected 3 arguments, but got 2. !!! related TS6211 tests/cases/compiler/arityErrorRelatedSpanBindingPattern.ts:1:20: An argument matching this binding pattern was not provided. bar("", 0); - ~~~~~~~~~~ + ~~~ !!! error TS2554: Expected 3 arguments, but got 2. !!! related TS6211 tests/cases/compiler/arityErrorRelatedSpanBindingPattern.ts:3:20: An argument matching this binding pattern was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/baseCheck.errors.txt b/tests/baselines/reference/baseCheck.errors.txt index 67358a10338..359d689e3fe 100644 --- a/tests/baselines/reference/baseCheck.errors.txt +++ b/tests/baselines/reference/baseCheck.errors.txt @@ -30,7 +30,7 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'. } class D extends C { constructor(public z: number) { super(this.z) } } // too few params - ~~~~~~~~~~~~~ + ~~~~~ !!! error TS2554: Expected 2 arguments, but got 1. !!! related TS6210 tests/cases/compiler/baseCheck.ts:1:34: An argument for 'y' was not provided. ~~~~ diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt index 407c1c22a37..96d23c6a304 100644 --- a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.errors.txt @@ -33,6 +33,6 @@ tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts(16,1): error T } foo(10); foo(); // not ok - needs number - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationES5.ts:1:14: An argument for 'a' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt index 0a6109ee05f..da0e50d3086 100644 --- a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.errors.txt @@ -33,6 +33,6 @@ tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts(16,1): error T } foo(10); foo(); // not ok - needs number - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationES6.ts:1:14: An argument for 'a' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt index b6c4ac4c6a5..c8c98c51917 100644 --- a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES5.errors.txt @@ -29,12 +29,12 @@ tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts(17,1): e } foo(10); foo(); // not ok - needs number - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts:2:14: An argument for 'a' was not provided. } foo(10); foo(); // not ok - needs number - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES5.ts:2:14: An argument for 'a' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt index d9b81d2686f..963b849ee72 100644 --- a/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt +++ b/tests/baselines/reference/blockScopedSameNameFunctionDeclarationStrictES6.errors.txt @@ -23,12 +23,12 @@ tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts(17,1): e } foo(10); foo(); // not ok - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts:2:14: An argument for 'a' was not provided. } foo(10); foo(); // not ok - needs number - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/blockScopedSameNameFunctionDeclarationStrictES6.ts:2:14: An argument for 'a' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/callOverload.errors.txt b/tests/baselines/reference/callOverload.errors.txt index 0f6a2ade085..b08bf7ce891 100644 --- a/tests/baselines/reference/callOverload.errors.txt +++ b/tests/baselines/reference/callOverload.errors.txt @@ -19,7 +19,7 @@ tests/cases/conformance/expressions/functionCalls/callOverload.ts(11,10): error !!! error TS2554: Expected 2 arguments, but got 4. withRest('a', ...n); // no error withRest(); - ~~~~~~~~~~ + ~~~~~~~~ !!! error TS2555: Expected at least 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callOverload.ts:3:27: An argument for 'a' was not provided. withRest(...n); diff --git a/tests/baselines/reference/callWithMissingVoid.errors.txt b/tests/baselines/reference/callWithMissingVoid.errors.txt index 67d380be662..8b38f53acd4 100644 --- a/tests/baselines/reference/callWithMissingVoid.errors.txt +++ b/tests/baselines/reference/callWithMissingVoid.errors.txt @@ -56,15 +56,15 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1): new MyPromise(resolve => resolve()); // no error new MyPromise(resolve => resolve()); // no error new MyPromise(resolve => resolve()); // error, `any` arguments cannot be omitted - ~~~~~~~~~ + ~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided. new MyPromise(resolve => resolve()); // error, `unknown` arguments cannot be omitted - ~~~~~~~~~ + ~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided. new MyPromise(resolve => resolve()); // error, `never` arguments cannot be omitted - ~~~~~~~~~ + ~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:28:38: An argument for 'value' was not provided. @@ -78,7 +78,7 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1): a(4, "hello"); // ok a(4, "hello", void 0); // ok a(4); // not ok - ~~~~ + ~ !!! error TS2554: Expected 3 arguments, but got 1. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:42:23: An argument for 'y' was not provided. @@ -88,15 +88,15 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1): b(4, "hello", void 0, 2); // ok b(4, "hello"); // not ok - ~~~~~~~~~~~~~ + ~ !!! error TS2554: Expected 4 arguments, but got 2. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:34: An argument for 'z' was not provided. b(4, "hello", void 0); // not ok - ~~~~~~~~~~~~~~~~~~~~~ + ~ !!! error TS2554: Expected 4 arguments, but got 3. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:43: An argument for 'what' was not provided. b(4); // not ok - ~~~~ + ~ !!! error TS2554: Expected 4 arguments, but got 1. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:50:23: An argument for 'y' was not provided. @@ -117,7 +117,7 @@ tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts(75,1): ...args: TS): void; call((x: number, y: number) => x + y) // error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 3 arguments, but got 1. !!! related TS6210 tests/cases/conformance/expressions/functionCalls/callWithMissingVoid.ts:73:5: An argument for 'args' was not provided. call((x: number, y: number) => x + y, 4, 2) // ok diff --git a/tests/baselines/reference/classCanExtendConstructorFunction.errors.txt b/tests/baselines/reference/classCanExtendConstructorFunction.errors.txt index 02c5940be14..26b83dc08a6 100644 --- a/tests/baselines/reference/classCanExtendConstructorFunction.errors.txt +++ b/tests/baselines/reference/classCanExtendConstructorFunction.errors.txt @@ -38,7 +38,7 @@ tests/cases/conformance/salsa/second.ts(17,15): error TS2345: Argument of type ' class Sql extends Wagon { constructor() { super(); // error: not enough arguments - ~~~~~~~ + ~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/salsa/first.js:5:16: An argument for 'numberOxen' was not provided. this.foonly = 12 diff --git a/tests/baselines/reference/functionCall11.errors.txt b/tests/baselines/reference/functionCall11.errors.txt index 4fb06f83157..b35a38fd099 100644 --- a/tests/baselines/reference/functionCall11.errors.txt +++ b/tests/baselines/reference/functionCall11.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/functionCall11.ts(6,15): error TS2554: Expected 1-2 argumen foo('foo', 1); foo('foo'); foo(); - ~~~~~ + ~~~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionCall11.ts:1:14: An argument for 'a' was not provided. foo(1, 'bar'); diff --git a/tests/baselines/reference/functionCall12.errors.txt b/tests/baselines/reference/functionCall12.errors.txt index 8b6c02b4804..0221a9006b7 100644 --- a/tests/baselines/reference/functionCall12.errors.txt +++ b/tests/baselines/reference/functionCall12.errors.txt @@ -8,7 +8,7 @@ tests/cases/compiler/functionCall12.ts(7,15): error TS2345: Argument of type '3' foo('foo', 1); foo('foo'); foo(); - ~~~~~ + ~~~ !!! error TS2554: Expected 1-3 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionCall12.ts:1:14: An argument for 'a' was not provided. foo(1, 'bar'); diff --git a/tests/baselines/reference/functionCall13.errors.txt b/tests/baselines/reference/functionCall13.errors.txt index 8e7b5ecc97a..4717d04f241 100644 --- a/tests/baselines/reference/functionCall13.errors.txt +++ b/tests/baselines/reference/functionCall13.errors.txt @@ -7,7 +7,7 @@ tests/cases/compiler/functionCall13.ts(5,5): error TS2345: Argument of type '1' foo('foo', 1); foo('foo'); foo(); - ~~~~~ + ~~~ !!! error TS2555: Expected at least 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionCall13.ts:1:14: An argument for 'a' was not provided. foo(1, 'bar'); diff --git a/tests/baselines/reference/functionCall16.errors.txt b/tests/baselines/reference/functionCall16.errors.txt index 220e2017b67..15e67bb6b14 100644 --- a/tests/baselines/reference/functionCall16.errors.txt +++ b/tests/baselines/reference/functionCall16.errors.txt @@ -11,7 +11,7 @@ tests/cases/compiler/functionCall16.ts(6,5): error TS2345: Argument of type '1' foo('foo'); foo('foo', 'bar'); foo(); - ~~~~~ + ~~~ !!! error TS2555: Expected at least 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionCall16.ts:1:14: An argument for 'a' was not provided. foo(1, 'bar'); diff --git a/tests/baselines/reference/functionCall17.errors.txt b/tests/baselines/reference/functionCall17.errors.txt index 5d1bfe98edd..8bb5a7e3e17 100644 --- a/tests/baselines/reference/functionCall17.errors.txt +++ b/tests/baselines/reference/functionCall17.errors.txt @@ -11,7 +11,7 @@ tests/cases/compiler/functionCall17.ts(6,12): error TS2345: Argument of type '1' !!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo'); foo(); - ~~~~~ + ~~~ !!! error TS2555: Expected at least 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionCall17.ts:1:14: An argument for 'a' was not provided. foo(1, 'bar'); diff --git a/tests/baselines/reference/functionCall18.errors.txt b/tests/baselines/reference/functionCall18.errors.txt index 1744c76982f..dfd0ab9af4f 100644 --- a/tests/baselines/reference/functionCall18.errors.txt +++ b/tests/baselines/reference/functionCall18.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/functionCall18.ts(4,1): error TS2554: Expected 2 arguments, declare function foo(a: T, b: T); declare function foo(a: {}); foo("hello"); - ~~~~~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2554: Expected 2 arguments, but got 1. !!! related TS6210 tests/cases/compiler/functionCall18.ts:2:31: An argument for 'b' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/functionCall6.errors.txt b/tests/baselines/reference/functionCall6.errors.txt index af3d4a0be22..585c12aa354 100644 --- a/tests/baselines/reference/functionCall6.errors.txt +++ b/tests/baselines/reference/functionCall6.errors.txt @@ -13,7 +13,7 @@ tests/cases/compiler/functionCall6.ts(5,1): error TS2554: Expected 1 arguments, ~~~~~ !!! error TS2554: Expected 1 arguments, but got 2. foo(); - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionCall6.ts:1:14: An argument for 'a' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/functionCall7.errors.txt b/tests/baselines/reference/functionCall7.errors.txt index 53a3c575ec3..31d0eb32008 100644 --- a/tests/baselines/reference/functionCall7.errors.txt +++ b/tests/baselines/reference/functionCall7.errors.txt @@ -15,7 +15,7 @@ tests/cases/compiler/functionCall7.ts(7,1): error TS2554: Expected 1 arguments, ~ !!! error TS2345: Argument of type '4' is not assignable to parameter of type 'c1'. foo(); - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionCall7.ts:2:14: An argument for 'a' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads29.errors.txt b/tests/baselines/reference/functionOverloads29.errors.txt index 908380417f9..3f0fdea31b4 100644 --- a/tests/baselines/reference/functionOverloads29.errors.txt +++ b/tests/baselines/reference/functionOverloads29.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/functionOverloads29.ts(4,9): error TS2554: Expected 1 argum function foo(bar:number):number; function foo(bar:any):any{ return bar } var x = foo(); - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionOverloads29.ts:1:14: An argument for 'bar' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads34.errors.txt b/tests/baselines/reference/functionOverloads34.errors.txt index 1d032b7c34d..c83981b9159 100644 --- a/tests/baselines/reference/functionOverloads34.errors.txt +++ b/tests/baselines/reference/functionOverloads34.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/functionOverloads34.ts(4,9): error TS2554: Expected 1 argum function foo(bar:{a:boolean;}):number; function foo(bar:{a:any;}):any{ return bar } var x = foo(); - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionOverloads34.ts:1:14: An argument for 'bar' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads37.errors.txt b/tests/baselines/reference/functionOverloads37.errors.txt index 9f0ac5ee0e5..7760944cd01 100644 --- a/tests/baselines/reference/functionOverloads37.errors.txt +++ b/tests/baselines/reference/functionOverloads37.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/functionOverloads37.ts(4,9): error TS2554: Expected 1 argum function foo(bar:{a:boolean;}[]):number; function foo(bar:{a:any;}[]):any{ return bar } var x = foo(); - ~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionOverloads37.ts:1:14: An argument for 'bar' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/functionParameterArityMismatch.errors.txt b/tests/baselines/reference/functionParameterArityMismatch.errors.txt index aa870c23028..45533c6a3fa 100644 --- a/tests/baselines/reference/functionParameterArityMismatch.errors.txt +++ b/tests/baselines/reference/functionParameterArityMismatch.errors.txt @@ -11,11 +11,11 @@ tests/cases/compiler/functionParameterArityMismatch.ts(14,22): error TS2554: Exp declare function f1(a: number); declare function f1(a: number, b: number, c: number); f1(); - ~~~~ + ~~ !!! error TS2554: Expected 1-3 arguments, but got 0. !!! related TS6210 tests/cases/compiler/functionParameterArityMismatch.ts:1:21: An argument for 'a' was not provided. f1(1, 2); - ~~~~~~~~ + ~~ !!! error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 3 arguments. f1(1, 2, 3, 4); ~ @@ -26,13 +26,13 @@ tests/cases/compiler/functionParameterArityMismatch.ts(14,22): error TS2554: Exp declare function f2(a: number, b: number, c: number, d: number); declare function f2(a: number, b: number, c: number, d: number, e: number, f: number); f2(1); - ~~~~~ + ~~ !!! error TS2575: No overload expects 1 arguments, but overloads do exist that expect either 0 or 2 arguments. f2(1, 2, 3); - ~~~~~~~~~~~ + ~~ !!! error TS2575: No overload expects 3 arguments, but overloads do exist that expect either 2 or 4 arguments. f2(1, 2, 3, 4, 5); - ~~~~~~~~~~~~~~~~~ + ~~ !!! error TS2575: No overload expects 5 arguments, but overloads do exist that expect either 4 or 6 arguments. f2(1, 2, 3, 4, 5, 6, 7); ~ diff --git a/tests/baselines/reference/genericRestArity.errors.txt b/tests/baselines/reference/genericRestArity.errors.txt index e9c98c35584..97889f68bd4 100644 --- a/tests/baselines/reference/genericRestArity.errors.txt +++ b/tests/baselines/reference/genericRestArity.errors.txt @@ -10,7 +10,7 @@ tests/cases/conformance/types/rest/genericRestArity.ts(8,45): error TS2554: Expe ...args: TS): void; call((x: number, y: number) => x + y); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 3 arguments, but got 1. !!! related TS6210 tests/cases/conformance/types/rest/genericRestArity.ts:5:5: An argument for 'args' was not provided. call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); diff --git a/tests/baselines/reference/genericRestArityStrict.errors.txt b/tests/baselines/reference/genericRestArityStrict.errors.txt index c5fc4e9704f..d91611ab494 100644 --- a/tests/baselines/reference/genericRestArityStrict.errors.txt +++ b/tests/baselines/reference/genericRestArityStrict.errors.txt @@ -10,7 +10,7 @@ tests/cases/conformance/types/rest/genericRestArityStrict.ts(8,45): error TS2554 ...args: TS): void; call((x: number, y: number) => x + y); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 3 arguments, but got 1. !!! related TS6210 tests/cases/conformance/types/rest/genericRestArityStrict.ts:5:5: An argument for 'args' was not provided. call((x: number, y: number) => x + y, 1, 2, 3, 4, 5, 6, 7); diff --git a/tests/baselines/reference/genericRestParameters3.errors.txt b/tests/baselines/reference/genericRestParameters3.errors.txt index 612140ea940..417338401e3 100644 --- a/tests/baselines/reference/genericRestParameters3.errors.txt +++ b/tests/baselines/reference/genericRestParameters3.errors.txt @@ -87,7 +87,7 @@ tests/cases/conformance/types/rest/genericRestParameters3.ts(53,5): error TS2345 declare function foo(cb: (...args: T) => void): void; foo>(); // Error - ~~~~~~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/rest/genericRestParameters3.ts:27:39: An argument for 'cb' was not provided. foo>(100); // Error diff --git a/tests/baselines/reference/iterableArrayPattern25.errors.txt b/tests/baselines/reference/iterableArrayPattern25.errors.txt index 0161be07d4b..d566c127e43 100644 --- a/tests/baselines/reference/iterableArrayPattern25.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern25.errors.txt @@ -4,5 +4,5 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts(2,1): error ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern25.ts (1 errors) ==== function takeFirstTwoEntries(...[[k1, v1], [k2, v2]]) { } takeFirstTwoEntries(new Map([["", 0], ["hello", 1]])); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 1. \ No newline at end of file diff --git a/tests/baselines/reference/jsFileFunctionParametersAsOptional2.errors.txt b/tests/baselines/reference/jsFileFunctionParametersAsOptional2.errors.txt index dda54d6dbe3..23b7c200b83 100644 --- a/tests/baselines/reference/jsFileFunctionParametersAsOptional2.errors.txt +++ b/tests/baselines/reference/jsFileFunctionParametersAsOptional2.errors.txt @@ -14,15 +14,15 @@ tests/cases/compiler/bar.ts(3,1): error TS2554: Expected 3 arguments, but got 2. ==== tests/cases/compiler/bar.ts (3 errors) ==== f(); // Error - ~~~ + ~ !!! error TS2554: Expected 3 arguments, but got 0. !!! related TS6210 tests/cases/compiler/foo.js:6:12: An argument for 'a' was not provided. f(1); // Error - ~~~~ + ~ !!! error TS2554: Expected 3 arguments, but got 1. !!! related TS6210 tests/cases/compiler/foo.js:6:15: An argument for 'b' was not provided. f(1, 2); // Error - ~~~~~~~ + ~ !!! error TS2554: Expected 3 arguments, but got 2. !!! related TS6210 tests/cases/compiler/foo.js:6:18: An argument for 'c' was not provided. diff --git a/tests/baselines/reference/jsdocTypeTagRequiredParameters.errors.txt b/tests/baselines/reference/jsdocTypeTagRequiredParameters.errors.txt index 3658797f87f..270050e0317 100644 --- a/tests/baselines/reference/jsdocTypeTagRequiredParameters.errors.txt +++ b/tests/baselines/reference/jsdocTypeTagRequiredParameters.errors.txt @@ -15,15 +15,15 @@ tests/cases/conformance/jsdoc/a.js(13,1): error TS2554: Expected 1 arguments, bu } f() // should error - ~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/jsdoc/a.js:1:21: An argument for '0' was not provided. g() // should error - ~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/jsdoc/a.js:5:12: An argument for 's' was not provided. h() - ~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/jsdoc/a.js:8:12: An argument for 's' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/optionalParamArgsTest.errors.txt b/tests/baselines/reference/optionalParamArgsTest.errors.txt index 139c83f7141..5b7c500db0c 100644 --- a/tests/baselines/reference/optionalParamArgsTest.errors.txt +++ b/tests/baselines/reference/optionalParamArgsTest.errors.txt @@ -145,11 +145,11 @@ tests/cases/compiler/optionalParamArgsTest.ts(117,1): error TS2554: Expected 1-2 !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:11:10: An argument for 'C1M2A1' was not provided. F2(); - ~~~~ + ~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:45:13: An argument for 'F2A1' was not provided. L2(); - ~~~~ + ~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:50:20: An argument for 'L2A1' was not provided. c1o1.C1M2(1,2); @@ -185,11 +185,11 @@ tests/cases/compiler/optionalParamArgsTest.ts(117,1): error TS2554: Expected 1-2 !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:13:10: An argument for 'C1M4A1' was not provided. F4(); - ~~~~ + ~~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:47:13: An argument for 'F4A1' was not provided. L4(); - ~~~~ + ~~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/compiler/optionalParamArgsTest.ts:52:20: An argument for 'L4A1' was not provided. diff --git a/tests/baselines/reference/overloadsAndTypeArgumentArityErrors.errors.txt b/tests/baselines/reference/overloadsAndTypeArgumentArityErrors.errors.txt index 6b64cd8a773..95e9bf27d23 100644 --- a/tests/baselines/reference/overloadsAndTypeArgumentArityErrors.errors.txt +++ b/tests/baselines/reference/overloadsAndTypeArgumentArityErrors.errors.txt @@ -17,7 +17,7 @@ tests/cases/compiler/overloadsAndTypeArgumentArityErrors.ts(9,1): error TS2554: declare function f(arg: number): void; f(); // wrong number of arguments (#25683) - ~~~~~~~~~~~ + ~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/overloadsAndTypeArgumentArityErrors.ts:8:31: An argument for 'arg' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/requiredInitializedParameter1.errors.txt b/tests/baselines/reference/requiredInitializedParameter1.errors.txt index f9baca7a1b5..e5963845d28 100644 --- a/tests/baselines/reference/requiredInitializedParameter1.errors.txt +++ b/tests/baselines/reference/requiredInitializedParameter1.errors.txt @@ -14,7 +14,7 @@ tests/cases/compiler/requiredInitializedParameter1.ts(16,1): error TS2554: Expec f4(0, 1, 2); f1(0, 1); - ~~~~~~~~ + ~~ !!! error TS2554: Expected 3 arguments, but got 2. !!! related TS6210 tests/cases/compiler/requiredInitializedParameter1.ts:1:23: An argument for 'c' was not provided. f2(0, 1); @@ -22,7 +22,7 @@ tests/cases/compiler/requiredInitializedParameter1.ts(16,1): error TS2554: Expec f4(0, 1); f1(0); - ~~~~~ + ~~ !!! error TS2554: Expected 3 arguments, but got 1. !!! related TS6210 tests/cases/compiler/requiredInitializedParameter1.ts:1:16: An argument for 'b' was not provided. f2(0); diff --git a/tests/baselines/reference/restParamsWithNonRestParams.errors.txt b/tests/baselines/reference/restParamsWithNonRestParams.errors.txt index 5bbcf92f702..067cf6c8267 100644 --- a/tests/baselines/reference/restParamsWithNonRestParams.errors.txt +++ b/tests/baselines/reference/restParamsWithNonRestParams.errors.txt @@ -6,7 +6,7 @@ tests/cases/compiler/restParamsWithNonRestParams.ts(4,1): error TS2555: Expected foo(); // ok function foo2(a:string, ...b:number[]){} foo2(); // should be an error - ~~~~~~ + ~~~~ !!! error TS2555: Expected at least 1 arguments, but got 0. !!! related TS6210 tests/cases/compiler/restParamsWithNonRestParams.ts:3:15: An argument for 'a' was not provided. function foo3(a?:string, ...b:number[]){} diff --git a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt index 393e21edb6c..d37b20f7403 100644 --- a/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt +++ b/tests/baselines/reference/spreadOfParamsFromGeneratorMakesRequiredParams.errors.txt @@ -10,6 +10,6 @@ tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts(6,1): err ): any; call(function* (a: 'a') { }); // error, 2nd argument required - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~ !!! error TS2554: Expected 2 arguments, but got 1. !!! related TS6210 tests/cases/compiler/spreadOfParamsFromGeneratorMakesRequiredParams.ts:3:5: An argument for 'args' was not provided. \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeCallSignatures.errors.txt b/tests/baselines/reference/unionTypeCallSignatures.errors.txt index f7a2c9d0766..3aaf2dad581 100644 --- a/tests/baselines/reference/unionTypeCallSignatures.errors.txt +++ b/tests/baselines/reference/unionTypeCallSignatures.errors.txt @@ -52,7 +52,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 ~~~~ !!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. unionOfDifferentReturnType1(); // error missing parameter - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:12:37: An argument for 'a' was not provided. @@ -66,13 +66,13 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 !!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number & string'. !!! error TS2345: Type '"hello"' is not assignable to type 'number'. unionOfDifferentParameterTypes();// error - no call signatures - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:18:40: An argument for 'a' was not provided. var unionOfDifferentNumberOfSignatures: { (a: number): number; } | { (a: number): Date; (a: string): boolean; }; unionOfDifferentNumberOfSignatures(); // error - no call signatures - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:23:44: An argument for 'a' was not provided. unionOfDifferentNumberOfSignatures(10); // error - no call signatures @@ -82,11 +82,11 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; unionWithDifferentParameterCount();// needs more args - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:28:69: An argument for 'a' was not provided. unionWithDifferentParameterCount("hello");// needs more args - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 1. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:28:80: An argument for 'b' was not provided. unionWithDifferentParameterCount("hello", 10);// OK @@ -98,13 +98,13 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 ~~~~~~~ !!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. strOrNum = unionWithOptionalParameter1(); // error - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:33:37: An argument for 'a' was not provided. var unionWithOptionalParameter2: { (a: string, b?: number): string; } | { (a: string, b: number): number }; strOrNum = unionWithOptionalParameter2('hello'); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 1. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:39:87: An argument for 'b' was not provided. strOrNum = unionWithOptionalParameter2('hello', 10); // error no call signature @@ -112,7 +112,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 ~~~~~~~ !!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. strOrNum = unionWithOptionalParameter2(); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:39:76: An argument for 'a' was not provided. @@ -123,7 +123,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 ~~~~~~~ !!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. strOrNum = unionWithOptionalParameter3(); // needs more args - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 1-2 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:45:37: An argument for 'a' was not provided. @@ -135,13 +135,13 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 ~~~~~~~ !!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. strOrNum = unionWithRestParameter1(); // error - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2555: Expected at least 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:51:33: An argument for 'a' was not provided. var unionWithRestParameter2: { (a: string, ...b: number[]): string; } | { (a: string, b: number): number }; strOrNum = unionWithRestParameter2('hello'); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 1. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:58:87: An argument for 'b' was not provided. strOrNum = unionWithRestParameter2('hello', 10); // error no call signature @@ -152,7 +152,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 ~~~~~~~ !!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. strOrNum = unionWithRestParameter2(); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:58:76: An argument for 'a' was not provided. @@ -164,13 +164,13 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 ~~~~~~~ !!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. strOrNum = unionWithRestParameter3(); // error no call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2555: Expected at least 1 arguments, but got 0. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:65:33: An argument for 'a' was not provided. var unionWithRestParameter4: { (...a: string[]): string; } | { (a: string, b: string): number; }; strOrNum = unionWithRestParameter4("hello"); // error supplied parameters do not match any call signature - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2554: Expected 2 arguments, but got 1. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures.ts:72:76: An argument for 'b' was not provided. strOrNum = unionWithRestParameter4("hello", "world"); diff --git a/tests/baselines/reference/unionTypeCallSignatures4.errors.txt b/tests/baselines/reference/unionTypeCallSignatures4.errors.txt index 37f8d7708c5..e991b211db2 100644 --- a/tests/baselines/reference/unionTypeCallSignatures4.errors.txt +++ b/tests/baselines/reference/unionTypeCallSignatures4.errors.txt @@ -26,7 +26,7 @@ tests/cases/conformance/types/union/unionTypeCallSignatures4.ts(25,18): error TS var f12345: F1 | F2 | F3 | F4 | F5; f12345("a"); // error - ~~~~~~~~~~~ + ~~~~~~ !!! error TS2554: Expected 2 arguments, but got 1. !!! related TS6210 tests/cases/conformance/types/union/unionTypeCallSignatures4.ts:5:23: An argument for 'b' was not provided. f12345("a", "b"); From 9ca8045baab84b8e27a1d6b8b15be8ae7c439c7d Mon Sep 17 00:00:00 2001 From: Dhruv Rajvanshi Date: Tue, 28 May 2019 22:23:33 +0530 Subject: [PATCH 04/26] Fix linter errors --- src/compiler/checker.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 44b3b4dc862..ba5a69c32f4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21357,7 +21357,8 @@ namespace ts { if (isCallExpression(node)) { if (isPropertyAccessExpression(node.expression)) { return node.expression.name; - } else { + } + else { return node.expression; } } From 32584249b29638d13444173414f72a5593415f4a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 17 Jun 2019 08:37:33 -1000 Subject: [PATCH 05/26] Union array literals in inference similar to object literals --- src/compiler/checker.ts | 46 +++++++++++++++++++++++++++-------------- src/compiler/types.ts | 15 ++++++++------ 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a4ad3af7d9a..9ffa85e73e1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5481,7 +5481,7 @@ namespace ts { function getTypeFromObjectBindingPattern(pattern: ObjectBindingPattern, includePatternInType: boolean, reportErrors: boolean): Type { const members = createSymbolTable(); let stringIndexInfo: IndexInfo | undefined; - let objectFlags = ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral; + let objectFlags = ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectOrArrayLiteral; forEach(pattern.elements, e => { const name = e.propertyName || e.name; if (e.dotDotDotToken) { @@ -10803,7 +10803,7 @@ namespace ts { emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly)); - spread.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral | ObjectFlags.ContainsSpread | objectFlags; + spread.objectFlags |= ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectOrArrayLiteral | ObjectFlags.ContainsSpread | objectFlags; return spread; } @@ -15644,12 +15644,16 @@ namespace ts { return !!(getObjectFlags(type) & ObjectFlags.ObjectLiteral); } - function widenObjectLiteralCandidates(candidates: Type[]): Type[] { + function isObjectOrArrayLiteralType(type: Type) { + return !!(getObjectFlags(type) & (ObjectFlags.ObjectLiteral | ObjectFlags.ArrayLiteral)); + } + + function unionObjectAndArrayLiteralCandidates(candidates: Type[]): Type[] { if (candidates.length > 1) { - const objectLiterals = filter(candidates, isObjectLiteralType); + const objectLiterals = filter(candidates, isObjectOrArrayLiteralType); if (objectLiterals.length) { - const objectLiteralsType = getWidenedType(getUnionType(objectLiterals, UnionReduction.Subtype)); - return concatenate(filter(candidates, t => !isObjectLiteralType(t)), [objectLiteralsType]); + const literalsType = getUnionType(objectLiterals, UnionReduction.Subtype); + return concatenate(filter(candidates, t => !isObjectOrArrayLiteralType(t)), [literalsType]); } } return candidates; @@ -15660,8 +15664,8 @@ namespace ts { } function getCovariantInference(inference: InferenceInfo, signature: Signature) { - // Extract all object literal types and replace them with a single widened and normalized type. - const candidates = widenObjectLiteralCandidates(inference.candidates!); + // Extract all object and array literal types and replace them with a single widened and normalized type. + const candidates = unionObjectAndArrayLiteralCandidates(inference.candidates!); // We widen inferred literal types if // all inferences were made to top-level occurrences of the type parameter, and // the type parameter has no constraint or its constraint includes no primitive or literal types, and @@ -19147,22 +19151,34 @@ namespace ts { const minLength = elementCount - (hasRestElement ? 1 : 0); // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such // that we get the same behavior for "var [x, y] = []" and "[x, y] = []". - let tupleResult: Type | undefined; + let tupleResult; if (inDestructuringPattern && minLength > 0) { const type = cloneTypeReference(createTupleType(elementTypes, minLength, hasRestElement)); type.pattern = node; return type; } else if (tupleResult = getArrayLiteralTupleTypeIfApplicable(elementTypes, contextualType, hasRestElement, elementCount, inConstContext)) { - return tupleResult; + return createArrayLiteralType(tupleResult); } else if (forceTuple) { - return createTupleType(elementTypes, minLength, hasRestElement); + return createArrayLiteralType(createTupleType(elementTypes, minLength, hasRestElement)); } } - return createArrayType(elementTypes.length ? + return createArrayLiteralType(createArrayType(elementTypes.length ? getUnionType(elementTypes, UnionReduction.Subtype) : - strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext); + strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext)); + } + + function createArrayLiteralType(type: ObjectType) { + if (!(getObjectFlags(type) & ObjectFlags.Reference)) { + return type; + } + let literalType = (type).literalType; + if (!literalType) { + literalType = (type).literalType = cloneTypeReference(type); + literalType.objectFlags |= ObjectFlags.ArrayLiteral | ObjectFlags.ContainsObjectOrArrayLiteral; + } + return literalType; } function getArrayLiteralTupleTypeIfApplicable(elementTypes: Type[], contextualType: Type | undefined, hasRestElement: boolean, elementCount = elementTypes.length, readonly = false) { @@ -19447,7 +19463,7 @@ namespace ts { const stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, IndexKind.String) : undefined; const numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, IndexKind.Number) : undefined; const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); - result.objectFlags |= objectFlags | ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral; + result.objectFlags |= objectFlags | ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectOrArrayLiteral; if (isJSObjectLiteral) { result.objectFlags |= ObjectFlags.JSLiteral; } @@ -19643,7 +19659,7 @@ namespace ts { function createJsxAttributesType() { objectFlags |= freshObjectLiteralFlag; const result = createAnonymousType(attributes.symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - result.objectFlags |= objectFlags | ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectLiteral; + result.objectFlags |= objectFlags | ObjectFlags.ObjectLiteral | ObjectFlags.ContainsObjectOrArrayLiteral; return result; } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0e99b22a5a1..3483ffce6f0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -4089,19 +4089,20 @@ namespace ts { MarkerType = 1 << 13, // Marker type used for variance probing JSLiteral = 1 << 14, // Object type declared in JS - disables errors on read/write of nonexisting members FreshLiteral = 1 << 15, // Fresh object literal + ArrayLiteral = 1 << 16, // Originates in an array literal /* @internal */ - PrimitiveUnion = 1 << 16, // Union of only primitive types + PrimitiveUnion = 1 << 17, // Union of only primitive types /* @internal */ - ContainsWideningType = 1 << 17, // Type is or contains undefined or null widening type + ContainsWideningType = 1 << 18, // Type is or contains undefined or null widening type /* @internal */ - ContainsObjectLiteral = 1 << 18, // Type is or contains object literal type + ContainsObjectOrArrayLiteral = 1 << 19, // Type is or contains object literal type /* @internal */ - NonInferrableType = 1 << 19, // Type is or contains anyFunctionType or silentNeverType + NonInferrableType = 1 << 20, // Type is or contains anyFunctionType or silentNeverType ClassOrInterface = Class | Interface, /* @internal */ - RequiresWidening = ContainsWideningType | ContainsObjectLiteral, + RequiresWidening = ContainsWideningType | ContainsObjectOrArrayLiteral, /* @internal */ - PropagatingFlags = ContainsWideningType | ContainsObjectLiteral | NonInferrableType + PropagatingFlags = ContainsWideningType | ContainsObjectOrArrayLiteral | NonInferrableType } /* @internal */ @@ -4154,6 +4155,8 @@ namespace ts { export interface TypeReference extends ObjectType { target: GenericType; // Type reference target typeArguments?: ReadonlyArray; // Type reference type arguments (undefined if none) + /* @internal */ + literalType?: TypeReference; // Clone of type with ObjectFlags.ArrayLiteral set } /* @internal */ From 3568beb4836549b9005bf8c8827c9845ac9fcca2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 17 Jun 2019 08:46:41 -1000 Subject: [PATCH 06/26] Accept new baselines --- tests/baselines/reference/api/tsserverlibrary.d.ts | 1 + tests/baselines/reference/api/typescript.d.ts | 1 + .../reference/contextualTypeWithTuple.errors.txt | 4 ++++ .../reference/objectLiteralNormalization.errors.txt | 10 +++++++++- .../baselines/reference/objectLiteralNormalization.js | 8 ++------ .../reference/objectLiteralNormalization.types | 8 ++++---- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index b73886dfa09..a4620121d93 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2303,6 +2303,7 @@ declare namespace ts { MarkerType = 8192, JSLiteral = 16384, FreshLiteral = 32768, + ArrayLiteral = 65536, ClassOrInterface = 3, } interface ObjectType extends Type { diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 6f75dbaf3fd..0940735647c 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2303,6 +2303,7 @@ declare namespace ts { MarkerType = 8192, JSLiteral = 16384, FreshLiteral = 32768, + ArrayLiteral = 65536, ClassOrInterface = 3, } interface ObjectType extends Type { diff --git a/tests/baselines/reference/contextualTypeWithTuple.errors.txt b/tests/baselines/reference/contextualTypeWithTuple.errors.txt index 14228786ef0..d4792119352 100644 --- a/tests/baselines/reference/contextualTypeWithTuple.errors.txt +++ b/tests/baselines/reference/contextualTypeWithTuple.errors.txt @@ -2,6 +2,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS232 Types of property 'length' are incompatible. Type '3' is not assignable to type '2'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'. + Types of property 'length' are incompatible. + Type '3' is not assignable to type '2'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,17): error TS2741: Property 'a' is missing in type '{}' but required in type '{ a: string; }'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(19,1): error TS2741: Property '2' is missing in type '[number, string]' but required in type '[number, string, boolean]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(20,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]'. @@ -38,6 +40,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23 numStrTuple = numStrBoolTuple; ~~~~~~~~~~~ !!! error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'. +!!! error TS2322: Types of property 'length' are incompatible. +!!! error TS2322: Type '3' is not assignable to type '2'. // error objNumTuple = [ {}, 5]; diff --git a/tests/baselines/reference/objectLiteralNormalization.errors.txt b/tests/baselines/reference/objectLiteralNormalization.errors.txt index bc2dfdf2284..bd14787178b 100644 --- a/tests/baselines/reference/objectLiteralNormalization.errors.txt +++ b/tests/baselines/reference/objectLiteralNormalization.errors.txt @@ -9,9 +9,11 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts Type 'string' is not assignable to type 'undefined'. tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(18,1): error TS2322: Type '{ a: number; }' is not assignable to type '{ a: number; b: number; } | { a: string; b?: undefined; } | { a?: undefined; b?: undefined; }'. Property 'b' is missing in type '{ a: number; }' but required in type '{ a: number; b: number; }'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(48,20): error TS2322: Type '2' is not assignable to type '1'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts(49,14): error TS2322: Type '2' is not assignable to type '1'. -==== tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts (5 errors) ==== +==== tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts (7 errors) ==== // Object literals in unions are normalized upon widening let a1 = [{ a: 0 }, { a: 1, b: "x" }, { a: 2, b: "y", c: true }][0]; a1.a; // number @@ -78,5 +80,11 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts let e1 = f({ a: 1, b: 2 }, { a: "abc" }, {}); let e2 = f({}, { a: "abc" }, { a: 1, b: 2 }); let e3 = f(data, { a: 2 }); + ~ +!!! error TS2322: Type '2' is not assignable to type '1'. +!!! related TS6500 tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts:43:21: The expected type comes from property 'a' which is declared here on type '{ a: 1; b: "abc"; c: true; }' let e4 = f({ a: 2 }, data); + ~ +!!! error TS2322: Type '2' is not assignable to type '1'. +!!! related TS6500 tests/cases/conformance/expressions/objectLiterals/objectLiteralNormalization.ts:43:21: The expected type comes from property 'a' which is declared here on type '{ a: 1; b: "abc"; c: true; }' \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralNormalization.js b/tests/baselines/reference/objectLiteralNormalization.js index 0d27e3a954d..1a8aa8d4b04 100644 --- a/tests/baselines/reference/objectLiteralNormalization.js +++ b/tests/baselines/reference/objectLiteralNormalization.js @@ -227,9 +227,5 @@ declare let e2: { a: number; b: number; }; -declare let e3: { - a: number; -}; -declare let e4: { - a: number; -}; +declare let e3: any; +declare let e4: any; diff --git a/tests/baselines/reference/objectLiteralNormalization.types b/tests/baselines/reference/objectLiteralNormalization.types index fbef2e824be..15c3b6b3ecf 100644 --- a/tests/baselines/reference/objectLiteralNormalization.types +++ b/tests/baselines/reference/objectLiteralNormalization.types @@ -304,8 +304,8 @@ let e2 = f({}, { a: "abc" }, { a: 1, b: 2 }); >2 : 2 let e3 = f(data, { a: 2 }); ->e3 : { a: number; } ->f(data, { a: 2 }) : { a: number; } +>e3 : any +>f(data, { a: 2 }) : any >f : (...items: T[]) => T >data : { a: 1; b: "abc"; c: true; } >{ a: 2 } : { a: number; } @@ -313,8 +313,8 @@ let e3 = f(data, { a: 2 }); >2 : 2 let e4 = f({ a: 2 }, data); ->e4 : { a: number; } ->f({ a: 2 }, data) : { a: number; } +>e4 : any +>f({ a: 2 }, data) : any >f : (...items: T[]) => T >{ a: 2 } : { a: number; } >a : number From 51712fb1aee91bd5b5c3f528c2676abbbeb332fc Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 17 Jun 2019 16:18:13 -1000 Subject: [PATCH 07/26] Add tests --- .../arrayLiterals/arrayLiteralInference.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/cases/conformance/expressions/arrayLiterals/arrayLiteralInference.ts diff --git a/tests/cases/conformance/expressions/arrayLiterals/arrayLiteralInference.ts b/tests/cases/conformance/expressions/arrayLiterals/arrayLiteralInference.ts new file mode 100644 index 00000000000..311cad6236f --- /dev/null +++ b/tests/cases/conformance/expressions/arrayLiterals/arrayLiteralInference.ts @@ -0,0 +1,36 @@ +// @strict: true +// @target: es2015 + +// Repro from #31204 + +export enum AppType { + HeaderDetail = 'HeaderDetail', + HeaderMultiDetail = 'HeaderMultiDetail', + AdvancedList = 'AdvancedList', + Standard = 'Standard', + Relationship = 'Relationship', + Report = 'Report', + Composite = 'Composite', + ListOnly = 'ListOnly', + ModuleSettings = 'ModuleSettings' +} + +export enum AppStyle { + Tree, + TreeEntity, + Standard, + MiniApp, + PivotTable +} + +const appTypeStylesWithError: Map> = new Map([ + [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], + [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], + [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]] +]); + +// Repro from #31204 + +declare function foo(...args: T[]): T[]; +let b1: { x: boolean }[] = foo({ x: true }, { x: false }); +let b2: boolean[][] = foo([true], [false]); From f38a4aa3cfbc8b800305950f7efd29365ec86f99 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 17 Jun 2019 16:18:20 -1000 Subject: [PATCH 08/26] Accept new baselines --- .../reference/arrayLiteralInference.js | 65 ++++++++ .../reference/arrayLiteralInference.symbols | 119 +++++++++++++++ .../reference/arrayLiteralInference.types | 139 ++++++++++++++++++ 3 files changed, 323 insertions(+) create mode 100644 tests/baselines/reference/arrayLiteralInference.js create mode 100644 tests/baselines/reference/arrayLiteralInference.symbols create mode 100644 tests/baselines/reference/arrayLiteralInference.types diff --git a/tests/baselines/reference/arrayLiteralInference.js b/tests/baselines/reference/arrayLiteralInference.js new file mode 100644 index 00000000000..6b98b22394a --- /dev/null +++ b/tests/baselines/reference/arrayLiteralInference.js @@ -0,0 +1,65 @@ +//// [arrayLiteralInference.ts] +// Repro from #31204 + +export enum AppType { + HeaderDetail = 'HeaderDetail', + HeaderMultiDetail = 'HeaderMultiDetail', + AdvancedList = 'AdvancedList', + Standard = 'Standard', + Relationship = 'Relationship', + Report = 'Report', + Composite = 'Composite', + ListOnly = 'ListOnly', + ModuleSettings = 'ModuleSettings' +} + +export enum AppStyle { + Tree, + TreeEntity, + Standard, + MiniApp, + PivotTable +} + +const appTypeStylesWithError: Map> = new Map([ + [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], + [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], + [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]] +]); + +// Repro from #31204 + +declare function foo(...args: T[]): T[]; +let b1: { x: boolean }[] = foo({ x: true }, { x: false }); +let b2: boolean[][] = foo([true], [false]); + + +//// [arrayLiteralInference.js] +// Repro from #31204 +export var AppType; +(function (AppType) { + AppType["HeaderDetail"] = "HeaderDetail"; + AppType["HeaderMultiDetail"] = "HeaderMultiDetail"; + AppType["AdvancedList"] = "AdvancedList"; + AppType["Standard"] = "Standard"; + AppType["Relationship"] = "Relationship"; + AppType["Report"] = "Report"; + AppType["Composite"] = "Composite"; + AppType["ListOnly"] = "ListOnly"; + AppType["ModuleSettings"] = "ModuleSettings"; +})(AppType || (AppType = {})); +export var AppStyle; +(function (AppStyle) { + AppStyle[AppStyle["Tree"] = 0] = "Tree"; + AppStyle[AppStyle["TreeEntity"] = 1] = "TreeEntity"; + AppStyle[AppStyle["Standard"] = 2] = "Standard"; + AppStyle[AppStyle["MiniApp"] = 3] = "MiniApp"; + AppStyle[AppStyle["PivotTable"] = 4] = "PivotTable"; +})(AppStyle || (AppStyle = {})); +const appTypeStylesWithError = new Map([ + [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], + [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], + [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]] +]); +let b1 = foo({ x: true }, { x: false }); +let b2 = foo([true], [false]); diff --git a/tests/baselines/reference/arrayLiteralInference.symbols b/tests/baselines/reference/arrayLiteralInference.symbols new file mode 100644 index 00000000000..cdb89eb2061 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralInference.symbols @@ -0,0 +1,119 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiteralInference.ts === +// Repro from #31204 + +export enum AppType { +>AppType : Symbol(AppType, Decl(arrayLiteralInference.ts, 0, 0)) + + HeaderDetail = 'HeaderDetail', +>HeaderDetail : Symbol(AppType.HeaderDetail, Decl(arrayLiteralInference.ts, 2, 21)) + + HeaderMultiDetail = 'HeaderMultiDetail', +>HeaderMultiDetail : Symbol(AppType.HeaderMultiDetail, Decl(arrayLiteralInference.ts, 3, 34)) + + AdvancedList = 'AdvancedList', +>AdvancedList : Symbol(AppType.AdvancedList, Decl(arrayLiteralInference.ts, 4, 44)) + + Standard = 'Standard', +>Standard : Symbol(AppType.Standard, Decl(arrayLiteralInference.ts, 5, 34)) + + Relationship = 'Relationship', +>Relationship : Symbol(AppType.Relationship, Decl(arrayLiteralInference.ts, 6, 26)) + + Report = 'Report', +>Report : Symbol(AppType.Report, Decl(arrayLiteralInference.ts, 7, 34)) + + Composite = 'Composite', +>Composite : Symbol(AppType.Composite, Decl(arrayLiteralInference.ts, 8, 22)) + + ListOnly = 'ListOnly', +>ListOnly : Symbol(AppType.ListOnly, Decl(arrayLiteralInference.ts, 9, 28)) + + ModuleSettings = 'ModuleSettings' +>ModuleSettings : Symbol(AppType.ModuleSettings, Decl(arrayLiteralInference.ts, 10, 26)) +} + +export enum AppStyle { +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) + + Tree, +>Tree : Symbol(AppStyle.Tree, Decl(arrayLiteralInference.ts, 14, 22)) + + TreeEntity, +>TreeEntity : Symbol(AppStyle.TreeEntity, Decl(arrayLiteralInference.ts, 15, 9)) + + Standard, +>Standard : Symbol(AppStyle.Standard, Decl(arrayLiteralInference.ts, 16, 15)) + + MiniApp, +>MiniApp : Symbol(AppStyle.MiniApp, Decl(arrayLiteralInference.ts, 17, 13)) + + PivotTable +>PivotTable : Symbol(AppStyle.PivotTable, Decl(arrayLiteralInference.ts, 18, 12)) +} + +const appTypeStylesWithError: Map> = new Map([ +>appTypeStylesWithError : Symbol(appTypeStylesWithError, Decl(arrayLiteralInference.ts, 22, 5)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>AppType : Symbol(AppType, Decl(arrayLiteralInference.ts, 0, 0)) +>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) +>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) + + [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], +>AppType.Standard : Symbol(AppType.Standard, Decl(arrayLiteralInference.ts, 5, 34)) +>AppType : Symbol(AppType, Decl(arrayLiteralInference.ts, 0, 0)) +>Standard : Symbol(AppType.Standard, Decl(arrayLiteralInference.ts, 5, 34)) +>AppStyle.Standard : Symbol(AppStyle.Standard, Decl(arrayLiteralInference.ts, 16, 15)) +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) +>Standard : Symbol(AppStyle.Standard, Decl(arrayLiteralInference.ts, 16, 15)) +>AppStyle.MiniApp : Symbol(AppStyle.MiniApp, Decl(arrayLiteralInference.ts, 17, 13)) +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) +>MiniApp : Symbol(AppStyle.MiniApp, Decl(arrayLiteralInference.ts, 17, 13)) + + [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], +>AppType.Relationship : Symbol(AppType.Relationship, Decl(arrayLiteralInference.ts, 6, 26)) +>AppType : Symbol(AppType, Decl(arrayLiteralInference.ts, 0, 0)) +>Relationship : Symbol(AppType.Relationship, Decl(arrayLiteralInference.ts, 6, 26)) +>AppStyle.Standard : Symbol(AppStyle.Standard, Decl(arrayLiteralInference.ts, 16, 15)) +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) +>Standard : Symbol(AppStyle.Standard, Decl(arrayLiteralInference.ts, 16, 15)) +>AppStyle.Tree : Symbol(AppStyle.Tree, Decl(arrayLiteralInference.ts, 14, 22)) +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) +>Tree : Symbol(AppStyle.Tree, Decl(arrayLiteralInference.ts, 14, 22)) +>AppStyle.TreeEntity : Symbol(AppStyle.TreeEntity, Decl(arrayLiteralInference.ts, 15, 9)) +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) +>TreeEntity : Symbol(AppStyle.TreeEntity, Decl(arrayLiteralInference.ts, 15, 9)) + + [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]] +>AppType.AdvancedList : Symbol(AppType.AdvancedList, Decl(arrayLiteralInference.ts, 4, 44)) +>AppType : Symbol(AppType, Decl(arrayLiteralInference.ts, 0, 0)) +>AdvancedList : Symbol(AppType.AdvancedList, Decl(arrayLiteralInference.ts, 4, 44)) +>AppStyle.Standard : Symbol(AppStyle.Standard, Decl(arrayLiteralInference.ts, 16, 15)) +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) +>Standard : Symbol(AppStyle.Standard, Decl(arrayLiteralInference.ts, 16, 15)) +>AppStyle.MiniApp : Symbol(AppStyle.MiniApp, Decl(arrayLiteralInference.ts, 17, 13)) +>AppStyle : Symbol(AppStyle, Decl(arrayLiteralInference.ts, 12, 1)) +>MiniApp : Symbol(AppStyle.MiniApp, Decl(arrayLiteralInference.ts, 17, 13)) + +]); + +// Repro from #31204 + +declare function foo(...args: T[]): T[]; +>foo : Symbol(foo, Decl(arrayLiteralInference.ts, 26, 3)) +>T : Symbol(T, Decl(arrayLiteralInference.ts, 30, 21)) +>args : Symbol(args, Decl(arrayLiteralInference.ts, 30, 24)) +>T : Symbol(T, Decl(arrayLiteralInference.ts, 30, 21)) +>T : Symbol(T, Decl(arrayLiteralInference.ts, 30, 21)) + +let b1: { x: boolean }[] = foo({ x: true }, { x: false }); +>b1 : Symbol(b1, Decl(arrayLiteralInference.ts, 31, 3)) +>x : Symbol(x, Decl(arrayLiteralInference.ts, 31, 9)) +>foo : Symbol(foo, Decl(arrayLiteralInference.ts, 26, 3)) +>x : Symbol(x, Decl(arrayLiteralInference.ts, 31, 32)) +>x : Symbol(x, Decl(arrayLiteralInference.ts, 31, 45)) + +let b2: boolean[][] = foo([true], [false]); +>b2 : Symbol(b2, Decl(arrayLiteralInference.ts, 32, 3)) +>foo : Symbol(foo, Decl(arrayLiteralInference.ts, 26, 3)) + diff --git a/tests/baselines/reference/arrayLiteralInference.types b/tests/baselines/reference/arrayLiteralInference.types new file mode 100644 index 00000000000..fc7bdc8c032 --- /dev/null +++ b/tests/baselines/reference/arrayLiteralInference.types @@ -0,0 +1,139 @@ +=== tests/cases/conformance/expressions/arrayLiterals/arrayLiteralInference.ts === +// Repro from #31204 + +export enum AppType { +>AppType : AppType + + HeaderDetail = 'HeaderDetail', +>HeaderDetail : AppType.HeaderDetail +>'HeaderDetail' : "HeaderDetail" + + HeaderMultiDetail = 'HeaderMultiDetail', +>HeaderMultiDetail : AppType.HeaderMultiDetail +>'HeaderMultiDetail' : "HeaderMultiDetail" + + AdvancedList = 'AdvancedList', +>AdvancedList : AppType.AdvancedList +>'AdvancedList' : "AdvancedList" + + Standard = 'Standard', +>Standard : AppType.Standard +>'Standard' : "Standard" + + Relationship = 'Relationship', +>Relationship : AppType.Relationship +>'Relationship' : "Relationship" + + Report = 'Report', +>Report : AppType.Report +>'Report' : "Report" + + Composite = 'Composite', +>Composite : AppType.Composite +>'Composite' : "Composite" + + ListOnly = 'ListOnly', +>ListOnly : AppType.ListOnly +>'ListOnly' : "ListOnly" + + ModuleSettings = 'ModuleSettings' +>ModuleSettings : AppType.ModuleSettings +>'ModuleSettings' : "ModuleSettings" +} + +export enum AppStyle { +>AppStyle : AppStyle + + Tree, +>Tree : AppStyle.Tree + + TreeEntity, +>TreeEntity : AppStyle.TreeEntity + + Standard, +>Standard : AppStyle.Standard + + MiniApp, +>MiniApp : AppStyle.MiniApp + + PivotTable +>PivotTable : AppStyle.PivotTable +} + +const appTypeStylesWithError: Map> = new Map([ +>appTypeStylesWithError : Map +>new Map([ [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]]]) : Map +>Map : MapConstructor +>[ [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]]] : ([AppType.Standard, (AppStyle.Standard | AppStyle.MiniApp)[]] | [AppType.Relationship, (AppStyle.Tree | AppStyle.TreeEntity | AppStyle.Standard)[]] | [AppType.AdvancedList, (AppStyle.Standard | AppStyle.MiniApp)[]])[] + + [AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]], +>[AppType.Standard, [AppStyle.Standard, AppStyle.MiniApp]] : [AppType.Standard, (AppStyle.Standard | AppStyle.MiniApp)[]] +>AppType.Standard : AppType.Standard +>AppType : typeof AppType +>Standard : AppType.Standard +>[AppStyle.Standard, AppStyle.MiniApp] : (AppStyle.Standard | AppStyle.MiniApp)[] +>AppStyle.Standard : AppStyle.Standard +>AppStyle : typeof AppStyle +>Standard : AppStyle.Standard +>AppStyle.MiniApp : AppStyle.MiniApp +>AppStyle : typeof AppStyle +>MiniApp : AppStyle.MiniApp + + [AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]], +>[AppType.Relationship, [AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity]] : [AppType.Relationship, (AppStyle.Tree | AppStyle.TreeEntity | AppStyle.Standard)[]] +>AppType.Relationship : AppType.Relationship +>AppType : typeof AppType +>Relationship : AppType.Relationship +>[AppStyle.Standard, AppStyle.Tree, AppStyle.TreeEntity] : (AppStyle.Tree | AppStyle.TreeEntity | AppStyle.Standard)[] +>AppStyle.Standard : AppStyle.Standard +>AppStyle : typeof AppStyle +>Standard : AppStyle.Standard +>AppStyle.Tree : AppStyle.Tree +>AppStyle : typeof AppStyle +>Tree : AppStyle.Tree +>AppStyle.TreeEntity : AppStyle.TreeEntity +>AppStyle : typeof AppStyle +>TreeEntity : AppStyle.TreeEntity + + [AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]] +>[AppType.AdvancedList, [AppStyle.Standard, AppStyle.MiniApp]] : [AppType.AdvancedList, (AppStyle.Standard | AppStyle.MiniApp)[]] +>AppType.AdvancedList : AppType.AdvancedList +>AppType : typeof AppType +>AdvancedList : AppType.AdvancedList +>[AppStyle.Standard, AppStyle.MiniApp] : (AppStyle.Standard | AppStyle.MiniApp)[] +>AppStyle.Standard : AppStyle.Standard +>AppStyle : typeof AppStyle +>Standard : AppStyle.Standard +>AppStyle.MiniApp : AppStyle.MiniApp +>AppStyle : typeof AppStyle +>MiniApp : AppStyle.MiniApp + +]); + +// Repro from #31204 + +declare function foo(...args: T[]): T[]; +>foo : (...args: T[]) => T[] +>args : T[] + +let b1: { x: boolean }[] = foo({ x: true }, { x: false }); +>b1 : { x: boolean; }[] +>x : boolean +>foo({ x: true }, { x: false }) : ({ x: true; } | { x: false; })[] +>foo : (...args: T[]) => T[] +>{ x: true } : { x: true; } +>x : true +>true : true +>{ x: false } : { x: false; } +>x : false +>false : false + +let b2: boolean[][] = foo([true], [false]); +>b2 : boolean[][] +>foo([true], [false]) : (true[] | false[])[] +>foo : (...args: T[]) => T[] +>[true] : true[] +>true : true +>[false] : false[] +>false : false + From 13b7af6ea0f05be0e3deadab36e0bcad8662e082 Mon Sep 17 00:00:00 2001 From: Suhas Date: Mon, 17 Jun 2019 23:14:02 -0700 Subject: [PATCH 09/26] fix tsserver picking hidden files created by emacs Saw this good for first timers. I followed what @sheetalkamat suggested. #31916 --- src/compiler/sys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index b1923a73a27..5abc19cdbc4 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -330,7 +330,7 @@ namespace ts { } /*@internal*/ - export const ignoredPaths = ["/node_modules/.", "/.git"]; + export const ignoredPaths = ["/node_modules/.", "/.git", "/.#"]; /*@internal*/ export interface RecursiveDirectoryWatcherHost { From 8a11f1556928bcd20182aa70188d26c22fd57051 Mon Sep 17 00:00:00 2001 From: Suhas Deshpande Date: Tue, 18 Jun 2019 22:50:40 -0700 Subject: [PATCH 10/26] Add unit test --- .../unittests/tsserver/watchEnvironment.ts | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/testRunner/unittests/tsserver/watchEnvironment.ts b/src/testRunner/unittests/tsserver/watchEnvironment.ts index bc8e84a8025..33a61bedfb2 100644 --- a/src/testRunner/unittests/tsserver/watchEnvironment.ts +++ b/src/testRunner/unittests/tsserver/watchEnvironment.ts @@ -171,33 +171,37 @@ namespace ts.projectSystem { path: `${projectFolder}/node_modules/.cache/someFile.d.ts`, content: "" }; - host.ensureFileOrFolder(nodeModulesIgnoredFileFromIgnoreDirectory); - host.checkTimeoutQueueLength(0); - verifyProject(); const nodeModulesIgnoredFile: File = { path: `${projectFolder}/node_modules/.cacheFile.ts`, content: "" }; - host.ensureFileOrFolder(nodeModulesIgnoredFile); - host.checkTimeoutQueueLength(0); - verifyProject(); const gitIgnoredFileFromIgnoreDirectory: File = { path: `${projectFolder}/.git/someFile.d.ts`, content: "" }; - host.ensureFileOrFolder(gitIgnoredFileFromIgnoreDirectory); - host.checkTimeoutQueueLength(0); - verifyProject(); const gitIgnoredFile: File = { path: `${projectFolder}/.gitCache.d.ts`, content: "" }; - host.ensureFileOrFolder(gitIgnoredFile); - host.checkTimeoutQueueLength(0); - verifyProject(); + const emacsIgnoredFileFromIgnoreDirectory: File = { + path: `${projectFolder}/src/.#field.ts`, + content: "" + }; + + [ + nodeModulesIgnoredFileFromIgnoreDirectory, + nodeModulesIgnoredFile, + gitIgnoredFileFromIgnoreDirectory, + gitIgnoredFile, + emacsIgnoredFileFromIgnoreDirectory + ].forEach(ignoredEntity => { + host.ensureFileOrFolder(ignoredEntity); + host.checkTimeoutQueueLength(0); + verifyProject(); + }) function verifyProject() { checkWatchedDirectories(host, emptyArray, /*recursive*/ true); From f8004a33dd710efa245c856b2652c44ea567210b Mon Sep 17 00:00:00 2001 From: Suhas Deshpande Date: Tue, 18 Jun 2019 23:17:58 -0700 Subject: [PATCH 11/26] semi-colon --- src/testRunner/unittests/tsserver/watchEnvironment.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testRunner/unittests/tsserver/watchEnvironment.ts b/src/testRunner/unittests/tsserver/watchEnvironment.ts index 33a61bedfb2..5e776aa9908 100644 --- a/src/testRunner/unittests/tsserver/watchEnvironment.ts +++ b/src/testRunner/unittests/tsserver/watchEnvironment.ts @@ -201,7 +201,7 @@ namespace ts.projectSystem { host.ensureFileOrFolder(ignoredEntity); host.checkTimeoutQueueLength(0); verifyProject(); - }) + }); function verifyProject() { checkWatchedDirectories(host, emptyArray, /*recursive*/ true); From 06d188a255ca384e53a6c6f7779c01d1df2c93a6 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Wed, 19 Jun 2019 15:02:00 -0700 Subject: [PATCH 12/26] Support --locale with --build Fixes #31960 --- src/compiler/commandLineParser.ts | 14 +++++++------- src/compiler/tsbuild.ts | 1 + .../unittests/config/commandLineParsing.ts | 10 ++++++++++ src/tsc/tsc.ts | 4 ++++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 394a94cb663..c0363788c9e 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -147,6 +147,12 @@ namespace ts { category: Diagnostics.Basic_Options, description: Diagnostics.Enable_incremental_compilation, }, + { + name: "locale", + type: "string", + category: Diagnostics.Advanced_Options, + description: Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + }, ]; /* @internal */ @@ -698,12 +704,6 @@ namespace ts { category: Diagnostics.Advanced_Options, description: Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files }, - { - name: "locale", - type: "string", - category: Diagnostics.Advanced_Options, - description: Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us - }, { name: "newLine", type: createMapFromTemplate({ @@ -1171,7 +1171,7 @@ namespace ts { export interface ParsedBuildCommand { buildOptions: BuildOptions; projects: string[]; - errors: ReadonlyArray; + errors: Diagnostic[]; } /*@internal*/ diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 94718a1b368..4602c0793be 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -172,6 +172,7 @@ namespace ts { traceResolution?: boolean; /* @internal */ diagnostics?: boolean; /* @internal */ extendedDiagnostics?: boolean; + /* @internal */ locale?: string; [option: string]: CompilerOptionsValue | undefined; } diff --git a/src/testRunner/unittests/config/commandLineParsing.ts b/src/testRunner/unittests/config/commandLineParsing.ts index 3c033d658ef..3d1001c7daf 100644 --- a/src/testRunner/unittests/config/commandLineParsing.ts +++ b/src/testRunner/unittests/config/commandLineParsing.ts @@ -486,6 +486,16 @@ namespace ts { }); }); + it("parse build with --locale en-us", () => { + // --lib es6 0.ts + assertParseResult(["--locale", "en-us", "src"], + { + errors: [], + projects: ["src"], + buildOptions: { locale: "en-us" } + }); + }); + it("parse build with --tsBuildInfoFile", () => { // --lib es6 0.ts assertParseResult(["--tsBuildInfoFile", "build.tsbuildinfo", "tests"], diff --git a/src/tsc/tsc.ts b/src/tsc/tsc.ts index 6a340109238..d27c1aace4e 100644 --- a/src/tsc/tsc.ts +++ b/src/tsc/tsc.ts @@ -186,6 +186,10 @@ namespace ts { // Update to pretty if host supports it updateReportDiagnostic(buildOptions); + if (buildOptions.locale) { + validateLocaleAndSetLanguage(buildOptions.locale, sys, errors); + } + if (errors.length > 0) { errors.forEach(reportDiagnostic); return sys.exit(ExitStatus.DiagnosticsPresent_OutputsSkipped); From e9d3f54a01d6170c0cdb63ae3988c6bdff640937 Mon Sep 17 00:00:00 2001 From: typescript-bot Date: Thu, 20 Jun 2019 13:27:21 +0000 Subject: [PATCH 13/26] Update user baselines --- .../reference/user/TypeScript-React-Native-Starter.log | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/baselines/reference/user/TypeScript-React-Native-Starter.log b/tests/baselines/reference/user/TypeScript-React-Native-Starter.log index 87439a7c4e6..2f5a0d1f7f5 100644 --- a/tests/baselines/reference/user/TypeScript-React-Native-Starter.log +++ b/tests/baselines/reference/user/TypeScript-React-Native-Starter.log @@ -3,7 +3,7 @@ Standard output: node_modules/@types/react-native/index.d.ts(3425,42): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. node_modules/@types/react-native/index.d.ts(3438,42): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. node_modules/@types/react-native/index.d.ts(8745,18): error TS2717: Subsequent property declarations must have the same type. Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'. -node_modules/@types/react/index.d.ts(377,23): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. +node_modules/@types/react/index.d.ts(378,23): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. From c39a877a9268cd6b7ec67347540c5c08566b9333 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 20 Jun 2019 12:47:57 -0700 Subject: [PATCH 14/26] Add dockerfile based tests for `azure-sdk-for-js` and `office-ui-fabric-react` (#31948) * Add dockerfile based tests * Update tests/cases/docker/README.md Co-Authored-By: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> * Combine sanitize functions * Add some debugging instructions to README * Fix listed command order --- .dockerignore | 48 ++ .npmignore | 2 + Dockerfile | 7 + src/harness/runnerbase.ts | 2 +- src/testRunner/externalCompileRunner.ts | 71 +++ src/testRunner/runner.ts | 6 + .../baselines/reference/docker/azure-sdk.log | 95 ++++ .../reference/docker/office-ui-fabric.log | 416 ++++++++++++++++++ tests/cases/docker/README.md | 21 + tests/cases/docker/azure-sdk/Dockerfile | 19 + .../cases/docker/office-ui-fabric/Dockerfile | 20 + 11 files changed, 706 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 tests/baselines/reference/docker/azure-sdk.log create mode 100644 tests/baselines/reference/docker/office-ui-fabric.log create mode 100644 tests/cases/docker/README.md create mode 100644 tests/cases/docker/azure-sdk/Dockerfile create mode 100644 tests/cases/docker/office-ui-fabric/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000000..1f64bbcee32 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,48 @@ +node_modules +.node_modules +built/* +test-args.txt +~*.docx +\#*\# +.\#* +src/harness/*.js +src/compiler/diagnosticInformationMap.generated.ts +src/compiler/diagnosticMessages.generated.json +src/parser/diagnosticInformationMap.generated.ts +src/parser/diagnosticMessages.generated.json +rwc-report.html +*.swp +build.json +*.actual +*.config +scripts/debug.bat +scripts/run.bat +scripts/word2md.js +scripts/buildProtocol.js +scripts/ior.js +scripts/authors.js +scripts/configurePrerelease.js +scripts/open-user-pr.js +scripts/open-cherry-pick-pr.js +scripts/processDiagnosticMessages.d.ts +scripts/processDiagnosticMessages.js +scripts/produceLKG.js +scripts/importDefinitelyTypedTests/importDefinitelyTypedTests.js +scripts/generateLocalizedDiagnosticMessages.js +scripts/*.js.map +scripts/typings/ +coverage/ +internal/ +**/.DS_Store +.settings +**/.vs +.idea +yarn.lock +yarn-error.log +.parallelperf.* +.failed-tests +TEST-results.xml +package-lock.json +tests +.vscode +.git \ No newline at end of file diff --git a/.npmignore b/.npmignore index 482633f48fc..2144451e3e8 100644 --- a/.npmignore +++ b/.npmignore @@ -29,3 +29,5 @@ package-lock.json yarn.lock CONTRIBUTING.md TEST-results.xml +.dockerignore +Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000000..8898a69af6d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +# We use this dockerfile to build a packed tarfile which we import in our `docker` tests +FROM node:current +COPY . /typescript +WORKDIR /typescript +RUN npm install +RUN npm i -g gulp-cli +RUN gulp configure-insiders && gulp LKG && gulp clean && npm pack . \ No newline at end of file diff --git a/src/harness/runnerbase.ts b/src/harness/runnerbase.ts index b29ebb7f920..ce56772927e 100644 --- a/src/harness/runnerbase.ts +++ b/src/harness/runnerbase.ts @@ -1,4 +1,4 @@ -type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user" | "dt"; +type TestRunnerKind = CompilerTestKind | FourslashTestKind | "project" | "rwc" | "test262" | "user" | "dt" | "docker"; type CompilerTestKind = "conformance" | "compiler"; type FourslashTestKind = "fourslash" | "fourslash-shims" | "fourslash-shims-pp" | "fourslash-server"; diff --git a/src/testRunner/externalCompileRunner.ts b/src/testRunner/externalCompileRunner.ts index c3b2ef3e6ec..e40f8115e59 100644 --- a/src/testRunner/externalCompileRunner.ts +++ b/src/testRunner/externalCompileRunner.ts @@ -106,6 +106,77 @@ ${stripAbsoluteImportPaths(result.stderr.toString().replace(/\r\n/g, "\n"))}`; } } +class DockerfileRunner extends ExternalCompileRunnerBase { + readonly testDir = "tests/cases/docker/"; + kind(): TestRunnerKind { + return "docker"; + } + initializeTests(): void { + // Read in and evaluate the test list + const testList = this.tests && this.tests.length ? this.tests : this.enumerateTestFiles(); + + // tslint:disable-next-line:no-this-assignment + const cls = this; + describe(`${this.kind()} code samples`, function(this: Mocha.ISuiteCallbackContext) { + this.timeout(cls.timeout); // 20 minutes + before(() => { + cls.exec("docker", ["build", ".", "-t", "typescript/typescript"], { cwd: Harness.IO.getWorkspaceRoot() }); // cached because workspace is hashed to determine cacheability + }); + for (const test of testList) { + const directory = typeof test === "string" ? test : test.file; + const cwd = path.join(Harness.IO.getWorkspaceRoot(), cls.testDir, directory); + it(`should build ${directory} successfully`, () => { + const imageName = `tstest/${directory}`; + cls.exec("docker", ["build", "--no-cache", ".", "-t", imageName], { cwd }); // --no-cache so the latest version of the repos referenced is always fetched + const cp: typeof import("child_process") = require("child_process"); + Harness.Baseline.runBaseline(`${cls.kind()}/${directory}.log`, cls.report(cp.spawnSync(`docker`, ["run", imageName], { cwd, timeout: cls.timeout, shell: true }))); + }); + } + }); + } + + private timeout = 1_200_000; // 20 minutes; + private exec(command: string, args: string[], options: { cwd: string, timeout?: number }): void { + const cp: typeof import("child_process") = require("child_process"); + const stdio = isWorker ? "pipe" : "inherit"; + const res = cp.spawnSync(command, args, { timeout: this.timeout, shell: true, stdio, ...options }); + if (res.status !== 0) { + throw new Error(`${command} ${args.join(" ")} for ${options.cwd} failed: ${res.stderr && res.stderr.toString()}`); + } + } + 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: +${sanitizeDockerfileOutput(result.stdout.toString())} + + +Standard error: +${sanitizeDockerfileOutput(result.stderr.toString())}`; + } +} + +function sanitizeDockerfileOutput(result: string): string { + return stripAbsoluteImportPaths(sanitizeTimestamps(stripANSIEscapes(normalizeNewlines(result)))); +} + +function normalizeNewlines(result: string): string { + return result.replace(/\r\n/g, "\n"); +} + +function stripANSIEscapes(result: string): string { + return result.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, ""); +} + +function sanitizeTimestamps(result: string): string { + return result.replace(/\[\d?\d:\d\d:\d\d (A|P)M\]/g, "[XX:XX:XX XM]") + .replace(/\d+(\.\d+)? seconds?/g, "? seconds") + .replace(/\d+(\.\d+)? minutes?/g, "") + .replace(/\d+(\.\d+)?s/g, "?s") + .replace(/\d+.\d+.\d+-insiders.\d\d\d\d\d\d\d\d/g, "X.X.X-insiders.xxxxxxxx"); +} + + /** * Import types and some other error messages use absolute paths in errors as they have no context to be written relative to; * This is problematic for error baselines, so we grep for them and strip them out. diff --git a/src/testRunner/runner.ts b/src/testRunner/runner.ts index be46d935297..816b2dff370 100644 --- a/src/testRunner/runner.ts +++ b/src/testRunner/runner.ts @@ -40,6 +40,8 @@ function createRunner(kind: TestRunnerKind): RunnerBase { return new UserCodeRunner(); case "dt": return new DefinitelyTypedRunner(); + case "docker": + return new DockerfileRunner(); } return ts.Debug.fail(`Unknown runner kind ${kind}`); } @@ -172,6 +174,9 @@ function handleTestConfig() { case "dt": runners.push(new DefinitelyTypedRunner()); break; + case "docker": + runners.push(new DockerfileRunner()); + break; } } } @@ -194,6 +199,7 @@ function handleTestConfig() { // CRON-only tests if (process.env.TRAVIS_EVENT_TYPE === "cron") { runners.push(new UserCodeRunner()); + runners.push(new DockerfileRunner()); } } if (runUnitTests === undefined) { diff --git a/tests/baselines/reference/docker/azure-sdk.log b/tests/baselines/reference/docker/azure-sdk.log new file mode 100644 index 00000000000..3d2374b1547 --- /dev/null +++ b/tests/baselines/reference/docker/azure-sdk.log @@ -0,0 +1,95 @@ +Exit Code: 1 +Standard output: + + +Rush Multi-Project Build Tool 5.7.3 - https://rushjs.io + + +Starting "rush rebuild" + +Executing a maximum of 1 simultaneous processes... + +[@azure/abort-controller] started +1 of 18: [@azure/abort-controller] completed successfully in ? seconds +[@azure/cosmos] started +2 of 18: [@azure/cosmos] completed successfully in ? seconds +[@azure/event-hubs] started +3 of 18: [@azure/event-hubs] completed successfully in ? seconds +[@azure/service-bus] started +Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md +[@azure/storage-blob] started +5 of 18: [@azure/storage-blob] completed successfully in ? seconds +[@azure/storage-datalake] started +6 of 18: [@azure/storage-datalake] completed successfully in ? seconds +[@azure/storage-file] started +7 of 18: [@azure/storage-file] completed successfully in ? seconds +[@azure/storage-queue] started +8 of 18: [@azure/storage-queue] completed successfully in ? seconds +[@azure/template] started +9 of 18: [@azure/template] completed successfully in ? seconds +[@azure/core-http] started +10 of 18: [@azure/core-http] completed successfully in ? seconds +[@azure/core-paging] started +11 of 18: [@azure/core-paging] completed successfully in ? seconds +[@azure/event-processor-host] started +12 of 18: [@azure/event-processor-host] completed successfully in ? seconds +[testhub] started +13 of 18: [testhub] completed successfully in ? seconds +[@azure/identity] started +14 of 18: [@azure/identity] completed successfully in ? seconds +[@azure/core-amqp] started +[@azure/keyvault-certificates] started +15 of 18: [@azure/keyvault-certificates] completed successfully in ? seconds +[@azure/keyvault-keys] started +16 of 18: [@azure/keyvault-keys] completed successfully in ? seconds +[@azure/keyvault-secrets] started +17 of 18: [@azure/keyvault-secrets] completed successfully in ? seconds + +SUCCESS (16) +================================ +@azure/abort-controller (? seconds) +@azure/core-http (? seconds) +@azure/core-paging (? seconds) +@azure/cosmos (? seconds) +@azure/event-hubs (? seconds) +@azure/event-processor-host (? seconds) +@azure/identity (? seconds) +@azure/keyvault-certificates (? seconds) +@azure/keyvault-keys (? seconds) +@azure/keyvault-secrets (? seconds) +@azure/storage-blob (? seconds) +@azure/storage-datalake (? seconds) +@azure/storage-file (? seconds) +@azure/storage-queue (? seconds) +@azure/template (? seconds) +testhub (? seconds) +================================ + +SUCCESS WITH WARNINGS (1) +================================ +@azure/service-bus (? seconds) +Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md +================================ + +FAILURE (1) +================================ +@azure/core-amqp (? seconds) +>>> @azure/core-amqp +tsc -p . && rollup -c 2>&1 +src/errors.ts(579,20): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'typeof ConditionErrorNameMapper'. +src/errors.ts(600,34): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'typeof SystemErrorConditionMapper'. +src/errors.ts(601,20): error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type 'typeof ConditionErrorNameMapper'. +================================ + + +Error: Project(s) failed to build +rush rebuild - Errors! ( ? seconds) + + + +Standard error: +Your version of Node.js (12.4.0) has not been tested with this release of Rush. The Rush team will not accept issue reports for it. Please consider upgrading Rush or downgrading Node.js. +4 of 18: [@azure/service-bus] completed with warnings in ? seconds + +14 of 18: [@azure/core-amqp] failed to build! +[@azure/core-amqp] Returned error code: 2 diff --git a/tests/baselines/reference/docker/office-ui-fabric.log b/tests/baselines/reference/docker/office-ui-fabric.log new file mode 100644 index 00000000000..e551d2ead88 --- /dev/null +++ b/tests/baselines/reference/docker/office-ui-fabric.log @@ -0,0 +1,416 @@ +Exit Code: 1 +Standard output: + + +Rush Multi-Project Build Tool 5.6.0 - https://rushjs.io + + +Starting "rush rebuild" + +Executing a maximum of 1 simultaneous processes... + +[@uifabric/prettier-rules] started +1 of 40: [@uifabric/prettier-rules] completed successfully in ? seconds +[@uifabric/tslint-rules] started +2 of 40: [@uifabric/tslint-rules] completed successfully in ? seconds +[@uifabric/codepen-loader] started +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. +[@uifabric/build] started +4 of 40: [@uifabric/build] completed successfully in ? seconds +[@uifabric/migration] started +5 of 40: [@uifabric/migration] completed successfully in ? seconds +[@uifabric/set-version] started +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. +[@uifabric/merge-styles] started +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. +[@uifabric/jest-serializer-merge-styles] started +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. +[@uifabric/test-utilities] started +9 of 40: [@uifabric/test-utilities] completed successfully in ? seconds +[@uifabric/utilities] started +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. +[@uifabric/styling] started +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. +[@uifabric/file-type-icons] started +12 of 40: [@uifabric/file-type-icons] completed successfully in ? seconds +[@uifabric/foundation] started +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + ● createFactory › passes componentProps without userProps + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:205:73) + + ● createFactory › passes userProp string as child + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:210:76) + + ● createFactory › passes userProp integer as child + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:220:76) + + ● createFactory › passes userProp string as defaultProp + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:225:92) + + ● createFactory › passes userProp integer as defaultProp + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:235:92) + + ● createFactory › merges userProps over componentProps + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:245:84) + + ● createFactory › renders div and userProp integer as children + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:255:86) + + ● createFactory › renders div and userProp string as children + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:266:86) + + ● createFactory › renders userProp span function without component props + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:288:61) + + ● createFactory › renders userProp span function with component props + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:301:61) + + ● createFactory › renders userProp span component with component props + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:314:61) + + ● createFactory › passes props and type arguments to userProp function + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at Object. (src/slots.test.tsx:334:43) + + ● getSlots › creates slots and passes merged props to them + + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at _renderSlot (src/slots.tsx:221:100) + at Object.slot [as testSlot1] (src/slots.tsx:142:16) + at Object. (src/slots.test.tsx:399:24) + +[XX:XX:XX XM] x Error detected while running 'jest' +[XX:XX:XX XM] x ------------------------------------ +[XX:XX:XX XM] x Error: Command failed: /usr/local/bin/node /office-ui-fabric-react/common/temp/node_modules/jest/bin/jest.js --config /office-ui-fabric-react/packages/foundation/jest.config.js --passWithNoTests --colors + at ChildProcess. (/office-ui-fabric-react/common/temp/node_modules/.registry.npmjs.org/just-scripts-utils/0.8.1/node_modules/just-scripts-utils/lib/exec.js:70:31) + at ChildProcess.emit (events.js:200:13) + at ChildProcess.EventEmitter.emit (domain.js:494:23) + at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) +[XX:XX:XX XM] x ------------------------------------ +[XX:XX:XX XM] x finished 'validate' in ?s with errors +[XX:XX:XX XM] x finished 'build' in ?s with errors +[XX:XX:XX XM] x Error previously detected. See above for error messages. +[@uifabric/icons] started +38 of 40: [@uifabric/icons] completed successfully in ? seconds +[@uifabric/webpack-utils] started +39 of 40: [@uifabric/webpack-utils] completed successfully in ? seconds + +SUCCESS (8) +================================ +@uifabric/build (? seconds) +@uifabric/file-type-icons (? seconds) +@uifabric/icons (? seconds) +@uifabric/migration (? seconds) +@uifabric/prettier-rules (? seconds) +@uifabric/test-utilities (? seconds) +@uifabric/tslint-rules (? seconds) +@uifabric/webpack-utils (? seconds) +================================ + +SUCCESS WITH WARNINGS (6) +================================ +@uifabric/codepen-loader (? seconds) +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + +@uifabric/jest-serializer-merge-styles (? seconds) +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + +@uifabric/merge-styles (? seconds) +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + +@uifabric/set-version (? seconds) +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + +@uifabric/styling (? seconds) +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + +@uifabric/utilities (? seconds) +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. +================================ + +BLOCKED (25) +================================ +@uifabric/api-docs +@uifabric/azure-themes +@uifabric/charting +@uifabric/date-time +@uifabric/example-app-base +@uifabric/experiments +@uifabric/fabric-website +@uifabric/fabric-website-resources +@uifabric/fluent-theme +@uifabric/foundation-scenarios +@uifabric/lists +@uifabric/pr-deploy-site +@uifabric/react-cards +@uifabric/theme-samples +@uifabric/variants +a11y-tests +dom-tests +office-ui-fabric-react +perf-test +server-rendered-app +ssr-tests +test-bundles +theming-designer +todo-app +vr-tests +================================ + +FAILURE (1) +================================ +@uifabric/foundation (? seconds) +ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. + ● createFactory › passes componentProps without userProps + RangeError: Invalid array length + + 189 | for (const props of allProps) { + 190 | classNames.push(props && props.className); + > 191 | assign(finalProps, ...(props as any)); + | ^ + 192 | } + 193 | +[...179 lines omitted...] + 193 | + 194 | finalProps.className = mergeStyles(defaultStyles, classNames); + + at Object.__spreadArrays (../../common/temp/node_modules/.registry.npmjs.org/tslib/1.10.0/node_modules/tslib/tslib.js:182:22) + at _constructFinalProps (src/slots.tsx:191:11) + at result (src/slots.tsx:88:24) + at _renderSlot (src/slots.tsx:221:100) + at Object.slot [as testSlot1] (src/slots.tsx:142:16) + at Object. (src/slots.test.tsx:399:24) +[XX:XX:XX XM] x Error detected while running 'jest' +[XX:XX:XX XM] x ------------------------------------ +[XX:XX:XX XM] x Error: Command failed: /usr/local/bin/node /office-ui-fabric-react/common/temp/node_modules/jest/bin/jest.js --config /office-ui-fabric-react/packages/foundation/jest.config.js --passWithNoTests --colors + at ChildProcess. (/office-ui-fabric-react/common/temp/node_modules/.registry.npmjs.org/just-scripts-utils/0.8.1/node_modules/just-scripts-utils/lib/exec.js:70:31) + at ChildProcess.emit (events.js:200:13) + at ChildProcess.EventEmitter.emit (domain.js:494:23) + at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12) +[XX:XX:XX XM] x ------------------------------------ +[XX:XX:XX XM] x finished 'validate' in ?s with errors +[XX:XX:XX XM] x finished 'build' in ?s with errors +[XX:XX:XX XM] x Error previously detected. See above for error messages. +================================ + + +Error: Project(s) failed to build +rush rebuild - Errors! ( ? seconds) + + + +Standard error: +Your version of Node.js (12.4.0) has not been tested with this release of Rush. The Rush team will not accept issue reports for it. Please consider upgrading Rush or downgrading Node.js. +3 of 40: [@uifabric/codepen-loader] completed with warnings in ? seconds +6 of 40: [@uifabric/set-version] completed with warnings in ? seconds +7 of 40: [@uifabric/merge-styles] completed with warnings in ? seconds +8 of 40: [@uifabric/jest-serializer-merge-styles] completed with warnings in ? seconds +10 of 40: [@uifabric/utilities] completed with warnings in ? seconds +11 of 40: [@uifabric/styling] completed with warnings in ? seconds + +12 of 40: [@uifabric/foundation] failed to build! +13 of 40: [@uifabric/experiments] blocked by [@uifabric/foundation]! +14 of 40: [@uifabric/fabric-website] blocked by [@uifabric/foundation]! +15 of 40: [@uifabric/pr-deploy-site] blocked by [@uifabric/foundation]! +16 of 40: [@uifabric/react-cards] blocked by [@uifabric/foundation]! +17 of 40: [theming-designer] blocked by [@uifabric/foundation]! +18 of 40: [vr-tests] blocked by [@uifabric/foundation]! +19 of 40: [dom-tests] blocked by [@uifabric/foundation]! +20 of 40: [perf-test] blocked by [@uifabric/foundation]! +21 of 40: [test-bundles] blocked by [@uifabric/foundation]! +22 of 40: [office-ui-fabric-react] blocked by [@uifabric/foundation]! +23 of 40: [@uifabric/api-docs] blocked by [@uifabric/foundation]! +24 of 40: [@uifabric/fabric-website-resources] blocked by [@uifabric/foundation]! +25 of 40: [a11y-tests] blocked by [@uifabric/foundation]! +26 of 40: [ssr-tests] blocked by [@uifabric/foundation]! +27 of 40: [@uifabric/azure-themes] blocked by [@uifabric/foundation]! +28 of 40: [@uifabric/charting] blocked by [@uifabric/foundation]! +29 of 40: [@uifabric/date-time] blocked by [@uifabric/foundation]! +30 of 40: [@uifabric/example-app-base] blocked by [@uifabric/foundation]! +31 of 40: [@uifabric/foundation-scenarios] blocked by [@uifabric/foundation]! +32 of 40: [@uifabric/lists] blocked by [@uifabric/foundation]! +33 of 40: [@uifabric/fluent-theme] blocked by [@uifabric/foundation]! +34 of 40: [@uifabric/theme-samples] blocked by [@uifabric/foundation]! +35 of 40: [@uifabric/variants] blocked by [@uifabric/foundation]! +36 of 40: [server-rendered-app] blocked by [@uifabric/foundation]! +37 of 40: [todo-app] blocked by [@uifabric/foundation]! +[@uifabric/foundation] Returned error code: 1 diff --git a/tests/cases/docker/README.md b/tests/cases/docker/README.md new file mode 100644 index 00000000000..f9b12e1a052 --- /dev/null +++ b/tests/cases/docker/README.md @@ -0,0 +1,21 @@ +Integrations +============ + +This repository contains `Dockerfile`s that describe how to build open source projects (usually those with complex build tasks) with a specific version of typescript. These are used for extended validations of a given typescript build. + +Contributing +----------- + +To add a new test: +* Create a new folder with the name of the project +* Create a `Dockerfile` within that folder +* The `Dockerfile` will be built with `docker build . -t tstest/folder` and then run with `docker run tstest/folder` +* Write the dockerfile such that it can build the target project and injects the typescript package from the `typescript/typescript` image (which should have a tar file at `/typescript/typescript-*.tgz`) + +Debugging +--------- + +You can open a test's container with an interactive shell to debug with `docker run -it --entrypoint "/bin/sh" tstest/folder`. +If you want to remote debug a typescript process within a container, you'll need to forward the port you instruct the +compiler or language server to listen on by passing `--expose PORT` where `PORT` is the port number you'd like forwarded to the +host. diff --git a/tests/cases/docker/azure-sdk/Dockerfile b/tests/cases/docker/azure-sdk/Dockerfile new file mode 100644 index 00000000000..e65643445aa --- /dev/null +++ b/tests/cases/docker/azure-sdk/Dockerfile @@ -0,0 +1,19 @@ +FROM node:current +RUN npm install -g @microsoft/rush +RUN git clone https://github.com/Azure/azure-sdk-for-js.git /azure-sdk +WORKDIR /azure-sdk +RUN git pull +RUN rush update +WORKDIR /azure-sdk/sdk/core/core-http +# Sync up all TS versions used internally so they're all linked from a known location +RUN rush add -p "typescript@3.5.1" --exact --dev -m +# Relink installed TSes to built TS +WORKDIR /azure-sdk/common/temp/node_modules/.registry.npmjs.org/typescript/3.5.1/node_modules +RUN rm -rf typescript +COPY --from=typescript/typescript /typescript/typescript-*.tgz /typescript.tgz +RUN mkdir /typescript +RUN tar -xzvf /typescript.tgz -C /typescript +RUN ln -s /typescript/package ./typescript +WORKDIR /azure-sdk +ENTRYPOINT [ "rush" ] +CMD [ "rebuild", "--parallelism", "1" ] \ No newline at end of file diff --git a/tests/cases/docker/office-ui-fabric/Dockerfile b/tests/cases/docker/office-ui-fabric/Dockerfile new file mode 100644 index 00000000000..718289fabe3 --- /dev/null +++ b/tests/cases/docker/office-ui-fabric/Dockerfile @@ -0,0 +1,20 @@ +FROM node:current +RUN npm install -g @microsoft/rush +RUN git clone https://github.com/OfficeDev/office-ui-fabric-react.git /office-ui-fabric-react +WORKDIR /office-ui-fabric-react +RUN git pull +RUN rush update +WORKDIR /office-ui-fabric-react/scripts +# Sync up all TS versions used internally so they're all linked from a known location +RUN rush add -p "typescript@3.5.1" --exact --dev -m +# Relink installed TSes to built TS +WORKDIR /office-ui-fabric-react/common/temp/node_modules/.registry.npmjs.org/typescript/3.5.1/node_modules +RUN rm -rf typescript +COPY --from=typescript/typescript /typescript/typescript-*.tgz /typescript.tgz +RUN mkdir /typescript +RUN tar -xzvf /typescript.tgz -C /typescript +RUN ln -s /typescript/package ./typescript +RUN npm i -g /typescript.tgz +WORKDIR /office-ui-fabric-react +ENTRYPOINT [ "rush" ] +CMD [ "rebuild", "--parallelism", "1" ] \ No newline at end of file From f2735b5a0695b6194e0f798fc17ffa3f28035a8a Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 20 Jun 2019 12:58:16 -0700 Subject: [PATCH 15/26] Fake up a namespace enclosing declaration when generating expando namespace members (#31971) * Fake up a namespace enclosing declaration when generating expando namespace members * Fix #31676 --- src/compiler/transformers/declarations.ts | 12 +- ...onEmitDefaultExportWithStaticAssignment.js | 114 ++++++++++++++++++ ...tDefaultExportWithStaticAssignment.symbols | 71 +++++++++++ ...mitDefaultExportWithStaticAssignment.types | 77 ++++++++++++ ...onEmitDefaultExportWithStaticAssignment.ts | 32 +++++ 5 files changed, 303 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js create mode 100644 tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.symbols create mode 100644 tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.types create mode 100644 tests/cases/compiler/declarationEmitDefaultExportWithStaticAssignment.ts diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 20aac7d4936..03f08b4de54 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -1036,19 +1036,25 @@ namespace ts { /*body*/ undefined )); if (clean && resolver.isExpandoFunctionDeclaration(input)) { - const declarations = mapDefined(resolver.getPropertiesOfContainerFunction(input), p => { + const props = resolver.getPropertiesOfContainerFunction(input); + const fakespace = createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || createIdentifier("_default"), createModuleBlock([]), NodeFlags.Namespace); + fakespace.flags ^= NodeFlags.Synthesized; // unset synthesized so it is usable as an enclosing declaration + fakespace.parent = enclosingDeclaration as SourceFile | NamespaceDeclaration; + fakespace.locals = createSymbolTable(props); + fakespace.symbol = props[0].parent!; + const declarations = mapDefined(props, p => { if (!isPropertyAccessExpression(p.valueDeclaration)) { return undefined; } getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration); - const type = resolver.createTypeOfDeclaration(p.valueDeclaration, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker); + const type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace, declarationEmitNodeBuilderFlags, symbolTracker); getSymbolAccessibilityDiagnostic = oldDiag; const varDecl = createVariableDeclaration(unescapeLeadingUnderscores(p.escapedName), type, /*initializer*/ undefined); return createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList([varDecl])); }); const namespaceDecl = createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input, isPrivate), input.name!, createModuleBlock(declarations), NodeFlags.Namespace); - if (!hasModifier(clean, ModifierFlags.ExportDefault)) { + if (!hasModifier(clean, ModifierFlags.Default)) { return [clean, namespaceDecl]; } diff --git a/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js new file mode 100644 index 00000000000..0edf3b6f01b --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.js @@ -0,0 +1,114 @@ +//// [tests/cases/compiler/declarationEmitDefaultExportWithStaticAssignment.ts] //// + +//// [foo.ts] +export class Foo {} + +//// [index1.ts] +import {Foo} from './foo'; +export default function Example() {} +Example.Foo = Foo + +//// [index2.ts] +import {Foo} from './foo'; +export {Foo}; +export default function Example() {} +Example.Foo = Foo + +//// [index3.ts] +export class Bar {} +export default function Example() {} + +Example.Bar = Bar + +//// [index4.ts] +function A() { } + +function B() { } + +export function C() { + return null; +} + +C.A = A; +C.B = B; + +//// [foo.js] +"use strict"; +exports.__esModule = true; +var Foo = /** @class */ (function () { + function Foo() { + } + return Foo; +}()); +exports.Foo = Foo; +//// [index1.js] +"use strict"; +exports.__esModule = true; +var foo_1 = require("./foo"); +function Example() { } +exports["default"] = Example; +Example.Foo = foo_1.Foo; +//// [index2.js] +"use strict"; +exports.__esModule = true; +var foo_1 = require("./foo"); +exports.Foo = foo_1.Foo; +function Example() { } +exports["default"] = Example; +Example.Foo = foo_1.Foo; +//// [index3.js] +"use strict"; +exports.__esModule = true; +var Bar = /** @class */ (function () { + function Bar() { + } + return Bar; +}()); +exports.Bar = Bar; +function Example() { } +exports["default"] = Example; +Example.Bar = Bar; +//// [index4.js] +"use strict"; +exports.__esModule = true; +function A() { } +function B() { } +function C() { + return null; +} +exports.C = C; +C.A = A; +C.B = B; + + +//// [foo.d.ts] +export declare class Foo { +} +//// [index1.d.ts] +declare function Example(): void; +declare namespace Example { + var Foo: typeof import("./foo").Foo; +} +export default Example; +//// [index2.d.ts] +import { Foo } from './foo'; +export { Foo }; +declare function Example(): void; +declare namespace Example { + var Foo: typeof import("./foo").Foo; +} +export default Example; +//// [index3.d.ts] +export declare class Bar { +} +declare function Example(): void; +declare namespace Example { + var Bar: typeof import("./index3").Bar; +} +export default Example; +//// [index4.d.ts] +export declare function C(): any; +export declare namespace C { + var A: () => void; + var B: () => void; +} diff --git a/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.symbols b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.symbols new file mode 100644 index 00000000000..f65952c18d7 --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.symbols @@ -0,0 +1,71 @@ +=== tests/cases/compiler/foo.ts === +export class Foo {} +>Foo : Symbol(Foo, Decl(foo.ts, 0, 0)) + +=== tests/cases/compiler/index1.ts === +import {Foo} from './foo'; +>Foo : Symbol(Foo, Decl(index1.ts, 0, 8)) + +export default function Example() {} +>Example : Symbol(Example, Decl(index1.ts, 0, 26), Decl(index1.ts, 1, 36)) + +Example.Foo = Foo +>Example.Foo : Symbol(Example.Foo, Decl(index1.ts, 1, 36)) +>Example : Symbol(Example, Decl(index1.ts, 0, 26), Decl(index1.ts, 1, 36)) +>Foo : Symbol(Example.Foo, Decl(index1.ts, 1, 36)) +>Foo : Symbol(Foo, Decl(index1.ts, 0, 8)) + +=== tests/cases/compiler/index2.ts === +import {Foo} from './foo'; +>Foo : Symbol(Foo, Decl(index2.ts, 0, 8)) + +export {Foo}; +>Foo : Symbol(Foo, Decl(index2.ts, 1, 8)) + +export default function Example() {} +>Example : Symbol(Example, Decl(index2.ts, 1, 13), Decl(index2.ts, 2, 36)) + +Example.Foo = Foo +>Example.Foo : Symbol(Example.Foo, Decl(index2.ts, 2, 36)) +>Example : Symbol(Example, Decl(index2.ts, 1, 13), Decl(index2.ts, 2, 36)) +>Foo : Symbol(Example.Foo, Decl(index2.ts, 2, 36)) +>Foo : Symbol(Foo, Decl(index2.ts, 0, 8)) + +=== tests/cases/compiler/index3.ts === +export class Bar {} +>Bar : Symbol(Bar, Decl(index3.ts, 0, 0)) + +export default function Example() {} +>Example : Symbol(Example, Decl(index3.ts, 0, 19), Decl(index3.ts, 1, 36)) + +Example.Bar = Bar +>Example.Bar : Symbol(Example.Bar, Decl(index3.ts, 1, 36)) +>Example : Symbol(Example, Decl(index3.ts, 0, 19), Decl(index3.ts, 1, 36)) +>Bar : Symbol(Example.Bar, Decl(index3.ts, 1, 36)) +>Bar : Symbol(Bar, Decl(index3.ts, 0, 0)) + +=== tests/cases/compiler/index4.ts === +function A() { } +>A : Symbol(A, Decl(index4.ts, 0, 0)) + +function B() { } +>B : Symbol(B, Decl(index4.ts, 0, 17)) + +export function C() { +>C : Symbol(C, Decl(index4.ts, 2, 16), Decl(index4.ts, 6, 1)) + + return null; +} + +C.A = A; +>C.A : Symbol(C.A, Decl(index4.ts, 6, 1)) +>C : Symbol(C, Decl(index4.ts, 2, 16), Decl(index4.ts, 6, 1)) +>A : Symbol(C.A, Decl(index4.ts, 6, 1)) +>A : Symbol(A, Decl(index4.ts, 0, 0)) + +C.B = B; +>C.B : Symbol(C.B, Decl(index4.ts, 8, 8)) +>C : Symbol(C, Decl(index4.ts, 2, 16), Decl(index4.ts, 6, 1)) +>B : Symbol(C.B, Decl(index4.ts, 8, 8)) +>B : Symbol(B, Decl(index4.ts, 0, 17)) + diff --git a/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.types b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.types new file mode 100644 index 00000000000..b00ddcd68cf --- /dev/null +++ b/tests/baselines/reference/declarationEmitDefaultExportWithStaticAssignment.types @@ -0,0 +1,77 @@ +=== tests/cases/compiler/foo.ts === +export class Foo {} +>Foo : Foo + +=== tests/cases/compiler/index1.ts === +import {Foo} from './foo'; +>Foo : typeof Foo + +export default function Example() {} +>Example : typeof Example + +Example.Foo = Foo +>Example.Foo = Foo : typeof Foo +>Example.Foo : typeof Foo +>Example : typeof Example +>Foo : typeof Foo +>Foo : typeof Foo + +=== tests/cases/compiler/index2.ts === +import {Foo} from './foo'; +>Foo : typeof Foo + +export {Foo}; +>Foo : typeof Foo + +export default function Example() {} +>Example : typeof Example + +Example.Foo = Foo +>Example.Foo = Foo : typeof Foo +>Example.Foo : typeof Foo +>Example : typeof Example +>Foo : typeof Foo +>Foo : typeof Foo + +=== tests/cases/compiler/index3.ts === +export class Bar {} +>Bar : Bar + +export default function Example() {} +>Example : typeof Example + +Example.Bar = Bar +>Example.Bar = Bar : typeof Bar +>Example.Bar : typeof Bar +>Example : typeof Example +>Bar : typeof Bar +>Bar : typeof Bar + +=== tests/cases/compiler/index4.ts === +function A() { } +>A : () => void + +function B() { } +>B : () => void + +export function C() { +>C : typeof C + + return null; +>null : null +} + +C.A = A; +>C.A = A : () => void +>C.A : () => void +>C : typeof C +>A : () => void +>A : () => void + +C.B = B; +>C.B = B : () => void +>C.B : () => void +>C : typeof C +>B : () => void +>B : () => void + diff --git a/tests/cases/compiler/declarationEmitDefaultExportWithStaticAssignment.ts b/tests/cases/compiler/declarationEmitDefaultExportWithStaticAssignment.ts new file mode 100644 index 00000000000..d6638ab8e36 --- /dev/null +++ b/tests/cases/compiler/declarationEmitDefaultExportWithStaticAssignment.ts @@ -0,0 +1,32 @@ +// @declaration: true +// @filename: foo.ts +export class Foo {} + +// @filename: index1.ts +import {Foo} from './foo'; +export default function Example() {} +Example.Foo = Foo + +// @filename: index2.ts +import {Foo} from './foo'; +export {Foo}; +export default function Example() {} +Example.Foo = Foo + +// @filename: index3.ts +export class Bar {} +export default function Example() {} + +Example.Bar = Bar + +// @filename: index4.ts +function A() { } + +function B() { } + +export function C() { + return null; +} + +C.A = A; +C.B = B; \ No newline at end of file From 0e5d95feef2c38d9a42896042fd971f13cf6d378 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 20 Jun 2019 16:09:24 -0700 Subject: [PATCH 16/26] Container only ref needs to be ignored from uptodate status Fixes #31288 --- src/compiler/tsbuild.ts | 3 +- src/testRunner/tsconfig.json | 1 + .../tsbuild/containerOnlyReferenced.ts | 48 +++++++++++++++++++ .../tsbuild/referencesWithRootDirInParent.ts | 1 - .../src/folder/index.ts | 1 + .../src/folder/tsconfig.json | 6 +++ .../src/folder2/index.ts | 1 + .../src/folder2/tsconfig.json | 6 +++ .../containerOnlyReferenced/src/tsconfig.json | 10 ++++ .../containerOnlyReferenced/tests/index.ts | 1 + .../tests/tsconfig.json | 9 ++++ .../containerOnlyReferenced/tsconfig.json | 10 ++++ 12 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts create mode 100644 tests/projects/containerOnlyReferenced/src/folder/index.ts create mode 100644 tests/projects/containerOnlyReferenced/src/folder/tsconfig.json create mode 100644 tests/projects/containerOnlyReferenced/src/folder2/index.ts create mode 100644 tests/projects/containerOnlyReferenced/src/folder2/tsconfig.json create mode 100644 tests/projects/containerOnlyReferenced/src/tsconfig.json create mode 100644 tests/projects/containerOnlyReferenced/tests/index.ts create mode 100644 tests/projects/containerOnlyReferenced/tests/tsconfig.json create mode 100644 tests/projects/containerOnlyReferenced/tsconfig.json diff --git a/src/compiler/tsbuild.ts b/src/compiler/tsbuild.ts index 4602c0793be..f2a43e5e79a 100644 --- a/src/compiler/tsbuild.ts +++ b/src/compiler/tsbuild.ts @@ -1462,7 +1462,8 @@ namespace ts { const refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath); // Its a circular reference ignore the status of this project - if (refStatus.type === UpToDateStatusType.ComputingUpstream) { + if (refStatus.type === UpToDateStatusType.ComputingUpstream || + refStatus.type === UpToDateStatusType.ContainerOnly) { // Container only ignore this project continue; } diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 07499a998ba..b2e7e3e78b9 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -90,6 +90,7 @@ "unittests/services/textChanges.ts", "unittests/services/transpile.ts", "unittests/tsbuild/amdModulesWithOut.ts", + "unittests/tsbuild/containerOnlyReferenced.ts", "unittests/tsbuild/emptyFiles.ts", "unittests/tsbuild/graphOrdering.ts", "unittests/tsbuild/inferredTypeFromTransitiveModule.ts", diff --git a/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts new file mode 100644 index 00000000000..425dbf2e20f --- /dev/null +++ b/src/testRunner/unittests/tsbuild/containerOnlyReferenced.ts @@ -0,0 +1,48 @@ +namespace ts { + describe("unittests:: tsbuild:: when containerOnly project is referenced", () => { + let projFs: vfs.FileSystem; + before(() => { + projFs = loadProjectFromDisk("tests/projects/containerOnlyReferenced"); + }); + + after(() => { + projFs = undefined!; // Release the contents + }); + + function outputs(folder: string) { + return [ + `${folder}/index.js`, + `${folder}/index.d.ts`, + `${folder}/tsconfig.tsbuildinfo` + ]; + } + + it("verify that subsequent builds after initial build doesnt build anything", () => { + const fs = projFs.shadow(); + const host = new fakes.SolutionBuilderHost(fs); + createSolutionBuilder(host, ["/src"], { verbose: true }).build(); + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild("src/src/folder/tsconfig.json", "src/src/folder2/tsconfig.json", "src/src/tsconfig.json", "src/tests/tsconfig.json", "src/tsconfig.json"), + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/src/folder/tsconfig.json", "src/src/folder/index.js"], + [Diagnostics.Building_project_0, "/src/src/folder/tsconfig.json"], + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/src/folder2/tsconfig.json", "src/src/folder2/index.js"], + [Diagnostics.Building_project_0, "/src/src/folder2/tsconfig.json"], + [Diagnostics.Project_0_is_out_of_date_because_output_file_1_does_not_exist, "src/tests/tsconfig.json", "src/tests/index.js"], + [Diagnostics.Building_project_0, "/src/tests/tsconfig.json"], + ); + verifyOutputsPresent(fs, [ + ...outputs("/src/src/folder"), + ...outputs("/src/src/folder2"), + ...outputs("/src/tests"), + ]); + host.clearDiagnostics(); + createSolutionBuilder(host, ["/src"], { verbose: true }).build(); + host.assertDiagnosticMessages( + getExpectedDiagnosticForProjectsInBuild("src/src/folder/tsconfig.json", "src/src/folder2/tsconfig.json", "src/src/tsconfig.json", "src/tests/tsconfig.json", "src/tsconfig.json"), + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/src/folder/tsconfig.json", "src/src/folder/index.ts", "src/src/folder/index.js"], + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/src/folder2/tsconfig.json", "src/src/folder2/index.ts", "src/src/folder2/index.js"], + [Diagnostics.Project_0_is_up_to_date_because_newest_input_1_is_older_than_oldest_output_2, "src/tests/tsconfig.json", "src/tests/index.ts", "src/tests/index.js"], + ); + }); + }); +} diff --git a/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts b/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts index 186a43b3c3e..f6a2dca6c2e 100644 --- a/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts +++ b/src/testRunner/unittests/tsbuild/referencesWithRootDirInParent.ts @@ -10,7 +10,6 @@ namespace ts { }); it("verify that it builds correctly", () => { - const projFs = loadProjectFromDisk("tests/projects/projectReferenceWithRootDirInParent"); const allExpectedOutputs = [ "/src/dist/other/other.js", "/src/dist/other/other.d.ts", "/src/dist/main/a.js", "/src/dist/main/a.d.ts", diff --git a/tests/projects/containerOnlyReferenced/src/folder/index.ts b/tests/projects/containerOnlyReferenced/src/folder/index.ts new file mode 100644 index 00000000000..a65e4235153 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/folder/index.ts @@ -0,0 +1 @@ +export const x = 10; \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/src/folder/tsconfig.json b/tests/projects/containerOnlyReferenced/src/folder/tsconfig.json new file mode 100644 index 00000000000..d54f4070fe9 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/folder/tsconfig.json @@ -0,0 +1,6 @@ +{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + } +} \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/src/folder2/index.ts b/tests/projects/containerOnlyReferenced/src/folder2/index.ts new file mode 100644 index 00000000000..a65e4235153 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/folder2/index.ts @@ -0,0 +1 @@ +export const x = 10; \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/src/folder2/tsconfig.json b/tests/projects/containerOnlyReferenced/src/folder2/tsconfig.json new file mode 100644 index 00000000000..d54f4070fe9 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/folder2/tsconfig.json @@ -0,0 +1,6 @@ +{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + } +} \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/src/tsconfig.json b/tests/projects/containerOnlyReferenced/src/tsconfig.json new file mode 100644 index 00000000000..4d67b0f8bea --- /dev/null +++ b/tests/projects/containerOnlyReferenced/src/tsconfig.json @@ -0,0 +1,10 @@ +{ + "files": [], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./folder" }, + { "path": "./folder2"} + ] + } \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/tests/index.ts b/tests/projects/containerOnlyReferenced/tests/index.ts new file mode 100644 index 00000000000..a65e4235153 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/tests/index.ts @@ -0,0 +1 @@ +export const x = 10; \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/tests/tsconfig.json b/tests/projects/containerOnlyReferenced/tests/tsconfig.json new file mode 100644 index 00000000000..987385d9745 --- /dev/null +++ b/tests/projects/containerOnlyReferenced/tests/tsconfig.json @@ -0,0 +1,9 @@ +{ + "files": ["index.ts"], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "../src" } + ] +} \ No newline at end of file diff --git a/tests/projects/containerOnlyReferenced/tsconfig.json b/tests/projects/containerOnlyReferenced/tsconfig.json new file mode 100644 index 00000000000..28ea2a4385e --- /dev/null +++ b/tests/projects/containerOnlyReferenced/tsconfig.json @@ -0,0 +1,10 @@ +{ + "files": [], + "compilerOptions": { + "composite": true + }, + "references": [ + { "path": "./src" }, + { "path": "./tests"} + ] +} \ No newline at end of file From a97c18f227c22d3d6e0e5d413d91d3eb06065410 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 20 Jun 2019 17:20:12 -0700 Subject: [PATCH 17/26] Ignore identifier declarations when calculating symbol visibility (#31974) --- src/compiler/checker.ts | 2 +- ...arationEmitExpandoWithGenericConstraint.js | 38 +++++++++++++ ...onEmitExpandoWithGenericConstraint.symbols | 53 +++++++++++++++++++ ...tionEmitExpandoWithGenericConstraint.types | 48 +++++++++++++++++ ...arationEmitExpandoWithGenericConstraint.ts | 15 ++++++ 5 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.js create mode 100644 tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.symbols create mode 100644 tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.types create mode 100644 tests/cases/compiler/declarationEmitExpandoWithGenericConstraint.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9ffa85e73e1..b5baa611729 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3265,7 +3265,7 @@ namespace ts { function hasVisibleDeclarations(symbol: Symbol, shouldComputeAliasToMakeVisible: boolean): SymbolVisibilityResult | undefined { let aliasesToMakeVisible: LateVisibilityPaintedStatement[] | undefined; - if (!every(symbol.declarations, getIsDeclarationVisible)) { + if (!every(filter(symbol.declarations, d => d.kind !== SyntaxKind.Identifier), getIsDeclarationVisible)) { return undefined; } return { accessibility: SymbolAccessibility.Accessible, aliasesToMakeVisible }; diff --git a/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.js b/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.js new file mode 100644 index 00000000000..ac1054da110 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.js @@ -0,0 +1,38 @@ +//// [declarationEmitExpandoWithGenericConstraint.ts] +export interface Point { + readonly x: number; + readonly y: number; +} + +export interface Rect

{ + readonly a: p; + readonly b: p; +} + +export const Point = (x: number, y: number): Point => ({ x, y }); +export const Rect =

(a: p, b: p): Rect

=> ({ a, b }); + +Point.zero = (): Point => Point(0, 0); + +//// [declarationEmitExpandoWithGenericConstraint.js] +"use strict"; +exports.__esModule = true; +exports.Point = function (x, y) { return ({ x: x, y: y }); }; +exports.Rect = function (a, b) { return ({ a: a, b: b }); }; +exports.Point.zero = function () { return exports.Point(0, 0); }; + + +//// [declarationEmitExpandoWithGenericConstraint.d.ts] +export interface Point { + readonly x: number; + readonly y: number; +} +export interface Rect

{ + readonly a: p; + readonly b: p; +} +export declare const Point: { + (x: number, y: number): Point; + zero(): Point; +}; +export declare const Rect:

(a: p, b: p) => Rect

; diff --git a/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.symbols b/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.symbols new file mode 100644 index 00000000000..3d3300b3a3a --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.symbols @@ -0,0 +1,53 @@ +=== tests/cases/compiler/declarationEmitExpandoWithGenericConstraint.ts === +export interface Point { +>Point : Symbol(Point, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 0), Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 12), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) + + readonly x: number; +>x : Symbol(Point.x, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 24)) + + readonly y: number; +>y : Symbol(Point.y, Decl(declarationEmitExpandoWithGenericConstraint.ts, 1, 23)) +} + +export interface Rect

{ +>Rect : Symbol(Rect, Decl(declarationEmitExpandoWithGenericConstraint.ts, 3, 1), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 12)) +>p : Symbol(p, Decl(declarationEmitExpandoWithGenericConstraint.ts, 5, 22)) +>Point : Symbol(Point, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 0), Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 12), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) + + readonly a: p; +>a : Symbol(Rect.a, Decl(declarationEmitExpandoWithGenericConstraint.ts, 5, 40)) +>p : Symbol(p, Decl(declarationEmitExpandoWithGenericConstraint.ts, 5, 22)) + + readonly b: p; +>b : Symbol(Rect.b, Decl(declarationEmitExpandoWithGenericConstraint.ts, 6, 18)) +>p : Symbol(p, Decl(declarationEmitExpandoWithGenericConstraint.ts, 5, 22)) +} + +export const Point = (x: number, y: number): Point => ({ x, y }); +>Point : Symbol(Point, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 0), Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 12), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) +>x : Symbol(x, Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 22)) +>y : Symbol(y, Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 32)) +>Point : Symbol(Point, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 0), Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 12), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) +>x : Symbol(x, Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 56)) +>y : Symbol(y, Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 59)) + +export const Rect =

(a: p, b: p): Rect

=> ({ a, b }); +>Rect : Symbol(Rect, Decl(declarationEmitExpandoWithGenericConstraint.ts, 3, 1), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 12)) +>p : Symbol(p, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 21)) +>Point : Symbol(Point, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 0), Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 12), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) +>a : Symbol(a, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 38)) +>p : Symbol(p, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 21)) +>b : Symbol(b, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 43)) +>p : Symbol(p, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 21)) +>Rect : Symbol(Rect, Decl(declarationEmitExpandoWithGenericConstraint.ts, 3, 1), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 12)) +>p : Symbol(p, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 21)) +>a : Symbol(a, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 64)) +>b : Symbol(b, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 67)) + +Point.zero = (): Point => Point(0, 0); +>Point.zero : Symbol(Point.zero, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) +>Point : Symbol(Point, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 0), Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 12), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) +>zero : Symbol(Point.zero, Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) +>Point : Symbol(Point, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 0), Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 12), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) +>Point : Symbol(Point, Decl(declarationEmitExpandoWithGenericConstraint.ts, 0, 0), Decl(declarationEmitExpandoWithGenericConstraint.ts, 10, 12), Decl(declarationEmitExpandoWithGenericConstraint.ts, 11, 73)) + diff --git a/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.types b/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.types new file mode 100644 index 00000000000..d4443fd0de4 --- /dev/null +++ b/tests/baselines/reference/declarationEmitExpandoWithGenericConstraint.types @@ -0,0 +1,48 @@ +=== tests/cases/compiler/declarationEmitExpandoWithGenericConstraint.ts === +export interface Point { + readonly x: number; +>x : number + + readonly y: number; +>y : number +} + +export interface Rect

{ + readonly a: p; +>a : p + + readonly b: p; +>b : p +} + +export const Point = (x: number, y: number): Point => ({ x, y }); +>Point : { (x: number, y: number): Point; zero(): Point; } +>(x: number, y: number): Point => ({ x, y }) : { (x: number, y: number): Point; zero(): Point; } +>x : number +>y : number +>({ x, y }) : { x: number; y: number; } +>{ x, y } : { x: number; y: number; } +>x : number +>y : number + +export const Rect =

(a: p, b: p): Rect

=> ({ a, b }); +>Rect :

(a: p, b: p) => Rect

+>

(a: p, b: p): Rect

=> ({ a, b }) :

(a: p, b: p) => Rect

+>a : p +>b : p +>({ a, b }) : { a: p; b: p; } +>{ a, b } : { a: p; b: p; } +>a : p +>b : p + +Point.zero = (): Point => Point(0, 0); +>Point.zero = (): Point => Point(0, 0) : () => Point +>Point.zero : () => Point +>Point : { (x: number, y: number): Point; zero(): Point; } +>zero : () => Point +>(): Point => Point(0, 0) : () => Point +>Point(0, 0) : Point +>Point : { (x: number, y: number): Point; zero(): Point; } +>0 : 0 +>0 : 0 + diff --git a/tests/cases/compiler/declarationEmitExpandoWithGenericConstraint.ts b/tests/cases/compiler/declarationEmitExpandoWithGenericConstraint.ts new file mode 100644 index 00000000000..79a704ce5ba --- /dev/null +++ b/tests/cases/compiler/declarationEmitExpandoWithGenericConstraint.ts @@ -0,0 +1,15 @@ +// @declaration: true +export interface Point { + readonly x: number; + readonly y: number; +} + +export interface Rect

{ + readonly a: p; + readonly b: p; +} + +export const Point = (x: number, y: number): Point => ({ x, y }); +export const Rect =

(a: p, b: p): Rect

=> ({ a, b }); + +Point.zero = (): Point => Point(0, 0); \ No newline at end of file From 37b20f6afd3eee694c26ca39c586c42ec97be98e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 20 Jun 2019 19:11:46 -0700 Subject: [PATCH 18/26] Eliminate references to defunct LSHost in comments (#32018) --- src/compiler/moduleNameResolver.ts | 4 ++-- src/server/project.ts | 2 +- src/testRunner/unittests/tscWatch/resolutionCache.ts | 2 +- .../unittests/tsserver/cachingFileSystemInformation.ts | 4 ++-- src/testRunner/unittests/tsserver/resolutionCache.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 604b82cce5e..94f835caff5 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -1487,8 +1487,8 @@ namespace ts { } /** - * LSHost may load a module from a global cache of typings. - * This is the minumum code needed to expose that functionality; the rest is in LSHost. + * A host may load a module from a global cache of typings. + * This is the minumum code needed to expose that functionality; the rest is in the host. */ /* @internal */ export function loadModuleFromGlobalCache(moduleName: string, projectName: string | undefined, compilerOptions: CompilerOptions, host: ModuleResolutionHost, globalCache: string): ResolvedModuleWithFailedLookupLocations { diff --git a/src/server/project.ts b/src/server/project.ts index a1a43a430f1..d1605e22d1d 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -952,7 +952,7 @@ namespace ts.server { this.externalFiles = this.getExternalFiles(); enumerateInsertsAndDeletes(this.externalFiles, oldExternalFiles, getStringComparer(!this.useCaseSensitiveFileNames()), // Ensure a ScriptInfo is created for new external files. This is performed indirectly - // by the LSHost for files in the program when the program is retrieved above but + // by the host for files in the program when the program is retrieved above but // the program doesn't contain external files so this must be done explicitly. inserted => { const scriptInfo = this.projectService.getOrCreateScriptInfoNotOpenedByClient(inserted, this.currentDirectory, this.directoryStructureHost)!; diff --git a/src/testRunner/unittests/tscWatch/resolutionCache.ts b/src/testRunner/unittests/tscWatch/resolutionCache.ts index b29fde85697..802b9c5bc52 100644 --- a/src/testRunner/unittests/tscWatch/resolutionCache.ts +++ b/src/testRunner/unittests/tscWatch/resolutionCache.ts @@ -54,7 +54,7 @@ namespace ts.tscWatch { root.content = `import {x} from "f2"`; host.reloadFS(files); - // trigger synchronization to make sure that LSHost will try to find 'f2' module on disk + // trigger synchronization to make sure that system will try to find 'f2' module on disk host.runQueuedTimeoutCallbacks(); // ensure file has correct number of errors after edit diff --git a/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts b/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts index 53a1cb4e421..688c8c49ebe 100644 --- a/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts +++ b/src/testRunner/unittests/tsserver/cachingFileSystemInformation.ts @@ -131,10 +131,10 @@ namespace ts.projectSystem { verifyImportedDiagnostics(); callsTrackingHost.verifyNoHostCalls(); - // trigger synchronization to make sure that LSHost will try to find 'f2' module on disk + // trigger synchronization to make sure that the host will try to find 'f2' module on disk editContent(`import {x} from "f2"`); try { - // trigger synchronization to make sure that LSHost will try to find 'f2' module on disk + // trigger synchronization to make sure that the host will try to find 'f2' module on disk verifyImportedDiagnostics(); assert.isTrue(false, `should not find file '${imported.path}'`); } diff --git a/src/testRunner/unittests/tsserver/resolutionCache.ts b/src/testRunner/unittests/tsserver/resolutionCache.ts index 441146ed33d..e9be75b90c1 100644 --- a/src/testRunner/unittests/tsserver/resolutionCache.ts +++ b/src/testRunner/unittests/tsserver/resolutionCache.ts @@ -5,7 +5,7 @@ namespace ts.projectSystem { return resolutionTrace; } - describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem extra resolution pass in lshost", () => { + describe("unittests:: tsserver:: resolutionCache:: tsserverProjectSystem extra resolution pass in server host", () => { it("can load typings that are proper modules", () => { const file1 = { path: "/a/b/app.js", From 1c58c1686e8e2e2a026f51d86c6613991745ef1f Mon Sep 17 00:00:00 2001 From: typescript-bot Date: Fri, 21 Jun 2019 13:47:03 +0000 Subject: [PATCH 19/26] Update user baselines --- .../reference/docker/office-ui-fabric.log | 84 ++++++++++--------- .../user/TypeScript-React-Native-Starter.log | 2 +- 2 files changed, 44 insertions(+), 42 deletions(-) diff --git a/tests/baselines/reference/docker/office-ui-fabric.log b/tests/baselines/reference/docker/office-ui-fabric.log index e551d2ead88..7107d8f3bcf 100644 --- a/tests/baselines/reference/docker/office-ui-fabric.log +++ b/tests/baselines/reference/docker/office-ui-fabric.log @@ -10,15 +10,15 @@ Starting "rush rebuild" Executing a maximum of 1 simultaneous processes... [@uifabric/prettier-rules] started -1 of 40: [@uifabric/prettier-rules] completed successfully in ? seconds +1 of 41: [@uifabric/prettier-rules] completed successfully in ? seconds [@uifabric/tslint-rules] started -2 of 40: [@uifabric/tslint-rules] completed successfully in ? seconds +2 of 41: [@uifabric/tslint-rules] completed successfully in ? seconds [@uifabric/codepen-loader] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/build] started -4 of 40: [@uifabric/build] completed successfully in ? seconds +4 of 41: [@uifabric/build] completed successfully in ? seconds [@uifabric/migration] started -5 of 40: [@uifabric/migration] completed successfully in ? seconds +5 of 41: [@uifabric/migration] completed successfully in ? seconds [@uifabric/set-version] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/merge-styles] started @@ -26,13 +26,13 @@ ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed [@uifabric/jest-serializer-merge-styles] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/test-utilities] started -9 of 40: [@uifabric/test-utilities] completed successfully in ? seconds +9 of 41: [@uifabric/test-utilities] completed successfully in ? seconds [@uifabric/utilities] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/styling] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/file-type-icons] started -12 of 40: [@uifabric/file-type-icons] completed successfully in ? seconds +12 of 41: [@uifabric/file-type-icons] completed successfully in ? seconds [@uifabric/foundation] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. ● createFactory › passes componentProps without userProps @@ -270,9 +270,9 @@ ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed [XX:XX:XX XM] x finished 'build' in ?s with errors [XX:XX:XX XM] x Error previously detected. See above for error messages. [@uifabric/icons] started -38 of 40: [@uifabric/icons] completed successfully in ? seconds +39 of 41: [@uifabric/icons] completed successfully in ? seconds [@uifabric/webpack-utils] started -39 of 40: [@uifabric/webpack-utils] completed successfully in ? seconds +40 of 41: [@uifabric/webpack-utils] completed successfully in ? seconds SUCCESS (8) ================================ @@ -307,7 +307,7 @@ ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. ================================ -BLOCKED (25) +BLOCKED (26) ================================ @uifabric/api-docs @uifabric/azure-themes @@ -323,6 +323,7 @@ BLOCKED (25) @uifabric/pr-deploy-site @uifabric/react-cards @uifabric/theme-samples +@uifabric/tsx-editor @uifabric/variants a11y-tests dom-tests @@ -380,37 +381,38 @@ rush rebuild - Errors! ( ? seconds) Standard error: Your version of Node.js (12.4.0) has not been tested with this release of Rush. The Rush team will not accept issue reports for it. Please consider upgrading Rush or downgrading Node.js. -3 of 40: [@uifabric/codepen-loader] completed with warnings in ? seconds -6 of 40: [@uifabric/set-version] completed with warnings in ? seconds -7 of 40: [@uifabric/merge-styles] completed with warnings in ? seconds -8 of 40: [@uifabric/jest-serializer-merge-styles] completed with warnings in ? seconds -10 of 40: [@uifabric/utilities] completed with warnings in ? seconds -11 of 40: [@uifabric/styling] completed with warnings in ? seconds +3 of 41: [@uifabric/codepen-loader] completed with warnings in ? seconds +6 of 41: [@uifabric/set-version] completed with warnings in ? seconds +7 of 41: [@uifabric/merge-styles] completed with warnings in ? seconds +8 of 41: [@uifabric/jest-serializer-merge-styles] completed with warnings in ? seconds +10 of 41: [@uifabric/utilities] completed with warnings in ? seconds +11 of 41: [@uifabric/styling] completed with warnings in ? seconds -12 of 40: [@uifabric/foundation] failed to build! -13 of 40: [@uifabric/experiments] blocked by [@uifabric/foundation]! -14 of 40: [@uifabric/fabric-website] blocked by [@uifabric/foundation]! -15 of 40: [@uifabric/pr-deploy-site] blocked by [@uifabric/foundation]! -16 of 40: [@uifabric/react-cards] blocked by [@uifabric/foundation]! -17 of 40: [theming-designer] blocked by [@uifabric/foundation]! -18 of 40: [vr-tests] blocked by [@uifabric/foundation]! -19 of 40: [dom-tests] blocked by [@uifabric/foundation]! -20 of 40: [perf-test] blocked by [@uifabric/foundation]! -21 of 40: [test-bundles] blocked by [@uifabric/foundation]! -22 of 40: [office-ui-fabric-react] blocked by [@uifabric/foundation]! -23 of 40: [@uifabric/api-docs] blocked by [@uifabric/foundation]! -24 of 40: [@uifabric/fabric-website-resources] blocked by [@uifabric/foundation]! -25 of 40: [a11y-tests] blocked by [@uifabric/foundation]! -26 of 40: [ssr-tests] blocked by [@uifabric/foundation]! -27 of 40: [@uifabric/azure-themes] blocked by [@uifabric/foundation]! -28 of 40: [@uifabric/charting] blocked by [@uifabric/foundation]! -29 of 40: [@uifabric/date-time] blocked by [@uifabric/foundation]! -30 of 40: [@uifabric/example-app-base] blocked by [@uifabric/foundation]! -31 of 40: [@uifabric/foundation-scenarios] blocked by [@uifabric/foundation]! -32 of 40: [@uifabric/lists] blocked by [@uifabric/foundation]! -33 of 40: [@uifabric/fluent-theme] blocked by [@uifabric/foundation]! -34 of 40: [@uifabric/theme-samples] blocked by [@uifabric/foundation]! -35 of 40: [@uifabric/variants] blocked by [@uifabric/foundation]! -36 of 40: [server-rendered-app] blocked by [@uifabric/foundation]! -37 of 40: [todo-app] blocked by [@uifabric/foundation]! +12 of 41: [@uifabric/foundation] failed to build! +13 of 41: [@uifabric/experiments] blocked by [@uifabric/foundation]! +14 of 41: [@uifabric/fabric-website] blocked by [@uifabric/foundation]! +15 of 41: [@uifabric/pr-deploy-site] blocked by [@uifabric/foundation]! +16 of 41: [@uifabric/react-cards] blocked by [@uifabric/foundation]! +17 of 41: [theming-designer] blocked by [@uifabric/foundation]! +18 of 41: [vr-tests] blocked by [@uifabric/foundation]! +19 of 41: [dom-tests] blocked by [@uifabric/foundation]! +20 of 41: [perf-test] blocked by [@uifabric/foundation]! +21 of 41: [test-bundles] blocked by [@uifabric/foundation]! +22 of 41: [office-ui-fabric-react] blocked by [@uifabric/foundation]! +23 of 41: [@uifabric/api-docs] blocked by [@uifabric/foundation]! +24 of 41: [@uifabric/fabric-website-resources] blocked by [@uifabric/foundation]! +25 of 41: [a11y-tests] blocked by [@uifabric/foundation]! +26 of 41: [ssr-tests] blocked by [@uifabric/foundation]! +27 of 41: [@uifabric/azure-themes] blocked by [@uifabric/foundation]! +28 of 41: [@uifabric/charting] blocked by [@uifabric/foundation]! +29 of 41: [@uifabric/date-time] blocked by [@uifabric/foundation]! +30 of 41: [@uifabric/example-app-base] blocked by [@uifabric/foundation]! +31 of 41: [@uifabric/foundation-scenarios] blocked by [@uifabric/foundation]! +32 of 41: [@uifabric/lists] blocked by [@uifabric/foundation]! +33 of 41: [@uifabric/fluent-theme] blocked by [@uifabric/foundation]! +34 of 41: [@uifabric/tsx-editor] blocked by [@uifabric/foundation]! +35 of 41: [@uifabric/theme-samples] blocked by [@uifabric/foundation]! +36 of 41: [@uifabric/variants] blocked by [@uifabric/foundation]! +37 of 41: [server-rendered-app] blocked by [@uifabric/foundation]! +38 of 41: [todo-app] blocked by [@uifabric/foundation]! [@uifabric/foundation] Returned error code: 1 diff --git a/tests/baselines/reference/user/TypeScript-React-Native-Starter.log b/tests/baselines/reference/user/TypeScript-React-Native-Starter.log index 2f5a0d1f7f5..87439a7c4e6 100644 --- a/tests/baselines/reference/user/TypeScript-React-Native-Starter.log +++ b/tests/baselines/reference/user/TypeScript-React-Native-Starter.log @@ -3,7 +3,7 @@ Standard output: node_modules/@types/react-native/index.d.ts(3425,42): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. node_modules/@types/react-native/index.d.ts(3438,42): error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. node_modules/@types/react-native/index.d.ts(8745,18): error TS2717: Subsequent property declarations must have the same type. Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'. -node_modules/@types/react/index.d.ts(378,23): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. +node_modules/@types/react/index.d.ts(377,23): error TS2583: Cannot find name 'Set'. Do you need to change your target library? Try changing the `lib` compiler option to es2015 or later. From fe2b9e9e17fd0e8488727627334c0b92c3f31a0d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 21 Jun 2019 10:38:31 -0700 Subject: [PATCH 20/26] Assert ranges exist when looped over in fourslash (#32012) --- src/harness/fourslash.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 17f6c587f80..cbe4c3336d7 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1177,7 +1177,9 @@ Actual: ${stringify(fullActual)}`); public verifyRenameLocations(startRanges: ArrayOrSingle, options: FourSlashInterface.RenameLocationsOptions) { const { findInStrings = false, findInComments = false, ranges = this.getRanges(), providePrefixAndSuffixTextForRename = true } = ts.isArray(options) ? { findInStrings: false, findInComments: false, ranges: options, providePrefixAndSuffixTextForRename: true } : options; - for (const startRange of toArray(startRanges)) { + const _startRanges = toArray(startRanges); + assert(_startRanges.length); + for (const startRange of _startRanges) { this.goToRangeStart(startRange); const renameInfo = this.languageService.getRenameInfo(this.activeFile.fileName, this.currentCaretPosition); @@ -2731,6 +2733,7 @@ Actual: ${stringify(fullActual)}`); public verifyRangesAreOccurrences(isWriteAccess?: boolean, ranges?: Range[]) { ranges = ranges || this.getRanges(); + assert(ranges.length); for (const r of ranges) { this.goToRangeStart(r); this.verifyOccurrencesAtPositionListCount(ranges.length); @@ -2761,6 +2764,7 @@ Actual: ${stringify(fullActual)}`); public verifyRangesAreDocumentHighlights(ranges: Range[] | undefined, options: FourSlashInterface.VerifyDocumentHighlightsOptions | undefined) { ranges = ranges || this.getRanges(); + assert(ranges.length); const fileNames = options && options.filesToSearch || unique(ranges, range => range.fileName); for (const range of ranges) { this.goToRangeStart(range); @@ -2930,7 +2934,9 @@ Actual: ${stringify(fullActual)}`); } public noMoveToNewFile() { - for (const range of this.getRanges()) { + const ranges = this.getRanges(); + assert(ranges.length); + for (const range of ranges) { for (const refactor of this.getApplicableRefactors(range, { allowTextChangesInNewFiles: true })) { if (refactor.name === "Move to a new file") { ts.Debug.fail("Did not expect to get 'move to a new file' refactor"); From 1cbace6eee8257309e5e8dc5a2389a20077a5c08 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 21 Jun 2019 13:26:29 -0700 Subject: [PATCH 21/26] Remove secondary reference lookup implementation (#32016) * Remove secondary reference lookup implementation * Remove TODO --- src/compiler/emitter.ts | 3 ++- src/compiler/program.ts | 5 +++-- src/compiler/transformers/declarations.ts | 2 +- src/compiler/types.ts | 3 ++- src/compiler/utilities.ts | 7 ------- src/services/goToDefinition.ts | 2 +- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index ddd273c3602..f22451157ac 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -725,7 +725,8 @@ namespace ts { fileExists: f => host.fileExists(f), directoryExists: host.directoryExists && (f => host.directoryExists!(f)), useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(), - getProgramBuildInfo: returnUndefined + getProgramBuildInfo: returnUndefined, + getSourceFileFromReference: returnUndefined, }; emitFiles( notImplementedResolver, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 2b62da72d24..f5ede694f8c 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1442,7 +1442,8 @@ namespace ts { }, ...(host.directoryExists ? { directoryExists: f => host.directoryExists!(f) } : {}), useCaseSensitiveFileNames: () => host.useCaseSensitiveFileNames(), - getProgramBuildInfo: () => program.getProgramBuildInfo && program.getProgramBuildInfo() + getProgramBuildInfo: () => program.getProgramBuildInfo && program.getProgramBuildInfo(), + getSourceFileFromReference: (file, ref) => program.getSourceFileFromReference(file, ref), }; } @@ -2127,7 +2128,7 @@ namespace ts { } /** This should have similar behavior to 'processSourceFile' without diagnostics or mutation. */ - function getSourceFileFromReference(referencingFile: SourceFile, ref: FileReference): SourceFile | undefined { + function getSourceFileFromReference(referencingFile: SourceFile | UnparsedSource, ref: FileReference): SourceFile | undefined { return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), fileName => filesByName.get(toPath(fileName)) || undefined); } diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 03f08b4de54..4f68c36d919 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -348,7 +348,7 @@ namespace ts { function collectReferences(sourceFile: SourceFile | UnparsedSource, ret: Map) { if (noResolve || (!isUnparsedSource(sourceFile) && isSourceFileJS(sourceFile))) return ret; forEach(sourceFile.referencedFiles, f => { - const elem = tryResolveScriptReference(host, sourceFile, f); + const elem = host.getSourceFileFromReference(sourceFile, f); if (elem) { ret.set("" + getOriginalNodeId(elem), elem); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index ec46da039d9..4442f339d83 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2975,7 +2975,7 @@ namespace ts { // For testing purposes only. /* @internal */ structureIsReused?: StructureIsReused; - /* @internal */ getSourceFileFromReference(referencingFile: SourceFile, ref: FileReference): SourceFile | undefined; + /* @internal */ getSourceFileFromReference(referencingFile: SourceFile | UnparsedSource, ref: FileReference): SourceFile | undefined; /* @internal */ getLibFileFromReference(ref: FileReference): SourceFile | undefined; /** Given a source file, get the name of the package it was imported from. */ @@ -5399,6 +5399,7 @@ namespace ts { writeFile: WriteFileCallback; getProgramBuildInfo(): ProgramBuildInfo | undefined; + getSourceFileFromReference: Program["getSourceFileFromReference"]; } export interface TransformationContext { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0e2488a0233..ae5b60cd864 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2611,13 +2611,6 @@ namespace ts { return undefined; } - export function tryResolveScriptReference(host: ScriptReferenceHost, sourceFile: SourceFile | UnparsedSource, reference: FileReference) { - if (!host.getCompilerOptions().noResolve) { - const referenceFileName = isRootedDiskPath(reference.fileName) ? reference.fileName : combinePaths(getDirectoryPath(sourceFile.fileName), reference.fileName); - return host.getSourceFile(referenceFileName); - } - } - export function getAncestor(node: Node | undefined, kind: SyntaxKind): Node | undefined { while (node) { if (node.kind === kind) { diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index fbd0be91022..1cb42a59e3c 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -108,7 +108,7 @@ namespace ts.GoToDefinition { export function getReferenceAtPosition(sourceFile: SourceFile, position: number, program: Program): { fileName: string, file: SourceFile } | undefined { const referencePath = findReferenceInPosition(sourceFile.referencedFiles, position); if (referencePath) { - const file = tryResolveScriptReference(program, sourceFile, referencePath); + const file = program.getSourceFileFromReference(sourceFile, referencePath); return file && { fileName: referencePath.fileName, file }; } From 5498f583f982b336725af200aa109abb7cc39992 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 21 Jun 2019 14:34:26 -0700 Subject: [PATCH 22/26] Update cherry-pick pr script to use mergebase (#32031) --- scripts/open-cherry-pick-pr.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/open-cherry-pick-pr.ts b/scripts/open-cherry-pick-pr.ts index 8bdeb05e4a2..5fc7f0ae299 100644 --- a/scripts/open-cherry-pick-pr.ts +++ b/scripts/open-cherry-pick-pr.ts @@ -36,9 +36,10 @@ async function main() { Component commits: ${logText.trim()}` const logpath = path.join(__dirname, "../", "logmessage.txt"); + const mergebase = runSequence([["git", ["merge-base", "origin/master", currentSha]]]).trim(); runSequence([ ["git", ["checkout", "-b", "temp-branch"]], - ["git", ["reset", "origin/master", "--soft"]] + ["git", ["reset", mergebase, "--soft"]] ]); fs.writeFileSync(logpath, logText); runSequence([ From 9d23ce3d0677167672ade174a846cc7373c93643 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 21 Jun 2019 14:49:43 -0700 Subject: [PATCH 23/26] Sanitize rush progress numbers in docker test output (#32029) --- src/testRunner/externalCompileRunner.ts | 6 +- .../baselines/reference/docker/azure-sdk.log | 36 ++++---- .../reference/docker/office-ui-fabric.log | 82 +++++++++---------- 3 files changed, 64 insertions(+), 60 deletions(-) diff --git a/src/testRunner/externalCompileRunner.ts b/src/testRunner/externalCompileRunner.ts index e40f8115e59..4e1575ca47d 100644 --- a/src/testRunner/externalCompileRunner.ts +++ b/src/testRunner/externalCompileRunner.ts @@ -157,7 +157,7 @@ ${sanitizeDockerfileOutput(result.stderr.toString())}`; } function sanitizeDockerfileOutput(result: string): string { - return stripAbsoluteImportPaths(sanitizeTimestamps(stripANSIEscapes(normalizeNewlines(result)))); + return stripAbsoluteImportPaths(sanitizeTimestamps(stripRushStageNumbers(stripANSIEscapes(normalizeNewlines(result))))); } function normalizeNewlines(result: string): string { @@ -168,6 +168,10 @@ function stripANSIEscapes(result: string): string { return result.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, ""); } +function stripRushStageNumbers(result: string): string { + return result.replace(/\d+ of \d+:/g, "XX of XX:"); +} + function sanitizeTimestamps(result: string): string { return result.replace(/\[\d?\d:\d\d:\d\d (A|P)M\]/g, "[XX:XX:XX XM]") .replace(/\d+(\.\d+)? seconds?/g, "? seconds") diff --git a/tests/baselines/reference/docker/azure-sdk.log b/tests/baselines/reference/docker/azure-sdk.log index 3d2374b1547..e89b970b006 100644 --- a/tests/baselines/reference/docker/azure-sdk.log +++ b/tests/baselines/reference/docker/azure-sdk.log @@ -10,40 +10,40 @@ Starting "rush rebuild" Executing a maximum of 1 simultaneous processes... [@azure/abort-controller] started -1 of 18: [@azure/abort-controller] completed successfully in ? seconds +XX of XX: [@azure/abort-controller] completed successfully in ? seconds [@azure/cosmos] started -2 of 18: [@azure/cosmos] completed successfully in ? seconds +XX of XX: [@azure/cosmos] completed successfully in ? seconds [@azure/event-hubs] started -3 of 18: [@azure/event-hubs] completed successfully in ? seconds +XX of XX: [@azure/event-hubs] completed successfully in ? seconds [@azure/service-bus] started Warning: You have changed the public API signature for this project. Updating review/service-bus.api.md [@azure/storage-blob] started -5 of 18: [@azure/storage-blob] completed successfully in ? seconds +XX of XX: [@azure/storage-blob] completed successfully in ? seconds [@azure/storage-datalake] started -6 of 18: [@azure/storage-datalake] completed successfully in ? seconds +XX of XX: [@azure/storage-datalake] completed successfully in ? seconds [@azure/storage-file] started -7 of 18: [@azure/storage-file] completed successfully in ? seconds +XX of XX: [@azure/storage-file] completed successfully in ? seconds [@azure/storage-queue] started -8 of 18: [@azure/storage-queue] completed successfully in ? seconds +XX of XX: [@azure/storage-queue] completed successfully in ? seconds [@azure/template] started -9 of 18: [@azure/template] completed successfully in ? seconds +XX of XX: [@azure/template] completed successfully in ? seconds [@azure/core-http] started -10 of 18: [@azure/core-http] completed successfully in ? seconds +XX of XX: [@azure/core-http] completed successfully in ? seconds [@azure/core-paging] started -11 of 18: [@azure/core-paging] completed successfully in ? seconds +XX of XX: [@azure/core-paging] completed successfully in ? seconds [@azure/event-processor-host] started -12 of 18: [@azure/event-processor-host] completed successfully in ? seconds +XX of XX: [@azure/event-processor-host] completed successfully in ? seconds [testhub] started -13 of 18: [testhub] completed successfully in ? seconds +XX of XX: [testhub] completed successfully in ? seconds [@azure/identity] started -14 of 18: [@azure/identity] completed successfully in ? seconds +XX of XX: [@azure/identity] completed successfully in ? seconds [@azure/core-amqp] started [@azure/keyvault-certificates] started -15 of 18: [@azure/keyvault-certificates] completed successfully in ? seconds +XX of XX: [@azure/keyvault-certificates] completed successfully in ? seconds [@azure/keyvault-keys] started -16 of 18: [@azure/keyvault-keys] completed successfully in ? seconds +XX of XX: [@azure/keyvault-keys] completed successfully in ? seconds [@azure/keyvault-secrets] started -17 of 18: [@azure/keyvault-secrets] completed successfully in ? seconds +XX of XX: [@azure/keyvault-secrets] completed successfully in ? seconds SUCCESS (16) ================================ @@ -89,7 +89,7 @@ rush rebuild - Errors! ( ? seconds) Standard error: Your version of Node.js (12.4.0) has not been tested with this release of Rush. The Rush team will not accept issue reports for it. Please consider upgrading Rush or downgrading Node.js. -4 of 18: [@azure/service-bus] completed with warnings in ? seconds +XX of XX: [@azure/service-bus] completed with warnings in ? seconds -14 of 18: [@azure/core-amqp] failed to build! +XX of XX: [@azure/core-amqp] failed to build! [@azure/core-amqp] Returned error code: 2 diff --git a/tests/baselines/reference/docker/office-ui-fabric.log b/tests/baselines/reference/docker/office-ui-fabric.log index 7107d8f3bcf..536a28f1142 100644 --- a/tests/baselines/reference/docker/office-ui-fabric.log +++ b/tests/baselines/reference/docker/office-ui-fabric.log @@ -10,15 +10,15 @@ Starting "rush rebuild" Executing a maximum of 1 simultaneous processes... [@uifabric/prettier-rules] started -1 of 41: [@uifabric/prettier-rules] completed successfully in ? seconds +XX of XX: [@uifabric/prettier-rules] completed successfully in ? seconds [@uifabric/tslint-rules] started -2 of 41: [@uifabric/tslint-rules] completed successfully in ? seconds +XX of XX: [@uifabric/tslint-rules] completed successfully in ? seconds [@uifabric/codepen-loader] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/build] started -4 of 41: [@uifabric/build] completed successfully in ? seconds +XX of XX: [@uifabric/build] completed successfully in ? seconds [@uifabric/migration] started -5 of 41: [@uifabric/migration] completed successfully in ? seconds +XX of XX: [@uifabric/migration] completed successfully in ? seconds [@uifabric/set-version] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/merge-styles] started @@ -26,13 +26,13 @@ ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed [@uifabric/jest-serializer-merge-styles] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/test-utilities] started -9 of 41: [@uifabric/test-utilities] completed successfully in ? seconds +XX of XX: [@uifabric/test-utilities] completed successfully in ? seconds [@uifabric/utilities] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/styling] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. [@uifabric/file-type-icons] started -12 of 41: [@uifabric/file-type-icons] completed successfully in ? seconds +XX of XX: [@uifabric/file-type-icons] completed successfully in ? seconds [@uifabric/foundation] started ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=2.7.0 <4.0.0). Please do not report issues in ts-jest if you are using unsupported versions. ● createFactory › passes componentProps without userProps @@ -270,9 +270,9 @@ ts-jest[versions] (WARN) Version X.X.X-insiders.xxxxxxxx of typescript installed [XX:XX:XX XM] x finished 'build' in ?s with errors [XX:XX:XX XM] x Error previously detected. See above for error messages. [@uifabric/icons] started -39 of 41: [@uifabric/icons] completed successfully in ? seconds +XX of XX: [@uifabric/icons] completed successfully in ? seconds [@uifabric/webpack-utils] started -40 of 41: [@uifabric/webpack-utils] completed successfully in ? seconds +XX of XX: [@uifabric/webpack-utils] completed successfully in ? seconds SUCCESS (8) ================================ @@ -381,38 +381,38 @@ rush rebuild - Errors! ( ? seconds) Standard error: Your version of Node.js (12.4.0) has not been tested with this release of Rush. The Rush team will not accept issue reports for it. Please consider upgrading Rush or downgrading Node.js. -3 of 41: [@uifabric/codepen-loader] completed with warnings in ? seconds -6 of 41: [@uifabric/set-version] completed with warnings in ? seconds -7 of 41: [@uifabric/merge-styles] completed with warnings in ? seconds -8 of 41: [@uifabric/jest-serializer-merge-styles] completed with warnings in ? seconds -10 of 41: [@uifabric/utilities] completed with warnings in ? seconds -11 of 41: [@uifabric/styling] completed with warnings in ? seconds +XX of XX: [@uifabric/codepen-loader] completed with warnings in ? seconds +XX of XX: [@uifabric/set-version] completed with warnings in ? seconds +XX of XX: [@uifabric/merge-styles] completed with warnings in ? seconds +XX of XX: [@uifabric/jest-serializer-merge-styles] completed with warnings in ? seconds +XX of XX: [@uifabric/utilities] completed with warnings in ? seconds +XX of XX: [@uifabric/styling] completed with warnings in ? seconds -12 of 41: [@uifabric/foundation] failed to build! -13 of 41: [@uifabric/experiments] blocked by [@uifabric/foundation]! -14 of 41: [@uifabric/fabric-website] blocked by [@uifabric/foundation]! -15 of 41: [@uifabric/pr-deploy-site] blocked by [@uifabric/foundation]! -16 of 41: [@uifabric/react-cards] blocked by [@uifabric/foundation]! -17 of 41: [theming-designer] blocked by [@uifabric/foundation]! -18 of 41: [vr-tests] blocked by [@uifabric/foundation]! -19 of 41: [dom-tests] blocked by [@uifabric/foundation]! -20 of 41: [perf-test] blocked by [@uifabric/foundation]! -21 of 41: [test-bundles] blocked by [@uifabric/foundation]! -22 of 41: [office-ui-fabric-react] blocked by [@uifabric/foundation]! -23 of 41: [@uifabric/api-docs] blocked by [@uifabric/foundation]! -24 of 41: [@uifabric/fabric-website-resources] blocked by [@uifabric/foundation]! -25 of 41: [a11y-tests] blocked by [@uifabric/foundation]! -26 of 41: [ssr-tests] blocked by [@uifabric/foundation]! -27 of 41: [@uifabric/azure-themes] blocked by [@uifabric/foundation]! -28 of 41: [@uifabric/charting] blocked by [@uifabric/foundation]! -29 of 41: [@uifabric/date-time] blocked by [@uifabric/foundation]! -30 of 41: [@uifabric/example-app-base] blocked by [@uifabric/foundation]! -31 of 41: [@uifabric/foundation-scenarios] blocked by [@uifabric/foundation]! -32 of 41: [@uifabric/lists] blocked by [@uifabric/foundation]! -33 of 41: [@uifabric/fluent-theme] blocked by [@uifabric/foundation]! -34 of 41: [@uifabric/tsx-editor] blocked by [@uifabric/foundation]! -35 of 41: [@uifabric/theme-samples] blocked by [@uifabric/foundation]! -36 of 41: [@uifabric/variants] blocked by [@uifabric/foundation]! -37 of 41: [server-rendered-app] blocked by [@uifabric/foundation]! -38 of 41: [todo-app] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/foundation] failed to build! +XX of XX: [@uifabric/experiments] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/fabric-website] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/pr-deploy-site] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/react-cards] blocked by [@uifabric/foundation]! +XX of XX: [theming-designer] blocked by [@uifabric/foundation]! +XX of XX: [vr-tests] blocked by [@uifabric/foundation]! +XX of XX: [dom-tests] blocked by [@uifabric/foundation]! +XX of XX: [perf-test] blocked by [@uifabric/foundation]! +XX of XX: [test-bundles] blocked by [@uifabric/foundation]! +XX of XX: [office-ui-fabric-react] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/api-docs] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/fabric-website-resources] blocked by [@uifabric/foundation]! +XX of XX: [a11y-tests] blocked by [@uifabric/foundation]! +XX of XX: [ssr-tests] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/azure-themes] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/charting] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/date-time] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/example-app-base] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/foundation-scenarios] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/lists] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/fluent-theme] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/tsx-editor] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/theme-samples] blocked by [@uifabric/foundation]! +XX of XX: [@uifabric/variants] blocked by [@uifabric/foundation]! +XX of XX: [server-rendered-app] blocked by [@uifabric/foundation]! +XX of XX: [todo-app] blocked by [@uifabric/foundation]! [@uifabric/foundation] Returned error code: 1 From 7cdc65b2a5ecb455b23800ecd93a65f4f2025be0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 21 Jun 2019 18:00:26 -1000 Subject: [PATCH 24/26] Out of bounds tuple elements have type 'undefined' --- 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 e071cc9f96c..9cb08b3e440 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14440,7 +14440,7 @@ namespace ts { if (propType) { return propType; } - if (everyType(type, isTupleType) && !everyType(type, t => !(t).target.hasRestElement)) { + if (everyType(type, isTupleType)) { return mapType(type, t => getRestTypeOfTupleType(t) || undefinedType); } return undefined; From 9223f39f5326a114b11403c1c6487a78ad66bb67 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 21 Jun 2019 18:07:15 -1000 Subject: [PATCH 25/26] Add regression test --- .../es6/destructuring/destructuringControlFlow.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts b/tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts index 033f2bdb75e..ea92b09081c 100644 --- a/tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts +++ b/tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts @@ -34,3 +34,9 @@ function f4() { ({ ["x"]: x } = 0); // Error ({ ["x" + ""]: x } = 0); // Errpr } + +// Repro from #31770 + +type KeyValue = [string, string?]; +let [key, value]: KeyValue = ["foo"]; +value.toUpperCase(); // Error From 3ca2e7dbb88448f36a66df67b5b713305a2c44a6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 21 Jun 2019 18:07:22 -1000 Subject: [PATCH 26/26] Accept new baselines --- .../destructuringControlFlow.errors.txt | 11 ++++++++++- .../reference/destructuringControlFlow.js | 8 ++++++++ .../reference/destructuringControlFlow.symbols | 13 +++++++++++++ .../reference/destructuringControlFlow.types | 17 +++++++++++++++++ 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/tests/baselines/reference/destructuringControlFlow.errors.txt b/tests/baselines/reference/destructuringControlFlow.errors.txt index 2bc85fdd638..e83a76942f0 100644 --- a/tests/baselines/reference/destructuringControlFlow.errors.txt +++ b/tests/baselines/reference/destructuringControlFlow.errors.txt @@ -1,9 +1,10 @@ tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(31,8): error TS2339: Property 'x' does not exist on type 'Number'. tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(32,9): error TS2339: Property 'x' does not exist on type 'Number'. tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(33,9): error TS2537: Type 'Number' has no matching index signature for type 'string'. +tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(40,1): error TS2532: Object is possibly 'undefined'. -==== tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts (3 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts (4 errors) ==== function f1(obj: { a?: string }) { if (obj.a) { obj = {}; @@ -44,4 +45,12 @@ tests/cases/conformance/es6/destructuring/destructuringControlFlow.ts(33,9): err ~~~~~~~~ !!! error TS2537: Type 'Number' has no matching index signature for type 'string'. } + + // Repro from #31770 + + type KeyValue = [string, string?]; + let [key, value]: KeyValue = ["foo"]; + value.toUpperCase(); // Error + ~~~~~ +!!! error TS2532: Object is possibly 'undefined'. \ No newline at end of file diff --git a/tests/baselines/reference/destructuringControlFlow.js b/tests/baselines/reference/destructuringControlFlow.js index 2d02fb5a40f..f3b5a8e0dd9 100644 --- a/tests/baselines/reference/destructuringControlFlow.js +++ b/tests/baselines/reference/destructuringControlFlow.js @@ -33,6 +33,12 @@ function f4() { ({ ["x"]: x } = 0); // Error ({ ["x" + ""]: x } = 0); // Errpr } + +// Repro from #31770 + +type KeyValue = [string, string?]; +let [key, value]: KeyValue = ["foo"]; +value.toUpperCase(); // Error //// [destructuringControlFlow.js] @@ -69,3 +75,5 @@ function f4() { (x = 0["x"]); // Error (_a = "x" + "", x = 0[_a]); // Errpr } +var _a = ["foo"], key = _a[0], value = _a[1]; +value.toUpperCase(); // Error diff --git a/tests/baselines/reference/destructuringControlFlow.symbols b/tests/baselines/reference/destructuringControlFlow.symbols index 75cbfcdb481..5e3fa6a365a 100644 --- a/tests/baselines/reference/destructuringControlFlow.symbols +++ b/tests/baselines/reference/destructuringControlFlow.symbols @@ -122,3 +122,16 @@ function f4() { >x : Symbol(x, Decl(destructuringControlFlow.ts, 29, 7)) } +// Repro from #31770 + +type KeyValue = [string, string?]; +>KeyValue : Symbol(KeyValue, Decl(destructuringControlFlow.ts, 33, 1)) + +let [key, value]: KeyValue = ["foo"]; +>key : Symbol(key, Decl(destructuringControlFlow.ts, 38, 5)) +>value : Symbol(value, Decl(destructuringControlFlow.ts, 38, 9)) +>KeyValue : Symbol(KeyValue, Decl(destructuringControlFlow.ts, 33, 1)) + +value.toUpperCase(); // Error +>value : Symbol(value, Decl(destructuringControlFlow.ts, 38, 9)) + diff --git a/tests/baselines/reference/destructuringControlFlow.types b/tests/baselines/reference/destructuringControlFlow.types index b831d116740..347aae32c10 100644 --- a/tests/baselines/reference/destructuringControlFlow.types +++ b/tests/baselines/reference/destructuringControlFlow.types @@ -158,3 +158,20 @@ function f4() { >0 : 0 } +// Repro from #31770 + +type KeyValue = [string, string?]; +>KeyValue : [string, (string | undefined)?] + +let [key, value]: KeyValue = ["foo"]; +>key : string +>value : string | undefined +>["foo"] : [string] +>"foo" : "foo" + +value.toUpperCase(); // Error +>value.toUpperCase() : any +>value.toUpperCase : any +>value : undefined +>toUpperCase : any +