From f6454326ddb7760bf69574d77b495ba801fb1611 Mon Sep 17 00:00:00 2001 From: erictsangx Date: Tue, 8 Dec 2015 17:47:40 +0800 Subject: [PATCH 001/508] Fix issue: Confusing error message when calling value whose type is a union of types with call signatures add diagnostic message 2658: Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures. Closes #5640 --- src/compiler/diagnosticMessages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 331568eae22..f0d0dae20fa 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1007,7 +1007,7 @@ "category": "Error", "code": 2348 }, - "Cannot invoke an expression whose type lacks a call signature.": { + "Cannot invoke an expression whose type lacks a call signature. Type '{0}' has no compatible call signatures.": { "category": "Error", "code": 2349 }, From bc2b1050371c9aa0998b5d1e69cc6ff3ddbabea3 Mon Sep 17 00:00:00 2001 From: erictsangx Date: Thu, 26 Nov 2015 18:33:56 +0800 Subject: [PATCH 002/508] add tests for the issue --- .../types/union/unionTypeCallSignatures.ts | 14 +++++++------- .../types/union/unionTypeCallSignatures5.ts | 12 ++++++++++++ .../conformance/types/union/unionTypeMembers.ts | 3 +-- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 tests/cases/conformance/types/union/unionTypeCallSignatures5.ts diff --git a/tests/cases/conformance/types/union/unionTypeCallSignatures.ts b/tests/cases/conformance/types/union/unionTypeCallSignatures.ts index a25d27d9a29..c15fa69ea91 100644 --- a/tests/cases/conformance/types/union/unionTypeCallSignatures.ts +++ b/tests/cases/conformance/types/union/unionTypeCallSignatures.ts @@ -16,9 +16,9 @@ unionOfDifferentReturnType1(true); // error in type of parameter unionOfDifferentReturnType1(); // error missing parameter var unionOfDifferentParameterTypes: { (a: number): number; } | { (a: string): Date; }; -unionOfDifferentParameterTypes(10);// error - no call signatures -unionOfDifferentParameterTypes("hello");// error - no call signatures -unionOfDifferentParameterTypes();// error - no call signatures +unionOfDifferentParameterTypes(10); //no error +unionOfDifferentParameterTypes("hello"); //no error +unionOfDifferentParameterTypes(); //error TS2346 var unionOfDifferentNumberOfSignatures: { (a: number): number; } | { (a: number): Date; (a: string): boolean; }; unionOfDifferentNumberOfSignatures(); // error - no call signatures @@ -26,9 +26,9 @@ unionOfDifferentNumberOfSignatures(10); // error - no call signatures unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; -unionWithDifferentParameterCount();// no call signature -unionWithDifferentParameterCount("hello");// no call signature -unionWithDifferentParameterCount("hello", 10);// no call signature +unionWithDifferentParameterCount(); //error TS2346 +unionWithDifferentParameterCount("hello"); //no error +unionWithDifferentParameterCount("hello", 10); //no error var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; strOrNum = unionWithOptionalParameter1('hello'); @@ -71,4 +71,4 @@ strOrNum = unionWithRestParameter3(); // error no call signature var unionWithRestParameter4: { (...a: string[]): string; } | { (a: string, b: string): number; }; strOrNum = unionWithRestParameter4("hello"); // error supplied parameters do not match any call signature -strOrNum = unionWithRestParameter4("hello", "world"); +strOrNum = unionWithRestParameter4("hello", "world"); \ No newline at end of file diff --git a/tests/cases/conformance/types/union/unionTypeCallSignatures5.ts b/tests/cases/conformance/types/union/unionTypeCallSignatures5.ts new file mode 100644 index 00000000000..75626151807 --- /dev/null +++ b/tests/cases/conformance/types/union/unionTypeCallSignatures5.ts @@ -0,0 +1,12 @@ +interface A { + (number) : number; +} + +var f1: string | number; +f1(); //error TS2658 + +var f2: string | A; +f2(); //error TS2658 + +var f3: string[] | number[]; +f3.map(value=>value); //should not throw TS2349 \ No newline at end of file diff --git a/tests/cases/conformance/types/union/unionTypeMembers.ts b/tests/cases/conformance/types/union/unionTypeMembers.ts index 73c6867e9ac..00dc7562ccf 100644 --- a/tests/cases/conformance/types/union/unionTypeMembers.ts +++ b/tests/cases/conformance/types/union/unionTypeMembers.ts @@ -41,8 +41,7 @@ str = x.commonMethodType(str); // (a: string) => string so result should be stri strOrNum = x.commonPropertyDifferenType; strOrNum = x.commonMethodDifferentReturnType(str); // string | union x.commonMethodDifferentParameterType; // No error - property exists -x.commonMethodDifferentParameterType(strOrNum); // error - no call signatures because the type of this property is ((a: string) => string) | (a: number) => number - // and the call signatures arent identical +x.commonMethodDifferentParameterType(strOrNum); //error - TS2345 num = x.commonMethodWithTypeParameter(num); num = x.commonMethodWithOwnTypeParameter(num); str = x.commonMethodWithOwnTypeParameter(str); From 67573be64196f344611da4ce5ed716b029a95e3c Mon Sep 17 00:00:00 2001 From: erictsangx Date: Tue, 8 Dec 2015 17:48:58 +0800 Subject: [PATCH 003/508] improvements based on comments --- .gitignore | 1 + src/compiler/checker.ts | 11 ++++++++--- .../types/union/unionTypeCallSignatures.ts | 14 +++++++------- .../types/union/unionTypeCallSignatures5.ts | 12 ------------ .../conformance/types/union/unionTypeMembers.ts | 3 ++- 5 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 tests/cases/conformance/types/union/unionTypeCallSignatures5.ts diff --git a/.gitignore b/.gitignore index 05f981a0ace..b911f4ca106 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ internal/ .settings .vscode/* !.vscode/tasks.json +.idea \ No newline at end of file diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 30d4818592b..03d79b8376e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3854,6 +3854,11 @@ namespace ts { return false; } + function typeHasCallSignatures(type: Type): boolean { + const callSignature = getSignaturesOfType(type, SignatureKind.Call); + return !!callSignature.length; + } + function typeHasCallOrConstructSignatures(type: Type): boolean { const apparentType = getApparentType(type); if (apparentType.flags & TypeFlags.StructuredType) { @@ -9496,7 +9501,7 @@ namespace ts { error(node, Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType)); } else { - error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); } return resolveErrorCall(node); } @@ -9586,7 +9591,7 @@ namespace ts { } if (!callSignatures.length) { - error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + error(node, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); return resolveErrorCall(node); } @@ -9633,7 +9638,7 @@ namespace ts { const headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); if (!callSignatures.length) { let errorInfo: DiagnosticMessageChain; - errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature); + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Cannot_invoke_an_expression_whose_type_lacks_a_call_signature_Type_0_has_no_compatible_call_signatures, typeToString(apparentType)); errorInfo = chainDiagnosticMessages(errorInfo, headMessage); diagnostics.add(createDiagnosticForNodeFromMessageChain(node, errorInfo)); return resolveErrorCall(node); diff --git a/tests/cases/conformance/types/union/unionTypeCallSignatures.ts b/tests/cases/conformance/types/union/unionTypeCallSignatures.ts index c15fa69ea91..a25d27d9a29 100644 --- a/tests/cases/conformance/types/union/unionTypeCallSignatures.ts +++ b/tests/cases/conformance/types/union/unionTypeCallSignatures.ts @@ -16,9 +16,9 @@ unionOfDifferentReturnType1(true); // error in type of parameter unionOfDifferentReturnType1(); // error missing parameter var unionOfDifferentParameterTypes: { (a: number): number; } | { (a: string): Date; }; -unionOfDifferentParameterTypes(10); //no error -unionOfDifferentParameterTypes("hello"); //no error -unionOfDifferentParameterTypes(); //error TS2346 +unionOfDifferentParameterTypes(10);// error - no call signatures +unionOfDifferentParameterTypes("hello");// error - no call signatures +unionOfDifferentParameterTypes();// error - no call signatures var unionOfDifferentNumberOfSignatures: { (a: number): number; } | { (a: number): Date; (a: string): boolean; }; unionOfDifferentNumberOfSignatures(); // error - no call signatures @@ -26,9 +26,9 @@ unionOfDifferentNumberOfSignatures(10); // error - no call signatures unionOfDifferentNumberOfSignatures("hello"); // error - no call signatures var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; -unionWithDifferentParameterCount(); //error TS2346 -unionWithDifferentParameterCount("hello"); //no error -unionWithDifferentParameterCount("hello", 10); //no error +unionWithDifferentParameterCount();// no call signature +unionWithDifferentParameterCount("hello");// no call signature +unionWithDifferentParameterCount("hello", 10);// no call signature var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; strOrNum = unionWithOptionalParameter1('hello'); @@ -71,4 +71,4 @@ strOrNum = unionWithRestParameter3(); // error no call signature var unionWithRestParameter4: { (...a: string[]): string; } | { (a: string, b: string): number; }; strOrNum = unionWithRestParameter4("hello"); // error supplied parameters do not match any call signature -strOrNum = unionWithRestParameter4("hello", "world"); \ No newline at end of file +strOrNum = unionWithRestParameter4("hello", "world"); diff --git a/tests/cases/conformance/types/union/unionTypeCallSignatures5.ts b/tests/cases/conformance/types/union/unionTypeCallSignatures5.ts deleted file mode 100644 index 75626151807..00000000000 --- a/tests/cases/conformance/types/union/unionTypeCallSignatures5.ts +++ /dev/null @@ -1,12 +0,0 @@ -interface A { - (number) : number; -} - -var f1: string | number; -f1(); //error TS2658 - -var f2: string | A; -f2(); //error TS2658 - -var f3: string[] | number[]; -f3.map(value=>value); //should not throw TS2349 \ No newline at end of file diff --git a/tests/cases/conformance/types/union/unionTypeMembers.ts b/tests/cases/conformance/types/union/unionTypeMembers.ts index 00dc7562ccf..73c6867e9ac 100644 --- a/tests/cases/conformance/types/union/unionTypeMembers.ts +++ b/tests/cases/conformance/types/union/unionTypeMembers.ts @@ -41,7 +41,8 @@ str = x.commonMethodType(str); // (a: string) => string so result should be stri strOrNum = x.commonPropertyDifferenType; strOrNum = x.commonMethodDifferentReturnType(str); // string | union x.commonMethodDifferentParameterType; // No error - property exists -x.commonMethodDifferentParameterType(strOrNum); //error - TS2345 +x.commonMethodDifferentParameterType(strOrNum); // error - no call signatures because the type of this property is ((a: string) => string) | (a: number) => number + // and the call signatures arent identical num = x.commonMethodWithTypeParameter(num); num = x.commonMethodWithOwnTypeParameter(num); str = x.commonMethodWithOwnTypeParameter(str); From 557433e5b4600fb3b4e4d598b04ba593f9861d67 Mon Sep 17 00:00:00 2001 From: erictsangx Date: Tue, 8 Dec 2015 18:16:00 +0800 Subject: [PATCH 004/508] baseline accept --- .../reference/callOnInstance.errors.txt | 4 ++-- ...putedPropertiesInDestructuring1.errors.txt | 8 +++---- ...dPropertiesInDestructuring1_ES6.errors.txt | 8 +++---- .../constructorOverloads4.errors.txt | 4 ++-- ...ctionExpressionShadowedByParams.errors.txt | 4 ++-- ...ropertiesInheritedIntoClassType.errors.txt | 8 +++---- .../instancePropertyInClassType.errors.txt | 8 +++---- .../strictModeReservedWord.errors.txt | 4 ++-- ...rCallParameterContextualTyping2.errors.txt | 4 ++-- .../templateStringInCallExpression.errors.txt | 4 ++-- ...mplateStringInCallExpressionES6.errors.txt | 4 ++-- .../templateStringInObjectLiteral.errors.txt | 4 ++-- ...emplateStringInObjectLiteralES6.errors.txt | 4 ++-- .../templateStringInPropertyName1.errors.txt | 4 ++-- .../templateStringInPropertyName2.errors.txt | 4 ++-- ...mplateStringInPropertyNameES6_1.errors.txt | 4 ++-- ...mplateStringInPropertyNameES6_2.errors.txt | 4 ++-- .../templateStringInTaggedTemplate.errors.txt | 4 ++-- ...mplateStringInTaggedTemplateES6.errors.txt | 4 ++-- .../unionTypeCallSignatures.errors.txt | 24 +++++++++---------- .../reference/unionTypeMembers.errors.txt | 4 ++-- ...unctionCallsWithTypeParameters1.errors.txt | 4 ++-- 22 files changed, 62 insertions(+), 62 deletions(-) diff --git a/tests/baselines/reference/callOnInstance.errors.txt b/tests/baselines/reference/callOnInstance.errors.txt index 156bdfd512a..4f80088ab75 100644 --- a/tests/baselines/reference/callOnInstance.errors.txt +++ b/tests/baselines/reference/callOnInstance.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/callOnInstance.ts(1,18): error TS2300: Duplicate identifier tests/cases/compiler/callOnInstance.ts(3,15): error TS2300: Duplicate identifier 'D'. tests/cases/compiler/callOnInstance.ts(7,19): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/callOnInstance.ts(7,19): error TS2350: Only a void function can be called with the 'new' keyword. -tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'C' has no compatible call signatures. ==== tests/cases/compiler/callOnInstance.ts (5 errors) ==== @@ -25,4 +25,4 @@ tests/cases/compiler/callOnInstance.ts(10,1): error TS2349: Cannot invoke an exp declare class C { constructor(value: number); } (new C(1))(); // Error for calling an instance ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'C' has no compatible call signatures. \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt b/tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt index dc536e544b2..ca1c0f4c0b9 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt +++ b/tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/computedPropertiesInDestructuring1.ts(20,8): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/computedPropertiesInDestructuring1.ts(20,8): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. tests/cases/compiler/computedPropertiesInDestructuring1.ts(21,12): error TS2339: Property 'toExponential' does not exist on type 'string'. -tests/cases/compiler/computedPropertiesInDestructuring1.ts(33,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/computedPropertiesInDestructuring1.ts(33,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365: Operator '+' cannot be applied to types 'number' and '{}'. @@ -26,7 +26,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365: // report errors on type errors in computed properties used in destructuring let [{[foo()]: bar6}] = [{bar: "bar"}]; ~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; ~~~~~~~~~~~~~ !!! error TS2339: Property 'toExponential' does not exist on type 'string'. @@ -43,7 +43,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365: [{[foo()]: bar4}] = [{bar: "bar"}]; ~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. [{[(1 + {})]: bar4}] = [{bar: "bar"}]; ~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'number' and '{}'. diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt index 96ab892d1b9..9a332d6aee8 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(21,8): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(21,8): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(22,12): error TS2339: Property 'toExponential' does not exist on type 'string'. -tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(34,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(34,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS2365: Operator '+' cannot be applied to types 'number' and '{}'. @@ -27,7 +27,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS23 // report errors on type errors in computed properties used in destructuring let [{[foo()]: bar6}] = [{bar: "bar"}]; ~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. let [{[foo.toExponential()]: bar7}] = [{bar: "bar"}]; ~~~~~~~~~~~~~ !!! error TS2339: Property 'toExponential' does not exist on type 'string'. @@ -44,7 +44,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS23 [{[foo()]: bar4}] = [{bar: "bar"}]; ~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. [{[(1 + {})]: bar4}] = [{bar: "bar"}]; ~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'number' and '{}'. diff --git a/tests/baselines/reference/constructorOverloads4.errors.txt b/tests/baselines/reference/constructorOverloads4.errors.txt index d2cc5ecd65b..3e6923d25dc 100644 --- a/tests/baselines/reference/constructorOverloads4.errors.txt +++ b/tests/baselines/reference/constructorOverloads4.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/constructorOverloads4.ts(2,18): error TS2300: Duplicate identifier 'Function'. tests/cases/compiler/constructorOverloads4.ts(5,21): error TS2300: Duplicate identifier 'Function'. tests/cases/compiler/constructorOverloads4.ts(6,21): error TS2300: Duplicate identifier 'Function'. -tests/cases/compiler/constructorOverloads4.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/constructorOverloads4.ts(10,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Function' has no compatible call signatures. tests/cases/compiler/constructorOverloads4.ts(11,1): error TS2348: Value of type 'typeof Function' is not callable. Did you mean to include 'new'? @@ -23,7 +23,7 @@ tests/cases/compiler/constructorOverloads4.ts(11,1): error TS2348: Value of type (new M.Function("return 5"))(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Function' has no compatible call signatures. M.Function("yo"); ~~~~~~~~~~~~~~~~ !!! error TS2348: Value of type 'typeof Function' is not callable. Did you mean to include 'new'? diff --git a/tests/baselines/reference/functionExpressionShadowedByParams.errors.txt b/tests/baselines/reference/functionExpressionShadowedByParams.errors.txt index 74b4c171a57..f0d821d89c1 100644 --- a/tests/baselines/reference/functionExpressionShadowedByParams.errors.txt +++ b/tests/baselines/reference/functionExpressionShadowedByParams.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/functionExpressionShadowedByParams.ts(3,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/functionExpressionShadowedByParams.ts(3,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures. tests/cases/compiler/functionExpressionShadowedByParams.ts(10,9): error TS2339: Property 'apply' does not exist on type 'number'. @@ -7,7 +7,7 @@ tests/cases/compiler/functionExpressionShadowedByParams.ts(10,9): error TS2339: b1.toPrecision(2); // should not error b1(12); // should error ~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures. } diff --git a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt index 340b5081866..21aaa938093 100644 --- a/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt +++ b/tests/baselines/reference/instancePropertiesInheritedIntoClassType.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(19,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(26,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(29,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts(41,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. ==== tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIntoClassType.ts (6 errors) ==== @@ -31,7 +31,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn r.y = 4; var r6 = d.y(); // error ~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures. } @@ -59,5 +59,5 @@ tests/cases/conformance/classes/members/classTypes/instancePropertiesInheritedIn r.y = ''; var r6 = d.y(); // error ~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. } \ No newline at end of file diff --git a/tests/baselines/reference/instancePropertyInClassType.errors.txt b/tests/baselines/reference/instancePropertyInClassType.errors.txt index d14607d81bc..bb0047880cb 100644 --- a/tests/baselines/reference/instancePropertyInClassType.errors.txt +++ b/tests/baselines/reference/instancePropertyInClassType.errors.txt @@ -1,9 +1,9 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(4,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(7,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(17,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(24,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(27,13): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts(37,14): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. ==== tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.ts (6 errors) ==== @@ -29,7 +29,7 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t r.y = 4; var r6 = c.y(); // error ~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures. } @@ -55,5 +55,5 @@ tests/cases/conformance/classes/members/classTypes/instancePropertyInClassType.t r.y = ''; var r6 = c.y(); // error ~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. } \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWord.errors.txt b/tests/baselines/reference/strictModeReservedWord.errors.txt index 02ece81a1d9..7a1bacbb525 100644 --- a/tests/baselines/reference/strictModeReservedWord.errors.txt +++ b/tests/baselines/reference/strictModeReservedWord.errors.txt @@ -40,7 +40,7 @@ tests/cases/compiler/strictModeReservedWord.ts(22,22): error TS1212: Identifier tests/cases/compiler/strictModeReservedWord.ts(22,30): error TS1212: Identifier expected. 'implements' is a reserved word in strict mode tests/cases/compiler/strictModeReservedWord.ts(23,5): error TS2304: Cannot find name 'ublic'. tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS1212: Identifier expected. 'static' is a reserved word in strict mode -tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. ==== tests/cases/compiler/strictModeReservedWord.ts (43 errors) ==== @@ -153,7 +153,7 @@ tests/cases/compiler/strictModeReservedWord.ts(24,5): error TS2349: Cannot invok ~~~~~~ !!! error TS1212: Identifier expected. 'static' is a reserved word in strict mode ~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. } \ No newline at end of file diff --git a/tests/baselines/reference/superCallParameterContextualTyping2.errors.txt b/tests/baselines/reference/superCallParameterContextualTyping2.errors.txt index a1e89d41efc..92451ffd056 100644 --- a/tests/baselines/reference/superCallParameterContextualTyping2.errors.txt +++ b/tests/baselines/reference/superCallParameterContextualTyping2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/contextualTyping/superCallParameterContextualTyping2.ts(10,43): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/expressions/contextualTyping/superCallParameterContextualTyping2.ts(10,43): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures. ==== tests/cases/conformance/expressions/contextualTyping/superCallParameterContextualTyping2.ts (1 errors) ==== @@ -13,5 +13,5 @@ tests/cases/conformance/expressions/contextualTyping/superCallParameterContextua // Ensure 'value' is not of type 'any' by invoking it with type arguments. constructor() { super(value => String(value())); } ~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'Number' has no compatible call signatures. } \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInCallExpression.errors.txt b/tests/baselines/reference/templateStringInCallExpression.errors.txt index c483fd9d4c0..cd5e2ff7c63 100644 --- a/tests/baselines/reference/templateStringInCallExpression.errors.txt +++ b/tests/baselines/reference/templateStringInCallExpression.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/templates/templateStringInCallExpression.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInCallExpression.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. ==== tests/cases/conformance/es6/templates/templateStringInCallExpression.ts (1 errors) ==== `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInCallExpressionES6.errors.txt b/tests/baselines/reference/templateStringInCallExpressionES6.errors.txt index 7a391b6afe7..fd47a8001ad 100644 --- a/tests/baselines/reference/templateStringInCallExpressionES6.errors.txt +++ b/tests/baselines/reference/templateStringInCallExpressionES6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/templates/templateStringInCallExpressionES6.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInCallExpressionES6.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. ==== tests/cases/conformance/es6/templates/templateStringInCallExpressionES6.ts (1 errors) ==== `abc${0}abc`(`hello ${0} world`, ` `, `1${2}3`); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInObjectLiteral.errors.txt b/tests/baselines/reference/templateStringInObjectLiteral.errors.txt index dcc8d565b75..234ccfdcae5 100644 --- a/tests/baselines/reference/templateStringInObjectLiteral.errors.txt +++ b/tests/baselines/reference/templateStringInObjectLiteral.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{ a: string; }' has no compatible call signatures. tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,8): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(3,10): error TS1134: Variable declaration expected. @@ -12,7 +12,7 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteral.ts(4,1): err ~~~~~~~~~~~~~~~~~~~~~~~~ `b`: 321 ~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{ a: string; }' has no compatible call signatures. ~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInObjectLiteralES6.errors.txt b/tests/baselines/reference/templateStringInObjectLiteralES6.errors.txt index ab914fabb8b..4c78dbea2cb 100644 --- a/tests/baselines/reference/templateStringInObjectLiteralES6.errors.txt +++ b/tests/baselines/reference/templateStringInObjectLiteralES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{ a: string; }' has no compatible call signatures. tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,8): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(3,10): error TS1134: Variable declaration expected. @@ -12,7 +12,7 @@ tests/cases/conformance/es6/templates/templateStringInObjectLiteralES6.ts(4,1): ~~~~~~~~~~~~~~~~~~~~~~~~ `b`: 321 ~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{ a: string; }' has no compatible call signatures. ~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInPropertyName1.errors.txt b/tests/baselines/reference/templateStringInPropertyName1.errors.txt index 306c6a651e4..15f4415611b 100644 --- a/tests/baselines/reference/templateStringInPropertyName1.errors.txt +++ b/tests/baselines/reference/templateStringInPropertyName1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,8): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(2,10): error TS1134: Variable declaration expected. @@ -10,7 +10,7 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName1.ts(3,1): err ~ `a`: 321 ~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. ~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInPropertyName2.errors.txt b/tests/baselines/reference/templateStringInPropertyName2.errors.txt index e004eec9bba..d9e5d73dd06 100644 --- a/tests/baselines/reference/templateStringInPropertyName2.errors.txt +++ b/tests/baselines/reference/templateStringInPropertyName2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,32): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(2,34): error TS1134: Variable declaration expected. @@ -10,7 +10,7 @@ tests/cases/conformance/es6/templates/templateStringInPropertyName2.ts(3,1): err ~ `abc${ 123 }def${ 456 }ghi`: 321 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. ~~~~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInPropertyNameES6_1.errors.txt b/tests/baselines/reference/templateStringInPropertyNameES6_1.errors.txt index 3576effe560..620b3248558 100644 --- a/tests/baselines/reference/templateStringInPropertyNameES6_1.errors.txt +++ b/tests/baselines/reference/templateStringInPropertyNameES6_1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,8): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(2,10): error TS1134: Variable declaration expected. @@ -10,7 +10,7 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_1.ts(3,1): ~ `a`: 321 ~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. ~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInPropertyNameES6_2.errors.txt b/tests/baselines/reference/templateStringInPropertyNameES6_2.errors.txt index 37e7dc8c0f8..00ef4e511bc 100644 --- a/tests/baselines/reference/templateStringInPropertyNameES6_2.errors.txt +++ b/tests/baselines/reference/templateStringInPropertyNameES6_2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(1,9): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,5): error TS1136: Property assignment expected. tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,32): error TS1005: ',' expected. tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(2,34): error TS1134: Variable declaration expected. @@ -10,7 +10,7 @@ tests/cases/conformance/es6/templates/templateStringInPropertyNameES6_2.ts(3,1): ~ `abc${ 123 }def${ 456 }ghi`: 321 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '{}' has no compatible call signatures. ~~~~~~ !!! error TS1136: Property assignment expected. ~ diff --git a/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt b/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt index 18ce24a0b3b..9494f03a8bf 100644 --- a/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt +++ b/tests/baselines/reference/templateStringInTaggedTemplate.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. ==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplate.ts (1 errors) ==== `I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringInTaggedTemplateES6.errors.txt b/tests/baselines/reference/templateStringInTaggedTemplateES6.errors.txt index fd30d7f4074..581e084e738 100644 --- a/tests/baselines/reference/templateStringInTaggedTemplateES6.errors.txt +++ b/tests/baselines/reference/templateStringInTaggedTemplateES6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/templates/templateStringInTaggedTemplateES6.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/es6/templates/templateStringInTaggedTemplateES6.ts(1,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. ==== tests/cases/conformance/es6/templates/templateStringInTaggedTemplateES6.ts (1 errors) ==== `I AM THE ${ `${ `TAG` } ` } PORTION` `I ${ "AM" } THE TEMPLATE PORTION` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'String' has no compatible call signatures. \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeCallSignatures.errors.txt b/tests/baselines/reference/unionTypeCallSignatures.errors.txt index bf1de6ff8e8..fe0fff0f7e8 100644 --- a/tests/baselines/reference/unionTypeCallSignatures.errors.txt +++ b/tests/baselines/reference/unionTypeCallSignatures.errors.txt @@ -2,14 +2,14 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(9,43): error TS23 tests/cases/conformance/types/union/unionTypeCallSignatures.ts(10,29): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(15,29): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(16,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(19,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(20,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(21,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(19,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: number) => number) | ((a: string) => Date)' has no compatible call signatures. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(20,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: number) => number) | ((a: string) => Date)' has no compatible call signatures. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(21,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: number) => number) | ((a: string) => Date)' has no compatible call signatures. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(24,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(26,36): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(29,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(30,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/conformance/types/union/unionTypeCallSignatures.ts(31,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(29,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(30,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures. +tests/cases/conformance/types/union/unionTypeCallSignatures.ts(31,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(36,49): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(37,12): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/union/unionTypeCallSignatures.ts(40,12): error TS2346: Supplied parameters do not match any signature of call target. @@ -60,13 +60,13 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 var unionOfDifferentParameterTypes: { (a: number): number; } | { (a: string): Date; }; unionOfDifferentParameterTypes(10);// error - no call signatures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: number) => number) | ((a: string) => Date)' has no compatible call signatures. unionOfDifferentParameterTypes("hello");// error - no call signatures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: number) => number) | ((a: string) => Date)' has no compatible call signatures. unionOfDifferentParameterTypes();// error - no call signatures ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: number) => number) | ((a: string) => Date)' has no compatible call signatures. var unionOfDifferentNumberOfSignatures: { (a: number): number; } | { (a: number): Date; (a: string): boolean; }; unionOfDifferentNumberOfSignatures(); // error - no call signatures @@ -80,13 +80,13 @@ tests/cases/conformance/types/union/unionTypeCallSignatures.ts(73,12): error TS2 var unionWithDifferentParameterCount: { (a: string): string; } | { (a: string, b: number): number; } ; unionWithDifferentParameterCount();// no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures. unionWithDifferentParameterCount("hello");// no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures. unionWithDifferentParameterCount("hello", 10);// no call signature ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: string, b: number) => number)' has no compatible call signatures. var unionWithOptionalParameter1: { (a: string, b?: number): string; } | { (a: string, b?: number): number; }; strOrNum = unionWithOptionalParameter1('hello'); diff --git a/tests/baselines/reference/unionTypeMembers.errors.txt b/tests/baselines/reference/unionTypeMembers.errors.txt index 21f1204ac6d..13aaedd631f 100644 --- a/tests/baselines/reference/unionTypeMembers.errors.txt +++ b/tests/baselines/reference/unionTypeMembers.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/union/unionTypeMembers.ts(44,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/types/union/unionTypeMembers.ts(44,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: number) => number)' has no compatible call signatures. tests/cases/conformance/types/union/unionTypeMembers.ts(51,3): error TS2339: Property 'propertyOnlyInI1' does not exist on type 'I1 | I2'. tests/cases/conformance/types/union/unionTypeMembers.ts(52,3): error TS2339: Property 'propertyOnlyInI2' does not exist on type 'I1 | I2'. tests/cases/conformance/types/union/unionTypeMembers.ts(53,3): error TS2339: Property 'methodOnlyInI1' does not exist on type 'I1 | I2'. @@ -51,7 +51,7 @@ tests/cases/conformance/types/union/unionTypeMembers.ts(54,3): error TS2339: Pro x.commonMethodDifferentParameterType; // No error - property exists x.commonMethodDifferentParameterType(strOrNum); // error - no call signatures because the type of this property is ((a: string) => string) | (a: number) => number ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((a: string) => string) | ((a: number) => number)' has no compatible call signatures. // and the call signatures arent identical num = x.commonMethodWithTypeParameter(num); num = x.commonMethodWithOwnTypeParameter(num); diff --git a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt index c6cd96578b4..399a37c32fd 100644 --- a/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt +++ b/tests/baselines/reference/untypedFunctionCallsWithTypeParameters1.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(5,10): error TS2 tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(8,10): error TS2347: Untyped function calls may not accept type arguments. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(10,7): error TS2420: Class 'C' incorrectly implements interface 'Function'. Property 'apply' is missing in type 'C'. -tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(18,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(18,10): error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'C' has no compatible call signatures. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(22,10): error TS2347: Untyped function calls may not accept type arguments. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(28,10): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(35,1): error TS2346: Supplied parameters do not match any signature of call target. @@ -39,7 +39,7 @@ tests/cases/compiler/untypedFunctionCallsWithTypeParameters1.ts(41,1): error TS2 var c2: C; var r4 = c2(); // should be an error ~~~~~~~~~~~~ -!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'C' has no compatible call signatures. class C2 extends Function { } // error var c3: C2; From cbc112a7617528c9449ba3c4ababacdb4baa725a Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 21 Mar 2016 08:26:56 -0700 Subject: [PATCH 005/508] Support this.prop = expr; assignments as declarations for ES6 JS classes --- src/compiler/binder.ts | 8 ++++++ src/compiler/checker.ts | 5 ++++ tests/cases/fourslash/javaScriptClass1.ts | 32 +++++++++++++++++++++++ tests/cases/fourslash/javaScriptClass2.ts | 22 ++++++++++++++++ tests/cases/fourslash/javaScriptClass3.ts | 24 +++++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 tests/cases/fourslash/javaScriptClass1.ts create mode 100644 tests/cases/fourslash/javaScriptClass2.ts create mode 100644 tests/cases/fourslash/javaScriptClass3.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6957be484f3..dc0ff55b89a 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1478,6 +1478,14 @@ namespace ts { // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); } + else if (container.kind === SyntaxKind.Constructor && isInJavaScriptFile(node)) { + // this.foo assignment in a JavaScript class + // Bind this property to the containing class + const saveContainer = container; + container = container.parent; + bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.None); + container = saveContainer; + } } function bindPrototypePropertyAssignment(node: BinaryExpression) { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 27b08397205..63d2afe72eb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8037,6 +8037,11 @@ namespace ts { const binaryExpression = node.parent; const operator = binaryExpression.operatorToken.kind; if (operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment) { + // Don't do this for special property assignments to avoid circularity + if (getSpecialPropertyAssignmentKind(binaryExpression) !== SpecialPropertyAssignmentKind.None) { + return undefined; + } + // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); diff --git a/tests/cases/fourslash/javaScriptClass1.ts b/tests/cases/fourslash/javaScriptClass1.ts new file mode 100644 index 00000000000..117fc5be9be --- /dev/null +++ b/tests/cases/fourslash/javaScriptClass1.ts @@ -0,0 +1,32 @@ +/// + +// Classes have their shape inferred from assignments +// to properties of 'this' in the constructor + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// class Foo { +//// constructor() { +//// this.bar = 'world'; +//// this.thing = 42; +//// this.union = 'foo'; +//// this.union = 100; +//// } +//// } +//// var x = new Foo(); +//// x/**/ + + +goTo.marker(); +edit.insert('.'); +verify.completionListContains("bar", /*displayText*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("thing", /*displayText*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("union", /*displayText*/ undefined, /*documentation*/ undefined, "property"); + +edit.insert('bar.'); +verify.completionListContains("substr", /*displayText*/ undefined, /*documentation*/ undefined, "method"); + +edit.backspace('bar.'.length); + +edit.insert('union.'); +verify.completionListContains("toString", /*displayText*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/javaScriptClass2.ts b/tests/cases/fourslash/javaScriptClass2.ts new file mode 100644 index 00000000000..d6daa320c5a --- /dev/null +++ b/tests/cases/fourslash/javaScriptClass2.ts @@ -0,0 +1,22 @@ +/// + +// In an inferred class, we can rename successfully + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// class Foo { +//// constructor() { +//// this.[|union|] = 'foo'; +//// this./*1*/[|union|] = 100; +//// } +//// method() { return this./*2*/[|union|]; } +//// } +//// var x = new Foo(); +//// x./*3*/[|union|]; + +goTo.marker('1'); +verify.renameLocations(/*findInStrings*/false, /*findInComments*/false); +goTo.marker('2'); +verify.renameLocations(/*findInStrings*/false, /*findInComments*/false); +goTo.marker('3'); +verify.renameLocations(/*findInStrings*/false, /*findInComments*/false); diff --git a/tests/cases/fourslash/javaScriptClass3.ts b/tests/cases/fourslash/javaScriptClass3.ts new file mode 100644 index 00000000000..47004d53b04 --- /dev/null +++ b/tests/cases/fourslash/javaScriptClass3.ts @@ -0,0 +1,24 @@ +/// + +// In an inferred class, we can to-to-def successfully + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// class Foo { +//// constructor() { +//// /*dst1*/this.alpha = 10; +//// /*dst2*/this.beta = 'gamma'; +//// } +//// method() { return this.alpha; } +//// } +//// var x = new Foo(); +//// x.alpha/*src1*/; +//// x.beta/*src2*/; + +goTo.marker('src1'); +goTo.definition(); +verify.caretAtMarker('dst1'); + +goTo.marker('src2'); +goTo.definition(); +verify.caretAtMarker('dst2'); From c8cd748e4807172871764d7726beddcb9deec250 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 21 Mar 2016 09:23:33 -0700 Subject: [PATCH 006/508] Handle JSDoc tags on 'this' properties --- src/compiler/checker.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 63d2afe72eb..49efcc7dc0b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2937,6 +2937,14 @@ namespace ts { } // Handle module.exports = expr if (declaration.kind === SyntaxKind.BinaryExpression) { + // Use JS Doc type if present on parent expression statement + if (declaration.flags & NodeFlags.JavaScriptFile) { + const typeTag = getJSDocTypeTag(declaration.parent); + if (typeTag && typeTag.typeExpression) { + return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); + } + } + return links.type = getUnionType(map(symbol.declarations, (decl: BinaryExpression) => checkExpressionCached(decl.right))); } if (declaration.kind === SyntaxKind.PropertyAccessExpression) { From 32b4e46c1d2979e43967345b08fd7e135ed1519c Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 21 Mar 2016 09:23:41 -0700 Subject: [PATCH 007/508] Update tests --- tests/cases/fourslash/javaScriptClass1.ts | 3 +-- tests/cases/fourslash/javaScriptClass4.ts | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tests/cases/fourslash/javaScriptClass4.ts diff --git a/tests/cases/fourslash/javaScriptClass1.ts b/tests/cases/fourslash/javaScriptClass1.ts index 117fc5be9be..19f7a39b615 100644 --- a/tests/cases/fourslash/javaScriptClass1.ts +++ b/tests/cases/fourslash/javaScriptClass1.ts @@ -8,7 +8,7 @@ //// class Foo { //// constructor() { //// this.bar = 'world'; -//// this.thing = 42; +//// this.thing = () => 0; //// this.union = 'foo'; //// this.union = 100; //// } @@ -25,7 +25,6 @@ verify.completionListContains("union", /*displayText*/ undefined, /*documentatio edit.insert('bar.'); verify.completionListContains("substr", /*displayText*/ undefined, /*documentation*/ undefined, "method"); - edit.backspace('bar.'.length); edit.insert('union.'); diff --git a/tests/cases/fourslash/javaScriptClass4.ts b/tests/cases/fourslash/javaScriptClass4.ts new file mode 100644 index 00000000000..1148d5f320e --- /dev/null +++ b/tests/cases/fourslash/javaScriptClass4.ts @@ -0,0 +1,22 @@ +/// + +// Classes have their shape inferred from assignments +// to properties of 'this' in the constructor + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// class Foo { +//// constructor() { +//// /** +//// * @type {string} +//// */ +//// this.baz = null; +//// } +//// } +//// var x = new Foo(); +//// x/**/ + +goTo.marker(); +edit.insert('.baz.'); +verify.completionListContains("substr", /*displayText*/ undefined, /*documentation*/ undefined, "method"); + From dfee3de3a664d2925110b919e3f3d0b780732fe4 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 21 Apr 2016 10:57:54 -0700 Subject: [PATCH 008/508] Add test case for #8229 --- ...tAnyDestructuringVarDeclaration.errors.txt | 18 ++++-- ...oImplicitAnyDestructuringVarDeclaration.js | 4 +- ...AnyDestructuringVarDeclaration2.errors.txt | 63 +++++++++++++++++++ ...ImplicitAnyDestructuringVarDeclaration2.js | 25 ++++++++ ...oImplicitAnyDestructuringVarDeclaration.ts | 2 +- ...ImplicitAnyDestructuringVarDeclaration2.ts | 12 ++++ 6 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.errors.txt create mode 100644 tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js create mode 100644 tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt index 10d6b05c622..e54261b117f 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt @@ -15,11 +15,13 @@ tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(5,18): error TS tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,5): error TS1182: A destructuring declaration must have an initializer. tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,13): error TS7008: Member 'b3' implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,25): error TS7008: Member 'b3' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,6): error TS7031: Binding element 'a1' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,26): error TS7031: Binding element 'b1' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,6): error TS7031: Binding element 'a4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,26): error TS7031: Binding element 'b4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,46): error TS7005: Variable 'c4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,62): error TS7005: Variable 'd4' implicitly has an 'any' type. -==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts (19 errors) ==== +==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts (21 errors) ==== var [a], {b}, c, d; // error ~~~ !!! error TS1182: A destructuring declaration must have an initializer. @@ -62,8 +64,12 @@ tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,26): error TS ~~ !!! error TS7008: Member 'b3' implicitly has an 'any' type. - var [a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null; // error + var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error ~~ -!!! error TS7031: Binding element 'a1' implicitly has an 'any' type. +!!! error TS7031: Binding element 'a4' implicitly has an 'any' type. ~~ -!!! error TS7031: Binding element 'b1' implicitly has an 'any' type. \ No newline at end of file +!!! error TS7031: Binding element 'b4' implicitly has an 'any' type. + ~~ +!!! error TS7005: Variable 'c4' implicitly has an 'any' type. + ~~ +!!! error TS7005: Variable 'd4' implicitly has an 'any' type. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js index cbc15c01e9e..4e9606d9c53 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js @@ -7,11 +7,11 @@ var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any; var {b3}: { b3 }, c3: { b3 }; // error in type instead -var [a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null; // error +var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error //// [noImplicitAnyDestructuringVarDeclaration.js] var a = (void 0)[0], b = (void 0).b, c, d; // error var _a = (void 0)[0], a1 = _a === void 0 ? undefined : _a, _b = (void 0).b1, b1 = _b === void 0 ? null : _b, c1 = undefined, d1 = null; // error var a2 = (void 0)[0], b2 = (void 0).b2, c2, d2; var b3 = (void 0).b3, c3; // error in type instead -var a1 = [undefined][0], b1 = { b1: null }.b1, c1 = undefined, d1 = null; // error +var a4 = [undefined][0], b4 = { b4: null }.b4, c4 = undefined, d4 = null; // error diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.errors.txt b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.errors.txt new file mode 100644 index 00000000000..d84a2975665 --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.errors.txt @@ -0,0 +1,63 @@ +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(1,6): error TS7031: Binding element 'a' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(1,9): error TS7031: Binding element 'b' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(1,12): error TS7031: Binding element 'c' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(3,6): error TS7031: Binding element 'a2' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(3,22): error TS7031: Binding element 'b2' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(3,38): error TS7031: Binding element 'c2' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(5,6): error TS7031: Binding element 'a4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(5,31): error TS7031: Binding element 'b4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(7,6): error TS7031: Binding element 'x' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(7,9): error TS7031: Binding element 'y' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(7,12): error TS7031: Binding element 'z' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(9,6): error TS7031: Binding element 'x2' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(9,22): error TS7031: Binding element 'y2' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(9,38): error TS7031: Binding element 'z2' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(11,6): error TS7031: Binding element 'x4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(11,37): error TS7031: Binding element 'y4' implicitly has an 'any' type. + + +==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts (16 errors) ==== + let [a, b, c] = [1, 2, 3]; // no error + ~ +!!! error TS7031: Binding element 'a' implicitly has an 'any' type. + ~ +!!! error TS7031: Binding element 'b' implicitly has an 'any' type. + ~ +!!! error TS7031: Binding element 'c' implicitly has an 'any' type. + let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error + let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error + ~~ +!!! error TS7031: Binding element 'a2' implicitly has an 'any' type. + ~~ +!!! error TS7031: Binding element 'b2' implicitly has an 'any' type. + ~~ +!!! error TS7031: Binding element 'c2' implicitly has an 'any' type. + let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error + let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error + ~~ +!!! error TS7031: Binding element 'a4' implicitly has an 'any' type. + ~~ +!!! error TS7031: Binding element 'b4' implicitly has an 'any' type. + + let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error + ~ +!!! error TS7031: Binding element 'x' implicitly has an 'any' type. + ~ +!!! error TS7031: Binding element 'y' implicitly has an 'any' type. + ~ +!!! error TS7031: Binding element 'z' implicitly has an 'any' type. + let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error + let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error + ~~ +!!! error TS7031: Binding element 'x2' implicitly has an 'any' type. + ~~ +!!! error TS7031: Binding element 'y2' implicitly has an 'any' type. + ~~ +!!! error TS7031: Binding element 'z2' implicitly has an 'any' type. + let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error + let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error + ~~ +!!! error TS7031: Binding element 'x4' implicitly has an 'any' type. + ~~ +!!! error TS7031: Binding element 'y4' implicitly has an 'any' type. + \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js new file mode 100644 index 00000000000..79ee0b8830f --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js @@ -0,0 +1,25 @@ +//// [noImplicitAnyDestructuringVarDeclaration2.ts] +let [a, b, c] = [1, 2, 3]; // no error +let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error +let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error +let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error +let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error + +let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error +let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error +let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error +let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error +let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error + + +//// [noImplicitAnyDestructuringVarDeclaration2.js] +var _a = [1, 2, 3], a = _a[0], b = _a[1], c = _a[2]; // no error +var _b = [1, 2, 3], _c = _b[0], a1 = _c === void 0 ? 10 : _c, _d = _b[1], b1 = _d === void 0 ? 10 : _d, _e = _b[2], c1 = _e === void 0 ? 10 : _e; // no error +var _f = [1, 2, 3], _g = _f[0], a2 = _g === void 0 ? undefined : _g, _h = _f[1], b2 = _h === void 0 ? undefined : _h, _j = _f[2], c2 = _j === void 0 ? undefined : _j; // no error +var _k = [1, 2, 3], _l = _k[0], a3 = _l === void 0 ? undefined : _l, _m = _k[1], b3 = _m === void 0 ? null : _m, _o = _k[2], c3 = _o === void 0 ? undefined : _o; // no error +var a4 = [undefined][0], b4 = [null][0], c4 = undefined, d4 = null; // no error +var _p = { x: 1, y: 2, z: 3 }, x = _p.x, y = _p.y, z = _p.z; // no error +var _q = { x1: 1, y1: 2, z1: 3 }, _r = _q.x1, x1 = _r === void 0 ? 10 : _r, _s = _q.y1, y1 = _s === void 0 ? 10 : _s, _t = _q.z1, z1 = _t === void 0 ? 10 : _t; // no error +var _u = { x2: 1, y2: 2, z2: 3 }, _v = _u.x2, x2 = _v === void 0 ? undefined : _v, _w = _u.y2, y2 = _w === void 0 ? undefined : _w, _x = _u.z2, z2 = _x === void 0 ? undefined : _x; // no error +var _y = { x3: 1, y3: 2, z3: 3 }, _z = _y.x3, x3 = _z === void 0 ? undefined : _z, _0 = _y.y3, y3 = _0 === void 0 ? null : _0, _1 = _y.z3, z3 = _1 === void 0 ? undefined : _1; // no error +var x4 = { x4: undefined }.x4, y4 = { y4: null }.y4; // no error diff --git a/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts index 6988416d4de..b9ecd8e72a8 100644 --- a/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts +++ b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts @@ -7,4 +7,4 @@ var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any; var {b3}: { b3 }, c3: { b3 }; // error in type instead -var [a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null; // error \ No newline at end of file +var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts new file mode 100644 index 00000000000..a964bd96dba --- /dev/null +++ b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts @@ -0,0 +1,12 @@ +// @noimplicitany: true +let [a, b, c] = [1, 2, 3]; // no error +let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error +let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error +let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error +let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error + +let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error +let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error +let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error +let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error +let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error From 90d347e855d94bfb24ef644731cc623552a0c854 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 21 Apr 2016 13:25:43 -0700 Subject: [PATCH 009/508] Do not report errors during contextual typecheck Fixes #8229 --- src/compiler/checker.ts | 28 ++-- ...AnyDestructuringVarDeclaration2.errors.txt | 63 -------- ...citAnyDestructuringVarDeclaration2.symbols | 78 ++++++++++ ...licitAnyDestructuringVarDeclaration2.types | 137 ++++++++++++++++++ 4 files changed, 230 insertions(+), 76 deletions(-) delete mode 100644 tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.errors.txt create mode 100644 tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.symbols create mode 100644 tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 899ee479578..f84988e68ba 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2873,7 +2873,7 @@ namespace ts { // If the declaration specifies a binding pattern, use the type implied by the binding pattern if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false, /*reportErrors*/ true); } // No type specified and nothing can be inferred @@ -2883,23 +2883,25 @@ namespace ts { // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. - function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean): Type { + function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean, reportErrors?: boolean): Type { if (element.initializer) { const type = checkExpressionCached(element.initializer); - reportErrorsFromWidening(element, type); + if (reportErrors) { + reportErrorsFromWidening(element, type); + } return getWidenedType(type); } if (isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name, includePatternInType); + return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); } - if (compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { + if (reportErrors && compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; } // Return the type implied by an object binding pattern - function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { + function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean, reportErrors: boolean): Type { const members: SymbolTable = {}; let hasComputedProperties = false; forEach(pattern.elements, e => { @@ -2913,7 +2915,7 @@ namespace ts { const text = getTextOfPropertyName(name); const flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0); const symbol = createSymbol(flags, text); - symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; members[symbol.name] = symbol; }); @@ -2928,13 +2930,13 @@ namespace ts { } // Return the type implied by an array binding pattern - function getTypeFromArrayBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { + function getTypeFromArrayBindingPattern(pattern: BindingPattern, includePatternInType: boolean, reportErrors: boolean): Type { const elements = pattern.elements; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - const elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType)); + const elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors)); if (includePatternInType) { const result = createNewTupleType(elementTypes); result.pattern = pattern; @@ -2950,10 +2952,10 @@ namespace ts { // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. - function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType?: boolean): Type { + function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType?: boolean, reportErrors?: boolean): Type { return pattern.kind === SyntaxKind.ObjectBindingPattern - ? getTypeFromObjectBindingPattern(pattern, includePatternInType) - : getTypeFromArrayBindingPattern(pattern, includePatternInType); + ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) + : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type @@ -8467,7 +8469,7 @@ namespace ts { } } if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } if (isBindingPattern(declaration.parent)) { const parentDeclaration = declaration.parent.parent; diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.errors.txt b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.errors.txt deleted file mode 100644 index d84a2975665..00000000000 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.errors.txt +++ /dev/null @@ -1,63 +0,0 @@ -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(1,6): error TS7031: Binding element 'a' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(1,9): error TS7031: Binding element 'b' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(1,12): error TS7031: Binding element 'c' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(3,6): error TS7031: Binding element 'a2' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(3,22): error TS7031: Binding element 'b2' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(3,38): error TS7031: Binding element 'c2' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(5,6): error TS7031: Binding element 'a4' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(5,31): error TS7031: Binding element 'b4' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(7,6): error TS7031: Binding element 'x' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(7,9): error TS7031: Binding element 'y' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(7,12): error TS7031: Binding element 'z' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(9,6): error TS7031: Binding element 'x2' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(9,22): error TS7031: Binding element 'y2' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(9,38): error TS7031: Binding element 'z2' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(11,6): error TS7031: Binding element 'x4' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts(11,37): error TS7031: Binding element 'y4' implicitly has an 'any' type. - - -==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts (16 errors) ==== - let [a, b, c] = [1, 2, 3]; // no error - ~ -!!! error TS7031: Binding element 'a' implicitly has an 'any' type. - ~ -!!! error TS7031: Binding element 'b' implicitly has an 'any' type. - ~ -!!! error TS7031: Binding element 'c' implicitly has an 'any' type. - let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error - let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error - ~~ -!!! error TS7031: Binding element 'a2' implicitly has an 'any' type. - ~~ -!!! error TS7031: Binding element 'b2' implicitly has an 'any' type. - ~~ -!!! error TS7031: Binding element 'c2' implicitly has an 'any' type. - let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error - let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error - ~~ -!!! error TS7031: Binding element 'a4' implicitly has an 'any' type. - ~~ -!!! error TS7031: Binding element 'b4' implicitly has an 'any' type. - - let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error - ~ -!!! error TS7031: Binding element 'x' implicitly has an 'any' type. - ~ -!!! error TS7031: Binding element 'y' implicitly has an 'any' type. - ~ -!!! error TS7031: Binding element 'z' implicitly has an 'any' type. - let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error - let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error - ~~ -!!! error TS7031: Binding element 'x2' implicitly has an 'any' type. - ~~ -!!! error TS7031: Binding element 'y2' implicitly has an 'any' type. - ~~ -!!! error TS7031: Binding element 'z2' implicitly has an 'any' type. - let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error - let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error - ~~ -!!! error TS7031: Binding element 'x4' implicitly has an 'any' type. - ~~ -!!! error TS7031: Binding element 'y4' implicitly has an 'any' type. - \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.symbols b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.symbols new file mode 100644 index 00000000000..ee7fe9f7edd --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.symbols @@ -0,0 +1,78 @@ +=== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts === +let [a, b, c] = [1, 2, 3]; // no error +>a : Symbol(a, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 5)) +>b : Symbol(b, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 7)) +>c : Symbol(c, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 10)) + +let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error +>a1 : Symbol(a1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 5)) +>b1 : Symbol(b1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 13)) +>c1 : Symbol(c1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 22)) + +let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error +>a2 : Symbol(a2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 5)) +>undefined : Symbol(undefined) +>b2 : Symbol(b2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 20)) +>undefined : Symbol(undefined) +>c2 : Symbol(c2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 36)) +>undefined : Symbol(undefined) + +let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error +>a3 : Symbol(a3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 5)) +>undefined : Symbol(undefined) +>b3 : Symbol(b3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 25)) +>c3 : Symbol(c3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 41)) +>undefined : Symbol(undefined) + +let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error +>a4 : Symbol(a4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 5)) +>undefined : Symbol(undefined) +>b4 : Symbol(b4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 30)) +>c4 : Symbol(c4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 48)) +>undefined : Symbol(undefined) +>d4 : Symbol(d4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 69)) + +let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error +>x : Symbol(x, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 5)) +>y : Symbol(y, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 7)) +>z : Symbol(z, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 10)) +>x : Symbol(x, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 17)) +>y : Symbol(y, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 23)) +>z : Symbol(z, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 29)) + +let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error +>x1 : Symbol(x1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 5)) +>y1 : Symbol(y1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 13)) +>z1 : Symbol(z1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 22)) +>x1 : Symbol(x1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 35)) +>y1 : Symbol(y1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 42)) +>z1 : Symbol(z1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 49)) + +let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error +>x2 : Symbol(x2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 5)) +>undefined : Symbol(undefined) +>y2 : Symbol(y2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 20)) +>undefined : Symbol(undefined) +>z2 : Symbol(z2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 36)) +>undefined : Symbol(undefined) +>x2 : Symbol(x2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 56)) +>y2 : Symbol(y2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 63)) +>z2 : Symbol(z2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 70)) + +let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error +>x3 : Symbol(x3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 5)) +>undefined : Symbol(undefined) +>y3 : Symbol(y3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 25)) +>z3 : Symbol(z3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 41)) +>undefined : Symbol(undefined) +>x3 : Symbol(x3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 66)) +>y3 : Symbol(y3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 73)) +>z3 : Symbol(z3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 80)) + +let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error +>x4 : Symbol(x4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 5)) +>x4 : Symbol(x4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 12)) +>undefined : Symbol(undefined) +>y4 : Symbol(y4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 36)) +>y4 : Symbol(y4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 43)) + diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types new file mode 100644 index 00000000000..ef0a3f2c25b --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types @@ -0,0 +1,137 @@ +=== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts === +let [a, b, c] = [1, 2, 3]; // no error +>a : number +>b : number +>c : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error +>a1 : number +>10 : number +>b1 : number +>10 : number +>c1 : number +>10 : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error +>a2 : number +>undefined : undefined +>b2 : number +>undefined : undefined +>c2 : number +>undefined : undefined +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error +>a3 : number +>undefined : any +>undefined : undefined +>b3 : number +>null : any +>null : null +>c3 : number +>undefined : any +>undefined : undefined +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error +>a4 : any +>[undefined] : [any] +>undefined : any +>undefined : undefined +>b4 : any +>[null] : [any] +>null : any +>null : null +>c4 : any +>undefined : any +>undefined : undefined +>d4 : any +>null : any +>null : null + +let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error +>x : number +>y : number +>z : number +>{ x: 1, y: 2, z: 3 } : { x: number; y: number; z: number; } +>x : number +>1 : number +>y : number +>2 : number +>z : number +>3 : number + +let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error +>x1 : number +>10 : number +>y1 : number +>10 : number +>z1 : number +>10 : number +>{ x1: 1, y1: 2, z1: 3 } : { x1?: number; y1?: number; z1?: number; } +>x1 : number +>1 : number +>y1 : number +>2 : number +>z1 : number +>3 : number + +let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error +>x2 : number +>undefined : undefined +>y2 : number +>undefined : undefined +>z2 : number +>undefined : undefined +>{ x2: 1, y2: 2, z2: 3 } : { x2?: number; y2?: number; z2?: number; } +>x2 : number +>1 : number +>y2 : number +>2 : number +>z2 : number +>3 : number + +let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error +>x3 : number +>undefined : any +>undefined : undefined +>y3 : number +>null : any +>null : null +>z3 : number +>undefined : any +>undefined : undefined +>{ x3: 1, y3: 2, z3: 3 } : { x3?: number; y3?: number; z3?: number; } +>x3 : number +>1 : number +>y3 : number +>2 : number +>z3 : number +>3 : number + +let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error +>x4 : any +>{ x4: undefined } : { x4: any; } +>x4 : any +>undefined : any +>undefined : undefined +>y4 : any +>{ y4: null } : { y4: any; } +>y4 : any +>null : any +>null : null + From 34f7f2caed8fe1198e095332500c6bb6f34de819 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Fri, 22 Apr 2016 10:40:06 -0700 Subject: [PATCH 010/508] Handle the scenario when let [a=undefined]=[] --- src/compiler/checker.ts | 6 +----- .../noImplicitAnyDestructuringVarDeclaration.errors.txt | 9 +++++++-- .../noImplicitAnyDestructuringVarDeclaration.js | 5 ++++- .../compiler/noImplicitAnyDestructuringVarDeclaration.ts | 4 +++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f84988e68ba..a6d1680a6e3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2885,11 +2885,7 @@ namespace ts { // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean, reportErrors?: boolean): Type { if (element.initializer) { - const type = checkExpressionCached(element.initializer); - if (reportErrors) { - reportErrorsFromWidening(element, type); - } - return getWidenedType(type); + return checkExpressionCached(element.initializer); } if (isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt index e54261b117f..f7e6475b971 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt @@ -19,9 +19,10 @@ tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,6): error TS7 tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,26): error TS7031: Binding element 'b4' implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,46): error TS7005: Variable 'c4' implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,62): error TS7005: Variable 'd4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(11,6): error TS7031: Binding element 'a5' implicitly has an 'any' type. -==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts (21 errors) ==== +==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts (22 errors) ==== var [a], {b}, c, d; // error ~~~ !!! error TS1182: A destructuring declaration must have an initializer. @@ -72,4 +73,8 @@ tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,62): error TS ~~ !!! error TS7005: Variable 'c4' implicitly has an 'any' type. ~~ -!!! error TS7005: Variable 'd4' implicitly has an 'any' type. \ No newline at end of file +!!! error TS7005: Variable 'd4' implicitly has an 'any' type. + + var [a5 = undefined] = []; // error + ~~ +!!! error TS7031: Binding element 'a5' implicitly has an 'any' type. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js index 4e9606d9c53..85358df666e 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js @@ -7,7 +7,9 @@ var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any; var {b3}: { b3 }, c3: { b3 }; // error in type instead -var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error +var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error + +var [a5 = undefined] = []; // error //// [noImplicitAnyDestructuringVarDeclaration.js] var a = (void 0)[0], b = (void 0).b, c, d; // error @@ -15,3 +17,4 @@ var _a = (void 0)[0], a1 = _a === void 0 ? undefined : _a, _b = (void 0).b1, b1 var a2 = (void 0)[0], b2 = (void 0).b2, c2, d2; var b3 = (void 0).b3, c3; // error in type instead var a4 = [undefined][0], b4 = { b4: null }.b4, c4 = undefined, d4 = null; // error +var _c = [][0], a5 = _c === void 0 ? undefined : _c; // error diff --git a/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts index b9ecd8e72a8..ea99d03bd7c 100644 --- a/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts +++ b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts @@ -7,4 +7,6 @@ var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any; var {b3}: { b3 }, c3: { b3 }; // error in type instead -var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error \ No newline at end of file +var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error + +var [a5 = undefined] = []; // error \ No newline at end of file From cdb0fb324fbfcde07306bc0ca42f321f3977ed87 Mon Sep 17 00:00:00 2001 From: Sergey Shandar Date: Sat, 4 Jun 2016 03:26:17 -0700 Subject: [PATCH 011/508] Fix findIndex documentation. --- src/lib/es2015.core.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 206b8b8f9bf..74026a6baeb 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -13,7 +13,7 @@ interface Array { find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T | undefined; /** - * Returns the index of the first element in the array where predicate is true, and undefined + * Returns the index of the first element in the array where predicate is true, and -1 * otherwise. * @param predicate find calls predicate once for each element of the array, in ascending * order, until it finds one where predicate returns true. If such an element is found, From c06b02ac3426a06959e49f50636c9f86c2d620ef Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 24 Jun 2016 13:56:45 -0700 Subject: [PATCH 012/508] Adding completions for import and reference directives --- src/compiler/checker.ts | 13 + src/compiler/program.ts | 4 +- src/compiler/types.ts | 1 + src/harness/harness.ts | 4 +- src/harness/harnessLanguageService.ts | 56 +++- src/harness/virtualFileSystem.ts | 101 ++++--- src/server/editorServices.ts | 8 + src/services/services.ts | 278 +++++++++++++++++- src/services/shims.ts | 26 ++ ...etionForStringLiteralNonrelativeImport1.ts | 53 ++++ ...etionForStringLiteralNonrelativeImport2.ts | 32 ++ ...etionForStringLiteralNonrelativeImport3.ts | 30 ++ ...etionForStringLiteralNonrelativeImport4.ts | 45 +++ ...etionForStringLiteralNonrelativeImport5.ts | 28 ++ ...etionForStringLiteralNonrelativeImport6.ts | 57 ++++ ...mpletionForStringLiteralRelativeImport1.ts | 77 +++++ ...mpletionForStringLiteralRelativeImport2.ts | 43 +++ ...mpletionForStringLiteralRelativeImport3.ts | 41 +++ .../completionForTripleSlashReference1.ts | 79 +++++ .../completionForTripleSlashReference2.ts | 47 +++ .../completionForTripleSlashReference3.ts | 41 +++ 21 files changed, 1009 insertions(+), 55 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts create mode 100644 tests/cases/fourslash/completionForTripleSlashReference1.ts create mode 100644 tests/cases/fourslash/completionForTripleSlashReference2.ts create mode 100644 tests/cases/fourslash/completionForTripleSlashReference3.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0ca0fd907fb..14cab98db0d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2,6 +2,8 @@ /* @internal */ namespace ts { + const ambientModuleSymbolRegex = /^".+"$/; + let nextSymbolId = 1; let nextNodeId = 1; let nextMergeId = 1; @@ -101,6 +103,7 @@ namespace ts { getAliasedSymbol: resolveAlias, getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, + getAmbientModules, getJsxElementAttributesType, getJsxIntrinsicTagNames, @@ -19104,5 +19107,15 @@ namespace ts { return true; } } + + function getAmbientModules(): Symbol[] { + const result: Symbol[] = []; + for (const sym in globals) { + if (globals.hasOwnProperty(sym) && ambientModuleSymbolRegex.test(sym)) { + result.push(globals[sym]); + } + } + return result; + } } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a01f3a4c5b2..2e5a5950098 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -15,9 +15,9 @@ namespace ts { const defaultTypeRoots = ["node_modules/@types"]; - export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName="tsconfig.json"): string { while (true) { - const fileName = combinePaths(searchPath, "tsconfig.json"); + const fileName = combinePaths(searchPath, configName); if (fileExists(fileName)) { return fileName; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index cac04172a5c..c2cf3a8527f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1854,6 +1854,7 @@ namespace ts { getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; + getAmbientModules(): Symbol[]; // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 1977d95492c..ace211f2553 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -742,14 +742,14 @@ namespace Harness { } export function readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]) { - const fs = new Utils.VirtualFileSystem(path, useCaseSensitiveFileNames()); + const fs = new Utils.VirtualFileSystem(path, useCaseSensitiveFileNames()); for (const file in listFiles(path)) { fs.addFile(file); } return ts.matchFiles(path, extension, exclude, include, useCaseSensitiveFileNames(), getCurrentDirectory(), path => { const entry = fs.traversePath(path); if (entry && entry.isDirectory()) { - const directory = entry; + const directory = >entry; return { files: ts.map(directory.getFiles(), f => f.name), directories: ts.map(directory.getDirectories(), d => d.name) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 8567a9109de..682496442e9 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -123,7 +123,7 @@ namespace Harness.LanguageService { } export class LanguageServiceAdapterHost { - protected fileNameToScript: ts.Map = {}; + protected virtualFileSystem: Utils.VirtualFileSystem = new Utils.VirtualFileSystem(/*root*/"c:", /*useCaseSensitiveFilenames*/false); constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, protected settings = ts.getDefaultCompilerOptions()) { @@ -135,7 +135,8 @@ namespace Harness.LanguageService { public getFilenames(): string[] { const fileNames: string[] = []; - ts.forEachValue(this.fileNameToScript, (scriptInfo) => { + this.virtualFileSystem.getAllFileEntries().forEach((virtualEntry) => { + const scriptInfo = virtualEntry.content; if (scriptInfo.isRootFile) { // only include root files here // usually it means that we won't include lib.d.ts in the list of root files so it won't mess the computation of compilation root dir. @@ -146,11 +147,12 @@ namespace Harness.LanguageService { } public getScriptInfo(fileName: string): ScriptInfo { - return ts.lookUp(this.fileNameToScript, fileName); + const fileEntry = this.virtualFileSystem.traversePath(fileName); + return fileEntry && fileEntry.isFile() ? (>fileEntry).content : undefined; } public addScript(fileName: string, content: string, isRootFile: boolean): void { - this.fileNameToScript[fileName] = new ScriptInfo(fileName, content, isRootFile); + this.virtualFileSystem.addFile(fileName, new ScriptInfo(fileName, content, isRootFile)); } public editScript(fileName: string, start: number, end: number, newText: string) { @@ -171,7 +173,7 @@ namespace Harness.LanguageService { * @param col 0 based index */ public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { - const script: ScriptInfo = this.fileNameToScript[fileName]; + const script: ScriptInfo = this.getScriptInfo(fileName); assert.isOk(script); return ts.computeLineAndCharacterOfPosition(script.getLineMap(), position); @@ -182,7 +184,13 @@ namespace Harness.LanguageService { class NativeLanguageServiceHost extends LanguageServiceAdapterHost implements ts.LanguageServiceHost { getCompilationSettings() { return this.settings; } getCancellationToken() { return this.cancellationToken; } - getDirectories(path: string): string[] { return []; } + getDirectories(path: string): string[] { + const dir = this.virtualFileSystem.traversePath(path); + if (dir && dir.isDirectory()) { + return ts.map((>dir).getDirectories(), (d) => ts.combinePaths(path, d.name)); + } + return []; + } getCurrentDirectory(): string { return ""; } getDefaultLibFileName(): string { return Harness.Compiler.defaultLibFileName; } getScriptFileNames(): string[] { return this.getFilenames(); } @@ -196,6 +204,39 @@ namespace Harness.LanguageService { return script ? script.version.toString() : undefined; } + fileExists(fileName: string): boolean { + const script = this.getScriptSnapshot(fileName); + return script !== undefined; + } + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] { + return ts.matchFiles(path, extensions, exclude, include, + /*useCaseSensitiveFileNames*/false, + /*currentDirectory*/"/", + (p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p)); + } + readFile(path: string, encoding?: string): string { + const snapshot = this.getScriptSnapshot(path); + return snapshot.getText(0, snapshot.getLength()); + } + resolvePath(path: string): string { + // Reduce away "." and ".." + const parts = path.split("/"); + const res: string[] = []; + for (let i = 0; i < parts.length; i++) { + if (parts[i] === ".") { + continue; + } + else if (parts[i] === ".." && res.length > 0) { + res.splice(res.length - 1, 1); + } + else { + res.push(parts[i]); + } + } + return res.join("/"); + } + + log(s: string): void { } trace(s: string): void { } error(s: string): void { } @@ -299,6 +340,9 @@ namespace Harness.LanguageService { const snapshot = this.nativeHost.getScriptSnapshot(fileName); return snapshot && snapshot.getText(0, snapshot.getLength()); } + resolvePath(path: string): string { + return this.nativeHost.resolvePath(path); + } log(s: string): void { this.nativeHost.log(s); } trace(s: string): void { this.nativeHost.trace(s); } error(s: string): void { this.nativeHost.error(s); } diff --git a/src/harness/virtualFileSystem.ts b/src/harness/virtualFileSystem.ts index 30192b8b8ec..5a89efea7fa 100644 --- a/src/harness/virtualFileSystem.ts +++ b/src/harness/virtualFileSystem.ts @@ -1,11 +1,11 @@ /// /// namespace Utils { - export class VirtualFileSystemEntry { - fileSystem: VirtualFileSystem; + export class VirtualFileSystemEntry { + fileSystem: VirtualFileSystem; name: string; - constructor(fileSystem: VirtualFileSystem, name: string) { + constructor(fileSystem: VirtualFileSystem, name: string) { this.fileSystem = fileSystem; this.name = name; } @@ -15,15 +15,15 @@ namespace Utils { isFileSystem() { return false; } } - export class VirtualFile extends VirtualFileSystemEntry { - content: string; + export class VirtualFile extends VirtualFileSystemEntry { + content: T; isFile() { return true; } } - export abstract class VirtualFileSystemContainer extends VirtualFileSystemEntry { - abstract getFileSystemEntries(): VirtualFileSystemEntry[]; + export abstract class VirtualFileSystemContainer extends VirtualFileSystemEntry { + abstract getFileSystemEntries(): VirtualFileSystemEntry[]; - getFileSystemEntry(name: string): VirtualFileSystemEntry { + getFileSystemEntry(name: string): VirtualFileSystemEntry { for (const entry of this.getFileSystemEntries()) { if (this.fileSystem.sameName(entry.name, name)) { return entry; @@ -32,57 +32,57 @@ namespace Utils { return undefined; } - getDirectories(): VirtualDirectory[] { - return ts.filter(this.getFileSystemEntries(), entry => entry.isDirectory()); + getDirectories(): VirtualDirectory[] { + return []>ts.filter(this.getFileSystemEntries(), entry => entry.isDirectory()); } - getFiles(): VirtualFile[] { - return ts.filter(this.getFileSystemEntries(), entry => entry.isFile()); + getFiles(): VirtualFile[] { + return []>ts.filter(this.getFileSystemEntries(), entry => entry.isFile()); } - getDirectory(name: string): VirtualDirectory { + getDirectory(name: string): VirtualDirectory { const entry = this.getFileSystemEntry(name); - return entry.isDirectory() ? entry : undefined; + return entry.isDirectory() ? >entry : undefined; } - getFile(name: string): VirtualFile { + getFile(name: string): VirtualFile { const entry = this.getFileSystemEntry(name); - return entry.isFile() ? entry : undefined; + return entry.isFile() ? >entry : undefined; } } - export class VirtualDirectory extends VirtualFileSystemContainer { - private entries: VirtualFileSystemEntry[] = []; + export class VirtualDirectory extends VirtualFileSystemContainer { + private entries: VirtualFileSystemEntry[] = []; isDirectory() { return true; } getFileSystemEntries() { return this.entries.slice(); } - addDirectory(name: string): VirtualDirectory { + addDirectory(name: string): VirtualDirectory { const entry = this.getFileSystemEntry(name); if (entry === undefined) { - const directory = new VirtualDirectory(this.fileSystem, name); + const directory = new VirtualDirectory(this.fileSystem, name); this.entries.push(directory); return directory; } else if (entry.isDirectory()) { - return entry; + return >entry; } else { return undefined; } } - addFile(name: string, content?: string): VirtualFile { + addFile(name: string, content?: T): VirtualFile { const entry = this.getFileSystemEntry(name); if (entry === undefined) { - const file = new VirtualFile(this.fileSystem, name); + const file = new VirtualFile(this.fileSystem, name); file.content = content; this.entries.push(file); return file; } else if (entry.isFile()) { - const file = entry; + const file = >entry; file.content = content; return file; } @@ -92,8 +92,8 @@ namespace Utils { } } - export class VirtualFileSystem extends VirtualFileSystemContainer { - private root: VirtualDirectory; + export class VirtualFileSystem extends VirtualFileSystemContainer { + private root: VirtualDirectory; currentDirectory: string; useCaseSensitiveFileNames: boolean; @@ -101,7 +101,7 @@ namespace Utils { constructor(currentDirectory: string, useCaseSensitiveFileNames: boolean) { super(undefined, ""); this.fileSystem = this; - this.root = new VirtualDirectory(this, ""); + this.root = new VirtualDirectory(this, ""); this.currentDirectory = currentDirectory; this.useCaseSensitiveFileNames = useCaseSensitiveFileNames; } @@ -112,7 +112,7 @@ namespace Utils { addDirectory(path: string) { const components = ts.getNormalizedPathComponents(path, this.currentDirectory); - let directory: VirtualDirectory = this.root; + let directory: VirtualDirectory = this.root; for (const component of components) { directory = directory.addDirectory(component); if (directory === undefined) { @@ -123,7 +123,7 @@ namespace Utils { return directory; } - addFile(path: string, content?: string) { + addFile(path: string, content?: T) { const absolutePath = ts.getNormalizedAbsolutePath(path, this.currentDirectory); const fileName = ts.getBaseFileName(path); const directoryPath = ts.getDirectoryPath(absolutePath); @@ -141,14 +141,14 @@ namespace Utils { } traversePath(path: string) { - let directory: VirtualDirectory = this.root; + let directory: VirtualDirectory = this.root; for (const component of ts.getNormalizedPathComponents(path, this.currentDirectory)) { const entry = directory.getFileSystemEntry(component); if (entry === undefined) { return undefined; } else if (entry.isDirectory()) { - directory = entry; + directory = >entry; } else { return entry; @@ -157,9 +157,34 @@ namespace Utils { return directory; } + + getAccessibleFileSystemEntries(path: string) { + const entry = this.traversePath(path); + if (entry && entry.isDirectory()) { + const directory = >entry; + return { + files: ts.map(directory.getFiles(), f => f.name), + directories: ts.map(directory.getDirectories(), d => d.name) + }; + } + return { files: [], directories: [] }; + } + + getAllFileEntries() { + const fileEntries: VirtualFile[] = []; + getFilesRecursive(this.root, fileEntries); + return fileEntries; + + function getFilesRecursive(dir: VirtualDirectory, result: VirtualFile[]) { + dir.getFiles().forEach((e) => result.push(e)); + dir.getDirectories().forEach((subDir) => getFilesRecursive(subDir, result)); + } + } + + } - export class MockParseConfigHost extends VirtualFileSystem implements ts.ParseConfigHost { + export class MockParseConfigHost extends VirtualFileSystem implements ts.ParseConfigHost { constructor(currentDirectory: string, ignoreCase: boolean, files: string[]) { super(currentDirectory, ignoreCase); for (const file of files) { @@ -170,17 +195,5 @@ namespace Utils { readDirectory(path: string, extensions: string[], excludes: string[], includes: string[]) { return ts.matchFiles(path, extensions, excludes, includes, this.useCaseSensitiveFileNames, this.currentDirectory, (path: string) => this.getAccessibleFileSystemEntries(path)); } - - getAccessibleFileSystemEntries(path: string) { - const entry = this.traversePath(path); - if (entry && entry.isDirectory()) { - const directory = entry; - return { - files: ts.map(directory.getFiles(), f => f.name), - directories: ts.map(directory.getDirectories(), d => d.name) - }; - } - return { files: [], directories: [] }; - } } } \ No newline at end of file diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 9c0662e5534..b94c366e7c9 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -321,6 +321,14 @@ namespace ts.server { return this.host.getDirectories(path); } + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] { + return this.host.readDirectory(path, extensions, exclude, include); + } + + readFile(path: string, encoding?: string): string { + return this.host.readFile(path, encoding); + } + /** * @param line 1 based index */ diff --git a/src/services/services.ts b/src/services/services.ts index 492be6f1719..c6c8a7a2e83 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1070,6 +1070,11 @@ namespace ts { error?(s: string): void; useCaseSensitiveFileNames?(): boolean; + readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; + resolvePath(path: string): string; + readFile(path: string, encoding?: string): string; + fileExists(path: string): boolean; + /* * LS host can optionally implement this method if it wants to be completely in charge of module name resolution. * if implementation is omitted then language service will use built-in module resolution logic and get answers to @@ -1943,6 +1948,9 @@ namespace ts { } + const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); + const tripleSlashDirectivePrefixRegex = /^\/\/\/\s*node); + } else { // Otherwise, get the completions from the contextual type if one exists return getStringLiteralCompletionEntriesFromContextualType(node); @@ -4314,6 +4339,258 @@ namespace ts { } } } + + function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral) { + const literalValue = node.text; + let result: CompletionEntry[]; + + const isRelativePath = startsWith(literalValue, "."); + const scriptDir = getDirectoryPath(node.getSourceFile().path); + if (isRelativePath || isRootedDiskPath(literalValue)) { + result = getCompletionEntriesForDirectoryFragment(literalValue, scriptDir, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false); + } + else { + // Check for node modules + result = getCompletionEntriesForNonRelativeModules(literalValue, scriptDir); + } + + return { + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: result + }; + } + + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean): CompletionEntry[] { + // Complete the path by looking for source files and directories + const result: CompletionEntry[] = []; + + const toComplete = getBaseFileName(fragment); + const absolutePath = normalizeSlashes(host.resolvePath(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment))); + const baseDir = getDirectoryPath(absolutePath); + + + if (directoryProbablyExists(baseDir, host)) { + // Enumerate the available files + const files = host.readDirectory(baseDir, extensions, /*exclude*/undefined, /*include*/["./*"]); + files.forEach((f) => { + const fName = includeExtensions ? getBaseFileName(f) : removeFileExtension(getBaseFileName(f)); + + if (startsWith(fName, toComplete)) { + result.push({ + name: fName, + kind: ScriptElementKind.unknown, + kindModifiers: ScriptElementKindModifier.none, + sortText: fName + }); + } + }); + + // If possible, get folder completion as well + if (host.getDirectories) { + const directories = host.getDirectories(baseDir); + directories.forEach((d) => { + const dName = getBaseFileName(removeTrailingDirectorySeparator(d)); + + if (startsWith(dName, toComplete)) { + result.push({ + name: ensureTrailingDirectorySeparator(dName), + kind: ScriptElementKind.unknown, + kindModifiers: ScriptElementKindModifier.none, + sortText: dName + }); + } + }); + } + } + + return includeExtensions ? result : deduplicate(result, (a, b) => a.name === b.name); + } + + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules declared in the program + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ and node_modules/@types/moduleName/ + * with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string): CompletionEntry[] { + return ts.map(enumeratePotentialNonRelativeModules(fragment, scriptPath), (moduleName) => { + return { + name: moduleName, + kind: ScriptElementKind.unknown, + kindModifiers: ScriptElementKindModifier.none, + sortText: moduleName + }; + }); + } + + function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string) { + const ambientSymbolNameRegex = /^"(.+?)"$/; + + // If this is a nested module, get the module name + const firstSeparator = fragment.indexOf(directorySeparator); + const moduleNameFragment = firstSeparator !== -1 ? fragment.substr(0, firstSeparator) : fragment; + const isNestedModule = fragment !== moduleNameFragment; + + // Get modules that the type checker picked up + const ambientModules = ts.map(program.getTypeChecker().getAmbientModules(), (sym) => { + const match = ambientSymbolNameRegex.exec(sym.name); + if (match) { + return match[1]; + } + // This should never happen + return sym.name; + }); + let nonRelativeModules = ts.filter(ambientModules, (moduleName) => startsWith(moduleName, fragment)); + + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because editors insert the completion + // only after that character + nonRelativeModules = ts.map(nonRelativeModules, (moduleName) => { + if (moduleName.indexOf(directorySeparator) !== -1) { + if (isNestedModule) { + return moduleName.substr(fragment.lastIndexOf(directorySeparator) + 1); + } + } + return moduleName; + }); + + // Check for node_modules. We only offer completions for modules that are listed in the + // package.json for a project for efficiency and to ensure that the completion list is + // not polluted with sub-dependencies + findPackageJsons(scriptPath).forEach((packageJson) => { + const package = tryReadingPackageJson(packageJson); + if (!package) { + return; + } + + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; + + if (package.dependencies) { + addPotentialPackageNames(package.dependencies, moduleNameFragment, foundModuleNames); + } + if (package.devDependencies) { + addPotentialPackageNames(package.devDependencies, moduleNameFragment, foundModuleNames); + } + + foundModuleNames.forEach((moduleName) => { + if (isNestedModule && moduleName === moduleNameFragment) { + const moduleDir = combinePaths(nodeModulesDir, moduleName); + if (directoryProbablyExists(moduleDir, host)) { + // Get all possible nested module names from files with all extensions + const nestedFiles = host.readDirectory(moduleDir, allSupportedExtensions, /*exclude*/undefined, /*include*/["./*"]); + + // Add those with typings to the completion list + nestedFiles.forEach((f) => { + const nestedModule = removeFileExtension(getBaseFileName(f)); + if (hasTypeScriptFileExtension(f)) { + nonRelativeModules.push(nestedModule); + } + }); + } + } + else if (startsWith(moduleName, fragment)) { + if (moduleCanBeImported(combinePaths(nodeModulesDir, moduleName))) { + nonRelativeModules.push(moduleName); + } + else { + nonRelativeModules.push(ensureTrailingDirectorySeparator(moduleName)); + } + } + }); + }); + + return deduplicate(nonRelativeModules); + } + + function findPackageJsons(currentDir: string): string[] { + const paths: string[] = []; + let currentConfigPath: string; + while (true) { + currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + + currentDir = getDirectoryPath(currentConfigPath); + const parent = getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + + return paths; + } + + function tryReadingPackageJson(filePath: string) { + try { + const fileText = host.readFile(filePath); + return JSON.parse(fileText); + } + catch (e) { + return undefined; + } + } + + function addPotentialPackageNames(dependencies: any, prefix: string, result: string[]) { + for (const dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && startsWith(dep, prefix)) { + result.push(dep); + } + } + } + + /* + * A module can be imported by name alone if one of the following is true: + * It defines the "typings" property in its package.json + * The module has a "main" export and an index.d.ts file + * The module has an index.ts + */ + function moduleCanBeImported(modulePath: string): boolean { + const packagePath = combinePaths(modulePath, "package.json"); + + let hasMainExport = false; + if (host.fileExists(packagePath)) { + const package = tryReadingPackageJson(packagePath); + if (package) { + if (package.typings) { + return true; + } + hasMainExport = !!package.main; + } + } + + hasMainExport = hasMainExport || host.fileExists(combinePaths(modulePath, "index.js")); + + return (hasMainExport && host.fileExists(combinePaths(modulePath, "index.d.ts"))) || host.fileExists(combinePaths(modulePath, "index.ts")); + } + + function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number) { + const node = getTokenAtPosition(sourceFile, position); + if (!node) { + return undefined; + } + + const text = sourceFile.text.substr(node.pos, position); + const match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + const fragment = match[1]; + const scriptPath = getDirectoryPath(sourceFile.path); + return { + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: getCompletionEntriesForDirectoryFragment(fragment, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true) + }; + } + + return undefined; + } } function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { @@ -6189,7 +6466,6 @@ namespace ts { symbolToIndex: number[]): void { const sourceFile = container.getSourceFile(); - const tripleSlashDirectivePrefixRegex = /^\/\/\/\s* + +// @Filename: tests/test0.ts +//// import * as foo from "f/*0*/ + +// @Filename: tests/test1.ts +//// import * as foo from "fake-module//*1*/ + +// @Filename: tests/test2.ts +//// import * as foo from "fake-module/*2*/ + +// @Filename: package.json +//// { "dependencies": { "fake-module": "latest" }, "devDependencies": { "fake-module-dev": "latest" } } + +// @Filename: node_modules/fake-module/index.js +//// /*fake-module*/ +// @Filename: node_modules/fake-module/index.d.ts +//// /*fakemodule-d-ts*/ +// @Filename: node_modules/fake-module/ts.ts +//// /*ts*/ +// @Filename: node_modules/fake-module/dts.d.ts +//// /*dts*/ +// @Filename: node_modules/fake-module/tsx.tsx +//// /*tsx*/ +// @Filename: node_modules/fake-module/js.js +//// /*js*/ +// @Filename: node_modules/fake-module/jsx.jsx +//// /*jsx*/ + +// @Filename: node_modules/fake-module-dev/index.js +//// /*fakemodule-dev*/ +// @Filename: node_modules/fake-module-dev/index.d.ts +//// /*fakemodule-dev-d-ts*/ + +// @Filename: node_modules/unlisted-module/index.ts +//// /*unlisted-module*/ + +goTo.marker("0"); +verify.completionListContains("fake-module"); +verify.completionListContains("fake-module-dev"); +verify.not.completionListItemsCountIsGreaterThan(2); + +goTo.marker("1"); +verify.completionListContains("index"); +verify.completionListContains("ts"); +verify.completionListContains("dts"); +verify.completionListContains("tsx"); +verify.not.completionListItemsCountIsGreaterThan(4); + +goTo.marker("2"); +verify.completionListContains("fake-module"); +verify.completionListContains("fake-module-dev"); +verify.not.completionListItemsCountIsGreaterThan(2); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts new file mode 100644 index 00000000000..c3e6f2e9062 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts @@ -0,0 +1,32 @@ +/// + +// @Filename: tests/test0.ts +//// import * as foo from "fake-module//*0*/ + +// @Filename: package.json +//// { "dependencies": { "fake-module": "latest" }, "devDependencies": { "fake-module-dev": "latest" } } + +// @Filename: node_modules/fake-module/repeated.ts +//// /*repeatedts*/ +// @Filename: node_modules/fake-module/repeated.tsx +//// /*repeatedtsx*/ +// @Filename: node_modules/fake-module/repeated.d.ts +//// /*repeateddts*/ +// @Filename: node_modules/fake-module/other.js +//// /*other*/ +// @Filename: node_modules/fake-module/other2.js +//// /*other2*/ + +// @Filename: node_modules/unlisted-module/index.js +//// /*unlisted-module*/ + +// @Filename: node_modules/@types/fake-module/other.d.ts +//// declare module "fake-module/other" {} + +// @Filename: node_modules/@types/unlisted-module/index.d.ts +//// /*unlisted-types*/ + +goTo.marker("0"); +verify.completionListContains("repeated"); +verify.completionListContains("other"); +verify.not.completionListItemsCountIsGreaterThan(2); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts new file mode 100644 index 00000000000..7be26cf76d2 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts @@ -0,0 +1,30 @@ +/// +// @allowJs: true + +// @Filename: tests/test0.ts +//// import * as foo from "fake-module//*0*/ + +// @Filename: package.json +//// { "dependencies": { "fake-module": "latest" } } + +// @Filename: node_modules/fake-module/ts.ts +//// /*ts*/ +// @Filename: node_modules/fake-module/tsx.tsx +//// /*tsx*/ +// @Filename: node_modules/fake-module/dts.d.ts +//// /*dts*/ +// @Filename: node_modules/fake-module/js.js +//// /*js*/ +// @Filename: node_modules/fake-module/jsx.jsx +//// /*jsx*/ +// @Filename: node_modules/fake-module/repeated.js +//// /*repeatedjs*/ +// @Filename: node_modules/fake-module/repeated.jsx +//// /*repeatedjsx*/ + +goTo.marker("0"); + +verify.completionListContains("ts"); +verify.completionListContains("tsx"); +verify.completionListContains("dts"); +verify.not.completionListItemsCountIsGreaterThan(3); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts new file mode 100644 index 00000000000..baa13638569 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -0,0 +1,45 @@ +/// + +// @Filename: dir1/dir2/dir3/dir4/test0.ts +//// import * as foo from "f/*0*/ + +// @Filename: dir1/dir2/dir3/dir4/test1.ts +//// import * as foo from "a/*1*/ + +// @Filename: dir1/dir2/dir3/dir4/test2.ts +//// import * as foo from "fake-module/*2*/ + +// @Filename: package.json +//// { "dependencies": { "fake-module": "latest" } } +// @Filename: node_modules/fake-module/ts.ts +//// /*module1*/ + +// @Filename: dir1/package.json +//// { "dependencies": { "fake-module2": "latest" } } +// @Filename: dir1/node_modules/@types/fake-module2/js.d.ts +//// declare module "ambient-module-test" {} + +// @Filename: dir1/dir2/dir3/package.json +//// { "dependencies": { "fake-module3": "latest" } } +// @Filename: dir1/dir2/dir3/node_modules/fake-module3/ts.ts +//// /*module3*/ + + +goTo.marker("0"); + +verify.completionListContains("fake-module/"); +verify.completionListContains("fake-module2/"); +verify.completionListContains("fake-module3/"); +verify.not.completionListItemsCountIsGreaterThan(3); + +goTo.marker("1"); + +verify.completionListContains("ambient-module-test"); +verify.not.completionListItemsCountIsGreaterThan(1); + +goTo.marker("2"); + +verify.completionListContains("fake-module/"); +verify.completionListContains("fake-module2/"); +verify.completionListContains("fake-module3/"); +verify.not.completionListItemsCountIsGreaterThan(3); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts new file mode 100644 index 00000000000..a5bd602bbbf --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts @@ -0,0 +1,28 @@ +/// + +// @Filename: test0.ts +//// import * as foo from "/*0*/ + +// @Filename: test1.ts +//// import * as foo from "a/*1*/ + +// @Filename: ambientModules.d.ts +//// declare module "ambientModule" {} +//// declare module "otherAmbientModule" {} + +// @Filename: ambientModules2.d.ts +//// declare module "otherOtherAmbientModule" {} + + +goTo.marker("0"); + +verify.completionListContains("ambientModule"); +verify.completionListContains("otherAmbientModule"); +verify.completionListContains("otherOtherAmbientModule"); +verify.not.completionListItemsCountIsGreaterThan(3); + +goTo.marker("1"); + +verify.completionListContains("ambientModule"); +verify.not.completionListItemsCountIsGreaterThan(1); + diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts new file mode 100644 index 00000000000..ed588f35802 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts @@ -0,0 +1,57 @@ +/// + +// @Filename: tests/test0.ts +//// import * as foo from "module-/*0*/ + +// @Filename: package.json +//// { "dependencies": { +//// "module-no-main": "latest", +//// "module-no-main-index-d-ts": "latest", +//// "module-index-ts": "latest", +//// "module-index-d-ts-explicit-main": "latest", +//// "module-index-d-ts-default-main": "latest", +//// "module-typings": "latest" +//// } } + +// @Filename: node_modules/module-no-main/package.json +//// { } + +// @Filename: node_modules/module-no-main-index-d-ts/package.json +//// { } +// @Filename: node_modules/module-no-main-index-d-ts/index.d.ts +//// /*module-no-main-index-d-ts*/ + +// @Filename: node_modules/module-index-ts/package.json +//// { } +// @Filename: node_modules/module-index-ts/index.ts +//// /*module-index-ts*/ + +// @Filename: node_modules/module-index-d-ts-explicit-main/package.json +//// { "main":"./notIndex.js" } +// @Filename: node_modules/module-index-d-ts-explicit-main/notIndex.js +//// /*module-index-d-ts-explicit-main*/ +// @Filename: node_modules/module-index-d-ts-explicit-main/index.d.ts +//// /*module-index-d-ts-explicit-main2*/ + +// @Filename: node_modules/module-index-d-ts-default-main/package.json +//// { } +// @Filename: node_modules/module-index-d-ts-default-main/index.js +//// /*module-index-d-ts-default-main*/ +// @Filename: node_modules/module-index-d-ts-default-main/index.d.ts +//// /*module-index-d-ts-default-main2*/ + +// @Filename: node_modules/module-typings/package.json +//// { "typings":"./types.d.ts" } +// @Filename: node_modules/module-typings/types.d.ts +//// /*module-typings*/ + + +goTo.marker("0"); + +verify.completionListContains("module-no-main/"); +verify.completionListContains("module-no-main-index-d-ts/"); +verify.completionListContains("module-index-ts"); +verify.completionListContains("module-index-d-ts-explicit-main"); +verify.completionListContains("module-index-d-ts-default-main"); +verify.completionListContains("module-typings"); +verify.not.completionListItemsCountIsGreaterThan(6); diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts new file mode 100644 index 00000000000..26a6645b3fa --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts @@ -0,0 +1,77 @@ +/// + +// @Filename: test0.ts +//// import * as foo from "./*0*/ + +// @Filename: test1.ts +//// import * as foo from ".//*1*/ + +// @Filename: test2.ts +//// import * as foo from "./f/*2*/ + +// @Filename: test3.ts +//// import * as foo from "./folder//*3*/ + +// @Filename: test4.ts +//// import * as foo from "./folder/h/*4*/ + +// @Filename: parentTest/sub/test5.ts +//// import * as foo from "../g/*5*/ + +// @Filename: f1.ts +//// /*f1*/ +// @Filename: f1.js +//// /*f1j*/ +// @Filename: f1.d.ts +//// /*f1d*/ +// @Filename: f2.tsx +//// /f2*/ +// @Filename: f3.js +//// /*f3*/ +// @Filename: f4.jsx +//// /*f4*/ +// @Filename: e1.ts +//// /*e1*/ +// @Filename: folder/f1.ts +//// /*subf1*/ +// @Filename: folder/h1.ts +//// /*subh1*/ +// @Filename: parentTest/f1.ts +//// /*parentf1*/ +// @Filename: parentTest/g1.ts +//// /*parentg1*/ + +goTo.marker("0"); +verify.completionListIsEmpty(); + +goTo.marker("1"); +verify.completionListContains("f1"); +verify.completionListContains("f2"); +verify.completionListContains("e1"); +verify.completionListContains("test0"); +verify.completionListContains("test1"); +verify.completionListContains("test2"); +verify.completionListContains("test3"); +verify.completionListContains("test4"); +verify.completionListContains("folder/"); +verify.completionListContains("parentTest/"); +verify.not.completionListItemsCountIsGreaterThan(10); + +goTo.marker("2"); +verify.completionListContains("f1"); +verify.completionListContains("f2"); +verify.completionListContains("folder/"); +verify.not.completionListItemsCountIsGreaterThan(3); + +goTo.marker("3"); +verify.completionListContains("f1"); +verify.completionListContains("h1"); +verify.not.completionListItemsCountIsGreaterThan(2); + +goTo.marker("4"); +verify.completionListContains("h1"); +verify.not.completionListItemsCountIsGreaterThan(1); + +goTo.marker("5"); +verify.completionListContains("g1"); +verify.not.completionListItemsCountIsGreaterThan(1); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts new file mode 100644 index 00000000000..1b4abe79119 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts @@ -0,0 +1,43 @@ +/// +// @allowJs: true + +// @Filename: test0.ts +//// import * as foo from ".//*0*/ + +// @Filename: test1.ts +//// import * as foo from "./f/*1*/ + +// @Filename: f1.ts +//// /f1*/ +// @Filename: f1.js +//// /*f1j*/ +// @Filename: f1.d.ts +//// /*f1d*/ +// @Filename: f2.tsx +//// /*f2*/ +// @Filename: f3.js +//// /*f3*/ +// @Filename: f4.jsx +//// /*f4*/ +// @Filename: e1.ts +//// /*e1*/ +// @Filename: e2.js +//// /*e2*/ + +goTo.marker("0"); +verify.completionListContains("f1"); +verify.completionListContains("f2"); +verify.completionListContains("f3"); +verify.completionListContains("f4"); +verify.completionListContains("e1"); +verify.completionListContains("e2"); +verify.completionListContains("test0"); +verify.completionListContains("test1"); +verify.not.completionListItemsCountIsGreaterThan(8); + +goTo.marker("1"); +verify.completionListContains("f1"); +verify.completionListContains("f2"); +verify.completionListContains("f3"); +verify.completionListContains("f4"); +verify.not.completionListItemsCountIsGreaterThan(4); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts new file mode 100644 index 00000000000..1b10ffff5b6 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -0,0 +1,41 @@ +/// + +// @Filename: tests/test0.ts +//// import * as foo from "c:/tests/cases/f/*0*/ + +// @Filename: tests/test1.ts +//// import * as foo from "c:/tests/cases/fourslash/*1*/ + +// @Filename: tests/test2.ts +//// import * as foo from "c:/tests/cases/fourslash//*2*/ + +// @Filename: f1.ts +//// /*f1*/ +// @Filename: f2.tsx +//// /*f2*/ +// @Filename: folder/f1.ts +//// /*subf1*/ +// @Filename: f3.js +//// /*f3*/ +// @Filename: f4.jsx +//// /*f4*/ +// @Filename: e1.ts +//// /*e1*/ +// @Filename: e2.js +//// /*e2*/ + +goTo.marker("0"); +verify.completionListContains("fourslash/"); +verify.not.completionListItemsCountIsGreaterThan(1); + +goTo.marker("1"); +verify.completionListContains("fourslash/"); +verify.not.completionListItemsCountIsGreaterThan(1); + +goTo.marker("2"); +verify.completionListContains("f1"); +verify.completionListContains("f2"); +verify.completionListContains("e1"); +verify.completionListContains("folder/"); +verify.completionListContains("tests/"); +verify.not.completionListItemsCountIsGreaterThan(5); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference1.ts b/tests/cases/fourslash/completionForTripleSlashReference1.ts new file mode 100644 index 00000000000..96582be1730 --- /dev/null +++ b/tests/cases/fourslash/completionForTripleSlashReference1.ts @@ -0,0 +1,79 @@ +/// + +// @Filename: test0.ts +//// /// + +// @Filename: test3.ts +//// /// +// @allowJs: true + +// @Filename: test0.ts +//// /// + +// @Filename: tests/test0.ts +//// /// Date: Fri, 24 Jun 2016 14:51:30 -0700 Subject: [PATCH 013/508] Minor fix --- src/services/services.ts | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index c6c8a7a2e83..650d0c4ce1a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1948,7 +1948,6 @@ namespace ts { } - const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); const tripleSlashDirectivePrefixRegex = /^\/\/\/\s* { @@ -4479,15 +4477,11 @@ namespace ts { if (isNestedModule && moduleName === moduleNameFragment) { const moduleDir = combinePaths(nodeModulesDir, moduleName); if (directoryProbablyExists(moduleDir, host)) { - // Get all possible nested module names from files with all extensions - const nestedFiles = host.readDirectory(moduleDir, allSupportedExtensions, /*exclude*/undefined, /*include*/["./*"]); + const nestedFiles = host.readDirectory(moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - // Add those with typings to the completion list nestedFiles.forEach((f) => { const nestedModule = removeFileExtension(getBaseFileName(f)); - if (hasTypeScriptFileExtension(f)) { - nonRelativeModules.push(nestedModule); - } + nonRelativeModules.push(nestedModule); }); } } From dbdd9893f54a5a5e3165bc1e21010d9e51740ae8 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 27 Jun 2016 13:06:40 -0700 Subject: [PATCH 014/508] Import completions for require calls --- src/services/services.ts | 26 ++++-- ...etionForStringLiteralNonrelativeImport1.ts | 46 ++++++---- ...etionForStringLiteralNonrelativeImport2.ts | 16 ++-- ...etionForStringLiteralNonrelativeImport3.ts | 17 ++-- ...etionForStringLiteralNonrelativeImport4.ts | 43 +++++---- ...etionForStringLiteralNonrelativeImport5.ts | 29 +++--- ...etionForStringLiteralNonrelativeImport6.ts | 23 +++-- ...mpletionForStringLiteralRelativeImport1.ts | 89 ++++++++++--------- ...mpletionForStringLiteralRelativeImport2.ts | 44 +++++---- ...mpletionForStringLiteralRelativeImport3.ts | 44 +++++---- 10 files changed, 225 insertions(+), 152 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 650d0c4ce1a..04c435f1339 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2775,13 +2775,17 @@ namespace ts { function isNameOfExternalModuleImportOrDeclaration(node: Node): boolean { if (node.kind === SyntaxKind.StringLiteral) { - return isNameOfModuleDeclaration(node) || - (isExternalModuleImportEqualsDeclaration(node.parent.parent) && getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node); + return isNameOfModuleDeclaration(node) || isExpressionOfExternalModuleImportEqualsDeclaration(node); } return false; } + function isExpressionOfExternalModuleImportEqualsDeclaration(node: Node) { + return isExternalModuleImportEqualsDeclaration(node.parent.parent) && + getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node; + } + /** Returns true if the position is within a comment */ function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean { // The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment @@ -4256,15 +4260,25 @@ namespace ts { const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); if (argumentInfo) { - // Get string literal completions from specialized signatures of the target - return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); + // Try to get string literal completions from specialized signatures of the target + const callExpressionCompletionEntries = getStringLiteralCompletionEntriesFromCallExpression(argumentInfo); + if (callExpressionCompletionEntries) { + return callExpressionCompletionEntries; + } + else if (isRequireCall(node.parent, false)) { + // If that failed but this call mataches the signature of a require call, treat the literal as an external module name + return getStringLiteralCompletionEntriesFromModuleNames(node); + } + else { + return undefined; + } } else if (isElementAccessExpression(node.parent) && node.parent.argumentExpression === node) { // Get all names of properties on the expression return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === SyntaxKind.ImportDeclaration) { - // Get all known module names + else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node)) { + // Get all known external module names or complete a path to a module return getStringLiteralCompletionEntriesFromModuleNames(node); } else { diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts index 681a6fce03c..5c7b2016a75 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts @@ -1,13 +1,17 @@ /// // @Filename: tests/test0.ts -//// import * as foo from "f/*0*/ +//// import * as foo1 from "f/*import_as0*/ +//// import * as foo2 from "fake-module//*import_as1*/ +//// import * as foo3 from "fake-module/*import_as2*/ -// @Filename: tests/test1.ts -//// import * as foo from "fake-module//*1*/ +//// import foo4 = require("f/*import_equals0*/ +//// import foo5 = require("fake-module//*import_equals1*/ +//// import foo6 = require("fake-module/*import_equals2*/ -// @Filename: tests/test2.ts -//// import * as foo from "fake-module/*2*/ +//// var foo7 = require("f/*require0*/ +//// var foo8 = require("fake-module//*require1*/ +//// var foo9 = require("fake-module/*require2*/ // @Filename: package.json //// { "dependencies": { "fake-module": "latest" }, "devDependencies": { "fake-module-dev": "latest" } } @@ -35,19 +39,23 @@ // @Filename: node_modules/unlisted-module/index.ts //// /*unlisted-module*/ -goTo.marker("0"); -verify.completionListContains("fake-module"); -verify.completionListContains("fake-module-dev"); -verify.not.completionListItemsCountIsGreaterThan(2); +const kinds = ["import_as", "import_equals", "require"]; -goTo.marker("1"); -verify.completionListContains("index"); -verify.completionListContains("ts"); -verify.completionListContains("dts"); -verify.completionListContains("tsx"); -verify.not.completionListItemsCountIsGreaterThan(4); +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("fake-module"); + verify.completionListContains("fake-module-dev"); + verify.not.completionListItemsCountIsGreaterThan(2); -goTo.marker("2"); -verify.completionListContains("fake-module"); -verify.completionListContains("fake-module-dev"); -verify.not.completionListItemsCountIsGreaterThan(2); \ No newline at end of file + goTo.marker(kind + "1"); + verify.completionListContains("index"); + verify.completionListContains("ts"); + verify.completionListContains("dts"); + verify.completionListContains("tsx"); + verify.not.completionListItemsCountIsGreaterThan(4); + + goTo.marker(kind + "2"); + verify.completionListContains("fake-module"); + verify.completionListContains("fake-module-dev"); + verify.not.completionListItemsCountIsGreaterThan(2); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts index c3e6f2e9062..2b5f57412de 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts @@ -1,7 +1,9 @@ /// // @Filename: tests/test0.ts -//// import * as foo from "fake-module//*0*/ +//// import * as foo1 from "fake-module//*import_as0*/ +//// import foo2 = require("fake-module//*import_equals0*/ +//// var foo3 = require("fake-module//*require0*/ // @Filename: package.json //// { "dependencies": { "fake-module": "latest" }, "devDependencies": { "fake-module-dev": "latest" } } @@ -26,7 +28,11 @@ // @Filename: node_modules/@types/unlisted-module/index.d.ts //// /*unlisted-types*/ -goTo.marker("0"); -verify.completionListContains("repeated"); -verify.completionListContains("other"); -verify.not.completionListItemsCountIsGreaterThan(2); +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("repeated"); + verify.completionListContains("other"); + verify.not.completionListItemsCountIsGreaterThan(2); +} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts index 7be26cf76d2..aec9f8411bc 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts @@ -2,7 +2,9 @@ // @allowJs: true // @Filename: tests/test0.ts -//// import * as foo from "fake-module//*0*/ +//// import * as foo1 from "fake-module//*import_as0*/ +//// import foo2 = require("fake-module//*import_equals0*/ +//// var foo3 = require("fake-module//*require0*/ // @Filename: package.json //// { "dependencies": { "fake-module": "latest" } } @@ -22,9 +24,12 @@ // @Filename: node_modules/fake-module/repeated.jsx //// /*repeatedjsx*/ -goTo.marker("0"); +const kinds = ["import_as", "import_equals", "require"]; -verify.completionListContains("ts"); -verify.completionListContains("tsx"); -verify.completionListContains("dts"); -verify.not.completionListItemsCountIsGreaterThan(3); +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("ts"); + verify.completionListContains("tsx"); + verify.completionListContains("dts"); + verify.not.completionListItemsCountIsGreaterThan(3); +} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index baa13638569..64e3cbad48e 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -1,13 +1,17 @@ /// // @Filename: dir1/dir2/dir3/dir4/test0.ts -//// import * as foo from "f/*0*/ +//// import * as foo1 from "f/*import_as0*/ +//// import * as foo2 from "a/*import_as1*/ +//// import * as foo3 from "fake-module/*import_as2*/ -// @Filename: dir1/dir2/dir3/dir4/test1.ts -//// import * as foo from "a/*1*/ +//// import foo4 = require("f/*import_equals0*/ +//// import foo5 = require("a/*import_equals1*/ +//// import foo6 = require("fake-module/*import_equals2*/ -// @Filename: dir1/dir2/dir3/dir4/test2.ts -//// import * as foo from "fake-module/*2*/ +//// var foo7 = require("f/*require0*/ +//// var foo8 = require("a/*require1*/ +//// var foo9 = require("fake-module/*require2*/ // @Filename: package.json //// { "dependencies": { "fake-module": "latest" } } @@ -24,22 +28,25 @@ // @Filename: dir1/dir2/dir3/node_modules/fake-module3/ts.ts //// /*module3*/ +const kinds = ["import_as", "import_equals", "require"]; -goTo.marker("0"); +for (const kind of kinds) { + goTo.marker(kind + "0"); -verify.completionListContains("fake-module/"); -verify.completionListContains("fake-module2/"); -verify.completionListContains("fake-module3/"); -verify.not.completionListItemsCountIsGreaterThan(3); + verify.completionListContains("fake-module/"); + verify.completionListContains("fake-module2/"); + verify.completionListContains("fake-module3/"); + verify.not.completionListItemsCountIsGreaterThan(3); -goTo.marker("1"); + goTo.marker(kind + "1"); -verify.completionListContains("ambient-module-test"); -verify.not.completionListItemsCountIsGreaterThan(1); + verify.completionListContains("ambient-module-test"); + verify.not.completionListItemsCountIsGreaterThan(1); -goTo.marker("2"); + goTo.marker(kind + "2"); -verify.completionListContains("fake-module/"); -verify.completionListContains("fake-module2/"); -verify.completionListContains("fake-module3/"); -verify.not.completionListItemsCountIsGreaterThan(3); + verify.completionListContains("fake-module/"); + verify.completionListContains("fake-module2/"); + verify.completionListContains("fake-module3/"); + verify.not.completionListItemsCountIsGreaterThan(3); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts index a5bd602bbbf..4a8b9e2f614 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts @@ -1,10 +1,14 @@ /// // @Filename: test0.ts -//// import * as foo from "/*0*/ +//// import * as foo1 from "/*import_as0*/ +//// import * as foo2 from "a/*import_as1*/ -// @Filename: test1.ts -//// import * as foo from "a/*1*/ +//// import foo3 = require("/*import_equals0*/ +//// import foo4 = require("a/*import_equals1*/ + +//// var foo5 = require("/*require0*/ +//// var foo6 = require("a/*require1*/ // @Filename: ambientModules.d.ts //// declare module "ambientModule" {} @@ -13,16 +17,19 @@ // @Filename: ambientModules2.d.ts //// declare module "otherOtherAmbientModule" {} +const kinds = ["import_as", "import_equals", "require"]; -goTo.marker("0"); +for (const kind of kinds) { + goTo.marker(kind + "0"); -verify.completionListContains("ambientModule"); -verify.completionListContains("otherAmbientModule"); -verify.completionListContains("otherOtherAmbientModule"); -verify.not.completionListItemsCountIsGreaterThan(3); + verify.completionListContains("ambientModule"); + verify.completionListContains("otherAmbientModule"); + verify.completionListContains("otherOtherAmbientModule"); + verify.not.completionListItemsCountIsGreaterThan(3); -goTo.marker("1"); + goTo.marker(kind + "1"); -verify.completionListContains("ambientModule"); -verify.not.completionListItemsCountIsGreaterThan(1); + verify.completionListContains("ambientModule"); + verify.not.completionListItemsCountIsGreaterThan(1); +} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts index ed588f35802..bfd0539e149 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts @@ -1,7 +1,9 @@ /// // @Filename: tests/test0.ts -//// import * as foo from "module-/*0*/ +//// import * as foo1 from "module-/*import_as0*/ +//// import foo2 = require("module-/*import_equals0*/ +//// var foo3 = require("module-/*require0*/ // @Filename: package.json //// { "dependencies": { @@ -45,13 +47,16 @@ // @Filename: node_modules/module-typings/types.d.ts //// /*module-typings*/ +const kinds = ["import_as", "import_equals", "require"]; -goTo.marker("0"); +for (const kind of kinds) { + goTo.marker(kind + "0"); -verify.completionListContains("module-no-main/"); -verify.completionListContains("module-no-main-index-d-ts/"); -verify.completionListContains("module-index-ts"); -verify.completionListContains("module-index-d-ts-explicit-main"); -verify.completionListContains("module-index-d-ts-default-main"); -verify.completionListContains("module-typings"); -verify.not.completionListItemsCountIsGreaterThan(6); + verify.completionListContains("module-no-main/"); + verify.completionListContains("module-no-main-index-d-ts/"); + verify.completionListContains("module-index-ts"); + verify.completionListContains("module-index-d-ts-explicit-main"); + verify.completionListContains("module-index-d-ts-default-main"); + verify.completionListContains("module-typings"); + verify.not.completionListItemsCountIsGreaterThan(6); +} diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts index 26a6645b3fa..bb9d6a59c7b 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts @@ -1,22 +1,30 @@ /// // @Filename: test0.ts -//// import * as foo from "./*0*/ +//// import * as foo1 from "./*import_as0*/ +//// import * as foo2 from ".//*import_as1*/ +//// import * as foo3 from "./f/*import_as2*/ +//// import * as foo4 from "./folder//*import_as3*/ +//// import * as foo5 from "./folder/h/*import_as4*/ -// @Filename: test1.ts -//// import * as foo from ".//*1*/ +//// import foo6 = require("./*import_equals0*/ +//// import foo7 = require(".//*import_equals1*/ +//// import foo8 = require("./f/*import_equals2*/ +//// import foo9 = require("./folder//*import_equals3*/ +//// import foo10 = require("./folder/h/*import_equals4*/ -// @Filename: test2.ts -//// import * as foo from "./f/*2*/ - -// @Filename: test3.ts -//// import * as foo from "./folder//*3*/ - -// @Filename: test4.ts -//// import * as foo from "./folder/h/*4*/ +//// var foo11 = require("./*require0*/ +//// var foo12 = require(".//*require1*/ +//// var foo13 = require("./f/*require2*/ +//// var foo14 = require("./folder//*require3*/ +//// var foo15 = require("./folder/h/*require4*/ // @Filename: parentTest/sub/test5.ts -//// import * as foo from "../g/*5*/ +//// import * as foo16 from "../g/*import_as5*/ + +//// import foo17 = require("../g/*import_equals5*/ + +//// var foo18 = require("../g/*require5*/ // @Filename: f1.ts //// /*f1*/ @@ -40,38 +48,37 @@ //// /*parentf1*/ // @Filename: parentTest/g1.ts //// /*parentg1*/ +const kinds = ["import_as", "import_equals", "require"]; -goTo.marker("0"); -verify.completionListIsEmpty(); +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListIsEmpty(); -goTo.marker("1"); -verify.completionListContains("f1"); -verify.completionListContains("f2"); -verify.completionListContains("e1"); -verify.completionListContains("test0"); -verify.completionListContains("test1"); -verify.completionListContains("test2"); -verify.completionListContains("test3"); -verify.completionListContains("test4"); -verify.completionListContains("folder/"); -verify.completionListContains("parentTest/"); -verify.not.completionListItemsCountIsGreaterThan(10); + goTo.marker(kind + "1"); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("e1"); + verify.completionListContains("test0"); + verify.completionListContains("folder/"); + verify.completionListContains("parentTest/"); + verify.not.completionListItemsCountIsGreaterThan(6); -goTo.marker("2"); -verify.completionListContains("f1"); -verify.completionListContains("f2"); -verify.completionListContains("folder/"); -verify.not.completionListItemsCountIsGreaterThan(3); + goTo.marker(kind + "2"); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("folder/"); + verify.not.completionListItemsCountIsGreaterThan(3); -goTo.marker("3"); -verify.completionListContains("f1"); -verify.completionListContains("h1"); -verify.not.completionListItemsCountIsGreaterThan(2); + goTo.marker(kind + "3"); + verify.completionListContains("f1"); + verify.completionListContains("h1"); + verify.not.completionListItemsCountIsGreaterThan(2); -goTo.marker("4"); -verify.completionListContains("h1"); -verify.not.completionListItemsCountIsGreaterThan(1); + goTo.marker(kind + "4"); + verify.completionListContains("h1"); + verify.not.completionListItemsCountIsGreaterThan(1); -goTo.marker("5"); -verify.completionListContains("g1"); -verify.not.completionListItemsCountIsGreaterThan(1); \ No newline at end of file + goTo.marker(kind + "5"); + verify.completionListContains("g1"); + verify.not.completionListItemsCountIsGreaterThan(1); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts index 1b4abe79119..4e879148469 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts @@ -2,10 +2,14 @@ // @allowJs: true // @Filename: test0.ts -//// import * as foo from ".//*0*/ +//// import * as foo1 from ".//*import_as0*/ +//// import * as foo2 from "./f/*import_as1*/ -// @Filename: test1.ts -//// import * as foo from "./f/*1*/ +//// import foo3 = require(".//*import_equals0*/ +//// import foo4 = require("./f/*import_equals1*/ + +//// var foo5 = require(".//*require0*/ +//// var foo6 = require("./f/*require1*/ // @Filename: f1.ts //// /f1*/ @@ -23,21 +27,23 @@ //// /*e1*/ // @Filename: e2.js //// /*e2*/ +const kinds = ["import_as", "import_equals", "require"]; -goTo.marker("0"); -verify.completionListContains("f1"); -verify.completionListContains("f2"); -verify.completionListContains("f3"); -verify.completionListContains("f4"); -verify.completionListContains("e1"); -verify.completionListContains("e2"); -verify.completionListContains("test0"); -verify.completionListContains("test1"); -verify.not.completionListItemsCountIsGreaterThan(8); +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("f3"); + verify.completionListContains("f4"); + verify.completionListContains("e1"); + verify.completionListContains("e2"); + verify.completionListContains("test0"); + verify.not.completionListItemsCountIsGreaterThan(7); -goTo.marker("1"); -verify.completionListContains("f1"); -verify.completionListContains("f2"); -verify.completionListContains("f3"); -verify.completionListContains("f4"); -verify.not.completionListItemsCountIsGreaterThan(4); \ No newline at end of file + goTo.marker(kind + "1"); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("f3"); + verify.completionListContains("f4"); + verify.not.completionListItemsCountIsGreaterThan(4); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts index 1b10ffff5b6..426eb3c2318 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -1,13 +1,17 @@ /// // @Filename: tests/test0.ts -//// import * as foo from "c:/tests/cases/f/*0*/ +//// import * as foo1 from "c:/tests/cases/f/*import_as0*/ +//// import * as foo2 from "c:/tests/cases/fourslash/*import_as1*/ +//// import * as foo3 from "c:/tests/cases/fourslash//*import_as2*/ -// @Filename: tests/test1.ts -//// import * as foo from "c:/tests/cases/fourslash/*1*/ +//// import foo4 = require("c:/tests/cases/f/*import_equals0*/ +//// import foo5 = require("c:/tests/cases/fourslash/*import_equals1*/ +//// import foo6 = require("c:/tests/cases/fourslash//*import_equals2*/ -// @Filename: tests/test2.ts -//// import * as foo from "c:/tests/cases/fourslash//*2*/ +//// var foo7 = require("c:/tests/cases/f/*require0*/ +//// var foo8 = require("c:/tests/cases/fourslash/*require1*/ +//// var foo9 = require("c:/tests/cases/fourslash//*require2*/ // @Filename: f1.ts //// /*f1*/ @@ -24,18 +28,22 @@ // @Filename: e2.js //// /*e2*/ -goTo.marker("0"); -verify.completionListContains("fourslash/"); -verify.not.completionListItemsCountIsGreaterThan(1); +const kinds = ["import_as", "import_equals", "require"]; -goTo.marker("1"); -verify.completionListContains("fourslash/"); -verify.not.completionListItemsCountIsGreaterThan(1); +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("fourslash/"); + verify.not.completionListItemsCountIsGreaterThan(1); -goTo.marker("2"); -verify.completionListContains("f1"); -verify.completionListContains("f2"); -verify.completionListContains("e1"); -verify.completionListContains("folder/"); -verify.completionListContains("tests/"); -verify.not.completionListItemsCountIsGreaterThan(5); \ No newline at end of file + goTo.marker(kind + "1"); + verify.completionListContains("fourslash/"); + verify.not.completionListItemsCountIsGreaterThan(1); + + goTo.marker(kind + "2"); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("e1"); + verify.completionListContains("folder/"); + verify.completionListContains("tests/"); + verify.not.completionListItemsCountIsGreaterThan(5); +} \ No newline at end of file From 801b49360202fd8c2c4f46b2aeedb49f5034b6a7 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 30 Jun 2016 10:30:23 -0700 Subject: [PATCH 015/508] PR feedback --- src/harness/harnessLanguageService.ts | 2 +- src/harness/virtualFileSystem.ts | 9 +++++++-- src/services/services.ts | 19 +++++++++++++------ 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 682496442e9..08c74e695be 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -135,7 +135,7 @@ namespace Harness.LanguageService { public getFilenames(): string[] { const fileNames: string[] = []; - this.virtualFileSystem.getAllFileEntries().forEach((virtualEntry) => { + ts.forEach(this.virtualFileSystem.getAllFileEntries(), (virtualEntry) => { const scriptInfo = virtualEntry.content; if (scriptInfo.isRootFile) { // only include root files here diff --git a/src/harness/virtualFileSystem.ts b/src/harness/virtualFileSystem.ts index 5a89efea7fa..2a46bf4c3fe 100644 --- a/src/harness/virtualFileSystem.ts +++ b/src/harness/virtualFileSystem.ts @@ -158,6 +158,11 @@ namespace Utils { return directory; } + /** + * Reads the directory at the given path and retrieves a list of file names and a list + * of directory names within it. Suitable for use with ts.matchFiles() + * @param path The path to the directory to be read + */ getAccessibleFileSystemEntries(path: string) { const entry = this.traversePath(path); if (entry && entry.isDirectory()) { @@ -176,8 +181,8 @@ namespace Utils { return fileEntries; function getFilesRecursive(dir: VirtualDirectory, result: VirtualFile[]) { - dir.getFiles().forEach((e) => result.push(e)); - dir.getDirectories().forEach((subDir) => getFilesRecursive(subDir, result)); + ts.forEach(dir.getFiles(), (e) => result.push(e)); + ts.forEach(dir.getDirectories(), (subDir) => getFilesRecursive(subDir, result)); } } diff --git a/src/services/services.ts b/src/services/services.ts index 04c435f1339..b7e79473fcd 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1947,8 +1947,15 @@ namespace ts { sourceMapText?: string; } - + // Matches the beginning of a triple slash directive const tripleSlashDirectivePrefixRegex = /^\/\/\/\s* { + ts.forEach(files, (f) => { const fName = includeExtensions ? getBaseFileName(f) : removeFileExtension(getBaseFileName(f)); if (startsWith(fName, toComplete)) { @@ -4402,7 +4409,7 @@ namespace ts { // If possible, get folder completion as well if (host.getDirectories) { const directories = host.getDirectories(baseDir); - directories.forEach((d) => { + ts.forEach(directories, (d) => { const dName = getBaseFileName(removeTrailingDirectorySeparator(d)); if (startsWith(dName, toComplete)) { @@ -4471,7 +4478,7 @@ namespace ts { // Check for node_modules. We only offer completions for modules that are listed in the // package.json for a project for efficiency and to ensure that the completion list is // not polluted with sub-dependencies - findPackageJsons(scriptPath).forEach((packageJson) => { + ts.forEach(findPackageJsons(scriptPath), (packageJson) => { const package = tryReadingPackageJson(packageJson); if (!package) { return; @@ -4487,13 +4494,13 @@ namespace ts { addPotentialPackageNames(package.devDependencies, moduleNameFragment, foundModuleNames); } - foundModuleNames.forEach((moduleName) => { + ts.forEach(foundModuleNames, (moduleName) => { if (isNestedModule && moduleName === moduleNameFragment) { const moduleDir = combinePaths(nodeModulesDir, moduleName); if (directoryProbablyExists(moduleDir, host)) { const nestedFiles = host.readDirectory(moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - nestedFiles.forEach((f) => { + ts.forEach(nestedFiles, (f) => { const nestedModule = removeFileExtension(getBaseFileName(f)); nonRelativeModules.push(nestedModule); }); From 5c24b3528d75220843334aac1ae56e48743d7c39 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 5 Jul 2016 17:01:26 -0700 Subject: [PATCH 016/508] Refactoring node_modules enumeration code --- src/services/services.ts | 112 ++---------------- src/services/utilities.ts | 103 ++++++++++++++++ ...etionForStringLiteralNonrelativeImport5.ts | 6 +- 3 files changed, 116 insertions(+), 105 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 167f8c9edf7..704a12fda21 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4477,117 +4477,23 @@ namespace ts { return moduleName; }); - // Check for node_modules. We only offer completions for modules that are listed in the - // package.json for a project for efficiency and to ensure that the completion list is - // not polluted with sub-dependencies - ts.forEach(findPackageJsons(scriptPath), (packageJson) => { - const package = tryReadingPackageJson(packageJson); - if (!package) { - return; + forEach(enumerateNodeModulesVisibleToScript(host, scriptPath, moduleNameFragment), visibleModule => { + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.canBeImported ? visibleModule.moduleName : ensureTrailingDirectorySeparator(visibleModule.moduleName)); } + else { + const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); - const foundModuleNames: string[] = []; - - if (package.dependencies) { - addPotentialPackageNames(package.dependencies, moduleNameFragment, foundModuleNames); + forEach(nestedFiles, (f) => { + const nestedModule = removeFileExtension(getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + }); } - if (package.devDependencies) { - addPotentialPackageNames(package.devDependencies, moduleNameFragment, foundModuleNames); - } - - ts.forEach(foundModuleNames, (moduleName) => { - if (isNestedModule && moduleName === moduleNameFragment) { - const moduleDir = combinePaths(nodeModulesDir, moduleName); - if (directoryProbablyExists(moduleDir, host)) { - const nestedFiles = host.readDirectory(moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - - ts.forEach(nestedFiles, (f) => { - const nestedModule = removeFileExtension(getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - }); - } - } - else if (startsWith(moduleName, fragment)) { - if (moduleCanBeImported(combinePaths(nodeModulesDir, moduleName))) { - nonRelativeModules.push(moduleName); - } - else { - nonRelativeModules.push(ensureTrailingDirectorySeparator(moduleName)); - } - } - }); }); return deduplicate(nonRelativeModules); } - function findPackageJsons(currentDir: string): string[] { - const paths: string[] = []; - let currentConfigPath: string; - while (true) { - currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - - currentDir = getDirectoryPath(currentConfigPath); - const parent = getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } - - return paths; - } - - function tryReadingPackageJson(filePath: string) { - try { - const fileText = host.readFile(filePath); - return JSON.parse(fileText); - } - catch (e) { - return undefined; - } - } - - function addPotentialPackageNames(dependencies: any, prefix: string, result: string[]) { - for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && startsWith(dep, prefix)) { - result.push(dep); - } - } - } - - /* - * A module can be imported by name alone if one of the following is true: - * It defines the "typings" property in its package.json - * The module has a "main" export and an index.d.ts file - * The module has an index.ts - */ - function moduleCanBeImported(modulePath: string): boolean { - const packagePath = combinePaths(modulePath, "package.json"); - - let hasMainExport = false; - if (host.fileExists(packagePath)) { - const package = tryReadingPackageJson(packagePath); - if (package) { - if (package.typings) { - return true; - } - hasMainExport = !!package.main; - } - } - - hasMainExport = hasMainExport || host.fileExists(combinePaths(modulePath, "index.js")); - - return (hasMainExport && host.fileExists(combinePaths(modulePath, "index.d.ts"))) || host.fileExists(combinePaths(modulePath, "index.ts")); - } - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number) { const node = getTokenAtPosition(sourceFile, position); if (!node) { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0c4c0fd1dea..44423860d4a 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -6,6 +6,12 @@ namespace ts { list: Node; } + export interface VisibleModuleInfo { + moduleName: string; + moduleDir: string; + canBeImported: boolean; + } + export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number { const lineStarts = sourceFile.getLineStarts(); const line = sourceFile.getLineAndCharacterOfPosition(position).line; @@ -927,4 +933,101 @@ namespace ts { } return ensureScriptKind(fileName, scriptKind); } + + export function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string, modulePrefix?: string) { + const result: VisibleModuleInfo[] = []; + findPackageJsons(scriptPath).forEach((packageJson) => { + const package = tryReadingPackageJson(packageJson); + if (!package) { + return; + } + + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; + + if (package.dependencies) { + addPotentialPackageNames(package.dependencies, modulePrefix, foundModuleNames); + } + if (package.devDependencies) { + addPotentialPackageNames(package.devDependencies, modulePrefix, foundModuleNames); + } + + forEach(foundModuleNames, (moduleName) => { + const moduleDir = combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName, + moduleDir, + canBeImported: moduleCanBeImported(moduleDir) + }); + }); + }); + + return result; + + function findPackageJsons(currentDir: string): string[] { + const paths: string[] = []; + let currentConfigPath: string; + while (true) { + currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + + currentDir = getDirectoryPath(currentConfigPath); + const parent = getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + + return paths; + } + + function tryReadingPackageJson(filePath: string) { + try { + const fileText = host.readFile(filePath); + return JSON.parse(fileText); + } + catch (e) { + return undefined; + } + } + + function addPotentialPackageNames(dependencies: any, prefix: string, result: string[]) { + for (const dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && (!prefix || startsWith(dep, prefix))) { + result.push(dep); + } + } + } + + /* + * A module can be imported by name alone if one of the following is true: + * It defines the "typings" property in its package.json + * The module has a "main" export and an index.d.ts file + * The module has an index.ts + */ + function moduleCanBeImported(modulePath: string): boolean { + const packagePath = combinePaths(modulePath, "package.json"); + + let hasMainExport = false; + if (host.fileExists(packagePath)) { + const package = tryReadingPackageJson(packagePath); + if (package) { + if (package.typings) { + return true; + } + hasMainExport = !!package.main; + } + } + + hasMainExport = hasMainExport || host.fileExists(combinePaths(modulePath, "index.js")); + + return (hasMainExport && host.fileExists(combinePaths(modulePath, "index.d.ts"))) || host.fileExists(combinePaths(modulePath, "index.ts")); + } + } } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts index 4a8b9e2f614..2e172e3578e 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts @@ -1,6 +1,8 @@ /// // @Filename: test0.ts +//// /// +//// /// //// import * as foo1 from "/*import_as0*/ //// import * as foo2 from "a/*import_as1*/ @@ -12,10 +14,10 @@ // @Filename: ambientModules.d.ts //// declare module "ambientModule" {} -//// declare module "otherAmbientModule" {} +//// declare module "otherAmbientModule" {} /*dummy0*/ // @Filename: ambientModules2.d.ts -//// declare module "otherOtherAmbientModule" {} +//// declare module "otherOtherAmbientModule" {} /*dummy1*/ const kinds = ["import_as", "import_equals", "require"]; From ffc165ee3657c4cabb5ad06e67eb9410c340ad0b Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 5 Jul 2016 17:38:52 -0700 Subject: [PATCH 017/508] Fixing behavior of resolvePath --- src/harness/harnessLanguageService.ts | 16 +--------------- src/services/services.ts | 6 +++--- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index e6d529bcde9..3cb83faf610 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -219,21 +219,7 @@ namespace Harness.LanguageService { return snapshot.getText(0, snapshot.getLength()); } resolvePath(path: string): string { - // Reduce away "." and ".." - const parts = path.split("/"); - const res: string[] = []; - for (let i = 0; i < parts.length; i++) { - if (parts[i] === ".") { - continue; - } - else if (parts[i] === ".." && res.length > 0) { - res.splice(res.length - 1, 1); - } - else { - res.push(parts[i]); - } - } - return res.join("/"); + return ts.normalizePath(ts.isRootedDiskPath(path) ? path : ts.combinePaths(this.getCurrentDirectory(), path)); } diff --git a/src/services/services.ts b/src/services/services.ts index 704a12fda21..d440f194b70 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4389,13 +4389,13 @@ namespace ts { const toComplete = getBaseFileName(fragment); const absolutePath = normalizeSlashes(host.resolvePath(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment))); - const baseDir = getDirectoryPath(absolutePath); + const baseDir = toComplete ? getDirectoryPath(absolutePath) : absolutePath; if (directoryProbablyExists(baseDir, host)) { // Enumerate the available files const files = host.readDirectory(baseDir, extensions, /*exclude*/undefined, /*include*/["./*"]); - ts.forEach(files, (f) => { + forEach(files, (f) => { const fName = includeExtensions ? getBaseFileName(f) : removeFileExtension(getBaseFileName(f)); if (startsWith(fName, toComplete)) { @@ -4411,7 +4411,7 @@ namespace ts { // If possible, get folder completion as well if (host.getDirectories) { const directories = host.getDirectories(baseDir); - ts.forEach(directories, (d) => { + forEach(directories, (d) => { const dName = getBaseFileName(removeTrailingDirectorySeparator(d)); if (startsWith(dName, toComplete)) { From 5c87c5a4bcd59e4012b22bbde8ab795a8f3c4522 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 6 Jul 2016 13:05:12 -0700 Subject: [PATCH 018/508] Removing forEach reference --- src/harness/virtualFileSystem.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/harness/virtualFileSystem.ts b/src/harness/virtualFileSystem.ts index 2a46bf4c3fe..c2502bbc80f 100644 --- a/src/harness/virtualFileSystem.ts +++ b/src/harness/virtualFileSystem.ts @@ -181,8 +181,14 @@ namespace Utils { return fileEntries; function getFilesRecursive(dir: VirtualDirectory, result: VirtualFile[]) { - ts.forEach(dir.getFiles(), (e) => result.push(e)); - ts.forEach(dir.getDirectories(), (subDir) => getFilesRecursive(subDir, result)); + const files = dir.getFiles(); + const dirs = dir.getDirectories(); + for (const file of files) { + result.push(file); + } + for (const subDir of dirs) { + getFilesRecursive(subDir, result); + } } } From ad56220c4562085b0d638d731269a7b327aeffa8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 14 Jul 2016 14:17:50 -0700 Subject: [PATCH 019/508] Instantiate contextual this parameters if needed --- src/compiler/checker.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index aea8c982a95..08ee6bf4b8a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4632,6 +4632,9 @@ namespace ts { function getThisTypeOfSignature(signature: Signature): Type | undefined { if (signature.thisParameter) { + if (signature.mapper) { + signature = instantiateSignature(signature, signature.mapper); + } return getTypeOfSymbol(signature.thisParameter); } } @@ -11770,6 +11773,10 @@ namespace ts { function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (context.thisParameter) { + // save the mapper in case we need to type `this` later + context.mapper = mapper; + } for (let i = 0; i < len; i++) { const parameter = signature.parameters[i]; const contextualParameterType = getTypeAtPosition(context, i); From 78f807c7729f2c3cf092b539a597c58824f45d2a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 14 Jul 2016 14:26:10 -0700 Subject: [PATCH 020/508] Test that contextually typed generic this parameters are instantiated --- ...instantiateContextuallyTypedGenericThis.js | 20 +++++++ ...ntiateContextuallyTypedGenericThis.symbols | 44 ++++++++++++++++ ...tantiateContextuallyTypedGenericThis.types | 52 +++++++++++++++++++ ...instantiateContextuallyTypedGenericThis.ts | 11 ++++ 4 files changed, 127 insertions(+) create mode 100644 tests/baselines/reference/instantiateContextuallyTypedGenericThis.js create mode 100644 tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols create mode 100644 tests/baselines/reference/instantiateContextuallyTypedGenericThis.types create mode 100644 tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js new file mode 100644 index 00000000000..0233180873d --- /dev/null +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js @@ -0,0 +1,20 @@ +//// [instantiateContextuallyTypedGenericThis.ts] +interface JQuery { + each( + collection: T[], callback: (this: T, dit: T) => T + ): any; +} + +let $: JQuery; +let lines: string[]; +$.each(lines, function(dit) { + return dit.charAt(0) + this.charAt(1); +}); + + +//// [instantiateContextuallyTypedGenericThis.js] +var $; +var lines; +$.each(lines, function (dit) { + return dit.charAt(0) + this.charAt(1); +}); diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols new file mode 100644 index 00000000000..34a477b706a --- /dev/null +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols @@ -0,0 +1,44 @@ +=== tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts === +interface JQuery { +>JQuery : Symbol(JQuery, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 0)) + + each( +>each : Symbol(JQuery.each, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 18)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) + + collection: T[], callback: (this: T, dit: T) => T +>collection : Symbol(collection, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 12)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) +>callback : Symbol(callback, Decl(instantiateContextuallyTypedGenericThis.ts, 2, 24)) +>this : Symbol(this, Decl(instantiateContextuallyTypedGenericThis.ts, 2, 36)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) +>dit : Symbol(dit, Decl(instantiateContextuallyTypedGenericThis.ts, 2, 44)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) + + ): any; +} + +let $: JQuery; +>$ : Symbol($, Decl(instantiateContextuallyTypedGenericThis.ts, 6, 3)) +>JQuery : Symbol(JQuery, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 0)) + +let lines: string[]; +>lines : Symbol(lines, Decl(instantiateContextuallyTypedGenericThis.ts, 7, 3)) + +$.each(lines, function(dit) { +>$.each : Symbol(JQuery.each, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 18)) +>$ : Symbol($, Decl(instantiateContextuallyTypedGenericThis.ts, 6, 3)) +>each : Symbol(JQuery.each, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 18)) +>lines : Symbol(lines, Decl(instantiateContextuallyTypedGenericThis.ts, 7, 3)) +>dit : Symbol(dit, Decl(instantiateContextuallyTypedGenericThis.ts, 8, 23)) + + return dit.charAt(0) + this.charAt(1); +>dit.charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) +>dit : Symbol(dit, Decl(instantiateContextuallyTypedGenericThis.ts, 8, 23)) +>charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) +>this.charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) +>charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) + +}); + diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types new file mode 100644 index 00000000000..060d35be21a --- /dev/null +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types @@ -0,0 +1,52 @@ +=== tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts === +interface JQuery { +>JQuery : JQuery + + each( +>each : (collection: T[], callback: (this: T, dit: T) => T) => any +>T : T + + collection: T[], callback: (this: T, dit: T) => T +>collection : T[] +>T : T +>callback : (this: T, dit: T) => T +>this : T +>T : T +>dit : T +>T : T +>T : T + + ): any; +} + +let $: JQuery; +>$ : JQuery +>JQuery : JQuery + +let lines: string[]; +>lines : string[] + +$.each(lines, function(dit) { +>$.each(lines, function(dit) { return dit.charAt(0) + this.charAt(1);}) : any +>$.each : (collection: T[], callback: (this: T, dit: T) => T) => any +>$ : JQuery +>each : (collection: T[], callback: (this: T, dit: T) => T) => any +>lines : string[] +>function(dit) { return dit.charAt(0) + this.charAt(1);} : (dit: string) => string +>dit : string + + return dit.charAt(0) + this.charAt(1); +>dit.charAt(0) + this.charAt(1) : string +>dit.charAt(0) : string +>dit.charAt : (pos: number) => string +>dit : string +>charAt : (pos: number) => string +>0 : number +>this.charAt(1) : string +>this.charAt : (pos: number) => string +>this : string +>charAt : (pos: number) => string +>1 : number + +}); + diff --git a/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts b/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts new file mode 100644 index 00000000000..f25e66ecfb8 --- /dev/null +++ b/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts @@ -0,0 +1,11 @@ +interface JQuery { + each( + collection: T[], callback: (this: T, dit: T) => T + ): any; +} + +let $: JQuery; +let lines: string[]; +$.each(lines, function(dit) { + return dit.charAt(0) + this.charAt(1); +}); From 448a480aa8d592378732b1052c645b5c681fa7e3 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 12 Jul 2016 08:37:52 -0700 Subject: [PATCH 021/508] Don't allow `.ts` to appear in an import --- src/compiler/program.ts | 61 +++++++++++-------- src/harness/unittests/moduleResolution.ts | 8 +-- .../missingFunctionImplementation2.errors.txt | 2 +- .../missingFunctionImplementation2.js | 2 +- .../reference/moduleResolutionNoTs.errors.txt | 11 ++++ .../reference/moduleResolutionNoTs.js | 15 +++++ .../moduleResolutionWithExtensions.js | 7 --- .../moduleResolutionWithExtensions.symbols | 5 -- .../moduleResolutionWithExtensions.trace.json | 6 -- .../moduleResolutionWithExtensions.types | 5 -- .../staticInstanceResolution5.errors.txt | 2 +- .../reference/staticInstanceResolution5.js | 2 +- .../missingFunctionImplementation2.ts | 2 +- tests/cases/compiler/moduleResolutionNoTs.ts | 5 ++ .../compiler/staticInstanceResolution5.ts | 2 +- .../moduleResolutionWithExtensions.ts | 4 -- 16 files changed, 77 insertions(+), 62 deletions(-) create mode 100644 tests/baselines/reference/moduleResolutionNoTs.errors.txt create mode 100644 tests/baselines/reference/moduleResolutionNoTs.js create mode 100644 tests/cases/compiler/moduleResolutionNoTs.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 988714be2ab..5ddf5f7d065 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -668,24 +668,37 @@ namespace ts { * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ - function loadModuleFromFile(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string { - // First try to keep/add an extension: importing "./foo.ts" can be matched by a file "./foo.ts", and "./foo" by "./foo.d.ts" - const resolvedByAddingOrKeepingExtension = loadModuleFromFileWorker(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingOrKeepingExtension) { - return resolvedByAddingOrKeepingExtension; + function loadModuleFromFile(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string | undefined { + // If the candidate already has an extension load that or quit. + if (hasTypeScriptFileExtension(candidate)) { + // Don't allow `.ts` to appear at the end + if (!fileExtensionIs(candidate, ".d.ts")) { + return undefined; + } + return tryFile(candidate, failedLookupLocation, onlyRecordFailures, state); } - // Then try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one, e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" + + // Next, try adding an extension. + // We don't allow an import of "foo.ts" to be matched by "foo.ts.ts", but we do allow "foo.js" to be matched by "foo.js.ts". + const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; + } + + // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; + // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" if (hasJavaScriptFileExtension(candidate)) { const extensionless = removeFileExtension(candidate); if (state.traceEnabled) { const extension = candidate.substring(extensionless.length); trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return loadModuleFromFileWorker(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); } } - function loadModuleFromFileWorker(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string { + /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ + function tryAddingExtensions(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string | undefined { if (!onlyRecordFailures) { // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing const directory = getDirectoryPath(candidate); @@ -693,26 +706,24 @@ namespace ts { onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - return forEach(extensions, tryLoad); + return forEach(extensions, ext => + !(state.skipTsx && isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state)); + } - function tryLoad(ext: string): string { - if (state.skipTsx && isJsxOrTsxExtension(ext)) { - return undefined; + /** Return the file if it exists. */ + function tryFile(fileName: string, failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string | undefined { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); } - const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, Diagnostics.File_0_does_not_exist, fileName); } + failedLookupLocation.push(fileName); + return undefined; } } diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index b3f2102d903..0c312f4701a 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -465,8 +465,8 @@ export = C; "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", "/a/B/c/moduleD.ts": ` -import a = require("./moduleA.ts"); -import b = require("./moduleB.ts"); +import a = require("./moduleA"); +import b = require("./moduleB"); ` }; test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], [1149]); @@ -477,8 +477,8 @@ import b = require("./moduleB.ts"); "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", "/a/B/c/moduleD.ts": ` -import a = require("./moduleA.ts"); -import b = require("./moduleB.ts"); +import a = require("./moduleA"); +import b = require("./moduleB"); ` }; test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], []); diff --git a/tests/baselines/reference/missingFunctionImplementation2.errors.txt b/tests/baselines/reference/missingFunctionImplementation2.errors.txt index a695482e1fb..86d8baba6f7 100644 --- a/tests/baselines/reference/missingFunctionImplementation2.errors.txt +++ b/tests/baselines/reference/missingFunctionImplementation2.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/missingFunctionImplementation2_b.ts(1,17): error TS2391: Fu ==== tests/cases/compiler/missingFunctionImplementation2_a.ts (1 errors) ==== export {}; - declare module "./missingFunctionImplementation2_b.ts" { + declare module "./missingFunctionImplementation2_b" { export function f(a, b): void; ~ !!! error TS2384: Overload signatures must all be ambient or non-ambient. diff --git a/tests/baselines/reference/missingFunctionImplementation2.js b/tests/baselines/reference/missingFunctionImplementation2.js index 104b6dd9443..7b3456015c8 100644 --- a/tests/baselines/reference/missingFunctionImplementation2.js +++ b/tests/baselines/reference/missingFunctionImplementation2.js @@ -2,7 +2,7 @@ //// [missingFunctionImplementation2_a.ts] export {}; -declare module "./missingFunctionImplementation2_b.ts" { +declare module "./missingFunctionImplementation2_b" { export function f(a, b): void; } diff --git a/tests/baselines/reference/moduleResolutionNoTs.errors.txt b/tests/baselines/reference/moduleResolutionNoTs.errors.txt new file mode 100644 index 00000000000..d1d6270ae13 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoTs.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/user.ts(1,15): error TS2307: Cannot find module './m.ts'. + + +==== tests/cases/compiler/m.ts (0 errors) ==== + export default 0; + +==== tests/cases/compiler/user.ts (1 errors) ==== + import x from "./m.ts"; + ~~~~~~~~ +!!! error TS2307: Cannot find module './m.ts'. + \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionNoTs.js b/tests/baselines/reference/moduleResolutionNoTs.js new file mode 100644 index 00000000000..2a56947ce19 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoTs.js @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/moduleResolutionNoTs.ts] //// + +//// [m.ts] +export default 0; + +//// [user.ts] +import x from "./m.ts"; + + +//// [m.js] +"use strict"; +exports.__esModule = true; +exports["default"] = 0; +//// [user.js] +"use strict"; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.js b/tests/baselines/reference/moduleResolutionWithExtensions.js index df12a3531bc..16d176872ca 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions.js @@ -8,10 +8,6 @@ export default 0; //// [b.ts] import a from './a'; -// Matching extension -//// [c.ts] -import a from './a.ts'; - // '.js' extension: stripped and replaced with '.ts' //// [d.ts] import a from './a.js'; @@ -36,9 +32,6 @@ exports["default"] = 0; // No extension: '.ts' added //// [b.js] "use strict"; -// Matching extension -//// [c.js] -"use strict"; // '.js' extension: stripped and replaced with '.ts' //// [d.js] "use strict"; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.symbols b/tests/baselines/reference/moduleResolutionWithExtensions.symbols index e9934946a64..eaaa1d51cc0 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.symbols +++ b/tests/baselines/reference/moduleResolutionWithExtensions.symbols @@ -7,11 +7,6 @@ No type information for this code.=== /src/b.ts === import a from './a'; >a : Symbol(a, Decl(b.ts, 0, 6)) -// Matching extension -=== /src/c.ts === -import a from './a.ts'; ->a : Symbol(a, Decl(c.ts, 0, 6)) - // '.js' extension: stripped and replaced with '.ts' === /src/d.ts === import a from './a.js'; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions.trace.json index 7dc9e8c104b..5060006ac56 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions.trace.json @@ -5,12 +5,6 @@ "File '/src/a.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/a.ts', result '/src/a.ts'", "======== Module name './a' was successfully resolved to '/src/a.ts'. ========", - "======== Resolving module './a.ts' from '/src/c.ts'. ========", - "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/a.ts'.", - "File '/src/a.ts' exist - use it as a name resolution result.", - "Resolving real path for '/src/a.ts', result '/src/a.ts'", - "======== Module name './a.ts' was successfully resolved to '/src/a.ts'. ========", "======== Resolving module './a.js' from '/src/d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module as file / folder, candidate module location '/src/a.js'.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.types b/tests/baselines/reference/moduleResolutionWithExtensions.types index fbc0091ee3b..f59eda1a81e 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.types +++ b/tests/baselines/reference/moduleResolutionWithExtensions.types @@ -7,11 +7,6 @@ No type information for this code.=== /src/b.ts === import a from './a'; >a : number -// Matching extension -=== /src/c.ts === -import a from './a.ts'; ->a : number - // '.js' extension: stripped and replaced with '.ts' === /src/d.ts === import a from './a.js'; diff --git a/tests/baselines/reference/staticInstanceResolution5.errors.txt b/tests/baselines/reference/staticInstanceResolution5.errors.txt index da6f0fde143..f36851b2b97 100644 --- a/tests/baselines/reference/staticInstanceResolution5.errors.txt +++ b/tests/baselines/reference/staticInstanceResolution5.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/staticInstanceResolution5_1.ts(6,16): error TS2304: Cannot ==== tests/cases/compiler/staticInstanceResolution5_1.ts (3 errors) ==== - import WinJS = require('staticInstanceResolution5_0.ts'); + import WinJS = require('staticInstanceResolution5_0'); // these 3 should be errors var x = (w1: WinJS) => { }; diff --git a/tests/baselines/reference/staticInstanceResolution5.js b/tests/baselines/reference/staticInstanceResolution5.js index 0809d1af5f0..b3514e00aad 100644 --- a/tests/baselines/reference/staticInstanceResolution5.js +++ b/tests/baselines/reference/staticInstanceResolution5.js @@ -8,7 +8,7 @@ export class Promise { } //// [staticInstanceResolution5_1.ts] -import WinJS = require('staticInstanceResolution5_0.ts'); +import WinJS = require('staticInstanceResolution5_0'); // these 3 should be errors var x = (w1: WinJS) => { }; diff --git a/tests/cases/compiler/missingFunctionImplementation2.ts b/tests/cases/compiler/missingFunctionImplementation2.ts index 25909b6add4..1717bc663f2 100644 --- a/tests/cases/compiler/missingFunctionImplementation2.ts +++ b/tests/cases/compiler/missingFunctionImplementation2.ts @@ -1,6 +1,6 @@ // @Filename: missingFunctionImplementation2_a.ts export {}; -declare module "./missingFunctionImplementation2_b.ts" { +declare module "./missingFunctionImplementation2_b" { export function f(a, b): void; } diff --git a/tests/cases/compiler/moduleResolutionNoTs.ts b/tests/cases/compiler/moduleResolutionNoTs.ts new file mode 100644 index 00000000000..18b042d905f --- /dev/null +++ b/tests/cases/compiler/moduleResolutionNoTs.ts @@ -0,0 +1,5 @@ +// @filename: m.ts +export default 0; + +// @filename: user.ts +import x from "./m.ts"; diff --git a/tests/cases/compiler/staticInstanceResolution5.ts b/tests/cases/compiler/staticInstanceResolution5.ts index 3adb8667be5..ed34dbd535f 100644 --- a/tests/cases/compiler/staticInstanceResolution5.ts +++ b/tests/cases/compiler/staticInstanceResolution5.ts @@ -7,7 +7,7 @@ export class Promise { } // @Filename: staticInstanceResolution5_1.ts -import WinJS = require('staticInstanceResolution5_0.ts'); +import WinJS = require('staticInstanceResolution5_0'); // these 3 should be errors var x = (w1: WinJS) => { }; diff --git a/tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts b/tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts index 6ad35658623..429289546c5 100644 --- a/tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts +++ b/tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts @@ -7,10 +7,6 @@ export default 0; // @Filename: /src/b.ts import a from './a'; -// Matching extension -// @Filename: /src/c.ts -import a from './a.ts'; - // '.js' extension: stripped and replaced with '.ts' // @Filename: /src/d.ts import a from './a.js'; From a8c05a98e98b0e2f7d50d983ac08d385d6dd3641 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 12 Jul 2016 11:11:03 -0700 Subject: [PATCH 022/508] Add specific error message for unwanted '.ts' extension --- src/compiler/checker.ts | 7 ++++++- src/compiler/core.ts | 3 ++- src/compiler/diagnosticMessages.json | 4 ++++ src/compiler/utilities.ts | 4 ++++ .../reference/moduleResolutionNoTs.errors.txt | 13 ++++++++----- tests/baselines/reference/moduleResolutionNoTs.js | 5 +++++ tests/cases/compiler/moduleResolutionNoTs.ts | 3 +++ 7 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1cebd469388..88565bcba92 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1342,7 +1342,12 @@ namespace ts { if (moduleNotFoundError) { // report errors only if it was requested - error(moduleReferenceLiteral, moduleNotFoundError, moduleName); + if (hasTypeScriptFileExtensionNonDts(moduleName)) { + error(moduleReferenceLiteral, Diagnostics.Module_name_should_not_include_a_ts_extension_Colon_0, moduleName); + } + else { + error(moduleReferenceLiteral, moduleNotFoundError, moduleName); + } } return undefined; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 926ee38a795..9b12f6a7f68 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1144,7 +1144,8 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"]; + export const supportedTypeScriptExtensionsNonDts = [".ts", ".tsx"]; + export const supportedTypeScriptExtensions = supportedTypeScriptExtensionsNonDts.concat([".d.ts"]); export const supportedJavascriptExtensions = [".js", ".jsx"]; const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8ffb02a8974..d85dc20afdf 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1943,6 +1943,10 @@ "category": "Error", "code": 2689 }, + "Module name should not include a '.ts' extension: '{0}'.": { + "category": "Error", + "code": 2690 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7219a5bbd24..bfe8e4bd657 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2726,6 +2726,10 @@ namespace ts { return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension)); } + export function hasTypeScriptFileExtensionNonDts(fileName: string) { + return forEach(supportedTypeScriptExtensionsNonDts, extension => fileExtensionIs(fileName, extension)); + } + /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences * representing the UTF-8 encoding of the character, and return the expanded char code list. diff --git a/tests/baselines/reference/moduleResolutionNoTs.errors.txt b/tests/baselines/reference/moduleResolutionNoTs.errors.txt index d1d6270ae13..de105f73539 100644 --- a/tests/baselines/reference/moduleResolutionNoTs.errors.txt +++ b/tests/baselines/reference/moduleResolutionNoTs.errors.txt @@ -1,11 +1,14 @@ -tests/cases/compiler/user.ts(1,15): error TS2307: Cannot find module './m.ts'. +tests/cases/compiler/user.ts(4,15): error TS2690: Module name should not include a '.ts' extension: './m.ts'. -==== tests/cases/compiler/m.ts (0 errors) ==== - export default 0; - ==== tests/cases/compiler/user.ts (1 errors) ==== + // '.ts' extension is OK in a reference + /// + import x from "./m.ts"; ~~~~~~~~ -!!! error TS2307: Cannot find module './m.ts'. +!!! error TS2690: Module name should not include a '.ts' extension: './m.ts'. + +==== tests/cases/compiler/m.ts (0 errors) ==== + export default 0; \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionNoTs.js b/tests/baselines/reference/moduleResolutionNoTs.js index 2a56947ce19..8a912f33011 100644 --- a/tests/baselines/reference/moduleResolutionNoTs.js +++ b/tests/baselines/reference/moduleResolutionNoTs.js @@ -4,6 +4,9 @@ export default 0; //// [user.ts] +// '.ts' extension is OK in a reference +/// + import x from "./m.ts"; @@ -12,4 +15,6 @@ import x from "./m.ts"; exports.__esModule = true; exports["default"] = 0; //// [user.js] +// '.ts' extension is OK in a reference +/// "use strict"; diff --git a/tests/cases/compiler/moduleResolutionNoTs.ts b/tests/cases/compiler/moduleResolutionNoTs.ts index 18b042d905f..29d81589cd9 100644 --- a/tests/cases/compiler/moduleResolutionNoTs.ts +++ b/tests/cases/compiler/moduleResolutionNoTs.ts @@ -2,4 +2,7 @@ export default 0; // @filename: user.ts +// '.ts' extension is OK in a reference +/// + import x from "./m.ts"; From 95e391ec72f289e5049d7601af758bdc7b0dcc69 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 22 Jul 2016 05:56:05 -0700 Subject: [PATCH 023/508] Allow `await` in a simple unary expression --- src/compiler/parser.ts | 2 ++ tests/baselines/reference/castOfAwait.js | 20 +++++++++++++++++++ tests/baselines/reference/castOfAwait.symbols | 7 +++++++ tests/baselines/reference/castOfAwait.types | 10 ++++++++++ tests/cases/compiler/castOfAwait.ts | 4 ++++ 5 files changed, 43 insertions(+) create mode 100644 tests/baselines/reference/castOfAwait.js create mode 100644 tests/baselines/reference/castOfAwait.symbols create mode 100644 tests/baselines/reference/castOfAwait.types create mode 100644 tests/cases/compiler/castOfAwait.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 774cea60e09..8545273afec 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3400,6 +3400,8 @@ namespace ts { return parseTypeOfExpression(); case SyntaxKind.VoidKeyword: return parseVoidExpression(); + case SyntaxKind.AwaitKeyword: + return parseAwaitExpression(); case SyntaxKind.LessThanToken: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): diff --git a/tests/baselines/reference/castOfAwait.js b/tests/baselines/reference/castOfAwait.js new file mode 100644 index 00000000000..8833a6aa972 --- /dev/null +++ b/tests/baselines/reference/castOfAwait.js @@ -0,0 +1,20 @@ +//// [castOfAwait.ts] +async function f() { + return await 0; +} + + +//// [castOfAwait.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function f() { + return __awaiter(this, void 0, void 0, function* () { + return yield 0; + }); +} diff --git a/tests/baselines/reference/castOfAwait.symbols b/tests/baselines/reference/castOfAwait.symbols new file mode 100644 index 00000000000..b6ee77ac793 --- /dev/null +++ b/tests/baselines/reference/castOfAwait.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/castOfAwait.ts === +async function f() { +>f : Symbol(f, Decl(castOfAwait.ts, 0, 0)) + + return await 0; +} + diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types new file mode 100644 index 00000000000..7b6d8ef035b --- /dev/null +++ b/tests/baselines/reference/castOfAwait.types @@ -0,0 +1,10 @@ +=== tests/cases/compiler/castOfAwait.ts === +async function f() { +>f : () => Promise + + return await 0; +> await 0 : number +>await 0 : number +>0 : number +} + diff --git a/tests/cases/compiler/castOfAwait.ts b/tests/cases/compiler/castOfAwait.ts new file mode 100644 index 00000000000..64e96be70f3 --- /dev/null +++ b/tests/cases/compiler/castOfAwait.ts @@ -0,0 +1,4 @@ +// @target: es6 +async function f() { + return await 0; +} From aded015c38dd78fa7e39a586ff98afb3505768ff Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 22 Jul 2016 08:43:34 -0700 Subject: [PATCH 024/508] Clarify code checking for UMD exports and eagerly return `undefined` rather than continuing on to the for loop. --- src/compiler/checker.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1cebd469388..552e85abfa6 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17713,14 +17713,17 @@ namespace ts { const parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) { + const symbolFile = parentSymbol.valueDeclaration; + const referenceFile = getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. - if (parentSymbol.valueDeclaration === getSourceFileOfNode(node)) { - return parentSymbol.valueDeclaration; - } + const symbolIsUmdExport = symbolFile !== referenceFile; + return symbolIsUmdExport ? undefined : symbolFile; } - for (let n = node.parent; n; n = n.parent) { - if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) { - return n; + else { + for (let n = node.parent; n; n = n.parent) { + if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) { + return n; + } } } } From bc5c7b654ad876f7a75422c58cbbc2d331bdf5f7 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 22 Jul 2016 13:33:22 -0700 Subject: [PATCH 025/508] More tests --- src/compiler/parser.ts | 1 + tests/baselines/reference/castOfAwait.js | 10 ++++++-- tests/baselines/reference/castOfAwait.symbols | 5 +++- tests/baselines/reference/castOfAwait.types | 24 +++++++++++++++++-- .../reference/castOfYield.errors.txt | 12 ++++++++++ tests/baselines/reference/castOfYield.js | 15 ++++++++++++ tests/cases/compiler/castOfAwait.ts | 5 +++- tests/cases/compiler/castOfYield.ts | 5 ++++ 8 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/castOfYield.errors.txt create mode 100644 tests/baselines/reference/castOfYield.js create mode 100644 tests/cases/compiler/castOfYield.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 8545273afec..61c7698c59d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3386,6 +3386,7 @@ namespace ts { * 6) - UnaryExpression[?yield] * 7) ~ UnaryExpression[?yield] * 8) ! UnaryExpression[?yield] + * 9) await AwaitExpression[?yield] */ function parseSimpleUnaryExpression(): UnaryExpression { switch (token) { diff --git a/tests/baselines/reference/castOfAwait.js b/tests/baselines/reference/castOfAwait.js index 8833a6aa972..9d1399d9d65 100644 --- a/tests/baselines/reference/castOfAwait.js +++ b/tests/baselines/reference/castOfAwait.js @@ -1,6 +1,9 @@ //// [castOfAwait.ts] async function f() { - return await 0; + await 0; + typeof await 0; + void await 0; + await void typeof void await 0; } @@ -15,6 +18,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; function f() { return __awaiter(this, void 0, void 0, function* () { - return yield 0; + yield 0; + typeof yield 0; + void yield 0; + yield void typeof void yield 0; }); } diff --git a/tests/baselines/reference/castOfAwait.symbols b/tests/baselines/reference/castOfAwait.symbols index b6ee77ac793..d0bca9f38c7 100644 --- a/tests/baselines/reference/castOfAwait.symbols +++ b/tests/baselines/reference/castOfAwait.symbols @@ -2,6 +2,9 @@ async function f() { >f : Symbol(f, Decl(castOfAwait.ts, 0, 0)) - return await 0; + await 0; + typeof await 0; + void await 0; + await void typeof void await 0; } diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types index 7b6d8ef035b..ba1590fe03d 100644 --- a/tests/baselines/reference/castOfAwait.types +++ b/tests/baselines/reference/castOfAwait.types @@ -1,10 +1,30 @@ === tests/cases/compiler/castOfAwait.ts === async function f() { ->f : () => Promise +>f : () => Promise - return await 0; + await 0; > await 0 : number >await 0 : number +>0 : number + + typeof await 0; +>typeof await 0 : string +>await 0 : number +>0 : number + + void await 0; +>void await 0 : undefined +>await 0 : number +>0 : number + + await void typeof void await 0; +>await void typeof void await 0 : any +>void typeof void await 0 : undefined +> typeof void await 0 : string +>typeof void await 0 : string +> void await 0 : number +>void await 0 : undefined +>await 0 : number >0 : number } diff --git a/tests/baselines/reference/castOfYield.errors.txt b/tests/baselines/reference/castOfYield.errors.txt new file mode 100644 index 00000000000..abafe678784 --- /dev/null +++ b/tests/baselines/reference/castOfYield.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/castOfYield.ts(4,14): error TS1109: Expression expected. + + +==== tests/cases/compiler/castOfYield.ts (1 errors) ==== + function* f() { + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + yield 0; + ~~~~~ +!!! error TS1109: Expression expected. + } + \ No newline at end of file diff --git a/tests/baselines/reference/castOfYield.js b/tests/baselines/reference/castOfYield.js new file mode 100644 index 00000000000..652cf28e9e1 --- /dev/null +++ b/tests/baselines/reference/castOfYield.js @@ -0,0 +1,15 @@ +//// [castOfYield.ts] +function* f() { + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + yield 0; +} + + +//// [castOfYield.js] +function f() { + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + ; + yield 0; +} diff --git a/tests/cases/compiler/castOfAwait.ts b/tests/cases/compiler/castOfAwait.ts index 64e96be70f3..6a152226ea2 100644 --- a/tests/cases/compiler/castOfAwait.ts +++ b/tests/cases/compiler/castOfAwait.ts @@ -1,4 +1,7 @@ // @target: es6 async function f() { - return await 0; + await 0; + typeof await 0; + void await 0; + await void typeof void await 0; } diff --git a/tests/cases/compiler/castOfYield.ts b/tests/cases/compiler/castOfYield.ts new file mode 100644 index 00000000000..9a85e6b21c2 --- /dev/null +++ b/tests/cases/compiler/castOfYield.ts @@ -0,0 +1,5 @@ +function* f() { + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + yield 0; +} From b58f4dd9282026385059e6a58d1b08674de862f5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 22 Jul 2016 13:37:25 -0700 Subject: [PATCH 026/508] Respond to PR comments --- src/compiler/checker.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 552e85abfa6..63087c910a3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17697,7 +17697,7 @@ namespace ts { // When resolved as an expression identifier, if the given node references an exported entity, return the declaration // node of the exported entity's container. Otherwise, return undefined. - function getReferencedExportContainer(node: Identifier): SourceFile | ModuleDeclaration | EnumDeclaration { + function getReferencedExportContainer(node: Identifier): SourceFile | ModuleDeclaration | EnumDeclaration | undefined { let symbol = getReferencedValueSymbol(node); if (symbol) { if (symbol.flags & SymbolFlags.ExportValue) { @@ -17713,21 +17713,21 @@ namespace ts { const parentSymbol = getParentOfSymbol(symbol); if (parentSymbol) { if (parentSymbol.flags & SymbolFlags.ValueModule && parentSymbol.valueDeclaration.kind === SyntaxKind.SourceFile) { - const symbolFile = parentSymbol.valueDeclaration; + const symbolFile = parentSymbol.valueDeclaration; const referenceFile = getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. const symbolIsUmdExport = symbolFile !== referenceFile; return symbolIsUmdExport ? undefined : symbolFile; } - else { - for (let n = node.parent; n; n = n.parent) { - if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) { - return n; - } + + for (let n = node.parent; n; n = n.parent) { + if ((n.kind === SyntaxKind.ModuleDeclaration || n.kind === SyntaxKind.EnumDeclaration) && getSymbolOfNode(n) === parentSymbol) { + return n; } } } } + return undefined; } // When resolved as an expression identifier, if the given node references an import, return the declaration of From 275dbc7537accc869da2e47d7f62c519ee223ad4 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 22 Jul 2016 14:01:59 -0700 Subject: [PATCH 027/508] Forbid `await await` --- src/compiler/parser.ts | 5 ++++- .../baselines/reference/awaitAwait.errors.txt | 10 +++++++++ tests/baselines/reference/awaitAwait.js | 21 +++++++++++++++++++ tests/cases/compiler/awaitAwait.ts | 4 ++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/awaitAwait.errors.txt create mode 100644 tests/baselines/reference/awaitAwait.js create mode 100644 tests/cases/compiler/awaitAwait.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 61c7698c59d..9c54de6ba13 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3337,7 +3337,10 @@ namespace ts { function parseAwaitExpression() { const node = createNode(SyntaxKind.AwaitExpression); nextToken(); - node.expression = parseSimpleUnaryExpression(); + node.expression = token === SyntaxKind.AwaitKeyword + // Forbid `await await` + ? createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics.Expression_expected) + : parseSimpleUnaryExpression(); return finishNode(node); } diff --git a/tests/baselines/reference/awaitAwait.errors.txt b/tests/baselines/reference/awaitAwait.errors.txt new file mode 100644 index 00000000000..5a04051139c --- /dev/null +++ b/tests/baselines/reference/awaitAwait.errors.txt @@ -0,0 +1,10 @@ +tests/cases/compiler/awaitAwait.ts(2,11): error TS1109: Expression expected. + + +==== tests/cases/compiler/awaitAwait.ts (1 errors) ==== + async function f() { + await await 0; + ~~~~~ +!!! error TS1109: Expression expected. + } + \ No newline at end of file diff --git a/tests/baselines/reference/awaitAwait.js b/tests/baselines/reference/awaitAwait.js new file mode 100644 index 00000000000..14fb3a11505 --- /dev/null +++ b/tests/baselines/reference/awaitAwait.js @@ -0,0 +1,21 @@ +//// [awaitAwait.ts] +async function f() { + await await 0; +} + + +//// [awaitAwait.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function f() { + return __awaiter(this, void 0, void 0, function* () { + yield ; + yield 0; + }); +} diff --git a/tests/cases/compiler/awaitAwait.ts b/tests/cases/compiler/awaitAwait.ts new file mode 100644 index 00000000000..5a405804b00 --- /dev/null +++ b/tests/cases/compiler/awaitAwait.ts @@ -0,0 +1,4 @@ +// @target: es6 +async function f() { + await await 0; +} From 52fd0334be9439d459757660b4b6cdf1e2778c6d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 25 Jul 2016 11:08:02 -0700 Subject: [PATCH 028/508] Allow `await await` --- src/compiler/parser.ts | 7 ++----- .../baselines/reference/awaitAwait.errors.txt | 10 --------- tests/baselines/reference/awaitAwait.js | 21 ------------------- tests/baselines/reference/castOfAwait.js | 2 ++ tests/baselines/reference/castOfAwait.symbols | 1 + tests/baselines/reference/castOfAwait.types | 5 +++++ tests/cases/compiler/awaitAwait.ts | 4 ---- tests/cases/compiler/castOfAwait.ts | 1 + 8 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 tests/baselines/reference/awaitAwait.errors.txt delete mode 100644 tests/baselines/reference/awaitAwait.js delete mode 100644 tests/cases/compiler/awaitAwait.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 9c54de6ba13..68753fdb638 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3337,10 +3337,7 @@ namespace ts { function parseAwaitExpression() { const node = createNode(SyntaxKind.AwaitExpression); nextToken(); - node.expression = token === SyntaxKind.AwaitKeyword - // Forbid `await await` - ? createMissingNode(SyntaxKind.Identifier, /*reportAtCurrentPosition*/ false, Diagnostics.Expression_expected) - : parseSimpleUnaryExpression(); + node.expression = parseSimpleUnaryExpression(); return finishNode(node); } @@ -3389,7 +3386,7 @@ namespace ts { * 6) - UnaryExpression[?yield] * 7) ~ UnaryExpression[?yield] * 8) ! UnaryExpression[?yield] - * 9) await AwaitExpression[?yield] + * 9) [+Await] await AwaitExpression[?yield] */ function parseSimpleUnaryExpression(): UnaryExpression { switch (token) { diff --git a/tests/baselines/reference/awaitAwait.errors.txt b/tests/baselines/reference/awaitAwait.errors.txt deleted file mode 100644 index 5a04051139c..00000000000 --- a/tests/baselines/reference/awaitAwait.errors.txt +++ /dev/null @@ -1,10 +0,0 @@ -tests/cases/compiler/awaitAwait.ts(2,11): error TS1109: Expression expected. - - -==== tests/cases/compiler/awaitAwait.ts (1 errors) ==== - async function f() { - await await 0; - ~~~~~ -!!! error TS1109: Expression expected. - } - \ No newline at end of file diff --git a/tests/baselines/reference/awaitAwait.js b/tests/baselines/reference/awaitAwait.js deleted file mode 100644 index 14fb3a11505..00000000000 --- a/tests/baselines/reference/awaitAwait.js +++ /dev/null @@ -1,21 +0,0 @@ -//// [awaitAwait.ts] -async function f() { - await await 0; -} - - -//// [awaitAwait.js] -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments)).next()); - }); -}; -function f() { - return __awaiter(this, void 0, void 0, function* () { - yield ; - yield 0; - }); -} diff --git a/tests/baselines/reference/castOfAwait.js b/tests/baselines/reference/castOfAwait.js index 9d1399d9d65..95817b7f0e6 100644 --- a/tests/baselines/reference/castOfAwait.js +++ b/tests/baselines/reference/castOfAwait.js @@ -4,6 +4,7 @@ async function f() { typeof await 0; void await 0; await void typeof void await 0; + await await 0; } @@ -22,5 +23,6 @@ function f() { typeof yield 0; void yield 0; yield void typeof void yield 0; + yield yield 0; }); } diff --git a/tests/baselines/reference/castOfAwait.symbols b/tests/baselines/reference/castOfAwait.symbols index d0bca9f38c7..574ee21f773 100644 --- a/tests/baselines/reference/castOfAwait.symbols +++ b/tests/baselines/reference/castOfAwait.symbols @@ -6,5 +6,6 @@ async function f() { typeof await 0; void await 0; await void typeof void await 0; + await await 0; } diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types index ba1590fe03d..ad3597f6c01 100644 --- a/tests/baselines/reference/castOfAwait.types +++ b/tests/baselines/reference/castOfAwait.types @@ -25,6 +25,11 @@ async function f() { > void await 0 : number >void await 0 : undefined >await 0 : number +>0 : number + + await await 0; +>await await 0 : number +>await 0 : number >0 : number } diff --git a/tests/cases/compiler/awaitAwait.ts b/tests/cases/compiler/awaitAwait.ts deleted file mode 100644 index 5a405804b00..00000000000 --- a/tests/cases/compiler/awaitAwait.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: es6 -async function f() { - await await 0; -} diff --git a/tests/cases/compiler/castOfAwait.ts b/tests/cases/compiler/castOfAwait.ts index 6a152226ea2..fcd8f999e9f 100644 --- a/tests/cases/compiler/castOfAwait.ts +++ b/tests/cases/compiler/castOfAwait.ts @@ -4,4 +4,5 @@ async function f() { typeof await 0; void await 0; await void typeof void await 0; + await await 0; } From 84a10e439ea895afcbdaa5494305f3f2533db7fd Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 25 Jul 2016 12:57:17 -0700 Subject: [PATCH 029/508] Some PR feedback --- src/services/services.ts | 61 +++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index d440f194b70..7024dc7211b 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1665,6 +1665,10 @@ namespace ts { export const constElement = "const"; export const letElement = "let"; + + export const directory = "directory"; + + export const externalModuleName = "external module name"; } export namespace ScriptElementKindModifier { @@ -4378,7 +4382,7 @@ namespace ts { return { isMemberCompletion: false, - isNewIdentifierLocation: false, + isNewIdentifierLocation: true, entries: result }; } @@ -4389,44 +4393,46 @@ namespace ts { const toComplete = getBaseFileName(fragment); const absolutePath = normalizeSlashes(host.resolvePath(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment))); - const baseDir = toComplete ? getDirectoryPath(absolutePath) : absolutePath; + const baseDirectory = toComplete ? getDirectoryPath(absolutePath) : absolutePath; - if (directoryProbablyExists(baseDir, host)) { + if (directoryProbablyExists(baseDirectory, host)) { // Enumerate the available files - const files = host.readDirectory(baseDir, extensions, /*exclude*/undefined, /*include*/["./*"]); - forEach(files, (f) => { - const fName = includeExtensions ? getBaseFileName(f) : removeFileExtension(getBaseFileName(f)); + const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); + forEach(files, f => { + const fileName = includeExtensions ? getBaseFileName(f) : removeFileExtension(getBaseFileName(f)); - if (startsWith(fName, toComplete)) { + const duplicate = includeExtensions ? false : forEach(result, entry => entry.name === fileName); + + if (startsWith(fileName, toComplete) && !duplicate) { result.push({ - name: fName, - kind: ScriptElementKind.unknown, + name: fileName, + kind: ScriptElementKind.directory, kindModifiers: ScriptElementKindModifier.none, - sortText: fName + sortText: fileName }); } }); // If possible, get folder completion as well if (host.getDirectories) { - const directories = host.getDirectories(baseDir); - forEach(directories, (d) => { - const dName = getBaseFileName(removeTrailingDirectorySeparator(d)); + const directories = host.getDirectories(baseDirectory); + forEach(directories, d => { + const directoryName = getBaseFileName(removeTrailingDirectorySeparator(d)); - if (startsWith(dName, toComplete)) { + if (startsWith(directoryName, toComplete)) { result.push({ - name: ensureTrailingDirectorySeparator(dName), - kind: ScriptElementKind.unknown, + name: ensureTrailingDirectorySeparator(directoryName), + kind: ScriptElementKind.directory, kindModifiers: ScriptElementKindModifier.none, - sortText: dName + sortText: directoryName }); } }); } } - return includeExtensions ? result : deduplicate(result, (a, b) => a.name === b.name); + return result; } /** @@ -4439,36 +4445,27 @@ namespace ts { return ts.map(enumeratePotentialNonRelativeModules(fragment, scriptPath), (moduleName) => { return { name: moduleName, - kind: ScriptElementKind.unknown, + kind: ScriptElementKind.externalModuleName, kindModifiers: ScriptElementKindModifier.none, sortText: moduleName }; }); } - function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string) { - const ambientSymbolNameRegex = /^"(.+?)"$/; - + function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string): string[] { // If this is a nested module, get the module name const firstSeparator = fragment.indexOf(directorySeparator); const moduleNameFragment = firstSeparator !== -1 ? fragment.substr(0, firstSeparator) : fragment; const isNestedModule = fragment !== moduleNameFragment; // Get modules that the type checker picked up - const ambientModules = ts.map(program.getTypeChecker().getAmbientModules(), (sym) => { - const match = ambientSymbolNameRegex.exec(sym.name); - if (match) { - return match[1]; - } - // This should never happen - return sym.name; - }); - let nonRelativeModules = ts.filter(ambientModules, (moduleName) => startsWith(moduleName, fragment)); + const ambientModules = ts.map(program.getTypeChecker().getAmbientModules(), sym => stripQuotes(sym.name)); + let nonRelativeModules = ts.filter(ambientModules, moduleName => startsWith(moduleName, fragment)); // Nested modules of the form "module-name/sub" need to be adjusted to only return the string // after the last '/' that appears in the fragment because editors insert the completion // only after that character - nonRelativeModules = ts.map(nonRelativeModules, (moduleName) => { + nonRelativeModules = ts.map(nonRelativeModules, moduleName => { if (moduleName.indexOf(directorySeparator) !== -1) { if (isNestedModule) { return moduleName.substr(fragment.lastIndexOf(directorySeparator) + 1); From ed2da32776449eef338fe535b5f0c662b82a7944 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 26 Jul 2016 13:43:29 -0700 Subject: [PATCH 030/508] Handling more compiler options and minor refactor --- src/harness/fourslash.ts | 34 ++- src/services/services.ts | 208 +++++++++++++++++- src/services/utilities.ts | 103 --------- ...etionForStringLiteralNonrelativeImport7.ts | 27 +++ ...etionForStringLiteralNonrelativeImport8.ts | 53 +++++ ...etionForStringLiteralNonrelativeImport9.ts | 34 +++ 6 files changed, 341 insertions(+), 118 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a42abbbc609..87b537417ea 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -245,14 +245,7 @@ namespace FourSlash { constructor(private basePath: string, private testType: FourSlashTestType, public testData: FourSlashData) { // Create a new Services Adapter this.cancellationToken = new TestCancellationToken(); - const compilationOptions = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions); - if (compilationOptions.typeRoots) { - compilationOptions.typeRoots = compilationOptions.typeRoots.map(p => ts.getNormalizedAbsolutePath(p, this.basePath)); - } - - const languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions); - this.languageServiceAdapterHost = languageServiceAdapter.getHost(); - this.languageService = languageServiceAdapter.getLanguageService(); + let compilationOptions = convertGlobalOptionsToCompilerOptions(this.testData.globalOptions); // Initialize the language service with all the scripts let startResolveFileRef: FourSlashFile; @@ -260,6 +253,22 @@ namespace FourSlash { ts.forEach(testData.files, file => { // Create map between fileName and its content for easily looking up when resolveReference flag is specified this.inputFiles[file.fileName] = file.content; + + if (ts.getBaseFileName(file.fileName).toLowerCase() === "tsconfig.json") { + const configJson = ts.parseConfigFileTextToJson(file.fileName, file.content); + assert.isTrue(configJson.config !== undefined); + + // Extend our existing compiler options so that we can also support tsconfig only options + if (configJson.config.compilerOptions) { + let baseDir = ts.normalizePath(ts.getDirectoryPath(file.fileName)); + let tsConfig = ts.convertCompilerOptionsFromJson(configJson.config.compilerOptions, baseDir, file.fileName); + + if (!tsConfig.errors || !tsConfig.errors.length) { + compilationOptions = ts.extend(compilationOptions, tsConfig.options); + } + } + } + if (!startResolveFileRef && file.fileOptions[metadataOptionNames.resolveReference] === "true") { startResolveFileRef = file; } @@ -269,6 +278,15 @@ namespace FourSlash { } }); + + if (compilationOptions.typeRoots) { + compilationOptions.typeRoots = compilationOptions.typeRoots.map(p => ts.getNormalizedAbsolutePath(p, this.basePath)); + } + + const languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions); + this.languageServiceAdapterHost = languageServiceAdapter.getHost(); + this.languageService = languageServiceAdapter.getLanguageService(); + if (startResolveFileRef) { // Add the entry-point file itself into the languageServiceShimHost this.languageServiceAdapterHost.addScript(startResolveFileRef.fileName, startResolveFileRef.content, /*isRootFile*/ true); diff --git a/src/services/services.ts b/src/services/services.ts index 7024dc7211b..275c41732c1 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1757,6 +1757,12 @@ namespace ts { owners: string[]; } + interface VisibleModuleInfo { + moduleName: string; + moduleDir: string; + canBeImported: boolean; + } + export interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } @@ -4438,18 +4444,100 @@ namespace ts { /** * Check all of the declared modules and those in node modules. Possible sources of modules: * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) * Modules from node_modules (i.e. those listed in package.json) * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions */ function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string): CompletionEntry[] { - return ts.map(enumeratePotentialNonRelativeModules(fragment, scriptPath), (moduleName) => { - return { - name: moduleName, - kind: ScriptElementKind.externalModuleName, - kindModifiers: ScriptElementKindModifier.none, - sortText: moduleName - }; + const options = program.getCompilerOptions(); + const { baseUrl, paths } = options; + + let result: CompletionEntry[]; + + if (baseUrl) { + const fileExtensions = getSupportedExtensions(options); + const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(host.getCurrentDirectory(), baseUrl) + result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false); + + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + forEach(paths[path], pattern => { + forEach(getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions), match => { + result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName)); + }); + }); + } + } + else if (startsWith(path, fragment)) { + const entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName)); + } + } + } + } + } + } + else { + result = []; + } + + + + forEach(enumeratePotentialNonRelativeModules(fragment, scriptPath), moduleName => { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); }); + + return result; + } + + function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[]): string[] { + const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; + if (parsed) { + const hasTrailingSlash = parsed.prefix.charAt(parsed.prefix.length - 1) === "/" || parsed.prefix.charAt(parsed.prefix.length - 1) === "\\"; + + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + const normalizedPrefix = hasTrailingSlash ? ensureTrailingDirectorySeparator(normalizePath(parsed.prefix)) : normalizePath(parsed.prefix); + const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); + const normalizedPrefixBase = getBaseFileName(normalizedPrefix); + + const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; + + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + const expandedPrefixDir = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; + + const normalizedSuffix = normalizePath(parsed.suffix); + const baseDirectory = combinePaths(baseUrl, expandedPrefixDir); + const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + const includeGlob = normalizedSuffix ? "**/*" : "./*" + + const matches = host.readDirectory(baseDirectory, fileExtensions, undefined, [includeGlob]); + const result: string[] = []; + + // Trim away prefix and suffix + forEach(matches, match => { + const normalizedMatch = normalizePath(match); + if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { + return; + } + + const start = completePrefix.length; + const length = normalizedMatch.length - start - normalizedSuffix.length; + + result.push(removeFileExtension(normalizedMatch.substr(start, length))); + }); + return result; + } + + return undefined; } function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string): string[] { @@ -4513,6 +4601,112 @@ namespace ts { } } + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string, modulePrefix?: string) { + const result: VisibleModuleInfo[] = []; + findPackageJsons(scriptPath).forEach((packageJson) => { + const package = tryReadingPackageJson(packageJson); + if (!package) { + return; + } + + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; + + if (package.dependencies) { + addPotentialPackageNames(package.dependencies, modulePrefix, foundModuleNames); + } + if (package.devDependencies) { + addPotentialPackageNames(package.devDependencies, modulePrefix, foundModuleNames); + } + + forEach(foundModuleNames, (moduleName) => { + const moduleDir = combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName, + moduleDir, + canBeImported: moduleCanBeImported(moduleDir) + }); + }); + }); + + return result; + + function findPackageJsons(currentDir: string): string[] { + const paths: string[] = []; + let currentConfigPath: string; + while (true) { + currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + + currentDir = getDirectoryPath(currentConfigPath); + const parent = getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + + return paths; + } + + function tryReadingPackageJson(filePath: string) { + try { + const fileText = host.readFile(filePath); + return JSON.parse(fileText); + } + catch (e) { + return undefined; + } + } + + function addPotentialPackageNames(dependencies: any, prefix: string, result: string[]) { + for (const dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && (!prefix || startsWith(dep, prefix))) { + result.push(dep); + } + } + } + + /* + * A module can be imported by name alone if one of the following is true: + * It defines the "typings" property in its package.json + * The module has a "main" export and an index.d.ts file + * The module has an index.ts + */ + function moduleCanBeImported(modulePath: string): boolean { + const packagePath = combinePaths(modulePath, "package.json"); + + let hasMainExport = false; + if (host.fileExists(packagePath)) { + const package = tryReadingPackageJson(packagePath); + if (package) { + if (package.typings) { + return true; + } + hasMainExport = !!package.main; + } + } + + hasMainExport = hasMainExport || host.fileExists(combinePaths(modulePath, "index.js")); + + return (hasMainExport && host.fileExists(combinePaths(modulePath, "index.d.ts"))) || host.fileExists(combinePaths(modulePath, "index.ts")); + } + } + + function createCompletionEntryForModule(name: string, kind: string): CompletionEntry { + return { + name, + kind, + kindModifiers: ScriptElementKindModifier.none, + sortText: name + } + } + function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { synchronizeHostData(); diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 44423860d4a..0c4c0fd1dea 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -6,12 +6,6 @@ namespace ts { list: Node; } - export interface VisibleModuleInfo { - moduleName: string; - moduleDir: string; - canBeImported: boolean; - } - export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number { const lineStarts = sourceFile.getLineStarts(); const line = sourceFile.getLineAndCharacterOfPosition(position).line; @@ -933,101 +927,4 @@ namespace ts { } return ensureScriptKind(fileName, scriptKind); } - - export function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string, modulePrefix?: string) { - const result: VisibleModuleInfo[] = []; - findPackageJsons(scriptPath).forEach((packageJson) => { - const package = tryReadingPackageJson(packageJson); - if (!package) { - return; - } - - const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); - const foundModuleNames: string[] = []; - - if (package.dependencies) { - addPotentialPackageNames(package.dependencies, modulePrefix, foundModuleNames); - } - if (package.devDependencies) { - addPotentialPackageNames(package.devDependencies, modulePrefix, foundModuleNames); - } - - forEach(foundModuleNames, (moduleName) => { - const moduleDir = combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName, - moduleDir, - canBeImported: moduleCanBeImported(moduleDir) - }); - }); - }); - - return result; - - function findPackageJsons(currentDir: string): string[] { - const paths: string[] = []; - let currentConfigPath: string; - while (true) { - currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - - currentDir = getDirectoryPath(currentConfigPath); - const parent = getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } - - return paths; - } - - function tryReadingPackageJson(filePath: string) { - try { - const fileText = host.readFile(filePath); - return JSON.parse(fileText); - } - catch (e) { - return undefined; - } - } - - function addPotentialPackageNames(dependencies: any, prefix: string, result: string[]) { - for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && (!prefix || startsWith(dep, prefix))) { - result.push(dep); - } - } - } - - /* - * A module can be imported by name alone if one of the following is true: - * It defines the "typings" property in its package.json - * The module has a "main" export and an index.d.ts file - * The module has an index.ts - */ - function moduleCanBeImported(modulePath: string): boolean { - const packagePath = combinePaths(modulePath, "package.json"); - - let hasMainExport = false; - if (host.fileExists(packagePath)) { - const package = tryReadingPackageJson(packagePath); - if (package) { - if (package.typings) { - return true; - } - hasMainExport = !!package.main; - } - } - - hasMainExport = hasMainExport || host.fileExists(combinePaths(modulePath, "index.js")); - - return (hasMainExport && host.fileExists(combinePaths(modulePath, "index.d.ts"))) || host.fileExists(combinePaths(modulePath, "index.ts")); - } - } } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts new file mode 100644 index 00000000000..35e144c7184 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts @@ -0,0 +1,27 @@ +/// +// @baseUrl: tests/cases/fourslash/modules + +// @Filename: tests/test0.ts +//// import * as foo1 from "mod/*import_as0*/ +//// import foo2 = require("mod/*import_equals0*/ +//// var foo3 = require("mod/*require0*/ + +// @Filename: modules/module.ts +//// export var x = 5; + +// @Filename: package.json +//// { "dependencies": { "module-from-node": "latest" } } +// @Filename: node_modules/module-from-node/index.ts +//// /*module1*/ + + + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + + verify.completionListContains("module"); + verify.completionListContains("module-from-node"); + verify.not.completionListItemsCountIsGreaterThan(2); +} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts new file mode 100644 index 00000000000..0e8da4b02bb --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts @@ -0,0 +1,53 @@ +/// + +// @Filename: tsconfig.json +//// { +//// "compilerOptions": { +//// "baseUrl": "./modules", +//// "paths": { +//// "*": [ +//// "prefix/0*/suffix.ts", +//// "prefix-only/*", +//// "*/suffix-only.ts" +//// ] +//// } +//// } +//// } + + +// @Filename: tests/test0.ts +//// import * as foo1 from "0/*import_as0*/ +//// import foo2 = require("0/*import_equals0*/ +//// var foo3 = require("0/*require0*/ + +//// import * as foo1 from "1/*import_as1*/ +//// import foo2 = require("1/*import_equals1*/ +//// var foo3 = require("1/*require1*/ + +//// import * as foo1 from "2/*import_as2*/ +//// import foo2 = require("2/*import_equals2*/ +//// var foo3 = require("2/*require2*/ + + +// @Filename: modules/prefix/00test/suffix.ts +//// export var x = 5; + +// @Filename: modules/prefix-only/1test.ts +//// export var y = 5; + +// @Filename: modules/2test/suffix-only.ts +//// export var z = 5; + + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("0test"); + + goTo.marker(kind + "1"); + verify.completionListContains("1test"); + + goTo.marker(kind + "2"); + verify.completionListContains("2test"); +} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts new file mode 100644 index 00000000000..3c32ec2670d --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts @@ -0,0 +1,34 @@ +/// + +// @Filename: tsconfig.json +//// { +//// "compilerOptions": { +//// "baseUrl": "./modules", +//// "paths": { +//// "module1": ["some/path/whatever.ts"], +//// "module2": ["some/other/path.ts"] +//// } +//// } +//// } + + +// @Filename: tests/test0.ts +//// import * as foo1 from "m/*import_as0*/ +//// import foo2 = require("m/*import_equals0*/ +//// var foo3 = require("m/*require0*/ + +// @Filename: some/path/whatever.ts +//// export var x = 9; + +// @Filename: some/other/path.ts +//// export var y = 10; + + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("module1"); + verify.completionListContains("module2"); + verify.not.completionListItemsCountIsGreaterThan(2); +} From 0b16180174ab6ccab7b58ef15b08f470090b1159 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 27 Jul 2016 11:41:45 -0700 Subject: [PATCH 031/508] Import completions with rootdirs compiler option --- src/harness/harnessLanguageService.ts | 17 ++++++- src/services/services.ts | 49 +++++++++++++++++-- ...mpletionForStringLiteralRelativeImport4.ts | 48 ++++++++++++++++++ 3 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 3cb83faf610..a488146ba69 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -219,7 +219,22 @@ namespace Harness.LanguageService { return snapshot.getText(0, snapshot.getLength()); } resolvePath(path: string): string { - return ts.normalizePath(ts.isRootedDiskPath(path) ? path : ts.combinePaths(this.getCurrentDirectory(), path)); + if (!ts.isRootedDiskPath(path)) { + // An "absolute" path for fourslash is one that is contained within the tests directory + const components = ts.getNormalizedPathComponents(path, this.getCurrentDirectory()); + if (components.length) { + // If this is still a relative path after normalization (i.e. currentDirectory is relative), the root will be the empty string + if (!components[0]) { + components.splice(0, 1); + if (components[0] !== "tests") { + // If not contained within test, assume its relative to the directory containing the test files + return ts.normalizePath(ts.combinePaths("tests/cases/fourslash", components.join(ts.directorySeparator))); + } + } + return ts.normalizePath(components.join(ts.directorySeparator)); + } + } + return ts.normalizePath(path); } diff --git a/src/services/services.ts b/src/services/services.ts index 275c41732c1..43f9552730d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4379,7 +4379,15 @@ namespace ts { const isRelativePath = startsWith(literalValue, "."); const scriptDir = getDirectoryPath(node.getSourceFile().path); if (isRelativePath || isRootedDiskPath(literalValue)) { - result = getCompletionEntriesForDirectoryFragment(literalValue, scriptDir, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false); + const compilerOptions = program.getCompilerOptions(); + if (compilerOptions.rootDirs) { + result = getCompletionEntriesForDirectoryFragmentWithRootDirs( + compilerOptions.rootDirs, literalValue, scriptDir, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false); + } + else { + result = getCompletionEntriesForDirectoryFragment( + literalValue, scriptDir, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false); + } } else { // Check for node modules @@ -4393,10 +4401,42 @@ namespace ts { }; } - function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean): CompletionEntry[] { - // Complete the path by looking for source files and directories + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean) { + // Make all paths absolute/normalized if they are not already + rootDirs = map(rootDirs, rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory))); + + // Determine the path to the directory containing the script relative to the root directory it is contained within + let relativeDirectory: string; + forEach(rootDirs, rootDirectory => { + if (containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + return true; + } + }); + + // Now find a path for each potential directory that is to be merged with the one containing the script + return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); + } + + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean): CompletionEntry[] { + const basePath = program.getCompilerOptions().project || host.getCurrentDirectory(); + + const baseDirectories = getBaseDirectoriesFromRootDirs( + rootDirs, basePath, scriptPath, host.useCaseSensitiveFileNames && !host.useCaseSensitiveFileNames()); const result: CompletionEntry[] = []; + for (const baseDirectory of baseDirectories) { + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, result); + } + + return result; + } + + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, result: CompletionEntry[] = []): CompletionEntry[] { const toComplete = getBaseFileName(fragment); const absolutePath = normalizeSlashes(host.resolvePath(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment))); const baseDirectory = toComplete ? getDirectoryPath(absolutePath) : absolutePath; @@ -4456,7 +4496,8 @@ namespace ts { if (baseUrl) { const fileExtensions = getSupportedExtensions(options); - const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(host.getCurrentDirectory(), baseUrl) + const projectDir = options.project || host.getCurrentDirectory(); + const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false); if (paths) { diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts new file mode 100644 index 00000000000..1895fff8514 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -0,0 +1,48 @@ +/// + +// @rootDirs: sub/src1,src2 + +// @Filename: src2/test0.ts +//// import * as foo1 from "./mo/*import_as0*/ +//// import foo2 = require("./mo/*import_equals0*/ +//// var foo3 = require("./mo/*require0*/ + +// @Filename: src2/module0.ts +//// export var w = 0; + +// @Filename: sub/src1/module1.ts +//// export var x = 0; + +// @Filename: sub/src1/module2.ts +//// export var y = 0; + +// @Filename: sub/src1/more/module3.ts +//// export var z = 0; + + +// @Filename: f1.ts +//// /*f1*/ +// @Filename: f2.tsx +//// /*f2*/ +// @Filename: folder/f1.ts +//// /*subf1*/ +// @Filename: f3.js +//// /*f3*/ +// @Filename: f4.jsx +//// /*f4*/ +// @Filename: e1.ts +//// /*e1*/ +// @Filename: e2.js +//// /*e2*/ + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + + verify.completionListContains("module0"); + verify.completionListContains("module1"); + verify.completionListContains("module2"); + verify.completionListContains("more/"); + verify.not.completionListItemsCountIsGreaterThan(4); +} \ No newline at end of file From a6642d68c92ce7ddd16e8da71a1f2eb909fde74d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 27 Jul 2016 13:21:42 -0700 Subject: [PATCH 032/508] JSDoc understands string literal types Unfortunately, I didn't find a way to reuse the normal string literal type, so I had to extend the existing JSDoc type hierarchy. Otherwise, this feature is very simple. --- src/compiler/checker.ts | 2 ++ src/compiler/parser.ts | 9 ++++++++- src/compiler/types.ts | 5 +++++ tests/baselines/reference/jsdocStringLiteral.js | 16 ++++++++++++++++ .../reference/jsdocStringLiteral.symbols | 12 ++++++++++++ .../baselines/reference/jsdocStringLiteral.types | 14 ++++++++++++++ .../conformance/jsdoc/jsdocStringLiteral.ts | 12 ++++++++++++ 7 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/jsdocStringLiteral.js create mode 100644 tests/baselines/reference/jsdocStringLiteral.symbols create mode 100644 tests/baselines/reference/jsdocStringLiteral.types create mode 100644 tests/cases/conformance/jsdoc/jsdocStringLiteral.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6da456afcbc..321bfcc74a3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5326,6 +5326,8 @@ namespace ts { return getTypeFromThisTypeNode(node); case SyntaxKind.StringLiteralType: return getTypeFromStringLiteralTypeNode(node); + case SyntaxKind.JSDocStringLiteralType: + return getTypeFromStringLiteralTypeNode((node).stringLiteral); case SyntaxKind.TypeReference: case SyntaxKind.JSDocTypeReference: return getTypeFromTypeReference(node); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 774cea60e09..2e76093cde2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -5860,9 +5860,10 @@ namespace ts { case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: return parseTokenNode(); + case SyntaxKind.StringLiteral: + return parseJSDocStringLiteralType(); } - // TODO (drosen): Parse string literal types in JSDoc as well. return parseJSDocTypeReference(); } @@ -6041,6 +6042,12 @@ namespace ts { return finishNode(result); } + function parseJSDocStringLiteralType(): JSDocStringLiteralType { + const result = createNode(SyntaxKind.JSDocStringLiteralType); + result.stringLiteral = parseStringLiteralTypeNode(); + return finishNode(result); + } + function parseJSDocUnknownOrNullableType(): JSDocUnknownType | JSDocNullableType { const pos = scanner.getStartPos(); // skip the ? diff --git a/src/compiler/types.ts b/src/compiler/types.ts index dc332b24567..17e8a25038d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -346,6 +346,7 @@ namespace ts { JSDocTypedefTag, JSDocPropertyTag, JSDocTypeLiteral, + JSDocStringLiteralType, // Synthesized list SyntaxList, @@ -1491,6 +1492,10 @@ namespace ts { type: JSDocType; } + export interface JSDocStringLiteralType extends JSDocType { + stringLiteral: StringLiteralTypeNode; + } + export type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; // @kind(SyntaxKind.JSDocRecordMember) diff --git a/tests/baselines/reference/jsdocStringLiteral.js b/tests/baselines/reference/jsdocStringLiteral.js new file mode 100644 index 00000000000..f74faf3519e --- /dev/null +++ b/tests/baselines/reference/jsdocStringLiteral.js @@ -0,0 +1,16 @@ +//// [in.js] +/** + * @param {'literal'} input + */ +function f(input) { + return input + '.'; +} + + +//// [out.js] +/** + * @param {'literal'} input + */ +function f(input) { + return input + '.'; +} diff --git a/tests/baselines/reference/jsdocStringLiteral.symbols b/tests/baselines/reference/jsdocStringLiteral.symbols new file mode 100644 index 00000000000..0414efc24d9 --- /dev/null +++ b/tests/baselines/reference/jsdocStringLiteral.symbols @@ -0,0 +1,12 @@ +=== tests/cases/compiler/in.js === +/** + * @param {'literal'} input + */ +function f(input) { +>f : Symbol(f, Decl(in.js, 0, 0)) +>input : Symbol(input, Decl(in.js, 3, 11)) + + return input + '.'; +>input : Symbol(input, Decl(in.js, 3, 11)) +} + diff --git a/tests/baselines/reference/jsdocStringLiteral.types b/tests/baselines/reference/jsdocStringLiteral.types new file mode 100644 index 00000000000..c7b87857d18 --- /dev/null +++ b/tests/baselines/reference/jsdocStringLiteral.types @@ -0,0 +1,14 @@ +=== tests/cases/compiler/in.js === +/** + * @param {'literal'} input + */ +function f(input) { +>f : (input: "literal") => string +>input : "literal" + + return input + '.'; +>input + '.' : string +>input : "literal" +>'.' : string +} + diff --git a/tests/cases/conformance/jsdoc/jsdocStringLiteral.ts b/tests/cases/conformance/jsdoc/jsdocStringLiteral.ts new file mode 100644 index 00000000000..d2a0d6c644d --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocStringLiteral.ts @@ -0,0 +1,12 @@ +// @allowJs: true +// @filename: in.js +// @out: out.js +/** + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 + */ +function f(p1, p2, p3, p4) { + return p1 + p2 + p3 + p4 + '.'; +} From 6fbd79b70954682f8a131a4899f8a227237e91f5 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 27 Jul 2016 13:25:16 -0700 Subject: [PATCH 033/508] Update baselines to be current --- .../baselines/reference/jsdocStringLiteral.js | 18 ++++++++----- .../reference/jsdocStringLiteral.symbols | 19 ++++++++++---- .../reference/jsdocStringLiteral.types | 26 ++++++++++++++----- 3 files changed, 45 insertions(+), 18 deletions(-) diff --git a/tests/baselines/reference/jsdocStringLiteral.js b/tests/baselines/reference/jsdocStringLiteral.js index f74faf3519e..e1210690f91 100644 --- a/tests/baselines/reference/jsdocStringLiteral.js +++ b/tests/baselines/reference/jsdocStringLiteral.js @@ -1,16 +1,22 @@ //// [in.js] /** - * @param {'literal'} input + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 */ -function f(input) { - return input + '.'; +function f(p1, p2, p3, p4) { + return p1 + p2 + p3 + p4 + '.'; } //// [out.js] /** - * @param {'literal'} input + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 */ -function f(input) { - return input + '.'; +function f(p1, p2, p3, p4) { + return p1 + p2 + p3 + p4 + '.'; } diff --git a/tests/baselines/reference/jsdocStringLiteral.symbols b/tests/baselines/reference/jsdocStringLiteral.symbols index 0414efc24d9..83f0f4b1e65 100644 --- a/tests/baselines/reference/jsdocStringLiteral.symbols +++ b/tests/baselines/reference/jsdocStringLiteral.symbols @@ -1,12 +1,21 @@ === tests/cases/compiler/in.js === /** - * @param {'literal'} input + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 */ -function f(input) { +function f(p1, p2, p3, p4) { >f : Symbol(f, Decl(in.js, 0, 0)) ->input : Symbol(input, Decl(in.js, 3, 11)) +>p1 : Symbol(p1, Decl(in.js, 6, 11)) +>p2 : Symbol(p2, Decl(in.js, 6, 14)) +>p3 : Symbol(p3, Decl(in.js, 6, 18)) +>p4 : Symbol(p4, Decl(in.js, 6, 22)) - return input + '.'; ->input : Symbol(input, Decl(in.js, 3, 11)) + return p1 + p2 + p3 + p4 + '.'; +>p1 : Symbol(p1, Decl(in.js, 6, 11)) +>p2 : Symbol(p2, Decl(in.js, 6, 14)) +>p3 : Symbol(p3, Decl(in.js, 6, 18)) +>p4 : Symbol(p4, Decl(in.js, 6, 22)) } diff --git a/tests/baselines/reference/jsdocStringLiteral.types b/tests/baselines/reference/jsdocStringLiteral.types index c7b87857d18..834ec65b916 100644 --- a/tests/baselines/reference/jsdocStringLiteral.types +++ b/tests/baselines/reference/jsdocStringLiteral.types @@ -1,14 +1,26 @@ === tests/cases/compiler/in.js === /** - * @param {'literal'} input + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 */ -function f(input) { ->f : (input: "literal") => string ->input : "literal" +function f(p1, p2, p3, p4) { +>f : (p1: "literal", p2: "literal", p3: "literal" | "other", p4: "literal" | number) => string +>p1 : "literal" +>p2 : "literal" +>p3 : "literal" | "other" +>p4 : "literal" | number - return input + '.'; ->input + '.' : string ->input : "literal" + return p1 + p2 + p3 + p4 + '.'; +>p1 + p2 + p3 + p4 + '.' : string +>p1 + p2 + p3 + p4 : string +>p1 + p2 + p3 : string +>p1 + p2 : string +>p1 : "literal" +>p2 : "literal" +>p3 : "literal" | "other" +>p4 : "literal" | number >'.' : string } From 3446557eae0dd6096ca388872a0ad28b7e2d4202 Mon Sep 17 00:00:00 2001 From: Josh Abernathy Date: Wed, 27 Jul 2016 16:40:43 -0400 Subject: [PATCH 034/508] Add find and findIndex to ReadonlyArray --- src/lib/es2015.core.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 206b8b8f9bf..dcfe9a0b92e 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -343,6 +343,30 @@ interface ObjectConstructor { defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; } +interface ReadonlyArray { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; +} + interface RegExp { /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. From 34e78e6dc1487c061c363e9fac49ee613dcf5def Mon Sep 17 00:00:00 2001 From: Josh Abernathy Date: Wed, 27 Jul 2016 16:42:14 -0400 Subject: [PATCH 035/508] The optional this should be readonly too. --- src/lib/es2015.core.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index dcfe9a0b92e..42e4a8c2b57 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -353,7 +353,7 @@ interface ReadonlyArray { * @param thisArg If provided, it will be used as the this value for each invocation of * predicate. If it is not provided, undefined is used instead. */ - find(predicate: (value: T, index: number, obj: Array) => boolean, thisArg?: any): T | undefined; + find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; /** * Returns the index of the first element in the array where predicate is true, and undefined From 5c2ba01bebd81e4b0afb146a1fa4e5fe8d4b6aa9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 27 Jul 2016 13:44:45 -0700 Subject: [PATCH 036/508] Update baseline source location --- tests/baselines/reference/jsdocStringLiteral.symbols | 2 +- tests/baselines/reference/jsdocStringLiteral.types | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/jsdocStringLiteral.symbols b/tests/baselines/reference/jsdocStringLiteral.symbols index 83f0f4b1e65..982a1536069 100644 --- a/tests/baselines/reference/jsdocStringLiteral.symbols +++ b/tests/baselines/reference/jsdocStringLiteral.symbols @@ -1,4 +1,4 @@ -=== tests/cases/compiler/in.js === +=== tests/cases/conformance/jsdoc/in.js === /** * @param {'literal'} p1 * @param {"literal"} p2 diff --git a/tests/baselines/reference/jsdocStringLiteral.types b/tests/baselines/reference/jsdocStringLiteral.types index 834ec65b916..0400416a259 100644 --- a/tests/baselines/reference/jsdocStringLiteral.types +++ b/tests/baselines/reference/jsdocStringLiteral.types @@ -1,4 +1,4 @@ -=== tests/cases/compiler/in.js === +=== tests/cases/conformance/jsdoc/in.js === /** * @param {'literal'} p1 * @param {"literal"} p2 From f8103b596091d717753ee8200f9f45a3c8ca6ef7 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 27 Jul 2016 15:58:13 -0700 Subject: [PATCH 037/508] Update LastJSDoc[Tag]Node --- src/compiler/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 17e8a25038d..d5d5546a0cd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -377,9 +377,9 @@ namespace ts { LastBinaryOperator = CaretEqualsToken, FirstNode = QualifiedName, FirstJSDocNode = JSDocTypeExpression, - LastJSDocNode = JSDocTypeLiteral, + LastJSDocNode = JSDocStringLiteralType, FirstJSDocTagNode = JSDocComment, - LastJSDocTagNode = JSDocTypeLiteral + LastJSDocTagNode = JSDocStringLiteralType } export const enum NodeFlags { From 9e962f5356a41d194907c883f5bc5d2bad1b5e5a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 28 Jul 2016 09:15:09 -0700 Subject: [PATCH 038/508] null/undefined are allowed as index expressions `null` and `undefined` are not allowed with `--strictNullChecks` turned on. Previously, they were disallowed whether or not it was on. --- src/compiler/checker.ts | 5 +- .../reference/indexWithUndefinedAndNull.js | 22 +++++++++ .../indexWithUndefinedAndNull.symbols | 39 +++++++++++++++ .../reference/indexWithUndefinedAndNull.types | 47 +++++++++++++++++++ ...ndefinedAndNullStrictNullChecks.errors.txt | 40 ++++++++++++++++ ...dexWithUndefinedAndNullStrictNullChecks.js | 22 +++++++++ .../compiler/indexWithUndefinedAndNull.ts | 13 +++++ ...dexWithUndefinedAndNullStrictNullChecks.ts | 13 +++++ 8 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/indexWithUndefinedAndNull.js create mode 100644 tests/baselines/reference/indexWithUndefinedAndNull.symbols create mode 100644 tests/baselines/reference/indexWithUndefinedAndNull.types create mode 100644 tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt create mode 100644 tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.js create mode 100644 tests/cases/compiler/indexWithUndefinedAndNull.ts create mode 100644 tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6da456afcbc..38079c1bea0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10394,10 +10394,11 @@ namespace ts { } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) { + const allowedOptionalFlags = strictNullChecks ? 0 : TypeFlags.Null | TypeFlags.Undefined; + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol | allowedOptionalFlags)) { // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike | allowedOptionalFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { const numberIndexInfo = getIndexInfoOfType(objectType, IndexKind.Number); if (numberIndexInfo) { getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; diff --git a/tests/baselines/reference/indexWithUndefinedAndNull.js b/tests/baselines/reference/indexWithUndefinedAndNull.js new file mode 100644 index 00000000000..f885323efae --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNull.js @@ -0,0 +1,22 @@ +//// [indexWithUndefinedAndNull.ts] +interface N { + [n: number]: string; +} +interface S { + [s: string]: number; +} +let n: N; +let s: S; +let str: string = n[undefined]; +str = n[null]; +let num: number = s[undefined]; +num = s[null]; + + +//// [indexWithUndefinedAndNull.js] +var n; +var s; +var str = n[undefined]; +str = n[null]; +var num = s[undefined]; +num = s[null]; diff --git a/tests/baselines/reference/indexWithUndefinedAndNull.symbols b/tests/baselines/reference/indexWithUndefinedAndNull.symbols new file mode 100644 index 00000000000..15e8bbdbf41 --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNull.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/indexWithUndefinedAndNull.ts === +interface N { +>N : Symbol(N, Decl(indexWithUndefinedAndNull.ts, 0, 0)) + + [n: number]: string; +>n : Symbol(n, Decl(indexWithUndefinedAndNull.ts, 1, 5)) +} +interface S { +>S : Symbol(S, Decl(indexWithUndefinedAndNull.ts, 2, 1)) + + [s: string]: number; +>s : Symbol(s, Decl(indexWithUndefinedAndNull.ts, 4, 5)) +} +let n: N; +>n : Symbol(n, Decl(indexWithUndefinedAndNull.ts, 6, 3)) +>N : Symbol(N, Decl(indexWithUndefinedAndNull.ts, 0, 0)) + +let s: S; +>s : Symbol(s, Decl(indexWithUndefinedAndNull.ts, 7, 3)) +>S : Symbol(S, Decl(indexWithUndefinedAndNull.ts, 2, 1)) + +let str: string = n[undefined]; +>str : Symbol(str, Decl(indexWithUndefinedAndNull.ts, 8, 3)) +>n : Symbol(n, Decl(indexWithUndefinedAndNull.ts, 6, 3)) +>undefined : Symbol(undefined) + +str = n[null]; +>str : Symbol(str, Decl(indexWithUndefinedAndNull.ts, 8, 3)) +>n : Symbol(n, Decl(indexWithUndefinedAndNull.ts, 6, 3)) + +let num: number = s[undefined]; +>num : Symbol(num, Decl(indexWithUndefinedAndNull.ts, 10, 3)) +>s : Symbol(s, Decl(indexWithUndefinedAndNull.ts, 7, 3)) +>undefined : Symbol(undefined) + +num = s[null]; +>num : Symbol(num, Decl(indexWithUndefinedAndNull.ts, 10, 3)) +>s : Symbol(s, Decl(indexWithUndefinedAndNull.ts, 7, 3)) + diff --git a/tests/baselines/reference/indexWithUndefinedAndNull.types b/tests/baselines/reference/indexWithUndefinedAndNull.types new file mode 100644 index 00000000000..07b6050503a --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNull.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/indexWithUndefinedAndNull.ts === +interface N { +>N : N + + [n: number]: string; +>n : number +} +interface S { +>S : S + + [s: string]: number; +>s : string +} +let n: N; +>n : N +>N : N + +let s: S; +>s : S +>S : S + +let str: string = n[undefined]; +>str : string +>n[undefined] : string +>n : N +>undefined : undefined + +str = n[null]; +>str = n[null] : string +>str : string +>n[null] : string +>n : N +>null : null + +let num: number = s[undefined]; +>num : number +>s[undefined] : number +>s : S +>undefined : undefined + +num = s[null]; +>num = s[null] : number +>num : number +>s[null] : number +>s : S +>null : null + diff --git a/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt new file mode 100644 index 00000000000..a1fce75c54e --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt @@ -0,0 +1,40 @@ +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,19): error TS2454: Variable 'n' is used before being assigned. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,19): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,7): error TS2454: Variable 'n' is used before being assigned. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,7): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,19): error TS2454: Variable 's' is used before being assigned. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,19): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error TS2454: Variable 's' is used before being assigned. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + + +==== tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts (8 errors) ==== + interface N { + [n: number]: string; + } + interface S { + [s: string]: number; + } + let n: N; + let s: S; + let str: string = n[undefined]; + ~ +!!! error TS2454: Variable 'n' is used before being assigned. + ~~~~~~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + str = n[null]; + ~ +!!! error TS2454: Variable 'n' is used before being assigned. + ~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + let num: number = s[undefined]; + ~ +!!! error TS2454: Variable 's' is used before being assigned. + ~~~~~~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + num = s[null]; + ~ +!!! error TS2454: Variable 's' is used before being assigned. + ~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + \ No newline at end of file diff --git a/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.js b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.js new file mode 100644 index 00000000000..9300b7c0549 --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.js @@ -0,0 +1,22 @@ +//// [indexWithUndefinedAndNullStrictNullChecks.ts] +interface N { + [n: number]: string; +} +interface S { + [s: string]: number; +} +let n: N; +let s: S; +let str: string = n[undefined]; +str = n[null]; +let num: number = s[undefined]; +num = s[null]; + + +//// [indexWithUndefinedAndNullStrictNullChecks.js] +var n; +var s; +var str = n[undefined]; +str = n[null]; +var num = s[undefined]; +num = s[null]; diff --git a/tests/cases/compiler/indexWithUndefinedAndNull.ts b/tests/cases/compiler/indexWithUndefinedAndNull.ts new file mode 100644 index 00000000000..2aeb2ee0b1d --- /dev/null +++ b/tests/cases/compiler/indexWithUndefinedAndNull.ts @@ -0,0 +1,13 @@ +// @strictNullChecks: false +interface N { + [n: number]: string; +} +interface S { + [s: string]: number; +} +let n: N; +let s: S; +let str: string = n[undefined]; +str = n[null]; +let num: number = s[undefined]; +num = s[null]; diff --git a/tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts b/tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts new file mode 100644 index 00000000000..f8fe0a323c6 --- /dev/null +++ b/tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts @@ -0,0 +1,13 @@ +// @strictNullChecks: true +interface N { + [n: number]: string; +} +interface S { + [s: string]: number; +} +let n: N; +let s: S; +let str: string = n[undefined]; +str = n[null]; +let num: number = s[undefined]; +num = s[null]; From e2709d801dd3f48f8e4d718ecdcded2bb5dd66f6 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 28 Jul 2016 09:19:25 -0700 Subject: [PATCH 039/508] Use correct nullable terminology --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 38079c1bea0..c8b03876c46 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10394,11 +10394,11 @@ namespace ts { } // Check for compatible indexer types. - const allowedOptionalFlags = strictNullChecks ? 0 : TypeFlags.Null | TypeFlags.Undefined; - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol | allowedOptionalFlags)) { + const allowedNullableFlags = strictNullChecks ? 0 : TypeFlags.Nullable; + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol | allowedNullableFlags)) { // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike | allowedOptionalFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike | allowedNullableFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { const numberIndexInfo = getIndexInfoOfType(objectType, IndexKind.Number); if (numberIndexInfo) { getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; From dbf19f18af35afc21640ecf9b80a6c745992f5a7 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 28 Jul 2016 11:52:15 -0700 Subject: [PATCH 040/508] Adding import completions for typings --- src/harness/fourslash.ts | 4 +- src/services/services.ts | 125 +++++++++++++----- ...etionForStringLiteralNonrelativeImport2.ts | 7 +- ...etionForStringLiteralNonrelativeImport4.ts | 6 +- ...rStringLiteralNonrelativeImportTypings1.ts | 32 +++++ ...rStringLiteralNonrelativeImportTypings2.ts | 29 ++++ ...rStringLiteralNonrelativeImportTypings3.ts | 25 ++++ 7 files changed, 183 insertions(+), 45 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 87b537417ea..8a8cb348a73 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -260,8 +260,8 @@ namespace FourSlash { // Extend our existing compiler options so that we can also support tsconfig only options if (configJson.config.compilerOptions) { - let baseDir = ts.normalizePath(ts.getDirectoryPath(file.fileName)); - let tsConfig = ts.convertCompilerOptionsFromJson(configJson.config.compilerOptions, baseDir, file.fileName); + const baseDirectory = ts.normalizePath(ts.getDirectoryPath(file.fileName)); + const tsConfig = ts.convertCompilerOptionsFromJson(configJson.config.compilerOptions, baseDirectory, file.fileName); if (!tsConfig.errors || !tsConfig.errors.length) { compilationOptions = ts.extend(compilationOptions, tsConfig.options); diff --git a/src/services/services.ts b/src/services/services.ts index 43f9552730d..76aed2ffe01 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1968,7 +1968,7 @@ namespace ts { * for completions. * For example, this matches /// { result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); @@ -4558,7 +4558,7 @@ namespace ts { // If we have a suffix, then we need to read the directory all the way down. We could create a glob // that encodes the suffix, but we would have to escape the character "?" which readDirectory // doesn't support. For now, this is safer but slower - const includeGlob = normalizedSuffix ? "**/*" : "./*" + const includeGlob = normalizedSuffix ? "**/*" : "./*"; const matches = host.readDirectory(baseDirectory, fileExtensions, undefined, [includeGlob]); const result: string[] = []; @@ -4629,19 +4629,97 @@ namespace ts { const text = sourceFile.text.substr(node.pos, position); const match = tripleSlashDirectiveFragmentRegex.exec(text); if (match) { - const fragment = match[1]; - const scriptPath = getDirectoryPath(sourceFile.path); - return { - isMemberCompletion: false, - isNewIdentifierLocation: false, - entries: getCompletionEntriesForDirectoryFragment(fragment, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true) - }; + const kind= match[1]; + const fragment = match[2]; + if (kind === "path") { + // Give completions for a relative path + const scriptPath = getDirectoryPath(sourceFile.path); + return { + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: getCompletionEntriesForDirectoryFragment(fragment, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true) + }; + } + else { + // Give completions based on what is available in the types directory + } } return undefined; } } + function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, result: CompletionEntry[]): CompletionEntry[] { + // Check for typings specified in compiler options + if (options.types) { + forEach(options.types, moduleName => { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); + }); + } + else if (options.typeRoots) { + const absoluteRoots = map(options.typeRoots, rootDirectory => getAbsoluteProjectPath(rootDirectory, host, options.project)); + forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectory(host, options, absoluteRoot, result)); + } + + // Also get all @types typings installed in visible node_modules directories + forEach(findPackageJsons(scriptPath), package => { + const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); + getCompletionEntriesFromDirectory(host, options, typesDir, result); + }); + + return result; + } + + function getAbsoluteProjectPath(path: string, host: LanguageServiceHost, projectDir?: string) { + if (isRootedDiskPath(path)) { + return normalizePath(path); + } + + if (projectDir) { + return normalizePath(combinePaths(projectDir, path)); + } + + return normalizePath(host.resolvePath(path)); + } + + function getCompletionEntriesFromDirectory(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: CompletionEntry[]) { + if (directoryProbablyExists(directory, host)) { + const typeDirectories = host.readDirectory(directory, getSupportedExtensions(options), /*exclude*/undefined, /*include*/["./*/*"]); + const seen: {[index: string]: boolean} = {}; + forEach(typeDirectories, typeFile => { + const typeDirectory = getDirectoryPath(typeFile); + if (!hasProperty(seen, typeDirectory)) { + seen[typeDirectory] = true; + result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName)); + } + }); + } + } + + function findPackageJsons(currentDir: string): string[] { + const paths: string[] = []; + let currentConfigPath: string; + while (true) { + currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + + currentDir = getDirectoryPath(currentConfigPath); + const parent = getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + + return paths; + } + + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string, modulePrefix?: string) { const result: VisibleModuleInfo[] = []; findPackageJsons(scriptPath).forEach((packageJson) => { @@ -4672,29 +4750,6 @@ namespace ts { return result; - function findPackageJsons(currentDir: string): string[] { - const paths: string[] = []; - let currentConfigPath: string; - while (true) { - currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - - currentDir = getDirectoryPath(currentConfigPath); - const parent = getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } - - return paths; - } - function tryReadingPackageJson(filePath: string) { try { const fileText = host.readFile(filePath); @@ -4745,7 +4800,7 @@ namespace ts { kind, kindModifiers: ScriptElementKindModifier.none, sortText: name - } + }; } function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts index 2b5f57412de..11420fe4f37 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts @@ -22,11 +22,8 @@ // @Filename: node_modules/unlisted-module/index.js //// /*unlisted-module*/ -// @Filename: node_modules/@types/fake-module/other.d.ts -//// declare module "fake-module/other" {} - -// @Filename: node_modules/@types/unlisted-module/index.d.ts -//// /*unlisted-types*/ +// @Filename: ambient.ts +//// declare module "fake-module/other" const kinds = ["import_as", "import_equals", "require"]; diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index 64e3cbad48e..5a96e4ee63e 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -20,7 +20,7 @@ // @Filename: dir1/package.json //// { "dependencies": { "fake-module2": "latest" } } -// @Filename: dir1/node_modules/@types/fake-module2/js.d.ts +// @Filename: dir1/node_modules/fake-module2/index.ts //// declare module "ambient-module-test" {} // @Filename: dir1/dir2/dir3/package.json @@ -34,7 +34,7 @@ for (const kind of kinds) { goTo.marker(kind + "0"); verify.completionListContains("fake-module/"); - verify.completionListContains("fake-module2/"); + verify.completionListContains("fake-module2"); verify.completionListContains("fake-module3/"); verify.not.completionListItemsCountIsGreaterThan(3); @@ -46,7 +46,7 @@ for (const kind of kinds) { goTo.marker(kind + "2"); verify.completionListContains("fake-module/"); - verify.completionListContains("fake-module2/"); + verify.completionListContains("fake-module2"); verify.completionListContains("fake-module3/"); verify.not.completionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts new file mode 100644 index 00000000000..53dc12033c9 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts @@ -0,0 +1,32 @@ +/// + +// @typeRoots: my_typings,my_other_typings + + +// @Filename: tests/test0.ts +//// import * as foo1 from "m/*import_as0*/ +//// import foo2 = require("m/*import_equals0*/ +//// var foo3 = require("m/*require0*/ + +// @Filename: my_typings/module-x/index.d.ts +//// export var x = 9; + +// @Filename: my_typings/module-x/whatever.d.ts +//// export var w = 9; + +// @Filename: my_typings/module-y/index.d.ts +//// export var y = 9; + +// @Filename: my_other_typings/module-z/index.d.ts +//// export var z = 9; + + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("module-x"); + verify.completionListContains("module-y"); + verify.completionListContains("module-z"); + verify.not.completionListItemsCountIsGreaterThan(3); +} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts new file mode 100644 index 00000000000..01e6f0ed420 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts @@ -0,0 +1,29 @@ +/// + +// @typeRoots: my_typings,my_other_typings +// @types: module-x,module-z + + +// @Filename: tests/test0.ts +//// import * as foo1 from "m/*import_as0*/ +//// import foo2 = require("m/*import_equals0*/ +//// var foo3 = require("m/*require0*/ + +// @Filename: my_typings/module-x/index.d.ts +//// export var x = 9; + +// @Filename: my_typings/module-y/index.d.ts +//// export var y = 9; + +// @Filename: my_other_typings/module-z/index.d.ts +//// export var z = 9; + + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("module-x"); + verify.completionListContains("module-z"); + verify.not.completionListItemsCountIsGreaterThan(2); +} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts new file mode 100644 index 00000000000..9710ce05cd5 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts @@ -0,0 +1,25 @@ +/// + +// @Filename: subdirectory/test0.ts +//// import * as foo1 from "m/*import_as0*/ +//// import foo2 = require("m/*import_equals0*/ +//// var foo3 = require("m/*require0*/ + +// @Filename: subdirectory/node_modules/@types/module-x/index.d.ts +//// export var x = 9; +// @Filename: subdirectory/package.json +//// { "dependencies": { "@types/module-x": "latest" } } + +// @Filename: node_modules/@types/module-y/index.d.ts +//// export var y = 9; +// @Filename: package.json +//// { "dependencies": { "@types/module-y": "latest" } } + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListContains("module-x"); + verify.completionListContains("module-y"); + verify.not.completionListItemsCountIsGreaterThan(2); +} From fdbc23e9acc1c2bbc04c6b8440a4bfe3577d6f78 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 28 Jul 2016 13:12:53 -0700 Subject: [PATCH 041/508] Add completions for types triple slash directives --- src/services/services.ts | 23 ++++++++++++++----- src/services/utilities.ts | 5 ++++ ...rStringLiteralNonrelativeImportTypings1.ts | 3 ++- ...rStringLiteralNonrelativeImportTypings2.ts | 3 ++- ...rStringLiteralNonrelativeImportTypings3.ts | 3 ++- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 76aed2ffe01..a4a1a444592 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4538,11 +4538,10 @@ namespace ts { function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[]): string[] { const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; if (parsed) { - const hasTrailingSlash = parsed.prefix.charAt(parsed.prefix.length - 1) === "/" || parsed.prefix.charAt(parsed.prefix.length - 1) === "\\"; - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a // full directory component. For example: directory/path/of/prefix/base* - const normalizedPrefix = hasTrailingSlash ? ensureTrailingDirectorySeparator(normalizePath(parsed.prefix)) : normalizePath(parsed.prefix); + const normalizedPrefix = hasTrailingDirectorySeparator(parsed.prefix) ? + ensureTrailingDirectorySeparator(normalizePath(parsed.prefix)) : normalizePath(parsed.prefix); const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); const normalizedPrefixBase = getBaseFileName(normalizedPrefix); @@ -4582,6 +4581,13 @@ namespace ts { } function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string): string[] { + const trailingSeperator = hasTrailingDirectorySeparator(fragment); + fragment = normalizePath(fragment); + + if (trailingSeperator) { + fragment = ensureTrailingDirectorySeparator(fragment); + } + // If this is a nested module, get the module name const firstSeparator = fragment.indexOf(directorySeparator); const moduleNameFragment = firstSeparator !== -1 ? fragment.substr(0, firstSeparator) : fragment; @@ -4631,9 +4637,9 @@ namespace ts { if (match) { const kind= match[1]; const fragment = match[2]; + const scriptPath = getDirectoryPath(sourceFile.path); if (kind === "path") { // Give completions for a relative path - const scriptPath = getDirectoryPath(sourceFile.path); return { isMemberCompletion: false, isNewIdentifierLocation: false, @@ -4641,7 +4647,12 @@ namespace ts { }; } else { - // Give completions based on what is available in the types directory + // Give completions based on the typings available + return { + isMemberCompletion: false, + isNewIdentifierLocation: false, + entries: getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath) + }; } } @@ -4649,7 +4660,7 @@ namespace ts { } } - function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, result: CompletionEntry[]): CompletionEntry[] { + function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, result: CompletionEntry[] = []): CompletionEntry[] { // Check for typings specified in compiler options if (options.types) { forEach(options.types, moduleName => { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 0c4c0fd1dea..3a9b56584c2 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -927,4 +927,9 @@ namespace ts { } return ensureScriptKind(fileName, scriptKind); } + + export function hasTrailingDirectorySeparator(path: string) { + const lastCharacter = path.charAt(path.length - 1); + return lastCharacter === "/" || lastCharacter === "\\"; + } } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts index 53dc12033c9..edce0ce7e9f 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts @@ -4,6 +4,7 @@ // @Filename: tests/test0.ts +//// /// //// import * as foo1 from "m/*import_as0*/ //// import foo2 = require("m/*import_equals0*/ //// var foo3 = require("m/*require0*/ @@ -21,7 +22,7 @@ //// export var z = 9; -const kinds = ["import_as", "import_equals", "require"]; +const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts index 01e6f0ed420..541bb88c073 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts @@ -5,6 +5,7 @@ // @Filename: tests/test0.ts +//// /// //// import * as foo1 from "m/*import_as0*/ //// import foo2 = require("m/*import_equals0*/ //// var foo3 = require("m/*require0*/ @@ -19,7 +20,7 @@ //// export var z = 9; -const kinds = ["import_as", "import_equals", "require"]; +const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts index 9710ce05cd5..7a7d4e00df9 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts @@ -1,6 +1,7 @@ /// // @Filename: subdirectory/test0.ts +//// /// //// import * as foo1 from "m/*import_as0*/ //// import foo2 = require("m/*import_equals0*/ //// var foo3 = require("m/*require0*/ @@ -15,7 +16,7 @@ // @Filename: package.json //// { "dependencies": { "@types/module-y": "latest" } } -const kinds = ["import_as", "import_equals", "require"]; +const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); From 9e797b4c787b3352cdda0a39ad7ac1704c8b596e Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 28 Jul 2016 16:44:24 -0700 Subject: [PATCH 042/508] Use getDirectories and condition node modules resolution on moduleResolution flag --- src/services/services.ts | 65 ++++++++++--------- ...tionForStringLiteralNonrelativeImport10.ts | 33 ++++++++++ 2 files changed, 67 insertions(+), 31 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts diff --git a/src/services/services.ts b/src/services/services.ts index a14090e26c9..025afcd1548 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1171,6 +1171,11 @@ namespace ts { resolveModuleNames?(moduleNames: string[], containingFile: string): ResolvedModule[]; resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists?(directoryName: string): boolean; + + /** + * getDirectories is also required for full import and type reference completions. Without it defined, certain + * completions will not be provided + */ getDirectories?(directoryName: string): string[]; } @@ -4652,7 +4657,7 @@ namespace ts { getCompletionEntriesFromTypings(host, options, scriptPath, result); - forEach(enumeratePotentialNonRelativeModules(fragment, scriptPath), moduleName => { + forEach(enumeratePotentialNonRelativeModules(fragment, scriptPath, options), moduleName => { result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); }); @@ -4704,7 +4709,7 @@ namespace ts { return undefined; } - function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string): string[] { + function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions): string[] { const trailingSeperator = hasTrailingDirectorySeparator(fragment); fragment = normalizePath(fragment); @@ -4733,19 +4738,21 @@ namespace ts { return moduleName; }); - forEach(enumerateNodeModulesVisibleToScript(host, scriptPath, moduleNameFragment), visibleModule => { - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.canBeImported ? visibleModule.moduleName : ensureTrailingDirectorySeparator(visibleModule.moduleName)); - } - else { - const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); + if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { + forEach(enumerateNodeModulesVisibleToScript(host, scriptPath, moduleNameFragment), visibleModule => { + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.canBeImported ? visibleModule.moduleName : ensureTrailingDirectorySeparator(visibleModule.moduleName)); + } + else { + const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - forEach(nestedFiles, (f) => { - const nestedModule = removeFileExtension(getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - }); - } - }); + forEach(nestedFiles, (f) => { + const nestedModule = removeFileExtension(getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + }); + } + }); + } return deduplicate(nonRelativeModules); } @@ -4791,16 +4798,18 @@ namespace ts { result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); }); } - else if (options.typeRoots) { + else if (host.getDirectories && options.typeRoots) { const absoluteRoots = map(options.typeRoots, rootDirectory => getAbsoluteProjectPath(rootDirectory, host, options.project)); - forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectory(host, options, absoluteRoot, result)); + forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectories(host, options, absoluteRoot, result)); } - // Also get all @types typings installed in visible node_modules directories - forEach(findPackageJsons(scriptPath), package => { - const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); - getCompletionEntriesFromDirectory(host, options, typesDir, result); - }); + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + forEach(findPackageJsons(scriptPath), package => { + const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, options, typesDir, result); + }); + } return result; } @@ -4817,16 +4826,10 @@ namespace ts { return normalizePath(host.resolvePath(path)); } - function getCompletionEntriesFromDirectory(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: CompletionEntry[]) { - if (directoryProbablyExists(directory, host)) { - const typeDirectories = host.readDirectory(directory, getSupportedExtensions(options), /*exclude*/undefined, /*include*/["./*/*"]); - const seen: {[index: string]: boolean} = {}; - forEach(typeDirectories, typeFile => { - const typeDirectory = getDirectoryPath(typeFile); - if (!hasProperty(seen, typeDirectory)) { - seen[typeDirectory] = true; - result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName)); - } + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: CompletionEntry[]) { + if (host.getDirectories && directoryProbablyExists(directory, host)) { + forEach(host.getDirectories(directory), typeDirectory => { + result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName)); }); } } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts new file mode 100644 index 00000000000..cb1f67f6349 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts @@ -0,0 +1,33 @@ +/// + +// @moduleResolution: classic + +// @Filename: dir1/dir2/dir3/dir4/test0.ts +//// import * as foo1 from "f/*import_as0*/ +//// import * as foo3 from "fake-module/*import_as1*/ + +//// import foo4 = require("f/*import_equals0*/ +//// import foo6 = require("fake-module/*import_equals1*/ + +//// var foo7 = require("f/*require0*/ +//// var foo9 = require("fake-module/*require1*/ + +// @Filename: package.json +//// { "dependencies": { "fake-module": "latest" } } +// @Filename: node_modules/fake-module/ts.ts +//// /*module1*/ + +// @Filename: dir1/dir2/dir3/package.json +//// { "dependencies": { "fake-module3": "latest" } } +// @Filename: dir1/dir2/dir3/node_modules/fake-module3/ts.ts +//// /*module3*/ + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + verify.completionListIsEmpty(); + + goTo.marker(kind + "1"); + verify.completionListIsEmpty(); +} \ No newline at end of file From dbd8dd5c88b206da384eba5aaf4d80771ff0ec17 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 29 Jul 2016 15:56:33 +0200 Subject: [PATCH 043/508] add Array.prototype.filter signature with type guard --- src/lib/es5.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 6f017c8a343..571c42e0eb4 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1055,6 +1055,12 @@ interface ReadonlyArray { * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. */ map(callbackfn: (value: T, index: number, array: ReadonlyArray) => U, thisArg?: any): U[]; + /** + * Returns the elements of an array that meet the condition specified in a callback function. + * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. + * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value. + */ + filter(callbackfn: (value: T, index: number, array: ReadonlyArray) => value is S, thisArg?: any): S[]; /** * Returns the elements of an array that meet the condition specified in a callback function. * @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array. From 97bbbd729e049ee644e954f4dff0c3756a0677db Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 28 Jul 2016 07:20:51 -0700 Subject: [PATCH 044/508] Introduce the `EntityNameExpression` type --- src/compiler/checker.ts | 102 ++++++++++-------- src/compiler/declarationEmitter.ts | 4 +- src/compiler/types.ts | 18 +++- src/compiler/utilities.ts | 36 ++++--- .../reference/exportDefaultProperty.js | 8 ++ .../reference/exportDefaultProperty.symbols | 5 + .../reference/exportDefaultProperty.types | 6 ++ tests/cases/compiler/exportDefaultProperty.ts | 1 + 8 files changed, 113 insertions(+), 67 deletions(-) create mode 100644 tests/baselines/reference/exportDefaultProperty.js create mode 100644 tests/baselines/reference/exportDefaultProperty.symbols create mode 100644 tests/baselines/reference/exportDefaultProperty.types create mode 100644 tests/cases/compiler/exportDefaultProperty.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 04c12eb613c..6d670c70541 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -968,28 +968,39 @@ namespace ts { function checkAndReportErrorForExtendingInterface(errorLocation: Node): boolean { - let parentClassExpression = errorLocation; - while (parentClassExpression) { - const kind = parentClassExpression.kind; - if (kind === SyntaxKind.Identifier || kind === SyntaxKind.PropertyAccessExpression) { - parentClassExpression = parentClassExpression.parent; - continue; - } - if (kind === SyntaxKind.ExpressionWithTypeArguments) { - break; - } + const parentExpression = climbToSupportedExpressionWithTypeArguments(errorLocation); + if (!parentExpression) { return false; } - if (!parentClassExpression) { - return false; - } - const expression = (parentClassExpression).expression; + const expression = parentExpression.expression; + if (resolveEntityName(expression, SymbolFlags.Interface, /*ignoreErrors*/ true)) { error(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression)); return true; } return false; } + /** + * Climbs up parents to a SupportedExpressionWIthTypeArguments. + * Does *not* just climb to an ExpressionWithTypeArguments; instead, ensures that this really is supported. + */ + function climbToSupportedExpressionWithTypeArguments(node: Node): SupportedExpressionWithTypeArguments | undefined { + while (node) { + switch (node.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.PropertyAccessExpression: + node = node.parent; + break; + case SyntaxKind.ExpressionWithTypeArguments: + Debug.assert(isSupportedExpressionWithTypeArguments(node)); + return node; + default: + return undefined; + } + } + return undefined; + } + function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); @@ -1274,7 +1285,7 @@ namespace ts { } // Resolves a qualified name and any involved aliases - function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean): Symbol { + function resolveEntityName(name: EntityNameOrEntityNameExpression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean): Symbol | undefined { if (nodeIsMissing(name)) { return undefined; } @@ -1289,7 +1300,7 @@ namespace ts { } } else if (name.kind === SyntaxKind.QualifiedName || name.kind === SyntaxKind.PropertyAccessExpression) { - const left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; + const left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; const right = name.kind === SyntaxKind.QualifiedName ? (name).right : (name).name; const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors); @@ -1845,7 +1856,7 @@ namespace ts { } } - function isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult { + function isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult { // get symbol of the first identifier of the entityName let meaning: SymbolFlags; if (entityName.parent.kind === SyntaxKind.TypeQuery || isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -5022,7 +5033,7 @@ namespace ts { return getDeclaredTypeOfSymbol(symbol); } - function getTypeReferenceName(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): LeftHandSideExpression | EntityName { + function getTypeReferenceName(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): EntityNameOrEntityNameExpression | undefined { switch (node.kind) { case SyntaxKind.TypeReference: return (node).typeName; @@ -5031,8 +5042,9 @@ namespace ts { case SyntaxKind.ExpressionWithTypeArguments: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. - if (isSupportedExpressionWithTypeArguments(node)) { - return (node).expression; + const expr = node; + if (isSupportedExpressionWithTypeArguments(expr)) { + return expr.expression; } // fall through; @@ -5043,7 +5055,7 @@ namespace ts { function resolveTypeReferenceName( node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, - typeReferenceName: LeftHandSideExpression | EntityName) { + typeReferenceName: EntityNameExpression | EntityName) { if (!typeReferenceName) { return unknownSymbol; @@ -5084,15 +5096,14 @@ namespace ts { const typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(node, typeReferenceName); type = getTypeReferenceType(node, symbol); - - links.resolvedSymbol = symbol; - links.resolvedType = type; } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - const typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : - isSupportedExpressionWithTypeArguments(node) ? (node).expression : - undefined; + const typeNameOrExpression: EntityNameOrEntityNameExpression = node.kind === SyntaxKind.TypeReference + ? (node).typeName + : isSupportedExpressionWithTypeArguments(node) + ? (node).expression + : undefined; symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : @@ -16951,20 +16962,21 @@ namespace ts { } } - function getFirstIdentifier(node: EntityName | Expression): Identifier { - while (true) { - if (node.kind === SyntaxKind.QualifiedName) { - node = (node).left; - } - else if (node.kind === SyntaxKind.PropertyAccessExpression) { - node = (node).expression; - } - else { - break; - } + function getFirstIdentifier(node: EntityNameOrEntityNameExpression): Identifier { + switch (node.kind) { + case SyntaxKind.Identifier: + return node; + case SyntaxKind.QualifiedName: + do { + node = (node).left; + } while (node.kind !== SyntaxKind.Identifier); + return node; + case SyntaxKind.PropertyAccessExpression: + do { + node = (node).expression; + } while (node.kind !== SyntaxKind.Identifier); + return node; } - Debug.assert(node.kind === SyntaxKind.Identifier); - return node; } function checkExternalImportOrExportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean { @@ -17663,7 +17675,7 @@ namespace ts { return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } - function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol { + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol | undefined { if (isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } @@ -17682,8 +17694,8 @@ namespace ts { } } - if (entityName.parent.kind === SyntaxKind.ExportAssignment) { - return resolveEntityName(entityName, + if (entityName.parent.kind === SyntaxKind.ExportAssignment && isEntityNameExpression(entityName)) { + return resolveEntityName(entityName, /*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } @@ -17697,7 +17709,7 @@ namespace ts { } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; + entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { @@ -18410,7 +18422,7 @@ namespace ts { }; // defined here to avoid outer scope pollution - function getTypeReferenceDirectivesForEntityName(node: EntityName | PropertyAccessExpression): string[] { + function getTypeReferenceDirectivesForEntityName(node: EntityNameOrEntityNameExpression): string[] { // program does not have any files with type reference directives - bail out if (!fileToDirective) { return undefined; diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index d93a8a0aed0..220244c55af 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -441,7 +441,7 @@ namespace ts { } } - function emitEntityName(entityName: EntityName | PropertyAccessExpression) { + function emitEntityName(entityName: EntityNameOrEntityNameExpression) { const visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration entityName.parent.kind === SyntaxKind.ImportEqualsDeclaration ? entityName.parent : enclosingDeclaration); @@ -454,7 +454,7 @@ namespace ts { function emitExpressionWithTypeArguments(node: ExpressionWithTypeArguments) { if (isSupportedExpressionWithTypeArguments(node)) { Debug.assert(node.expression.kind === SyntaxKind.Identifier || node.expression.kind === SyntaxKind.PropertyAccessExpression); - emitEntityName(node.expression); + emitEntityName(node.expression); if (node.typeArguments) { write("<"); emitCommaList(node.typeArguments, emitType); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 072209aa496..983ed25c848 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -982,13 +982,19 @@ namespace ts { multiLine?: boolean; } + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + // @kind(SyntaxKind.PropertyAccessExpression) export interface PropertyAccessExpression extends MemberExpression, Declaration { expression: LeftHandSideExpression; name: Identifier; } - - export type IdentifierOrPropertyAccess = Identifier | PropertyAccessExpression; + /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ + export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + _propertyAccessExpressionLikeQualifiedNameBrand?: any; + expression: EntityNameExpression; + } // @kind(SyntaxKind.ElementAccessExpression) export interface ElementAccessExpression extends MemberExpression { @@ -1008,6 +1014,10 @@ namespace ts { expression: LeftHandSideExpression; typeArguments?: NodeArray; } + export interface SupportedExpressionWithTypeArguments extends ExpressionWithTypeArguments { + _supportedExpressionWithTypeArgumentsBrand?: any; + expression: EntityNameExpression; + } // @kind(SyntaxKind.NewExpression) export interface NewExpression extends CallExpression, PrimaryExpression { } @@ -2021,7 +2031,7 @@ namespace ts { writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult; - isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult; + isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; getReferencedValueDeclaration(reference: Identifier): Declaration; @@ -2030,7 +2040,7 @@ namespace ts { moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; isArgumentsLocalBinding(node: Identifier): boolean; getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; - getTypeReferenceDirectivesForEntityName(name: EntityName | PropertyAccessExpression): string[]; + getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4ae0005e9c5..acace78396b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1033,14 +1033,14 @@ namespace ts { && (node).expression.kind === SyntaxKind.SuperKeyword; } - - export function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression { + export function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression { if (node) { switch (node.kind) { case SyntaxKind.TypeReference: return (node).typeName; case SyntaxKind.ExpressionWithTypeArguments: - return (node).expression; + Debug.assert(isSupportedExpressionWithTypeArguments(node)); + return (node).expression; case SyntaxKind.Identifier: case SyntaxKind.QualifiedName: return (node); @@ -2680,24 +2680,28 @@ namespace ts { isClassLike(node.parent.parent); } - // Returns false if this heritage clause element's expression contains something unsupported - // (i.e. not a name or dotted name). - export function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): boolean { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); + export function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): node is SupportedExpressionWithTypeArguments { + return isEntityNameExpression(node.expression); } - function isSupportedExpressionWithTypeArgumentsRest(node: Expression): boolean { - if (node.kind === SyntaxKind.Identifier) { - return true; - } - else if (isPropertyAccessExpression(node)) { - return isSupportedExpressionWithTypeArgumentsRest(node.expression); - } - else { - return false; + export function isEntityNameExpression(node: Expression): node is EntityNameExpression { + for (; ; ) { + switch (node.kind) { + case SyntaxKind.Identifier: + return true; + case SyntaxKind.PropertyAccessExpression: + node = (node).expression; + break; + default: + return false; + } } } + export function isPropertyAccessAnEntityNameExpression(node: PropertyAccessExpression): node is PropertyAccessEntityNameExpression { + return isEntityNameExpression(node.expression); + } + export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) { return (node.parent.kind === SyntaxKind.QualifiedName && (node.parent).right === node) || (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); diff --git a/tests/baselines/reference/exportDefaultProperty.js b/tests/baselines/reference/exportDefaultProperty.js new file mode 100644 index 00000000000..efb4ee8bff3 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty.js @@ -0,0 +1,8 @@ +//// [exportDefaultProperty.ts] +export default "".length + + +//// [exportDefaultProperty.js] +"use strict"; +exports.__esModule = true; +exports["default"] = "".length; diff --git a/tests/baselines/reference/exportDefaultProperty.symbols b/tests/baselines/reference/exportDefaultProperty.symbols new file mode 100644 index 00000000000..2bc00e48fec --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty.symbols @@ -0,0 +1,5 @@ +=== tests/cases/compiler/exportDefaultProperty.ts === +export default "".length +>"".length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/exportDefaultProperty.types b/tests/baselines/reference/exportDefaultProperty.types new file mode 100644 index 00000000000..82e6277b292 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty.types @@ -0,0 +1,6 @@ +=== tests/cases/compiler/exportDefaultProperty.ts === +export default "".length +>"".length : number +>"" : string +>length : number + diff --git a/tests/cases/compiler/exportDefaultProperty.ts b/tests/cases/compiler/exportDefaultProperty.ts new file mode 100644 index 00000000000..4df2eb692a8 --- /dev/null +++ b/tests/cases/compiler/exportDefaultProperty.ts @@ -0,0 +1 @@ +export default "".length From f9fd4967af519473bdf32395df677b2bc966c64e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 29 Jul 2016 08:06:04 -0700 Subject: [PATCH 045/508] Allow `export =` and `export default` to alias any EntityNameExpression, not just identifiers. --- src/compiler/binder.ts | 13 ++- src/compiler/checker.ts | 4 +- src/compiler/core.ts | 15 ++- src/compiler/utilities.ts | 10 +- .../reference/exportDefaultProperty.js | 76 +++++++++++++- .../reference/exportDefaultProperty.symbols | 93 ++++++++++++++++- .../reference/exportDefaultProperty.types | 99 ++++++++++++++++++- .../reference/exportEqualsProperty.js | 72 ++++++++++++++ .../reference/exportEqualsProperty.symbols | 87 ++++++++++++++++ .../reference/exportEqualsProperty.types | 92 +++++++++++++++++ tests/cases/compiler/exportDefaultProperty.ts | 40 +++++++- tests/cases/compiler/exportEqualsProperty.ts | 38 +++++++ 12 files changed, 613 insertions(+), 26 deletions(-) create mode 100644 tests/baselines/reference/exportEqualsProperty.js create mode 100644 tests/baselines/reference/exportEqualsProperty.symbols create mode 100644 tests/baselines/reference/exportEqualsProperty.types create mode 100644 tests/cases/compiler/exportEqualsProperty.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 8d8666a67ab..502cb39e8fe 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1887,18 +1887,17 @@ namespace ts { } function bindExportAssignment(node: ExportAssignment | BinaryExpression) { - const boundExpression = node.kind === SyntaxKind.ExportAssignment ? (node).expression : (node).right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)); } - else if (boundExpression.kind === SyntaxKind.Identifier && node.kind === SyntaxKind.ExportAssignment) { - // An export default clause with an identifier exports all meanings of that identifier - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); - } else { - // An export default clause with an expression exports a value - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); + const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node) + // An export default clause with an EntityNameExpression exports all meanings of that identifier + ? SymbolFlags.Alias + // An export default clause with any other expression exports a value + : SymbolFlags.Property; + declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6d670c70541..21d74bb24b8 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1044,7 +1044,7 @@ namespace ts { } function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration { - return forEach(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); + return find(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); } function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration): Symbol { @@ -1175,7 +1175,7 @@ namespace ts { } function getTargetOfExportAssignment(node: ExportAssignment): Symbol { - return resolveEntityName(node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace); + return resolveEntityName(node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace); } function getTargetOfAliasDeclaration(node: Declaration): Symbol { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 709a331e022..cd332b6bef3 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -81,7 +81,7 @@ namespace ts { * returns a truthy value, then returns that value. * If no such value is found, the callback is applied to each element of array and undefined is returned. */ - export function forEach(array: T[], callback: (element: T, index: number) => U): U { + export function forEach(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { if (array) { for (let i = 0, len = array.length; i < len; i++) { const result = callback(array[i], i); @@ -93,6 +93,17 @@ namespace ts { return undefined; } + /** Like `forEach`, but assumes existence of array and fails if no truthy value is found. */ + export function find(array: T[], callback: (element: T, index: number) => U | undefined): U { + for (let i = 0, len = array.length; i < len; i++) { + const result = callback(array[i], i); + if (result) { + return result; + } + } + Debug.fail(); + } + export function contains(array: T[], value: T): boolean { if (array) { for (const v of array) { @@ -941,7 +952,7 @@ namespace ts { * [^./] # matches everything up to the first . character (excluding directory seperators) * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension */ - const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; + const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; const singleAsteriskRegexFragmentOther = "[^/]*"; export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index acace78396b..466cf8c2b77 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1693,8 +1693,8 @@ namespace ts { // import * as from ... // import { x as } from ... // export { x as } from ... - // export = ... - // export default ... + // export = + // export default export function isAliasSymbolDeclaration(node: Node): boolean { return node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.NamespaceExportDeclaration || @@ -1702,7 +1702,11 @@ namespace ts { node.kind === SyntaxKind.NamespaceImport || node.kind === SyntaxKind.ImportSpecifier || node.kind === SyntaxKind.ExportSpecifier || - node.kind === SyntaxKind.ExportAssignment && (node).expression.kind === SyntaxKind.Identifier; + node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node); + } + + export function exportAssignmentIsAlias(node: ExportAssignment): boolean { + return isEntityNameExpression(node.expression); } export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration) { diff --git a/tests/baselines/reference/exportDefaultProperty.js b/tests/baselines/reference/exportDefaultProperty.js index efb4ee8bff3..10ba6d6419a 100644 --- a/tests/baselines/reference/exportDefaultProperty.js +++ b/tests/baselines/reference/exportDefaultProperty.js @@ -1,8 +1,76 @@ -//// [exportDefaultProperty.ts] -export default "".length +//// [tests/cases/compiler/exportDefaultProperty.ts] //// + +//// [declarations.d.ts] +// This test is just like exportEqualsProperty, but with `export default`. + +declare namespace foo.bar { + export type X = number; + export const X: number; +} + +declare module "foobar" { + export default foo.bar; +} + +declare module "foobarx" { + export default foo.bar.X; +} + +//// [a.ts] +namespace A { + export class B { constructor(b: number) {} } + export namespace B { export const b: number = 0; } +} +export default A.B; + +//// [b.ts] +export default "foo".length; + +//// [index.ts] +/// +import fooBar from "foobar"; +import X = fooBar.X; +import X2 from "foobarx"; +const x: X = X; +const x2: X2 = X2; + +import B from "./a"; +const b: B = new B(B.b); + +import fooLength from "./b"; +fooLength + 1; -//// [exportDefaultProperty.js] +//// [a.js] +"use strict"; +var A; +(function (A) { + var B = (function () { + function B(b) { + } + return B; + }()); + A.B = B; + var B; + (function (B) { + B.b = 0; + })(B = A.B || (A.B = {})); +})(A || (A = {})); +exports.__esModule = true; +exports["default"] = A.B; +//// [b.js] "use strict"; exports.__esModule = true; -exports["default"] = "".length; +exports["default"] = "foo".length; +//// [index.js] +"use strict"; +/// +var foobar_1 = require("foobar"); +var X = foobar_1["default"].X; +var foobarx_1 = require("foobarx"); +var x = X; +var x2 = foobarx_1["default"]; +var a_1 = require("./a"); +var b = new a_1["default"](a_1["default"].b); +var b_1 = require("./b"); +b_1["default"] + 1; diff --git a/tests/baselines/reference/exportDefaultProperty.symbols b/tests/baselines/reference/exportDefaultProperty.symbols index 2bc00e48fec..f9edcd154cc 100644 --- a/tests/baselines/reference/exportDefaultProperty.symbols +++ b/tests/baselines/reference/exportDefaultProperty.symbols @@ -1,5 +1,92 @@ -=== tests/cases/compiler/exportDefaultProperty.ts === -export default "".length ->"".length : Symbol(String.length, Decl(lib.d.ts, --, --)) +=== tests/cases/compiler/index.ts === +/// +import fooBar from "foobar"; +>fooBar : Symbol(fooBar, Decl(index.ts, 1, 6)) + +import X = fooBar.X; +>X : Symbol(X, Decl(index.ts, 1, 28)) +>fooBar : Symbol(fooBar, Decl(index.ts, 1, 6)) +>X : Symbol(fooBar.X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) + +import X2 from "foobarx"; +>X2 : Symbol(X2, Decl(index.ts, 3, 6)) + +const x: X = X; +>x : Symbol(x, Decl(index.ts, 4, 5)) +>X : Symbol(X, Decl(index.ts, 1, 28)) +>X : Symbol(X, Decl(index.ts, 1, 28)) + +const x2: X2 = X2; +>x2 : Symbol(x2, Decl(index.ts, 5, 5)) +>X2 : Symbol(X2, Decl(index.ts, 3, 6)) +>X2 : Symbol(X2, Decl(index.ts, 3, 6)) + +import B from "./a"; +>B : Symbol(B, Decl(index.ts, 7, 6)) + +const b: B = new B(B.b); +>b : Symbol(b, Decl(index.ts, 8, 5)) +>B : Symbol(B, Decl(index.ts, 7, 6)) +>B : Symbol(B, Decl(index.ts, 7, 6)) +>B.b : Symbol(B.b, Decl(a.ts, 2, 37)) +>B : Symbol(B, Decl(index.ts, 7, 6)) +>b : Symbol(B.b, Decl(a.ts, 2, 37)) + +import fooLength from "./b"; +>fooLength : Symbol(fooLength, Decl(index.ts, 10, 6)) + +fooLength + 1; +>fooLength : Symbol(fooLength, Decl(index.ts, 10, 6)) + +=== tests/cases/compiler/declarations.d.ts === +// This test is just like exportEqualsProperty, but with `export default`. + +declare namespace foo.bar { +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(bar, Decl(declarations.d.ts, 2, 22)) + + export type X = number; +>X : Symbol(X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) + + export const X: number; +>X : Symbol(X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +} + +declare module "foobar" { + export default foo.bar; +>foo.bar : Symbol(default, Decl(declarations.d.ts, 2, 22)) +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(default, Decl(declarations.d.ts, 2, 22)) +} + +declare module "foobarx" { + export default foo.bar.X; +>foo.bar.X : Symbol(default, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +>foo.bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>X : Symbol(default, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +} + +=== tests/cases/compiler/a.ts === +namespace A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export class B { constructor(b: number) {} } +>B : Symbol(B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>b : Symbol(b, Decl(a.ts, 1, 33)) + + export namespace B { export const b: number = 0; } +>B : Symbol(B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>b : Symbol(b, Decl(a.ts, 2, 37)) +} +export default A.B; +>A.B : Symbol(default, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>A : Symbol(A, Decl(a.ts, 0, 0)) +>B : Symbol(default, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) + +=== tests/cases/compiler/b.ts === +export default "foo".length; +>"foo".length : Symbol(String.length, Decl(lib.d.ts, --, --)) >length : Symbol(String.length, Decl(lib.d.ts, --, --)) diff --git a/tests/baselines/reference/exportDefaultProperty.types b/tests/baselines/reference/exportDefaultProperty.types index 82e6277b292..47cfabfbc16 100644 --- a/tests/baselines/reference/exportDefaultProperty.types +++ b/tests/baselines/reference/exportDefaultProperty.types @@ -1,6 +1,97 @@ -=== tests/cases/compiler/exportDefaultProperty.ts === -export default "".length ->"".length : number ->"" : string +=== tests/cases/compiler/index.ts === +/// +import fooBar from "foobar"; +>fooBar : typeof fooBar + +import X = fooBar.X; +>X : number +>fooBar : typeof fooBar +>X : number + +import X2 from "foobarx"; +>X2 : number + +const x: X = X; +>x : number +>X : number +>X : number + +const x2: X2 = X2; +>x2 : number +>X2 : number +>X2 : number + +import B from "./a"; +>B : typeof B + +const b: B = new B(B.b); +>b : B +>B : B +>new B(B.b) : B +>B : typeof B +>B.b : number +>B : typeof B +>b : number + +import fooLength from "./b"; +>fooLength : number + +fooLength + 1; +>fooLength + 1 : number +>fooLength : number +>1 : number + +=== tests/cases/compiler/declarations.d.ts === +// This test is just like exportEqualsProperty, but with `export default`. + +declare namespace foo.bar { +>foo : typeof foo +>bar : typeof bar + + export type X = number; +>X : number + + export const X: number; +>X : number +} + +declare module "foobar" { + export default foo.bar; +>foo.bar : typeof default +>foo : typeof foo +>bar : typeof default +} + +declare module "foobarx" { + export default foo.bar.X; +>foo.bar.X : number +>foo.bar : typeof foo.bar +>foo : typeof foo +>bar : typeof foo.bar +>X : number +} + +=== tests/cases/compiler/a.ts === +namespace A { +>A : typeof A + + export class B { constructor(b: number) {} } +>B : B +>b : number + + export namespace B { export const b: number = 0; } +>B : typeof B +>b : number +>0 : number +} +export default A.B; +>A.B : typeof default +>A : typeof A +>B : typeof default + +=== tests/cases/compiler/b.ts === +export default "foo".length; +>"foo".length : number +>"foo" : string >length : number diff --git a/tests/baselines/reference/exportEqualsProperty.js b/tests/baselines/reference/exportEqualsProperty.js new file mode 100644 index 00000000000..2fd8a8c8511 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty.js @@ -0,0 +1,72 @@ +//// [tests/cases/compiler/exportEqualsProperty.ts] //// + +//// [declarations.d.ts] +// This test is just like exportDefaultProperty, but with `export =`. + +declare namespace foo.bar { + export type X = number; + export const X: number; +} + +declare module "foobar" { + export = foo.bar; +} + +declare module "foobarx" { + export = foo.bar.X; +} + +//// [a.ts] +namespace A { + export class B { constructor(b: number) {} } + export namespace B { export const b: number = 0; } +} +export = A.B; + +//// [b.ts] +export = "foo".length; + +//// [index.ts] +/// +import { X } from "foobar"; +import X2 = require("foobarx"); +const x: X = X; +const x2: X2 = X2; + +import B = require("./a"); +const b: B = new B(B.b); + +import fooLength = require("./b"); +fooLength + 1; + + +//// [a.js] +"use strict"; +var A; +(function (A) { + var B = (function () { + function B(b) { + } + return B; + }()); + A.B = B; + var B; + (function (B) { + B.b = 0; + })(B = A.B || (A.B = {})); +})(A || (A = {})); +module.exports = A.B; +//// [b.js] +"use strict"; +module.exports = "foo".length; +//// [index.js] +"use strict"; +/// +var foobar_1 = require("foobar"); +var X2 = require("foobarx"); +var x = foobar_1.X; +var x2 = X2; +var B = require("./a"); +var b = new B(B.b); +var fooLength = require("./b"); +fooLength + 1; diff --git a/tests/baselines/reference/exportEqualsProperty.symbols b/tests/baselines/reference/exportEqualsProperty.symbols new file mode 100644 index 00000000000..43c9ed32518 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty.symbols @@ -0,0 +1,87 @@ +=== tests/cases/compiler/index.ts === +/// +import { X } from "foobar"; +>X : Symbol(X, Decl(index.ts, 1, 8)) + +import X2 = require("foobarx"); +>X2 : Symbol(X2, Decl(index.ts, 1, 27)) + +const x: X = X; +>x : Symbol(x, Decl(index.ts, 3, 5)) +>X : Symbol(X, Decl(index.ts, 1, 8)) +>X : Symbol(X, Decl(index.ts, 1, 8)) + +const x2: X2 = X2; +>x2 : Symbol(x2, Decl(index.ts, 4, 5)) +>X2 : Symbol(X2, Decl(index.ts, 1, 27)) +>X2 : Symbol(X2, Decl(index.ts, 1, 27)) + +import B = require("./a"); +>B : Symbol(B, Decl(index.ts, 4, 18)) + +const b: B = new B(B.b); +>b : Symbol(b, Decl(index.ts, 7, 5)) +>B : Symbol(B, Decl(index.ts, 4, 18)) +>B : Symbol(B, Decl(index.ts, 4, 18)) +>B.b : Symbol(B.b, Decl(a.ts, 2, 37)) +>B : Symbol(B, Decl(index.ts, 4, 18)) +>b : Symbol(B.b, Decl(a.ts, 2, 37)) + +import fooLength = require("./b"); +>fooLength : Symbol(fooLength, Decl(index.ts, 7, 24)) + +fooLength + 1; +>fooLength : Symbol(fooLength, Decl(index.ts, 7, 24)) + +=== tests/cases/compiler/declarations.d.ts === +// This test is just like exportDefaultProperty, but with `export =`. + +declare namespace foo.bar { +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(bar, Decl(declarations.d.ts, 2, 22)) + + export type X = number; +>X : Symbol(X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) + + export const X: number; +>X : Symbol(X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +} + +declare module "foobar" { + export = foo.bar; +>foo.bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +} + +declare module "foobarx" { + export = foo.bar.X; +>foo.bar.X : Symbol(foo.bar.X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +>foo.bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>X : Symbol(foo.bar.X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +} + +=== tests/cases/compiler/a.ts === +namespace A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export class B { constructor(b: number) {} } +>B : Symbol(B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>b : Symbol(b, Decl(a.ts, 1, 33)) + + export namespace B { export const b: number = 0; } +>B : Symbol(B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>b : Symbol(b, Decl(a.ts, 2, 37)) +} +export = A.B; +>A.B : Symbol(A.B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>A : Symbol(A, Decl(a.ts, 0, 0)) +>B : Symbol(A.B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) + +=== tests/cases/compiler/b.ts === +export = "foo".length; +>"foo".length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/exportEqualsProperty.types b/tests/baselines/reference/exportEqualsProperty.types new file mode 100644 index 00000000000..a92af53b12b --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty.types @@ -0,0 +1,92 @@ +=== tests/cases/compiler/index.ts === +/// +import { X } from "foobar"; +>X : number + +import X2 = require("foobarx"); +>X2 : number + +const x: X = X; +>x : number +>X : number +>X : number + +const x2: X2 = X2; +>x2 : number +>X2 : number +>X2 : number + +import B = require("./a"); +>B : typeof B + +const b: B = new B(B.b); +>b : B +>B : B +>new B(B.b) : B +>B : typeof B +>B.b : number +>B : typeof B +>b : number + +import fooLength = require("./b"); +>fooLength : number + +fooLength + 1; +>fooLength + 1 : number +>fooLength : number +>1 : number + +=== tests/cases/compiler/declarations.d.ts === +// This test is just like exportDefaultProperty, but with `export =`. + +declare namespace foo.bar { +>foo : typeof foo +>bar : typeof bar + + export type X = number; +>X : number + + export const X: number; +>X : number +} + +declare module "foobar" { + export = foo.bar; +>foo.bar : typeof foo.bar +>foo : typeof foo +>bar : typeof foo.bar +} + +declare module "foobarx" { + export = foo.bar.X; +>foo.bar.X : number +>foo.bar : typeof foo.bar +>foo : typeof foo +>bar : typeof foo.bar +>X : number +} + +=== tests/cases/compiler/a.ts === +namespace A { +>A : typeof A + + export class B { constructor(b: number) {} } +>B : B +>b : number + + export namespace B { export const b: number = 0; } +>B : typeof B +>b : number +>0 : number +} +export = A.B; +>A.B : typeof A.B +>A : typeof A +>B : typeof A.B + +=== tests/cases/compiler/b.ts === +export = "foo".length; +>"foo".length : number +>"foo" : string +>length : number + diff --git a/tests/cases/compiler/exportDefaultProperty.ts b/tests/cases/compiler/exportDefaultProperty.ts index 4df2eb692a8..4a4b4139025 100644 --- a/tests/cases/compiler/exportDefaultProperty.ts +++ b/tests/cases/compiler/exportDefaultProperty.ts @@ -1 +1,39 @@ -export default "".length +// This test is just like exportEqualsProperty, but with `export default`. + +// @Filename: declarations.d.ts +declare namespace foo.bar { + export type X = number; + export const X: number; +} + +declare module "foobar" { + export default foo.bar; +} + +declare module "foobarx" { + export default foo.bar.X; +} + +// @Filename: a.ts +namespace A { + export class B { constructor(b: number) {} } + export namespace B { export const b: number = 0; } +} +export default A.B; + +// @Filename: b.ts +export default "foo".length; + +// @Filename: index.ts +/// +import fooBar from "foobar"; +import X = fooBar.X; +import X2 from "foobarx"; +const x: X = X; +const x2: X2 = X2; + +import B from "./a"; +const b: B = new B(B.b); + +import fooLength from "./b"; +fooLength + 1; diff --git a/tests/cases/compiler/exportEqualsProperty.ts b/tests/cases/compiler/exportEqualsProperty.ts new file mode 100644 index 00000000000..0d14815a5bd --- /dev/null +++ b/tests/cases/compiler/exportEqualsProperty.ts @@ -0,0 +1,38 @@ +// This test is just like exportDefaultProperty, but with `export =`. + +// @Filename: declarations.d.ts +declare namespace foo.bar { + export type X = number; + export const X: number; +} + +declare module "foobar" { + export = foo.bar; +} + +declare module "foobarx" { + export = foo.bar.X; +} + +// @Filename: a.ts +namespace A { + export class B { constructor(b: number) {} } + export namespace B { export const b: number = 0; } +} +export = A.B; + +// @Filename: b.ts +export = "foo".length; + +// @Filename: index.ts +/// +import { X } from "foobar"; +import X2 = require("foobarx"); +const x: X = X; +const x2: X2 = X2; + +import B = require("./a"); +const b: B = new B(B.b); + +import fooLength = require("./b"); +fooLength + 1; From c50ccbf9616bbb06e7f73203a7e0134ab852f0d6 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 29 Jul 2016 12:31:02 -0700 Subject: [PATCH 046/508] Simplify some code --- src/compiler/checker.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 21d74bb24b8..ca665346036 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17699,13 +17699,11 @@ namespace ts { /*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } - if (entityName.kind !== SyntaxKind.PropertyAccessExpression) { - if (isInRightSideOfImportOrExportAssignment(entityName)) { - // Since we already checked for ExportAssignment, this really could only be an Import - const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); - Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); - } + if (entityName.kind !== SyntaxKind.PropertyAccessExpression && isInRightSideOfImportOrExportAssignment(entityName)) { + // Since we already checked for ExportAssignment, this really could only be an Import + const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); + Debug.assert(importEqualsDeclaration !== undefined); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { From 167d318a1375a467877bc6d6672a0015e3e684bd Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 25 Jul 2016 14:48:41 -0700 Subject: [PATCH 047/508] Draft of configuration inheritance --- Jakefile.js | 1 + src/compiler/commandLineParser.ts | 81 +++++- src/compiler/core.ts | 30 ++- src/compiler/diagnosticMessages.json | 9 + src/compiler/types.ts | 2 + src/harness/harness.ts | 3 +- src/harness/projectsRunner.ts | 5 + src/harness/rwcRunner.ts | 1 + src/harness/tsconfig.json | 1 + .../unittests/configurationExtension.ts | 230 ++++++++++++++++++ src/harness/virtualFileSystem.ts | 25 +- 11 files changed, 374 insertions(+), 14 deletions(-) create mode 100644 src/harness/unittests/configurationExtension.ts diff --git a/Jakefile.js b/Jakefile.js index f63275284d0..d6a2f253ac8 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -155,6 +155,7 @@ var harnessSources = harnessCoreSources.concat([ "moduleResolution.ts", "tsconfigParsing.ts", "commandLineParsing.ts", + "configurationExtension.ts", "convertCompilerOptionsFromJson.ts", "convertTypingOptionsFromJson.ts", "tsserverProjectSystem.ts", diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7e2c6eb8d33..41a126f234d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -700,12 +700,54 @@ namespace ts { * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string): ParsedCommandLine { + export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = []): ParsedCommandLine { const errors: Diagnostic[] = []; - const compilerOptions: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); - const options = extend(existingOptions, compilerOptions); + const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); + const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName); + if (resolutionStack.indexOf(resolvedPath) >= 0) { + return { + options: {}, + fileNames: [], + typingOptions: {}, + raw: json, + errors: [createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))], + wildcardDirectories: {} + }; + } + + let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); const typingOptions: TypingOptions = convertTypingOptionsFromJsonWorker(json["typingOptions"], basePath, errors, configFileName); + if (json["extends"]) { + let [include, exclude, files, baseOptions]: [string[], string[], string[], CompilerOptions] = [undefined, undefined, undefined, {}]; + if (typeof json["extends"] === "string") { + [include, exclude, files, baseOptions] = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]); + } + else if (typeof json["extends"] === "object" && json["extends"].length) { + for (const name of json["extends"]) { + const [tempinclude, tempexclude, tempfiles, tempBase]: [string[], string[], string[], CompilerOptions] = (tryExtendsName(name) || [include, exclude, files, baseOptions]); + include = tempinclude || include; + exclude = tempexclude || exclude; + files = tempfiles || files; + baseOptions = assign({}, baseOptions, tempBase); + } + } + else { + errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string or string[]")); + } + if (include && !json["include"]) { + json["include"] = include; + } + if (exclude && !json["exclude"]) { + json["exclude"] = exclude; + } + if (files && !json["files"]) { + json["files"] = files; + } + options = assign({}, baseOptions, options); + } + + options = extend(existingOptions, options); options.configFilePath = configFileName; const { fileNames, wildcardDirectories } = getFileNames(errors); @@ -719,6 +761,39 @@ namespace ts { wildcardDirectories }; + function tryExtendsName(extendedConfig: string): [string[], string[], string[], CompilerOptions] { + // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) + if (!(isRootedDiskPath(extendedConfig) || startsWith(normalizeSlashes(extendedConfig), "./") || startsWith(normalizeSlashes(extendedConfig), "../"))) { + errors.push(createCompilerDiagnostic(Diagnostics.The_path_in_an_extends_options_must_be_relative_or_rooted)); + return; + } + let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = `${extendedConfigPath}.json` as Path; + if (!host.fileExists(extendedConfigPath)) { + errors.push(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, extendedConfig)); + return; + } + } + const extendedResult = readConfigFile(extendedConfigPath, path => host.readFile(path)); + if (extendedResult.error) { + errors.push(extendedResult.error); + return; + } + const extendedDirname = getDirectoryPath(extendedConfigPath); + const relativeDifference = convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + const updatePath: (path: string) => string = path => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path); + // Merge configs (copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios) + const result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, /*existingOptions*/undefined, getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); + errors.push(...result.errors); + const [include, exclude, files] = map(["include", "exclude", "files"], key => { + if (!json[key] && extendedResult.config[key]) { + return map(extendedResult.config[key], updatePath); + } + }); + return [include, exclude, files, result.options]; + } + function getFileNames(errors: Diagnostic[]): ExpandResult { let fileNames: string[]; if (hasProperty(json, "files")) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 709a331e022..089ed967515 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -171,6 +171,20 @@ namespace ts { return result; } + export function mapObject(object: Map, f: (key: string, x: T) => [string, U]): Map { + let result: Map = {}; + if (object) { + result = {}; + for (const v of getKeys(object)) { + const [key, value]: [string, U] = f(v, object[v]) || [undefined, undefined]; + if (key !== undefined) { + result[key] = value; + } + } + } + return result; + } + export function concatenate(array1: T[], array2: T[]): T[] { if (!array2 || !array2.length) return array1; if (!array1 || !array1.length) return array2; @@ -357,6 +371,20 @@ namespace ts { return result; } + export function assign, T2, T3>(t: T1, arg1: T2, arg2: T3): T1 & T2 & T3; + export function assign, T2>(t: T1, arg1: T2): T1 & T2; + export function assign>(t: T1, ...args: any[]): any; + export function assign>(t: T1, ...args: any[]) { + for (const arg of args) { + for (const p of getKeys(arg)) { + if (hasProperty(arg, p)) { + t[p] = arg[p]; + } + } + } + return t; + } + export function forEachValue(map: Map, callback: (value: T) => U): U { let result: U; for (const id in map) { @@ -941,7 +969,7 @@ namespace ts { * [^./] # matches everything up to the first . character (excluding directory seperators) * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension */ - const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; + const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; const singleAsteriskRegexFragmentOther = "[^/]*"; export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8126d5c605e..fedaf02b4a0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -3031,5 +3031,14 @@ "Unknown typing option '{0}'.": { "category": "Error", "code": 17010 + }, + + "Circularity detected while resolving configuration: {0}": { + "category": "Error", + "code": 18000 + }, + "The path in an 'extends' options must be relative or rooted.": { + "category": "Error", + "code": 18001 } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 072209aa496..95e2e358e24 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1693,6 +1693,8 @@ namespace ts { * @param path The path to test. */ fileExists(path: string): boolean; + + readFile(path: string): string; } export interface WriteFileCallback { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index f27e7e1c174..6649463edb9 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1540,7 +1540,8 @@ namespace Harness { const parseConfigHost: ts.ParseConfigHost = { useCaseSensitiveFileNames: false, readDirectory: (name) => [], - fileExists: (name) => true + fileExists: (name) => true, + readFile: (name) => ts.forEach(testUnitData, data => data.name.toLowerCase() === name.toLowerCase() ? data.content : undefined) }; // check if project has tsconfig.json in the list of files diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 038b2dbe359..64ed9ff79a4 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -222,6 +222,7 @@ class ProjectRunner extends RunnerBase { useCaseSensitiveFileNames: Harness.IO.useCaseSensitiveFileNames(), fileExists, readDirectory, + readFile }; const configParseResult = ts.parseJsonConfigFileContent(configObject, configParseHost, ts.getDirectoryPath(configFileName), compilerOptions); if (configParseResult.errors.length > 0) { @@ -295,6 +296,10 @@ class ProjectRunner extends RunnerBase { return Harness.IO.fileExists(getFileNameInTheProjectTest(fileName)); } + function readFile(fileName: string): string { + return Harness.IO.readFile(getFileNameInTheProjectTest(fileName)); + } + function getSourceFileText(fileName: string): string { let text: string = undefined; try { diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 1266ffa5d37..57e6705318c 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -79,6 +79,7 @@ namespace RWC { useCaseSensitiveFileNames: Harness.IO.useCaseSensitiveFileNames(), fileExists: Harness.IO.fileExists, readDirectory: Harness.IO.readDirectory, + readFile: Harness.IO.readFile }; const configParseResult = ts.parseJsonConfigFileContent(parsedTsconfigFileContents.config, configParseHost, ts.getDirectoryPath(tsconfigFile.path)); fileNames = configParseResult.fileNames; diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 3b9025c27c3..11824e16d9d 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -86,6 +86,7 @@ "./unittests/moduleResolution.ts", "./unittests/tsconfigParsing.ts", "./unittests/commandLineParsing.ts", + "./unittests/configurationExtension.ts", "./unittests/convertCompilerOptionsFromJson.ts", "./unittests/convertTypingOptionsFromJson.ts", "./unittests/tsserverProjectSystem.ts", diff --git a/src/harness/unittests/configurationExtension.ts b/src/harness/unittests/configurationExtension.ts new file mode 100644 index 00000000000..21584d4b67d --- /dev/null +++ b/src/harness/unittests/configurationExtension.ts @@ -0,0 +1,230 @@ +/// +/// + +namespace ts { + const testContents = { + "/dev/tsconfig.json": `{ + "extends": "./configs/base", + "files": [ + "main.ts", + "supplemental.ts" + ] +}`, + "/dev/tsconfig.nostrictnull.json": `{ + "extends": "./tsconfig", + "compilerOptions": { + "strictNullChecks": false + } +}`, + "/dev/tsconfig.tests.json": `{ + "extends": ["./configs/tests", "./tsconfig"], + "compilerOptions": { + "module": "commonjs" + } +}`, + "/dev/tsconfig.tests.browser.json": `{ + "extends": ["./configs/tests", "./tsconfig"], + "compilerOptions": { + "module": "amd" + } +}`, + "/dev/configs/base.json": `{ + "compilerOptions": { + "allowJs": true, + "noImplicitAny": true, + "strictNullChecks": true + } +}`, + "/dev/configs/tests.json": `{ + "compilerOptions": { + "preserveConstEnums": true, + "removeComments": false, + "sourceMap": true + }, + "exclude": [ + "../tests/baselines", + "../tests/scenarios" + ], + "include": [ + "../tests/**/*.ts" + ] +}`, + "/dev/circular.json": `{ + "extends": "./circular2", + "compilerOptions": { + "module": "amd" + } +}`, + "/dev/circular2.json": `{ + "extends": "./circular", + "compilerOptions": { + "module": "commonjs" + } +}`, + "/dev/missing.json": `{ + "extends": "./missing2", + "compilerOptions": { + "types": [] + } +}`, + "/dev/failure.json": `{ + "extends": "./failure2.json", + "compilerOptions": { + "typeRoots": [] + } +}`, + "/dev/failure2.json": `{ + "excludes": ["*.js"] +}`, + "/dev/multi.json": `{ + "extends": ["./configs/first", "./configs/second"], + "compilerOptions": { + "allowJs": false + } +}`, + "/dev/configs/first.json": `{ + "extends": "./base", + "compilerOptions": { + "module": "commonjs" + }, + "files": ["../main.ts"] +}`, + "/dev/configs/second.json": `{ + "extends": "./base", + "compilerOptions": { + "module": "amd" + }, + "include": ["../supplemental.*"] +}`, + "/dev/extends.json": `{ "extends": 42 }`, + "/dev/extends2.json": `{ "extends": "configs/base" }`, + "/dev/main.ts": "", + "/dev/supplemental.ts": "", + "/dev/tests/unit/spec.ts": "", + "/dev/tests/utils.ts": "", + "/dev/tests/scenarios/first.json": "", + "/dev/tests/baselines/first/output.ts": "" + }; + + const caseInsensitiveBasePath = "c:/dev/"; + const caseInsensitiveHost = new Utils.MockParseConfigHost(caseInsensitiveBasePath, /*useCaseSensitiveFileNames*/ false, mapObject(testContents, (key, content) => [`c:${key}`, content])); + + const caseSensitiveBasePath = "/dev/"; + const caseSensitiveHost = new Utils.MockParseConfigHost(caseSensitiveBasePath, /*useCaseSensitiveFileNames*/ true, testContents); + + function verifyDiagnostics(actual: Diagnostic[], expected: {code: number, category: DiagnosticCategory, messageText: string}[]) { + assert.isTrue(expected.length === actual.length, `Expected error: ${JSON.stringify(expected)}. Actual error: ${JSON.stringify(actual)}.`); + for (let i = 0; i < actual.length; i++) { + const actualError = actual[i]; + const expectedError = expected[i]; + assert.equal(actualError.code, expectedError.code, "Error code mismatch"); + assert.equal(actualError.category, expectedError.category, "Category mismatch"); + assert.equal(flattenDiagnosticMessageText(actualError.messageText, "\n"), expectedError.messageText); + } + } + + describe("Configuration Extension", () => { + forEach<[string, string, Utils.MockParseConfigHost], void>([ + ["under a case insensitive host", caseInsensitiveBasePath, caseInsensitiveHost], + ["under a case sensitive host", caseSensitiveBasePath, caseSensitiveHost] + ], ([testName, basePath, host]) => { + function testSuccess(name: string, entry: string, expected: CompilerOptions, expectedFiles: string[]) { + it(name, () => { + const {config, error} = ts.readConfigFile(entry, name => host.readFile(name)); + assert(config && !error, flattenDiagnosticMessageText(error && error.messageText, "\n")); + const parsed = ts.parseJsonConfigFileContent(config, host, basePath, {}, entry); + assert(!parsed.errors.length, flattenDiagnosticMessageText(parsed.errors[0] && parsed.errors[0].messageText, "\n")); + expected.configFilePath = entry; + assert.deepEqual(parsed.options, expected); + assert.deepEqual(parsed.fileNames, expectedFiles); + }); + } + + function testFailure(name: string, entry: string, expectedDiagnostics: {code: number, category: DiagnosticCategory, messageText: string}[]) { + it(name, () => { + const {config, error} = ts.readConfigFile(entry, name => host.readFile(name)); + assert(config && !error, flattenDiagnosticMessageText(error && error.messageText, "\n")); + const parsed = ts.parseJsonConfigFileContent(config, host, basePath, {}, entry); + verifyDiagnostics(parsed.errors, expectedDiagnostics); + }); + } + + describe(testName, () => { + testSuccess("can resolve an extension with a base extension", "tsconfig.json", { + allowJs: true, + noImplicitAny: true, + strictNullChecks: true, + }, [ + combinePaths(basePath, "main.ts"), + combinePaths(basePath, "supplemental.ts"), + ]); + + testSuccess("can resolve an extension with a base extension that overrides options", "tsconfig.nostrictnull.json", { + allowJs: true, + noImplicitAny: true, + strictNullChecks: false, + }, [ + combinePaths(basePath, "main.ts"), + combinePaths(basePath, "supplemental.ts"), + ]); + + testSuccess("can resolve an extension with a multiple base extensions that overrides options", "tsconfig.tests.json", { + allowJs: true, + noImplicitAny: true, + strictNullChecks: true, + preserveConstEnums: true, + removeComments: false, + sourceMap: true, + module: ts.ModuleKind.CommonJS, + }, [ + combinePaths(basePath, "main.ts"), + combinePaths(basePath, "supplemental.ts"), + combinePaths(basePath, "tests/unit/spec.ts"), + combinePaths(basePath, "tests/utils.ts"), + ]); + + testSuccess("can resolve a diamond dependency graph", "multi.json", { + allowJs: false, + noImplicitAny: true, + strictNullChecks: true, + module: ts.ModuleKind.AMD, + }, [ + combinePaths(basePath, "configs/../main.ts"), // Probably should consider resolving these kinds of paths when they appear + combinePaths(basePath, "supplemental.ts"), + ]); + + testFailure("can report errors on circular imports", "circular.json", [ + { + code: 18000, + category: DiagnosticCategory.Error, + messageText: `Circularity detected while resolving configuration: ${[combinePaths(basePath, "circular.json"), combinePaths(basePath, "circular2.json"), combinePaths(basePath, "circular.json")].join(" -> ")}` + } + ]); + + testFailure("can report missing configurations", "missing.json", [{ + code: 6096, + category: DiagnosticCategory.Message, + messageText: `File './missing2' does not exist.` + }]); + + testFailure("can report errors in extended configs", "failure.json", [{ + code: 6114, + category: DiagnosticCategory.Error, + messageText: `Unknown option 'excludes'. Did you mean 'exclude'?` + }]); + + testFailure("can error when 'extends' is neither a string nor a string[]", "extends.json", [{ + code: 5024, + category: DiagnosticCategory.Error, + messageText: `Compiler option 'extends' requires a value of type string or string[].` + }]); + + testFailure("can error when 'extends' is neither relative nor rooted.", "extends2.json", [{ + code: 18001, + category: DiagnosticCategory.Error, + messageText: `The path in an 'extends' options must be relative or rooted.` + }]); + }); + }); + }); +} \ No newline at end of file diff --git a/src/harness/virtualFileSystem.ts b/src/harness/virtualFileSystem.ts index 30192b8b8ec..36b25cfd29b 100644 --- a/src/harness/virtualFileSystem.ts +++ b/src/harness/virtualFileSystem.ts @@ -10,9 +10,9 @@ namespace Utils { this.name = name; } - isDirectory() { return false; } - isFile() { return false; } - isFileSystem() { return false; } + isDirectory(): this is VirtualDirectory { return false; } + isFile(): this is VirtualFile { return false; } + isFileSystem(): this is VirtualFileSystem { return false; } } export class VirtualFile extends VirtualFileSystemEntry { @@ -82,9 +82,8 @@ namespace Utils { return file; } else if (entry.isFile()) { - const file = entry; - file.content = content; - return file; + entry.content = content; + return entry; } else { return undefined; @@ -160,10 +159,18 @@ namespace Utils { } export class MockParseConfigHost extends VirtualFileSystem implements ts.ParseConfigHost { - constructor(currentDirectory: string, ignoreCase: boolean, files: string[]) { + constructor(currentDirectory: string, ignoreCase: boolean, files: ts.Map | string[]) { super(currentDirectory, ignoreCase); - for (const file of files) { - this.addFile(file); + const fileNames = (files instanceof Array) ? files : ts.getKeys(files); + for (const file of fileNames) { + this.addFile(file, (files as any)[file]); + } + } + + readFile(path: string): string { + const value = this.traversePath(path); + if (value && value.isFile()) { + return value.content; } } From e8066158eba22aff78d6899d0bc0dc67b20404d4 Mon Sep 17 00:00:00 2001 From: Yuichi Nukiyama Date: Mon, 1 Aug 2016 15:15:11 +0900 Subject: [PATCH 048/508] change error message for unused parameter property fix --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 4 ++++ .../unusedParameterProperty1.errors.txt | 14 ++++++++++++++ .../reference/unusedParameterProperty1.js | 19 +++++++++++++++++++ .../unusedParameterProperty2.errors.txt | 14 ++++++++++++++ .../reference/unusedParameterProperty2.js | 19 +++++++++++++++++++ .../compiler/unusedParameterProperty1.ts | 9 +++++++++ .../compiler/unusedParameterProperty2.ts | 9 +++++++++ 8 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/unusedParameterProperty1.errors.txt create mode 100644 tests/baselines/reference/unusedParameterProperty1.js create mode 100644 tests/baselines/reference/unusedParameterProperty2.errors.txt create mode 100644 tests/baselines/reference/unusedParameterProperty2.js create mode 100644 tests/cases/compiler/unusedParameterProperty1.ts create mode 100644 tests/cases/compiler/unusedParameterProperty2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7b85189b784..4b12e2e61f5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14967,7 +14967,7 @@ namespace ts { else if (member.kind === SyntaxKind.Constructor) { for (const parameter of (member).parameters) { if (!parameter.symbol.isReferenced && parameter.flags & NodeFlags.Private) { - error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + error(parameter.name, Diagnostics.Property_0_is_declared_but_never_used, parameter.symbol.name); } } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8126d5c605e..c1eead94f14 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2828,6 +2828,10 @@ "category": "Message", "code": 6137 }, + "Property '{0}' is declared but never used.": { + "category": "Error", + "code": 6138 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/tests/baselines/reference/unusedParameterProperty1.errors.txt b/tests/baselines/reference/unusedParameterProperty1.errors.txt new file mode 100644 index 00000000000..0581199313f --- /dev/null +++ b/tests/baselines/reference/unusedParameterProperty1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedParameterProperty1.ts(3,25): error TS6138: Property 'used' is declared but never used. + + +==== tests/cases/compiler/unusedParameterProperty1.ts (1 errors) ==== + + class A { + constructor(private used: string) { + ~~~~ +!!! error TS6138: Property 'used' is declared but never used. + let foge = used; + foge += ""; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterProperty1.js b/tests/baselines/reference/unusedParameterProperty1.js new file mode 100644 index 00000000000..d0b608a6d87 --- /dev/null +++ b/tests/baselines/reference/unusedParameterProperty1.js @@ -0,0 +1,19 @@ +//// [unusedParameterProperty1.ts] + +class A { + constructor(private used: string) { + let foge = used; + foge += ""; + } +} + + +//// [unusedParameterProperty1.js] +var A = (function () { + function A(used) { + this.used = used; + var foge = used; + foge += ""; + } + return A; +}()); diff --git a/tests/baselines/reference/unusedParameterProperty2.errors.txt b/tests/baselines/reference/unusedParameterProperty2.errors.txt new file mode 100644 index 00000000000..cb3b3e95556 --- /dev/null +++ b/tests/baselines/reference/unusedParameterProperty2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedParameterProperty2.ts(3,25): error TS6138: Property 'used' is declared but never used. + + +==== tests/cases/compiler/unusedParameterProperty2.ts (1 errors) ==== + + class A { + constructor(private used) { + ~~~~ +!!! error TS6138: Property 'used' is declared but never used. + let foge = used; + foge += ""; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterProperty2.js b/tests/baselines/reference/unusedParameterProperty2.js new file mode 100644 index 00000000000..2bb04fde088 --- /dev/null +++ b/tests/baselines/reference/unusedParameterProperty2.js @@ -0,0 +1,19 @@ +//// [unusedParameterProperty2.ts] + +class A { + constructor(private used) { + let foge = used; + foge += ""; + } +} + + +//// [unusedParameterProperty2.js] +var A = (function () { + function A(used) { + this.used = used; + var foge = used; + foge += ""; + } + return A; +}()); diff --git a/tests/cases/compiler/unusedParameterProperty1.ts b/tests/cases/compiler/unusedParameterProperty1.ts new file mode 100644 index 00000000000..61c4374c60a --- /dev/null +++ b/tests/cases/compiler/unusedParameterProperty1.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + constructor(private used: string) { + let foge = used; + foge += ""; + } +} diff --git a/tests/cases/compiler/unusedParameterProperty2.ts b/tests/cases/compiler/unusedParameterProperty2.ts new file mode 100644 index 00000000000..b9e05fbc967 --- /dev/null +++ b/tests/cases/compiler/unusedParameterProperty2.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + constructor(private used) { + let foge = used; + foge += ""; + } +} From 4ec8b2b134c9f6c91251c12ec42974bf0b3b403f Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 1 Aug 2016 14:29:10 -0700 Subject: [PATCH 049/508] Refactoring import completions into their own api --- src/harness/fourslash.ts | 75 ++++ src/harness/harnessLanguageService.ts | 3 + src/server/client.ts | 15 + src/server/protocol.d.ts | 14 + src/server/session.ts | 1 + src/services/services.ts | 350 +++++++++--------- src/services/shims.ts | 8 + ...etionForStringLiteralNonrelativeImport1.ts | 22 +- ...tionForStringLiteralNonrelativeImport10.ts | 4 +- ...etionForStringLiteralNonrelativeImport2.ts | 6 +- ...etionForStringLiteralNonrelativeImport3.ts | 8 +- ...etionForStringLiteralNonrelativeImport4.ts | 20 +- ...etionForStringLiteralNonrelativeImport5.ts | 12 +- ...etionForStringLiteralNonrelativeImport6.ts | 14 +- ...etionForStringLiteralNonrelativeImport7.ts | 6 +- ...etionForStringLiteralNonrelativeImport8.ts | 6 +- ...etionForStringLiteralNonrelativeImport9.ts | 6 +- ...rStringLiteralNonrelativeImportTypings1.ts | 8 +- ...rStringLiteralNonrelativeImportTypings2.ts | 6 +- ...rStringLiteralNonrelativeImportTypings3.ts | 6 +- ...mpletionForStringLiteralRelativeImport1.ts | 38 +- ...mpletionForStringLiteralRelativeImport2.ts | 26 +- ...mpletionForStringLiteralRelativeImport3.ts | 20 +- ...mpletionForStringLiteralRelativeImport4.ts | 10 +- .../completionForTripleSlashReference1.ts | 50 +-- .../completionForTripleSlashReference2.ts | 36 +- .../completionForTripleSlashReference3.ts | 20 +- tests/cases/fourslash/fourslash.ts | 3 + 28 files changed, 456 insertions(+), 337 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8a8cb348a73..8b0968664e0 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -597,6 +597,38 @@ namespace FourSlash { } } + public verifyImportModuleCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) { + const completions = this.getImportModuleCompletionListAtCaret(); + const itemsCount = completions.length; + + if (negative) { + if (itemsCount > count) { + this.raiseError(`Expected import module completion list items count to not be greater than ${count}, but is actually ${itemsCount}`); + } + } + else { + if (itemsCount <= count) { + this.raiseError(`Expected import module completion list items count to be greater than ${count}, but is actually ${itemsCount}`); + } + } + } + + public verifyImportModuleCompletionListIsEmpty(negative: boolean) { + const completions = this.getImportModuleCompletionListAtCaret(); + if ((!completions || completions.length === 0) && negative) { + this.raiseError("Completion list is empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition); + } + else if (completions && completions.length !== 0 && !negative) { + let errorMsg = "\n" + "Completion List contains: [" + completions[0].name; + for (let i = 1; i < completions.length; i++) { + errorMsg += ", " + completions[i].name; + } + errorMsg += "]\n"; + + this.raiseError("Completion list is not empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition + errorMsg); + } + } + public verifyCompletionListStartsWithItemsInOrder(items: string[]): void { if (items.length === 0) { return; @@ -734,6 +766,28 @@ namespace FourSlash { } } + public verifyImportModuleCompletionListContains(symbol: string) { + const completions = this.getImportModuleCompletionListAtCaret(); + if (completions) { + if (!ts.forEach(completions, completion => completion.name === symbol)) { + const itemsString = completions.map(item => stringify({ name: item.name, span: item.span })).join(",\n"); + this.raiseError(`Expected "${symbol}" to be in list [${itemsString}]`); + } + } + else { + this.raiseError(`No import module completions at position '${this.currentCaretPosition}' when looking for '${symbol}'.`); + } + } + + public verifyImportModuleCompletionListDoesNotContain(symbol: string) { + const completions = this.getImportModuleCompletionListAtCaret(); + if (completions) { + if (ts.forEach(completions, completion => completion.name === symbol)) { + this.raiseError(`Import module completion list did contain ${symbol}`); + } + } + } + public verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string) { const details = this.getCompletionEntryDetails(entryName); @@ -820,6 +874,10 @@ namespace FourSlash { return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition); } + private getImportModuleCompletionListAtCaret() { + return this.languageService.getImportModuleCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition); + } + private getCompletionEntryDetails(entryName: string) { return this.languageService.getCompletionEntryDetails(this.activeFile.fileName, this.currentCaretPosition, entryName); } @@ -2885,6 +2943,23 @@ namespace FourSlashInterface { this.state.verifyCompletionListItemsCountIsGreaterThan(count, this.negative); } + public importModuleCompletionListContains(symbol: string): void { + if (this.negative) { + this.state.verifyImportModuleCompletionListDoesNotContain(symbol); + } + else { + this.state.verifyImportModuleCompletionListContains(symbol); + } + } + + public importModuleCompletionListItemsCountIsGreaterThan(count: number): void { + this.state.verifyImportModuleCompletionListItemsCountIsGreaterThan(count, this.negative); + } + + public importModuleCompletionListIsEmpty(): void { + this.state.verifyImportModuleCompletionListIsEmpty(this.negative); + } + public assertHasRanges(ranges: FourSlash.Range[]) { assert(ranges.length !== 0, "Array of ranges is expected to be non-empty"); } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index d5491d55acd..1972ab85b9d 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -426,6 +426,9 @@ namespace Harness.LanguageService { getCompletionsAtPosition(fileName: string, position: number): ts.CompletionInfo { return unwrapJSONCallResult(this.shim.getCompletionsAtPosition(fileName, position)); } + getImportModuleCompletionsAtPosition(fileName: string, position: number): ts.ImportCompletionEntry[] { + return unwrapJSONCallResult(this.shim.getImportModuleCompletionsAtPosition(fileName, position)); + } getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails { return unwrapJSONCallResult(this.shim.getCompletionEntryDetails(fileName, position, entryName)); } diff --git a/src/server/client.ts b/src/server/client.ts index f04dbd8dc02..04784a77f10 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -220,6 +220,21 @@ namespace ts.server { }; } + getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionEntry[] { + const lineOffset = this.positionToOneBasedLineOffset(fileName, position); + const args: protocol.CompletionsRequestArgs = { + file: fileName, + line: lineOffset.line, + offset: lineOffset.offset, + prefix: undefined + }; + + const request = this.processRequest(CommandNames.ImportModuleCompletions, args); + const response = this.processResponse(request); + + return response.body; + } + getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { const lineOffset = this.positionToOneBasedLineOffset(fileName, position); const args: protocol.CompletionDetailsRequestArgs = { diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 6442848abbe..803edce0d70 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -717,6 +717,16 @@ declare namespace ts.server.protocol { arguments: CompletionsRequestArgs; } + /** + * Import Module Completions request; value of command field is + * "importModuleCompletions". Given a file location (file, line, + * col) return the possible completions for external module + * specifiers or paths given that position refers to a module + * import declaration, require call, or triple slash reference. + */ + export interface ImportModuleCompletionsRequest extends FileLocationRequest { + } + /** * Arguments for completion details request. */ @@ -806,6 +816,10 @@ declare namespace ts.server.protocol { body?: CompletionEntry[]; } + export interface ImportModuleCompletionsResponse extends Response { + body?: ImportCompletionEntry[]; + } + export interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } diff --git a/src/server/session.ts b/src/server/session.ts index 7e1ca81e2af..74f6e6bb233 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -103,6 +103,7 @@ namespace ts.server { export const Change = "change"; export const Close = "close"; export const Completions = "completions"; + export const ImportModuleCompletions = "importModuleCompletions"; export const CompletionDetails = "completionEntryDetails"; export const Configure = "configure"; export const Definition = "definition"; diff --git a/src/services/services.ts b/src/services/services.ts index 025afcd1548..11eec28a5f6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1208,6 +1208,7 @@ namespace ts { getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; + getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionEntry[]; getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; @@ -1480,6 +1481,13 @@ namespace ts { sortText: string; } + export interface ImportCompletionEntry { + name: string; + kind: string; // see ScriptElementKind + span: TextSpan; + sortText: string; + } + export interface CompletionEntryDetails { name: string; kind: string; // see ScriptElementKind @@ -4225,10 +4233,6 @@ namespace ts { return getStringLiteralCompletionEntries(sourceFile, position); } - if (isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); - } - const completionData = getCompletionData(fileName, position); if (!completionData) { return undefined; @@ -4394,27 +4398,13 @@ namespace ts { // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } - else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node)) { - // Get all known external module names or complete a path to a module - return getStringLiteralCompletionEntriesFromModuleNames(node); - } else { const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); if (argumentInfo) { // Get string literal completions from specialized signatures of the target // i.e. declare function f(a: 'A'); // f("/*completion position*/") - const callExpressionCompletionEntries = getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); - if (callExpressionCompletionEntries) { - return callExpressionCompletionEntries; - } - else if (isRequireCall(node.parent, false)) { - // If that failed but this call mataches the signature of a require call, treat the literal as an external module name - return getStringLiteralCompletionEntriesFromModuleNames(node); - } - else { - return undefined; - } + return getStringLiteralCompletionEntriesFromCallExpression(argumentInfo, node); } // Get completion for string literal from string literal type @@ -4500,10 +4490,35 @@ namespace ts { } } } + } + + function getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionEntry[] { + synchronizeHostData(); + + const sourceFile = getValidSourceFile(fileName); + if (isInReferenceComment(sourceFile, position)) { + return getTripleSlashReferenceCompletion(sourceFile, position); + } + else if (isInString(sourceFile, position)) { + const node = findPrecedingToken(position, sourceFile); + if (!node || node.kind !== SyntaxKind.StringLiteral) { + return undefined; + } + + if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + return getStringLiteralCompletionEntriesFromModuleNames(node); + } + } + + return undefined; function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral) { const literalValue = node.text; - let result: CompletionEntry[]; + let result: ImportCompletionEntry[]; + + const nodeStart = node.getStart(); + const span: TextSpan = { start: nodeStart, length: nodeStart - node.getEnd() }; const isRelativePath = startsWith(literalValue, "."); const scriptDir = getDirectoryPath(node.getSourceFile().path); @@ -4511,30 +4526,26 @@ namespace ts { const compilerOptions = program.getCompilerOptions(); if (compilerOptions.rootDirs) { result = getCompletionEntriesForDirectoryFragmentWithRootDirs( - compilerOptions.rootDirs, literalValue, scriptDir, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false); + compilerOptions.rootDirs, literalValue, scriptDir, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span); } else { result = getCompletionEntriesForDirectoryFragment( - literalValue, scriptDir, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false); + literalValue, scriptDir, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span); } } else { // Check for node modules - result = getCompletionEntriesForNonRelativeModules(literalValue, scriptDir); + result = getCompletionEntriesForNonRelativeModules(literalValue, scriptDir, span); } - return { - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: result - }; + return result; } /** * Takes a script path and returns paths for all potential folders that could be merged with its * containing folder via the "rootDirs" compiler option */ - function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean) { + function getBaseDirectoriesFromRootDirs(rootDirs: string[], basePath: string, scriptPath: string, ignoreCase: boolean): string[] { // Make all paths absolute/normalized if they are not already rootDirs = map(rootDirs, rootDirectory => normalizePath(isRootedDiskPath(rootDirectory) ? rootDirectory : combinePaths(basePath, rootDirectory))); @@ -4551,26 +4562,25 @@ namespace ts { return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean): CompletionEntry[] { + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan): ImportCompletionEntry[] { const basePath = program.getCompilerOptions().project || host.getCurrentDirectory(); const baseDirectories = getBaseDirectoriesFromRootDirs( rootDirs, basePath, scriptPath, host.useCaseSensitiveFileNames && !host.useCaseSensitiveFileNames()); - const result: CompletionEntry[] = []; + const result: ImportCompletionEntry[] = []; for (const baseDirectory of baseDirectories) { - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, result); + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, result); } return result; } - function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, result: CompletionEntry[] = []): CompletionEntry[] { + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { const toComplete = getBaseFileName(fragment); const absolutePath = normalizeSlashes(host.resolvePath(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment))); const baseDirectory = toComplete ? getDirectoryPath(absolutePath) : absolutePath; - if (directoryProbablyExists(baseDirectory, host)) { // Enumerate the available files const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); @@ -4583,8 +4593,8 @@ namespace ts { result.push({ name: fileName, kind: ScriptElementKind.directory, - kindModifiers: ScriptElementKindModifier.none, - sortText: fileName + sortText: fileName, + span }); } }); @@ -4599,8 +4609,8 @@ namespace ts { result.push({ name: ensureTrailingDirectorySeparator(directoryName), kind: ScriptElementKind.directory, - kindModifiers: ScriptElementKindModifier.none, - sortText: directoryName + sortText: directoryName, + span }); } }); @@ -4617,17 +4627,17 @@ namespace ts { * Modules from node_modules (i.e. those listed in package.json) * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions */ - function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string): CompletionEntry[] { + function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan): ImportCompletionEntry[] { const options = program.getCompilerOptions(); const { baseUrl, paths } = options; - let result: CompletionEntry[]; + let result: ImportCompletionEntry[]; if (baseUrl) { const fileExtensions = getSupportedExtensions(options); const projectDir = options.project || host.getCurrentDirectory(); const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false); + result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span); if (paths) { for (const path in paths) { @@ -4636,7 +4646,7 @@ namespace ts { if (paths[path]) { forEach(paths[path], pattern => { forEach(getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions), match => { - result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName)); + result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); }); }); } @@ -4644,7 +4654,7 @@ namespace ts { else if (startsWith(path, fragment)) { const entry = paths[path] && paths[path].length === 1 && paths[path][0]; if (entry) { - result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName)); + result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); } } } @@ -4655,10 +4665,10 @@ namespace ts { result = []; } - getCompletionEntriesFromTypings(host, options, scriptPath, result); + getCompletionEntriesFromTypings(host, options, scriptPath, span, result); forEach(enumeratePotentialNonRelativeModules(fragment, scriptPath, options), moduleName => { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); }); return result; @@ -4757,12 +4767,14 @@ namespace ts { return deduplicate(nonRelativeModules); } - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number) { + function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number): ImportCompletionEntry[] { const node = getTokenAtPosition(sourceFile, position); if (!node) { return undefined; } + const span: TextSpan = undefined; + const text = sourceFile.text.substr(node.pos, position); const match = tripleSlashDirectiveFragmentRegex.exec(text); if (match) { @@ -4771,174 +4783,161 @@ namespace ts { const scriptPath = getDirectoryPath(sourceFile.path); if (kind === "path") { // Give completions for a relative path - return { - isMemberCompletion: false, - isNewIdentifierLocation: false, - entries: getCompletionEntriesForDirectoryFragment(fragment, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true) - }; + return getCompletionEntriesForDirectoryFragment(fragment, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, span); } else { // Give completions based on the typings available - return { - isMemberCompletion: false, - isNewIdentifierLocation: false, - entries: getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath) - }; + return getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath, span); } } return undefined; } - } - function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, result: CompletionEntry[] = []): CompletionEntry[] { - // Check for typings specified in compiler options - if (options.types) { - forEach(options.types, moduleName => { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); - }); - } - else if (host.getDirectories && options.typeRoots) { - const absoluteRoots = map(options.typeRoots, rootDirectory => getAbsoluteProjectPath(rootDirectory, host, options.project)); - forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectories(host, options, absoluteRoot, result)); + function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { + // Check for typings specified in compiler options + if (options.types) { + forEach(options.types, moduleName => { + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + }); + } + else if (host.getDirectories && options.typeRoots) { + const absoluteRoots = map(options.typeRoots, rootDirectory => getAbsoluteProjectPath(rootDirectory, host, options.project)); + forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectories(host, options, absoluteRoot, span, result)); + } + + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + forEach(findPackageJsons(scriptPath), package => { + const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + }); + } + + return result; } - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - forEach(findPackageJsons(scriptPath), package => { - const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, result); - }); + function getAbsoluteProjectPath(path: string, host: LanguageServiceHost, projectDir?: string) { + if (isRootedDiskPath(path)) { + return normalizePath(path); + } + + if (projectDir) { + return normalizePath(combinePaths(projectDir, path)); + } + + return normalizePath(host.resolvePath(path)); } - return result; - } - - function getAbsoluteProjectPath(path: string, host: LanguageServiceHost, projectDir?: string) { - if (isRootedDiskPath(path)) { - return normalizePath(path); + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, span: TextSpan, result: ImportCompletionEntry[]) { + if (host.getDirectories && directoryProbablyExists(directory, host)) { + forEach(host.getDirectories(directory), typeDirectory => { + result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); + }); + } } - if (projectDir) { - return normalizePath(combinePaths(projectDir, path)); - } + function findPackageJsons(currentDir: string): string[] { + const paths: string[] = []; + let currentConfigPath: string; + while (true) { + currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); - return normalizePath(host.resolvePath(path)); - } - - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: CompletionEntry[]) { - if (host.getDirectories && directoryProbablyExists(directory, host)) { - forEach(host.getDirectories(directory), typeDirectory => { - result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName)); - }); - } - } - - function findPackageJsons(currentDir: string): string[] { - const paths: string[] = []; - let currentConfigPath: string; - while (true) { - currentConfigPath = findConfigFile(currentDir, (f) => host.fileExists(f), "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - - currentDir = getDirectoryPath(currentConfigPath); - const parent = getDirectoryPath(currentDir); - if (currentDir === parent) { + currentDir = getDirectoryPath(currentConfigPath); + const parent = getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { break; } - currentDir = parent; - } - else { - break; } + + return paths; } - return paths; - } + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string, modulePrefix?: string) { + const result: VisibleModuleInfo[] = []; + findPackageJsons(scriptPath).forEach((packageJson) => { + const package = tryReadingPackageJson(packageJson); + if (!package) { + return; + } - function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string, modulePrefix?: string) { - const result: VisibleModuleInfo[] = []; - findPackageJsons(scriptPath).forEach((packageJson) => { - const package = tryReadingPackageJson(packageJson); - if (!package) { - return; - } + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; - const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); - const foundModuleNames: string[] = []; + if (package.dependencies) { + addPotentialPackageNames(package.dependencies, modulePrefix, foundModuleNames); + } + if (package.devDependencies) { + addPotentialPackageNames(package.devDependencies, modulePrefix, foundModuleNames); + } - if (package.dependencies) { - addPotentialPackageNames(package.dependencies, modulePrefix, foundModuleNames); - } - if (package.devDependencies) { - addPotentialPackageNames(package.devDependencies, modulePrefix, foundModuleNames); - } - - forEach(foundModuleNames, (moduleName) => { - const moduleDir = combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName, - moduleDir, - canBeImported: moduleCanBeImported(moduleDir) + forEach(foundModuleNames, (moduleName) => { + const moduleDir = combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName, + moduleDir, + canBeImported: moduleCanBeImported(moduleDir) + }); }); }); - }); - return result; + return result; - function tryReadingPackageJson(filePath: string) { - try { - const fileText = host.readFile(filePath); - return JSON.parse(fileText); - } - catch (e) { - return undefined; - } - } - - function addPotentialPackageNames(dependencies: any, prefix: string, result: string[]) { - for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && (!prefix || startsWith(dep, prefix))) { - result.push(dep); + function tryReadingPackageJson(filePath: string) { + try { + const fileText = host.readFile(filePath); + return JSON.parse(fileText); + } + catch (e) { + return undefined; } } - } - /* - * A module can be imported by name alone if one of the following is true: - * It defines the "typings" property in its package.json - * The module has a "main" export and an index.d.ts file - * The module has an index.ts - */ - function moduleCanBeImported(modulePath: string): boolean { - const packagePath = combinePaths(modulePath, "package.json"); - - let hasMainExport = false; - if (host.fileExists(packagePath)) { - const package = tryReadingPackageJson(packagePath); - if (package) { - if (package.typings) { - return true; + function addPotentialPackageNames(dependencies: any, prefix: string, result: string[]) { + for (const dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && (!prefix || startsWith(dep, prefix))) { + result.push(dep); } - hasMainExport = !!package.main; } } - hasMainExport = hasMainExport || host.fileExists(combinePaths(modulePath, "index.js")); + /* + * A module can be imported by name alone if one of the following is true: + * It defines the "typings" property in its package.json + * The module has a "main" export and an index.d.ts file + * The module has an index.ts + */ + function moduleCanBeImported(modulePath: string): boolean { + const packagePath = combinePaths(modulePath, "package.json"); - return (hasMainExport && host.fileExists(combinePaths(modulePath, "index.d.ts"))) || host.fileExists(combinePaths(modulePath, "index.ts")); + let hasMainExport = false; + if (host.fileExists(packagePath)) { + const package = tryReadingPackageJson(packagePath); + if (package) { + if (package.typings) { + return true; + } + hasMainExport = !!package.main; + } + } + + hasMainExport = hasMainExport || host.fileExists(combinePaths(modulePath, "index.js")); + + return (hasMainExport && host.fileExists(combinePaths(modulePath, "index.d.ts"))) || host.fileExists(combinePaths(modulePath, "index.ts")); + } } - } - function createCompletionEntryForModule(name: string, kind: string): CompletionEntry { - return { - name, - kind, - kindModifiers: ScriptElementKindModifier.none, - sortText: name - }; + function createCompletionEntryForModule(name: string, kind: string, span: TextSpan): ImportCompletionEntry { + return { name, kind, sortText: name, span }; + } } function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { @@ -8752,6 +8751,7 @@ namespace ts { getEncodedSyntacticClassifications, getEncodedSemanticClassifications, getCompletionsAtPosition, + getImportModuleCompletionsAtPosition, getCompletionEntryDetails, getSignatureHelpItems, getQuickInfoAtPosition, diff --git a/src/services/shims.ts b/src/services/shims.ts index ca12733e0a2..eb6c5e55b7b 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -131,6 +131,7 @@ namespace ts { getEncodedSemanticClassifications(fileName: string, start: number, length: number): string; getCompletionsAtPosition(fileName: string, position: number): string; + getImportModuleCompletionsAtPosition(fileName: string, position: number): string; getCompletionEntryDetails(fileName: string, position: number, entryName: string): string; getQuickInfoAtPosition(fileName: string, position: number): string; @@ -870,6 +871,13 @@ namespace ts { ); } + getImportModuleCompletionsAtPosition(fileName: string, position: number): string { + return this.forwardJSONCall( + `getImportModuleCompletionsAtPosition('${fileName}', ${position})`, + () => this.languageService.getCompletionsAtPosition(fileName, position) + ); + } + /** Get a string based representation of a completion list entry details */ public getCompletionEntryDetails(fileName: string, position: number, entryName: string) { return this.forwardJSONCall( diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts index 5c7b2016a75..f8ea68a271c 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts @@ -43,19 +43,19 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("fake-module"); - verify.completionListContains("fake-module-dev"); - verify.not.completionListItemsCountIsGreaterThan(2); + verify.importModuleCompletionListContains("fake-module"); + verify.importModuleCompletionListContains("fake-module-dev"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); goTo.marker(kind + "1"); - verify.completionListContains("index"); - verify.completionListContains("ts"); - verify.completionListContains("dts"); - verify.completionListContains("tsx"); - verify.not.completionListItemsCountIsGreaterThan(4); + verify.importModuleCompletionListContains("index"); + verify.importModuleCompletionListContains("ts"); + verify.importModuleCompletionListContains("dts"); + verify.importModuleCompletionListContains("tsx"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); goTo.marker(kind + "2"); - verify.completionListContains("fake-module"); - verify.completionListContains("fake-module-dev"); - verify.not.completionListItemsCountIsGreaterThan(2); + verify.importModuleCompletionListContains("fake-module"); + verify.importModuleCompletionListContains("fake-module-dev"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts index cb1f67f6349..393ffed0c52 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts @@ -26,8 +26,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListIsEmpty(); + verify.importModuleCompletionListIsEmpty(); goTo.marker(kind + "1"); - verify.completionListIsEmpty(); + verify.importModuleCompletionListIsEmpty(); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts index 11420fe4f37..08b92b05295 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts @@ -29,7 +29,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("repeated"); - verify.completionListContains("other"); - verify.not.completionListItemsCountIsGreaterThan(2); + verify.importModuleCompletionListContains("repeated"); + verify.importModuleCompletionListContains("other"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts index aec9f8411bc..9d9beac16e7 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts @@ -28,8 +28,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("ts"); - verify.completionListContains("tsx"); - verify.completionListContains("dts"); - verify.not.completionListItemsCountIsGreaterThan(3); + verify.importModuleCompletionListContains("ts"); + verify.importModuleCompletionListContains("tsx"); + verify.importModuleCompletionListContains("dts"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index 5a96e4ee63e..28170754456 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -33,20 +33,20 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("fake-module/"); - verify.completionListContains("fake-module2"); - verify.completionListContains("fake-module3/"); - verify.not.completionListItemsCountIsGreaterThan(3); + verify.importModuleCompletionListContains("fake-module/"); + verify.importModuleCompletionListContains("fake-module2"); + verify.importModuleCompletionListContains("fake-module3/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); goTo.marker(kind + "1"); - verify.completionListContains("ambient-module-test"); - verify.not.completionListItemsCountIsGreaterThan(1); + verify.importModuleCompletionListContains("ambient-module-test"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker(kind + "2"); - verify.completionListContains("fake-module/"); - verify.completionListContains("fake-module2"); - verify.completionListContains("fake-module3/"); - verify.not.completionListItemsCountIsGreaterThan(3); + verify.importModuleCompletionListContains("fake-module/"); + verify.importModuleCompletionListContains("fake-module2"); + verify.importModuleCompletionListContains("fake-module3/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts index 2e172e3578e..9e0c756a919 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts @@ -24,14 +24,14 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("ambientModule"); - verify.completionListContains("otherAmbientModule"); - verify.completionListContains("otherOtherAmbientModule"); - verify.not.completionListItemsCountIsGreaterThan(3); + verify.importModuleCompletionListContains("ambientModule"); + verify.importModuleCompletionListContains("otherAmbientModule"); + verify.importModuleCompletionListContains("otherOtherAmbientModule"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); goTo.marker(kind + "1"); - verify.completionListContains("ambientModule"); - verify.not.completionListItemsCountIsGreaterThan(1); + verify.importModuleCompletionListContains("ambientModule"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts index bfd0539e149..263b57d9d29 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts @@ -52,11 +52,11 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("module-no-main/"); - verify.completionListContains("module-no-main-index-d-ts/"); - verify.completionListContains("module-index-ts"); - verify.completionListContains("module-index-d-ts-explicit-main"); - verify.completionListContains("module-index-d-ts-default-main"); - verify.completionListContains("module-typings"); - verify.not.completionListItemsCountIsGreaterThan(6); + verify.importModuleCompletionListContains("module-no-main/"); + verify.importModuleCompletionListContains("module-no-main-index-d-ts/"); + verify.importModuleCompletionListContains("module-index-ts"); + verify.importModuleCompletionListContains("module-index-d-ts-explicit-main"); + verify.importModuleCompletionListContains("module-index-d-ts-default-main"); + verify.importModuleCompletionListContains("module-typings"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts index 35e144c7184..d08ebd17b73 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts @@ -21,7 +21,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("module"); - verify.completionListContains("module-from-node"); - verify.not.completionListItemsCountIsGreaterThan(2); + verify.importModuleCompletionListContains("module"); + verify.importModuleCompletionListContains("module-from-node"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts index 0e8da4b02bb..b7e745f814e 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts @@ -43,11 +43,11 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("0test"); + verify.importModuleCompletionListContains("0test"); goTo.marker(kind + "1"); - verify.completionListContains("1test"); + verify.importModuleCompletionListContains("1test"); goTo.marker(kind + "2"); - verify.completionListContains("2test"); + verify.importModuleCompletionListContains("2test"); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts index 3c32ec2670d..31984df9081 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts @@ -28,7 +28,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("module1"); - verify.completionListContains("module2"); - verify.not.completionListItemsCountIsGreaterThan(2); + verify.importModuleCompletionListContains("module1"); + verify.importModuleCompletionListContains("module2"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts index edce0ce7e9f..1b77c57f5ca 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts @@ -26,8 +26,8 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("module-x"); - verify.completionListContains("module-y"); - verify.completionListContains("module-z"); - verify.not.completionListItemsCountIsGreaterThan(3); + verify.importModuleCompletionListContains("module-x"); + verify.importModuleCompletionListContains("module-y"); + verify.importModuleCompletionListContains("module-z"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts index 541bb88c073..3e991b3d4b4 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts @@ -24,7 +24,7 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("module-x"); - verify.completionListContains("module-z"); - verify.not.completionListItemsCountIsGreaterThan(2); + verify.importModuleCompletionListContains("module-x"); + verify.importModuleCompletionListContains("module-z"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts index 7a7d4e00df9..add1238cefc 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts @@ -20,7 +20,7 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("module-x"); - verify.completionListContains("module-y"); - verify.not.completionListItemsCountIsGreaterThan(2); + verify.importModuleCompletionListContains("module-x"); + verify.importModuleCompletionListContains("module-y"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts index bb9d6a59c7b..f3607d70c28 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts @@ -52,33 +52,33 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListIsEmpty(); + verify.importModuleCompletionListIsEmpty(); goTo.marker(kind + "1"); - verify.completionListContains("f1"); - verify.completionListContains("f2"); - verify.completionListContains("e1"); - verify.completionListContains("test0"); - verify.completionListContains("folder/"); - verify.completionListContains("parentTest/"); - verify.not.completionListItemsCountIsGreaterThan(6); + verify.importModuleCompletionListContains("f1"); + verify.importModuleCompletionListContains("f2"); + verify.importModuleCompletionListContains("e1"); + verify.importModuleCompletionListContains("test0"); + verify.importModuleCompletionListContains("folder/"); + verify.importModuleCompletionListContains("parentTest/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); goTo.marker(kind + "2"); - verify.completionListContains("f1"); - verify.completionListContains("f2"); - verify.completionListContains("folder/"); - verify.not.completionListItemsCountIsGreaterThan(3); + verify.importModuleCompletionListContains("f1"); + verify.importModuleCompletionListContains("f2"); + verify.importModuleCompletionListContains("folder/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); goTo.marker(kind + "3"); - verify.completionListContains("f1"); - verify.completionListContains("h1"); - verify.not.completionListItemsCountIsGreaterThan(2); + verify.importModuleCompletionListContains("f1"); + verify.importModuleCompletionListContains("h1"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); goTo.marker(kind + "4"); - verify.completionListContains("h1"); - verify.not.completionListItemsCountIsGreaterThan(1); + verify.importModuleCompletionListContains("h1"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker(kind + "5"); - verify.completionListContains("g1"); - verify.not.completionListItemsCountIsGreaterThan(1); + verify.importModuleCompletionListContains("g1"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts index 4e879148469..eeb24d591f0 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts @@ -31,19 +31,19 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("f1"); - verify.completionListContains("f2"); - verify.completionListContains("f3"); - verify.completionListContains("f4"); - verify.completionListContains("e1"); - verify.completionListContains("e2"); - verify.completionListContains("test0"); - verify.not.completionListItemsCountIsGreaterThan(7); + verify.importModuleCompletionListContains("f1"); + verify.importModuleCompletionListContains("f2"); + verify.importModuleCompletionListContains("f3"); + verify.importModuleCompletionListContains("f4"); + verify.importModuleCompletionListContains("e1"); + verify.importModuleCompletionListContains("e2"); + verify.importModuleCompletionListContains("test0"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(7); goTo.marker(kind + "1"); - verify.completionListContains("f1"); - verify.completionListContains("f2"); - verify.completionListContains("f3"); - verify.completionListContains("f4"); - verify.not.completionListItemsCountIsGreaterThan(4); + verify.importModuleCompletionListContains("f1"); + verify.importModuleCompletionListContains("f2"); + verify.importModuleCompletionListContains("f3"); + verify.importModuleCompletionListContains("f4"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts index 426eb3c2318..4f35612c5c6 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -32,18 +32,18 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("fourslash/"); - verify.not.completionListItemsCountIsGreaterThan(1); + verify.importModuleCompletionListContains("fourslash/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker(kind + "1"); - verify.completionListContains("fourslash/"); - verify.not.completionListItemsCountIsGreaterThan(1); + verify.importModuleCompletionListContains("fourslash/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker(kind + "2"); - verify.completionListContains("f1"); - verify.completionListContains("f2"); - verify.completionListContains("e1"); - verify.completionListContains("folder/"); - verify.completionListContains("tests/"); - verify.not.completionListItemsCountIsGreaterThan(5); + verify.importModuleCompletionListContains("f1"); + verify.importModuleCompletionListContains("f2"); + verify.importModuleCompletionListContains("e1"); + verify.importModuleCompletionListContains("folder/"); + verify.importModuleCompletionListContains("tests/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index 1895fff8514..5f4d7bb7fc0 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -40,9 +40,9 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.completionListContains("module0"); - verify.completionListContains("module1"); - verify.completionListContains("module2"); - verify.completionListContains("more/"); - verify.not.completionListItemsCountIsGreaterThan(4); + verify.importModuleCompletionListContains("module0"); + verify.importModuleCompletionListContains("module1"); + verify.importModuleCompletionListContains("module2"); + verify.importModuleCompletionListContains("more/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference1.ts b/tests/cases/fourslash/completionForTripleSlashReference1.ts index 96582be1730..284d5ff66a4 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference1.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference1.ts @@ -42,38 +42,38 @@ //// /*parentg1*/ goTo.marker("0"); -verify.completionListIsEmpty(); +verify.importModuleCompletionListIsEmpty(); goTo.marker("1"); -verify.completionListContains("f1.ts"); -verify.completionListContains("f1.d.ts"); -verify.completionListContains("f2.tsx"); -verify.completionListContains("e1.ts"); -verify.completionListContains("test0.ts"); -verify.completionListContains("test1.ts"); -verify.completionListContains("test2.ts"); -verify.completionListContains("test3.ts"); -verify.completionListContains("test4.ts"); -verify.completionListContains("folder/"); -verify.completionListContains("parentTest/"); -verify.not.completionListItemsCountIsGreaterThan(11); +verify.importModuleCompletionListContains("f1.ts"); +verify.importModuleCompletionListContains("f1.d.ts"); +verify.importModuleCompletionListContains("f2.tsx"); +verify.importModuleCompletionListContains("e1.ts"); +verify.importModuleCompletionListContains("test0.ts"); +verify.importModuleCompletionListContains("test1.ts"); +verify.importModuleCompletionListContains("test2.ts"); +verify.importModuleCompletionListContains("test3.ts"); +verify.importModuleCompletionListContains("test4.ts"); +verify.importModuleCompletionListContains("folder/"); +verify.importModuleCompletionListContains("parentTest/"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(11); goTo.marker("2"); -verify.completionListContains("f1.ts"); -verify.completionListContains("f1.d.ts"); -verify.completionListContains("f2.tsx"); -verify.completionListContains("folder/"); -verify.not.completionListItemsCountIsGreaterThan(4); +verify.importModuleCompletionListContains("f1.ts"); +verify.importModuleCompletionListContains("f1.d.ts"); +verify.importModuleCompletionListContains("f2.tsx"); +verify.importModuleCompletionListContains("folder/"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); goTo.marker("3"); -verify.completionListContains("f1.ts"); -verify.completionListContains("h1.ts"); -verify.not.completionListItemsCountIsGreaterThan(2); +verify.importModuleCompletionListContains("f1.ts"); +verify.importModuleCompletionListContains("h1.ts"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); goTo.marker("4"); -verify.completionListContains("h1.ts"); -verify.not.completionListItemsCountIsGreaterThan(1); +verify.importModuleCompletionListContains("h1.ts"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker("5"); -verify.completionListContains("g1.ts"); -verify.not.completionListItemsCountIsGreaterThan(1); \ No newline at end of file +verify.importModuleCompletionListContains("g1.ts"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference2.ts b/tests/cases/fourslash/completionForTripleSlashReference2.ts index 69a9e98810a..8296b851ac2 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference2.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference2.ts @@ -25,23 +25,23 @@ //// /*e2*/ goTo.marker("0"); -verify.completionListContains("f1.ts"); -verify.completionListContains("f1.js"); -verify.completionListContains("f1.d.ts"); -verify.completionListContains("f2.tsx"); -verify.completionListContains("f3.js"); -verify.completionListContains("f4.jsx"); -verify.completionListContains("e1.ts"); -verify.completionListContains("e2.js"); -verify.completionListContains("test0.ts"); -verify.completionListContains("test1.ts"); -verify.not.completionListItemsCountIsGreaterThan(10); +verify.importModuleCompletionListContains("f1.ts"); +verify.importModuleCompletionListContains("f1.js"); +verify.importModuleCompletionListContains("f1.d.ts"); +verify.importModuleCompletionListContains("f2.tsx"); +verify.importModuleCompletionListContains("f3.js"); +verify.importModuleCompletionListContains("f4.jsx"); +verify.importModuleCompletionListContains("e1.ts"); +verify.importModuleCompletionListContains("e2.js"); +verify.importModuleCompletionListContains("test0.ts"); +verify.importModuleCompletionListContains("test1.ts"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(10); goTo.marker("1"); -verify.completionListContains("f1.ts"); -verify.completionListContains("f1.js"); -verify.completionListContains("f1.d.ts"); -verify.completionListContains("f2.tsx"); -verify.completionListContains("f3.js"); -verify.completionListContains("f4.jsx"); -verify.not.completionListItemsCountIsGreaterThan(6); \ No newline at end of file +verify.importModuleCompletionListContains("f1.ts"); +verify.importModuleCompletionListContains("f1.js"); +verify.importModuleCompletionListContains("f1.d.ts"); +verify.importModuleCompletionListContains("f2.tsx"); +verify.importModuleCompletionListContains("f3.js"); +verify.importModuleCompletionListContains("f4.jsx"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference3.ts b/tests/cases/fourslash/completionForTripleSlashReference3.ts index e7aca7399f0..dda6ae92b41 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference3.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference3.ts @@ -25,17 +25,17 @@ //// /*e2*/ goTo.marker("0"); -verify.completionListContains("fourslash/"); -verify.not.completionListItemsCountIsGreaterThan(1); +verify.importModuleCompletionListContains("fourslash/"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker("1"); -verify.completionListContains("fourslash/"); -verify.not.completionListItemsCountIsGreaterThan(1); +verify.importModuleCompletionListContains("fourslash/"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker("2"); -verify.completionListContains("f1.ts"); -verify.completionListContains("f2.tsx"); -verify.completionListContains("e1.ts"); -verify.completionListContains("folder/"); -verify.completionListContains("tests/"); -verify.not.completionListItemsCountIsGreaterThan(5); \ No newline at end of file +verify.importModuleCompletionListContains("f1.ts"); +verify.importModuleCompletionListContains("f2.tsx"); +verify.importModuleCompletionListContains("e1.ts"); +verify.importModuleCompletionListContains("folder/"); +verify.importModuleCompletionListContains("tests/"); +verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 9ce3197a46f..e011dde4b68 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -125,6 +125,9 @@ declare namespace FourSlashInterface { completionListItemsCountIsGreaterThan(count: number): void; completionListIsEmpty(): void; completionListAllowsNewIdentifier(): void; + importModuleCompletionListContains(symbol: string): void; + importModuleCompletionListItemsCountIsGreaterThan(count: number): void; + importModuleCompletionListIsEmpty(): void; memberListIsEmpty(): void; signatureHelpPresent(): void; errorExistsBetweenMarkers(startMarker: string, endMarker: string): void; From 98a162be2a510a7771e7998f63370252c799741f Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 1 Aug 2016 16:58:33 -0700 Subject: [PATCH 050/508] Replacement spans for import completions --- src/harness/fourslash.ts | 24 ++++++++++--- src/services/services.ts | 34 +++++++++++++------ .../completionForStringLiteralImport1.ts | 19 +++++++++++ .../completionForStringLiteralImport2.ts | 28 +++++++++++++++ tests/cases/fourslash/fourslash.ts | 2 +- 5 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteralImport1.ts create mode 100644 tests/cases/fourslash/completionForStringLiteralImport2.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 8b0968664e0..9ad5f25e005 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -766,13 +766,29 @@ namespace FourSlash { } } - public verifyImportModuleCompletionListContains(symbol: string) { + public verifyImportModuleCompletionListContains(symbol: string, rangeIndex?: number) { const completions = this.getImportModuleCompletionListAtCaret(); if (completions) { - if (!ts.forEach(completions, completion => completion.name === symbol)) { + const completion = ts.forEach(completions, completion => completion.name === symbol ? completion : undefined); + if (!completion) { const itemsString = completions.map(item => stringify({ name: item.name, span: item.span })).join(",\n"); this.raiseError(`Expected "${symbol}" to be in list [${itemsString}]`); } + else if (rangeIndex !== undefined) { + const ranges = this.getRanges(); + if (ranges && ranges.length > rangeIndex) { + const range = ranges[rangeIndex]; + + const start = completion.span.start; + const end = start + completion.span.length; + if (range.start !== start || range.end !== end) { + this.raiseError(`Expected completion span for '${symbol}', ${stringify(completion.span)}, to cover range ${stringify(range)}`); + } + } + else { + this.raiseError(`Expected completion span for '${symbol}' to cover range at index ${rangeIndex}, but no range was found at that index`); + } + } } else { this.raiseError(`No import module completions at position '${this.currentCaretPosition}' when looking for '${symbol}'.`); @@ -2943,12 +2959,12 @@ namespace FourSlashInterface { this.state.verifyCompletionListItemsCountIsGreaterThan(count, this.negative); } - public importModuleCompletionListContains(symbol: string): void { + public importModuleCompletionListContains(symbol: string, rangeIndex?: number): void { if (this.negative) { this.state.verifyImportModuleCompletionListDoesNotContain(symbol); } else { - this.state.verifyImportModuleCompletionListContains(symbol); + this.state.verifyImportModuleCompletionListContains(symbol, rangeIndex); } } diff --git a/src/services/services.ts b/src/services/services.ts index 11eec28a5f6..61d624c29df 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2069,7 +2069,7 @@ namespace ts { * for completions. * For example, this matches /// position >= commentRange.pos && position <= commentRange.end && commentRange); + + if (!range) { + return undefined; + } + + const text = sourceFile.text.substr(range.pos, position - range.pos); - const text = sourceFile.text.substr(node.pos, position); const match = tripleSlashDirectiveFragmentRegex.exec(text); if (match) { - const kind= match[1]; - const fragment = match[2]; + const prefix = match[1]; + const kind = match[2]; + const toComplete = match[3]; + + const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + const scriptPath = getDirectoryPath(sourceFile.path); if (kind === "path") { // Give completions for a relative path - return getCompletionEntriesForDirectoryFragment(fragment, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, span); + return getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, span); } else { // Give completions based on the typings available diff --git a/tests/cases/fourslash/completionForStringLiteralImport1.ts b/tests/cases/fourslash/completionForStringLiteralImport1.ts new file mode 100644 index 00000000000..42c2dbaf3d4 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralImport1.ts @@ -0,0 +1,19 @@ +/// + +// @Filename: test.ts +//// import * as foo0 from "[|./some|]/*0*/ +//// import foo1 = require( "[|./some|]/*1*/ +//// var foo2 = require( "[|./some|]/*2*/ + +//// import * as foo3 from "[|./some|]/*3*/"; +//// import foo4 = require( "[|./some|]/*4*/"; +//// var foo5 = require( "[|./some|]/*5*/"; + + +// @Filename: someFile.ts +//// /*someFile*/ + +for (let i = 0; i < 6; i++) { + goTo.marker("" + i); + verify.importModuleCompletionListContains("someFile", i); +} \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralImport2.ts b/tests/cases/fourslash/completionForStringLiteralImport2.ts new file mode 100644 index 00000000000..a0618c344a7 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralImport2.ts @@ -0,0 +1,28 @@ +/// + +// @typeRoots: my_typings + +// @Filename: test.ts +//// /// +//// /// + +// @Filename: someFile.ts +//// /*someFile*/ + +// @Filename: my_typings/some-module/index.d.ts +//// export var x = 9; + +goTo.marker("0"); +verify.importModuleCompletionListContains("someFile.ts", 0); + +goTo.marker("1"); +verify.importModuleCompletionListContains("some-module", 1); + +goTo.marker("2"); +verify.importModuleCompletionListContains("someFile.ts", 2); + +goTo.marker("3"); +verify.importModuleCompletionListContains("some-module", 3); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index e011dde4b68..948477b78dd 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -125,7 +125,7 @@ declare namespace FourSlashInterface { completionListItemsCountIsGreaterThan(count: number): void; completionListIsEmpty(): void; completionListAllowsNewIdentifier(): void; - importModuleCompletionListContains(symbol: string): void; + importModuleCompletionListContains(symbol: string, rangeIndex?: number): void; importModuleCompletionListItemsCountIsGreaterThan(count: number): void; importModuleCompletionListIsEmpty(): void; memberListIsEmpty(): void; From 35cd480a9c81b1db735587e3dcab3d12d3879f41 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 1 Aug 2016 17:49:13 -0700 Subject: [PATCH 051/508] Fixing import completion spans to only include the end of the directory fragment --- src/services/services.ts | 15 ++++++-- .../completionForStringLiteralImport1.ts | 38 ++++++++++++------- .../completionForStringLiteralImport2.ts | 9 +++-- 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 61d624c29df..66b894bb428 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4518,7 +4518,7 @@ namespace ts { let result: ImportCompletionEntry[]; // Replace the entire text of the string literal (excluding the quotes) - const span: TextSpan = { start: node.getStart() + 1, length: literalValue.length }; + const span: TextSpan = getDirectoryFragmentTextSpan(literalValue, node.getStart() + 1); const isRelativePath = startsWith(literalValue, "."); const scriptDir = getDirectoryPath(node.getSourceFile().path); @@ -4792,15 +4792,16 @@ namespace ts { const kind = match[2]; const toComplete = match[3]; - const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - const scriptPath = getDirectoryPath(sourceFile.path); if (kind === "path") { // Give completions for a relative path + const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); return getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, span); } else { // Give completions based on the typings available + // Replace the entire string + const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; return getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath, span); } } @@ -4952,6 +4953,14 @@ namespace ts { function createCompletionEntryForModule(name: string, kind: string, span: TextSpan): ImportCompletionEntry { return { name, kind, sortText: name, span }; } + + // Replace everything after the last directory seperator that appears + // FIXME: do we care about the other seperator? + function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { + const index = text.lastIndexOf(directorySeparator); + const offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset } + } } function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { diff --git a/tests/cases/fourslash/completionForStringLiteralImport1.ts b/tests/cases/fourslash/completionForStringLiteralImport1.ts index 42c2dbaf3d4..239c3be42fc 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport1.ts @@ -1,19 +1,31 @@ /// +// @typeRoots: my_typings + // @Filename: test.ts -//// import * as foo0 from "[|./some|]/*0*/ -//// import foo1 = require( "[|./some|]/*1*/ -//// var foo2 = require( "[|./some|]/*2*/ - -//// import * as foo3 from "[|./some|]/*3*/"; -//// import foo4 = require( "[|./some|]/*4*/"; -//// var foo5 = require( "[|./some|]/*5*/"; +//// import * as foo0 from "./[|some|]/*0*/ +//// import * as foo1 from "./sub/[|some|]/*1*/ +//// import * as foo2 from "[|some-|]/*2*/" +//// import * as foo3 from "../[||]/*3*/"; -// @Filename: someFile.ts -//// /*someFile*/ +// @Filename: someFile1.ts +//// /*someFile1*/ -for (let i = 0; i < 6; i++) { - goTo.marker("" + i); - verify.importModuleCompletionListContains("someFile", i); -} \ No newline at end of file +// @Filename: sub/someFile2.ts +//// /*someFile2*/ + +// @Filename: my_typings/some-module/index.d.ts +//// export var x = 9; + +goTo.marker("0"); +verify.importModuleCompletionListContains("someFile1", 0); + +goTo.marker("1"); +verify.importModuleCompletionListContains("someFile2", 1); + +goTo.marker("2"); +verify.importModuleCompletionListContains("some-module", 2); + +goTo.marker("3"); +verify.importModuleCompletionListContains("fourslash/", 3); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralImport2.ts b/tests/cases/fourslash/completionForStringLiteralImport2.ts index a0618c344a7..2910d9e1475 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport2.ts @@ -3,15 +3,18 @@ // @typeRoots: my_typings // @Filename: test.ts -//// /// +//// /// //// /// // @Filename: someFile.ts //// /*someFile*/ +// @Filename: sub/someOtherFile.ts +//// /*someOtherFile*/ + // @Filename: my_typings/some-module/index.d.ts //// export var x = 9; @@ -22,7 +25,7 @@ goTo.marker("1"); verify.importModuleCompletionListContains("some-module", 1); goTo.marker("2"); -verify.importModuleCompletionListContains("someFile.ts", 2); +verify.importModuleCompletionListContains("someOtherFile.ts", 2); goTo.marker("3"); verify.importModuleCompletionListContains("some-module", 3); \ No newline at end of file From 0f134ed69efb8d59919bcec6a1e702f403665af6 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 2 Aug 2016 06:58:26 -0700 Subject: [PATCH 052/508] Improve error message --- src/compiler/checker.ts | 6 +++-- src/compiler/core.ts | 21 ++++++++++++++--- src/compiler/diagnosticMessages.json | 2 +- src/compiler/utilities.ts | 5 ++-- .../reference/moduleResolutionNoTs.errors.txt | 23 ++++++++++++++----- .../reference/moduleResolutionNoTs.js | 22 ++++++++++++++---- tests/cases/compiler/moduleResolutionNoTs.ts | 14 ++++++++--- 7 files changed, 71 insertions(+), 22 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7eab69f1df6..290fa257daf 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1366,8 +1366,10 @@ namespace ts { if (moduleNotFoundError) { // report errors only if it was requested - if (hasTypeScriptFileExtensionNonDts(moduleName)) { - error(moduleReferenceLiteral, Diagnostics.Module_name_should_not_include_a_ts_extension_Colon_0, moduleName); + const nonDtsExtension = tryExtractTypeScriptExtensionNonDts(moduleName); + if (nonDtsExtension) { + const diag = Diagnostics.An_import_path_should_not_end_with_a_0_extension_Consider_importing_1_instead; + error(moduleReferenceLiteral, diag, nonDtsExtension, removeExtension(moduleName, nonDtsExtension)); } else { error(moduleReferenceLiteral, moduleNotFoundError, moduleName); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7d6aea62462..d77036660b0 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -93,6 +93,17 @@ namespace ts { return undefined; } + /** Works like Array.prototype.find. */ + export function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined { + for (let i = 0, len = array.length; i < len; i++) { + const value = array[i]; + if (predicate(value, i)) { + return value; + } + } + return undefined; + } + export function contains(array: T[], value: T): boolean { if (array) { for (const v of array) { @@ -941,7 +952,7 @@ namespace ts { * [^./] # matches everything up to the first . character (excluding directory seperators) * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension */ - const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; + const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; const singleAsteriskRegexFragmentOther = "[^/]*"; export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") { @@ -1271,8 +1282,12 @@ namespace ts { return path; } - export function tryRemoveExtension(path: string, extension: string): string { - return fileExtensionIs(path, extension) ? path.substring(0, path.length - extension.length) : undefined; + export function tryRemoveExtension(path: string, extension: string): string | undefined { + return fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined; + } + + export function removeExtension(path: string, extension: string): string { + return path.substring(0, path.length - extension.length); } export function isJsxOrTsxExtension(ext: string): boolean { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index ff534847cda..93bd6c608f0 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1951,7 +1951,7 @@ "category": "Error", "code": 2690 }, - "Module name should not include a '.ts' extension: '{0}'.": { + "An import path should not end with a '{0}' extension. Consider importing '{1}' instead.": { "category": "Error", "code": 2691 }, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index d6667d2b8b2..b92037b7e5b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2726,8 +2726,9 @@ namespace ts { return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension)); } - export function hasTypeScriptFileExtensionNonDts(fileName: string) { - return forEach(supportedTypeScriptExtensionsNonDts, extension => fileExtensionIs(fileName, extension)); + /** Return ".ts" or ".tsx" if that is the extension. */ + export function tryExtractTypeScriptExtensionNonDts(fileName: string): string | undefined { + return find(supportedTypeScriptExtensionsNonDts, extension => fileExtensionIs(fileName, extension)); } /** diff --git a/tests/baselines/reference/moduleResolutionNoTs.errors.txt b/tests/baselines/reference/moduleResolutionNoTs.errors.txt index de105f73539..2a9b74a1af6 100644 --- a/tests/baselines/reference/moduleResolutionNoTs.errors.txt +++ b/tests/baselines/reference/moduleResolutionNoTs.errors.txt @@ -1,14 +1,25 @@ -tests/cases/compiler/user.ts(4,15): error TS2690: Module name should not include a '.ts' extension: './m.ts'. +tests/cases/compiler/user.ts(4,15): error TS2691: An import path should not end with a '.ts' extension. Consider importing './x' instead. +tests/cases/compiler/user.ts(5,15): error TS2691: An import path should not end with a '.tsx' extension. Consider importing './y' instead. -==== tests/cases/compiler/user.ts (1 errors) ==== +==== tests/cases/compiler/user.ts (2 errors) ==== // '.ts' extension is OK in a reference - /// + /// - import x from "./m.ts"; + import x from "./x.ts"; ~~~~~~~~ -!!! error TS2690: Module name should not include a '.ts' extension: './m.ts'. +!!! error TS2691: An import path should not end with a '.ts' extension. Consider importing './x' instead. + import y from "./y.tsx"; + ~~~~~~~~~ +!!! error TS2691: An import path should not end with a '.tsx' extension. Consider importing './y' instead. -==== tests/cases/compiler/m.ts (0 errors) ==== + // Making sure the suggested fixes are valid: + import x2 from "./x"; + import y2 from "./y"; + +==== tests/cases/compiler/x.ts (0 errors) ==== + export default 0; + +==== tests/cases/compiler/y.tsx (0 errors) ==== export default 0; \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionNoTs.js b/tests/baselines/reference/moduleResolutionNoTs.js index 8a912f33011..d9d918f5600 100644 --- a/tests/baselines/reference/moduleResolutionNoTs.js +++ b/tests/baselines/reference/moduleResolutionNoTs.js @@ -1,20 +1,32 @@ //// [tests/cases/compiler/moduleResolutionNoTs.ts] //// -//// [m.ts] +//// [x.ts] +export default 0; + +//// [y.tsx] export default 0; //// [user.ts] // '.ts' extension is OK in a reference -/// +/// -import x from "./m.ts"; +import x from "./x.ts"; +import y from "./y.tsx"; + +// Making sure the suggested fixes are valid: +import x2 from "./x"; +import y2 from "./y"; -//// [m.js] +//// [x.js] +"use strict"; +exports.__esModule = true; +exports["default"] = 0; +//// [y.js] "use strict"; exports.__esModule = true; exports["default"] = 0; //// [user.js] // '.ts' extension is OK in a reference -/// +/// "use strict"; diff --git a/tests/cases/compiler/moduleResolutionNoTs.ts b/tests/cases/compiler/moduleResolutionNoTs.ts index 29d81589cd9..683f6630d9f 100644 --- a/tests/cases/compiler/moduleResolutionNoTs.ts +++ b/tests/cases/compiler/moduleResolutionNoTs.ts @@ -1,8 +1,16 @@ -// @filename: m.ts +// @filename: x.ts +export default 0; + +// @filename: y.tsx export default 0; // @filename: user.ts // '.ts' extension is OK in a reference -/// +/// -import x from "./m.ts"; +import x from "./x.ts"; +import y from "./y.tsx"; + +// Making sure the suggested fixes are valid: +import x2 from "./x"; +import y2 from "./y"; From 91c9d76f09c173c0480d7faa9fc19624e6ff8bcc Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 2 Aug 2016 10:32:42 -0700 Subject: [PATCH 053/508] Remove `SupportedExpressionWithTypeArguments` type; just check that the expression of each `ExpressionWithTypeArguments` is an `EntityNameExpression`. --- src/compiler/checker.ts | 59 ++++++++++++++---------------- src/compiler/declarationEmitter.ts | 4 +- src/compiler/types.ts | 4 -- src/compiler/utilities.ts | 12 +----- 4 files changed, 32 insertions(+), 47 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ca665346036..d8b3785a89e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -968,37 +968,34 @@ namespace ts { function checkAndReportErrorForExtendingInterface(errorLocation: Node): boolean { - const parentExpression = climbToSupportedExpressionWithTypeArguments(errorLocation); - if (!parentExpression) { - return false; - } - const expression = parentExpression.expression; - - if (resolveEntityName(expression, SymbolFlags.Interface, /*ignoreErrors*/ true)) { + const expression = climbToEntityNameOfExpressionWithTypeArguments(errorLocation); + const isError = !!(expression && resolveEntityName(expression, SymbolFlags.Interface, /*ignoreErrors*/ true)); + if (isError) { error(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression)); - return true; } - return false; + return isError; } /** - * Climbs up parents to a SupportedExpressionWIthTypeArguments. - * Does *not* just climb to an ExpressionWithTypeArguments; instead, ensures that this really is supported. + * Climbs up parents to an ExpressionWithTypeArguments, and returns its expression, + * but returns undefined if that expression is not an EntityNameExpression. */ - function climbToSupportedExpressionWithTypeArguments(node: Node): SupportedExpressionWithTypeArguments | undefined { - while (node) { - switch (node.kind) { - case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccessExpression: + function climbToEntityNameOfExpressionWithTypeArguments(node: Node): EntityNameExpression | undefined { + switch (node.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.PropertyAccessExpression: + if (node.parent) { node = node.parent; - break; - case SyntaxKind.ExpressionWithTypeArguments: - Debug.assert(isSupportedExpressionWithTypeArguments(node)); - return node; - default: + } + else { return undefined; - } + } + break; + case SyntaxKind.ExpressionWithTypeArguments: + Debug.assert(isEntityNameExpression((node).expression)); + return (node).expression; + default: + return undefined; } - return undefined; } @@ -3686,7 +3683,7 @@ namespace ts { const baseTypeNodes = getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { for (const node of baseTypeNodes) { - if (isSupportedExpressionWithTypeArguments(node)) { + if (isEntityNameExpression(node.expression)) { const baseSymbol = resolveEntityName(node.expression, SymbolFlags.Type, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & SymbolFlags.Interface) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; @@ -5042,9 +5039,9 @@ namespace ts { case SyntaxKind.ExpressionWithTypeArguments: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. - const expr = node; - if (isSupportedExpressionWithTypeArguments(expr)) { - return expr.expression; + const expr = (node).expression; + if (isEntityNameExpression(expr)) { + return expr; } // fall through; @@ -5101,8 +5098,8 @@ namespace ts { // We only support expressions that are simple qualified names. For other expressions this produces undefined. const typeNameOrExpression: EntityNameOrEntityNameExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName - : isSupportedExpressionWithTypeArguments(node) - ? (node).expression + : isEntityNameExpression((node).expression) + ? (node).expression : undefined; symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; type = symbol === unknownSymbol ? unknownType : @@ -16255,7 +16252,7 @@ namespace ts { const implementedTypeNodes = getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { for (const typeRefNode of implementedTypeNodes) { - if (!isSupportedExpressionWithTypeArguments(typeRefNode)) { + if (!isEntityNameExpression(typeRefNode.expression)) { error(typeRefNode.expression, Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } checkTypeReferenceNode(typeRefNode); @@ -16497,7 +16494,7 @@ namespace ts { checkObjectTypeForDuplicateDeclarations(node); } forEach(getInterfaceBaseTypeNodes(node), heritageElement => { - if (!isSupportedExpressionWithTypeArguments(heritageElement)) { + if (!isEntityNameExpression(heritageElement.expression)) { error(heritageElement.expression, Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } checkTypeReferenceNode(heritageElement); diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 220244c55af..c93784cd9e0 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -452,7 +452,7 @@ namespace ts { } function emitExpressionWithTypeArguments(node: ExpressionWithTypeArguments) { - if (isSupportedExpressionWithTypeArguments(node)) { + if (isEntityNameExpression(node.expression)) { Debug.assert(node.expression.kind === SyntaxKind.Identifier || node.expression.kind === SyntaxKind.PropertyAccessExpression); emitEntityName(node.expression); if (node.typeArguments) { @@ -1019,7 +1019,7 @@ namespace ts { } function emitTypeOfTypeReference(node: ExpressionWithTypeArguments) { - if (isSupportedExpressionWithTypeArguments(node)) { + if (isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 983ed25c848..804989570d8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1014,10 +1014,6 @@ namespace ts { expression: LeftHandSideExpression; typeArguments?: NodeArray; } - export interface SupportedExpressionWithTypeArguments extends ExpressionWithTypeArguments { - _supportedExpressionWithTypeArgumentsBrand?: any; - expression: EntityNameExpression; - } // @kind(SyntaxKind.NewExpression) export interface NewExpression extends CallExpression, PrimaryExpression { } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 466cf8c2b77..f946e4b614f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1039,8 +1039,8 @@ namespace ts { case SyntaxKind.TypeReference: return (node).typeName; case SyntaxKind.ExpressionWithTypeArguments: - Debug.assert(isSupportedExpressionWithTypeArguments(node)); - return (node).expression; + Debug.assert(isEntityNameExpression((node).expression)); + return (node).expression; case SyntaxKind.Identifier: case SyntaxKind.QualifiedName: return (node); @@ -2684,10 +2684,6 @@ namespace ts { isClassLike(node.parent.parent); } - export function isSupportedExpressionWithTypeArguments(node: ExpressionWithTypeArguments): node is SupportedExpressionWithTypeArguments { - return isEntityNameExpression(node.expression); - } - export function isEntityNameExpression(node: Expression): node is EntityNameExpression { for (; ; ) { switch (node.kind) { @@ -2702,10 +2698,6 @@ namespace ts { } } - export function isPropertyAccessAnEntityNameExpression(node: PropertyAccessExpression): node is PropertyAccessEntityNameExpression { - return isEntityNameExpression(node.expression); - } - export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) { return (node.parent.kind === SyntaxKind.QualifiedName && (node.parent).right === node) || (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); From db44a710058b2340184de90127aed3182ed1c251 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 2 Aug 2016 10:47:06 -0700 Subject: [PATCH 054/508] Fix bug --- src/compiler/checker.ts | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d8b3785a89e..dc0c8a6a415 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -980,21 +980,23 @@ namespace ts { * but returns undefined if that expression is not an EntityNameExpression. */ function climbToEntityNameOfExpressionWithTypeArguments(node: Node): EntityNameExpression | undefined { - switch (node.kind) { - case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccessExpression: - if (node.parent) { - node = node.parent; - } - else { + for (; ; ) { + switch (node.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.PropertyAccessExpression: + if (node.parent) { + node = node.parent; + } + else { + return undefined; + } + break; + case SyntaxKind.ExpressionWithTypeArguments: + Debug.assert(isEntityNameExpression((node).expression)); + return (node).expression; + default: return undefined; - } - break; - case SyntaxKind.ExpressionWithTypeArguments: - Debug.assert(isEntityNameExpression((node).expression)); - return (node).expression; - default: - return undefined; + } } } From 0eeb9cbd0c9d89f0bc5d72ea7ad9248f0302cd37 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 2 Aug 2016 12:34:23 -0700 Subject: [PATCH 055/508] Fix #10083 - allowSyntheticDefaultImports alters getExternalModuleMember (#10096) --- src/compiler/checker.ts | 4 +++ .../allowSyntheticDefaultImports10.errors.txt | 17 +++++++++++ .../allowSyntheticDefaultImports10.js | 17 +++++++++++ .../allowSyntheticDefaultImports7.js | 28 +++++++++++++++++++ .../allowSyntheticDefaultImports7.symbols | 22 +++++++++++++++ .../allowSyntheticDefaultImports7.types | 24 ++++++++++++++++ .../allowSyntheticDefaultImports8.errors.txt | 14 ++++++++++ .../allowSyntheticDefaultImports8.js | 28 +++++++++++++++++++ .../allowSyntheticDefaultImports9.js | 17 +++++++++++ .../allowSyntheticDefaultImports9.symbols | 22 +++++++++++++++ .../allowSyntheticDefaultImports9.types | 24 ++++++++++++++++ .../allowSyntheticDefaultImports10.ts | 11 ++++++++ .../compiler/allowSyntheticDefaultImports7.ts | 10 +++++++ .../compiler/allowSyntheticDefaultImports8.ts | 11 ++++++++ .../compiler/allowSyntheticDefaultImports9.ts | 11 ++++++++ 15 files changed, 260 insertions(+) create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports10.js create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports7.js create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports7.symbols create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports7.types create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports8.errors.txt create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports8.js create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports9.js create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports9.symbols create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports9.types create mode 100644 tests/cases/compiler/allowSyntheticDefaultImports10.ts create mode 100644 tests/cases/compiler/allowSyntheticDefaultImports7.ts create mode 100644 tests/cases/compiler/allowSyntheticDefaultImports8.ts create mode 100644 tests/cases/compiler/allowSyntheticDefaultImports9.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0a45b61660a..c1626ff0b75 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1135,6 +1135,10 @@ namespace ts { else { symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } + // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default + if (!symbolFromVariable && allowSyntheticDefaultImports && name.text === "default") { + symbolFromVariable = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); const symbolFromModule = getExportOfModule(targetSymbol, name.text); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt b/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt new file mode 100644 index 00000000000..981f89214e2 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/a.ts(2,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. +tests/cases/compiler/a.ts(3,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. + + +==== tests/cases/compiler/a.ts (2 errors) ==== + import Foo = require("./b"); + Foo.default.bar(); + ~~~~~~~ +!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. + Foo.default.default.foo(); + ~~~~~~~ +!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. +==== tests/cases/compiler/b.d.ts (0 errors) ==== + export function foo(); + + export function bar(); + \ No newline at end of file diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.js b/tests/baselines/reference/allowSyntheticDefaultImports10.js new file mode 100644 index 00000000000..746997c4c89 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/allowSyntheticDefaultImports10.ts] //// + +//// [b.d.ts] +export function foo(); + +export function bar(); + +//// [a.ts] +import Foo = require("./b"); +Foo.default.bar(); +Foo.default.default.foo(); + +//// [a.js] +"use strict"; +var Foo = require("./b"); +Foo.default.bar(); +Foo.default.default.foo(); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports7.js b/tests/baselines/reference/allowSyntheticDefaultImports7.js new file mode 100644 index 00000000000..51cc63e6e11 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports7.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/allowSyntheticDefaultImports7.ts] //// + +//// [b.d.ts] +export function foo(); + +export function bar(); + +//// [a.ts] +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); + +//// [a.js] +System.register(["./b"], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var b_1; + return { + setters:[ + function (b_1_1) { + b_1 = b_1_1; + }], + execute: function() { + b_1["default"].bar(); + b_1["default"].foo(); + } + } +}); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports7.symbols b/tests/baselines/reference/allowSyntheticDefaultImports7.symbols new file mode 100644 index 00000000000..51155dd69df --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports7.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : Symbol(foo, Decl(b.d.ts, 0, 0)) + +export function bar(); +>bar : Symbol(bar, Decl(b.d.ts, 0, 22)) + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : Symbol(Foo, Decl(a.ts, 0, 8)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) + +Foo.bar(); +>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) +>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22)) + +Foo.foo(); +>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) +>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports7.types b/tests/baselines/reference/allowSyntheticDefaultImports7.types new file mode 100644 index 00000000000..69ce39e6dc6 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports7.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : () => any + +export function bar(); +>bar : () => any + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : typeof Foo +>Foo : typeof Foo + +Foo.bar(); +>Foo.bar() : any +>Foo.bar : () => any +>Foo : typeof Foo +>bar : () => any + +Foo.foo(); +>Foo.foo() : any +>Foo.foo : () => any +>Foo : typeof Foo +>foo : () => any + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports8.errors.txt b/tests/baselines/reference/allowSyntheticDefaultImports8.errors.txt new file mode 100644 index 00000000000..acb584f8fd9 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports8.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/a.ts(1,10): error TS2305: Module '"tests/cases/compiler/b"' has no exported member 'default'. + + +==== tests/cases/compiler/b.d.ts (0 errors) ==== + export function foo(); + + export function bar(); + +==== tests/cases/compiler/a.ts (1 errors) ==== + import { default as Foo } from "./b"; + ~~~~~~~ +!!! error TS2305: Module '"tests/cases/compiler/b"' has no exported member 'default'. + Foo.bar(); + Foo.foo(); \ No newline at end of file diff --git a/tests/baselines/reference/allowSyntheticDefaultImports8.js b/tests/baselines/reference/allowSyntheticDefaultImports8.js new file mode 100644 index 00000000000..3c3c5fa8d28 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports8.js @@ -0,0 +1,28 @@ +//// [tests/cases/compiler/allowSyntheticDefaultImports8.ts] //// + +//// [b.d.ts] +export function foo(); + +export function bar(); + +//// [a.ts] +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); + +//// [a.js] +System.register(["./b"], function(exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var b_1; + return { + setters:[ + function (b_1_1) { + b_1 = b_1_1; + }], + execute: function() { + b_1["default"].bar(); + b_1["default"].foo(); + } + } +}); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports9.js b/tests/baselines/reference/allowSyntheticDefaultImports9.js new file mode 100644 index 00000000000..15810ccaaf7 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports9.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/allowSyntheticDefaultImports9.ts] //// + +//// [b.d.ts] +export function foo(); + +export function bar(); + +//// [a.ts] +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); + +//// [a.js] +"use strict"; +var b_1 = require("./b"); +b_1["default"].bar(); +b_1["default"].foo(); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports9.symbols b/tests/baselines/reference/allowSyntheticDefaultImports9.symbols new file mode 100644 index 00000000000..51155dd69df --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports9.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : Symbol(foo, Decl(b.d.ts, 0, 0)) + +export function bar(); +>bar : Symbol(bar, Decl(b.d.ts, 0, 22)) + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : Symbol(Foo, Decl(a.ts, 0, 8)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) + +Foo.bar(); +>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) +>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22)) + +Foo.foo(); +>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) +>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports9.types b/tests/baselines/reference/allowSyntheticDefaultImports9.types new file mode 100644 index 00000000000..69ce39e6dc6 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports9.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : () => any + +export function bar(); +>bar : () => any + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : typeof Foo +>Foo : typeof Foo + +Foo.bar(); +>Foo.bar() : any +>Foo.bar : () => any +>Foo : typeof Foo +>bar : () => any + +Foo.foo(); +>Foo.foo() : any +>Foo.foo : () => any +>Foo : typeof Foo +>foo : () => any + diff --git a/tests/cases/compiler/allowSyntheticDefaultImports10.ts b/tests/cases/compiler/allowSyntheticDefaultImports10.ts new file mode 100644 index 00000000000..6b50bae96d8 --- /dev/null +++ b/tests/cases/compiler/allowSyntheticDefaultImports10.ts @@ -0,0 +1,11 @@ +// @allowSyntheticDefaultImports: true +// @module: commonjs +// @Filename: b.d.ts +export function foo(); + +export function bar(); + +// @Filename: a.ts +import Foo = require("./b"); +Foo.default.bar(); +Foo.default.default.foo(); \ No newline at end of file diff --git a/tests/cases/compiler/allowSyntheticDefaultImports7.ts b/tests/cases/compiler/allowSyntheticDefaultImports7.ts new file mode 100644 index 00000000000..2da05e4678c --- /dev/null +++ b/tests/cases/compiler/allowSyntheticDefaultImports7.ts @@ -0,0 +1,10 @@ +// @module: system +// @Filename: b.d.ts +export function foo(); + +export function bar(); + +// @Filename: a.ts +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); \ No newline at end of file diff --git a/tests/cases/compiler/allowSyntheticDefaultImports8.ts b/tests/cases/compiler/allowSyntheticDefaultImports8.ts new file mode 100644 index 00000000000..3a213ad8023 --- /dev/null +++ b/tests/cases/compiler/allowSyntheticDefaultImports8.ts @@ -0,0 +1,11 @@ +// @allowSyntheticDefaultImports: false +// @module: system +// @Filename: b.d.ts +export function foo(); + +export function bar(); + +// @Filename: a.ts +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); \ No newline at end of file diff --git a/tests/cases/compiler/allowSyntheticDefaultImports9.ts b/tests/cases/compiler/allowSyntheticDefaultImports9.ts new file mode 100644 index 00000000000..8da66f33adf --- /dev/null +++ b/tests/cases/compiler/allowSyntheticDefaultImports9.ts @@ -0,0 +1,11 @@ +// @allowSyntheticDefaultImports: true +// @module: commonjs +// @Filename: b.d.ts +export function foo(); + +export function bar(); + +// @Filename: a.ts +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); \ No newline at end of file From dc192238cca65da38eb321c9e3ed6f7ced643f9a Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 2 Aug 2016 12:37:30 -0700 Subject: [PATCH 056/508] Use recursion, and fix error for undefined node --- src/compiler/checker.ts | 33 +++++++++++++-------------------- src/compiler/utilities.ts | 13 ++----------- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index dc0c8a6a415..ca85a85e279 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -664,7 +664,7 @@ namespace ts { // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with // the given name can be found. - function resolveName(location: Node, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): Symbol { + function resolveName(location: Node | undefined, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): Symbol { let result: Symbol; let lastLocation: Node; let propertyWithInvalidInitializer: Node; @@ -881,7 +881,8 @@ namespace ts { if (!result) { if (nameNotFoundMessage) { - if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && + if (!errorLocation || + !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); } @@ -930,7 +931,7 @@ namespace ts { } function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: string, nameArg: string | Identifier): boolean { - if (!errorLocation || (errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } @@ -980,23 +981,15 @@ namespace ts { * but returns undefined if that expression is not an EntityNameExpression. */ function climbToEntityNameOfExpressionWithTypeArguments(node: Node): EntityNameExpression | undefined { - for (; ; ) { - switch (node.kind) { - case SyntaxKind.Identifier: - case SyntaxKind.PropertyAccessExpression: - if (node.parent) { - node = node.parent; - } - else { - return undefined; - } - break; - case SyntaxKind.ExpressionWithTypeArguments: - Debug.assert(isEntityNameExpression((node).expression)); - return (node).expression; - default: - return undefined; - } + switch (node.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.PropertyAccessExpression: + return node.parent ? climbToEntityNameOfExpressionWithTypeArguments(node.parent) : undefined; + case SyntaxKind.ExpressionWithTypeArguments: + Debug.assert(isEntityNameExpression((node).expression)); + return (node).expression + default: + return undefined; } } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index f946e4b614f..affbcbe7a98 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2685,17 +2685,8 @@ namespace ts { } export function isEntityNameExpression(node: Expression): node is EntityNameExpression { - for (; ; ) { - switch (node.kind) { - case SyntaxKind.Identifier: - return true; - case SyntaxKind.PropertyAccessExpression: - node = (node).expression; - break; - default: - return false; - } - } + return node.kind === SyntaxKind.Identifier || + node.kind === SyntaxKind.PropertyAccessExpression && isEntityNameExpression((node).expression); } export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) { From 6814a9fac6a218c8a51fd283b1cfd3144cf3d67b Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 2 Aug 2016 12:41:22 -0700 Subject: [PATCH 057/508] Rename function --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ca85a85e279..dd9b56a5b58 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -969,7 +969,7 @@ namespace ts { function checkAndReportErrorForExtendingInterface(errorLocation: Node): boolean { - const expression = climbToEntityNameOfExpressionWithTypeArguments(errorLocation); + const expression = getEntityNameForExtendingInterface(errorLocation); const isError = !!(expression && resolveEntityName(expression, SymbolFlags.Interface, /*ignoreErrors*/ true)); if (isError) { error(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression)); @@ -980,11 +980,11 @@ namespace ts { * Climbs up parents to an ExpressionWithTypeArguments, and returns its expression, * but returns undefined if that expression is not an EntityNameExpression. */ - function climbToEntityNameOfExpressionWithTypeArguments(node: Node): EntityNameExpression | undefined { + function getEntityNameForExtendingInterface(node: Node): EntityNameExpression | undefined { switch (node.kind) { case SyntaxKind.Identifier: case SyntaxKind.PropertyAccessExpression: - return node.parent ? climbToEntityNameOfExpressionWithTypeArguments(node.parent) : undefined; + return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; case SyntaxKind.ExpressionWithTypeArguments: Debug.assert(isEntityNameExpression((node).expression)); return (node).expression From 7908257ab7b59b4760e7012c03fcc700e31e7fa2 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 2 Aug 2016 13:18:46 -0700 Subject: [PATCH 058/508] Fix lint error --- 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 dd9b56a5b58..0c65050a327 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -987,7 +987,7 @@ namespace ts { return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; case SyntaxKind.ExpressionWithTypeArguments: Debug.assert(isEntityNameExpression((node).expression)); - return (node).expression + return (node).expression; default: return undefined; } From a5d73bfc2430091176de535af86a90ce677293a4 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 2 Aug 2016 15:55:30 -0700 Subject: [PATCH 059/508] No more filtering results --- src/services/services.ts | 122 ++++++++++-------- ...etionForStringLiteralNonrelativeImport4.ts | 22 +--- ...mpletionForStringLiteralRelativeImport1.ts | 44 ++----- ...mpletionForStringLiteralRelativeImport2.ts | 7 +- ...mpletionForStringLiteralRelativeImport4.ts | 2 + .../completionForTripleSlashReference1.ts | 78 ++++------- .../completionForTripleSlashReference2.ts | 49 +++---- 7 files changed, 127 insertions(+), 197 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 66b894bb428..e8ff3847804 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2069,7 +2069,7 @@ namespace ts { * for completions. * For example, this matches /// combinePaths(rootDirectory, relativeDirectory))); } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan): ImportCompletionEntry[] { + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string): ImportCompletionEntry[] { const basePath = program.getCompilerOptions().project || host.getCurrentDirectory(); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - const baseDirectories = getBaseDirectoriesFromRootDirs( - rootDirs, basePath, scriptPath, host.useCaseSensitiveFileNames && !host.useCaseSensitiveFileNames()); const result: ImportCompletionEntry[] = []; for (const baseDirectory of baseDirectories) { - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, result); + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); } return result; } - function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { - const toComplete = getBaseFileName(fragment); - const absolutePath = normalizeSlashes(host.resolvePath(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment))); - const baseDirectory = toComplete ? getDirectoryPath(absolutePath) : absolutePath; + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { + fragment = getDirectoryPath(fragment); + if (!fragment) { + fragment = "./" + } + else { + fragment = ensureTrailingDirectorySeparator(fragment); + } + + const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); + const baseDirectory = host.resolvePath(getDirectoryPath(absolutePath)); + const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); if (directoryProbablyExists(baseDirectory, host)) { // Enumerate the available files const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); - forEach(files, f => { - const fileName = includeExtensions ? getBaseFileName(f) : removeFileExtension(getBaseFileName(f)); + forEach(files, filePath => { + if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { + return false; + } - const duplicate = includeExtensions ? false : forEach(result, entry => entry.name === fileName); + const fileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); + const duplicate = !includeExtensions && forEach(result, entry => entry.name === fileName); - if (startsWith(fileName, toComplete) && !duplicate) { + if (!duplicate) { result.push({ name: fileName, kind: ScriptElementKind.directory, @@ -4605,14 +4612,12 @@ namespace ts { forEach(directories, d => { const directoryName = getBaseFileName(removeTrailingDirectorySeparator(d)); - if (startsWith(directoryName, toComplete)) { - result.push({ - name: ensureTrailingDirectorySeparator(directoryName), - kind: ScriptElementKind.directory, - sortText: directoryName, - span - }); - } + result.push({ + name: ensureTrailingDirectorySeparator(directoryName), + kind: ScriptElementKind.directory, + sortText: directoryName, + span + }); }); } } @@ -4679,18 +4684,17 @@ namespace ts { if (parsed) { // The prefix has two effective parts: the directory path and the base component after the filepath that is not a // full directory component. For example: directory/path/of/prefix/base* - const normalizedPrefix = hasTrailingDirectorySeparator(parsed.prefix) ? - ensureTrailingDirectorySeparator(normalizePath(parsed.prefix)) : normalizePath(parsed.prefix); + const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); const normalizedPrefixBase = getBaseFileName(normalizedPrefix); const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - const expandedPrefixDir = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; + const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; const normalizedSuffix = normalizePath(parsed.suffix); - const baseDirectory = combinePaths(baseUrl, expandedPrefixDir); + const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; // If we have a suffix, then we need to read the directory all the way down. We could create a glob @@ -4720,17 +4724,8 @@ namespace ts { } function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions): string[] { - const trailingSeperator = hasTrailingDirectorySeparator(fragment); - fragment = normalizePath(fragment); - - if (trailingSeperator) { - fragment = ensureTrailingDirectorySeparator(fragment); - } - - // If this is a nested module, get the module name - const firstSeparator = fragment.indexOf(directorySeparator); - const moduleNameFragment = firstSeparator !== -1 ? fragment.substr(0, firstSeparator) : fragment; - const isNestedModule = fragment !== moduleNameFragment; + // Check If this is a nested module + const isNestedModule = fragment.indexOf(directorySeparator) !== -1 ; // Get modules that the type checker picked up const ambientModules = ts.map(program.getTypeChecker().getAmbientModules(), sym => stripQuotes(sym.name)); @@ -4749,7 +4744,7 @@ namespace ts { }); if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { - forEach(enumerateNodeModulesVisibleToScript(host, scriptPath, moduleNameFragment), visibleModule => { + forEach(enumerateNodeModulesVisibleToScript(host, scriptPath), visibleModule => { if (!isNestedModule) { nonRelativeModules.push(visibleModule.canBeImported ? visibleModule.moduleName : ensureTrailingDirectorySeparator(visibleModule.moduleName)); } @@ -4796,7 +4791,7 @@ namespace ts { if (kind === "path") { // Give completions for a relative path const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - return getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, span); + return getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, span, sourceFile.path); } else { // Give completions based on the typings available @@ -4876,7 +4871,7 @@ namespace ts { } - function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string, modulePrefix?: string) { + function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { const result: VisibleModuleInfo[] = []; findPackageJsons(scriptPath).forEach((packageJson) => { const package = tryReadingPackageJson(packageJson); @@ -4888,10 +4883,10 @@ namespace ts { const foundModuleNames: string[] = []; if (package.dependencies) { - addPotentialPackageNames(package.dependencies, modulePrefix, foundModuleNames); + addPotentialPackageNames(package.dependencies, foundModuleNames); } if (package.devDependencies) { - addPotentialPackageNames(package.devDependencies, modulePrefix, foundModuleNames); + addPotentialPackageNames(package.devDependencies, foundModuleNames); } forEach(foundModuleNames, (moduleName) => { @@ -4916,9 +4911,10 @@ namespace ts { } } - function addPotentialPackageNames(dependencies: any, prefix: string, result: string[]) { + function addPotentialPackageNames(dependencies: any, result: string[]) { for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && (!prefix || startsWith(dep, prefix))) { + if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types") && + dep.charCodeAt(6) !== CharacterCodes.slash && dep.charCodeAt(6) !== CharacterCodes.backslash) { result.push(dep); } } @@ -4961,6 +4957,20 @@ namespace ts { const offset = index !== -1 ? index + 1 : 0; return { start: textStart + offset, length: text.length - offset } } + + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path: string) { + if (path && path.length >= 2 && path.charCodeAt(0) === CharacterCodes.dot) { + const slashIndex = path.length >= 3 && path.charCodeAt(1) === CharacterCodes.dot ? 2 : 1; + const slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === CharacterCodes.slash || slashCharCode === CharacterCodes.backslash; + } + return false; + } + + function normalizeAndPreserveTrailingSlash(path: string) { + return hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalizePath(path)) : normalizePath(path); + } } function getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index 28170754456..f4a9ae2d537 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -2,16 +2,8 @@ // @Filename: dir1/dir2/dir3/dir4/test0.ts //// import * as foo1 from "f/*import_as0*/ -//// import * as foo2 from "a/*import_as1*/ -//// import * as foo3 from "fake-module/*import_as2*/ - //// import foo4 = require("f/*import_equals0*/ -//// import foo5 = require("a/*import_equals1*/ -//// import foo6 = require("fake-module/*import_equals2*/ - //// var foo7 = require("f/*require0*/ -//// var foo8 = require("a/*require1*/ -//// var foo9 = require("fake-module/*require2*/ // @Filename: package.json //// { "dependencies": { "fake-module": "latest" } } @@ -21,7 +13,7 @@ // @Filename: dir1/package.json //// { "dependencies": { "fake-module2": "latest" } } // @Filename: dir1/node_modules/fake-module2/index.ts -//// declare module "ambient-module-test" {} +//// /*module2*/ // @Filename: dir1/dir2/dir3/package.json //// { "dependencies": { "fake-module3": "latest" } } @@ -37,16 +29,4 @@ for (const kind of kinds) { verify.importModuleCompletionListContains("fake-module2"); verify.importModuleCompletionListContains("fake-module3/"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); - - goTo.marker(kind + "1"); - - verify.importModuleCompletionListContains("ambient-module-test"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); - - goTo.marker(kind + "2"); - - verify.importModuleCompletionListContains("fake-module/"); - verify.importModuleCompletionListContains("fake-module2"); - verify.importModuleCompletionListContains("fake-module3/"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts index f3607d70c28..52d62f3b4f8 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts @@ -3,28 +3,21 @@ // @Filename: test0.ts //// import * as foo1 from "./*import_as0*/ //// import * as foo2 from ".//*import_as1*/ -//// import * as foo3 from "./f/*import_as2*/ -//// import * as foo4 from "./folder//*import_as3*/ -//// import * as foo5 from "./folder/h/*import_as4*/ +//// import * as foo4 from "./folder//*import_as2*/ //// import foo6 = require("./*import_equals0*/ //// import foo7 = require(".//*import_equals1*/ -//// import foo8 = require("./f/*import_equals2*/ -//// import foo9 = require("./folder//*import_equals3*/ -//// import foo10 = require("./folder/h/*import_equals4*/ +//// import foo9 = require("./folder//*import_equals2*/ //// var foo11 = require("./*require0*/ //// var foo12 = require(".//*require1*/ -//// var foo13 = require("./f/*require2*/ -//// var foo14 = require("./folder//*require3*/ -//// var foo15 = require("./folder/h/*require4*/ +//// var foo14 = require("./folder//*require2*/ // @Filename: parentTest/sub/test5.ts -//// import * as foo16 from "../g/*import_as5*/ +//// import * as foo16 from "../g/*import_as3*/ +//// import foo17 = require("../g/*import_equals3*/ +//// var foo18 = require("../g/*require3*/ -//// import foo17 = require("../g/*import_equals5*/ - -//// var foo18 = require("../g/*require5*/ // @Filename: f1.ts //// /*f1*/ @@ -40,11 +33,11 @@ //// /*f4*/ // @Filename: e1.ts //// /*e1*/ -// @Filename: folder/f1.ts +// @Filename: folder/f3.ts //// /*subf1*/ // @Filename: folder/h1.ts //// /*subh1*/ -// @Filename: parentTest/f1.ts +// @Filename: parentTest/f4.ts //// /*parentf1*/ // @Filename: parentTest/g1.ts //// /*parentg1*/ @@ -58,27 +51,18 @@ for (const kind of kinds) { verify.importModuleCompletionListContains("f1"); verify.importModuleCompletionListContains("f2"); verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("test0"); verify.importModuleCompletionListContains("folder/"); verify.importModuleCompletionListContains("parentTest/"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("folder/"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); - - goTo.marker(kind + "3"); - verify.importModuleCompletionListContains("f1"); + verify.importModuleCompletionListContains("f3"); verify.importModuleCompletionListContains("h1"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); - goTo.marker(kind + "4"); - verify.importModuleCompletionListContains("h1"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); - - goTo.marker(kind + "5"); + goTo.marker(kind + "3"); + verify.importModuleCompletionListContains("f4"); verify.importModuleCompletionListContains("g1"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.importModuleCompletionListContains("sub/"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts index eeb24d591f0..72b28d39b87 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts @@ -37,13 +37,14 @@ for (const kind of kinds) { verify.importModuleCompletionListContains("f4"); verify.importModuleCompletionListContains("e1"); verify.importModuleCompletionListContains("e2"); - verify.importModuleCompletionListContains("test0"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(7); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); goTo.marker(kind + "1"); verify.importModuleCompletionListContains("f1"); verify.importModuleCompletionListContains("f2"); verify.importModuleCompletionListContains("f3"); verify.importModuleCompletionListContains("f4"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); + verify.importModuleCompletionListContains("e1"); + verify.importModuleCompletionListContains("e2"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index 5f4d7bb7fc0..773c4d90d75 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -44,5 +44,7 @@ for (const kind of kinds) { verify.importModuleCompletionListContains("module1"); verify.importModuleCompletionListContains("module2"); verify.importModuleCompletionListContains("more/"); + + // Should not contain itself verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference1.ts b/tests/cases/fourslash/completionForTripleSlashReference1.ts index 284d5ff66a4..8c6188ac90c 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference1.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference1.ts @@ -1,22 +1,15 @@ /// // @Filename: test0.ts -//// /// +//// /// - -// @Filename: test3.ts -//// /// // @Filename: f1.ts -//// /f1*/ +//// /*f1*/ // @Filename: f1.js //// /*f1j*/ // @Filename: f1.d.ts //// /*f1d*/ // @Filename: f2.tsx -//// /*f2*/ -// @Filename: f3.js -//// /*f3*/ +//// /f2*/ // @Filename: f4.jsx //// /*f4*/ -// @Filename: e1.ts -//// /*e1*/ -// @Filename: e2.js -//// /*e2*/ -goTo.marker("0"); -verify.importModuleCompletionListContains("f1.ts"); -verify.importModuleCompletionListContains("f1.js"); -verify.importModuleCompletionListContains("f1.d.ts"); -verify.importModuleCompletionListContains("f2.tsx"); -verify.importModuleCompletionListContains("f3.js"); -verify.importModuleCompletionListContains("f4.jsx"); -verify.importModuleCompletionListContains("e1.ts"); -verify.importModuleCompletionListContains("e2.js"); -verify.importModuleCompletionListContains("test0.ts"); -verify.importModuleCompletionListContains("test1.ts"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(10); - -goTo.marker("1"); -verify.importModuleCompletionListContains("f1.ts"); -verify.importModuleCompletionListContains("f1.js"); -verify.importModuleCompletionListContains("f1.d.ts"); -verify.importModuleCompletionListContains("f2.tsx"); -verify.importModuleCompletionListContains("f3.js"); -verify.importModuleCompletionListContains("f4.jsx"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); \ No newline at end of file +for (let i = 0; i < 5; i++) { + goTo.marker("" + i); + verify.importModuleCompletionListContains("f1.ts"); + verify.importModuleCompletionListContains("f1.js"); + verify.importModuleCompletionListContains("f1.d.ts"); + verify.importModuleCompletionListContains("f2.tsx"); + verify.importModuleCompletionListContains("f4.jsx"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); +} \ No newline at end of file From 4189b4d71855dd059b79d075320601cb12f71659 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 2 Aug 2016 16:10:20 -0700 Subject: [PATCH 060/508] Narrowing type parameter intersects w/narrowed types This makes sure that a union type that includes a type parameter is still usable as the actual type that the type guard narrows to. --- src/compiler/checker.ts | 30 +++++++++--- .../reference/controlFlowIfStatement.js | 32 +++++++++++++ .../reference/controlFlowIfStatement.symbols | 38 +++++++++++++++ .../reference/controlFlowIfStatement.types | 47 +++++++++++++++++++ .../controlFlow/controlFlowIfStatement.ts | 16 +++++++ 5 files changed, 156 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 04c12eb613c..2d4ce970172 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7900,13 +7900,17 @@ namespace ts { return TypeFacts.All; } - function getTypeWithFacts(type: Type, include: TypeFacts) { + function getTypeWithFacts(type: Type, include: TypeFacts, intersectForTypeParameters = false) { if (!(type.flags & TypeFlags.Union)) { return getTypeFacts(type) & include ? type : neverType; } let firstType: Type; + let hasTypeParameter = false; let types: Type[]; for (const t of (type as UnionType).types) { + if (t.flags & TypeFlags.TypeParameter) { + hasTypeParameter = true; + } if (getTypeFacts(t) & include) { if (!firstType) { firstType = t; @@ -7919,7 +7923,19 @@ namespace ts { } } } - return firstType ? types ? getUnionType(types) : firstType : neverType; + const narrowed = types ? getUnionType(types) : + firstType ? firstType : neverType; + // if there is a type parameter in the narrowed type, + // add an intersection with the members of the narrowed type so that the shape of the type is correct + if (type.flags & TypeFlags.Union && + narrowed.flags & TypeFlags.Union && + hasTypeParameter && + intersectForTypeParameters) { + return getIntersectionType(types.concat([narrowed])); + } + else { + return narrowed; + } } function getTypeWithDefault(type: Type, defaultExpression: Expression) { @@ -8183,7 +8199,7 @@ namespace ts { let type = getTypeAtFlowNode(flow.antecedent); if (type !== neverType) { // If we have an antecedent type (meaning we're reachable in some way), we first - // attempt to narrow the antecedent type. If that produces the nothing type, then + // attempt to narrow the antecedent type. If that produces the never type, then // we take the type guard as an indication that control could reach here in a // manner not understood by the control flow analyzer (e.g. a function argument // has an invalid type, or a nested function has possibly made an assignment to a @@ -8292,10 +8308,10 @@ namespace ts { function narrowTypeByTruthiness(type: Type, expr: Expression, assumeTrue: boolean): Type { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy); + return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy, assumeTrue); } if (isMatchingPropertyAccess(expr)) { - return narrowTypeByDiscriminant(type, expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy)); + return narrowTypeByDiscriminant(type, expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy, assumeTrue)); } return type; } @@ -8353,7 +8369,7 @@ namespace ts { value.kind === SyntaxKind.NullKeyword ? assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull : assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; - return getTypeWithFacts(type, facts); + return getTypeWithFacts(type, facts, assumeTrue); } if (type.flags & TypeFlags.NotUnionOrUnit) { return type; @@ -8391,7 +8407,7 @@ namespace ts { const facts = assumeTrue ? getProperty(typeofEQFacts, literal.text) || TypeFacts.TypeofEQHostObject : getProperty(typeofNEFacts, literal.text) || TypeFacts.TypeofNEHostObject; - return getTypeWithFacts(type, facts); + return getTypeWithFacts(type, facts, assumeTrue); } function narrowTypeBySwitchOnDiscriminant(type: Type, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number) { diff --git a/tests/baselines/reference/controlFlowIfStatement.js b/tests/baselines/reference/controlFlowIfStatement.js index a70c07d38dc..e40b831552f 100644 --- a/tests/baselines/reference/controlFlowIfStatement.js +++ b/tests/baselines/reference/controlFlowIfStatement.js @@ -35,6 +35,22 @@ function b() { } x; // string } +function c(data: string | T): T { + if (typeof data === 'string') { + return JSON.parse(data); + } + else { + return data; + } +} +function d(data: string | T): never { + if (typeof data === 'string') { + throw new Error('will always happen'); + } + else { + return data; + } +} //// [controlFlowIfStatement.js] @@ -72,3 +88,19 @@ function b() { } x; // string } +function c(data) { + if (typeof data === 'string') { + return JSON.parse(data); + } + else { + return data; + } +} +function d(data) { + if (typeof data === 'string') { + throw new Error('will always happen'); + } + else { + return data; + } +} diff --git a/tests/baselines/reference/controlFlowIfStatement.symbols b/tests/baselines/reference/controlFlowIfStatement.symbols index 1d85b31c998..e4d2bb9f184 100644 --- a/tests/baselines/reference/controlFlowIfStatement.symbols +++ b/tests/baselines/reference/controlFlowIfStatement.symbols @@ -71,4 +71,42 @@ function b() { x; // string >x : Symbol(x, Decl(controlFlowIfStatement.ts, 26, 7)) } +function c(data: string | T): T { +>c : Symbol(c, Decl(controlFlowIfStatement.ts, 35, 1)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 36, 11)) +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 36, 14)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 36, 11)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 36, 11)) + + if (typeof data === 'string') { +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 36, 14)) + + return JSON.parse(data); +>JSON.parse : Symbol(JSON.parse, Decl(lib.d.ts, --, --)) +>JSON : Symbol(JSON, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>parse : Symbol(JSON.parse, Decl(lib.d.ts, --, --)) +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 36, 14)) + } + else { + return data; +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 36, 14)) + } +} +function d(data: string | T): never { +>d : Symbol(d, Decl(controlFlowIfStatement.ts, 43, 1)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 44, 11)) +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 44, 29)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 44, 11)) + + if (typeof data === 'string') { +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 44, 29)) + + throw new Error('will always happen'); +>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + } + else { + return data; +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 44, 29)) + } +} diff --git a/tests/baselines/reference/controlFlowIfStatement.types b/tests/baselines/reference/controlFlowIfStatement.types index 716491ea58b..e706f9f6a4e 100644 --- a/tests/baselines/reference/controlFlowIfStatement.types +++ b/tests/baselines/reference/controlFlowIfStatement.types @@ -90,4 +90,51 @@ function b() { x; // string >x : string } +function c(data: string | T): T { +>c : (data: string | T) => T +>T : T +>data : string | T +>T : T +>T : T + + if (typeof data === 'string') { +>typeof data === 'string' : boolean +>typeof data : string +>data : string | T +>'string' : "string" + + return JSON.parse(data); +>JSON.parse(data) : any +>JSON.parse : (text: string, reviver?: (key: any, value: any) => any) => any +>JSON : JSON +>parse : (text: string, reviver?: (key: any, value: any) => any) => any +>data : string & T & (string | T) + } + else { + return data; +>data : T + } +} +function d(data: string | T): never { +>d : (data: string | T) => never +>T : T +>data : string | T +>T : T + + if (typeof data === 'string') { +>typeof data === 'string' : boolean +>typeof data : string +>data : string | T +>'string' : "string" + + throw new Error('will always happen'); +>new Error('will always happen') : Error +>Error : ErrorConstructor +>'will always happen' : string + } + else { + return data; +>data : never + } +} diff --git a/tests/cases/conformance/controlFlow/controlFlowIfStatement.ts b/tests/cases/conformance/controlFlow/controlFlowIfStatement.ts index c9e9be92f8e..dc1cf97fe59 100644 --- a/tests/cases/conformance/controlFlow/controlFlowIfStatement.ts +++ b/tests/cases/conformance/controlFlow/controlFlowIfStatement.ts @@ -34,3 +34,19 @@ function b() { } x; // string } +function c(data: string | T): T { + if (typeof data === 'string') { + return JSON.parse(data); + } + else { + return data; + } +} +function d(data: string | T): never { + if (typeof data === 'string') { + throw new Error('will always happen'); + } + else { + return data; + } +} From 8b5a3d9fd7142a18b2f25c589622a70476306ae9 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 2 Aug 2016 19:03:36 -0700 Subject: [PATCH 061/508] Refactoring API to remove duplicate spans --- src/harness/fourslash.ts | 24 ++++---- src/harness/harnessLanguageService.ts | 2 +- src/server/client.ts | 10 +++- src/server/protocol.d.ts | 3 +- src/services/services.ts | 84 +++++++++++++++------------ src/services/shims.ts | 2 +- 6 files changed, 70 insertions(+), 55 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 9ad5f25e005..532dccd4f6b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -599,7 +599,7 @@ namespace FourSlash { public verifyImportModuleCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) { const completions = this.getImportModuleCompletionListAtCaret(); - const itemsCount = completions.length; + const itemsCount = completions.entries.length; if (negative) { if (itemsCount > count) { @@ -615,13 +615,13 @@ namespace FourSlash { public verifyImportModuleCompletionListIsEmpty(negative: boolean) { const completions = this.getImportModuleCompletionListAtCaret(); - if ((!completions || completions.length === 0) && negative) { + if ((!completions || completions.entries.length === 0) && negative) { this.raiseError("Completion list is empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition); } - else if (completions && completions.length !== 0 && !negative) { - let errorMsg = "\n" + "Completion List contains: [" + completions[0].name; - for (let i = 1; i < completions.length; i++) { - errorMsg += ", " + completions[i].name; + else if (completions && completions.entries.length !== 0 && !negative) { + let errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name; + for (let i = 1; i < completions.entries.length; i++) { + errorMsg += ", " + completions.entries[i].name; } errorMsg += "]\n"; @@ -769,9 +769,9 @@ namespace FourSlash { public verifyImportModuleCompletionListContains(symbol: string, rangeIndex?: number) { const completions = this.getImportModuleCompletionListAtCaret(); if (completions) { - const completion = ts.forEach(completions, completion => completion.name === symbol ? completion : undefined); + const completion = ts.forEach(completions.entries, completion => completion.name === symbol ? completion : undefined); if (!completion) { - const itemsString = completions.map(item => stringify({ name: item.name, span: item.span })).join(",\n"); + const itemsString = completions.entries.map(item => item.name).join(",\n"); this.raiseError(`Expected "${symbol}" to be in list [${itemsString}]`); } else if (rangeIndex !== undefined) { @@ -779,10 +779,10 @@ namespace FourSlash { if (ranges && ranges.length > rangeIndex) { const range = ranges[rangeIndex]; - const start = completion.span.start; - const end = start + completion.span.length; + const start = completions.span.start; + const end = start + completions.span.length; if (range.start !== start || range.end !== end) { - this.raiseError(`Expected completion span for '${symbol}', ${stringify(completion.span)}, to cover range ${stringify(range)}`); + this.raiseError(`Expected completion span for '${symbol}', ${stringify(completions.span)}, to cover range ${stringify(range)}`); } } else { @@ -798,7 +798,7 @@ namespace FourSlash { public verifyImportModuleCompletionListDoesNotContain(symbol: string) { const completions = this.getImportModuleCompletionListAtCaret(); if (completions) { - if (ts.forEach(completions, completion => completion.name === symbol)) { + if (ts.forEach(completions.entries, completion => completion.name === symbol)) { this.raiseError(`Import module completion list did contain ${symbol}`); } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 1972ab85b9d..35032f31828 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -426,7 +426,7 @@ namespace Harness.LanguageService { getCompletionsAtPosition(fileName: string, position: number): ts.CompletionInfo { return unwrapJSONCallResult(this.shim.getCompletionsAtPosition(fileName, position)); } - getImportModuleCompletionsAtPosition(fileName: string, position: number): ts.ImportCompletionEntry[] { + getImportModuleCompletionsAtPosition(fileName: string, position: number): ts.ImportCompletionInfo { return unwrapJSONCallResult(this.shim.getImportModuleCompletionsAtPosition(fileName, position)); } getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails { diff --git a/src/server/client.ts b/src/server/client.ts index 04784a77f10..03a370411d1 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -220,7 +220,7 @@ namespace ts.server { }; } - getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionEntry[] { + getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionInfo { const lineOffset = this.positionToOneBasedLineOffset(fileName, position); const args: protocol.CompletionsRequestArgs = { file: fileName, @@ -232,7 +232,13 @@ namespace ts.server { const request = this.processRequest(CommandNames.ImportModuleCompletions, args); const response = this.processResponse(request); - return response.body; + const startPosition = this.lineOffsetToPosition(fileName, response.span.start); + const endPosition = this.lineOffsetToPosition(fileName, response.span.end); + + return { + span: ts.createTextSpanFromBounds(startPosition, endPosition), + entries: response.body + }; } getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails { diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 803edce0d70..20670ae0245 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -816,7 +816,8 @@ declare namespace ts.server.protocol { body?: CompletionEntry[]; } - export interface ImportModuleCompletionsResponse extends Response { + export interface ImportModuleCompletionsResponse extends Response { + span: TextSpan; body?: ImportCompletionEntry[]; } diff --git a/src/services/services.ts b/src/services/services.ts index e8ff3847804..fd665908248 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1208,7 +1208,7 @@ namespace ts { getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; - getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionEntry[]; + getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionInfo; getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; @@ -1481,10 +1481,14 @@ namespace ts { sortText: string; } + export interface ImportCompletionInfo { + span: TextSpan; + entries: ImportCompletionEntry[]; + } + export interface ImportCompletionEntry { name: string; kind: string; // see ScriptElementKind - span: TextSpan; sortText: string; } @@ -4492,7 +4496,7 @@ namespace ts { } } - function getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionEntry[] { + function getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionInfo { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); @@ -4507,7 +4511,10 @@ namespace ts { if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module - return getStringLiteralCompletionEntriesFromModuleNames(node); + return { + entries: getStringLiteralCompletionEntriesFromModuleNames(node), + span: getDirectoryFragmentTextSpan((node).text, node.getStart() + 1) + }; } } @@ -4515,8 +4522,6 @@ namespace ts { function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral) { const literalValue = normalizeSlashes(node.text); - // Replace the entire text of the string literal (excluding the quotes) - const span: TextSpan = getDirectoryFragmentTextSpan(literalValue, node.getStart() + 1); const scriptPath = node.getSourceFile().path; const scriptDirectory = getDirectoryPath(scriptPath); @@ -4524,16 +4529,16 @@ namespace ts { const compilerOptions = program.getCompilerOptions(); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs( - compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span, scriptPath); + compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, scriptPath); } else { return getCompletionEntriesForDirectoryFragment( - literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span, scriptPath); + literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, scriptPath); } } else { // Check for node modules - return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); + return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory); } } @@ -4558,7 +4563,7 @@ namespace ts { return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string): ImportCompletionEntry[] { + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, exclude?: string): ImportCompletionEntry[] { const basePath = program.getCompilerOptions().project || host.getCurrentDirectory(); const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); @@ -4566,16 +4571,16 @@ namespace ts { const result: ImportCompletionEntry[] = []; for (const baseDirectory of baseDirectories) { - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, exclude, result); } return result; } - function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, exclude?: string, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { fragment = getDirectoryPath(fragment); if (!fragment) { - fragment = "./" + fragment = "./"; } else { fragment = ensureTrailingDirectorySeparator(fragment); @@ -4600,8 +4605,7 @@ namespace ts { result.push({ name: fileName, kind: ScriptElementKind.directory, - sortText: fileName, - span + sortText: fileName }); } }); @@ -4615,8 +4619,7 @@ namespace ts { result.push({ name: ensureTrailingDirectorySeparator(directoryName), kind: ScriptElementKind.directory, - sortText: directoryName, - span + sortText: directoryName }); }); } @@ -4632,7 +4635,7 @@ namespace ts { * Modules from node_modules (i.e. those listed in package.json) * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions */ - function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan): ImportCompletionEntry[] { + function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string): ImportCompletionEntry[] { const options = program.getCompilerOptions(); const { baseUrl, paths } = options; @@ -4642,7 +4645,7 @@ namespace ts { const fileExtensions = getSupportedExtensions(options); const projectDir = options.project || host.getCurrentDirectory(); const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span); + result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false); if (paths) { for (const path in paths) { @@ -4651,7 +4654,7 @@ namespace ts { if (paths[path]) { forEach(paths[path], pattern => { forEach(getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions), match => { - result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); + result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName)); }); }); } @@ -4659,7 +4662,7 @@ namespace ts { else if (startsWith(path, fragment)) { const entry = paths[path] && paths[path].length === 1 && paths[path][0]; if (entry) { - result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); + result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName)); } } } @@ -4670,10 +4673,10 @@ namespace ts { result = []; } - getCompletionEntriesFromTypings(host, options, scriptPath, span, result); + getCompletionEntriesFromTypings(host, options, scriptPath, result); forEach(enumeratePotentialNonRelativeModules(fragment, scriptPath, options), moduleName => { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); }); return result; @@ -4762,7 +4765,7 @@ namespace ts { return deduplicate(nonRelativeModules); } - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number): ImportCompletionEntry[] { + function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number): ImportCompletionInfo { const token = getTokenAtPosition(sourceFile, position); if (!token) { return undefined; @@ -4791,36 +4794,41 @@ namespace ts { if (kind === "path") { // Give completions for a relative path const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - return getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, span, sourceFile.path); + return { + entries: getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, sourceFile.path), + span + }; } else { // Give completions based on the typings available - // Replace the entire string const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - return getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath, span); + return { + entries: getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath), + span + }; } } return undefined; } - function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { + function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { // Check for typings specified in compiler options if (options.types) { forEach(options.types, moduleName => { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); }); } else if (host.getDirectories && options.typeRoots) { const absoluteRoots = map(options.typeRoots, rootDirectory => getAbsoluteProjectPath(rootDirectory, host, options.project)); - forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectories(host, options, absoluteRoot, span, result)); + forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectories(host, options, absoluteRoot, result)); } if (host.getDirectories) { // Also get all @types typings installed in visible node_modules directories forEach(findPackageJsons(scriptPath), package => { const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, span, result); + getCompletionEntriesFromDirectories(host, options, typesDir, result); }); } @@ -4839,10 +4847,10 @@ namespace ts { return normalizePath(host.resolvePath(path)); } - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, span: TextSpan, result: ImportCompletionEntry[]) { + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: ImportCompletionEntry[]) { if (host.getDirectories && directoryProbablyExists(directory, host)) { forEach(host.getDirectories(directory), typeDirectory => { - result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); + result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName)); }); } } @@ -4911,10 +4919,10 @@ namespace ts { } } + // Add all the package names that are not in the @types scope function addPotentialPackageNames(dependencies: any, result: string[]) { for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types") && - dep.charCodeAt(6) !== CharacterCodes.slash && dep.charCodeAt(6) !== CharacterCodes.backslash) { + if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { result.push(dep); } } @@ -4946,8 +4954,8 @@ namespace ts { } } - function createCompletionEntryForModule(name: string, kind: string, span: TextSpan): ImportCompletionEntry { - return { name, kind, sortText: name, span }; + function createCompletionEntryForModule(name: string, kind: string): ImportCompletionEntry { + return { name, kind, sortText: name }; } // Replace everything after the last directory seperator that appears @@ -4955,7 +4963,7 @@ namespace ts { function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { const index = text.lastIndexOf(directorySeparator); const offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset } + return { start: textStart + offset, length: text.length - offset }; } // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) diff --git a/src/services/shims.ts b/src/services/shims.ts index eb6c5e55b7b..9f4d9d24a43 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -874,7 +874,7 @@ namespace ts { getImportModuleCompletionsAtPosition(fileName: string, position: number): string { return this.forwardJSONCall( `getImportModuleCompletionsAtPosition('${fileName}', ${position})`, - () => this.languageService.getCompletionsAtPosition(fileName, position) + () => this.languageService.getImportModuleCompletionsAtPosition(fileName, position) ); } From 359c8b12ef3a8339940edd9203dcb2a10c08615b Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 3 Aug 2016 07:12:10 -0700 Subject: [PATCH 062/508] Don't allow ".d.ts" extension in an import either. --- src/compiler/checker.ts | 8 ++-- src/compiler/core.ts | 3 +- src/compiler/diagnosticMessages.json | 2 +- src/compiler/program.ts | 16 ++------ src/compiler/utilities.ts | 6 ++- src/harness/compilerRunner.ts | 2 +- .../reference/moduleResolutionNoTs.errors.txt | 40 +++++++++++-------- .../reference/moduleResolutionNoTs.js | 11 ++--- tests/cases/compiler/moduleResolutionNoTs.ts | 9 +++-- 9 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 290fa257daf..6dd2747e33f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1366,10 +1366,10 @@ namespace ts { if (moduleNotFoundError) { // report errors only if it was requested - const nonDtsExtension = tryExtractTypeScriptExtensionNonDts(moduleName); - if (nonDtsExtension) { - const diag = Diagnostics.An_import_path_should_not_end_with_a_0_extension_Consider_importing_1_instead; - error(moduleReferenceLiteral, diag, nonDtsExtension, removeExtension(moduleName, nonDtsExtension)); + const tsExtension = tryExtractTypeScriptExtension(moduleName); + if (tsExtension) { + const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + error(moduleReferenceLiteral, diag, tsExtension, removeExtension(moduleName, tsExtension)); } else { error(moduleReferenceLiteral, moduleNotFoundError, moduleName); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d77036660b0..869cddb2d4d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1198,8 +1198,7 @@ namespace ts { /** * List of supported extensions in order of file resolution precedence. */ - export const supportedTypeScriptExtensionsNonDts = [".ts", ".tsx"]; - export const supportedTypeScriptExtensions = supportedTypeScriptExtensionsNonDts.concat([".d.ts"]); + export const supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"]; export const supportedJavascriptExtensions = [".js", ".jsx"]; const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 93bd6c608f0..8975e5daa04 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1951,7 +1951,7 @@ "category": "Error", "code": 2690 }, - "An import path should not end with a '{0}' extension. Consider importing '{1}' instead.": { + "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead.": { "category": "Error", "code": 2691 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a2674d79783..d35ce644120 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -669,17 +669,7 @@ namespace ts { * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ function loadModuleFromFile(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string | undefined { - // If the candidate already has an extension load that or quit. - if (hasTypeScriptFileExtension(candidate)) { - // Don't allow `.ts` to appear at the end - if (!fileExtensionIs(candidate, ".d.ts")) { - return undefined; - } - return tryFile(candidate, failedLookupLocation, onlyRecordFailures, state); - } - - // Next, try adding an extension. - // We don't allow an import of "foo.ts" to be matched by "foo.ts.ts", but we do allow "foo.js" to be matched by "foo.js.ts". + // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); if (resolvedByAddingExtension) { return resolvedByAddingExtension; @@ -736,7 +726,9 @@ namespace ts { } const typesFile = tryReadTypesSection(packageJsonPath, candidate, state); if (typesFile) { - const result = loadModuleFromFile(typesFile, extensions, failedLookupLocation, !directoryProbablyExists(getDirectoryPath(typesFile), state.host), state); + const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(typesFile), state.host); + // The package.json "typings" property must specify the file with extension, so just try that exact filename. + const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state); if (result) { return result; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index b92037b7e5b..22c93550725 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2727,9 +2727,11 @@ namespace ts { } /** Return ".ts" or ".tsx" if that is the extension. */ - export function tryExtractTypeScriptExtensionNonDts(fileName: string): string | undefined { - return find(supportedTypeScriptExtensionsNonDts, extension => fileExtensionIs(fileName, extension)); + export function tryExtractTypeScriptExtension(fileName: string): string | undefined { + return find(supportedTypescriptExtensionsWithDtsFirst, extension => fileExtensionIs(fileName, extension)); } + // Must have '.d.ts' first because if '.ts' goes first, that will be detected as the extension instead of '.d.ts'. + const supportedTypescriptExtensionsWithDtsFirst = supportedTypeScriptExtensions.slice().reverse(); /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index ecdc18394b0..b8467adda5c 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -52,7 +52,7 @@ class CompilerBaselineRunner extends RunnerBase { private makeUnitName(name: string, root: string) { const path = ts.toPath(name, root, (fileName) => Harness.Compiler.getCanonicalFileName(fileName)); const pathStart = ts.toPath(Harness.IO.getCurrentDirectory(), "", (fileName) => Harness.Compiler.getCanonicalFileName(fileName)); - return path.replace(pathStart, "/"); + return pathStart === "" ? path : path.replace(pathStart, "/"); }; public checkTestCodeOutput(fileName: string) { diff --git a/tests/baselines/reference/moduleResolutionNoTs.errors.txt b/tests/baselines/reference/moduleResolutionNoTs.errors.txt index 2a9b74a1af6..c0543307311 100644 --- a/tests/baselines/reference/moduleResolutionNoTs.errors.txt +++ b/tests/baselines/reference/moduleResolutionNoTs.errors.txt @@ -1,25 +1,31 @@ -tests/cases/compiler/user.ts(4,15): error TS2691: An import path should not end with a '.ts' extension. Consider importing './x' instead. -tests/cases/compiler/user.ts(5,15): error TS2691: An import path should not end with a '.tsx' extension. Consider importing './y' instead. +tests/cases/compiler/user.ts(1,15): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x' instead. +tests/cases/compiler/user.ts(2,15): error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './y' instead. +tests/cases/compiler/user.ts(3,15): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './z' instead. -==== tests/cases/compiler/user.ts (2 errors) ==== - // '.ts' extension is OK in a reference - /// - - import x from "./x.ts"; - ~~~~~~~~ -!!! error TS2691: An import path should not end with a '.ts' extension. Consider importing './x' instead. - import y from "./y.tsx"; - ~~~~~~~~~ -!!! error TS2691: An import path should not end with a '.tsx' extension. Consider importing './y' instead. - - // Making sure the suggested fixes are valid: - import x2 from "./x"; - import y2 from "./y"; - ==== tests/cases/compiler/x.ts (0 errors) ==== export default 0; ==== tests/cases/compiler/y.tsx (0 errors) ==== export default 0; + +==== tests/cases/compiler/z.d.ts (0 errors) ==== + declare const x: number; + export default x; + +==== tests/cases/compiler/user.ts (3 errors) ==== + import x from "./x.ts"; + ~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x' instead. + import y from "./y.tsx"; + ~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './y' instead. + import z from "./z.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './z' instead. + + // Making sure the suggested fixes are valid: + import x2 from "./x"; + import y2 from "./y"; + import z2 from "./z"; \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionNoTs.js b/tests/baselines/reference/moduleResolutionNoTs.js index d9d918f5600..9ff33d688ea 100644 --- a/tests/baselines/reference/moduleResolutionNoTs.js +++ b/tests/baselines/reference/moduleResolutionNoTs.js @@ -6,16 +6,19 @@ export default 0; //// [y.tsx] export default 0; +//// [z.d.ts] +declare const x: number; +export default x; + //// [user.ts] -// '.ts' extension is OK in a reference -/// - import x from "./x.ts"; import y from "./y.tsx"; +import z from "./z.d.ts"; // Making sure the suggested fixes are valid: import x2 from "./x"; import y2 from "./y"; +import z2 from "./z"; //// [x.js] @@ -27,6 +30,4 @@ exports["default"] = 0; exports.__esModule = true; exports["default"] = 0; //// [user.js] -// '.ts' extension is OK in a reference -/// "use strict"; diff --git a/tests/cases/compiler/moduleResolutionNoTs.ts b/tests/cases/compiler/moduleResolutionNoTs.ts index 683f6630d9f..2051bc259bf 100644 --- a/tests/cases/compiler/moduleResolutionNoTs.ts +++ b/tests/cases/compiler/moduleResolutionNoTs.ts @@ -4,13 +4,16 @@ export default 0; // @filename: y.tsx export default 0; -// @filename: user.ts -// '.ts' extension is OK in a reference -/// +// @filename: z.d.ts +declare const x: number; +export default x; +// @filename: user.ts import x from "./x.ts"; import y from "./y.tsx"; +import z from "./z.d.ts"; // Making sure the suggested fixes are valid: import x2 from "./x"; import y2 from "./y"; +import z2 from "./z"; From 204f2c16c0d6ff851e4798c03a9646b625ac2bd7 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 3 Aug 2016 08:55:55 -0700 Subject: [PATCH 063/508] Add a helper function `getOrUpdateProperty` to prevent unprotected access to Maps. --- src/compiler/core.ts | 10 +++++++--- src/compiler/emitter.ts | 2 +- tests/baselines/reference/exportToString.js | 9 +++++++++ tests/baselines/reference/exportToString.symbols | 7 +++++++ tests/baselines/reference/exportToString.types | 8 ++++++++ tests/cases/compiler/exportToString.ts | 2 ++ 6 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/exportToString.js create mode 100644 tests/baselines/reference/exportToString.symbols create mode 100644 tests/baselines/reference/exportToString.types create mode 100644 tests/cases/compiler/exportToString.ts diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 709a331e022..6c87ad82955 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -323,8 +323,12 @@ namespace ts { return keys; } - export function getProperty(map: Map, key: string): T { - return hasOwnProperty.call(map, key) ? map[key] : undefined; + export function getProperty(map: Map, key: string): T | undefined { + return hasProperty(map, key) ? map[key] : undefined; + } + + export function getOrUpdateProperty(map: Map, key: string, makeValue: () => T): T { + return hasProperty(map, key) ? map[key] : map[key] = makeValue(); } export function isEmpty(map: Map) { @@ -941,7 +945,7 @@ namespace ts { * [^./] # matches everything up to the first . character (excluding directory seperators) * (\\.(?!min\\.js$))? # matches . characters but not if they are part of the .min.js file extension */ - const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; + const singleAsteriskRegexFragmentFiles = "([^./]|(\\.(?!min\\.js$))?)*"; const singleAsteriskRegexFragmentOther = "[^/]*"; export function getRegularExpressionForWildcard(specs: string[], basePath: string, usage: "files" | "directories" | "exclude") { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5fe5027978c..c8bd8072b24 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6842,7 +6842,7 @@ const _super = (function (geti, seti) { // export { x, y } for (const specifier of (node).exportClause.elements) { const name = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier); + getOrUpdateProperty(exportSpecifiers, name, () => []).push(specifier); } } break; diff --git a/tests/baselines/reference/exportToString.js b/tests/baselines/reference/exportToString.js new file mode 100644 index 00000000000..190d1693c24 --- /dev/null +++ b/tests/baselines/reference/exportToString.js @@ -0,0 +1,9 @@ +//// [exportToString.ts] +const toString = 0; +export { toString }; + + +//// [exportToString.js] +"use strict"; +var toString = 0; +exports.toString = toString; diff --git a/tests/baselines/reference/exportToString.symbols b/tests/baselines/reference/exportToString.symbols new file mode 100644 index 00000000000..ce5446317a4 --- /dev/null +++ b/tests/baselines/reference/exportToString.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/exportToString.ts === +const toString = 0; +>toString : Symbol(toString, Decl(exportToString.ts, 0, 5)) + +export { toString }; +>toString : Symbol(toString, Decl(exportToString.ts, 1, 8)) + diff --git a/tests/baselines/reference/exportToString.types b/tests/baselines/reference/exportToString.types new file mode 100644 index 00000000000..17037852f3b --- /dev/null +++ b/tests/baselines/reference/exportToString.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/exportToString.ts === +const toString = 0; +>toString : number +>0 : number + +export { toString }; +>toString : number + diff --git a/tests/cases/compiler/exportToString.ts b/tests/cases/compiler/exportToString.ts new file mode 100644 index 00000000000..248df036bfd --- /dev/null +++ b/tests/cases/compiler/exportToString.ts @@ -0,0 +1,2 @@ +const toString = 0; +export { toString }; From 7ab6e11aaf5a3c98592555889e34ec4301cd0339 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 3 Aug 2016 10:00:37 -0700 Subject: [PATCH 064/508] Limit type guards as assertions to incomplete types in loops --- src/compiler/checker.ts | 74 +++++++++++++++++++++++++---------------- src/compiler/types.ts | 10 ++++++ 2 files changed, 56 insertions(+), 28 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0a45b61660a..69c93a75323 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -215,7 +215,7 @@ namespace ts { const flowLoopKeys: string[] = []; const flowLoopTypes: Type[][] = []; const visitedFlowNodes: FlowNode[] = []; - const visitedFlowTypes: Type[] = []; + const visitedFlowTypes: FlowType[] = []; const potentialThisCollisions: Node[] = []; const awaitedTypeStack: number[] = []; @@ -8086,6 +8086,18 @@ namespace ts { f(type) ? type : neverType; } + function isIncomplete(flowType: FlowType) { + return flowType.flags === 0; + } + + function getTypeFromFlowType(flowType: FlowType) { + return flowType.flags === 0 ? (flowType).type : flowType; + } + + function createFlowType(type: Type, incomplete: boolean): FlowType { + return incomplete ? { flags: 0, type } : type; + } + function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, includeOuterFunctions: boolean) { let key: string; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) { @@ -8093,14 +8105,14 @@ namespace ts { } const initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, TypeFlags.Undefined); const visitedFlowStart = visitedFlowCount; - const result = getTypeAtFlowNode(reference.flowNode); + const result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(result, TypeFacts.NEUndefinedOrNull) === neverType) { return declaredType; } return result; - function getTypeAtFlowNode(flow: FlowNode): Type { + function getTypeAtFlowNode(flow: FlowNode): FlowType { while (true) { if (flow.flags & FlowFlags.Shared) { // We cache results of flow type resolution for shared nodes that were previously visited in @@ -8112,7 +8124,7 @@ namespace ts { } } } - let type: Type; + let type: FlowType; if (flow.flags & FlowFlags.Assignment) { type = getTypeAtFlowAssignment(flow); if (!type) { @@ -8180,41 +8192,44 @@ namespace ts { return undefined; } - function getTypeAtFlowCondition(flow: FlowCondition) { - let type = getTypeAtFlowNode(flow.antecedent); + function getTypeAtFlowCondition(flow: FlowCondition): FlowType { + const flowType = getTypeAtFlowNode(flow.antecedent); + let type = getTypeFromFlowType(flowType); if (type !== neverType) { // If we have an antecedent type (meaning we're reachable in some way), we first - // attempt to narrow the antecedent type. If that produces the nothing type, then - // we take the type guard as an indication that control could reach here in a - // manner not understood by the control flow analyzer (e.g. a function argument - // has an invalid type, or a nested function has possibly made an assignment to a - // captured variable). We proceed by reverting to the declared type and then + // attempt to narrow the antecedent type. If that produces the never type, and if + // the antecedent type is incomplete (i.e. a transient type in a loop), then we + // take the type guard as an indication that control *could* reach here once we + // have the complete type. We proceed by reverting to the declared type and then // narrow that. const assumeTrue = (flow.flags & FlowFlags.TrueCondition) !== 0; type = narrowType(type, flow.expression, assumeTrue); - if (type === neverType) { + if (type === neverType && isIncomplete(flowType)) { type = narrowType(declaredType, flow.expression, assumeTrue); } } - return type; + return createFlowType(type, isIncomplete(flowType)); } - function getTypeAtSwitchClause(flow: FlowSwitchClause) { - const type = getTypeAtFlowNode(flow.antecedent); + function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType { + const flowType = getTypeAtFlowNode(flow.antecedent); + let type = getTypeFromFlowType(flowType); const expr = flow.switchStatement.expression; if (isMatchingReference(reference, expr)) { - return narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); + type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - if (isMatchingPropertyAccess(expr)) { - return narrowTypeByDiscriminant(type, expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); + else if (isMatchingPropertyAccess(expr)) { + type = narrowTypeByDiscriminant(type, expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); } - return type; + return createFlowType(type, isIncomplete(flowType)); } - function getTypeAtFlowBranchLabel(flow: FlowLabel) { + function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType { const antecedentTypes: Type[] = []; + let seenIncomplete = false; for (const antecedent of flow.antecedents) { - const type = getTypeAtFlowNode(antecedent); + const flowType = getTypeAtFlowNode(antecedent); + const type = getTypeFromFlowType(flowType); // If the type at a particular antecedent path is the declared type and the // reference is known to always be assigned (i.e. when declared and initial types // are the same), there is no reason to process more antecedents since the only @@ -8225,11 +8240,14 @@ namespace ts { if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); } + if (isIncomplete(flowType)) { + seenIncomplete = true; + } } - return getUnionType(antecedentTypes); + return createFlowType(getUnionType(antecedentTypes), seenIncomplete); } - function getTypeAtFlowLoopLabel(flow: FlowLabel) { + function getTypeAtFlowLoopLabel(flow: FlowLabel): FlowType { // If we have previously computed the control flow type for the reference at // this flow loop junction, return the cached type. const id = getFlowNodeId(flow); @@ -8241,12 +8259,12 @@ namespace ts { return cache[key]; } // If this flow loop junction and reference are already being processed, return - // the union of the types computed for each branch so far. We should never see - // an empty array here because the first antecedent of a loop junction is always - // the non-looping control flow path that leads to the top. + // the union of the types computed for each branch so far, marked as incomplete. + // We should never see an empty array here because the first antecedent of a loop + // junction is always the non-looping control flow path that leads to the top. for (let i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return getUnionType(flowLoopTypes[i]); + return createFlowType(getUnionType(flowLoopTypes[i]), true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -8257,7 +8275,7 @@ namespace ts { flowLoopTypes[flowLoopCount] = antecedentTypes; for (const antecedent of flow.antecedents) { flowLoopCount++; - const type = getTypeAtFlowNode(antecedent); + const type = getTypeFromFlowType(getTypeAtFlowNode(antecedent)); flowLoopCount--; // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 072209aa496..b9de9ce1635 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1606,6 +1606,16 @@ namespace ts { antecedent: FlowNode; } + export type FlowType = Type | IncompleteType; + + // Incomplete types occur during control flow analysis of loops. An IncompleteType + // is distinguished from a regular type by a flags value of zero. Incomplete type + // objects are internal to the getFlowTypeOfRefecence function and never escape it. + export interface IncompleteType { + flags: TypeFlags; // No flags set + type: Type; // The type marked incomplete + } + export interface AmdDependency { path: string; name: string; From 917d18a1ca1b490f1d022aba0a736d23d0e0e07b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 3 Aug 2016 10:05:49 -0700 Subject: [PATCH 065/508] Accept new baselines --- .../reference/stringLiteralTypesAndTuples01.types | 2 +- .../typeGuardTautologicalConsistiency.types | 4 ++-- .../reference/typeGuardTypeOfUndefined.types | 6 +++--- .../baselines/reference/typeGuardsAsAssertions.types | 12 ++++++------ .../reference/typeGuardsInIfStatement.errors.txt | 5 ++++- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.types b/tests/baselines/reference/stringLiteralTypesAndTuples01.types index 0900d9fc745..10a30a6d75c 100644 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.types +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.types @@ -55,5 +55,5 @@ function rawr(dino: RexOrRaptor) { throw "Unexpected " + dino; >"Unexpected " + dino : string >"Unexpected " : string ->dino : "t-rex" +>dino : never } diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.types b/tests/baselines/reference/typeGuardTautologicalConsistiency.types index f86a9e66fa2..0a6524dd26f 100644 --- a/tests/baselines/reference/typeGuardTautologicalConsistiency.types +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.types @@ -15,7 +15,7 @@ if (typeof stringOrNumber === "number") { >"number" : "number" stringOrNumber; ->stringOrNumber : string +>stringOrNumber : never } } @@ -31,6 +31,6 @@ if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { >"number" : "number" stringOrNumber; ->stringOrNumber : string +>stringOrNumber : never } diff --git a/tests/baselines/reference/typeGuardTypeOfUndefined.types b/tests/baselines/reference/typeGuardTypeOfUndefined.types index 8e9928896a1..520d045d9e0 100644 --- a/tests/baselines/reference/typeGuardTypeOfUndefined.types +++ b/tests/baselines/reference/typeGuardTypeOfUndefined.types @@ -47,7 +47,7 @@ function test2(a: any) { >"boolean" : "boolean" a; ->a : boolean +>a : never } else { a; @@ -129,7 +129,7 @@ function test5(a: boolean | void) { } else { a; ->a : void +>a : never } } else { @@ -188,7 +188,7 @@ function test7(a: boolean | void) { } else { a; ->a : void +>a : never } } diff --git a/tests/baselines/reference/typeGuardsAsAssertions.types b/tests/baselines/reference/typeGuardsAsAssertions.types index 34d3b296a48..661ce9fbc55 100644 --- a/tests/baselines/reference/typeGuardsAsAssertions.types +++ b/tests/baselines/reference/typeGuardsAsAssertions.types @@ -193,10 +193,10 @@ function f1() { >x : undefined x; // string | number (guard as assertion) ->x : string | number +>x : never } x; // string | number | undefined ->x : string | number | undefined +>x : undefined } function f2() { @@ -216,10 +216,10 @@ function f2() { >"string" : "string" x; // string (guard as assertion) ->x : string +>x : never } x; // string | undefined ->x : string | undefined +>x : undefined } function f3() { @@ -239,7 +239,7 @@ function f3() { return; } x; // string | number (guard as assertion) ->x : string | number +>x : never } function f4() { @@ -281,7 +281,7 @@ function f5(x: string | number) { >"number" : "number" x; // number (guard as assertion) ->x : number +>x : never } else { x; // string | number diff --git a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt index 984ca454e76..cd9ae40932a 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt +++ b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt @@ -1,9 +1,10 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(22,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(31,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(49,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,17): error TS2339: Property 'toString' does not exist on type 'never'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (3 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (4 errors) ==== // In the true branch statement of an 'if' statement, // the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true. // In the false branch statement of an 'if' statement, @@ -149,5 +150,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(49,10) return typeof x === "number" ? x.toString() // number : x.toString(); // boolean | string + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. } } \ No newline at end of file From 12eb57c4d0d9b1082e8f4e7b459685e5829bac78 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 3 Aug 2016 10:15:00 -0700 Subject: [PATCH 066/508] Fix linting error --- 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 69c93a75323..4e5da63af2f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8264,7 +8264,7 @@ namespace ts { // junction is always the non-looping control flow path that leads to the top. for (let i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return createFlowType(getUnionType(flowLoopTypes[i]), true); + return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze From 8c01efba04a3ee3a1fa0aec6658afb5884b9e3a4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 3 Aug 2016 10:33:10 -0700 Subject: [PATCH 067/508] Allow JS multiple declarations of ctor properties When a property is declared in the constructor and on the prototype of an ES6 class, the property's symbol is discarded in favour of the method's symbol. That because the usual use for this pattern is to bind an instance function: `this.m = this.m.bind(this)`. In this case the type you want really is the method's type. --- src/compiler/binder.ts | 60 +++++++++++-------- src/compiler/types.ts | 1 + .../reference/multipleDeclarations.js | 32 +++++++++- .../reference/multipleDeclarations.symbols | 47 ++++++++++++++- .../reference/multipleDeclarations.types | 57 +++++++++++++++++- .../conformance/salsa/multipleDeclarations.ts | 17 +++++- 6 files changed, 184 insertions(+), 30 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 8d8666a67ab..6f0def32702 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -298,8 +298,10 @@ namespace ts { const name = isDefaultExport && parent ? "default" : getDeclarationName(node); let symbol: Symbol; - if (name !== undefined) { - + if (name === undefined) { + symbol = createSymbol(SymbolFlags.None, "__missing"); + } + else { // Check and see if the symbol table already has a symbol with this name. If not, // create a new symbol with this name and add it to the table. Note that we don't // give the new symbol any flags *yet*. This ensures that it will not conflict @@ -326,34 +328,38 @@ namespace ts { classifiableNames[name] = name; } - if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; + else if (symbol.flags & excludes) { + if (symbol.isDiscardable) { + // Javascript constructor-declared symbols can be discarded in favor of + // prototype symbols like methods. + symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name); } - - // Report errors every position with duplicate declaration - // Report errors on previous encountered declarations - let message = symbol.flags & SymbolFlags.BlockScopedVariable - ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : Diagnostics.Duplicate_identifier_0; - - forEach(symbol.declarations, declaration => { - if (declaration.flags & NodeFlags.Default) { - message = Diagnostics.A_module_cannot_have_multiple_default_exports; + else { + if (node.name) { + node.name.parent = node; } - }); - forEach(symbol.declarations, declaration => { - file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + // Report errors every position with duplicate declaration + // Report errors on previous encountered declarations + let message = symbol.flags & SymbolFlags.BlockScopedVariable + ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : Diagnostics.Duplicate_identifier_0; - symbol = createSymbol(SymbolFlags.None, name); + forEach(symbol.declarations, declaration => { + if (declaration.flags & NodeFlags.Default) { + message = Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); + + forEach(symbol.declarations, declaration => { + file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + + symbol = createSymbol(SymbolFlags.None, name); + } } } - else { - symbol = createSymbol(SymbolFlags.None, "__missing"); - } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; @@ -1967,7 +1973,7 @@ namespace ts { } function bindThisPropertyAssignment(node: BinaryExpression) { - // Declare a 'member' in case it turns out the container was an ES5 class or ES6 constructor + // Declare a 'member' if the container is an ES5 class or ES6 constructor let assignee: Node; if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) { assignee = container; @@ -1980,7 +1986,9 @@ namespace ts { } assignee.symbol.members = assignee.symbol.members || {}; // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); + // AND it can be overwritten by subsequent method declarations + let symbol = declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); + symbol.isDiscardable = true; } function bindPrototypePropertyAssignment(node: BinaryExpression) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 072209aa496..4c08d7a487c 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2137,6 +2137,7 @@ namespace ts { /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums /* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere + /* @internal */ isDiscardable?: boolean;// True if a Javascript class property can be overwritten by a method } /* @internal */ diff --git a/tests/baselines/reference/multipleDeclarations.js b/tests/baselines/reference/multipleDeclarations.js index 5f5ac29e909..e5aae416663 100644 --- a/tests/baselines/reference/multipleDeclarations.js +++ b/tests/baselines/reference/multipleDeclarations.js @@ -5,7 +5,22 @@ function C() { } C.prototype.m = function() { this.nothing(); -}; +} + +class X { + constructor() { + this.m = this.m.bind(this); + this.mistake = 'frankly, complete nonsense'; + } + m() { + } + mistake() { + } +} +let x = new X(); +X.prototype.mistake = false; +x.m(); +x.mistake; //// [output.js] @@ -15,3 +30,18 @@ function C() { C.prototype.m = function () { this.nothing(); }; +var X = (function () { + function X() { + this.m = this.m.bind(this); + this.mistake = 'frankly, complete nonsense'; + } + X.prototype.m = function () { + }; + X.prototype.mistake = function () { + }; + return X; +}()); +var x = new X(); +X.prototype.mistake = false; +x.m(); +x.mistake; diff --git a/tests/baselines/reference/multipleDeclarations.symbols b/tests/baselines/reference/multipleDeclarations.symbols index a256943dd50..7e4bcd53c8a 100644 --- a/tests/baselines/reference/multipleDeclarations.symbols +++ b/tests/baselines/reference/multipleDeclarations.symbols @@ -14,6 +14,51 @@ C.prototype.m = function() { this.nothing(); >this : Symbol(C, Decl(input.js, 0, 0)) +} -}; +class X { +>X : Symbol(X, Decl(input.js, 6, 1)) + + constructor() { + this.m = this.m.bind(this); +>this.m : Symbol(X.m, Decl(input.js, 12, 5)) +>this : Symbol(X, Decl(input.js, 6, 1)) +>m : Symbol(X.m, Decl(input.js, 9, 19)) +>this.m.bind : Symbol(Function.bind, Decl(lib.d.ts, --, --)) +>this.m : Symbol(X.m, Decl(input.js, 12, 5)) +>this : Symbol(X, Decl(input.js, 6, 1)) +>m : Symbol(X.m, Decl(input.js, 12, 5)) +>bind : Symbol(Function.bind, Decl(lib.d.ts, --, --)) +>this : Symbol(X, Decl(input.js, 6, 1)) + + this.mistake = 'frankly, complete nonsense'; +>this.mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) +>this : Symbol(X, Decl(input.js, 6, 1)) +>mistake : Symbol(X.mistake, Decl(input.js, 10, 35)) + } + m() { +>m : Symbol(X.m, Decl(input.js, 12, 5)) + } + mistake() { +>mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) + } +} +let x = new X(); +>x : Symbol(x, Decl(input.js, 18, 3)) +>X : Symbol(X, Decl(input.js, 6, 1)) + +X.prototype.mistake = false; +>X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) +>X : Symbol(X, Decl(input.js, 6, 1)) +>prototype : Symbol(X.prototype) + +x.m(); +>x.m : Symbol(X.m, Decl(input.js, 12, 5)) +>x : Symbol(x, Decl(input.js, 18, 3)) +>m : Symbol(X.m, Decl(input.js, 12, 5)) + +x.mistake; +>x.mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) +>x : Symbol(x, Decl(input.js, 18, 3)) +>mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) diff --git a/tests/baselines/reference/multipleDeclarations.types b/tests/baselines/reference/multipleDeclarations.types index 7c0a3de70c9..2a7cac18205 100644 --- a/tests/baselines/reference/multipleDeclarations.types +++ b/tests/baselines/reference/multipleDeclarations.types @@ -24,6 +24,61 @@ C.prototype.m = function() { >this.nothing : any >this : { m: () => void; } >nothing : any +} -}; +class X { +>X : X + + constructor() { + this.m = this.m.bind(this); +>this.m = this.m.bind(this) : any +>this.m : () => void +>this : this +>m : () => void +>this.m.bind(this) : any +>this.m.bind : (this: Function, thisArg: any, ...argArray: any[]) => any +>this.m : () => void +>this : this +>m : () => void +>bind : (this: Function, thisArg: any, ...argArray: any[]) => any +>this : this + + this.mistake = 'frankly, complete nonsense'; +>this.mistake = 'frankly, complete nonsense' : string +>this.mistake : () => void +>this : this +>mistake : () => void +>'frankly, complete nonsense' : string + } + m() { +>m : () => void + } + mistake() { +>mistake : () => void + } +} +let x = new X(); +>x : X +>new X() : X +>X : typeof X + +X.prototype.mistake = false; +>X.prototype.mistake = false : boolean +>X.prototype.mistake : () => void +>X.prototype : X +>X : typeof X +>prototype : X +>mistake : () => void +>false : boolean + +x.m(); +>x.m() : void +>x.m : () => void +>x : X +>m : () => void + +x.mistake; +>x.mistake : () => void +>x : X +>mistake : () => void diff --git a/tests/cases/conformance/salsa/multipleDeclarations.ts b/tests/cases/conformance/salsa/multipleDeclarations.ts index 6899be2ec89..9ead1eeb0a5 100644 --- a/tests/cases/conformance/salsa/multipleDeclarations.ts +++ b/tests/cases/conformance/salsa/multipleDeclarations.ts @@ -7,4 +7,19 @@ function C() { } C.prototype.m = function() { this.nothing(); -}; +} + +class X { + constructor() { + this.m = this.m.bind(this); + this.mistake = 'frankly, complete nonsense'; + } + m() { + } + mistake() { + } +} +let x = new X(); +X.prototype.mistake = false; +x.m(); +x.mistake; From 293ca60ffd224f8c4a2d4c9c17426b54adee8b1f Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 3 Aug 2016 11:07:57 -0700 Subject: [PATCH 068/508] Renamed span to textSpan to better follow other language service APIs --- src/harness/fourslash.ts | 6 +++--- src/server/client.ts | 2 +- src/services/services.ts | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 532dccd4f6b..be8f1877c8f 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -779,10 +779,10 @@ namespace FourSlash { if (ranges && ranges.length > rangeIndex) { const range = ranges[rangeIndex]; - const start = completions.span.start; - const end = start + completions.span.length; + const start = completions.textSpan.start; + const end = start + completions.textSpan.length; if (range.start !== start || range.end !== end) { - this.raiseError(`Expected completion span for '${symbol}', ${stringify(completions.span)}, to cover range ${stringify(range)}`); + this.raiseError(`Expected completion span for '${symbol}', ${stringify(completions.textSpan)}, to cover range ${stringify(range)}`); } } else { diff --git a/src/server/client.ts b/src/server/client.ts index 03a370411d1..7af7be16f19 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -236,7 +236,7 @@ namespace ts.server { const endPosition = this.lineOffsetToPosition(fileName, response.span.end); return { - span: ts.createTextSpanFromBounds(startPosition, endPosition), + textSpan: ts.createTextSpanFromBounds(startPosition, endPosition), entries: response.body }; } diff --git a/src/services/services.ts b/src/services/services.ts index fd665908248..1ed91381469 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1482,7 +1482,7 @@ namespace ts { } export interface ImportCompletionInfo { - span: TextSpan; + textSpan: TextSpan; entries: ImportCompletionEntry[]; } @@ -4513,7 +4513,7 @@ namespace ts { // Get all known external module names or complete a path to a module return { entries: getStringLiteralCompletionEntriesFromModuleNames(node), - span: getDirectoryFragmentTextSpan((node).text, node.getStart() + 1) + textSpan: getDirectoryFragmentTextSpan((node).text, node.getStart() + 1) }; } } @@ -4793,18 +4793,18 @@ namespace ts { const scriptPath = getDirectoryPath(sourceFile.path); if (kind === "path") { // Give completions for a relative path - const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + const textSpan: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); return { entries: getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, sourceFile.path), - span + textSpan }; } else { // Give completions based on the typings available - const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + const textSpan: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; return { entries: getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath), - span + textSpan }; } } From 045b51a8ef0961b3c4420fb1d315e98bde77ece9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 3 Aug 2016 14:36:05 -0700 Subject: [PATCH 069/508] Use {} type facts for unconstrained type params Previously it was using TypeFacts.All. But the constraint of an unconstrained type parameter is actually {}. --- src/compiler/checker.ts | 33 +++++-------------- .../reference/controlFlowIfStatement.types | 2 +- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2d4ce970172..278d27a2347 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1187,7 +1187,7 @@ namespace ts { } function resolveSymbol(symbol: Symbol): Symbol { - return symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)) ? resolveAlias(symbol) : symbol; + return symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol: Symbol): Symbol { @@ -7892,7 +7892,7 @@ namespace ts { } if (flags & TypeFlags.TypeParameter) { const constraint = getConstraintOfTypeParameter(type); - return constraint ? getTypeFacts(constraint) : TypeFacts.All; + return getTypeFacts(constraint || emptyObjectType); } if (flags & TypeFlags.UnionOrIntersection) { return getTypeFactsOfTypes((type).types); @@ -7900,17 +7900,13 @@ namespace ts { return TypeFacts.All; } - function getTypeWithFacts(type: Type, include: TypeFacts, intersectForTypeParameters = false) { + function getTypeWithFacts(type: Type, include: TypeFacts) { if (!(type.flags & TypeFlags.Union)) { return getTypeFacts(type) & include ? type : neverType; } let firstType: Type; - let hasTypeParameter = false; let types: Type[]; for (const t of (type as UnionType).types) { - if (t.flags & TypeFlags.TypeParameter) { - hasTypeParameter = true; - } if (getTypeFacts(t) & include) { if (!firstType) { firstType = t; @@ -7923,19 +7919,8 @@ namespace ts { } } } - const narrowed = types ? getUnionType(types) : - firstType ? firstType : neverType; - // if there is a type parameter in the narrowed type, - // add an intersection with the members of the narrowed type so that the shape of the type is correct - if (type.flags & TypeFlags.Union && - narrowed.flags & TypeFlags.Union && - hasTypeParameter && - intersectForTypeParameters) { - return getIntersectionType(types.concat([narrowed])); - } - else { - return narrowed; - } + return types ? getUnionType(types) : + firstType ? firstType : neverType; } function getTypeWithDefault(type: Type, defaultExpression: Expression) { @@ -8308,10 +8293,10 @@ namespace ts { function narrowTypeByTruthiness(type: Type, expr: Expression, assumeTrue: boolean): Type { if (isMatchingReference(reference, expr)) { - return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy, assumeTrue); + return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy); } if (isMatchingPropertyAccess(expr)) { - return narrowTypeByDiscriminant(type, expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy, assumeTrue)); + return narrowTypeByDiscriminant(type, expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy)); } return type; } @@ -8369,7 +8354,7 @@ namespace ts { value.kind === SyntaxKind.NullKeyword ? assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull : assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; - return getTypeWithFacts(type, facts, assumeTrue); + return getTypeWithFacts(type, facts); } if (type.flags & TypeFlags.NotUnionOrUnit) { return type; @@ -8407,7 +8392,7 @@ namespace ts { const facts = assumeTrue ? getProperty(typeofEQFacts, literal.text) || TypeFacts.TypeofEQHostObject : getProperty(typeofNEFacts, literal.text) || TypeFacts.TypeofNEHostObject; - return getTypeWithFacts(type, facts, assumeTrue); + return getTypeWithFacts(type, facts); } function narrowTypeBySwitchOnDiscriminant(type: Type, switchStatement: SwitchStatement, clauseStart: number, clauseEnd: number) { diff --git a/tests/baselines/reference/controlFlowIfStatement.types b/tests/baselines/reference/controlFlowIfStatement.types index e706f9f6a4e..79985378bf5 100644 --- a/tests/baselines/reference/controlFlowIfStatement.types +++ b/tests/baselines/reference/controlFlowIfStatement.types @@ -108,7 +108,7 @@ function c(data: string | T): T { >JSON.parse : (text: string, reviver?: (key: any, value: any) => any) => any >JSON : JSON >parse : (text: string, reviver?: (key: any, value: any) => any) => any ->data : string & T & (string | T) +>data : string } else { return data; From 38ee13cc3215b09ccee398283c936c59a7d8723c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 3 Aug 2016 14:38:05 -0700 Subject: [PATCH 070/508] Fix newline lint --- 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 278d27a2347..5e9fb856823 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1187,7 +1187,7 @@ namespace ts { } function resolveSymbol(symbol: Symbol): Symbol { - return symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)) ? resolveAlias(symbol) : symbol; + return symbol && symbol.flags & SymbolFlags.Alias && !(symbol.flags & (SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace)) ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol: Symbol): Symbol { From 72057500b5220b28e637a6a31acb86f4f4273393 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 3 Aug 2016 16:10:14 -0700 Subject: [PATCH 071/508] Test that declares conflicting method first --- .../conformance/salsa/multipleDeclarations.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/cases/conformance/salsa/multipleDeclarations.ts b/tests/cases/conformance/salsa/multipleDeclarations.ts index 9ead1eeb0a5..ba2e14e11e9 100644 --- a/tests/cases/conformance/salsa/multipleDeclarations.ts +++ b/tests/cases/conformance/salsa/multipleDeclarations.ts @@ -1,14 +1,12 @@ // @filename: input.js // @out: output.js // @allowJs: true - function C() { this.m = null; } C.prototype.m = function() { this.nothing(); } - class X { constructor() { this.m = this.m.bind(this); @@ -23,3 +21,17 @@ let x = new X(); X.prototype.mistake = false; x.m(); x.mistake; +class Y { + mistake() { + } + m() { + } + constructor() { + this.m = this.m.bind(this); + this.mistake = 'even more nonsense'; + } +} +Y.prototype.mistake = true; +let y = new Y(); +y.m(); +y.mistake(); From 10b36abc8f85c8a2610fd56f04c81836bcf393a4 Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 4 Aug 2016 07:43:54 -0700 Subject: [PATCH 072/508] [Release-2.0] Fix 9662: Visual Studio 2015 with TS2.0 gives incorrect @types path resolution errors (#9867) * Change the shape of the shim layer to support getAutomaticTypeDirectives * Change the key for looking up automatic type-directives * Update baselines from change look-up name of type-directives * Add @currentDirectory into the test * Update baselines * Fix linting error * Address PR: fix spelling mistake * Instead of return path of the type directive names just return type directive names --- src/compiler/program.ts | 19 +++++----- src/compiler/types.ts | 1 + src/services/services.ts | 2 +- src/services/shims.ts | 35 ++++++++++++++++--- .../reference/library-reference-13.trace.json | 2 +- .../reference/library-reference-14.trace.json | 2 +- .../reference/library-reference-15.trace.json | 2 +- .../reference/library-reference-2.trace.json | 2 +- .../reference/library-reference-6.trace.json | 2 +- .../reference/typeReferenceDirectives1.js | 1 - .../typeReferenceDirectives1.symbols | 3 +- .../reference/typeReferenceDirectives1.types | 1 - .../compiler/typeReferenceDirectives1.ts | 2 +- .../compiler/typeReferenceDirectives10.ts | 1 + .../compiler/typeReferenceDirectives11.ts | 1 + .../compiler/typeReferenceDirectives12.ts | 1 + .../compiler/typeReferenceDirectives13.ts | 1 + .../compiler/typeReferenceDirectives2.ts | 1 + .../compiler/typeReferenceDirectives3.ts | 1 + .../compiler/typeReferenceDirectives4.ts | 1 + .../compiler/typeReferenceDirectives5.ts | 1 + .../compiler/typeReferenceDirectives6.ts | 1 + .../compiler/typeReferenceDirectives7.ts | 1 + .../compiler/typeReferenceDirectives8.ts | 1 + .../compiler/typeReferenceDirectives9.ts | 1 + .../references/library-reference-13.ts | 1 + .../conformance/typings/typingsLookup1.ts | 1 + 27 files changed, 62 insertions(+), 26 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 4b9948c3ba0..7d40b2f3219 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1055,19 +1055,15 @@ namespace ts { return resolutions; } - function getInferredTypesRoot(options: CompilerOptions, rootFiles: string[], host: CompilerHost) { - return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f)); - } - /** - * Given a set of options and a set of root files, returns the set of type directive names + * Given a set of options, returns the set of type directive names * that should be included for this program automatically. * This list could either come from the config file, * or from enumerating the types root + initial secondary types lookup location. * More type directives might appear in the program later as a result of loading actual source files; * this list is only the set of defaults that are implicitly included. */ - export function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] { + export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] { // Use explicit type list from tsconfig.json if (options.types) { return options.types; @@ -1080,7 +1076,10 @@ namespace ts { if (typeRoots) { for (const root of typeRoots) { if (host.directoryExists(root)) { - result = result.concat(host.getDirectories(root)); + for (const typeDirectivePath of host.getDirectories(root)) { + // Return just the type directive names + result = result.concat(getBaseFileName(normalizePath(typeDirectivePath))); + } } } } @@ -1155,11 +1154,11 @@ namespace ts { forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false)); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, rootNames, host); + const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, host); if (typeReferences) { - const inferredRoot = getInferredTypesRoot(options, rootNames, host); - const containingFilename = combinePaths(inferredRoot, "__inferred type names__.ts"); + // This containingFilename needs to match with the one used in managed-side + const containingFilename = combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (let i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index b9de9ce1635..28ededebb0d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2910,6 +2910,7 @@ namespace ts { directoryExists?(directoryName: string): boolean; realpath?(path: string): string; getCurrentDirectory?(): string; + getDirectories?(path: string): string[]; } export interface ResolvedModule { diff --git a/src/services/services.ts b/src/services/services.ts index 6ec95343e33..ab1e30a44a6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1886,7 +1886,7 @@ namespace ts { }; } - // Cache host information about scrip Should be refreshed + // Cache host information about script should be refreshed // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. class HostCache { diff --git a/src/services/shims.ts b/src/services/shims.ts index 271d6f2d6e2..45c4b284ae7 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -72,8 +72,13 @@ namespace ts { directoryExists(directoryName: string): boolean; } - /** Public interface of the the of a config service shim instance.*/ - export interface CoreServicesShimHost extends Logger, ModuleResolutionHost { + /** Public interface of the core-services host instance used in managed side */ + export interface CoreServicesShimHost extends Logger { + directoryExists(directoryName: string): boolean; + fileExists(fileName: string): boolean; + getCurrentDirectory(): string; + getDirectories(path: string): string; + /** * Returns a JSON-encoded value of the type: string[] * @@ -81,9 +86,14 @@ namespace ts { * when enumerating the directory. */ readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - useCaseSensitiveFileNames?(): boolean; - getCurrentDirectory(): string; + + /** + * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules + */ + readFile(fileName: string): string; + realpath?(path: string): string; trace(s: string): void; + useCaseSensitiveFileNames?(): boolean; } /// @@ -240,6 +250,7 @@ namespace ts { } export interface CoreServicesShim extends Shim { + getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string; getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getDefaultCompilationSettings(): string; @@ -492,6 +503,10 @@ namespace ts { private readDirectoryFallback(rootDir: string, extension: string, exclude: string[]) { return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); } + + public getDirectories(path: string): string[] { + return JSON.parse(this.shimHost.getDirectories(path)); + } } function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): any { @@ -1003,7 +1018,7 @@ namespace ts { public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string { return this.forwardJSONCall( - "getPreProcessedFileInfo('" + fileName + "')", + `getPreProcessedFileInfo('${fileName}')`, () => { // for now treat files as JavaScript const result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); @@ -1017,6 +1032,16 @@ namespace ts { }); } + public getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string { + return this.forwardJSONCall( + `getAutomaticTypeDirectiveNames('${compilerOptionsJson}')`, + () => { + const compilerOptions = JSON.parse(compilerOptionsJson); + return getAutomaticTypeDirectiveNames(compilerOptions, this.host); + } + ); + } + private convertFileReferences(refs: FileReference[]): IFileReference[] { if (!refs) { return undefined; diff --git a/tests/baselines/reference/library-reference-13.trace.json b/tests/baselines/reference/library-reference-13.trace.json index d8dfb57c2a6..a23f0ef0ca5 100644 --- a/tests/baselines/reference/library-reference-13.trace.json +++ b/tests/baselines/reference/library-reference-13.trace.json @@ -1,5 +1,5 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/a/types'. ========", "Resolving with primary search path '/a/types'", "File '/a/types/jquery/package.json' does not exist.", "File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-14.trace.json b/tests/baselines/reference/library-reference-14.trace.json index d8dfb57c2a6..fb3a2bb7da4 100644 --- a/tests/baselines/reference/library-reference-14.trace.json +++ b/tests/baselines/reference/library-reference-14.trace.json @@ -1,5 +1,5 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========", + "======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========", "Resolving with primary search path '/a/types'", "File '/a/types/jquery/package.json' does not exist.", "File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-15.trace.json b/tests/baselines/reference/library-reference-15.trace.json index 3e9d7dba1d2..e23517976b0 100644 --- a/tests/baselines/reference/library-reference-15.trace.json +++ b/tests/baselines/reference/library-reference-15.trace.json @@ -1,5 +1,5 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory 'types'. ========", + "======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory 'types'. ========", "Resolving with primary search path 'types'", "File 'types/jquery/package.json' does not exist.", "File 'types/jquery/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-2.trace.json b/tests/baselines/reference/library-reference-2.trace.json index c26f7d2763d..64cdd809183 100644 --- a/tests/baselines/reference/library-reference-2.trace.json +++ b/tests/baselines/reference/library-reference-2.trace.json @@ -5,7 +5,7 @@ "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", "File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========", - "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/types'. ========", + "======== Resolving type reference directive 'jquery', containing file 'test/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'", "Found 'package.json' at '/types/jquery/package.json'.", "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", diff --git a/tests/baselines/reference/library-reference-6.trace.json b/tests/baselines/reference/library-reference-6.trace.json index 48fb49e6c7f..fd83c1431b4 100644 --- a/tests/baselines/reference/library-reference-6.trace.json +++ b/tests/baselines/reference/library-reference-6.trace.json @@ -4,7 +4,7 @@ "File '/node_modules/@types/alpha/package.json' does not exist.", "File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'alpha', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "======== Resolving type reference directive 'alpha', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'", "File '/node_modules/@types/alpha/package.json' does not exist.", "File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/typeReferenceDirectives1.js b/tests/baselines/reference/typeReferenceDirectives1.js index 775af9c5283..a6210819931 100644 --- a/tests/baselines/reference/typeReferenceDirectives1.js +++ b/tests/baselines/reference/typeReferenceDirectives1.js @@ -2,7 +2,6 @@ //// [index.d.ts] - interface $ { x } //// [app.ts] diff --git a/tests/baselines/reference/typeReferenceDirectives1.symbols b/tests/baselines/reference/typeReferenceDirectives1.symbols index 55c17b219ec..a33a2aba408 100644 --- a/tests/baselines/reference/typeReferenceDirectives1.symbols +++ b/tests/baselines/reference/typeReferenceDirectives1.symbols @@ -9,8 +9,7 @@ interface A { } === /types/lib/index.d.ts === - interface $ { x } >$ : Symbol($, Decl(index.d.ts, 0, 0)) ->x : Symbol($.x, Decl(index.d.ts, 2, 13)) +>x : Symbol($.x, Decl(index.d.ts, 1, 13)) diff --git a/tests/baselines/reference/typeReferenceDirectives1.types b/tests/baselines/reference/typeReferenceDirectives1.types index 05080e05651..be789a08ddc 100644 --- a/tests/baselines/reference/typeReferenceDirectives1.types +++ b/tests/baselines/reference/typeReferenceDirectives1.types @@ -9,7 +9,6 @@ interface A { } === /types/lib/index.d.ts === - interface $ { x } >$ : $ >x : any diff --git a/tests/cases/compiler/typeReferenceDirectives1.ts b/tests/cases/compiler/typeReferenceDirectives1.ts index e17e498b978..13c84c7ae5e 100644 --- a/tests/cases/compiler/typeReferenceDirectives1.ts +++ b/tests/cases/compiler/typeReferenceDirectives1.ts @@ -2,7 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types - +// @currentDirectory: / // @filename: /types/lib/index.d.ts interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives10.ts b/tests/cases/compiler/typeReferenceDirectives10.ts index 61971ba44b2..1eb796d03fd 100644 --- a/tests/cases/compiler/typeReferenceDirectives10.ts +++ b/tests/cases/compiler/typeReferenceDirectives10.ts @@ -2,6 +2,7 @@ // @declaration: true // @typeRoots: /types // @traceResolution: true +// @currentDirectory: / // @filename: /ref.d.ts export interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives11.ts b/tests/cases/compiler/typeReferenceDirectives11.ts index 2d93e22bdcf..8b56459cd69 100644 --- a/tests/cases/compiler/typeReferenceDirectives11.ts +++ b/tests/cases/compiler/typeReferenceDirectives11.ts @@ -4,6 +4,7 @@ // @traceResolution: true // @types: lib // @out: output.js +// @currentDirectory: / // @filename: /types/lib/index.d.ts diff --git a/tests/cases/compiler/typeReferenceDirectives12.ts b/tests/cases/compiler/typeReferenceDirectives12.ts index efdb1e8312b..f1abe27f05f 100644 --- a/tests/cases/compiler/typeReferenceDirectives12.ts +++ b/tests/cases/compiler/typeReferenceDirectives12.ts @@ -3,6 +3,7 @@ // @typeRoots: /types // @traceResolution: true // @out: output.js +// @currentDirectory: / // @filename: /types/lib/index.d.ts diff --git a/tests/cases/compiler/typeReferenceDirectives13.ts b/tests/cases/compiler/typeReferenceDirectives13.ts index 124c31274ac..f9dede73267 100644 --- a/tests/cases/compiler/typeReferenceDirectives13.ts +++ b/tests/cases/compiler/typeReferenceDirectives13.ts @@ -2,6 +2,7 @@ // @declaration: true // @typeRoots: /types // @traceResolution: true +// @currentDirectory: / // @filename: /ref.d.ts export interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives2.ts b/tests/cases/compiler/typeReferenceDirectives2.ts index 31a01a0b8e4..44218683a5a 100644 --- a/tests/cases/compiler/typeReferenceDirectives2.ts +++ b/tests/cases/compiler/typeReferenceDirectives2.ts @@ -3,6 +3,7 @@ // @declaration: true // @typeRoots: /types // @types: lib +// @currentDirectory: / // @filename: /types/lib/index.d.ts interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives3.ts b/tests/cases/compiler/typeReferenceDirectives3.ts index 4c2729ab389..1baf0bdac9d 100644 --- a/tests/cases/compiler/typeReferenceDirectives3.ts +++ b/tests/cases/compiler/typeReferenceDirectives3.ts @@ -2,6 +2,7 @@ // @declaration: true // @typeRoots: /types // @traceResolution: true +// @currentDirectory: / // $ comes from d.ts file - no need to add type reference directive diff --git a/tests/cases/compiler/typeReferenceDirectives4.ts b/tests/cases/compiler/typeReferenceDirectives4.ts index ac7346895ef..dfa87b65138 100644 --- a/tests/cases/compiler/typeReferenceDirectives4.ts +++ b/tests/cases/compiler/typeReferenceDirectives4.ts @@ -2,6 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types +// @currentDirectory: / // $ comes from d.ts file - no need to add type reference directive diff --git a/tests/cases/compiler/typeReferenceDirectives5.ts b/tests/cases/compiler/typeReferenceDirectives5.ts index bb24b82b324..e81ae663e24 100644 --- a/tests/cases/compiler/typeReferenceDirectives5.ts +++ b/tests/cases/compiler/typeReferenceDirectives5.ts @@ -2,6 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types +// @currentDirectory: / // @filename: /ref.d.ts export interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives6.ts b/tests/cases/compiler/typeReferenceDirectives6.ts index 7154963f1ef..edf2ece7e06 100644 --- a/tests/cases/compiler/typeReferenceDirectives6.ts +++ b/tests/cases/compiler/typeReferenceDirectives6.ts @@ -2,6 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types +// @currentDirectory: / // $ comes from type declaration file - type reference directive should be added diff --git a/tests/cases/compiler/typeReferenceDirectives7.ts b/tests/cases/compiler/typeReferenceDirectives7.ts index 79d42fa7018..e9335b07082 100644 --- a/tests/cases/compiler/typeReferenceDirectives7.ts +++ b/tests/cases/compiler/typeReferenceDirectives7.ts @@ -2,6 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types +// @currentDirectory: / // local value shadows global - no need to add type reference directive diff --git a/tests/cases/compiler/typeReferenceDirectives8.ts b/tests/cases/compiler/typeReferenceDirectives8.ts index c7725a3aab1..bed69cbf357 100644 --- a/tests/cases/compiler/typeReferenceDirectives8.ts +++ b/tests/cases/compiler/typeReferenceDirectives8.ts @@ -3,6 +3,7 @@ // @typeRoots: /types // @traceResolution: true // @types: lib +// @currentDirectory: / // @filename: /types/lib/index.d.ts diff --git a/tests/cases/compiler/typeReferenceDirectives9.ts b/tests/cases/compiler/typeReferenceDirectives9.ts index 610c7173c89..1ad1aa52288 100644 --- a/tests/cases/compiler/typeReferenceDirectives9.ts +++ b/tests/cases/compiler/typeReferenceDirectives9.ts @@ -2,6 +2,7 @@ // @declaration: true // @typeRoots: /types // @traceResolution: true +// @currentDirectory: / // @filename: /types/lib/index.d.ts diff --git a/tests/cases/conformance/references/library-reference-13.ts b/tests/cases/conformance/references/library-reference-13.ts index 92b4b259ba4..419643d9d0d 100644 --- a/tests/cases/conformance/references/library-reference-13.ts +++ b/tests/cases/conformance/references/library-reference-13.ts @@ -1,5 +1,6 @@ // @noImplicitReferences: true // @traceResolution: true +// @currentDirectory: / // load type declarations from types section of tsconfig diff --git a/tests/cases/conformance/typings/typingsLookup1.ts b/tests/cases/conformance/typings/typingsLookup1.ts index 555d4569af3..150deef992a 100644 --- a/tests/cases/conformance/typings/typingsLookup1.ts +++ b/tests/cases/conformance/typings/typingsLookup1.ts @@ -1,5 +1,6 @@ // @traceResolution: true // @noImplicitReferences: true +// @currentDirectory: / // @filename: /tsconfig.json { "files": "a.ts" } From 18fb33d36fbac6d296b4e7d9a94beb29b57de607 Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 4 Aug 2016 08:11:42 -0700 Subject: [PATCH 073/508] Remove unused reference files: these tests produce erros so they will not produce these files (#9233) From e5973b8daa325344cf55b4c2840dd235e5e4e4f4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 4 Aug 2016 09:46:35 -0700 Subject: [PATCH 074/508] Add string-literal completion test for jsdoc --- .../fourslash/completionForStringLiteral4.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/cases/fourslash/completionForStringLiteral4.ts diff --git a/tests/cases/fourslash/completionForStringLiteral4.ts b/tests/cases/fourslash/completionForStringLiteral4.ts new file mode 100644 index 00000000000..c240c125dbe --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral4.ts @@ -0,0 +1,22 @@ +/// +// @allowJs: true +// @Filename: in.js +/////** I am documentation +//// * @param {'literal'} p1 +//// * @param {"literal"} p2 +//// * @param {'other1' | 'other2'} p3 +//// * @param {'literal' | number} p4 +//// */ +////function f(p1, p2, p3, p4) { +//// return p1 + p2 + p3 + p4 + '.'; +////} +////f/*1*/('literal', 'literal', "o/*2*/ther1", 12); + +goTo.marker('1'); +verify.quickInfoExists(); +verify.quickInfoIs('function f(p1: "literal", p2: "literal", p3: "other1" | "other2", p4: "literal" | number): string', 'I am documentation'); + +goTo.marker('2'); +verify.completionListContains("other1"); +verify.completionListContains("other2"); +verify.memberListCount(2); From ca288231f7a531778e511643524fa83b03cfc478 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 4 Aug 2016 11:10:00 -0700 Subject: [PATCH 075/508] Fixing shim and normalizing paths --- src/services/services.ts | 5 ++++- src/services/shims.ts | 15 ++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 1ed91381469..7b523d7e7ab 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4594,6 +4594,7 @@ namespace ts { // Enumerate the available files const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); forEach(files, filePath => { + filePath = normalizePath(filePath); if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { return false; } @@ -4614,7 +4615,7 @@ namespace ts { if (host.getDirectories) { const directories = host.getDirectories(baseDirectory); forEach(directories, d => { - const directoryName = getBaseFileName(removeTrailingDirectorySeparator(d)); + const directoryName = getBaseFileName(normalizePath(d)); result.push({ name: ensureTrailingDirectorySeparator(directoryName), @@ -4755,6 +4756,7 @@ namespace ts { const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); forEach(nestedFiles, (f) => { + f = normalizePath(f); const nestedModule = removeFileExtension(getBaseFileName(f)); nonRelativeModules.push(nestedModule); }); @@ -4850,6 +4852,7 @@ namespace ts { function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: ImportCompletionEntry[]) { if (host.getDirectories && directoryProbablyExists(directory, host)) { forEach(host.getDirectories(directory), typeDirectory => { + typeDirectory = normalizePath(typeDirectory); result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName)); }); } diff --git a/src/services/shims.ts b/src/services/shims.ts index 9f4d9d24a43..70e4975ce45 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -67,7 +67,7 @@ namespace ts { getProjectVersion?(): string; useCaseSensitiveFileNames?(): boolean; - readDirectory(path: string, extensions?: string, exclude?: string, include?: string): string; + readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; readFile(path: string, encoding?: string): string; resolvePath(path: string): string; fileExists(path: string): boolean; @@ -417,12 +417,17 @@ namespace ts { return this.shimHost.getDefaultLibFileName(JSON.stringify(options)); } - public readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] { + public readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[], depth?: number): string[] { + const pattern = getFileMatcherPatterns(path, extensions, exclude, include, + this.shimHost.useCaseSensitiveFileNames(), this.shimHost.getCurrentDirectory()); return JSON.parse(this.shimHost.readDirectory( path, - extensions ? JSON.stringify(extensions) : undefined, - exclude ? JSON.stringify(exclude) : undefined, - include ? JSON.stringify(include) : undefined + JSON.stringify(extensions), + JSON.stringify(pattern.basePaths), + pattern.excludePattern, + pattern.includeFilePattern, + pattern.includeDirectoryPattern, + depth )); } From 3c32478b8fd433b5bdf708b27aef04309a107a3d Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 4 Aug 2016 13:01:17 -0700 Subject: [PATCH 076/508] Support other (new) literal types in jsdoc --- src/compiler/checker.ts | 4 ++-- src/compiler/parser.ts | 13 ++++++---- src/compiler/types.ts | 10 ++++---- ...{jsdocStringLiteral.js => jsdocLiteral.js} | 10 ++++---- .../baselines/reference/jsdocLiteral.symbols | 24 +++++++++++++++++++ ...StringLiteral.types => jsdocLiteral.types} | 16 ++++++++----- .../reference/jsdocStringLiteral.symbols | 21 ---------------- ...{jsdocStringLiteral.ts => jsdocLiteral.ts} | 5 ++-- .../fourslash/completionForStringLiteral4.ts | 7 +++--- 9 files changed, 63 insertions(+), 47 deletions(-) rename tests/baselines/reference/{jsdocStringLiteral.js => jsdocLiteral.js} (55%) create mode 100644 tests/baselines/reference/jsdocLiteral.symbols rename tests/baselines/reference/{jsdocStringLiteral.types => jsdocLiteral.types} (54%) delete mode 100644 tests/baselines/reference/jsdocStringLiteral.symbols rename tests/cases/conformance/jsdoc/{jsdocStringLiteral.ts => jsdocLiteral.ts} (63%) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 01aeb7ca744..ddc188ace92 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5529,8 +5529,8 @@ namespace ts { return getTypeFromThisTypeNode(node); case SyntaxKind.LiteralType: return getTypeFromLiteralTypeNode(node); - case SyntaxKind.JSDocStringLiteralType: - return getTypeFromStringLiteralTypeNode((node).stringLiteral); + case SyntaxKind.JSDocLiteralType: + return getTypeFromLiteralTypeNode((node).literal); case SyntaxKind.TypeReference: case SyntaxKind.JSDocTypeReference: return getTypeFromTypeReference(node); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 9136105457e..07f013e4f31 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -417,6 +417,8 @@ namespace ts { case SyntaxKind.JSDocPropertyTag: return visitNode(cbNode, (node).typeExpression) || visitNode(cbNode, (node).name); + case SyntaxKind.JSDocLiteralType: + return visitNode(cbNode, (node).literal); } } @@ -5890,7 +5892,10 @@ namespace ts { case SyntaxKind.VoidKeyword: return parseTokenNode(); case SyntaxKind.StringLiteral: - return parseJSDocStringLiteralType(); + case SyntaxKind.NumericLiteral: + case SyntaxKind.TrueKeyword: + case SyntaxKind.FalseKeyword: + return parseJSDocLiteralType(); } return parseJSDocTypeReference(); @@ -6071,9 +6076,9 @@ namespace ts { return finishNode(result); } - function parseJSDocStringLiteralType(): JSDocStringLiteralType { - const result = createNode(SyntaxKind.JSDocStringLiteralType); - result.stringLiteral = parseStringLiteralTypeNode(); + function parseJSDocLiteralType(): JSDocLiteralType { + const result = createNode(SyntaxKind.JSDocLiteralType); + result.literal = parseLiteralTypeNode(); return finishNode(result); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4f6806d11a5..45187b784b0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -346,7 +346,7 @@ namespace ts { JSDocTypedefTag, JSDocPropertyTag, JSDocTypeLiteral, - JSDocStringLiteralType, + JSDocLiteralType, // Synthesized list SyntaxList, @@ -377,9 +377,9 @@ namespace ts { LastBinaryOperator = CaretEqualsToken, FirstNode = QualifiedName, FirstJSDocNode = JSDocTypeExpression, - LastJSDocNode = JSDocStringLiteralType, + LastJSDocNode = JSDocLiteralType, FirstJSDocTagNode = JSDocComment, - LastJSDocTagNode = JSDocStringLiteralType + LastJSDocTagNode = JSDocLiteralType } export const enum NodeFlags { @@ -1493,8 +1493,8 @@ namespace ts { type: JSDocType; } - export interface JSDocStringLiteralType extends JSDocType { - stringLiteral: StringLiteralTypeNode; + export interface JSDocLiteralType extends JSDocType { + literal: LiteralTypeNode; } export type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; diff --git a/tests/baselines/reference/jsdocStringLiteral.js b/tests/baselines/reference/jsdocLiteral.js similarity index 55% rename from tests/baselines/reference/jsdocStringLiteral.js rename to tests/baselines/reference/jsdocLiteral.js index e1210690f91..1a017160302 100644 --- a/tests/baselines/reference/jsdocStringLiteral.js +++ b/tests/baselines/reference/jsdocLiteral.js @@ -4,9 +4,10 @@ * @param {"literal"} p2 * @param {'literal' | 'other'} p3 * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 */ -function f(p1, p2, p3, p4) { - return p1 + p2 + p3 + p4 + '.'; +function f(p1, p2, p3, p4, p5) { + return p1 + p2 + p3 + p4 + p5 + '.'; } @@ -16,7 +17,8 @@ function f(p1, p2, p3, p4) { * @param {"literal"} p2 * @param {'literal' | 'other'} p3 * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 */ -function f(p1, p2, p3, p4) { - return p1 + p2 + p3 + p4 + '.'; +function f(p1, p2, p3, p4, p5) { + return p1 + p2 + p3 + p4 + p5 + '.'; } diff --git a/tests/baselines/reference/jsdocLiteral.symbols b/tests/baselines/reference/jsdocLiteral.symbols new file mode 100644 index 00000000000..9f01fe782aa --- /dev/null +++ b/tests/baselines/reference/jsdocLiteral.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/jsdoc/in.js === +/** + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 + */ +function f(p1, p2, p3, p4, p5) { +>f : Symbol(f, Decl(in.js, 0, 0)) +>p1 : Symbol(p1, Decl(in.js, 7, 11)) +>p2 : Symbol(p2, Decl(in.js, 7, 14)) +>p3 : Symbol(p3, Decl(in.js, 7, 18)) +>p4 : Symbol(p4, Decl(in.js, 7, 22)) +>p5 : Symbol(p5, Decl(in.js, 7, 26)) + + return p1 + p2 + p3 + p4 + p5 + '.'; +>p1 : Symbol(p1, Decl(in.js, 7, 11)) +>p2 : Symbol(p2, Decl(in.js, 7, 14)) +>p3 : Symbol(p3, Decl(in.js, 7, 18)) +>p4 : Symbol(p4, Decl(in.js, 7, 22)) +>p5 : Symbol(p5, Decl(in.js, 7, 26)) +} + diff --git a/tests/baselines/reference/jsdocStringLiteral.types b/tests/baselines/reference/jsdocLiteral.types similarity index 54% rename from tests/baselines/reference/jsdocStringLiteral.types rename to tests/baselines/reference/jsdocLiteral.types index 0400416a259..b6c9e522ac3 100644 --- a/tests/baselines/reference/jsdocStringLiteral.types +++ b/tests/baselines/reference/jsdocLiteral.types @@ -4,23 +4,27 @@ * @param {"literal"} p2 * @param {'literal' | 'other'} p3 * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 */ -function f(p1, p2, p3, p4) { ->f : (p1: "literal", p2: "literal", p3: "literal" | "other", p4: "literal" | number) => string +function f(p1, p2, p3, p4, p5) { +>f : (p1: "literal", p2: "literal", p3: "literal" | "other", p4: number | "literal", p5: true | 12 | "str") => string >p1 : "literal" >p2 : "literal" >p3 : "literal" | "other" ->p4 : "literal" | number +>p4 : number | "literal" +>p5 : true | 12 | "str" - return p1 + p2 + p3 + p4 + '.'; ->p1 + p2 + p3 + p4 + '.' : string + return p1 + p2 + p3 + p4 + p5 + '.'; +>p1 + p2 + p3 + p4 + p5 + '.' : string +>p1 + p2 + p3 + p4 + p5 : string >p1 + p2 + p3 + p4 : string >p1 + p2 + p3 : string >p1 + p2 : string >p1 : "literal" >p2 : "literal" >p3 : "literal" | "other" ->p4 : "literal" | number +>p4 : number | "literal" +>p5 : true | 12 | "str" >'.' : string } diff --git a/tests/baselines/reference/jsdocStringLiteral.symbols b/tests/baselines/reference/jsdocStringLiteral.symbols deleted file mode 100644 index 982a1536069..00000000000 --- a/tests/baselines/reference/jsdocStringLiteral.symbols +++ /dev/null @@ -1,21 +0,0 @@ -=== tests/cases/conformance/jsdoc/in.js === -/** - * @param {'literal'} p1 - * @param {"literal"} p2 - * @param {'literal' | 'other'} p3 - * @param {'literal' | number} p4 - */ -function f(p1, p2, p3, p4) { ->f : Symbol(f, Decl(in.js, 0, 0)) ->p1 : Symbol(p1, Decl(in.js, 6, 11)) ->p2 : Symbol(p2, Decl(in.js, 6, 14)) ->p3 : Symbol(p3, Decl(in.js, 6, 18)) ->p4 : Symbol(p4, Decl(in.js, 6, 22)) - - return p1 + p2 + p3 + p4 + '.'; ->p1 : Symbol(p1, Decl(in.js, 6, 11)) ->p2 : Symbol(p2, Decl(in.js, 6, 14)) ->p3 : Symbol(p3, Decl(in.js, 6, 18)) ->p4 : Symbol(p4, Decl(in.js, 6, 22)) -} - diff --git a/tests/cases/conformance/jsdoc/jsdocStringLiteral.ts b/tests/cases/conformance/jsdoc/jsdocLiteral.ts similarity index 63% rename from tests/cases/conformance/jsdoc/jsdocStringLiteral.ts rename to tests/cases/conformance/jsdoc/jsdocLiteral.ts index d2a0d6c644d..bd0d2d562f9 100644 --- a/tests/cases/conformance/jsdoc/jsdocStringLiteral.ts +++ b/tests/cases/conformance/jsdoc/jsdocLiteral.ts @@ -6,7 +6,8 @@ * @param {"literal"} p2 * @param {'literal' | 'other'} p3 * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 */ -function f(p1, p2, p3, p4) { - return p1 + p2 + p3 + p4 + '.'; +function f(p1, p2, p3, p4, p5) { + return p1 + p2 + p3 + p4 + p5 + '.'; } diff --git a/tests/cases/fourslash/completionForStringLiteral4.ts b/tests/cases/fourslash/completionForStringLiteral4.ts index c240c125dbe..11ae699eab8 100644 --- a/tests/cases/fourslash/completionForStringLiteral4.ts +++ b/tests/cases/fourslash/completionForStringLiteral4.ts @@ -6,15 +6,16 @@ //// * @param {"literal"} p2 //// * @param {'other1' | 'other2'} p3 //// * @param {'literal' | number} p4 +//// * @param {12 | true} p5 //// */ -////function f(p1, p2, p3, p4) { -//// return p1 + p2 + p3 + p4 + '.'; +////function f(p1, p2, p3, p4, p5) { +//// return p1 + p2 + p3 + p4 + p5 + '.'; ////} ////f/*1*/('literal', 'literal', "o/*2*/ther1", 12); goTo.marker('1'); verify.quickInfoExists(); -verify.quickInfoIs('function f(p1: "literal", p2: "literal", p3: "other1" | "other2", p4: "literal" | number): string', 'I am documentation'); +verify.quickInfoIs('function f(p1: "literal", p2: "literal", p3: "other1" | "other2", p4: number | "literal", p5: true | 12): string', 'I am documentation'); goTo.marker('2'); verify.completionListContains("other1"); From 9947ac2ecefcd343b6ebc40b9614c1dfcf76b666 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 4 Aug 2016 14:13:07 -0700 Subject: [PATCH 077/508] Don't allow properties inherited from Object to be automatically included in TSX attributes --- src/compiler/checker.ts | 4 ++-- .../baselines/reference/tsxAttributeResolution5.errors.txt | 7 +++++-- tests/baselines/reference/tsxAttributeResolution5.js | 4 ++-- tests/cases/conformance/jsx/tsxAttributeResolution5.tsx | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0599eb4bbbc..84d5cd08a2b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10060,7 +10060,7 @@ namespace ts { for (const prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type - if (!nameTable[prop.name]) { + if (!hasProperty(nameTable, prop.name)) { const targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { const msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); @@ -10406,7 +10406,7 @@ namespace ts { const targetProperties = getPropertiesOfType(targetAttributesType); for (let i = 0; i < targetProperties.length; i++) { if (!(targetProperties[i].flags & SymbolFlags.Optional) && - nameTable[targetProperties[i].name] === undefined) { + !hasProperty(nameTable, targetProperties[i].name)) { error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); } diff --git a/tests/baselines/reference/tsxAttributeResolution5.errors.txt b/tests/baselines/reference/tsxAttributeResolution5.errors.txt index d7aa46bc05a..42dabc741ab 100644 --- a/tests/baselines/reference/tsxAttributeResolution5.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution5.errors.txt @@ -2,9 +2,10 @@ tests/cases/conformance/jsx/file.tsx(21,16): error TS2606: Property 'x' of JSX s Type 'number' is not assignable to type 'string'. tests/cases/conformance/jsx/file.tsx(25,9): error TS2324: Property 'x' is missing in type 'Attribs1'. tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'x' is missing in type 'Attribs1'. +tests/cases/conformance/jsx/file.tsx(30,1): error TS2324: Property 'toString' is missing in type 'Attribs2'. -==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (4 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { @@ -41,5 +42,7 @@ tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'x' is missin ; // Error, missing x ~~~~~~~~~~~~~~~~~ !!! error TS2324: Property 'x' is missing in type 'Attribs1'. - ; // OK + ; // Error, missing toString + ~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'toString' is missing in type 'Attribs2'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution5.js b/tests/baselines/reference/tsxAttributeResolution5.js index abfb54e000c..4bde09074b5 100644 --- a/tests/baselines/reference/tsxAttributeResolution5.js +++ b/tests/baselines/reference/tsxAttributeResolution5.js @@ -28,7 +28,7 @@ function make3 (obj: T) { ; // Error, missing x -; // OK +; // Error, missing toString //// [file.jsx] @@ -42,4 +42,4 @@ function make3(obj) { return ; // Error, missing x } ; // Error, missing x -; // OK +; // Error, missing toString diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx index dd16ade10e3..83fb7b32f56 100644 --- a/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx +++ b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx @@ -29,4 +29,4 @@ function make3 (obj: T) { ; // Error, missing x -; // OK +; // Error, missing toString From 798be6f4f977dfbc0e46353e56b28b59c123d1d6 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 4 Aug 2016 15:17:08 -0700 Subject: [PATCH 078/508] Add new test baseline and delete else in binder The extra `else` caused a ton of test failures! --- src/compiler/binder.ts | 2 +- .../reference/multipleDeclarations.js | 31 +++++- .../reference/multipleDeclarations.symbols | 98 +++++++++++++------ .../reference/multipleDeclarations.types | 59 ++++++++++- 4 files changed, 157 insertions(+), 33 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 6f0def32702..5e2cd3f8680 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -328,7 +328,7 @@ namespace ts { classifiableNames[name] = name; } - else if (symbol.flags & excludes) { + if (symbol.flags & excludes) { if (symbol.isDiscardable) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. diff --git a/tests/baselines/reference/multipleDeclarations.js b/tests/baselines/reference/multipleDeclarations.js index e5aae416663..7fb7e0bca02 100644 --- a/tests/baselines/reference/multipleDeclarations.js +++ b/tests/baselines/reference/multipleDeclarations.js @@ -1,12 +1,10 @@ //// [input.js] - function C() { this.m = null; } C.prototype.m = function() { this.nothing(); } - class X { constructor() { this.m = this.m.bind(this); @@ -21,6 +19,20 @@ let x = new X(); X.prototype.mistake = false; x.m(); x.mistake; +class Y { + mistake() { + } + m() { + } + constructor() { + this.m = this.m.bind(this); + this.mistake = 'even more nonsense'; + } +} +Y.prototype.mistake = true; +let y = new Y(); +y.m(); +y.mistake(); //// [output.js] @@ -45,3 +57,18 @@ var x = new X(); X.prototype.mistake = false; x.m(); x.mistake; +var Y = (function () { + function Y() { + this.m = this.m.bind(this); + this.mistake = 'even more nonsense'; + } + Y.prototype.mistake = function () { + }; + Y.prototype.m = function () { + }; + return Y; +}()); +Y.prototype.mistake = true; +var y = new Y(); +y.m(); +y.mistake(); diff --git a/tests/baselines/reference/multipleDeclarations.symbols b/tests/baselines/reference/multipleDeclarations.symbols index 7e4bcd53c8a..9e49c2fc00c 100644 --- a/tests/baselines/reference/multipleDeclarations.symbols +++ b/tests/baselines/reference/multipleDeclarations.symbols @@ -1,64 +1,106 @@ === tests/cases/conformance/salsa/input.js === - function C() { >C : Symbol(C, Decl(input.js, 0, 0)) this.m = null; ->m : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1)) +>m : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1)) } C.prototype.m = function() { ->C.prototype : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1)) +>C.prototype : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1)) >C : Symbol(C, Decl(input.js, 0, 0)) >prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --)) ->m : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1)) +>m : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1)) this.nothing(); >this : Symbol(C, Decl(input.js, 0, 0)) } - class X { ->X : Symbol(X, Decl(input.js, 6, 1)) +>X : Symbol(X, Decl(input.js, 5, 1)) constructor() { this.m = this.m.bind(this); ->this.m : Symbol(X.m, Decl(input.js, 12, 5)) ->this : Symbol(X, Decl(input.js, 6, 1)) ->m : Symbol(X.m, Decl(input.js, 9, 19)) +>this.m : Symbol(X.m, Decl(input.js, 10, 5)) +>this : Symbol(X, Decl(input.js, 5, 1)) +>m : Symbol(X.m, Decl(input.js, 7, 19)) >this.m.bind : Symbol(Function.bind, Decl(lib.d.ts, --, --)) ->this.m : Symbol(X.m, Decl(input.js, 12, 5)) ->this : Symbol(X, Decl(input.js, 6, 1)) ->m : Symbol(X.m, Decl(input.js, 12, 5)) +>this.m : Symbol(X.m, Decl(input.js, 10, 5)) +>this : Symbol(X, Decl(input.js, 5, 1)) +>m : Symbol(X.m, Decl(input.js, 10, 5)) >bind : Symbol(Function.bind, Decl(lib.d.ts, --, --)) ->this : Symbol(X, Decl(input.js, 6, 1)) +>this : Symbol(X, Decl(input.js, 5, 1)) this.mistake = 'frankly, complete nonsense'; ->this.mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) ->this : Symbol(X, Decl(input.js, 6, 1)) ->mistake : Symbol(X.mistake, Decl(input.js, 10, 35)) +>this.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>this : Symbol(X, Decl(input.js, 5, 1)) +>mistake : Symbol(X.mistake, Decl(input.js, 8, 35)) } m() { ->m : Symbol(X.m, Decl(input.js, 12, 5)) +>m : Symbol(X.m, Decl(input.js, 10, 5)) } mistake() { ->mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) +>mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) } } let x = new X(); ->x : Symbol(x, Decl(input.js, 18, 3)) ->X : Symbol(X, Decl(input.js, 6, 1)) +>x : Symbol(x, Decl(input.js, 16, 3)) +>X : Symbol(X, Decl(input.js, 5, 1)) X.prototype.mistake = false; ->X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) ->X : Symbol(X, Decl(input.js, 6, 1)) +>X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>X : Symbol(X, Decl(input.js, 5, 1)) >prototype : Symbol(X.prototype) x.m(); ->x.m : Symbol(X.m, Decl(input.js, 12, 5)) ->x : Symbol(x, Decl(input.js, 18, 3)) ->m : Symbol(X.m, Decl(input.js, 12, 5)) +>x.m : Symbol(X.m, Decl(input.js, 10, 5)) +>x : Symbol(x, Decl(input.js, 16, 3)) +>m : Symbol(X.m, Decl(input.js, 10, 5)) x.mistake; ->x.mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) ->x : Symbol(x, Decl(input.js, 18, 3)) ->mistake : Symbol(X.mistake, Decl(input.js, 14, 5)) +>x.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>x : Symbol(x, Decl(input.js, 16, 3)) +>mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) + +class Y { +>Y : Symbol(Y, Decl(input.js, 19, 10)) + + mistake() { +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) + } + m() { +>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) + } + constructor() { + this.m = this.m.bind(this); +>this.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>this : Symbol(Y, Decl(input.js, 19, 10)) +>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>this.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>this : Symbol(Y, Decl(input.js, 19, 10)) +>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>this : Symbol(Y, Decl(input.js, 19, 10)) + + this.mistake = 'even more nonsense'; +>this.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>this : Symbol(Y, Decl(input.js, 19, 10)) +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) + } +} +Y.prototype.mistake = true; +>Y.prototype.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>Y : Symbol(Y, Decl(input.js, 19, 10)) +>prototype : Symbol(Y.prototype) + +let y = new Y(); +>y : Symbol(y, Decl(input.js, 31, 3)) +>Y : Symbol(Y, Decl(input.js, 19, 10)) + +y.m(); +>y.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>y : Symbol(y, Decl(input.js, 31, 3)) +>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) + +y.mistake(); +>y.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>y : Symbol(y, Decl(input.js, 31, 3)) +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) diff --git a/tests/baselines/reference/multipleDeclarations.types b/tests/baselines/reference/multipleDeclarations.types index 2a7cac18205..900d03195d4 100644 --- a/tests/baselines/reference/multipleDeclarations.types +++ b/tests/baselines/reference/multipleDeclarations.types @@ -1,5 +1,4 @@ === tests/cases/conformance/salsa/input.js === - function C() { >C : () => void @@ -25,7 +24,6 @@ C.prototype.m = function() { >this : { m: () => void; } >nothing : any } - class X { >X : X @@ -82,3 +80,60 @@ x.mistake; >x : X >mistake : () => void +class Y { +>Y : Y + + mistake() { +>mistake : any + } + m() { +>m : any + } + constructor() { + this.m = this.m.bind(this); +>this.m = this.m.bind(this) : any +>this.m : any +>this : this +>m : any +>this.m.bind(this) : any +>this.m.bind : any +>this.m : any +>this : this +>m : any +>bind : any +>this : this + + this.mistake = 'even more nonsense'; +>this.mistake = 'even more nonsense' : string +>this.mistake : any +>this : this +>mistake : any +>'even more nonsense' : string + } +} +Y.prototype.mistake = true; +>Y.prototype.mistake = true : boolean +>Y.prototype.mistake : any +>Y.prototype : Y +>Y : typeof Y +>prototype : Y +>mistake : any +>true : boolean + +let y = new Y(); +>y : Y +>new Y() : Y +>Y : typeof Y + +y.m(); +>y.m() : any +>y.m : any +>y : Y +>m : any + +y.mistake(); +>y.mistake() : any +>y.mistake : any +>y : Y +>mistake : any + From 0f22079d9e52f3fd4c26b9999ef20a774896649b Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 4 Aug 2016 18:17:41 -0700 Subject: [PATCH 079/508] Remove trailing slashes, remove mostly useless IO, fix script element kind for files --- src/services/services.ts | 35 +++---------------- .../completionForStringLiteralImport1.ts | 2 +- ...etionForStringLiteralNonrelativeImport4.ts | 4 +-- ...etionForStringLiteralNonrelativeImport6.ts | 4 +-- ...mpletionForStringLiteralRelativeImport1.ts | 6 ++-- ...mpletionForStringLiteralRelativeImport3.ts | 8 ++--- ...mpletionForStringLiteralRelativeImport4.ts | 2 +- .../completionForTripleSlashReference1.ts | 6 ++-- .../completionForTripleSlashReference3.ts | 8 ++--- 9 files changed, 24 insertions(+), 51 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 7b523d7e7ab..6cb92547998 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1865,7 +1865,6 @@ namespace ts { interface VisibleModuleInfo { moduleName: string; moduleDir: string; - canBeImported: boolean; } export interface DisplayPartsSymbolWriter extends SymbolWriter { @@ -4605,7 +4604,7 @@ namespace ts { if (!duplicate) { result.push({ name: fileName, - kind: ScriptElementKind.directory, + kind: ScriptElementKind.scriptElement, sortText: fileName }); } @@ -4618,7 +4617,7 @@ namespace ts { const directoryName = getBaseFileName(normalizePath(d)); result.push({ - name: ensureTrailingDirectorySeparator(directoryName), + name: directoryName, kind: ScriptElementKind.directory, sortText: directoryName }); @@ -4750,7 +4749,7 @@ namespace ts { if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { forEach(enumerateNodeModulesVisibleToScript(host, scriptPath), visibleModule => { if (!isNestedModule) { - nonRelativeModules.push(visibleModule.canBeImported ? visibleModule.moduleName : ensureTrailingDirectorySeparator(visibleModule.moduleName)); + nonRelativeModules.push(visibleModule.moduleName); } else { const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); @@ -4904,8 +4903,7 @@ namespace ts { const moduleDir = combinePaths(nodeModulesDir, moduleName); result.push({ moduleName, - moduleDir, - canBeImported: moduleCanBeImported(moduleDir) + moduleDir }); }); }); @@ -4930,31 +4928,6 @@ namespace ts { } } } - - /* - * A module can be imported by name alone if one of the following is true: - * It defines the "typings" property in its package.json - * The module has a "main" export and an index.d.ts file - * The module has an index.ts - */ - function moduleCanBeImported(modulePath: string): boolean { - const packagePath = combinePaths(modulePath, "package.json"); - - let hasMainExport = false; - if (host.fileExists(packagePath)) { - const package = tryReadingPackageJson(packagePath); - if (package) { - if (package.typings) { - return true; - } - hasMainExport = !!package.main; - } - } - - hasMainExport = hasMainExport || host.fileExists(combinePaths(modulePath, "index.js")); - - return (hasMainExport && host.fileExists(combinePaths(modulePath, "index.d.ts"))) || host.fileExists(combinePaths(modulePath, "index.ts")); - } } function createCompletionEntryForModule(name: string, kind: string): ImportCompletionEntry { diff --git a/tests/cases/fourslash/completionForStringLiteralImport1.ts b/tests/cases/fourslash/completionForStringLiteralImport1.ts index 239c3be42fc..5fcb3e42f1a 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport1.ts @@ -28,4 +28,4 @@ goTo.marker("2"); verify.importModuleCompletionListContains("some-module", 2); goTo.marker("3"); -verify.importModuleCompletionListContains("fourslash/", 3); \ No newline at end of file +verify.importModuleCompletionListContains("fourslash", 3); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index f4a9ae2d537..ef926a7c8ad 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -25,8 +25,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("fake-module/"); + verify.importModuleCompletionListContains("fake-module"); verify.importModuleCompletionListContains("fake-module2"); - verify.importModuleCompletionListContains("fake-module3/"); + verify.importModuleCompletionListContains("fake-module3"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts index 263b57d9d29..c430310a217 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts @@ -52,8 +52,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module-no-main/"); - verify.importModuleCompletionListContains("module-no-main-index-d-ts/"); + verify.importModuleCompletionListContains("module-no-main"); + verify.importModuleCompletionListContains("module-no-main-index-d-ts"); verify.importModuleCompletionListContains("module-index-ts"); verify.importModuleCompletionListContains("module-index-d-ts-explicit-main"); verify.importModuleCompletionListContains("module-index-d-ts-default-main"); diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts index 52d62f3b4f8..3257dff40af 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts @@ -51,8 +51,8 @@ for (const kind of kinds) { verify.importModuleCompletionListContains("f1"); verify.importModuleCompletionListContains("f2"); verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("folder/"); - verify.importModuleCompletionListContains("parentTest/"); + verify.importModuleCompletionListContains("folder"); + verify.importModuleCompletionListContains("parentTest"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); goTo.marker(kind + "2"); @@ -63,6 +63,6 @@ for (const kind of kinds) { goTo.marker(kind + "3"); verify.importModuleCompletionListContains("f4"); verify.importModuleCompletionListContains("g1"); - verify.importModuleCompletionListContains("sub/"); + verify.importModuleCompletionListContains("sub"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts index 4f35612c5c6..95e4e51577a 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -32,18 +32,18 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("fourslash/"); + verify.importModuleCompletionListContains("fourslash"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("fourslash/"); + verify.importModuleCompletionListContains("fourslash"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker(kind + "2"); verify.importModuleCompletionListContains("f1"); verify.importModuleCompletionListContains("f2"); verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("folder/"); - verify.importModuleCompletionListContains("tests/"); + verify.importModuleCompletionListContains("folder"); + verify.importModuleCompletionListContains("tests"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index 773c4d90d75..f89eaa567ad 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -43,7 +43,7 @@ for (const kind of kinds) { verify.importModuleCompletionListContains("module0"); verify.importModuleCompletionListContains("module1"); verify.importModuleCompletionListContains("module2"); - verify.importModuleCompletionListContains("more/"); + verify.importModuleCompletionListContains("more"); // Should not contain itself verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); diff --git a/tests/cases/fourslash/completionForTripleSlashReference1.ts b/tests/cases/fourslash/completionForTripleSlashReference1.ts index 8c6188ac90c..66dfa5f93c2 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference1.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference1.ts @@ -34,16 +34,16 @@ for (let i = 0; i < 5; i++) { verify.importModuleCompletionListContains("f1.d.ts"); verify.importModuleCompletionListContains("f2.tsx"); verify.importModuleCompletionListContains("e1.ts"); - verify.importModuleCompletionListContains("parentTest/"); + verify.importModuleCompletionListContains("parentTest"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); } goTo.marker("5"); verify.importModuleCompletionListContains("g1.ts"); -verify.importModuleCompletionListContains("sub/"); +verify.importModuleCompletionListContains("sub"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); goTo.marker("6"); verify.importModuleCompletionListContains("g1.ts"); -verify.importModuleCompletionListContains("sub/"); +verify.importModuleCompletionListContains("sub"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference3.ts b/tests/cases/fourslash/completionForTripleSlashReference3.ts index dda6ae92b41..af8d49d9df3 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference3.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference3.ts @@ -25,17 +25,17 @@ //// /*e2*/ goTo.marker("0"); -verify.importModuleCompletionListContains("fourslash/"); +verify.importModuleCompletionListContains("fourslash"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker("1"); -verify.importModuleCompletionListContains("fourslash/"); +verify.importModuleCompletionListContains("fourslash"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); goTo.marker("2"); verify.importModuleCompletionListContains("f1.ts"); verify.importModuleCompletionListContains("f2.tsx"); verify.importModuleCompletionListContains("e1.ts"); -verify.importModuleCompletionListContains("folder/"); -verify.importModuleCompletionListContains("tests/"); +verify.importModuleCompletionListContains("folder"); +verify.importModuleCompletionListContains("tests"); verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); \ No newline at end of file From 8f638f7ecdc154c00c2be11a55971a7d13ee5757 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 5 Aug 2016 09:58:30 -0700 Subject: [PATCH 080/508] Fix lint --- src/compiler/binder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 5e2cd3f8680..b771a3b67be 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1987,7 +1987,7 @@ namespace ts { assignee.symbol.members = assignee.symbol.members || {}; // It's acceptable for multiple 'this' assignments of the same identifier to occur // AND it can be overwritten by subsequent method declarations - let symbol = declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); + const symbol = declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); symbol.isDiscardable = true; } From ceab31cf0db3eb0b5e96559c1f5e77c9328e58aa Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 5 Aug 2016 10:12:01 -0700 Subject: [PATCH 081/508] Port PR #10016 to Master (#10100) * Treat namespaceExportDeclaration as declaration * Update baselines * wip - add tests * Add tests * Show "export namespace" for quick-info --- src/compiler/checker.ts | 3 ++- src/compiler/utilities.ts | 1 + src/services/services.ts | 9 ++++++++- .../reference/umd-augmentation-1.symbols | 1 + .../reference/umd-augmentation-1.types | 2 +- .../reference/umd-augmentation-2.symbols | 1 + .../reference/umd-augmentation-2.types | 2 +- .../reference/umd-augmentation-3.symbols | 1 + .../reference/umd-augmentation-3.types | 2 +- .../reference/umd-augmentation-4.symbols | 1 + .../reference/umd-augmentation-4.types | 2 +- tests/baselines/reference/umd1.symbols | 1 + tests/baselines/reference/umd1.types | 2 +- tests/baselines/reference/umd3.symbols | 1 + tests/baselines/reference/umd3.types | 2 +- tests/baselines/reference/umd4.symbols | 1 + tests/baselines/reference/umd4.types | 2 +- tests/baselines/reference/umd6.symbols | 1 + tests/baselines/reference/umd6.types | 2 +- tests/baselines/reference/umd7.symbols | 1 + tests/baselines/reference/umd7.types | 2 +- tests/baselines/reference/umd8.symbols | 1 + tests/baselines/reference/umd8.types | 2 +- .../fourslash/findAllRefsForUMDModuleAlias1.ts | 13 +++++++++++++ .../fourslash/quickInfoForUMDModuleAlias.ts | 17 +++++++++++++++++ tests/cases/fourslash/renameAlias.ts | 8 ++++---- tests/cases/fourslash/renameUMDModuleAlias1.ts | 17 +++++++++++++++++ tests/cases/fourslash/renameUMDModuleAlias2.ts | 14 ++++++++++++++ 28 files changed, 96 insertions(+), 16 deletions(-) create mode 100644 tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts create mode 100644 tests/cases/fourslash/quickInfoForUMDModuleAlias.ts create mode 100644 tests/cases/fourslash/renameUMDModuleAlias1.ts create mode 100644 tests/cases/fourslash/renameUMDModuleAlias2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 84d5cd08a2b..9583fadba62 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19691,7 +19691,7 @@ namespace ts { } function checkGrammarTopLevelElementForRequiredDeclareModifier(node: Node): boolean { - // A declare modifier is required for any top level .d.ts declaration except export=, export default, + // A declare modifier is required for any top level .d.ts declaration except export=, export default, export as namespace // interfaces and imports categories: // // DeclarationElement: @@ -19709,6 +19709,7 @@ namespace ts { node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.ExportDeclaration || node.kind === SyntaxKind.ExportAssignment || + node.kind === SyntaxKind.NamespaceExportDeclaration || (node.flags & NodeFlags.Ambient) || (node.flags & (NodeFlags.Export | NodeFlags.Default))) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4ae0005e9c5..2cfaf1f5cfb 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1569,6 +1569,7 @@ namespace ts { case SyntaxKind.MethodSignature: case SyntaxKind.ModuleDeclaration: case SyntaxKind.NamespaceImport: + case SyntaxKind.NamespaceExportDeclaration: case SyntaxKind.Parameter: case SyntaxKind.PropertyAssignment: case SyntaxKind.PropertyDeclaration: diff --git a/src/services/services.ts b/src/services/services.ts index ab1e30a44a6..aea4d5f872e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4830,7 +4830,14 @@ namespace ts { } if (symbolFlags & SymbolFlags.Alias) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(SyntaxKind.ImportKeyword)); + if (symbol.declarations[0].kind === SyntaxKind.NamespaceExportDeclaration) { + displayParts.push(keywordPart(SyntaxKind.ExportKeyword)); + displayParts.push(spacePart()); + displayParts.push(keywordPart(SyntaxKind.NamespaceKeyword)); + } + else { + displayParts.push(keywordPart(SyntaxKind.ImportKeyword)); + } displayParts.push(spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, declaration => { diff --git a/tests/baselines/reference/umd-augmentation-1.symbols b/tests/baselines/reference/umd-augmentation-1.symbols index 645511350a9..70715649894 100644 --- a/tests/baselines/reference/umd-augmentation-1.symbols +++ b/tests/baselines/reference/umd-augmentation-1.symbols @@ -39,6 +39,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; +>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) export interface Point { >Point : Symbol(Point, Decl(index.d.ts, 1, 27)) diff --git a/tests/baselines/reference/umd-augmentation-1.types b/tests/baselines/reference/umd-augmentation-1.types index 31ac43fe855..59b577141e0 100644 --- a/tests/baselines/reference/umd-augmentation-1.types +++ b/tests/baselines/reference/umd-augmentation-1.types @@ -48,7 +48,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : any +>Math2d : typeof Math2d export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-2.symbols b/tests/baselines/reference/umd-augmentation-2.symbols index bd6584d3d74..a31ed61d531 100644 --- a/tests/baselines/reference/umd-augmentation-2.symbols +++ b/tests/baselines/reference/umd-augmentation-2.symbols @@ -37,6 +37,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; +>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) export interface Point { >Point : Symbol(Point, Decl(index.d.ts, 1, 27)) diff --git a/tests/baselines/reference/umd-augmentation-2.types b/tests/baselines/reference/umd-augmentation-2.types index 20bba091903..24fe6df3c3c 100644 --- a/tests/baselines/reference/umd-augmentation-2.types +++ b/tests/baselines/reference/umd-augmentation-2.types @@ -46,7 +46,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : any +>Math2d : typeof Math2d export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-3.symbols b/tests/baselines/reference/umd-augmentation-3.symbols index 3193e83cd19..3e2df7c8a89 100644 --- a/tests/baselines/reference/umd-augmentation-3.symbols +++ b/tests/baselines/reference/umd-augmentation-3.symbols @@ -39,6 +39,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; +>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) export = M2D; >M2D : Symbol(M2D, Decl(index.d.ts, 3, 13)) diff --git a/tests/baselines/reference/umd-augmentation-3.types b/tests/baselines/reference/umd-augmentation-3.types index 854ebceff37..39bc28cbd24 100644 --- a/tests/baselines/reference/umd-augmentation-3.types +++ b/tests/baselines/reference/umd-augmentation-3.types @@ -48,7 +48,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : any +>Math2d : typeof Math2d export = M2D; >M2D : typeof M2D diff --git a/tests/baselines/reference/umd-augmentation-4.symbols b/tests/baselines/reference/umd-augmentation-4.symbols index 3f2cc913d86..7be5d278bf2 100644 --- a/tests/baselines/reference/umd-augmentation-4.symbols +++ b/tests/baselines/reference/umd-augmentation-4.symbols @@ -37,6 +37,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; +>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) export = M2D; >M2D : Symbol(M2D, Decl(index.d.ts, 3, 13)) diff --git a/tests/baselines/reference/umd-augmentation-4.types b/tests/baselines/reference/umd-augmentation-4.types index 71783d03012..246270aa5a6 100644 --- a/tests/baselines/reference/umd-augmentation-4.types +++ b/tests/baselines/reference/umd-augmentation-4.types @@ -46,7 +46,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : any +>Math2d : typeof Math2d export = M2D; >M2D : typeof M2D diff --git a/tests/baselines/reference/umd1.symbols b/tests/baselines/reference/umd1.symbols index 9b964456bcf..0307a9b78d3 100644 --- a/tests/baselines/reference/umd1.symbols +++ b/tests/baselines/reference/umd1.symbols @@ -30,4 +30,5 @@ export interface Thing { n: typeof x } >x : Symbol(x, Decl(foo.d.ts, 1, 10)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38)) diff --git a/tests/baselines/reference/umd1.types b/tests/baselines/reference/umd1.types index 1767f3b5a89..1379bba8d5d 100644 --- a/tests/baselines/reference/umd1.types +++ b/tests/baselines/reference/umd1.types @@ -31,5 +31,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : any +>Foo : typeof Foo diff --git a/tests/baselines/reference/umd3.symbols b/tests/baselines/reference/umd3.symbols index 165fd81597a..c1fd3d6d74f 100644 --- a/tests/baselines/reference/umd3.symbols +++ b/tests/baselines/reference/umd3.symbols @@ -32,4 +32,5 @@ export interface Thing { n: typeof x } >x : Symbol(x, Decl(foo.d.ts, 1, 10)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38)) diff --git a/tests/baselines/reference/umd3.types b/tests/baselines/reference/umd3.types index 85ee6bafe5e..23149e58d76 100644 --- a/tests/baselines/reference/umd3.types +++ b/tests/baselines/reference/umd3.types @@ -33,5 +33,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : any +>Foo : typeof Foo diff --git a/tests/baselines/reference/umd4.symbols b/tests/baselines/reference/umd4.symbols index 8403187198b..d266997770b 100644 --- a/tests/baselines/reference/umd4.symbols +++ b/tests/baselines/reference/umd4.symbols @@ -32,4 +32,5 @@ export interface Thing { n: typeof x } >x : Symbol(x, Decl(foo.d.ts, 1, 10)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38)) diff --git a/tests/baselines/reference/umd4.types b/tests/baselines/reference/umd4.types index 579599f5661..18794258517 100644 --- a/tests/baselines/reference/umd4.types +++ b/tests/baselines/reference/umd4.types @@ -33,5 +33,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : any +>Foo : typeof Foo diff --git a/tests/baselines/reference/umd6.symbols b/tests/baselines/reference/umd6.symbols index d08507f1ea2..958875b79eb 100644 --- a/tests/baselines/reference/umd6.symbols +++ b/tests/baselines/reference/umd6.symbols @@ -18,4 +18,5 @@ export = Thing; >Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15)) diff --git a/tests/baselines/reference/umd6.types b/tests/baselines/reference/umd6.types index 7318a43057a..5b1469cbd6c 100644 --- a/tests/baselines/reference/umd6.types +++ b/tests/baselines/reference/umd6.types @@ -19,5 +19,5 @@ export = Thing; >Thing : typeof Thing export as namespace Foo; ->Foo : any +>Foo : typeof Thing diff --git a/tests/baselines/reference/umd7.symbols b/tests/baselines/reference/umd7.symbols index 0b3ef17fb7b..19b56ed30f3 100644 --- a/tests/baselines/reference/umd7.symbols +++ b/tests/baselines/reference/umd7.symbols @@ -13,4 +13,5 @@ export = Thing; >Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 2, 15)) diff --git a/tests/baselines/reference/umd7.types b/tests/baselines/reference/umd7.types index 60782543710..d83e039b674 100644 --- a/tests/baselines/reference/umd7.types +++ b/tests/baselines/reference/umd7.types @@ -14,5 +14,5 @@ export = Thing; >Thing : () => number export as namespace Foo; ->Foo : any +>Foo : () => number diff --git a/tests/baselines/reference/umd8.symbols b/tests/baselines/reference/umd8.symbols index 8c38f267a2a..97da693b38f 100644 --- a/tests/baselines/reference/umd8.symbols +++ b/tests/baselines/reference/umd8.symbols @@ -22,4 +22,5 @@ export = Thing; >Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15)) diff --git a/tests/baselines/reference/umd8.types b/tests/baselines/reference/umd8.types index 0e66a49b963..ae3bdfd5fc8 100644 --- a/tests/baselines/reference/umd8.types +++ b/tests/baselines/reference/umd8.types @@ -23,5 +23,5 @@ export = Thing; >Thing : Thing export as namespace Foo; ->Foo : any +>Foo : typeof Thing diff --git a/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts b/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts new file mode 100644 index 00000000000..4177e154532 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts @@ -0,0 +1,13 @@ +/// + +// @Filename: 0.d.ts +//// export function doThing(): string; +//// export function doTheOtherThing(): void; + +//// export as namespace [|myLib|]; + +// @Filename: 1.ts +//// /// +//// [|myLib|].doThing(); + +verify.rangesReferenceEachOther(); diff --git a/tests/cases/fourslash/quickInfoForUMDModuleAlias.ts b/tests/cases/fourslash/quickInfoForUMDModuleAlias.ts new file mode 100644 index 00000000000..085ea33b874 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForUMDModuleAlias.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: 0.d.ts +//// export function doThing(): string; +//// export function doTheOtherThing(): void; + +//// export as namespace /*0*/myLib; + +// @Filename: 1.ts +//// /// +//// /*1*/myLib.doThing(); + +goTo.marker("0"); +verify.quickInfoIs("export namespace myLib"); + +goTo.marker("1"); +verify.quickInfoIs("export namespace myLib"); diff --git a/tests/cases/fourslash/renameAlias.ts b/tests/cases/fourslash/renameAlias.ts index e3f57ac7b41..e0408af656f 100644 --- a/tests/cases/fourslash/renameAlias.ts +++ b/tests/cases/fourslash/renameAlias.ts @@ -4,8 +4,8 @@ ////import [|M|] = SomeModule; ////import C = [|M|].SomeClass; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); } \ No newline at end of file diff --git a/tests/cases/fourslash/renameUMDModuleAlias1.ts b/tests/cases/fourslash/renameUMDModuleAlias1.ts new file mode 100644 index 00000000000..94aabcdbde5 --- /dev/null +++ b/tests/cases/fourslash/renameUMDModuleAlias1.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: 0.d.ts +//// export function doThing(): string; +//// export function doTheOtherThing(): void; + +//// export as namespace [|myLib|]; + +// @Filename: 1.ts +//// /// +//// [|myLib|].doThing(); + +const ranges = test.ranges() +for (const range of ranges) { + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameUMDModuleAlias2.ts b/tests/cases/fourslash/renameUMDModuleAlias2.ts new file mode 100644 index 00000000000..0daa4087b0d --- /dev/null +++ b/tests/cases/fourslash/renameUMDModuleAlias2.ts @@ -0,0 +1,14 @@ +/// + +// @Filename: 0.d.ts +//// export function doThing(): string; +//// export function doTheOtherThing(): void; + +//// export as namespace /**/[|myLib|]; + +// @Filename: 1.ts +//// /// +//// myLib.doThing(); + +goTo.marker(); +verify.renameInfoSucceeded("myLib"); \ No newline at end of file From cabd276ddcfe849f59b1ccfebc24b0d798dee062 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 5 Aug 2016 10:28:03 -0700 Subject: [PATCH 082/508] Fix more lint --- src/compiler/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 4c08d7a487c..f5cee2f8f8f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2137,7 +2137,7 @@ namespace ts { /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums /* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere - /* @internal */ isDiscardable?: boolean;// True if a Javascript class property can be overwritten by a method + /* @internal */ isDiscardable?: boolean; // True if a Javascript class property can be overwritten by a method } /* @internal */ From 02a79e3f81ce7e09ab41050cf4bb3068c1cfeae6 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 5 Aug 2016 13:50:21 -0700 Subject: [PATCH 083/508] Try using runtests-parallel for CI (#9970) * Try using runtests-parallel for CI * Put worker count setting into .travis.yml * Reduce worker count to 4 - 8 wasnt much different from 4-6 but had contention issues causing timeouts --- .travis.yml | 4 ++++ package.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 478e31c4398..cb9bf42225a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,16 @@ node_js: sudo: false +env: + - workerCount=4 + matrix: fast_finish: true include: - os: osx node_js: stable osx_image: xcode7.3 + env: workerCount=2 branches: only: diff --git a/package.json b/package.json index 5606a423a0e..9f3122c3374 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ }, "scripts": { "pretest": "jake tests", - "test": "jake runtests", + "test": "jake runtests-parallel", "build": "npm run build:compiler && npm run build:tests", "build:compiler": "jake local", "build:tests": "jake tests", From 269b8285387f5a7fdf1a2d2aafa40e96a425576d Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 5 Aug 2016 14:16:29 -0700 Subject: [PATCH 084/508] Fix lssl task (#9967) --- Gulpfile.ts | 4 ++-- Jakefile.js | 6 +++--- src/server/tsconfig.library.json | 2 ++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 6c91ef52cbb..b9b5d2068b2 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -449,7 +449,7 @@ gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { }); gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]); -gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON]); +gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]); gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]); @@ -503,7 +503,7 @@ gulp.task("VerifyLKG", false, [], () => { return gulp.src(expectedFiles).pipe(gulp.dest(LKGDirectory)); }); -gulp.task("LKGInternal", false, ["lib", "local", "lssl"]); +gulp.task("LKGInternal", false, ["lib", "local"]); gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUseDebugMode"], () => { return runSequence("LKGInternal", "VerifyLKG"); diff --git a/Jakefile.js b/Jakefile.js index 174be5e702f..a5650a56b16 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -551,7 +551,7 @@ var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibr compileFile( tsserverLibraryFile, languageServiceLibrarySources, - [builtLocalDirectory, copyright].concat(languageServiceLibrarySources), + [builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { noOutFile: false, generateDeclarations: true }); @@ -562,7 +562,7 @@ task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]); // Local target to build the compiler and services desc("Builds the full compiler and services"); -task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON]); +task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl"]); // Local target to build only tsc.js desc("Builds only the compiler"); @@ -617,7 +617,7 @@ task("generate-spec", [specMd]); // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory desc("Makes a new LKG out of the built js files"); -task("LKG", ["clean", "release", "local", "lssl"].concat(libraryTargets), function() { +task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() { var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets); var missingFiles = expectedFiles.filter(function (f) { return !fs.existsSync(f); diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 746283720bf..af04a74d557 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -10,6 +10,8 @@ "types": [] }, "files": [ + "../services/shims.ts", + "../services/utilities.ts", "editorServices.ts", "protocol.d.ts", "session.ts" From 46f5e5fad14785023e022c88ef09c1637ad5f5f8 Mon Sep 17 00:00:00 2001 From: gcnew Date: Sat, 6 Aug 2016 01:10:02 +0300 Subject: [PATCH 085/508] Surface noErrorTruncation option --- src/compiler/commandLineParser.ts | 5 +++++ src/compiler/diagnosticMessages.json | 4 ++++ .../reference/noErrorTruncation.errors.txt | 22 +++++++++++++++++++ .../baselines/reference/noErrorTruncation.js | 21 ++++++++++++++++++ tests/cases/compiler/noErrorTruncation.ts | 15 +++++++++++++ 5 files changed, 67 insertions(+) create mode 100644 tests/baselines/reference/noErrorTruncation.errors.txt create mode 100644 tests/baselines/reference/noErrorTruncation.js create mode 100644 tests/cases/compiler/noErrorTruncation.ts diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7e2c6eb8d33..c1408187d88 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -126,6 +126,11 @@ namespace ts { type: "boolean", description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, + { + name: "noErrorTruncation", + type: "boolean", + description: Diagnostics.Do_not_truncate_verbose_types, + }, { name: "noImplicitAny", type: "boolean", diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8126d5c605e..e3ac2d78c63 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2828,6 +2828,10 @@ "category": "Message", "code": 6137 }, + "Do not truncate verbose types.": { + "category": "Message", + "code": 6138 + }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 diff --git a/tests/baselines/reference/noErrorTruncation.errors.txt b/tests/baselines/reference/noErrorTruncation.errors.txt new file mode 100644 index 00000000000..d27fad84e50 --- /dev/null +++ b/tests/baselines/reference/noErrorTruncation.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type 'number' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. + + +==== tests/cases/compiler/noErrorTruncation.ts (1 errors) ==== + // @noErrorTruncation + + type SomeLongOptionA = { someLongOptionA: string } + type SomeLongOptionB = { someLongOptionB: string } + type SomeLongOptionC = { someLongOptionC: string } + type SomeLongOptionD = { someLongOptionD: string } + type SomeLongOptionE = { someLongOptionE: string } + type SomeLongOptionF = { someLongOptionF: string } + + const x: SomeLongOptionA + ~ +!!! error TS2322: Type 'number' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42; + \ No newline at end of file diff --git a/tests/baselines/reference/noErrorTruncation.js b/tests/baselines/reference/noErrorTruncation.js new file mode 100644 index 00000000000..70bbc6bd8dc --- /dev/null +++ b/tests/baselines/reference/noErrorTruncation.js @@ -0,0 +1,21 @@ +//// [noErrorTruncation.ts] +// @noErrorTruncation + +type SomeLongOptionA = { someLongOptionA: string } +type SomeLongOptionB = { someLongOptionB: string } +type SomeLongOptionC = { someLongOptionC: string } +type SomeLongOptionD = { someLongOptionD: string } +type SomeLongOptionE = { someLongOptionE: string } +type SomeLongOptionF = { someLongOptionF: string } + +const x: SomeLongOptionA + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42; + + +//// [noErrorTruncation.js] +// @noErrorTruncation +var x = 42; diff --git a/tests/cases/compiler/noErrorTruncation.ts b/tests/cases/compiler/noErrorTruncation.ts new file mode 100644 index 00000000000..5bd6ecf1d74 --- /dev/null +++ b/tests/cases/compiler/noErrorTruncation.ts @@ -0,0 +1,15 @@ +// @noErrorTruncation + +type SomeLongOptionA = { someLongOptionA: string } +type SomeLongOptionB = { someLongOptionB: string } +type SomeLongOptionC = { someLongOptionC: string } +type SomeLongOptionD = { someLongOptionD: string } +type SomeLongOptionE = { someLongOptionE: string } +type SomeLongOptionF = { someLongOptionF: string } + +const x: SomeLongOptionA + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42; From ecdbdb33af5b360427d15635a4826556ce93f472 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 5 Aug 2016 17:42:52 -0700 Subject: [PATCH 086/508] Fixing the filtering of nested module completions --- src/services/services.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 6cb92547998..1a952491365 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4728,30 +4728,33 @@ namespace ts { function enumeratePotentialNonRelativeModules(fragment: string, scriptPath: string, options: CompilerOptions): string[] { // Check If this is a nested module - const isNestedModule = fragment.indexOf(directorySeparator) !== -1 ; + const isNestedModule = fragment.indexOf(directorySeparator) !== -1; + const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; // Get modules that the type checker picked up const ambientModules = ts.map(program.getTypeChecker().getAmbientModules(), sym => stripQuotes(sym.name)); let nonRelativeModules = ts.filter(ambientModules, moduleName => startsWith(moduleName, fragment)); // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because editors insert the completion - // only after that character - nonRelativeModules = ts.map(nonRelativeModules, moduleName => { - if (moduleName.indexOf(directorySeparator) !== -1) { - if (isNestedModule) { - return moduleName.substr(fragment.lastIndexOf(directorySeparator) + 1); + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + const moduleNameWithSeperator = ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, moduleName => { + if (startsWith(fragment, moduleNameWithSeperator)) { + return moduleName.substr(moduleNameWithSeperator.length); } - } - return moduleName; - }); + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { forEach(enumerateNodeModulesVisibleToScript(host, scriptPath), visibleModule => { if (!isNestedModule) { nonRelativeModules.push(visibleModule.moduleName); } - else { + else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); forEach(nestedFiles, (f) => { From e11d5e9de632bdd93a26eb2133050d4934aec1c8 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 5 Aug 2016 17:53:04 -0700 Subject: [PATCH 087/508] Cleaning up test cases and adding a few more --- .../completionForStringLiteralImport1.ts | 2 + .../completionForStringLiteralImport2.ts | 2 + ...etionForStringLiteralNonrelativeImport1.ts | 2 + ...tionForStringLiteralNonrelativeImport10.ts | 2 + ...tionForStringLiteralNonrelativeImport11.ts | 38 ++++++++++++ ...etionForStringLiteralNonrelativeImport2.ts | 2 + ...etionForStringLiteralNonrelativeImport3.ts | 3 + ...etionForStringLiteralNonrelativeImport4.ts | 2 + ...etionForStringLiteralNonrelativeImport5.ts | 2 + ...etionForStringLiteralNonrelativeImport6.ts | 62 ------------------- ...etionForStringLiteralNonrelativeImport7.ts | 3 + ...etionForStringLiteralNonrelativeImport8.ts | 2 + ...etionForStringLiteralNonrelativeImport9.ts | 2 + ...rStringLiteralNonrelativeImportTypings1.ts | 2 + ...rStringLiteralNonrelativeImportTypings2.ts | 2 + ...rStringLiteralNonrelativeImportTypings3.ts | 2 + ...mpletionForStringLiteralRelativeImport1.ts | 2 + ...mpletionForStringLiteralRelativeImport2.ts | 3 + ...mpletionForStringLiteralRelativeImport3.ts | 2 + ...mpletionForStringLiteralRelativeImport4.ts | 2 + .../completionForTripleSlashReference1.ts | 2 + .../completionForTripleSlashReference2.ts | 3 + .../completionForTripleSlashReference3.ts | 2 + .../completionForTripleSlashReference4.ts | 43 +++++++++++++ 24 files changed, 127 insertions(+), 62 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts delete mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts create mode 100644 tests/cases/fourslash/completionForTripleSlashReference4.ts diff --git a/tests/cases/fourslash/completionForStringLiteralImport1.ts b/tests/cases/fourslash/completionForStringLiteralImport1.ts index 5fcb3e42f1a..482726f6305 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport1.ts @@ -1,5 +1,7 @@ /// +// Should define spans for replacement that appear after the last directory seperator in import statements + // @typeRoots: my_typings // @Filename: test.ts diff --git a/tests/cases/fourslash/completionForStringLiteralImport2.ts b/tests/cases/fourslash/completionForStringLiteralImport2.ts index 2910d9e1475..43896f1f392 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport2.ts @@ -1,5 +1,7 @@ /// +// Should define spans for replacement that appear after the last directory seperator in triple slash references + // @typeRoots: my_typings // @Filename: test.ts diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts index f8ea68a271c..d6f38431ce1 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts @@ -1,5 +1,7 @@ /// +// Should give completions for node modules and files within those modules with ts file extensions + // @Filename: tests/test0.ts //// import * as foo1 from "f/*import_as0*/ //// import * as foo2 from "fake-module//*import_as1*/ diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts index 393ffed0c52..aa9fd976644 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts @@ -1,5 +1,7 @@ /// +// Should not give node module completions if classic module resolution is enabled + // @moduleResolution: classic // @Filename: dir1/dir2/dir3/dir4/test0.ts diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts new file mode 100644 index 00000000000..70d39182a8a --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts @@ -0,0 +1,38 @@ +/// + +// Should handle nested files in folders discovered via the baseUrl compiler option + +// @baseUrl: tests/cases/fourslash/modules + +// @Filename: tests/test0.ts +//// import * as foo1 from "subfolder//*import_as0*/ +//// import foo2 = require("subfolder//*import_equals0*/ +//// var foo3 = require("subfolder//*require0*/ + +//// import * as foo1 from "module-from-node//*import_as1*/ +//// import foo2 = require("module-from-node//*import_equals1*/ +//// var foo3 = require("module-from-node//*require1*/ + +// @Filename: modules/subfolder/module.ts +//// export var x = 5; + +// @Filename: package.json +//// { "dependencies": { "module-from-node": "latest" } } +// @Filename: node_modules/module-from-node/index.ts +//// /*module1*/ + + + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + + verify.importModuleCompletionListContains("module"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + + goTo.marker(kind + "1"); + + verify.importModuleCompletionListContains("index"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); +} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts index 08b92b05295..bc2529e86f9 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts @@ -1,5 +1,7 @@ /// +// Should not give duplicate entries for similarly named files with different extensions + // @Filename: tests/test0.ts //// import * as foo1 from "fake-module//*import_as0*/ //// import foo2 = require("fake-module//*import_equals0*/ diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts index 9d9beac16e7..9b1fd451185 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts @@ -1,4 +1,7 @@ /// + +// Should give completions for js files in node modules when allowJs is set to true + // @allowJs: true // @Filename: tests/test0.ts diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index ef926a7c8ad..b9be9f90213 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -1,5 +1,7 @@ /// +// Should give completions for all node modules visible to the script + // @Filename: dir1/dir2/dir3/dir4/test0.ts //// import * as foo1 from "f/*import_as0*/ //// import foo4 = require("f/*import_equals0*/ diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts index 9e0c756a919..4afa5854bf8 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts @@ -1,5 +1,7 @@ /// +// Should give completions for ambiently declared modules + // @Filename: test0.ts //// /// //// /// diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts deleted file mode 100644 index c430310a217..00000000000 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport6.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// - -// @Filename: tests/test0.ts -//// import * as foo1 from "module-/*import_as0*/ -//// import foo2 = require("module-/*import_equals0*/ -//// var foo3 = require("module-/*require0*/ - -// @Filename: package.json -//// { "dependencies": { -//// "module-no-main": "latest", -//// "module-no-main-index-d-ts": "latest", -//// "module-index-ts": "latest", -//// "module-index-d-ts-explicit-main": "latest", -//// "module-index-d-ts-default-main": "latest", -//// "module-typings": "latest" -//// } } - -// @Filename: node_modules/module-no-main/package.json -//// { } - -// @Filename: node_modules/module-no-main-index-d-ts/package.json -//// { } -// @Filename: node_modules/module-no-main-index-d-ts/index.d.ts -//// /*module-no-main-index-d-ts*/ - -// @Filename: node_modules/module-index-ts/package.json -//// { } -// @Filename: node_modules/module-index-ts/index.ts -//// /*module-index-ts*/ - -// @Filename: node_modules/module-index-d-ts-explicit-main/package.json -//// { "main":"./notIndex.js" } -// @Filename: node_modules/module-index-d-ts-explicit-main/notIndex.js -//// /*module-index-d-ts-explicit-main*/ -// @Filename: node_modules/module-index-d-ts-explicit-main/index.d.ts -//// /*module-index-d-ts-explicit-main2*/ - -// @Filename: node_modules/module-index-d-ts-default-main/package.json -//// { } -// @Filename: node_modules/module-index-d-ts-default-main/index.js -//// /*module-index-d-ts-default-main*/ -// @Filename: node_modules/module-index-d-ts-default-main/index.d.ts -//// /*module-index-d-ts-default-main2*/ - -// @Filename: node_modules/module-typings/package.json -//// { "typings":"./types.d.ts" } -// @Filename: node_modules/module-typings/types.d.ts -//// /*module-typings*/ - -const kinds = ["import_as", "import_equals", "require"]; - -for (const kind of kinds) { - goTo.marker(kind + "0"); - - verify.importModuleCompletionListContains("module-no-main"); - verify.importModuleCompletionListContains("module-no-main-index-d-ts"); - verify.importModuleCompletionListContains("module-index-ts"); - verify.importModuleCompletionListContains("module-index-d-ts-explicit-main"); - verify.importModuleCompletionListContains("module-index-d-ts-default-main"); - verify.importModuleCompletionListContains("module-typings"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); -} diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts index d08ebd17b73..eca5a3e5412 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts @@ -1,4 +1,7 @@ /// + +// Should give completions for files that are discovered via the baseUrl compiler option + // @baseUrl: tests/cases/fourslash/modules // @Filename: tests/test0.ts diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts index b7e745f814e..54893991432 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts @@ -1,5 +1,7 @@ /// +// Should give completions for modules referenced via baseUrl and paths compiler options with wildcards + // @Filename: tsconfig.json //// { //// "compilerOptions": { diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts index 31984df9081..bcdb731d1f1 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts @@ -1,5 +1,7 @@ /// +// Should give completions for modules referenced via baseUrl and paths compiler options with explicit name mappings + // @Filename: tsconfig.json //// { //// "compilerOptions": { diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts index 1b77c57f5ca..9cf2af9c875 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts @@ -1,5 +1,7 @@ /// +// Should give completions for typings discovered via the typeRoots compiler option + // @typeRoots: my_typings,my_other_typings diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts index 3e991b3d4b4..1452c6c1c61 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts @@ -1,5 +1,7 @@ /// +// Should respect the types compiler option when giving completions + // @typeRoots: my_typings,my_other_typings // @types: module-x,module-z diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts index add1238cefc..f4a4dbaaa99 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts @@ -1,5 +1,7 @@ /// +// Should give completions for typings discovered in all visible @types directories + // @Filename: subdirectory/test0.ts //// /// //// import * as foo1 from "m/*import_as0*/ diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts index 3257dff40af..909e2c6b14d 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts @@ -1,5 +1,7 @@ /// +// Should give completions for ts files when allowJs is false + // @Filename: test0.ts //// import * as foo1 from "./*import_as0*/ //// import * as foo2 from ".//*import_as1*/ diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts index 72b28d39b87..8c8cb405cd3 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts @@ -1,4 +1,7 @@ /// + +// Should give completions for ts and js files when allowJs is true + // @allowJs: true // @Filename: test0.ts diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts index 95e4e51577a..a2035ee7fdb 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -1,5 +1,7 @@ /// +// Should give completions for absolute paths + // @Filename: tests/test0.ts //// import * as foo1 from "c:/tests/cases/f/*import_as0*/ //// import * as foo2 from "c:/tests/cases/fourslash/*import_as1*/ diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index f89eaa567ad..df30b925d11 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -1,5 +1,7 @@ /// +// Should give completions for directories that are merged via the rootDirs compiler option + // @rootDirs: sub/src1,src2 // @Filename: src2/test0.ts diff --git a/tests/cases/fourslash/completionForTripleSlashReference1.ts b/tests/cases/fourslash/completionForTripleSlashReference1.ts index 66dfa5f93c2..f8ea7fc4d44 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference1.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference1.ts @@ -1,5 +1,7 @@ /// +// Should give completions for relative references to ts files when allowJs is false + // @Filename: test0.ts //// /// + +// Should give completions for relative references to js and ts files when allowJs is true + // @allowJs: true // @Filename: test0.ts diff --git a/tests/cases/fourslash/completionForTripleSlashReference3.ts b/tests/cases/fourslash/completionForTripleSlashReference3.ts index af8d49d9df3..2f92de19a21 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference3.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference3.ts @@ -1,5 +1,7 @@ /// +// Should give completions for absolute paths + // @Filename: tests/test0.ts //// /// Date: Fri, 5 Aug 2016 21:45:13 -0700 Subject: [PATCH 088/508] [Transforms] Merge master on 08/05 (#10182) * Fix #10083 - allowSyntheticDefaultImports alters getExternalModuleMember (#10096) * Add a helper function `getOrUpdateProperty` to prevent unprotected access to Maps. * Limit type guards as assertions to incomplete types in loops * Accept new baselines * Fix linting error * [Release-2.0] Fix 9662: Visual Studio 2015 with TS2.0 gives incorrect @types path resolution errors (#9867) * Change the shape of the shim layer to support getAutomaticTypeDirectives * Change the key for looking up automatic type-directives * Update baselines from change look-up name of type-directives * Add @currentDirectory into the test * Update baselines * Fix linting error * Address PR: fix spelling mistake * Instead of return path of the type directive names just return type directive names * Remove unused reference files: these tests produce erros so they will not produce these files (#9233) * Don't allow properties inherited from Object to be automatically included in TSX attributes * Port PR #10016 to Master (#10100) * Treat namespaceExportDeclaration as declaration * Update baselines * wip - add tests * Add tests * Show "export namespace" for quick-info * Update baselines from merging --- src/compiler/checker.ts | 86 ++-- src/compiler/core.ts | 8 +- src/compiler/program.ts | 19 +- src/compiler/types.ts | 11 + src/compiler/utilities.ts | 8 +- src/services/services.ts | 11 +- src/services/shims.ts | 35 +- .../allowSyntheticDefaultImports10.errors.txt | 17 + .../allowSyntheticDefaultImports10.js | 17 + .../allowSyntheticDefaultImports7.js | 29 ++ .../allowSyntheticDefaultImports7.symbols | 22 + .../allowSyntheticDefaultImports7.types | 24 + .../allowSyntheticDefaultImports8.errors.txt | 14 + .../allowSyntheticDefaultImports8.js | 29 ++ .../allowSyntheticDefaultImports9.js | 17 + .../allowSyntheticDefaultImports9.symbols | 22 + .../allowSyntheticDefaultImports9.types | 24 + .../discriminatedUnionTypes1.symbols | 402 --------------- .../reference/discriminatedUnionTypes1.types | 465 ------------------ tests/baselines/reference/exportToString.js | 9 + .../reference/exportToString.symbols | 7 + .../baselines/reference/exportToString.types | 8 + .../reference/library-reference-13.trace.json | 2 +- .../reference/library-reference-14.trace.json | 2 +- .../reference/library-reference-15.trace.json | 2 +- .../reference/library-reference-2.trace.json | 2 +- .../reference/library-reference-6.trace.json | 2 +- .../stringLiteralTypesAndTuples01.types | 2 +- .../tsxAttributeResolution5.errors.txt | 7 +- .../reference/tsxAttributeResolution5.js | 4 +- .../typeGuardTautologicalConsistiency.types | 4 +- .../reference/typeGuardTypeOfUndefined.types | 6 +- .../reference/typeGuardsAsAssertions.types | 12 +- .../typeGuardsInIfStatement.errors.txt | 5 +- .../reference/typeReferenceDirectives1.js | 1 - .../typeReferenceDirectives1.symbols | 3 +- .../reference/typeReferenceDirectives1.types | 1 - .../reference/umd-augmentation-1.symbols | 1 + .../reference/umd-augmentation-1.types | 2 +- .../reference/umd-augmentation-2.symbols | 1 + .../reference/umd-augmentation-2.types | 2 +- .../reference/umd-augmentation-3.symbols | 1 + .../reference/umd-augmentation-3.types | 2 +- .../reference/umd-augmentation-4.symbols | 1 + .../reference/umd-augmentation-4.types | 2 +- tests/baselines/reference/umd1.symbols | 1 + tests/baselines/reference/umd1.types | 2 +- tests/baselines/reference/umd3.symbols | 1 + tests/baselines/reference/umd3.types | 2 +- tests/baselines/reference/umd4.symbols | 1 + tests/baselines/reference/umd4.types | 2 +- tests/baselines/reference/umd6.symbols | 1 + tests/baselines/reference/umd6.types | 2 +- tests/baselines/reference/umd7.symbols | 1 + tests/baselines/reference/umd7.types | 2 +- tests/baselines/reference/umd8.symbols | 1 + tests/baselines/reference/umd8.types | 2 +- .../allowSyntheticDefaultImports10.ts | 11 + .../compiler/allowSyntheticDefaultImports7.ts | 10 + .../compiler/allowSyntheticDefaultImports8.ts | 11 + .../compiler/allowSyntheticDefaultImports9.ts | 11 + tests/cases/compiler/exportToString.ts | 2 + .../compiler/typeReferenceDirectives1.ts | 2 +- .../compiler/typeReferenceDirectives10.ts | 1 + .../compiler/typeReferenceDirectives11.ts | 1 + .../compiler/typeReferenceDirectives12.ts | 1 + .../compiler/typeReferenceDirectives13.ts | 1 + .../compiler/typeReferenceDirectives2.ts | 1 + .../compiler/typeReferenceDirectives3.ts | 1 + .../compiler/typeReferenceDirectives4.ts | 1 + .../compiler/typeReferenceDirectives5.ts | 1 + .../compiler/typeReferenceDirectives6.ts | 1 + .../compiler/typeReferenceDirectives7.ts | 1 + .../compiler/typeReferenceDirectives8.ts | 1 + .../compiler/typeReferenceDirectives9.ts | 1 + .../jsx/tsxAttributeResolution5.tsx | 2 +- .../references/library-reference-13.ts | 1 + .../conformance/typings/typingsLookup1.ts | 1 + .../findAllRefsForUMDModuleAlias1.ts | 13 + .../fourslash/quickInfoForUMDModuleAlias.ts | 17 + tests/cases/fourslash/renameAlias.ts | 8 +- .../cases/fourslash/renameUMDModuleAlias1.ts | 17 + .../cases/fourslash/renameUMDModuleAlias2.ts | 14 + 83 files changed, 535 insertions(+), 966 deletions(-) create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports10.js create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports7.js create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports7.symbols create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports7.types create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports8.errors.txt create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports8.js create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports9.js create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports9.symbols create mode 100644 tests/baselines/reference/allowSyntheticDefaultImports9.types delete mode 100644 tests/baselines/reference/discriminatedUnionTypes1.symbols delete mode 100644 tests/baselines/reference/discriminatedUnionTypes1.types create mode 100644 tests/baselines/reference/exportToString.js create mode 100644 tests/baselines/reference/exportToString.symbols create mode 100644 tests/baselines/reference/exportToString.types create mode 100644 tests/cases/compiler/allowSyntheticDefaultImports10.ts create mode 100644 tests/cases/compiler/allowSyntheticDefaultImports7.ts create mode 100644 tests/cases/compiler/allowSyntheticDefaultImports8.ts create mode 100644 tests/cases/compiler/allowSyntheticDefaultImports9.ts create mode 100644 tests/cases/compiler/exportToString.ts create mode 100644 tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts create mode 100644 tests/cases/fourslash/quickInfoForUMDModuleAlias.ts create mode 100644 tests/cases/fourslash/renameUMDModuleAlias1.ts create mode 100644 tests/cases/fourslash/renameUMDModuleAlias2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f87f8bea2b7..0a5173efece 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -216,7 +216,7 @@ namespace ts { const flowLoopKeys: string[] = []; const flowLoopTypes: Type[][] = []; const visitedFlowNodes: FlowNode[] = []; - const visitedFlowTypes: Type[] = []; + const visitedFlowTypes: FlowType[] = []; const potentialThisCollisions: Node[] = []; const awaitedTypeStack: number[] = []; @@ -1136,6 +1136,10 @@ namespace ts { else { symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } + // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default + if (!symbolFromVariable && allowSyntheticDefaultImports && name.text === "default") { + symbolFromVariable = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); const symbolFromModule = getExportOfModule(targetSymbol, name.text); @@ -8094,6 +8098,18 @@ namespace ts { f(type) ? type : neverType; } + function isIncomplete(flowType: FlowType) { + return flowType.flags === 0; + } + + function getTypeFromFlowType(flowType: FlowType) { + return flowType.flags === 0 ? (flowType).type : flowType; + } + + function createFlowType(type: Type, incomplete: boolean): FlowType { + return incomplete ? { flags: 0, type } : type; + } + function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, includeOuterFunctions: boolean) { let key: string; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) { @@ -8101,14 +8117,14 @@ namespace ts { } const initialType = assumeInitialized ? declaredType : includeFalsyTypes(declaredType, TypeFlags.Undefined); const visitedFlowStart = visitedFlowCount; - const result = getTypeAtFlowNode(reference.flowNode); + const result = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; if (reference.parent.kind === SyntaxKind.NonNullExpression && getTypeWithFacts(result, TypeFacts.NEUndefinedOrNull) === neverType) { return declaredType; } return result; - function getTypeAtFlowNode(flow: FlowNode): Type { + function getTypeAtFlowNode(flow: FlowNode): FlowType { while (true) { if (flow.flags & FlowFlags.Shared) { // We cache results of flow type resolution for shared nodes that were previously visited in @@ -8120,7 +8136,7 @@ namespace ts { } } } - let type: Type; + let type: FlowType; if (flow.flags & FlowFlags.Assignment) { type = getTypeAtFlowAssignment(flow); if (!type) { @@ -8188,41 +8204,44 @@ namespace ts { return undefined; } - function getTypeAtFlowCondition(flow: FlowCondition) { - let type = getTypeAtFlowNode(flow.antecedent); + function getTypeAtFlowCondition(flow: FlowCondition): FlowType { + const flowType = getTypeAtFlowNode(flow.antecedent); + let type = getTypeFromFlowType(flowType); if (type !== neverType) { // If we have an antecedent type (meaning we're reachable in some way), we first - // attempt to narrow the antecedent type. If that produces the nothing type, then - // we take the type guard as an indication that control could reach here in a - // manner not understood by the control flow analyzer (e.g. a function argument - // has an invalid type, or a nested function has possibly made an assignment to a - // captured variable). We proceed by reverting to the declared type and then + // attempt to narrow the antecedent type. If that produces the never type, and if + // the antecedent type is incomplete (i.e. a transient type in a loop), then we + // take the type guard as an indication that control *could* reach here once we + // have the complete type. We proceed by reverting to the declared type and then // narrow that. const assumeTrue = (flow.flags & FlowFlags.TrueCondition) !== 0; type = narrowType(type, flow.expression, assumeTrue); - if (type === neverType) { + if (type === neverType && isIncomplete(flowType)) { type = narrowType(declaredType, flow.expression, assumeTrue); } } - return type; + return createFlowType(type, isIncomplete(flowType)); } - function getTypeAtSwitchClause(flow: FlowSwitchClause) { - const type = getTypeAtFlowNode(flow.antecedent); + function getTypeAtSwitchClause(flow: FlowSwitchClause): FlowType { + const flowType = getTypeAtFlowNode(flow.antecedent); + let type = getTypeFromFlowType(flowType); const expr = flow.switchStatement.expression; if (isMatchingReference(reference, expr)) { - return narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); + type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - if (isMatchingPropertyAccess(expr)) { - return narrowTypeByDiscriminant(type, expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); + else if (isMatchingPropertyAccess(expr)) { + type = narrowTypeByDiscriminant(type, expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); } - return type; + return createFlowType(type, isIncomplete(flowType)); } - function getTypeAtFlowBranchLabel(flow: FlowLabel) { + function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType { const antecedentTypes: Type[] = []; + let seenIncomplete = false; for (const antecedent of flow.antecedents) { - const type = getTypeAtFlowNode(antecedent); + const flowType = getTypeAtFlowNode(antecedent); + const type = getTypeFromFlowType(flowType); // If the type at a particular antecedent path is the declared type and the // reference is known to always be assigned (i.e. when declared and initial types // are the same), there is no reason to process more antecedents since the only @@ -8233,11 +8252,14 @@ namespace ts { if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); } + if (isIncomplete(flowType)) { + seenIncomplete = true; + } } - return getUnionType(antecedentTypes); + return createFlowType(getUnionType(antecedentTypes), seenIncomplete); } - function getTypeAtFlowLoopLabel(flow: FlowLabel) { + function getTypeAtFlowLoopLabel(flow: FlowLabel): FlowType { // If we have previously computed the control flow type for the reference at // this flow loop junction, return the cached type. const id = getFlowNodeId(flow); @@ -8249,12 +8271,12 @@ namespace ts { return cache[key]; } // If this flow loop junction and reference are already being processed, return - // the union of the types computed for each branch so far. We should never see - // an empty array here because the first antecedent of a loop junction is always - // the non-looping control flow path that leads to the top. + // the union of the types computed for each branch so far, marked as incomplete. + // We should never see an empty array here because the first antecedent of a loop + // junction is always the non-looping control flow path that leads to the top. for (let i = flowLoopStart; i < flowLoopCount; i++) { if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key) { - return getUnionType(flowLoopTypes[i]); + return createFlowType(getUnionType(flowLoopTypes[i]), /*incomplete*/ true); } } // Add the flow loop junction and reference to the in-process stack and analyze @@ -8265,7 +8287,7 @@ namespace ts { flowLoopTypes[flowLoopCount] = antecedentTypes; for (const antecedent of flow.antecedents) { flowLoopCount++; - const type = getTypeAtFlowNode(antecedent); + const type = getTypeFromFlowType(getTypeAtFlowNode(antecedent)); flowLoopCount--; // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up @@ -10068,7 +10090,7 @@ namespace ts { for (const prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type - if (!nameTable[prop.name]) { + if (!hasProperty(nameTable, prop.name)) { const targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { const msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); @@ -10414,7 +10436,7 @@ namespace ts { const targetProperties = getPropertiesOfType(targetAttributesType); for (let i = 0; i < targetProperties.length; i++) { if (!(targetProperties[i].flags & SymbolFlags.Optional) && - nameTable[targetProperties[i].name] === undefined) { + !hasProperty(nameTable, targetProperties[i].name)) { error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); } @@ -19845,7 +19867,7 @@ namespace ts { } function checkGrammarTopLevelElementForRequiredDeclareModifier(node: Node): boolean { - // A declare modifier is required for any top level .d.ts declaration except export=, export default, + // A declare modifier is required for any top level .d.ts declaration except export=, export default, export as namespace // interfaces and imports categories: // // DeclarationElement: @@ -19863,8 +19885,8 @@ namespace ts { node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.ExportDeclaration || node.kind === SyntaxKind.ExportAssignment || + node.kind === SyntaxKind.NamespaceExportDeclaration || getModifierFlags(node) & (ModifierFlags.Ambient | ModifierFlags.Export | ModifierFlags.Default)) { - return false; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b11484f3c68..064f68849c6 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -499,8 +499,12 @@ namespace ts { return keys; } - export function getProperty(map: Map, key: string): T { - return hasOwnProperty.call(map, key) ? map[key] : undefined; + export function getProperty(map: Map, key: string): T | undefined { + return hasProperty(map, key) ? map[key] : undefined; + } + + export function getOrUpdateProperty(map: Map, key: string, makeValue: () => T): T { + return hasProperty(map, key) ? map[key] : map[key] = makeValue(); } export function isEmpty(map: Map) { diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 90201a06987..58468bec628 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1056,19 +1056,15 @@ namespace ts { return resolutions; } - function getInferredTypesRoot(options: CompilerOptions, rootFiles: string[], host: CompilerHost) { - return computeCommonSourceDirectoryOfFilenames(rootFiles, host.getCurrentDirectory(), f => host.getCanonicalFileName(f)); - } - /** - * Given a set of options and a set of root files, returns the set of type directive names + * Given a set of options, returns the set of type directive names * that should be included for this program automatically. * This list could either come from the config file, * or from enumerating the types root + initial secondary types lookup location. * More type directives might appear in the program later as a result of loading actual source files; * this list is only the set of defaults that are implicitly included. */ - export function getAutomaticTypeDirectiveNames(options: CompilerOptions, rootFiles: string[], host: CompilerHost): string[] { + export function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[] { // Use explicit type list from tsconfig.json if (options.types) { return options.types; @@ -1081,7 +1077,10 @@ namespace ts { if (typeRoots) { for (const root of typeRoots) { if (host.directoryExists(root)) { - result = result.concat(host.getDirectories(root)); + for (const typeDirectivePath of host.getDirectories(root)) { + // Return just the type directive names + result = result.concat(getBaseFileName(normalizePath(typeDirectivePath))); + } } } } @@ -1156,11 +1155,11 @@ namespace ts { forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false)); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders - const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, rootNames, host); + const typeReferences: string[] = getAutomaticTypeDirectiveNames(options, host); if (typeReferences) { - const inferredRoot = getInferredTypesRoot(options, rootNames, host); - const containingFilename = combinePaths(inferredRoot, "__inferred type names__.ts"); + // This containingFilename needs to match with the one used in managed-side + const containingFilename = combinePaths(host.getCurrentDirectory(), "__inferred type names__.ts"); const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename); for (let i = 0; i < typeReferences.length; i++) { processTypeReferenceDirective(typeReferences[i], resolutions[i]); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0b8f04ed32a..fc64ba6be8b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1680,6 +1680,16 @@ namespace ts { antecedent: FlowNode; } + export type FlowType = Type | IncompleteType; + + // Incomplete types occur during control flow analysis of loops. An IncompleteType + // is distinguished from a regular type by a flags value of zero. Incomplete type + // objects are internal to the getFlowTypeOfRefecence function and never escape it. + export interface IncompleteType { + flags: TypeFlags; // No flags set + type: Type; // The type marked incomplete + } + export interface AmdDependency { path: string; name: string; @@ -2978,6 +2988,7 @@ namespace ts { directoryExists?(directoryName: string): boolean; realpath?(path: string): string; getCurrentDirectory?(): string; + getDirectories?(path: string): string[]; } export interface ResolvedModule { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 188ba2ccae0..a5848668bf0 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -3521,12 +3521,7 @@ namespace ts { // export { x, y } for (const specifier of (node).exportClause.elements) { const name = (specifier.propertyName || specifier.name).text; - if (!exportSpecifiers[name]) { - exportSpecifiers[name] = [specifier]; - } - else { - exportSpecifiers[name].push(specifier); - } + getOrUpdateProperty(exportSpecifiers, name, () => []).push(specifier); } } break; @@ -3965,6 +3960,7 @@ namespace ts { || kind === SyntaxKind.MethodDeclaration || kind === SyntaxKind.MethodSignature || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.NamespaceExportDeclaration || kind === SyntaxKind.NamespaceImport || kind === SyntaxKind.Parameter || kind === SyntaxKind.PropertyAssignment diff --git a/src/services/services.ts b/src/services/services.ts index c09eb21b959..86661bd5503 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1891,7 +1891,7 @@ namespace ts { }; } - // Cache host information about scrip Should be refreshed + // Cache host information about script should be refreshed // at each language service public entry point, since we don't know when // set of scripts handled by the host changes. class HostCache { @@ -4835,7 +4835,14 @@ namespace ts { } if (symbolFlags & SymbolFlags.Alias) { addNewLineIfDisplayPartsExist(); - displayParts.push(keywordPart(SyntaxKind.ImportKeyword)); + if (symbol.declarations[0].kind === SyntaxKind.NamespaceExportDeclaration) { + displayParts.push(keywordPart(SyntaxKind.ExportKeyword)); + displayParts.push(spacePart()); + displayParts.push(keywordPart(SyntaxKind.NamespaceKeyword)); + } + else { + displayParts.push(keywordPart(SyntaxKind.ImportKeyword)); + } displayParts.push(spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, declaration => { diff --git a/src/services/shims.ts b/src/services/shims.ts index 271d6f2d6e2..45c4b284ae7 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -72,8 +72,13 @@ namespace ts { directoryExists(directoryName: string): boolean; } - /** Public interface of the the of a config service shim instance.*/ - export interface CoreServicesShimHost extends Logger, ModuleResolutionHost { + /** Public interface of the core-services host instance used in managed side */ + export interface CoreServicesShimHost extends Logger { + directoryExists(directoryName: string): boolean; + fileExists(fileName: string): boolean; + getCurrentDirectory(): string; + getDirectories(path: string): string; + /** * Returns a JSON-encoded value of the type: string[] * @@ -81,9 +86,14 @@ namespace ts { * when enumerating the directory. */ readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; - useCaseSensitiveFileNames?(): boolean; - getCurrentDirectory(): string; + + /** + * Read arbitary text files on disk, i.e. when resolution procedure needs the content of 'package.json' to determine location of bundled typings for node modules + */ + readFile(fileName: string): string; + realpath?(path: string): string; trace(s: string): void; + useCaseSensitiveFileNames?(): boolean; } /// @@ -240,6 +250,7 @@ namespace ts { } export interface CoreServicesShim extends Shim { + getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string; getPreProcessedFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getTSConfigFileInfo(fileName: string, sourceText: IScriptSnapshot): string; getDefaultCompilationSettings(): string; @@ -492,6 +503,10 @@ namespace ts { private readDirectoryFallback(rootDir: string, extension: string, exclude: string[]) { return JSON.parse(this.shimHost.readDirectory(rootDir, extension, JSON.stringify(exclude))); } + + public getDirectories(path: string): string[] { + return JSON.parse(this.shimHost.getDirectories(path)); + } } function simpleForwardCall(logger: Logger, actionDescription: string, action: () => any, logPerformance: boolean): any { @@ -1003,7 +1018,7 @@ namespace ts { public getPreProcessedFileInfo(fileName: string, sourceTextSnapshot: IScriptSnapshot): string { return this.forwardJSONCall( - "getPreProcessedFileInfo('" + fileName + "')", + `getPreProcessedFileInfo('${fileName}')`, () => { // for now treat files as JavaScript const result = preProcessFile(sourceTextSnapshot.getText(0, sourceTextSnapshot.getLength()), /* readImportFiles */ true, /* detectJavaScriptImports */ true); @@ -1017,6 +1032,16 @@ namespace ts { }); } + public getAutomaticTypeDirectiveNames(compilerOptionsJson: string): string { + return this.forwardJSONCall( + `getAutomaticTypeDirectiveNames('${compilerOptionsJson}')`, + () => { + const compilerOptions = JSON.parse(compilerOptionsJson); + return getAutomaticTypeDirectiveNames(compilerOptions, this.host); + } + ); + } + private convertFileReferences(refs: FileReference[]): IFileReference[] { if (!refs) { return undefined; diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt b/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt new file mode 100644 index 00000000000..981f89214e2 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/a.ts(2,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. +tests/cases/compiler/a.ts(3,5): error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. + + +==== tests/cases/compiler/a.ts (2 errors) ==== + import Foo = require("./b"); + Foo.default.bar(); + ~~~~~~~ +!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. + Foo.default.default.foo(); + ~~~~~~~ +!!! error TS2339: Property 'default' does not exist on type 'typeof "tests/cases/compiler/b"'. +==== tests/cases/compiler/b.d.ts (0 errors) ==== + export function foo(); + + export function bar(); + \ No newline at end of file diff --git a/tests/baselines/reference/allowSyntheticDefaultImports10.js b/tests/baselines/reference/allowSyntheticDefaultImports10.js new file mode 100644 index 00000000000..746997c4c89 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports10.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/allowSyntheticDefaultImports10.ts] //// + +//// [b.d.ts] +export function foo(); + +export function bar(); + +//// [a.ts] +import Foo = require("./b"); +Foo.default.bar(); +Foo.default.default.foo(); + +//// [a.js] +"use strict"; +var Foo = require("./b"); +Foo.default.bar(); +Foo.default.default.foo(); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports7.js b/tests/baselines/reference/allowSyntheticDefaultImports7.js new file mode 100644 index 00000000000..6d0ea5b3be0 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports7.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/allowSyntheticDefaultImports7.ts] //// + +//// [b.d.ts] +export function foo(); + +export function bar(); + +//// [a.ts] +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); + +//// [a.js] +System.register(["./b"], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var b_1; + return { + setters: [ + function (b_1_1) { + b_1 = b_1_1; + } + ], + execute: function () { + b_1["default"].bar(); + b_1["default"].foo(); + } + }; +}); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports7.symbols b/tests/baselines/reference/allowSyntheticDefaultImports7.symbols new file mode 100644 index 00000000000..51155dd69df --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports7.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : Symbol(foo, Decl(b.d.ts, 0, 0)) + +export function bar(); +>bar : Symbol(bar, Decl(b.d.ts, 0, 22)) + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : Symbol(Foo, Decl(a.ts, 0, 8)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) + +Foo.bar(); +>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) +>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22)) + +Foo.foo(); +>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) +>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports7.types b/tests/baselines/reference/allowSyntheticDefaultImports7.types new file mode 100644 index 00000000000..69ce39e6dc6 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports7.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : () => any + +export function bar(); +>bar : () => any + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : typeof Foo +>Foo : typeof Foo + +Foo.bar(); +>Foo.bar() : any +>Foo.bar : () => any +>Foo : typeof Foo +>bar : () => any + +Foo.foo(); +>Foo.foo() : any +>Foo.foo : () => any +>Foo : typeof Foo +>foo : () => any + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports8.errors.txt b/tests/baselines/reference/allowSyntheticDefaultImports8.errors.txt new file mode 100644 index 00000000000..acb584f8fd9 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports8.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/a.ts(1,10): error TS2305: Module '"tests/cases/compiler/b"' has no exported member 'default'. + + +==== tests/cases/compiler/b.d.ts (0 errors) ==== + export function foo(); + + export function bar(); + +==== tests/cases/compiler/a.ts (1 errors) ==== + import { default as Foo } from "./b"; + ~~~~~~~ +!!! error TS2305: Module '"tests/cases/compiler/b"' has no exported member 'default'. + Foo.bar(); + Foo.foo(); \ No newline at end of file diff --git a/tests/baselines/reference/allowSyntheticDefaultImports8.js b/tests/baselines/reference/allowSyntheticDefaultImports8.js new file mode 100644 index 00000000000..5a77e51e6a2 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports8.js @@ -0,0 +1,29 @@ +//// [tests/cases/compiler/allowSyntheticDefaultImports8.ts] //// + +//// [b.d.ts] +export function foo(); + +export function bar(); + +//// [a.ts] +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); + +//// [a.js] +System.register(["./b"], function (exports_1, context_1) { + "use strict"; + var __moduleName = context_1 && context_1.id; + var b_1; + return { + setters: [ + function (b_1_1) { + b_1 = b_1_1; + } + ], + execute: function () { + b_1["default"].bar(); + b_1["default"].foo(); + } + }; +}); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports9.js b/tests/baselines/reference/allowSyntheticDefaultImports9.js new file mode 100644 index 00000000000..15810ccaaf7 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports9.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/allowSyntheticDefaultImports9.ts] //// + +//// [b.d.ts] +export function foo(); + +export function bar(); + +//// [a.ts] +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); + +//// [a.js] +"use strict"; +var b_1 = require("./b"); +b_1["default"].bar(); +b_1["default"].foo(); diff --git a/tests/baselines/reference/allowSyntheticDefaultImports9.symbols b/tests/baselines/reference/allowSyntheticDefaultImports9.symbols new file mode 100644 index 00000000000..51155dd69df --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports9.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : Symbol(foo, Decl(b.d.ts, 0, 0)) + +export function bar(); +>bar : Symbol(bar, Decl(b.d.ts, 0, 22)) + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : Symbol(Foo, Decl(a.ts, 0, 8)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) + +Foo.bar(); +>Foo.bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) +>bar : Symbol(Foo.bar, Decl(b.d.ts, 0, 22)) + +Foo.foo(); +>Foo.foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0)) +>Foo : Symbol(Foo, Decl(a.ts, 0, 8)) +>foo : Symbol(Foo.foo, Decl(b.d.ts, 0, 0)) + diff --git a/tests/baselines/reference/allowSyntheticDefaultImports9.types b/tests/baselines/reference/allowSyntheticDefaultImports9.types new file mode 100644 index 00000000000..69ce39e6dc6 --- /dev/null +++ b/tests/baselines/reference/allowSyntheticDefaultImports9.types @@ -0,0 +1,24 @@ +=== tests/cases/compiler/b.d.ts === +export function foo(); +>foo : () => any + +export function bar(); +>bar : () => any + +=== tests/cases/compiler/a.ts === +import { default as Foo } from "./b"; +>default : typeof Foo +>Foo : typeof Foo + +Foo.bar(); +>Foo.bar() : any +>Foo.bar : () => any +>Foo : typeof Foo +>bar : () => any + +Foo.foo(); +>Foo.foo() : any +>Foo.foo : () => any +>Foo : typeof Foo +>foo : () => any + diff --git a/tests/baselines/reference/discriminatedUnionTypes1.symbols b/tests/baselines/reference/discriminatedUnionTypes1.symbols deleted file mode 100644 index 38069447423..00000000000 --- a/tests/baselines/reference/discriminatedUnionTypes1.symbols +++ /dev/null @@ -1,402 +0,0 @@ -=== tests/cases/conformance/types/union/discriminatedUnionTypes1.ts === -interface Square { ->Square : Symbol(Square, Decl(discriminatedUnionTypes1.ts, 0, 0)) - - kind: "square"; ->kind : Symbol(Square.kind, Decl(discriminatedUnionTypes1.ts, 0, 18)) - - size: number; ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) -} - -interface Rectangle { ->Rectangle : Symbol(Rectangle, Decl(discriminatedUnionTypes1.ts, 3, 1)) - - kind: "rectangle"; ->kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21)) - - width: number; ->width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) - - height: number; ->height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) -} - -interface Circle { ->Circle : Symbol(Circle, Decl(discriminatedUnionTypes1.ts, 9, 1)) - - kind: "circle"; ->kind : Symbol(Circle.kind, Decl(discriminatedUnionTypes1.ts, 11, 18)) - - radius: number; ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) -} - -type Shape = Square | Rectangle | Circle; ->Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1)) ->Square : Symbol(Square, Decl(discriminatedUnionTypes1.ts, 0, 0)) ->Rectangle : Symbol(Rectangle, Decl(discriminatedUnionTypes1.ts, 3, 1)) ->Circle : Symbol(Circle, Decl(discriminatedUnionTypes1.ts, 9, 1)) - -function area1(s: Shape) { ->area1 : Symbol(area1, Decl(discriminatedUnionTypes1.ts, 16, 41)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1)) - - if (s.kind === "square") { ->s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) - - return s.size * s.size; ->s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) - } - else if (s.kind === "circle") { ->s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) - - return Math.PI * s.radius * s.radius; ->Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --)) ->Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->PI : Symbol(Math.PI, Decl(lib.d.ts, --, --)) ->s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) - } - else if (s.kind === "rectangle") { ->s.kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->kind : Symbol(Rectangle.kind, Decl(discriminatedUnionTypes1.ts, 5, 21)) - - return s.width * s.height; ->s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) ->s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 18, 15)) ->height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) - } - else { - return 0; - } -} - -function area2(s: Shape) { ->area2 : Symbol(area2, Decl(discriminatedUnionTypes1.ts, 31, 1)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15)) ->Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1)) - - switch (s.kind) { ->s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) - - case "square": return s.size * s.size; ->s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15)) ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15)) ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) - - case "rectangle": return s.width * s.height; ->s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15)) ->width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) ->s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15)) ->height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) - - case "circle": return Math.PI * s.radius * s.radius; ->Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --)) ->Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->PI : Symbol(Math.PI, Decl(lib.d.ts, --, --)) ->s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15)) ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 33, 15)) ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) - } -} - -function assertNever(x: never): never { ->assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1)) ->x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 41, 21)) - - throw new Error("Unexpected object: " + x); ->Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 41, 21)) -} - -function area3(s: Shape) { ->area3 : Symbol(area3, Decl(discriminatedUnionTypes1.ts, 43, 1)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) ->Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1)) - - switch (s.kind) { ->s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) - - case "square": return s.size * s.size; ->s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) - - case "rectangle": return s.width * s.height; ->s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) ->width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) ->s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) ->height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) - - case "circle": return Math.PI * s.radius * s.radius; ->Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --)) ->Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->PI : Symbol(Math.PI, Decl(lib.d.ts, --, --)) ->s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) - - default: return assertNever(s); ->assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 45, 15)) - } -} - -function area4(s: Shape) { ->area4 : Symbol(area4, Decl(discriminatedUnionTypes1.ts, 52, 1)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) ->Shape : Symbol(Shape, Decl(discriminatedUnionTypes1.ts, 14, 1)) - - switch (s.kind) { ->s.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 0, 18), Decl(discriminatedUnionTypes1.ts, 5, 21), Decl(discriminatedUnionTypes1.ts, 11, 18)) - - case "square": return s.size * s.size; ->s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s.size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) ->size : Symbol(Square.size, Decl(discriminatedUnionTypes1.ts, 1, 19)) - - case "rectangle": return s.width * s.height; ->s.width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) ->width : Symbol(Rectangle.width, Decl(discriminatedUnionTypes1.ts, 6, 22)) ->s.height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) ->height : Symbol(Rectangle.height, Decl(discriminatedUnionTypes1.ts, 7, 18)) - - case "circle": return Math.PI * s.radius * s.radius; ->Math.PI : Symbol(Math.PI, Decl(lib.d.ts, --, --)) ->Math : Symbol(Math, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) ->PI : Symbol(Math.PI, Decl(lib.d.ts, --, --)) ->s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s.radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) ->radius : Symbol(Circle.radius, Decl(discriminatedUnionTypes1.ts, 12, 19)) - } - return assertNever(s); ->assertNever : Symbol(assertNever, Decl(discriminatedUnionTypes1.ts, 39, 1)) ->s : Symbol(s, Decl(discriminatedUnionTypes1.ts, 54, 15)) -} - -type Message = ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) - - { kind: "A", x: string } | ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5)) ->x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 64, 16)) - - { kind: "B" | "C", y: number } | ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5)) ->y : Symbol(y, Decl(discriminatedUnionTypes1.ts, 65, 22)) - - { kind: "D" }; ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 66, 5)) - -function f1(m: Message) { ->f1 : Symbol(f1, Decl(discriminatedUnionTypes1.ts, 66, 18)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12)) ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) - - if (m.kind === "A") { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) - - m; // { kind: "A", x: string } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12)) - } - else if (m.kind === "D") { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) - - m; // { kind: "D" } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12)) - } - else { - m; // { kind: "B" | "C", y: number } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 68, 12)) - } -} - -function f2(m: Message) { ->f2 : Symbol(f2, Decl(discriminatedUnionTypes1.ts, 78, 1)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12)) ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) - - if (m.kind === "A") { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) - - return; - } - m; // { kind: "B" | "C", y: number } | { kind: "D" } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 80, 12)) -} - -function f3(m: Message) { ->f3 : Symbol(f3, Decl(discriminatedUnionTypes1.ts, 85, 1)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12)) ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) - - if (m.kind === "X") { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) - - m; // never ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 87, 12)) - } -} - -function f4(m: Message, x: "A" | "D") { ->f4 : Symbol(f4, Decl(discriminatedUnionTypes1.ts, 91, 1)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12)) ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) ->x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 93, 23)) - - if (m.kind == x) { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->x : Symbol(x, Decl(discriminatedUnionTypes1.ts, 93, 23)) - - m; // { kind: "A", x: string } | { kind: "D" } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 93, 12)) - } -} - -function f5(m: Message) { ->f5 : Symbol(f5, Decl(discriminatedUnionTypes1.ts, 97, 1)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12)) ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) - - switch (m.kind) { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) - - case "A": - m; // { kind: "A", x: string } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12)) - - break; - case "D": - m; // { kind: "D" } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12)) - - break; - default: - m; // { kind: "B" | "C", y: number } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 99, 12)) - } -} - -function f6(m: Message) { ->f6 : Symbol(f6, Decl(discriminatedUnionTypes1.ts, 110, 1)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12)) ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) - - switch (m.kind) { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) - - case "A": - m; // { kind: "A", x: string } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12)) - - case "D": - m; // { kind: "A", x: string } | { kind: "D" } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12)) - - break; - default: - m; // { kind: "B" | "C", y: number } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 112, 12)) - } -} - -function f7(m: Message) { ->f7 : Symbol(f7, Decl(discriminatedUnionTypes1.ts, 122, 1)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12)) ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) - - switch (m.kind) { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) - - case "A": - case "B": - return; - } - m; // { kind: "B" | "C", y: number } | { kind: "D" } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 124, 12)) -} - -function f8(m: Message) { ->f8 : Symbol(f8, Decl(discriminatedUnionTypes1.ts, 131, 1)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12)) ->Message : Symbol(Message, Decl(discriminatedUnionTypes1.ts, 61, 1)) - - switch (m.kind) { ->m.kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12)) ->kind : Symbol(kind, Decl(discriminatedUnionTypes1.ts, 64, 5), Decl(discriminatedUnionTypes1.ts, 65, 5), Decl(discriminatedUnionTypes1.ts, 66, 5)) - - case "A": - return; - case "D": - throw new Error(); ->Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) - } - m; // { kind: "B" | "C", y: number } ->m : Symbol(m, Decl(discriminatedUnionTypes1.ts, 133, 12)) -} diff --git a/tests/baselines/reference/discriminatedUnionTypes1.types b/tests/baselines/reference/discriminatedUnionTypes1.types deleted file mode 100644 index 234de28eaba..00000000000 --- a/tests/baselines/reference/discriminatedUnionTypes1.types +++ /dev/null @@ -1,465 +0,0 @@ -=== tests/cases/conformance/types/union/discriminatedUnionTypes1.ts === -interface Square { ->Square : Square - - kind: "square"; ->kind : "square" - - size: number; ->size : number -} - -interface Rectangle { ->Rectangle : Rectangle - - kind: "rectangle"; ->kind : "rectangle" - - width: number; ->width : number - - height: number; ->height : number -} - -interface Circle { ->Circle : Circle - - kind: "circle"; ->kind : "circle" - - radius: number; ->radius : number -} - -type Shape = Square | Rectangle | Circle; ->Shape : Square | Rectangle | Circle ->Square : Square ->Rectangle : Rectangle ->Circle : Circle - -function area1(s: Shape) { ->area1 : (s: Square | Rectangle | Circle) => number ->s : Square | Rectangle | Circle ->Shape : Square | Rectangle | Circle - - if (s.kind === "square") { ->s.kind === "square" : boolean ->s.kind : "square" | "rectangle" | "circle" ->s : Square | Rectangle | Circle ->kind : "square" | "rectangle" | "circle" ->"square" : string - - return s.size * s.size; ->s.size * s.size : number ->s.size : number ->s : Square ->size : number ->s.size : number ->s : Square ->size : number - } - else if (s.kind === "circle") { ->s.kind === "circle" : boolean ->s.kind : "rectangle" | "circle" ->s : Rectangle | Circle ->kind : "rectangle" | "circle" ->"circle" : string - - return Math.PI * s.radius * s.radius; ->Math.PI * s.radius * s.radius : number ->Math.PI * s.radius : number ->Math.PI : number ->Math : Math ->PI : number ->s.radius : number ->s : Circle ->radius : number ->s.radius : number ->s : Circle ->radius : number - } - else if (s.kind === "rectangle") { ->s.kind === "rectangle" : boolean ->s.kind : "rectangle" ->s : Rectangle ->kind : "rectangle" ->"rectangle" : string - - return s.width * s.height; ->s.width * s.height : number ->s.width : number ->s : Rectangle ->width : number ->s.height : number ->s : Rectangle ->height : number - } - else { - return 0; ->0 : number - } -} - -function area2(s: Shape) { ->area2 : (s: Square | Rectangle | Circle) => number ->s : Square | Rectangle | Circle ->Shape : Square | Rectangle | Circle - - switch (s.kind) { ->s.kind : "square" | "rectangle" | "circle" ->s : Square | Rectangle | Circle ->kind : "square" | "rectangle" | "circle" - - case "square": return s.size * s.size; ->"square" : string ->s.size * s.size : number ->s.size : number ->s : Square ->size : number ->s.size : number ->s : Square ->size : number - - case "rectangle": return s.width * s.height; ->"rectangle" : string ->s.width * s.height : number ->s.width : number ->s : Rectangle ->width : number ->s.height : number ->s : Rectangle ->height : number - - case "circle": return Math.PI * s.radius * s.radius; ->"circle" : string ->Math.PI * s.radius * s.radius : number ->Math.PI * s.radius : number ->Math.PI : number ->Math : Math ->PI : number ->s.radius : number ->s : Circle ->radius : number ->s.radius : number ->s : Circle ->radius : number - } -} - -function assertNever(x: never): never { ->assertNever : (x: never) => never ->x : never - - throw new Error("Unexpected object: " + x); ->new Error("Unexpected object: " + x) : Error ->Error : ErrorConstructor ->"Unexpected object: " + x : string ->"Unexpected object: " : string ->x : never -} - -function area3(s: Shape) { ->area3 : (s: Square | Rectangle | Circle) => number ->s : Square | Rectangle | Circle ->Shape : Square | Rectangle | Circle - - switch (s.kind) { ->s.kind : "square" | "rectangle" | "circle" ->s : Square | Rectangle | Circle ->kind : "square" | "rectangle" | "circle" - - case "square": return s.size * s.size; ->"square" : string ->s.size * s.size : number ->s.size : number ->s : Square ->size : number ->s.size : number ->s : Square ->size : number - - case "rectangle": return s.width * s.height; ->"rectangle" : string ->s.width * s.height : number ->s.width : number ->s : Rectangle ->width : number ->s.height : number ->s : Rectangle ->height : number - - case "circle": return Math.PI * s.radius * s.radius; ->"circle" : string ->Math.PI * s.radius * s.radius : number ->Math.PI * s.radius : number ->Math.PI : number ->Math : Math ->PI : number ->s.radius : number ->s : Circle ->radius : number ->s.radius : number ->s : Circle ->radius : number - - default: return assertNever(s); ->assertNever(s) : never ->assertNever : (x: never) => never ->s : never - } -} - -function area4(s: Shape) { ->area4 : (s: Square | Rectangle | Circle) => number ->s : Square | Rectangle | Circle ->Shape : Square | Rectangle | Circle - - switch (s.kind) { ->s.kind : "square" | "rectangle" | "circle" ->s : Square | Rectangle | Circle ->kind : "square" | "rectangle" | "circle" - - case "square": return s.size * s.size; ->"square" : string ->s.size * s.size : number ->s.size : number ->s : Square ->size : number ->s.size : number ->s : Square ->size : number - - case "rectangle": return s.width * s.height; ->"rectangle" : string ->s.width * s.height : number ->s.width : number ->s : Rectangle ->width : number ->s.height : number ->s : Rectangle ->height : number - - case "circle": return Math.PI * s.radius * s.radius; ->"circle" : string ->Math.PI * s.radius * s.radius : number ->Math.PI * s.radius : number ->Math.PI : number ->Math : Math ->PI : number ->s.radius : number ->s : Circle ->radius : number ->s.radius : number ->s : Circle ->radius : number - } - return assertNever(s); ->assertNever(s) : never ->assertNever : (x: never) => never ->s : never -} - -type Message = ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } - - { kind: "A", x: string } | ->kind : "A" ->x : string - - { kind: "B" | "C", y: number } | ->kind : "B" | "C" ->y : number - - { kind: "D" }; ->kind : "D" - -function f1(m: Message) { ->f1 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } - - if (m.kind === "A") { ->m.kind === "A" : boolean ->m.kind : "A" | "B" | "C" | "D" ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "A" | "B" | "C" | "D" ->"A" : string - - m; // { kind: "A", x: string } ->m : { kind: "A"; x: string; } - } - else if (m.kind === "D") { ->m.kind === "D" : boolean ->m.kind : "B" | "C" | "D" ->m : { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "B" | "C" | "D" ->"D" : string - - m; // { kind: "D" } ->m : { kind: "D"; } - } - else { - m; // { kind: "B" | "C", y: number } ->m : { kind: "B" | "C"; y: number; } - } -} - -function f2(m: Message) { ->f2 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } - - if (m.kind === "A") { ->m.kind === "A" : boolean ->m.kind : "A" | "B" | "C" | "D" ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "A" | "B" | "C" | "D" ->"A" : string - - return; - } - m; // { kind: "B" | "C", y: number } | { kind: "D" } ->m : { kind: "B" | "C"; y: number; } | { kind: "D"; } -} - -function f3(m: Message) { ->f3 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } - - if (m.kind === "X") { ->m.kind === "X" : boolean ->m.kind : "A" | "B" | "C" | "D" ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "A" | "B" | "C" | "D" ->"X" : string - - m; // never ->m : never - } -} - -function f4(m: Message, x: "A" | "D") { ->f4 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }, x: "A" | "D") => void ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->x : "A" | "D" - - if (m.kind == x) { ->m.kind == x : boolean ->m.kind : "A" | "B" | "C" | "D" ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "A" | "B" | "C" | "D" ->x : "A" | "D" - - m; // { kind: "A", x: string } | { kind: "D" } ->m : { kind: "A"; x: string; } | { kind: "D"; } - } -} - -function f5(m: Message) { ->f5 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } - - switch (m.kind) { ->m.kind : "A" | "B" | "C" | "D" ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "A" | "B" | "C" | "D" - - case "A": ->"A" : string - - m; // { kind: "A", x: string } ->m : { kind: "A"; x: string; } - - break; - case "D": ->"D" : string - - m; // { kind: "D" } ->m : { kind: "D"; } - - break; - default: - m; // { kind: "B" | "C", y: number } ->m : { kind: "B" | "C"; y: number; } - } -} - -function f6(m: Message) { ->f6 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } - - switch (m.kind) { ->m.kind : "A" | "B" | "C" | "D" ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "A" | "B" | "C" | "D" - - case "A": ->"A" : string - - m; // { kind: "A", x: string } ->m : { kind: "A"; x: string; } - - case "D": ->"D" : string - - m; // { kind: "A", x: string } | { kind: "D" } ->m : { kind: "D"; } | { kind: "A"; x: string; } - - break; - default: - m; // { kind: "B" | "C", y: number } ->m : { kind: "B" | "C"; y: number; } - } -} - -function f7(m: Message) { ->f7 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } - - switch (m.kind) { ->m.kind : "A" | "B" | "C" | "D" ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "A" | "B" | "C" | "D" - - case "A": ->"A" : string - - case "B": ->"B" : string - - return; - } - m; // { kind: "B" | "C", y: number } | { kind: "D" } ->m : { kind: "B" | "C"; y: number; } | { kind: "D"; } -} - -function f8(m: Message) { ->f8 : (m: { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; }) => void ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->Message : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } - - switch (m.kind) { ->m.kind : "A" | "B" | "C" | "D" ->m : { kind: "A"; x: string; } | { kind: "B" | "C"; y: number; } | { kind: "D"; } ->kind : "A" | "B" | "C" | "D" - - case "A": ->"A" : string - - return; - case "D": ->"D" : string - - throw new Error(); ->new Error() : Error ->Error : ErrorConstructor - } - m; // { kind: "B" | "C", y: number } ->m : { kind: "B" | "C"; y: number; } -} diff --git a/tests/baselines/reference/exportToString.js b/tests/baselines/reference/exportToString.js new file mode 100644 index 00000000000..190d1693c24 --- /dev/null +++ b/tests/baselines/reference/exportToString.js @@ -0,0 +1,9 @@ +//// [exportToString.ts] +const toString = 0; +export { toString }; + + +//// [exportToString.js] +"use strict"; +var toString = 0; +exports.toString = toString; diff --git a/tests/baselines/reference/exportToString.symbols b/tests/baselines/reference/exportToString.symbols new file mode 100644 index 00000000000..ce5446317a4 --- /dev/null +++ b/tests/baselines/reference/exportToString.symbols @@ -0,0 +1,7 @@ +=== tests/cases/compiler/exportToString.ts === +const toString = 0; +>toString : Symbol(toString, Decl(exportToString.ts, 0, 5)) + +export { toString }; +>toString : Symbol(toString, Decl(exportToString.ts, 1, 8)) + diff --git a/tests/baselines/reference/exportToString.types b/tests/baselines/reference/exportToString.types new file mode 100644 index 00000000000..17037852f3b --- /dev/null +++ b/tests/baselines/reference/exportToString.types @@ -0,0 +1,8 @@ +=== tests/cases/compiler/exportToString.ts === +const toString = 0; +>toString : number +>0 : number + +export { toString }; +>toString : number + diff --git a/tests/baselines/reference/library-reference-13.trace.json b/tests/baselines/reference/library-reference-13.trace.json index d8dfb57c2a6..a23f0ef0ca5 100644 --- a/tests/baselines/reference/library-reference-13.trace.json +++ b/tests/baselines/reference/library-reference-13.trace.json @@ -1,5 +1,5 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/a/types'. ========", "Resolving with primary search path '/a/types'", "File '/a/types/jquery/package.json' does not exist.", "File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-14.trace.json b/tests/baselines/reference/library-reference-14.trace.json index d8dfb57c2a6..fb3a2bb7da4 100644 --- a/tests/baselines/reference/library-reference-14.trace.json +++ b/tests/baselines/reference/library-reference-14.trace.json @@ -1,5 +1,5 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory '/a/types'. ========", + "======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory '/a/types'. ========", "Resolving with primary search path '/a/types'", "File '/a/types/jquery/package.json' does not exist.", "File '/a/types/jquery/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-15.trace.json b/tests/baselines/reference/library-reference-15.trace.json index 3e9d7dba1d2..e23517976b0 100644 --- a/tests/baselines/reference/library-reference-15.trace.json +++ b/tests/baselines/reference/library-reference-15.trace.json @@ -1,5 +1,5 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/__inferred type names__.ts', root directory 'types'. ========", + "======== Resolving type reference directive 'jquery', containing file '/a/__inferred type names__.ts', root directory 'types'. ========", "Resolving with primary search path 'types'", "File 'types/jquery/package.json' does not exist.", "File 'types/jquery/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/library-reference-2.trace.json b/tests/baselines/reference/library-reference-2.trace.json index c26f7d2763d..64cdd809183 100644 --- a/tests/baselines/reference/library-reference-2.trace.json +++ b/tests/baselines/reference/library-reference-2.trace.json @@ -5,7 +5,7 @@ "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", "File '/types/jquery/jquery.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'jquery' was successfully resolved to '/types/jquery/jquery.d.ts', primary: true. ========", - "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/types'. ========", + "======== Resolving type reference directive 'jquery', containing file 'test/__inferred type names__.ts', root directory '/types'. ========", "Resolving with primary search path '/types'", "Found 'package.json' at '/types/jquery/package.json'.", "'package.json' has 'types' field 'jquery.d.ts' that references '/types/jquery/jquery.d.ts'.", diff --git a/tests/baselines/reference/library-reference-6.trace.json b/tests/baselines/reference/library-reference-6.trace.json index 48fb49e6c7f..fd83c1431b4 100644 --- a/tests/baselines/reference/library-reference-6.trace.json +++ b/tests/baselines/reference/library-reference-6.trace.json @@ -4,7 +4,7 @@ "File '/node_modules/@types/alpha/package.json' does not exist.", "File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.", "======== Type reference directive 'alpha' was successfully resolved to '/node_modules/@types/alpha/index.d.ts', primary: true. ========", - "======== Resolving type reference directive 'alpha', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "======== Resolving type reference directive 'alpha', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", "Resolving with primary search path '/node_modules/@types'", "File '/node_modules/@types/alpha/package.json' does not exist.", "File '/node_modules/@types/alpha/index.d.ts' exist - use it as a name resolution result.", diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.types b/tests/baselines/reference/stringLiteralTypesAndTuples01.types index 0900d9fc745..10a30a6d75c 100644 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.types +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.types @@ -55,5 +55,5 @@ function rawr(dino: RexOrRaptor) { throw "Unexpected " + dino; >"Unexpected " + dino : string >"Unexpected " : string ->dino : "t-rex" +>dino : never } diff --git a/tests/baselines/reference/tsxAttributeResolution5.errors.txt b/tests/baselines/reference/tsxAttributeResolution5.errors.txt index d7aa46bc05a..42dabc741ab 100644 --- a/tests/baselines/reference/tsxAttributeResolution5.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution5.errors.txt @@ -2,9 +2,10 @@ tests/cases/conformance/jsx/file.tsx(21,16): error TS2606: Property 'x' of JSX s Type 'number' is not assignable to type 'string'. tests/cases/conformance/jsx/file.tsx(25,9): error TS2324: Property 'x' is missing in type 'Attribs1'. tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'x' is missing in type 'Attribs1'. +tests/cases/conformance/jsx/file.tsx(30,1): error TS2324: Property 'toString' is missing in type 'Attribs2'. -==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (4 errors) ==== declare module JSX { interface Element { } interface IntrinsicElements { @@ -41,5 +42,7 @@ tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'x' is missin ; // Error, missing x ~~~~~~~~~~~~~~~~~ !!! error TS2324: Property 'x' is missing in type 'Attribs1'. - ; // OK + ; // Error, missing toString + ~~~~~~~~~~~~~~~~~ +!!! error TS2324: Property 'toString' is missing in type 'Attribs2'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution5.js b/tests/baselines/reference/tsxAttributeResolution5.js index abfb54e000c..4bde09074b5 100644 --- a/tests/baselines/reference/tsxAttributeResolution5.js +++ b/tests/baselines/reference/tsxAttributeResolution5.js @@ -28,7 +28,7 @@ function make3 (obj: T) { ; // Error, missing x -; // OK +; // Error, missing toString //// [file.jsx] @@ -42,4 +42,4 @@ function make3(obj) { return ; // Error, missing x } ; // Error, missing x -; // OK +; // Error, missing toString diff --git a/tests/baselines/reference/typeGuardTautologicalConsistiency.types b/tests/baselines/reference/typeGuardTautologicalConsistiency.types index f86a9e66fa2..0a6524dd26f 100644 --- a/tests/baselines/reference/typeGuardTautologicalConsistiency.types +++ b/tests/baselines/reference/typeGuardTautologicalConsistiency.types @@ -15,7 +15,7 @@ if (typeof stringOrNumber === "number") { >"number" : "number" stringOrNumber; ->stringOrNumber : string +>stringOrNumber : never } } @@ -31,6 +31,6 @@ if (typeof stringOrNumber === "number" && typeof stringOrNumber !== "number") { >"number" : "number" stringOrNumber; ->stringOrNumber : string +>stringOrNumber : never } diff --git a/tests/baselines/reference/typeGuardTypeOfUndefined.types b/tests/baselines/reference/typeGuardTypeOfUndefined.types index 8e9928896a1..520d045d9e0 100644 --- a/tests/baselines/reference/typeGuardTypeOfUndefined.types +++ b/tests/baselines/reference/typeGuardTypeOfUndefined.types @@ -47,7 +47,7 @@ function test2(a: any) { >"boolean" : "boolean" a; ->a : boolean +>a : never } else { a; @@ -129,7 +129,7 @@ function test5(a: boolean | void) { } else { a; ->a : void +>a : never } } else { @@ -188,7 +188,7 @@ function test7(a: boolean | void) { } else { a; ->a : void +>a : never } } diff --git a/tests/baselines/reference/typeGuardsAsAssertions.types b/tests/baselines/reference/typeGuardsAsAssertions.types index 34d3b296a48..661ce9fbc55 100644 --- a/tests/baselines/reference/typeGuardsAsAssertions.types +++ b/tests/baselines/reference/typeGuardsAsAssertions.types @@ -193,10 +193,10 @@ function f1() { >x : undefined x; // string | number (guard as assertion) ->x : string | number +>x : never } x; // string | number | undefined ->x : string | number | undefined +>x : undefined } function f2() { @@ -216,10 +216,10 @@ function f2() { >"string" : "string" x; // string (guard as assertion) ->x : string +>x : never } x; // string | undefined ->x : string | undefined +>x : undefined } function f3() { @@ -239,7 +239,7 @@ function f3() { return; } x; // string | number (guard as assertion) ->x : string | number +>x : never } function f4() { @@ -281,7 +281,7 @@ function f5(x: string | number) { >"number" : "number" x; // number (guard as assertion) ->x : number +>x : never } else { x; // string | number diff --git a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt index 984ca454e76..cd9ae40932a 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt +++ b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt @@ -1,9 +1,10 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(22,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(31,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(49,10): error TS2354: No best common type exists among return expressions. +tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,17): error TS2339: Property 'toString' does not exist on type 'never'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (3 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (4 errors) ==== // In the true branch statement of an 'if' statement, // the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true. // In the false branch statement of an 'if' statement, @@ -149,5 +150,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(49,10) return typeof x === "number" ? x.toString() // number : x.toString(); // boolean | string + ~~~~~~~~ +!!! error TS2339: Property 'toString' does not exist on type 'never'. } } \ No newline at end of file diff --git a/tests/baselines/reference/typeReferenceDirectives1.js b/tests/baselines/reference/typeReferenceDirectives1.js index 775af9c5283..a6210819931 100644 --- a/tests/baselines/reference/typeReferenceDirectives1.js +++ b/tests/baselines/reference/typeReferenceDirectives1.js @@ -2,7 +2,6 @@ //// [index.d.ts] - interface $ { x } //// [app.ts] diff --git a/tests/baselines/reference/typeReferenceDirectives1.symbols b/tests/baselines/reference/typeReferenceDirectives1.symbols index 55c17b219ec..a33a2aba408 100644 --- a/tests/baselines/reference/typeReferenceDirectives1.symbols +++ b/tests/baselines/reference/typeReferenceDirectives1.symbols @@ -9,8 +9,7 @@ interface A { } === /types/lib/index.d.ts === - interface $ { x } >$ : Symbol($, Decl(index.d.ts, 0, 0)) ->x : Symbol($.x, Decl(index.d.ts, 2, 13)) +>x : Symbol($.x, Decl(index.d.ts, 1, 13)) diff --git a/tests/baselines/reference/typeReferenceDirectives1.types b/tests/baselines/reference/typeReferenceDirectives1.types index 05080e05651..be789a08ddc 100644 --- a/tests/baselines/reference/typeReferenceDirectives1.types +++ b/tests/baselines/reference/typeReferenceDirectives1.types @@ -9,7 +9,6 @@ interface A { } === /types/lib/index.d.ts === - interface $ { x } >$ : $ >x : any diff --git a/tests/baselines/reference/umd-augmentation-1.symbols b/tests/baselines/reference/umd-augmentation-1.symbols index 645511350a9..70715649894 100644 --- a/tests/baselines/reference/umd-augmentation-1.symbols +++ b/tests/baselines/reference/umd-augmentation-1.symbols @@ -39,6 +39,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; +>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) export interface Point { >Point : Symbol(Point, Decl(index.d.ts, 1, 27)) diff --git a/tests/baselines/reference/umd-augmentation-1.types b/tests/baselines/reference/umd-augmentation-1.types index 31ac43fe855..59b577141e0 100644 --- a/tests/baselines/reference/umd-augmentation-1.types +++ b/tests/baselines/reference/umd-augmentation-1.types @@ -48,7 +48,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : any +>Math2d : typeof Math2d export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-2.symbols b/tests/baselines/reference/umd-augmentation-2.symbols index bd6584d3d74..a31ed61d531 100644 --- a/tests/baselines/reference/umd-augmentation-2.symbols +++ b/tests/baselines/reference/umd-augmentation-2.symbols @@ -37,6 +37,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; +>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) export interface Point { >Point : Symbol(Point, Decl(index.d.ts, 1, 27)) diff --git a/tests/baselines/reference/umd-augmentation-2.types b/tests/baselines/reference/umd-augmentation-2.types index 20bba091903..24fe6df3c3c 100644 --- a/tests/baselines/reference/umd-augmentation-2.types +++ b/tests/baselines/reference/umd-augmentation-2.types @@ -46,7 +46,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : any +>Math2d : typeof Math2d export interface Point { >Point : Point diff --git a/tests/baselines/reference/umd-augmentation-3.symbols b/tests/baselines/reference/umd-augmentation-3.symbols index 3193e83cd19..3e2df7c8a89 100644 --- a/tests/baselines/reference/umd-augmentation-3.symbols +++ b/tests/baselines/reference/umd-augmentation-3.symbols @@ -39,6 +39,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; +>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) export = M2D; >M2D : Symbol(M2D, Decl(index.d.ts, 3, 13)) diff --git a/tests/baselines/reference/umd-augmentation-3.types b/tests/baselines/reference/umd-augmentation-3.types index 854ebceff37..39bc28cbd24 100644 --- a/tests/baselines/reference/umd-augmentation-3.types +++ b/tests/baselines/reference/umd-augmentation-3.types @@ -48,7 +48,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : any +>Math2d : typeof Math2d export = M2D; >M2D : typeof M2D diff --git a/tests/baselines/reference/umd-augmentation-4.symbols b/tests/baselines/reference/umd-augmentation-4.symbols index 3f2cc913d86..7be5d278bf2 100644 --- a/tests/baselines/reference/umd-augmentation-4.symbols +++ b/tests/baselines/reference/umd-augmentation-4.symbols @@ -37,6 +37,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; +>Math2d : Symbol(Math2d, Decl(index.d.ts, 0, 0)) export = M2D; >M2D : Symbol(M2D, Decl(index.d.ts, 3, 13)) diff --git a/tests/baselines/reference/umd-augmentation-4.types b/tests/baselines/reference/umd-augmentation-4.types index 71783d03012..246270aa5a6 100644 --- a/tests/baselines/reference/umd-augmentation-4.types +++ b/tests/baselines/reference/umd-augmentation-4.types @@ -46,7 +46,7 @@ var t = p.x; === tests/cases/conformance/externalModules/node_modules/math2d/index.d.ts === export as namespace Math2d; ->Math2d : any +>Math2d : typeof Math2d export = M2D; >M2D : typeof M2D diff --git a/tests/baselines/reference/umd1.symbols b/tests/baselines/reference/umd1.symbols index 9b964456bcf..0307a9b78d3 100644 --- a/tests/baselines/reference/umd1.symbols +++ b/tests/baselines/reference/umd1.symbols @@ -30,4 +30,5 @@ export interface Thing { n: typeof x } >x : Symbol(x, Decl(foo.d.ts, 1, 10)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38)) diff --git a/tests/baselines/reference/umd1.types b/tests/baselines/reference/umd1.types index 1767f3b5a89..1379bba8d5d 100644 --- a/tests/baselines/reference/umd1.types +++ b/tests/baselines/reference/umd1.types @@ -31,5 +31,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : any +>Foo : typeof Foo diff --git a/tests/baselines/reference/umd3.symbols b/tests/baselines/reference/umd3.symbols index 165fd81597a..c1fd3d6d74f 100644 --- a/tests/baselines/reference/umd3.symbols +++ b/tests/baselines/reference/umd3.symbols @@ -32,4 +32,5 @@ export interface Thing { n: typeof x } >x : Symbol(x, Decl(foo.d.ts, 1, 10)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38)) diff --git a/tests/baselines/reference/umd3.types b/tests/baselines/reference/umd3.types index 85ee6bafe5e..23149e58d76 100644 --- a/tests/baselines/reference/umd3.types +++ b/tests/baselines/reference/umd3.types @@ -33,5 +33,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : any +>Foo : typeof Foo diff --git a/tests/baselines/reference/umd4.symbols b/tests/baselines/reference/umd4.symbols index 8403187198b..d266997770b 100644 --- a/tests/baselines/reference/umd4.symbols +++ b/tests/baselines/reference/umd4.symbols @@ -32,4 +32,5 @@ export interface Thing { n: typeof x } >x : Symbol(x, Decl(foo.d.ts, 1, 10)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 3, 38)) diff --git a/tests/baselines/reference/umd4.types b/tests/baselines/reference/umd4.types index 579599f5661..18794258517 100644 --- a/tests/baselines/reference/umd4.types +++ b/tests/baselines/reference/umd4.types @@ -33,5 +33,5 @@ export interface Thing { n: typeof x } >x : number export as namespace Foo; ->Foo : any +>Foo : typeof Foo diff --git a/tests/baselines/reference/umd6.symbols b/tests/baselines/reference/umd6.symbols index d08507f1ea2..958875b79eb 100644 --- a/tests/baselines/reference/umd6.symbols +++ b/tests/baselines/reference/umd6.symbols @@ -18,4 +18,5 @@ export = Thing; >Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15)) diff --git a/tests/baselines/reference/umd6.types b/tests/baselines/reference/umd6.types index 7318a43057a..5b1469cbd6c 100644 --- a/tests/baselines/reference/umd6.types +++ b/tests/baselines/reference/umd6.types @@ -19,5 +19,5 @@ export = Thing; >Thing : typeof Thing export as namespace Foo; ->Foo : any +>Foo : typeof Thing diff --git a/tests/baselines/reference/umd7.symbols b/tests/baselines/reference/umd7.symbols index 0b3ef17fb7b..19b56ed30f3 100644 --- a/tests/baselines/reference/umd7.symbols +++ b/tests/baselines/reference/umd7.symbols @@ -13,4 +13,5 @@ export = Thing; >Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 2, 15)) diff --git a/tests/baselines/reference/umd7.types b/tests/baselines/reference/umd7.types index 60782543710..d83e039b674 100644 --- a/tests/baselines/reference/umd7.types +++ b/tests/baselines/reference/umd7.types @@ -14,5 +14,5 @@ export = Thing; >Thing : () => number export as namespace Foo; ->Foo : any +>Foo : () => number diff --git a/tests/baselines/reference/umd8.symbols b/tests/baselines/reference/umd8.symbols index 8c38f267a2a..97da693b38f 100644 --- a/tests/baselines/reference/umd8.symbols +++ b/tests/baselines/reference/umd8.symbols @@ -22,4 +22,5 @@ export = Thing; >Thing : Symbol(Thing, Decl(foo.d.ts, 0, 0)) export as namespace Foo; +>Foo : Symbol(Foo, Decl(foo.d.ts, 4, 15)) diff --git a/tests/baselines/reference/umd8.types b/tests/baselines/reference/umd8.types index 0e66a49b963..ae3bdfd5fc8 100644 --- a/tests/baselines/reference/umd8.types +++ b/tests/baselines/reference/umd8.types @@ -23,5 +23,5 @@ export = Thing; >Thing : Thing export as namespace Foo; ->Foo : any +>Foo : typeof Thing diff --git a/tests/cases/compiler/allowSyntheticDefaultImports10.ts b/tests/cases/compiler/allowSyntheticDefaultImports10.ts new file mode 100644 index 00000000000..6b50bae96d8 --- /dev/null +++ b/tests/cases/compiler/allowSyntheticDefaultImports10.ts @@ -0,0 +1,11 @@ +// @allowSyntheticDefaultImports: true +// @module: commonjs +// @Filename: b.d.ts +export function foo(); + +export function bar(); + +// @Filename: a.ts +import Foo = require("./b"); +Foo.default.bar(); +Foo.default.default.foo(); \ No newline at end of file diff --git a/tests/cases/compiler/allowSyntheticDefaultImports7.ts b/tests/cases/compiler/allowSyntheticDefaultImports7.ts new file mode 100644 index 00000000000..2da05e4678c --- /dev/null +++ b/tests/cases/compiler/allowSyntheticDefaultImports7.ts @@ -0,0 +1,10 @@ +// @module: system +// @Filename: b.d.ts +export function foo(); + +export function bar(); + +// @Filename: a.ts +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); \ No newline at end of file diff --git a/tests/cases/compiler/allowSyntheticDefaultImports8.ts b/tests/cases/compiler/allowSyntheticDefaultImports8.ts new file mode 100644 index 00000000000..3a213ad8023 --- /dev/null +++ b/tests/cases/compiler/allowSyntheticDefaultImports8.ts @@ -0,0 +1,11 @@ +// @allowSyntheticDefaultImports: false +// @module: system +// @Filename: b.d.ts +export function foo(); + +export function bar(); + +// @Filename: a.ts +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); \ No newline at end of file diff --git a/tests/cases/compiler/allowSyntheticDefaultImports9.ts b/tests/cases/compiler/allowSyntheticDefaultImports9.ts new file mode 100644 index 00000000000..8da66f33adf --- /dev/null +++ b/tests/cases/compiler/allowSyntheticDefaultImports9.ts @@ -0,0 +1,11 @@ +// @allowSyntheticDefaultImports: true +// @module: commonjs +// @Filename: b.d.ts +export function foo(); + +export function bar(); + +// @Filename: a.ts +import { default as Foo } from "./b"; +Foo.bar(); +Foo.foo(); \ No newline at end of file diff --git a/tests/cases/compiler/exportToString.ts b/tests/cases/compiler/exportToString.ts new file mode 100644 index 00000000000..248df036bfd --- /dev/null +++ b/tests/cases/compiler/exportToString.ts @@ -0,0 +1,2 @@ +const toString = 0; +export { toString }; diff --git a/tests/cases/compiler/typeReferenceDirectives1.ts b/tests/cases/compiler/typeReferenceDirectives1.ts index e17e498b978..13c84c7ae5e 100644 --- a/tests/cases/compiler/typeReferenceDirectives1.ts +++ b/tests/cases/compiler/typeReferenceDirectives1.ts @@ -2,7 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types - +// @currentDirectory: / // @filename: /types/lib/index.d.ts interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives10.ts b/tests/cases/compiler/typeReferenceDirectives10.ts index 61971ba44b2..1eb796d03fd 100644 --- a/tests/cases/compiler/typeReferenceDirectives10.ts +++ b/tests/cases/compiler/typeReferenceDirectives10.ts @@ -2,6 +2,7 @@ // @declaration: true // @typeRoots: /types // @traceResolution: true +// @currentDirectory: / // @filename: /ref.d.ts export interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives11.ts b/tests/cases/compiler/typeReferenceDirectives11.ts index 3bbb771a6c7..6529bcdc6d2 100644 --- a/tests/cases/compiler/typeReferenceDirectives11.ts +++ b/tests/cases/compiler/typeReferenceDirectives11.ts @@ -5,6 +5,7 @@ // @types: lib // @out: output.js // @module: amd +// @currentDirectory: / // @filename: /types/lib/index.d.ts diff --git a/tests/cases/compiler/typeReferenceDirectives12.ts b/tests/cases/compiler/typeReferenceDirectives12.ts index 7601668e8f1..373da244f9a 100644 --- a/tests/cases/compiler/typeReferenceDirectives12.ts +++ b/tests/cases/compiler/typeReferenceDirectives12.ts @@ -4,6 +4,7 @@ // @traceResolution: true // @out: output.js // @module: amd +// @currentDirectory: / // @filename: /types/lib/index.d.ts diff --git a/tests/cases/compiler/typeReferenceDirectives13.ts b/tests/cases/compiler/typeReferenceDirectives13.ts index 124c31274ac..f9dede73267 100644 --- a/tests/cases/compiler/typeReferenceDirectives13.ts +++ b/tests/cases/compiler/typeReferenceDirectives13.ts @@ -2,6 +2,7 @@ // @declaration: true // @typeRoots: /types // @traceResolution: true +// @currentDirectory: / // @filename: /ref.d.ts export interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives2.ts b/tests/cases/compiler/typeReferenceDirectives2.ts index 31a01a0b8e4..44218683a5a 100644 --- a/tests/cases/compiler/typeReferenceDirectives2.ts +++ b/tests/cases/compiler/typeReferenceDirectives2.ts @@ -3,6 +3,7 @@ // @declaration: true // @typeRoots: /types // @types: lib +// @currentDirectory: / // @filename: /types/lib/index.d.ts interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives3.ts b/tests/cases/compiler/typeReferenceDirectives3.ts index 4c2729ab389..1baf0bdac9d 100644 --- a/tests/cases/compiler/typeReferenceDirectives3.ts +++ b/tests/cases/compiler/typeReferenceDirectives3.ts @@ -2,6 +2,7 @@ // @declaration: true // @typeRoots: /types // @traceResolution: true +// @currentDirectory: / // $ comes from d.ts file - no need to add type reference directive diff --git a/tests/cases/compiler/typeReferenceDirectives4.ts b/tests/cases/compiler/typeReferenceDirectives4.ts index ac7346895ef..dfa87b65138 100644 --- a/tests/cases/compiler/typeReferenceDirectives4.ts +++ b/tests/cases/compiler/typeReferenceDirectives4.ts @@ -2,6 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types +// @currentDirectory: / // $ comes from d.ts file - no need to add type reference directive diff --git a/tests/cases/compiler/typeReferenceDirectives5.ts b/tests/cases/compiler/typeReferenceDirectives5.ts index bb24b82b324..e81ae663e24 100644 --- a/tests/cases/compiler/typeReferenceDirectives5.ts +++ b/tests/cases/compiler/typeReferenceDirectives5.ts @@ -2,6 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types +// @currentDirectory: / // @filename: /ref.d.ts export interface $ { x } diff --git a/tests/cases/compiler/typeReferenceDirectives6.ts b/tests/cases/compiler/typeReferenceDirectives6.ts index 7154963f1ef..edf2ece7e06 100644 --- a/tests/cases/compiler/typeReferenceDirectives6.ts +++ b/tests/cases/compiler/typeReferenceDirectives6.ts @@ -2,6 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types +// @currentDirectory: / // $ comes from type declaration file - type reference directive should be added diff --git a/tests/cases/compiler/typeReferenceDirectives7.ts b/tests/cases/compiler/typeReferenceDirectives7.ts index 79d42fa7018..e9335b07082 100644 --- a/tests/cases/compiler/typeReferenceDirectives7.ts +++ b/tests/cases/compiler/typeReferenceDirectives7.ts @@ -2,6 +2,7 @@ // @traceResolution: true // @declaration: true // @typeRoots: /types +// @currentDirectory: / // local value shadows global - no need to add type reference directive diff --git a/tests/cases/compiler/typeReferenceDirectives8.ts b/tests/cases/compiler/typeReferenceDirectives8.ts index c7725a3aab1..bed69cbf357 100644 --- a/tests/cases/compiler/typeReferenceDirectives8.ts +++ b/tests/cases/compiler/typeReferenceDirectives8.ts @@ -3,6 +3,7 @@ // @typeRoots: /types // @traceResolution: true // @types: lib +// @currentDirectory: / // @filename: /types/lib/index.d.ts diff --git a/tests/cases/compiler/typeReferenceDirectives9.ts b/tests/cases/compiler/typeReferenceDirectives9.ts index 610c7173c89..1ad1aa52288 100644 --- a/tests/cases/compiler/typeReferenceDirectives9.ts +++ b/tests/cases/compiler/typeReferenceDirectives9.ts @@ -2,6 +2,7 @@ // @declaration: true // @typeRoots: /types // @traceResolution: true +// @currentDirectory: / // @filename: /types/lib/index.d.ts diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx index dd16ade10e3..83fb7b32f56 100644 --- a/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx +++ b/tests/cases/conformance/jsx/tsxAttributeResolution5.tsx @@ -29,4 +29,4 @@ function make3 (obj: T) { ; // Error, missing x -; // OK +; // Error, missing toString diff --git a/tests/cases/conformance/references/library-reference-13.ts b/tests/cases/conformance/references/library-reference-13.ts index 92b4b259ba4..419643d9d0d 100644 --- a/tests/cases/conformance/references/library-reference-13.ts +++ b/tests/cases/conformance/references/library-reference-13.ts @@ -1,5 +1,6 @@ // @noImplicitReferences: true // @traceResolution: true +// @currentDirectory: / // load type declarations from types section of tsconfig diff --git a/tests/cases/conformance/typings/typingsLookup1.ts b/tests/cases/conformance/typings/typingsLookup1.ts index 555d4569af3..150deef992a 100644 --- a/tests/cases/conformance/typings/typingsLookup1.ts +++ b/tests/cases/conformance/typings/typingsLookup1.ts @@ -1,5 +1,6 @@ // @traceResolution: true // @noImplicitReferences: true +// @currentDirectory: / // @filename: /tsconfig.json { "files": "a.ts" } diff --git a/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts b/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts new file mode 100644 index 00000000000..4177e154532 --- /dev/null +++ b/tests/cases/fourslash/findAllRefsForUMDModuleAlias1.ts @@ -0,0 +1,13 @@ +/// + +// @Filename: 0.d.ts +//// export function doThing(): string; +//// export function doTheOtherThing(): void; + +//// export as namespace [|myLib|]; + +// @Filename: 1.ts +//// /// +//// [|myLib|].doThing(); + +verify.rangesReferenceEachOther(); diff --git a/tests/cases/fourslash/quickInfoForUMDModuleAlias.ts b/tests/cases/fourslash/quickInfoForUMDModuleAlias.ts new file mode 100644 index 00000000000..085ea33b874 --- /dev/null +++ b/tests/cases/fourslash/quickInfoForUMDModuleAlias.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: 0.d.ts +//// export function doThing(): string; +//// export function doTheOtherThing(): void; + +//// export as namespace /*0*/myLib; + +// @Filename: 1.ts +//// /// +//// /*1*/myLib.doThing(); + +goTo.marker("0"); +verify.quickInfoIs("export namespace myLib"); + +goTo.marker("1"); +verify.quickInfoIs("export namespace myLib"); diff --git a/tests/cases/fourslash/renameAlias.ts b/tests/cases/fourslash/renameAlias.ts index e3f57ac7b41..e0408af656f 100644 --- a/tests/cases/fourslash/renameAlias.ts +++ b/tests/cases/fourslash/renameAlias.ts @@ -4,8 +4,8 @@ ////import [|M|] = SomeModule; ////import C = [|M|].SomeClass; -let ranges = test.ranges() -for (let range of ranges) { - goTo.position(range.start); - verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +let ranges = test.ranges() +for (let range of ranges) { + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); } \ No newline at end of file diff --git a/tests/cases/fourslash/renameUMDModuleAlias1.ts b/tests/cases/fourslash/renameUMDModuleAlias1.ts new file mode 100644 index 00000000000..94aabcdbde5 --- /dev/null +++ b/tests/cases/fourslash/renameUMDModuleAlias1.ts @@ -0,0 +1,17 @@ +/// + +// @Filename: 0.d.ts +//// export function doThing(): string; +//// export function doTheOtherThing(): void; + +//// export as namespace [|myLib|]; + +// @Filename: 1.ts +//// /// +//// [|myLib|].doThing(); + +const ranges = test.ranges() +for (const range of ranges) { + goTo.position(range.start); + verify.renameLocations(/*findInStrings*/ false, /*findInComments*/ false); +} \ No newline at end of file diff --git a/tests/cases/fourslash/renameUMDModuleAlias2.ts b/tests/cases/fourslash/renameUMDModuleAlias2.ts new file mode 100644 index 00000000000..0daa4087b0d --- /dev/null +++ b/tests/cases/fourslash/renameUMDModuleAlias2.ts @@ -0,0 +1,14 @@ +/// + +// @Filename: 0.d.ts +//// export function doThing(): string; +//// export function doTheOtherThing(): void; + +//// export as namespace /**/[|myLib|]; + +// @Filename: 1.ts +//// /// +//// myLib.doThing(); + +goTo.marker(); +verify.renameInfoSucceeded("myLib"); \ No newline at end of file From 37e96b3a06c99b6f22bf0221cf63e7057c86dc05 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 6 Aug 2016 09:01:35 -0700 Subject: [PATCH 089/508] Stricter check for discriminant properties in type guards --- src/compiler/checker.ts | 62 ++++++++++++++++++++++++++++++++++------- src/compiler/types.ts | 2 ++ 2 files changed, 54 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 84d5cd08a2b..3158a190244 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4416,10 +4416,19 @@ namespace ts { } const propTypes: Type[] = []; const declarations: Declaration[] = []; + let commonType: Type = undefined; + let hasCommonType = true; for (const prop of props) { if (prop.declarations) { addRange(declarations, prop.declarations); } + const type = getTypeOfSymbol(prop); + if (!commonType) { + commonType = type; + } + else if (type !== commonType) { + hasCommonType = false; + } propTypes.push(getTypeOfSymbol(prop)); } const result = createSymbol( @@ -4429,6 +4438,7 @@ namespace ts { commonFlags, name); result.containingType = containingType; + result.hasCommonType = hasCommonType; result.declarations = declarations; result.isReadonly = isReadonly; result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -7793,8 +7803,39 @@ namespace ts { return false; } - function rootContainsMatchingReference(source: Node, target: Node) { - return target.kind === SyntaxKind.PropertyAccessExpression && containsMatchingReference(source, (target).expression); + // Return true if target is a property access xxx.yyy, source is a property access xxx.zzz, the declared + // type of xxx is a union type, and yyy is a property that is possibly a discriminant. We consider a property + // a possible discriminant if its type differs in the constituents of containing union type, and if every + // choice is a unit type or a union of unit types. + function containsMatchingReferenceDiscriminant(source: Node, target: Node) { + return target.kind === SyntaxKind.PropertyAccessExpression && + containsMatchingReference(source, (target).expression) && + isDiscriminantProperty(getDeclaredTypeOfReference((target).expression), (target).name.text); + } + + function getDeclaredTypeOfReference(expr: Node): Type { + if (expr.kind === SyntaxKind.Identifier) { + return getTypeOfSymbol(getResolvedSymbol(expr)); + } + if (expr.kind === SyntaxKind.PropertyAccessExpression) { + const type = getDeclaredTypeOfReference((expr).expression); + return type && getTypeOfPropertyOfType(type, (expr).name.text); + } + return undefined; + } + + function isDiscriminantProperty(type: Type, name: string) { + if (type && type.flags & TypeFlags.Union) { + const prop = getPropertyOfType(type, name); + if (prop && prop.flags & SymbolFlags.SyntheticProperty) { + if ((prop).isDiscriminantProperty === undefined) { + (prop).isDiscriminantProperty = !(prop).hasCommonType && + isUnitUnionType(getTypeOfSymbol(prop)); + } + return (prop).isDiscriminantProperty; + } + } + return false; } function isOrContainsMatchingReference(source: Node, target: Node) { @@ -8222,7 +8263,7 @@ namespace ts { if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingPropertyAccess(expr)) { + else if (isMatchingReferenceDiscriminant(expr)) { type = narrowTypeByDiscriminant(type, expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); } return createFlowType(type, isIncomplete(flowType)); @@ -8300,10 +8341,11 @@ namespace ts { return cache[key] = getUnionType(antecedentTypes); } - function isMatchingPropertyAccess(expr: Expression) { + function isMatchingReferenceDiscriminant(expr: Expression) { return expr.kind === SyntaxKind.PropertyAccessExpression && + declaredType.flags & TypeFlags.Union && isMatchingReference(reference, (expr).expression) && - (declaredType.flags & TypeFlags.Union) !== 0; + isDiscriminantProperty(declaredType, (expr).name.text); } function narrowTypeByDiscriminant(type: Type, propAccess: PropertyAccessExpression, narrowType: (t: Type) => Type): Type { @@ -8317,10 +8359,10 @@ namespace ts { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy); } - if (isMatchingPropertyAccess(expr)) { + if (isMatchingReferenceDiscriminant(expr)) { return narrowTypeByDiscriminant(type, expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy)); } - if (rootContainsMatchingReference(reference, expr)) { + if (containsMatchingReferenceDiscriminant(reference, expr)) { return declaredType; } return type; @@ -8349,13 +8391,13 @@ namespace ts { if (isMatchingReference(reference, right)) { return narrowTypeByEquality(type, operator, left, assumeTrue); } - if (isMatchingPropertyAccess(left)) { + if (isMatchingReferenceDiscriminant(left)) { return narrowTypeByDiscriminant(type, left, t => narrowTypeByEquality(t, operator, right, assumeTrue)); } - if (isMatchingPropertyAccess(right)) { + if (isMatchingReferenceDiscriminant(right)) { return narrowTypeByDiscriminant(type, right, t => narrowTypeByEquality(t, operator, left, assumeTrue)); } - if (rootContainsMatchingReference(reference, left) || rootContainsMatchingReference(reference, right)) { + if (containsMatchingReferenceDiscriminant(reference, left) || containsMatchingReferenceDiscriminant(reference, right)) { return declaredType; } break; diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 28ededebb0d..a6e860450c6 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2160,6 +2160,8 @@ namespace ts { mapper?: TypeMapper; // Type mapper for instantiation alias referenced?: boolean; // True if alias symbol has been referenced as a value containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property + hasCommonType?: boolean; // True if constituents of synthetic property all have same type + isDiscriminantProperty?: boolean; // True if discriminant synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration From 1375505a1f58a623c0c5142046de4c54a4402f93 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 6 Aug 2016 09:06:56 -0700 Subject: [PATCH 090/508] Add tests --- .../discriminantPropertyCheck.errors.txt | 77 ++++++++++++ .../reference/discriminantPropertyCheck.js | 111 ++++++++++++++++++ .../compiler/discriminantPropertyCheck.ts | 69 +++++++++++ 3 files changed, 257 insertions(+) create mode 100644 tests/baselines/reference/discriminantPropertyCheck.errors.txt create mode 100644 tests/baselines/reference/discriminantPropertyCheck.js create mode 100644 tests/cases/compiler/discriminantPropertyCheck.ts diff --git a/tests/baselines/reference/discriminantPropertyCheck.errors.txt b/tests/baselines/reference/discriminantPropertyCheck.errors.txt new file mode 100644 index 00000000000..41593c4b224 --- /dev/null +++ b/tests/baselines/reference/discriminantPropertyCheck.errors.txt @@ -0,0 +1,77 @@ +tests/cases/compiler/discriminantPropertyCheck.ts(30,9): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/discriminantPropertyCheck.ts(66,9): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/discriminantPropertyCheck.ts (2 errors) ==== + + type Item = Item1 | Item2; + + interface Base { + bar: boolean; + } + + interface Item1 extends Base { + kind: "A"; + foo: string | undefined; + baz: boolean; + qux: true; + } + + interface Item2 extends Base { + kind: "B"; + foo: string | undefined; + baz: boolean; + qux: false; + } + + function goo1(x: Item) { + if (x.kind === "A" && x.foo !== undefined) { + x.foo.length; + } + } + + function goo2(x: Item) { + if (x.foo !== undefined && x.kind === "A") { + x.foo.length; // Error, intervening discriminant guard + ~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + + function foo1(x: Item) { + if (x.bar && x.foo !== undefined) { + x.foo.length; + } + } + + function foo2(x: Item) { + if (x.foo !== undefined && x.bar) { + x.foo.length; + } + } + + function foo3(x: Item) { + if (x.baz && x.foo !== undefined) { + x.foo.length; + } + } + + function foo4(x: Item) { + if (x.foo !== undefined && x.baz) { + x.foo.length; + } + } + + function foo5(x: Item) { + if (x.qux && x.foo !== undefined) { + x.foo.length; + } + } + + function foo6(x: Item) { + if (x.foo !== undefined && x.qux) { + x.foo.length; // Error, intervening discriminant guard + ~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/discriminantPropertyCheck.js b/tests/baselines/reference/discriminantPropertyCheck.js new file mode 100644 index 00000000000..b75a6277735 --- /dev/null +++ b/tests/baselines/reference/discriminantPropertyCheck.js @@ -0,0 +1,111 @@ +//// [discriminantPropertyCheck.ts] + +type Item = Item1 | Item2; + +interface Base { + bar: boolean; +} + +interface Item1 extends Base { + kind: "A"; + foo: string | undefined; + baz: boolean; + qux: true; +} + +interface Item2 extends Base { + kind: "B"; + foo: string | undefined; + baz: boolean; + qux: false; +} + +function goo1(x: Item) { + if (x.kind === "A" && x.foo !== undefined) { + x.foo.length; + } +} + +function goo2(x: Item) { + if (x.foo !== undefined && x.kind === "A") { + x.foo.length; // Error, intervening discriminant guard + } +} + +function foo1(x: Item) { + if (x.bar && x.foo !== undefined) { + x.foo.length; + } +} + +function foo2(x: Item) { + if (x.foo !== undefined && x.bar) { + x.foo.length; + } +} + +function foo3(x: Item) { + if (x.baz && x.foo !== undefined) { + x.foo.length; + } +} + +function foo4(x: Item) { + if (x.foo !== undefined && x.baz) { + x.foo.length; + } +} + +function foo5(x: Item) { + if (x.qux && x.foo !== undefined) { + x.foo.length; + } +} + +function foo6(x: Item) { + if (x.foo !== undefined && x.qux) { + x.foo.length; // Error, intervening discriminant guard + } +} + +//// [discriminantPropertyCheck.js] +function goo1(x) { + if (x.kind === "A" && x.foo !== undefined) { + x.foo.length; + } +} +function goo2(x) { + if (x.foo !== undefined && x.kind === "A") { + x.foo.length; // Error, intervening discriminant guard + } +} +function foo1(x) { + if (x.bar && x.foo !== undefined) { + x.foo.length; + } +} +function foo2(x) { + if (x.foo !== undefined && x.bar) { + x.foo.length; + } +} +function foo3(x) { + if (x.baz && x.foo !== undefined) { + x.foo.length; + } +} +function foo4(x) { + if (x.foo !== undefined && x.baz) { + x.foo.length; + } +} +function foo5(x) { + if (x.qux && x.foo !== undefined) { + x.foo.length; + } +} +function foo6(x) { + if (x.foo !== undefined && x.qux) { + x.foo.length; // Error, intervening discriminant guard + } +} diff --git a/tests/cases/compiler/discriminantPropertyCheck.ts b/tests/cases/compiler/discriminantPropertyCheck.ts new file mode 100644 index 00000000000..e493f6bf770 --- /dev/null +++ b/tests/cases/compiler/discriminantPropertyCheck.ts @@ -0,0 +1,69 @@ +// @strictNullChecks: true + +type Item = Item1 | Item2; + +interface Base { + bar: boolean; +} + +interface Item1 extends Base { + kind: "A"; + foo: string | undefined; + baz: boolean; + qux: true; +} + +interface Item2 extends Base { + kind: "B"; + foo: string | undefined; + baz: boolean; + qux: false; +} + +function goo1(x: Item) { + if (x.kind === "A" && x.foo !== undefined) { + x.foo.length; + } +} + +function goo2(x: Item) { + if (x.foo !== undefined && x.kind === "A") { + x.foo.length; // Error, intervening discriminant guard + } +} + +function foo1(x: Item) { + if (x.bar && x.foo !== undefined) { + x.foo.length; + } +} + +function foo2(x: Item) { + if (x.foo !== undefined && x.bar) { + x.foo.length; + } +} + +function foo3(x: Item) { + if (x.baz && x.foo !== undefined) { + x.foo.length; + } +} + +function foo4(x: Item) { + if (x.foo !== undefined && x.baz) { + x.foo.length; + } +} + +function foo5(x: Item) { + if (x.qux && x.foo !== undefined) { + x.foo.length; + } +} + +function foo6(x: Item) { + if (x.foo !== undefined && x.qux) { + x.foo.length; // Error, intervening discriminant guard + } +} \ No newline at end of file From cc2dc3acb0a3c654ca6ca26cad906af5585fcadf Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Sat, 6 Aug 2016 10:36:17 -0700 Subject: [PATCH 091/508] Emit more efficient/concise "empty" ES6 ctor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When there are property assignments in a the class body of an inheriting class, tsc current emit the following compilation: ```ts class Foo extends Bar { public foo = 1; } ``` ```js class Foo extends Bar { constructor(…args) { super(…args); this.foo = 1; } } ``` This introduces an unneeded local variable and might force a reification of the `arguments` object (or otherwise reify the arguments into an array). This is particularly bad when that output is fed into another transpiler like Babel. In Babel, you get something like this today: ```js var Foo = (function (_Bar) { _inherits(Foo, _Bar); function Foo() { _classCallCheck(this, Foo); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _Bar.call.apply(_Bar, [this].concat(args)); this.foo = 1; } return Foo; })(Bar); ``` This causes a lot of needless work/allocations and some very strange code (`.call.apply` o_0). Admittedly, this is not strictly tsc’s problem; it could have done a deeper analysis of the code and optimized out the extra dance. However, tsc could also have emitted this simpler, more concise and semantically equivalent code in the first place: ```js class Foo extends Bar { constructor() { super(…arguments); this.foo = 1; } } ``` Which compiles into the following in Babel: ```js var Foo = (function (_Bar) { _inherits(Foo, _Bar); function Foo() { _classCallCheck(this, Foo); _Bar.apply(this, arguments); this.foo = 1; } return Foo; })(Bar); ``` Which is well-optimized (today) in most engines and much less confusing to read. As far as I can tell, the proposed compilation has exactly the same semantics as before. Fixes #10175 --- src/compiler/emitter.ts | 15 ++------------- tests/baselines/reference/classExpressionES63.js | 8 ++++---- ...ClassDeclarationWithPropertyAssignmentInES6.js | 4 ++-- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index c8bd8072b24..6666b7df235 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5311,18 +5311,7 @@ const _super = (function (geti, seti) { emitSignatureParameters(ctor); } else { - // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. - // If constructor is empty, then, - // If ClassHeritageopt is present, then - // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. - // Else, - // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition - if (baseTypeElement) { - write("(...args)"); - } - else { - write("()"); - } + write("()"); } } @@ -5360,7 +5349,7 @@ const _super = (function (geti, seti) { write("_super.apply(this, arguments);"); } else { - write("super(...args);"); + write("super(...arguments);"); } emitEnd(baseTypeElement); } diff --git a/tests/baselines/reference/classExpressionES63.js b/tests/baselines/reference/classExpressionES63.js index 6b3a06cf7c3..5a72e173475 100644 --- a/tests/baselines/reference/classExpressionES63.js +++ b/tests/baselines/reference/classExpressionES63.js @@ -13,14 +13,14 @@ let C = class extends class extends class { } } { - constructor(...args) { - super(...args); + constructor() { + super(...arguments); this.b = 2; } } { - constructor(...args) { - super(...args); + constructor() { + super(...arguments); this.c = 3; } } diff --git a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js index 03fb45b806e..91e6c506c2b 100644 --- a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js +++ b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js @@ -37,8 +37,8 @@ class D { } } class E extends D { - constructor(...args) { - super(...args); + constructor() { + super(...arguments); this.z = true; } } From 01f865dee7f36f00ad79877b09661e6b8de08b21 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 7 Aug 2016 07:48:40 -0700 Subject: [PATCH 092/508] Fix instanceof operator narrowing issues --- src/compiler/checker.ts | 53 +++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9583fadba62..7dbd6c1ab8b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8084,6 +8084,25 @@ namespace ts { return source.flags & TypeFlags.Union ? !forEach((source).types, t => !contains(types, t)) : contains(types, source); } + function isTypeSubsetOf(source: Type, target: Type) { + return source === target || target.flags & TypeFlags.Union && isTypeSubsetOfUnion(source, target); + } + + function isTypeSubsetOfUnion(source: Type, target: UnionType) { + if (source.flags & TypeFlags.Union) { + for (const t of (source).types) { + if (!containsType(target.types, t)) { + return false; + } + } + return true; + } + if (source.flags & TypeFlags.EnumLiteral && target.flags & TypeFlags.Enum && (source).baseType === target) { + return true; + } + return containsType(target.types, source); + } + function filterType(type: Type, f: (t: Type) => boolean): Type { return type.flags & TypeFlags.Union ? getUnionType(filter((type).types, f)) : @@ -8230,6 +8249,7 @@ namespace ts { function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType { const antecedentTypes: Type[] = []; + let subtypeReduction = false; let seenIncomplete = false; for (const antecedent of flow.antecedents) { const flowType = getTypeAtFlowNode(antecedent); @@ -8244,11 +8264,17 @@ namespace ts { if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); } + // If an antecedent type is not a subset of the declared type, we need to perform + // subtype reduction. This happens when a "foreign" type is injected into the control + // flow using the instanceof operator or a user defined type predicate. + if (!isTypeSubsetOf(type, declaredType)) { + subtypeReduction = true; + } if (isIncomplete(flowType)) { seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes), seenIncomplete); + return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow: FlowLabel): FlowType { @@ -8274,6 +8300,7 @@ namespace ts { // Add the flow loop junction and reference to the in-process stack and analyze // each antecedent code path. const antecedentTypes: Type[] = []; + let subtypeReduction = false; flowLoopNodes[flowLoopCount] = flow; flowLoopKeys[flowLoopCount] = key; flowLoopTypes[flowLoopCount] = antecedentTypes; @@ -8290,6 +8317,12 @@ namespace ts { if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); } + // If an antecedent type is not a subset of the declared type, we need to perform + // subtype reduction. This happens when a "foreign" type is injected into the control + // flow using the instanceof operator or a user defined type predicate. + if (!isTypeSubsetOf(type, declaredType)) { + subtypeReduction = true; + } // If the type at a particular antecedent path is the declared type there is no // reason to process more antecedents since the only possible outcome is subtypes // that will be removed in the final union type anyway. @@ -8297,7 +8330,7 @@ namespace ts { break; } } - return cache[key] = getUnionType(antecedentTypes); + return cache[key] = getUnionType(antecedentTypes, subtypeReduction); } function isMatchingPropertyAccess(expr: Expression) { @@ -8494,9 +8527,7 @@ namespace ts { function getNarrowedType(type: Type, candidate: Type, assumeTrue: boolean) { if (!assumeTrue) { - return type.flags & TypeFlags.Union ? - getUnionType(filter((type).types, t => !isTypeSubtypeOf(t, candidate))) : - type; + return filterType(type, t => !isTypeSubtypeOf(t, candidate)); } // If the current type is a union type, remove all constituents that aren't assignable to // the candidate type. If one or more constituents remain, return a union of those. @@ -8506,13 +8537,15 @@ namespace ts { return getUnionType(assignableConstituents); } } - // If the candidate type is assignable to the target type, narrow to the candidate type. - // Otherwise, if the current type is assignable to the candidate, keep the current type. - // Otherwise, the types are completely unrelated, so narrow to the empty type. + // If the candidate type is a subtype of the target type, narrow to the candidate type. + // Otherwise, narrow to whichever of the target type or the candidate type that is assignable + // to the other. Otherwise, the types are completely unrelated, so narrow to an intersection + // of the two types. const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type; - return isTypeAssignableTo(candidate, targetType) ? candidate : + return isTypeSubtypeOf(candidate, targetType) ? candidate : isTypeAssignableTo(type, candidate) ? type : - getIntersectionType([type, candidate]); + isTypeAssignableTo(candidate, targetType) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type { From f50226b481900af204ed9f8d0c29e32a56827c54 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 7 Aug 2016 07:53:36 -0700 Subject: [PATCH 093/508] Accept new baselines --- .../baselines/reference/controlFlowBinaryOrExpression.symbols | 4 ++-- tests/baselines/reference/controlFlowBinaryOrExpression.types | 2 +- tests/baselines/reference/stringLiteralTypesAsTags01.types | 4 ++-- tests/baselines/reference/stringLiteralTypesAsTags02.types | 4 ++-- tests/baselines/reference/stringLiteralTypesAsTags03.types | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.symbols b/tests/baselines/reference/controlFlowBinaryOrExpression.symbols index e76cfbf4cab..5251973005f 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.symbols +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.symbols @@ -86,8 +86,8 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) sourceObj.length; ->sourceObj.length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>sourceObj.length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27)) >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) ->length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27)) } diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.types b/tests/baselines/reference/controlFlowBinaryOrExpression.types index 0bf5ab524b9..d24462316b4 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.types +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.types @@ -106,7 +106,7 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { sourceObj.length; >sourceObj.length : number ->sourceObj : NodeList | HTMLCollection | ({ a: string; } & HTMLCollection) +>sourceObj : NodeList >length : number } diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.types b/tests/baselines/reference/stringLiteralTypesAsTags01.types index e00fd18163d..e95a7364f93 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.types @@ -99,8 +99,8 @@ if (hasKind(x, "A")) { } else { let b = x; ->b : A ->x : A +>b : never +>x : never } if (!hasKind(x, "B")) { diff --git a/tests/baselines/reference/stringLiteralTypesAsTags02.types b/tests/baselines/reference/stringLiteralTypesAsTags02.types index fb1632559ea..c984b8a78f9 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags02.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags02.types @@ -93,8 +93,8 @@ if (hasKind(x, "A")) { } else { let b = x; ->b : A ->x : A +>b : never +>x : never } if (!hasKind(x, "B")) { diff --git a/tests/baselines/reference/stringLiteralTypesAsTags03.types b/tests/baselines/reference/stringLiteralTypesAsTags03.types index 05be633813b..fbe71ff07c1 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags03.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags03.types @@ -96,8 +96,8 @@ if (hasKind(x, "A")) { } else { let b = x; ->b : A ->x : A +>b : never +>x : never } if (!hasKind(x, "B")) { From 67b3fe58fa9b0761da93d9ea6ab2e8019b6a4b22 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 7 Aug 2016 08:53:36 -0700 Subject: [PATCH 094/508] Add regression test --- .../reference/controlFlowInstanceof.js | 156 +++++++++++++ .../reference/controlFlowInstanceof.symbols | 194 ++++++++++++++++ .../reference/controlFlowInstanceof.types | 217 ++++++++++++++++++ tests/cases/compiler/controlFlowInstanceof.ts | 80 +++++++ 4 files changed, 647 insertions(+) create mode 100644 tests/baselines/reference/controlFlowInstanceof.js create mode 100644 tests/baselines/reference/controlFlowInstanceof.symbols create mode 100644 tests/baselines/reference/controlFlowInstanceof.types create mode 100644 tests/cases/compiler/controlFlowInstanceof.ts diff --git a/tests/baselines/reference/controlFlowInstanceof.js b/tests/baselines/reference/controlFlowInstanceof.js new file mode 100644 index 00000000000..7c7833927ca --- /dev/null +++ b/tests/baselines/reference/controlFlowInstanceof.js @@ -0,0 +1,156 @@ +//// [controlFlowInstanceof.ts] + +// Repros from #10167 + +function f1(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + s; // Set + s.add(42); +} + +function f2(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Promise) { + s; // Set & Promise + } + s; // Set + s.add(42); +} + +function f3(s: Set | Set) { + s; // Set | Set + if (s instanceof Set) { + s; // Set | Set + } + else { + s; // never + } +} + +function f4(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + else { + s; // never + } +} + +// More tests + +class A { a: string } +class B extends A { b: string } +class C extends A { c: string } + +function foo(x: A | undefined) { + x; // A | undefined + if (x instanceof B || x instanceof C) { + x; // B | C + } + x; // A | undefined + if (x instanceof B && x instanceof C) { + x; // B & C + } + x; // A | undefined + if (!x) { + return; + } + x; // A + if (x instanceof B) { + x; // B + if (x instanceof C) { + x; // B & C + } + else { + x; // B + } + x; // B + } + else { + x; // A + } + x; // A +} + +//// [controlFlowInstanceof.js] +// Repros from #10167 +function f1(s) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + s; // Set + s.add(42); +} +function f2(s) { + s = new Set(); + s; // Set + if (s instanceof Promise) { + s; // Set & Promise + } + s; // Set + s.add(42); +} +function f3(s) { + s; // Set | Set + if (s instanceof Set) { + s; // Set | Set + } + else { + s; // never + } +} +function f4(s) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + else { + s; // never + } +} +// More tests +class A { +} +class B extends A { +} +class C extends A { +} +function foo(x) { + x; // A | undefined + if (x instanceof B || x instanceof C) { + x; // B | C + } + x; // A | undefined + if (x instanceof B && x instanceof C) { + x; // B & C + } + x; // A | undefined + if (!x) { + return; + } + x; // A + if (x instanceof B) { + x; // B + if (x instanceof C) { + x; // B & C + } + else { + x; // B + } + x; // B + } + else { + x; // A + } + x; // A +} diff --git a/tests/baselines/reference/controlFlowInstanceof.symbols b/tests/baselines/reference/controlFlowInstanceof.symbols new file mode 100644 index 00000000000..64b567c1548 --- /dev/null +++ b/tests/baselines/reference/controlFlowInstanceof.symbols @@ -0,0 +1,194 @@ +=== tests/cases/compiler/controlFlowInstanceof.ts === + +// Repros from #10167 + +function f1(s: Set | Set) { +>f1 : Symbol(f1, Decl(controlFlowInstanceof.ts, 0, 0)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s = new Set(); +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) + + if (s instanceof Set) { +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) + } + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) + + s.add(42); +>s.add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) +>add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) +} + +function f2(s: Set | Set) { +>f2 : Symbol(f2, Decl(controlFlowInstanceof.ts, 11, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s = new Set(); +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) + + if (s instanceof Promise) { +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + s; // Set & Promise +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) + } + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) + + s.add(42); +>s.add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) +>add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) +} + +function f3(s: Set | Set) { +>f3 : Symbol(f3, Decl(controlFlowInstanceof.ts, 21, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set | Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) + + if (s instanceof Set) { +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set | Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) + } + else { + s; // never +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) + } +} + +function f4(s: Set | Set) { +>f4 : Symbol(f4, Decl(controlFlowInstanceof.ts, 31, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s = new Set(); +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) + + if (s instanceof Set) { +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) + } + else { + s; // never +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) + } +} + +// More tests + +class A { a: string } +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 42, 1)) +>a : Symbol(A.a, Decl(controlFlowInstanceof.ts, 46, 9)) + +class B extends A { b: string } +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 46, 21)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 42, 1)) +>b : Symbol(B.b, Decl(controlFlowInstanceof.ts, 47, 19)) + +class C extends A { c: string } +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 47, 31)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 42, 1)) +>c : Symbol(C.c, Decl(controlFlowInstanceof.ts, 48, 19)) + +function foo(x: A | undefined) { +>foo : Symbol(foo, Decl(controlFlowInstanceof.ts, 48, 31)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 42, 1)) + + x; // A | undefined +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (x instanceof B || x instanceof C) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 46, 21)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 47, 31)) + + x; // B | C +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + x; // A | undefined +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (x instanceof B && x instanceof C) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 46, 21)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 47, 31)) + + x; // B & C +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + x; // A | undefined +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (!x) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + return; + } + x; // A +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (x instanceof B) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 46, 21)) + + x; // B +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (x instanceof C) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 47, 31)) + + x; // B & C +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + else { + x; // B +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + x; // B +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + else { + x; // A +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + x; // A +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +} diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types new file mode 100644 index 00000000000..362715914f9 --- /dev/null +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -0,0 +1,217 @@ +=== tests/cases/compiler/controlFlowInstanceof.ts === + +// Repros from #10167 + +function f1(s: Set | Set) { +>f1 : (s: Set | Set) => void +>s : Set | Set +>Set : Set +>Set : Set + + s = new Set(); +>s = new Set() : Set +>s : Set | Set +>new Set() : Set +>Set : SetConstructor + + s; // Set +>s : Set + + if (s instanceof Set) { +>s instanceof Set : boolean +>s : Set +>Set : SetConstructor + + s; // Set +>s : Set + } + s; // Set +>s : Set + + s.add(42); +>s.add(42) : Set +>s.add : (value: number) => Set +>s : Set +>add : (value: number) => Set +>42 : number +} + +function f2(s: Set | Set) { +>f2 : (s: Set | Set) => void +>s : Set | Set +>Set : Set +>Set : Set + + s = new Set(); +>s = new Set() : Set +>s : Set | Set +>new Set() : Set +>Set : SetConstructor + + s; // Set +>s : Set + + if (s instanceof Promise) { +>s instanceof Promise : boolean +>s : Set +>Promise : PromiseConstructor + + s; // Set & Promise +>s : Set & Promise + } + s; // Set +>s : Set + + s.add(42); +>s.add(42) : Set +>s.add : (value: number) => Set +>s : Set +>add : (value: number) => Set +>42 : number +} + +function f3(s: Set | Set) { +>f3 : (s: Set | Set) => void +>s : Set | Set +>Set : Set +>Set : Set + + s; // Set | Set +>s : Set | Set + + if (s instanceof Set) { +>s instanceof Set : boolean +>s : Set | Set +>Set : SetConstructor + + s; // Set | Set +>s : Set | Set + } + else { + s; // never +>s : never + } +} + +function f4(s: Set | Set) { +>f4 : (s: Set | Set) => void +>s : Set | Set +>Set : Set +>Set : Set + + s = new Set(); +>s = new Set() : Set +>s : Set | Set +>new Set() : Set +>Set : SetConstructor + + s; // Set +>s : Set + + if (s instanceof Set) { +>s instanceof Set : boolean +>s : Set +>Set : SetConstructor + + s; // Set +>s : Set + } + else { + s; // never +>s : never + } +} + +// More tests + +class A { a: string } +>A : A +>a : string + +class B extends A { b: string } +>B : B +>A : A +>b : string + +class C extends A { c: string } +>C : C +>A : A +>c : string + +function foo(x: A | undefined) { +>foo : (x: A) => void +>x : A +>A : A + + x; // A | undefined +>x : A + + if (x instanceof B || x instanceof C) { +>x instanceof B || x instanceof C : boolean +>x instanceof B : boolean +>x : A +>B : typeof B +>x instanceof C : boolean +>x : A +>C : typeof C + + x; // B | C +>x : B | C + } + x; // A | undefined +>x : A + + if (x instanceof B && x instanceof C) { +>x instanceof B && x instanceof C : boolean +>x instanceof B : boolean +>x : A +>B : typeof B +>x instanceof C : boolean +>x : B +>C : typeof C + + x; // B & C +>x : B & C + } + x; // A | undefined +>x : A + + if (!x) { +>!x : boolean +>x : A + + return; + } + x; // A +>x : A + + if (x instanceof B) { +>x instanceof B : boolean +>x : A +>B : typeof B + + x; // B +>x : B + + if (x instanceof C) { +>x instanceof C : boolean +>x : B +>C : typeof C + + x; // B & C +>x : B & C + } + else { + x; // B +>x : B + } + x; // B +>x : B + } + else { + x; // A +>x : A + } + x; // A +>x : A +} diff --git a/tests/cases/compiler/controlFlowInstanceof.ts b/tests/cases/compiler/controlFlowInstanceof.ts new file mode 100644 index 00000000000..229a00236ba --- /dev/null +++ b/tests/cases/compiler/controlFlowInstanceof.ts @@ -0,0 +1,80 @@ +// @target: es6 + +// Repros from #10167 + +function f1(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + s; // Set + s.add(42); +} + +function f2(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Promise) { + s; // Set & Promise + } + s; // Set + s.add(42); +} + +function f3(s: Set | Set) { + s; // Set | Set + if (s instanceof Set) { + s; // Set | Set + } + else { + s; // never + } +} + +function f4(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + else { + s; // never + } +} + +// More tests + +class A { a: string } +class B extends A { b: string } +class C extends A { c: string } + +function foo(x: A | undefined) { + x; // A | undefined + if (x instanceof B || x instanceof C) { + x; // B | C + } + x; // A | undefined + if (x instanceof B && x instanceof C) { + x; // B & C + } + x; // A | undefined + if (!x) { + return; + } + x; // A + if (x instanceof B) { + x; // B + if (x instanceof C) { + x; // B & C + } + else { + x; // B + } + x; // B + } + else { + x; // A + } + x; // A +} \ No newline at end of file From 2845d2f8b8c2c476085eda9abe083000047d70c4 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 8 Aug 2016 09:04:46 -0700 Subject: [PATCH 095/508] Improve naming and documentation from PR --- src/compiler/binder.ts | 9 +++++++-- src/compiler/types.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index b771a3b67be..849f503ef85 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -313,6 +313,11 @@ namespace ts { // declaration we have for this symbol, and then create a new symbol for this // declaration. // + // Note that when properties declared in Javascript constructors + // (marked by isReplaceableByMethod) conflict with another symbol, the property loses. + // Always. This allows the common Javascript pattern of overwriting a prototype method + // with an bound instance method of the same type: `this.method = this.method.bind(this)` + // // If we created a new symbol, either because we didn't have a symbol with this name // in the symbol table, or we conflicted with an existing symbol, then just add this // node as the sole declaration of the new symbol. @@ -329,7 +334,7 @@ namespace ts { } if (symbol.flags & excludes) { - if (symbol.isDiscardable) { + if (symbol.isReplaceableByMethod) { // Javascript constructor-declared symbols can be discarded in favor of // prototype symbols like methods. symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name); @@ -1988,7 +1993,7 @@ namespace ts { // It's acceptable for multiple 'this' assignments of the same identifier to occur // AND it can be overwritten by subsequent method declarations const symbol = declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); - symbol.isDiscardable = true; + symbol.isReplaceableByMethod = true; } function bindPrototypePropertyAssignment(node: BinaryExpression) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f5cee2f8f8f..70bd3c3c070 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2137,7 +2137,7 @@ namespace ts { /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums /* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere - /* @internal */ isDiscardable?: boolean; // True if a Javascript class property can be overwritten by a method + /* @internal */ isReplaceableByMethod?: boolean; // Can this Javascript class property be replaced by a method symbol? } /* @internal */ From a0c5608770b911d357c745f4842e03b408a135fe Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Aug 2016 09:44:24 -0700 Subject: [PATCH 096/508] Update comment --- src/compiler/checker.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7dbd6c1ab8b..09402b94119 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8538,9 +8538,10 @@ namespace ts { } } // If the candidate type is a subtype of the target type, narrow to the candidate type. - // Otherwise, narrow to whichever of the target type or the candidate type that is assignable - // to the other. Otherwise, the types are completely unrelated, so narrow to an intersection - // of the two types. + // Otherwise, if the target type is assignable to the candidate type, keep the target type. + // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate + // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the + // two types. const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type; return isTypeSubtypeOf(candidate, targetType) ? candidate : isTypeAssignableTo(type, candidate) ? type : From ce5a3f466d281695d700fbd08dcb92a685340809 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Aug 2016 09:44:43 -0700 Subject: [PATCH 097/508] Add more tests --- tests/cases/compiler/controlFlowInstanceof.ts | 19 ++++++++++++ .../discriminantsAndTypePredicates.ts | 31 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tests/cases/compiler/discriminantsAndTypePredicates.ts diff --git a/tests/cases/compiler/controlFlowInstanceof.ts b/tests/cases/compiler/controlFlowInstanceof.ts index 229a00236ba..56f3ff97e4c 100644 --- a/tests/cases/compiler/controlFlowInstanceof.ts +++ b/tests/cases/compiler/controlFlowInstanceof.ts @@ -77,4 +77,23 @@ function foo(x: A | undefined) { x; // A } x; // A +} + +// X is neither assignable to Y nor a subtype of Y +// Y is assignable to X, but not a subtype of X + +interface X { + x?: string; +} + +class Y { + y: string; +} + +function goo(x: X) { + x; + if (x instanceof Y) { + x.y; + } + x; } \ No newline at end of file diff --git a/tests/cases/compiler/discriminantsAndTypePredicates.ts b/tests/cases/compiler/discriminantsAndTypePredicates.ts new file mode 100644 index 00000000000..c21ab7ec8f4 --- /dev/null +++ b/tests/cases/compiler/discriminantsAndTypePredicates.ts @@ -0,0 +1,31 @@ +// Repro from #10145 + +interface A { type: 'A' } +interface B { type: 'B' } + +function isA(x: A | B): x is A { return x.type === 'A'; } +function isB(x: A | B): x is B { return x.type === 'B'; } + +function foo1(x: A | B): any { + x; // A | B + if (isA(x)) { + return x; // A + } + x; // B + if (isB(x)) { + return x; // B + } + x; // never +} + +function foo2(x: A | B): any { + x; // A | B + if (x.type === 'A') { + return x; // A + } + x; // B + if (x.type === 'B') { + return x; // B + } + x; // never +} \ No newline at end of file From ba521de66d8f654784be4f011814a5ca17b413a2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Aug 2016 09:45:12 -0700 Subject: [PATCH 098/508] Accept new baselines --- .../reference/controlFlowInstanceof.js | 28 +++++ .../reference/controlFlowInstanceof.symbols | 38 +++++++ .../reference/controlFlowInstanceof.types | 39 +++++++ .../discriminantsAndTypePredicates.js | 59 ++++++++++ .../discriminantsAndTypePredicates.symbols | 94 ++++++++++++++++ .../discriminantsAndTypePredicates.types | 104 ++++++++++++++++++ 6 files changed, 362 insertions(+) create mode 100644 tests/baselines/reference/discriminantsAndTypePredicates.js create mode 100644 tests/baselines/reference/discriminantsAndTypePredicates.symbols create mode 100644 tests/baselines/reference/discriminantsAndTypePredicates.types diff --git a/tests/baselines/reference/controlFlowInstanceof.js b/tests/baselines/reference/controlFlowInstanceof.js index 7c7833927ca..3f2287b4628 100644 --- a/tests/baselines/reference/controlFlowInstanceof.js +++ b/tests/baselines/reference/controlFlowInstanceof.js @@ -77,6 +77,25 @@ function foo(x: A | undefined) { x; // A } x; // A +} + +// X is neither assignable to Y nor a subtype of Y +// Y is assignable to X, but not a subtype of X + +interface X { + x?: string; +} + +class Y { + y: string; +} + +function goo(x: X) { + x; + if (x instanceof Y) { + x.y; + } + x; } //// [controlFlowInstanceof.js] @@ -154,3 +173,12 @@ function foo(x) { } x; // A } +class Y { +} +function goo(x) { + x; + if (x instanceof Y) { + x.y; + } + x; +} diff --git a/tests/baselines/reference/controlFlowInstanceof.symbols b/tests/baselines/reference/controlFlowInstanceof.symbols index 64b567c1548..31894827990 100644 --- a/tests/baselines/reference/controlFlowInstanceof.symbols +++ b/tests/baselines/reference/controlFlowInstanceof.symbols @@ -192,3 +192,41 @@ function foo(x: A | undefined) { x; // A >x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) } + +// X is neither assignable to Y nor a subtype of Y +// Y is assignable to X, but not a subtype of X + +interface X { +>X : Symbol(X, Decl(controlFlowInstanceof.ts, 78, 1)) + + x?: string; +>x : Symbol(X.x, Decl(controlFlowInstanceof.ts, 83, 13)) +} + +class Y { +>Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 85, 1)) + + y: string; +>y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 87, 9)) +} + +function goo(x: X) { +>goo : Symbol(goo, Decl(controlFlowInstanceof.ts, 89, 1)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) +>X : Symbol(X, Decl(controlFlowInstanceof.ts, 78, 1)) + + x; +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) + + if (x instanceof Y) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) +>Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 85, 1)) + + x.y; +>x.y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 87, 9)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) +>y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 87, 9)) + } + x; +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) +} diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types index 362715914f9..e52d1a25b1d 100644 --- a/tests/baselines/reference/controlFlowInstanceof.types +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -215,3 +215,42 @@ function foo(x: A | undefined) { x; // A >x : A } + +// X is neither assignable to Y nor a subtype of Y +// Y is assignable to X, but not a subtype of X + +interface X { +>X : X + + x?: string; +>x : string +} + +class Y { +>Y : Y + + y: string; +>y : string +} + +function goo(x: X) { +>goo : (x: X) => void +>x : X +>X : X + + x; +>x : X + + if (x instanceof Y) { +>x instanceof Y : boolean +>x : X +>Y : typeof Y + + x.y; +>x.y : string +>x : Y +>y : string + } + x; +>x : X +} diff --git a/tests/baselines/reference/discriminantsAndTypePredicates.js b/tests/baselines/reference/discriminantsAndTypePredicates.js new file mode 100644 index 00000000000..66cfe056ab7 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndTypePredicates.js @@ -0,0 +1,59 @@ +//// [discriminantsAndTypePredicates.ts] +// Repro from #10145 + +interface A { type: 'A' } +interface B { type: 'B' } + +function isA(x: A | B): x is A { return x.type === 'A'; } +function isB(x: A | B): x is B { return x.type === 'B'; } + +function foo1(x: A | B): any { + x; // A | B + if (isA(x)) { + return x; // A + } + x; // B + if (isB(x)) { + return x; // B + } + x; // never +} + +function foo2(x: A | B): any { + x; // A | B + if (x.type === 'A') { + return x; // A + } + x; // B + if (x.type === 'B') { + return x; // B + } + x; // never +} + +//// [discriminantsAndTypePredicates.js] +// Repro from #10145 +function isA(x) { return x.type === 'A'; } +function isB(x) { return x.type === 'B'; } +function foo1(x) { + x; // A | B + if (isA(x)) { + return x; // A + } + x; // B + if (isB(x)) { + return x; // B + } + x; // never +} +function foo2(x) { + x; // A | B + if (x.type === 'A') { + return x; // A + } + x; // B + if (x.type === 'B') { + return x; // B + } + x; // never +} diff --git a/tests/baselines/reference/discriminantsAndTypePredicates.symbols b/tests/baselines/reference/discriminantsAndTypePredicates.symbols new file mode 100644 index 00000000000..4f412823936 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndTypePredicates.symbols @@ -0,0 +1,94 @@ +=== tests/cases/compiler/discriminantsAndTypePredicates.ts === +// Repro from #10145 + +interface A { type: 'A' } +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>type : Symbol(A.type, Decl(discriminantsAndTypePredicates.ts, 2, 13)) + +interface B { type: 'B' } +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) +>type : Symbol(B.type, Decl(discriminantsAndTypePredicates.ts, 3, 13)) + +function isA(x: A | B): x is A { return x.type === 'A'; } +>isA : Symbol(isA, Decl(discriminantsAndTypePredicates.ts, 3, 25)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 5, 13)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 5, 13)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>x.type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 5, 13)) +>type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) + +function isB(x: A | B): x is B { return x.type === 'B'; } +>isB : Symbol(isB, Decl(discriminantsAndTypePredicates.ts, 5, 57)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 6, 13)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 6, 13)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) +>x.type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 6, 13)) +>type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) + +function foo1(x: A | B): any { +>foo1 : Symbol(foo1, Decl(discriminantsAndTypePredicates.ts, 6, 57)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) + + x; // A | B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + + if (isA(x)) { +>isA : Symbol(isA, Decl(discriminantsAndTypePredicates.ts, 3, 25)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + + return x; // A +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + } + x; // B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + + if (isB(x)) { +>isB : Symbol(isB, Decl(discriminantsAndTypePredicates.ts, 5, 57)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + + return x; // B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + } + x; // never +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) +} + +function foo2(x: A | B): any { +>foo2 : Symbol(foo2, Decl(discriminantsAndTypePredicates.ts, 18, 1)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) + + x; // A | B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) + + if (x.type === 'A') { +>x.type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) +>type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) + + return x; // A +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) + } + x; // B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) + + if (x.type === 'B') { +>x.type : Symbol(B.type, Decl(discriminantsAndTypePredicates.ts, 3, 13)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) +>type : Symbol(B.type, Decl(discriminantsAndTypePredicates.ts, 3, 13)) + + return x; // B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) + } + x; // never +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) +} diff --git a/tests/baselines/reference/discriminantsAndTypePredicates.types b/tests/baselines/reference/discriminantsAndTypePredicates.types new file mode 100644 index 00000000000..f7675b14756 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndTypePredicates.types @@ -0,0 +1,104 @@ +=== tests/cases/compiler/discriminantsAndTypePredicates.ts === +// Repro from #10145 + +interface A { type: 'A' } +>A : A +>type : "A" + +interface B { type: 'B' } +>B : B +>type : "B" + +function isA(x: A | B): x is A { return x.type === 'A'; } +>isA : (x: A | B) => x is A +>x : A | B +>A : A +>B : B +>x : any +>A : A +>x.type === 'A' : boolean +>x.type : "A" | "B" +>x : A | B +>type : "A" | "B" +>'A' : "A" + +function isB(x: A | B): x is B { return x.type === 'B'; } +>isB : (x: A | B) => x is B +>x : A | B +>A : A +>B : B +>x : any +>B : B +>x.type === 'B' : boolean +>x.type : "A" | "B" +>x : A | B +>type : "A" | "B" +>'B' : "B" + +function foo1(x: A | B): any { +>foo1 : (x: A | B) => any +>x : A | B +>A : A +>B : B + + x; // A | B +>x : A | B + + if (isA(x)) { +>isA(x) : boolean +>isA : (x: A | B) => x is A +>x : A | B + + return x; // A +>x : A + } + x; // B +>x : B + + if (isB(x)) { +>isB(x) : boolean +>isB : (x: A | B) => x is B +>x : B + + return x; // B +>x : B + } + x; // never +>x : never +} + +function foo2(x: A | B): any { +>foo2 : (x: A | B) => any +>x : A | B +>A : A +>B : B + + x; // A | B +>x : A | B + + if (x.type === 'A') { +>x.type === 'A' : boolean +>x.type : "A" | "B" +>x : A | B +>type : "A" | "B" +>'A' : "A" + + return x; // A +>x : A + } + x; // B +>x : B + + if (x.type === 'B') { +>x.type === 'B' : boolean +>x.type : "B" +>x : B +>type : "B" +>'B' : "B" + + return x; // B +>x : B + } + x; // never +>x : never +} From 8a976f1100d96259bb6cb10b2ef4d7d813abd478 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 8 Aug 2016 11:04:17 -0700 Subject: [PATCH 099/508] Moving some utility functions around --- src/services/services.ts | 21 --------------------- src/services/utilities.ts | 31 ++++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 1a952491365..ade5cc0b1bf 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2063,9 +2063,6 @@ namespace ts { sourceMapText?: string; } - // Matches the beginning of a triple slash directive - const tripleSlashDirectivePrefixRegex = /^\/\/\/\s* Date: Mon, 8 Aug 2016 13:11:02 -0700 Subject: [PATCH 100/508] Reduce worker count to 3 (#10210) Since we saw a starvation issue on one of @sandersn's PRs. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index cb9bf42225a..4126683eb62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,7 @@ node_js: sudo: false env: - - workerCount=4 + - workerCount=3 matrix: fast_finish: true From ce7f554090c68ad9c897ea4928596a8c64d6e934 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 8 Aug 2016 13:15:25 -0700 Subject: [PATCH 101/508] Speed up fourslash tests --- src/harness/fourslash.ts | 107 +++++++++++++-------------------------- 1 file changed, 35 insertions(+), 72 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a42abbbc609..366891c0d30 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -249,6 +249,7 @@ namespace FourSlash { if (compilationOptions.typeRoots) { compilationOptions.typeRoots = compilationOptions.typeRoots.map(p => ts.getNormalizedAbsolutePath(p, this.basePath)); } + compilationOptions.skipDefaultLibCheck = true; const languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions); this.languageServiceAdapterHost = languageServiceAdapter.getHost(); @@ -376,7 +377,7 @@ namespace FourSlash { public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) { const startMarker = this.getMarkerByName(startMarkerName); const endMarker = this.getMarkerByName(endMarkerName); - const predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { + const predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false; }; @@ -428,12 +429,12 @@ namespace FourSlash { let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean; if (after) { - predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { + predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false; }; } else { - predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { + predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false; }; } @@ -458,7 +459,7 @@ namespace FourSlash { endPos = endMarker.position; } - errors.forEach(function (error: ts.Diagnostic) { + errors.forEach(function(error: ts.Diagnostic) { if (predicate(error.start, error.start + error.length, startPos, endPos)) { exists = true; } @@ -475,7 +476,7 @@ namespace FourSlash { Harness.IO.log("Unexpected error(s) found. Error list is:"); } - errors.forEach(function (error: ts.Diagnostic) { + errors.forEach(function(error: ts.Diagnostic) { Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + ", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n"); @@ -1348,14 +1349,7 @@ namespace FourSlash { } // Enters lines of text at the current caret position - public type(text: string) { - return this.typeHighFidelity(text); - } - - // Enters lines of text at the current caret position, invoking - // language service APIs to mimic Visual Studio's behavior - // as much as possible - private typeHighFidelity(text: string) { + public type(text: string, highFidelity = false) { let offset = this.currentCaretPosition; const prevChar = " "; const checkCadence = (text.length >> 2) + 1; @@ -1364,24 +1358,26 @@ namespace FourSlash { // Make the edit const ch = text.charAt(i); this.languageServiceAdapterHost.editScript(this.activeFile.fileName, offset, offset, ch); - this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, offset); + if (highFidelity) { + this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, offset); + } this.updateMarkersForEdit(this.activeFile.fileName, offset, offset, ch); offset++; - if (ch === "(" || ch === ",") { - /* Signature help*/ - this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset); - } - else if (prevChar === " " && /A-Za-z_/.test(ch)) { - /* Completions */ - this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset); - } + if (highFidelity) { + if (ch === "(" || ch === ",") { + /* Signature help*/ + this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset); + } + else if (prevChar === " " && /A-Za-z_/.test(ch)) { + /* Completions */ + this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset); + } - if (i % checkCadence === 0) { - this.checkPostEditInvariants(); - // this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); - // this.languageService.getSemanticDiagnostics(this.activeFile.fileName); + if (i % checkCadence === 0) { + this.checkPostEditInvariants(); + } } // Handle post-keystroke formatting @@ -1389,14 +1385,12 @@ namespace FourSlash { const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); - // this.checkPostEditInvariants(); } } } // Move the caret to wherever we ended up this.currentCaretPosition = offset; - this.fixCaretPosition(); this.checkPostEditInvariants(); } @@ -1415,7 +1409,6 @@ namespace FourSlash { const edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, offset, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); - this.checkPostEditInvariants(); } } @@ -1433,20 +1426,22 @@ namespace FourSlash { return; } - const incrementalSourceFile = this.languageService.getNonBoundSourceFile(this.activeFile.fileName); - Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined); + if (1 + 1 === 2) { + const incrementalSourceFile = this.languageService.getNonBoundSourceFile(this.activeFile.fileName); + Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined); - const incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; + const incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; - // Check syntactic structure - const content = this.getFileContent(this.activeFile.fileName); + // Check syntactic structure + const content = this.getFileContent(this.activeFile.fileName); - const referenceSourceFile = ts.createLanguageServiceSourceFile( - this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false); - const referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics; + const referenceSourceFile = ts.createLanguageServiceSourceFile( + this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false); + const referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics; - Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics); - Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile); + Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics); + Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile); + } } private fixCaretPosition() { @@ -2269,40 +2264,8 @@ namespace FourSlash { export function runFourSlashTestContent(basePath: string, testType: FourSlashTestType, content: string, fileName: string): void { // Parse out the files and their metadata const testData = parseTestData(basePath, content, fileName); - const state = new TestState(basePath, testType, testData); - - let result = ""; - const fourslashFile: Harness.Compiler.TestFile = { - unitName: Harness.Compiler.fourslashFileName, - content: undefined, - }; - const testFile: Harness.Compiler.TestFile = { - unitName: fileName, - content: content - }; - - const host = Harness.Compiler.createCompilerHost( - [fourslashFile, testFile], - (fn, contents) => result = contents, - ts.ScriptTarget.Latest, - Harness.IO.useCaseSensitiveFileNames(), - Harness.IO.getCurrentDirectory()); - - const program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); - - const sourceFile = host.getSourceFile(fileName, ts.ScriptTarget.ES3); - - const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile); - if (diagnostics.length > 0) { - throw new Error(`Error compiling ${fileName}: ` + - diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, Harness.IO.newLine())).join("\r\n")); - } - - program.emit(sourceFile); - - ts.Debug.assert(!!result); - runCode(result, state); + runCode(ts.transpile(content), state); } function runCode(code: string, state: TestState): void { From e724e883e6dd21226c8399893e5b49a9266f5797 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 8 Aug 2016 13:31:45 -0700 Subject: [PATCH 102/508] Duh --- src/harness/fourslash.ts | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 366891c0d30..751db7b971a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1426,22 +1426,20 @@ namespace FourSlash { return; } - if (1 + 1 === 2) { - const incrementalSourceFile = this.languageService.getNonBoundSourceFile(this.activeFile.fileName); - Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined); + const incrementalSourceFile = this.languageService.getNonBoundSourceFile(this.activeFile.fileName); + Utils.assertInvariants(incrementalSourceFile, /*parent:*/ undefined); - const incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; + const incrementalSyntaxDiagnostics = incrementalSourceFile.parseDiagnostics; - // Check syntactic structure - const content = this.getFileContent(this.activeFile.fileName); + // Check syntactic structure + const content = this.getFileContent(this.activeFile.fileName); - const referenceSourceFile = ts.createLanguageServiceSourceFile( - this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false); - const referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics; + const referenceSourceFile = ts.createLanguageServiceSourceFile( + this.activeFile.fileName, createScriptSnapShot(content), ts.ScriptTarget.Latest, /*version:*/ "0", /*setNodeParents:*/ false); + const referenceSyntaxDiagnostics = referenceSourceFile.parseDiagnostics; - Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics); - Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile); - } + Utils.assertDiagnosticsEquals(incrementalSyntaxDiagnostics, referenceSyntaxDiagnostics); + Utils.assertStructuralEquals(incrementalSourceFile, referenceSourceFile); } private fixCaretPosition() { From 53d54c2b282d7bc4808941292fd91c1d41f5e4cc Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 8 Aug 2016 14:30:27 -0700 Subject: [PATCH 103/508] Make baselines faster by not writing out unneeded files --- Gulpfile.ts | 111 ++++++++++++++++++++----------------- Jakefile.js | 17 +++--- package.json | 1 + scripts/types/ambient.d.ts | 2 +- src/harness/harness.ts | 19 +++---- 5 files changed, 79 insertions(+), 71 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index b9b5d2068b2..e2d37277bcf 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -17,7 +17,7 @@ declare module "gulp-typescript" { stripInternal?: boolean; types?: string[]; } - interface CompileStream extends NodeJS.ReadWriteStream {} // Either gulp or gulp-typescript has some odd typings which don't reflect reality, making this required + interface CompileStream extends NodeJS.ReadWriteStream { } // Either gulp or gulp-typescript has some odd typings which don't reflect reality, making this required } import * as insert from "gulp-insert"; import * as sourcemaps from "gulp-sourcemaps"; @@ -65,7 +65,7 @@ const cmdLineOptions = minimist(process.argv.slice(2), { } }); -function exec(cmd: string, args: string[], complete: () => void = (() => {}), error: (e: any, status: number) => void = (() => {})) { +function exec(cmd: string, args: string[], complete: () => void = (() => { }), error: (e: any, status: number) => void = (() => { })) { console.log(`${cmd} ${args.join(" ")}`); // TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition const subshellFlag = isWin ? "/c" : "-c"; @@ -116,12 +116,12 @@ const es2015LibrarySources = [ ]; const es2015LibrarySourceMap = es2015LibrarySources.map(function(source) { - return { target: "lib." + source, sources: ["header.d.ts", source] }; + return { target: "lib." + source, sources: ["header.d.ts", source] }; }); -const es2016LibrarySource = [ "es2016.array.include.d.ts" ]; +const es2016LibrarySource = ["es2016.array.include.d.ts"]; -const es2016LibrarySourceMap = es2016LibrarySource.map(function (source) { +const es2016LibrarySourceMap = es2016LibrarySource.map(function(source) { return { target: "lib." + source, sources: ["header.d.ts", source] }; }); @@ -130,38 +130,38 @@ const es2017LibrarySource = [ "es2017.sharedmemory.d.ts" ]; -const es2017LibrarySourceMap = es2017LibrarySource.map(function (source) { +const es2017LibrarySourceMap = es2017LibrarySource.map(function(source) { return { target: "lib." + source, sources: ["header.d.ts", source] }; }); const hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"]; const librarySourceMap = [ - // Host library - { target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] }, - { target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] }, - { target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] }, - { target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] }, + // Host library + { target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] }, + { target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] }, + { target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] }, + { target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] }, - // JavaScript library - { target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] }, - { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, - { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, - { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, + // JavaScript library + { target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] }, + { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, + { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, + { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, - // JavaScript + all host library - { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, - { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } + // JavaScript + all host library + { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, + { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } ].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap); -const libraryTargets = librarySourceMap.map(function (f) { +const libraryTargets = librarySourceMap.map(function(f) { return path.join(builtLocalDirectory, f.target); }); for (const i in libraryTargets) { const entry = librarySourceMap[i]; const target = libraryTargets[i]; - const sources = [copyright].concat(entry.sources.map(function (s) { + const sources = [copyright].concat(entry.sources.map(function(s) { return path.join(libraryDirectory, s); })); gulp.task(target, false, [], function() { @@ -391,7 +391,7 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => { .pipe(sourcemaps.init()) .pipe(tsc(servicesProject)); const completedJs = js.pipe(prependCopyright()) - .pipe(sourcemaps.write(".")); + .pipe(sourcemaps.write(".")); const completedDts = dts.pipe(prependCopyright(/*outputCopyright*/true)) .pipe(insert.transform((contents, file) => { file.path = standaloneDefinitionsFile; @@ -434,17 +434,17 @@ const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverli gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { const serverLibraryProject = tsc.createProject("src/server/tsconfig.library.json", getCompilerSettings({}, /*useBuiltCompiler*/ true)); - const {js, dts}: {js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream} = serverLibraryProject.src() + const {js, dts}: { js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } = serverLibraryProject.src() .pipe(sourcemaps.init()) .pipe(newer(tsserverLibraryFile)) .pipe(tsc(serverLibraryProject)); return merge2([ js.pipe(prependCopyright()) - .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(builtLocalDirectory)), + .pipe(sourcemaps.write(".")) + .pipe(gulp.dest(builtLocalDirectory)), dts.pipe(prependCopyright()) - .pipe(gulp.dest(builtLocalDirectory)) + .pipe(gulp.dest(builtLocalDirectory)) ]); }); @@ -476,7 +476,7 @@ gulp.task(specMd, false, [word2mdJs], (done) => { const specMDFullPath = path.resolve(specMd); const cmd = "cscript //nologo " + word2mdJs + " \"" + specWordFullPath + "\" " + "\"" + specMDFullPath + "\""; console.log(cmd); - cp.exec(cmd, function () { + cp.exec(cmd, function() { done(); }); }); @@ -492,12 +492,12 @@ gulp.task("dontUseDebugMode", false, [], (done) => { useDebugMode = false; done( gulp.task("VerifyLKG", false, [], () => { const expectedFiles = [builtLocalCompiler, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets); - const missingFiles = expectedFiles.filter(function (f) { + const missingFiles = expectedFiles.filter(function(f) { return !fs.existsSync(f); }); if (missingFiles.length > 0) { throw new Error("Cannot replace the LKG unless all built targets are present in directory " + builtLocalDirectory + - ". The following files are missing:\n" + missingFiles.join("\n")); + ". The following files are missing:\n" + missingFiles.join("\n")); } // Copy all the targets into the LKG directory return gulp.src(expectedFiles).pipe(gulp.dest(LKGDirectory)); @@ -627,7 +627,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: } args.push(run); setNodeEnvToDevelopment(); - runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) { + runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function(err) { // last worker clean everything and runs linter in case if there were no errors del(taskConfigsFolder).then(() => { if (!err) { @@ -679,7 +679,7 @@ gulp.task("runtests", ["build-rules", "tests"], (done) => { runConsoleTests("mocha-fivemat-progress-reporter", /*runInParallel*/ false, done); -}); + }); const nodeServerOutFile = "tests/webTestServer.js"; const nodeServerInFile = "tests/webTestServer.ts"; @@ -812,31 +812,38 @@ gulp.task("diff-rwc", "Diffs the RWC baselines using the diff tool specified by }); -gulp.task("baseline-accept", "Makes the most recent test results the new baseline, overwriting the old baseline", (done) => { - const softAccept = cmdLineOptions["soft"]; - if (!softAccept) { - del(refBaseline).then(() => { - fs.renameSync(localBaseline, refBaseline); - done(); - }, done); - } - else { - gulp.src(localBaseline) - .pipe(gulp.dest(refBaseline)) - .on("end", () => { - del(path.join(refBaseline, "local")).then(() => done(), done); - }); - } +const deleteEnding = '.delete'; +gulp.task("baseline-accept", "Makes the most recent test results the new baseline, overwriting the old baseline", () => { + return baselineAccept(""); }); + +function baselineAccept(subfolder = "") { + return merge2(baselineCopy(subfolder), baselineDelete(subfolder)); +} + +function baselineCopy(subfolder = "") { + return gulp.src([`tests/baselines/local/${subfolder}/**`, `!tests/baselines/local/${subfolder}/**/*.delete`]) + .pipe(gulp.dest(refBaseline)); +} + +function baselineDelete(subfolder = "") { + return gulp.src(['tests/baselines/local/**/*.delete']) + .pipe(insert.transform((content, fileObj) => { + const target = path.join(refBaseline, fileObj.relative.substr(0, fileObj.relative.length - '.delete'.length)); + console.log(target); + del.sync(target); + del.sync(fileObj.path); + return ''; + })); +} + gulp.task("baseline-accept-rwc", "Makes the most recent rwc test results the new baseline, overwriting the old baseline", () => { - return del(refRwcBaseline).then(() => { - fs.renameSync(localRwcBaseline, refRwcBaseline); - }); + return baselineAccept("rwc"); }); + + gulp.task("baseline-accept-test262", "Makes the most recent test262 test results the new baseline, overwriting the old baseline", () => { - return del(refTest262Baseline).then(() => { - fs.renameSync(localTest262Baseline, refTest262Baseline); - }); + return baselineAccept("test262"); }); diff --git a/Jakefile.js b/Jakefile.js index a5650a56b16..8062d8a2928 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1,3 +1,4 @@ +"use strict"; // This file contains the build logic for the public repo var fs = require("fs"); @@ -898,16 +899,16 @@ task("tests-debug", ["setDebugMode", "tests"]); // Makes the test results the new baseline desc("Makes the most recent test results the new baseline, overwriting the old baseline"); task("baseline-accept", function(hardOrSoft) { - if (!hardOrSoft || hardOrSoft === "hard") { - jake.rmRf(refBaseline); - fs.renameSync(localBaseline, refBaseline); - } - else if (hardOrSoft === "soft") { - var files = jake.readdirR(localBaseline); - for (var i in files) { + var files = jake.readdirR(localBaseline); + var deleteEnding = '.delete'; + for (var i in files) { + if (files[i].substr(files[i].length - deleteEnding.length) === deleteEnding) { + var filename = path.basename(files[i]); + filename = filename.substr(0, filename.length - deleteEnding.length); + fs.unlink(path.join(refBaseline, filename)); + } else { jake.cpR(files[i], refBaseline); } - jake.rmRf(path.join(refBaseline, "local")); } }); diff --git a/package.json b/package.json index 9f3122c3374..1f1c52b42ed 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "mkdirp": "latest", "mocha": "latest", "mocha-fivemat-progress-reporter": "latest", + "q": "latest", "run-sequence": "latest", "sorcery": "latest", "through2": "latest", diff --git a/scripts/types/ambient.d.ts b/scripts/types/ambient.d.ts index e77e3fe8c5a..16ec9385cb1 100644 --- a/scripts/types/ambient.d.ts +++ b/scripts/types/ambient.d.ts @@ -10,7 +10,7 @@ declare module "gulp-insert" { export function append(text: string | Buffer): NodeJS.ReadWriteStream; export function prepend(text: string | Buffer): NodeJS.ReadWriteStream; export function wrap(text: string | Buffer, tail: string | Buffer): NodeJS.ReadWriteStream; - export function transform(cb: (contents: string, file: {path: string}) => string): NodeJS.ReadWriteStream; // file is a vinyl file + export function transform(cb: (contents: string, file: {path: string, relative: string}) => string): NodeJS.ReadWriteStream; // file is a vinyl file } declare module "into-stream" { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index f27e7e1c174..18a440c789b 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1569,6 +1569,7 @@ namespace Harness { /** Support class for baseline files */ export namespace Baseline { + const NoContent = ""; export interface BaselineOptions { Subfolder?: string; @@ -1635,14 +1636,6 @@ namespace Harness { throw new Error("The generated content was \"undefined\". Return \"null\" if no baselining is required.\""); } - // Store the content in the 'local' folder so we - // can accept it later (manually) - /* tslint:disable:no-null-keyword */ - if (actual !== null) { - /* tslint:enable:no-null-keyword */ - IO.writeFile(actualFileName, actual); - } - return actual; } @@ -1659,7 +1652,7 @@ namespace Harness { /* tslint:disable:no-null-keyword */ if (actual === null) { /* tslint:enable:no-null-keyword */ - actual = ""; + actual = NoContent; } let expected = ""; @@ -1672,7 +1665,13 @@ namespace Harness { function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) { const encoded_actual = Utils.encodeString(actual); - if (expected != encoded_actual) { + if (expected !== encoded_actual) { + if (actual === NoContent) { + IO.writeFile(relativeFileName + '.delete', ''); + } + else { + IO.writeFile(relativeFileName, actual); + } // Overwrite & issue error const errMsg = "The baseline file " + relativeFileName + " has changed."; throw new Error(errMsg); From eac7a48c5f03248bf6c597aacf7a1216e20f4ba9 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 8 Aug 2016 14:39:31 -0700 Subject: [PATCH 104/508] Fix non-strict-compliant test --- tests/cases/fourslash/localGetReferences.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index ada4947acde..b05346a366a 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -205,12 +205,13 @@ const rangesByText = test.rangesByText(); for (const text in rangesByText) { const ranges = rangesByText[text]; if (text === "globalVar") { - function isShadow(r) { - return r.marker && r.marker.data && r.marker.data.shadow; - } verify.rangesReferenceEachOther(ranges.filter(isShadow)); verify.rangesReferenceEachOther(ranges.filter(r => !isShadow(r))); } else { verify.rangesReferenceEachOther(ranges); } } + +function isShadow(r) { + return r.marker && r.marker.data && r.marker.data.shadow; +} From 3f6aa3f3f0705cfc6bfe59920d49e76c12023953 Mon Sep 17 00:00:00 2001 From: Yui Date: Mon, 8 Aug 2016 14:45:29 -0700 Subject: [PATCH 105/508] Fix 10076: Fix Tuple Destructing with "this" (#10208) * Call checkExpression eventhough there is no appropriate type from destructuring of array * Add tests and baselines --- src/compiler/checker.ts | 14 ++++++++--- ...turingThisInTupleDestructuring1.errors.txt | 13 +++++++++++ .../emitCapturingThisInTupleDestructuring1.js | 11 +++++++++ ...turingThisInTupleDestructuring2.errors.txt | 16 +++++++++++++ .../emitCapturingThisInTupleDestructuring2.js | 23 +++++++++++++++++++ .../emitCapturingThisInTupleDestructuring1.ts | 4 ++++ .../emitCapturingThisInTupleDestructuring2.ts | 10 ++++++++ 7 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/emitCapturingThisInTupleDestructuring1.errors.txt create mode 100644 tests/baselines/reference/emitCapturingThisInTupleDestructuring1.js create mode 100644 tests/baselines/reference/emitCapturingThisInTupleDestructuring2.errors.txt create mode 100644 tests/baselines/reference/emitCapturingThisInTupleDestructuring2.js create mode 100644 tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts create mode 100644 tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fb60852faf3..bec8686ab93 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4457,9 +4457,14 @@ namespace ts { return property; } - // Return the symbol for the property with the given name in the given type. Creates synthetic union properties when - // necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from - // Object and Function as appropriate. + /** + * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when + * necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from + * Object and Function as appropriate. + * + * @param type a type to look up property from + * @param name a name of property to look up in a given type + */ function getPropertyOfType(type: Type, name: string): Symbol { type = getApparentType(type); if (type.flags & TypeFlags.ObjectType) { @@ -12932,6 +12937,9 @@ namespace ts { return checkDestructuringAssignment(element, type, contextualMapper); } else { + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); if (isTupleType(sourceType)) { error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), (sourceType).elementTypes.length, elements.length); } diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.errors.txt b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.errors.txt new file mode 100644 index 00000000000..d0f11d056ca --- /dev/null +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts(3,17): error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'. +tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts(3,29): error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'. + + +==== tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts (2 errors) ==== + declare function wrapper(x: any); + wrapper((array: [any]) => { + [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" + ~~~~~~~~~~ +!!! error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'. + ~~~~~~~~~~ +!!! error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'. + }); \ No newline at end of file diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.js b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.js new file mode 100644 index 00000000000..9dd7453ba4f --- /dev/null +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.js @@ -0,0 +1,11 @@ +//// [emitCapturingThisInTupleDestructuring1.ts] +declare function wrapper(x: any); +wrapper((array: [any]) => { + [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" +}); + +//// [emitCapturingThisInTupleDestructuring1.js] +var _this = this; +wrapper(function (array) { + _this.test = array[0], _this.test1 = array[1], _this.test2 = array[2]; // even though there is a compiler error, we should still emit lexical capture for "this" +}); diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.errors.txt b/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.errors.txt new file mode 100644 index 00000000000..25207e28c79 --- /dev/null +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts(8,39): error TS2493: Tuple type '[number, number]' with length '2' cannot be assigned to tuple with length '3'. + + +==== tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts (1 errors) ==== + var array1: [number, number] = [1, 2]; + + class B { + test: number; + test1: any; + test2: any; + method() { + () => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this" + ~~~~~~~~~~ +!!! error TS2493: Tuple type '[number, number]' with length '2' cannot be assigned to tuple with length '3'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.js b/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.js new file mode 100644 index 00000000000..f999cfe70f0 --- /dev/null +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.js @@ -0,0 +1,23 @@ +//// [emitCapturingThisInTupleDestructuring2.ts] +var array1: [number, number] = [1, 2]; + +class B { + test: number; + test1: any; + test2: any; + method() { + () => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this" + } +} + +//// [emitCapturingThisInTupleDestructuring2.js] +var array1 = [1, 2]; +var B = (function () { + function B() { + } + B.prototype.method = function () { + var _this = this; + (function () { return (_this.test = array1[0], _this.test1 = array1[1], _this.test2 = array1[2], array1); }); // even though there is a compiler error, we should still emit lexical capture for "this" + }; + return B; +}()); diff --git a/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts b/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts new file mode 100644 index 00000000000..e369cd9fb50 --- /dev/null +++ b/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts @@ -0,0 +1,4 @@ +declare function wrapper(x: any); +wrapper((array: [any]) => { + [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" +}); \ No newline at end of file diff --git a/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts b/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts new file mode 100644 index 00000000000..2bb931c4f4f --- /dev/null +++ b/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts @@ -0,0 +1,10 @@ +var array1: [number, number] = [1, 2]; + +class B { + test: number; + test1: any; + test2: any; + method() { + () => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this" + } +} \ No newline at end of file From 40f0c6018dce1e1aeadec37020827ef6a7b318a3 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 8 Aug 2016 15:36:38 -0700 Subject: [PATCH 106/508] use transpileModule --- src/harness/fourslash.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 751db7b971a..d0643db4967 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2263,7 +2263,11 @@ namespace FourSlash { // Parse out the files and their metadata const testData = parseTestData(basePath, content, fileName); const state = new TestState(basePath, testType, testData); - runCode(ts.transpile(content), state); + const output = ts.transpileModule(content, { reportDiagnostics: true }); + if (output.diagnostics.length > 0) { + throw new Error(`Syntax error in ${basePath}: ${output.diagnostics[0].messageText}`); + } + runCode(output.outputText, state); } function runCode(code: string, state: TestState): void { From 5adceb92a73c93dbc4dd642dae7398e6b1a4ad7b Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Mon, 8 Aug 2016 15:40:25 -0700 Subject: [PATCH 107/508] Remove use strict --- Jakefile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 8062d8a2928..0c08c0faf4c 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -1,4 +1,3 @@ -"use strict"; // This file contains the build logic for the public repo var fs = require("fs"); From 624e52e8342947f49f9744de8904bad7917175c8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Aug 2016 16:40:59 -0700 Subject: [PATCH 108/508] Improve instanceof for structurally identical types --- src/compiler/checker.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index fb60852faf3..e2e09b80a72 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8569,8 +8569,12 @@ namespace ts { } function getNarrowedType(type: Type, candidate: Type, assumeTrue: boolean) { + // In the false branch we keep types that aren't subtypes of the candidate type and we keep structurally + // identical types except for the current type itself. The latter rule means that given two structurally + // identical classes A and B and a variable x of type A, in the false branch of an 'x instanceof B' type + // guard x keeps type A and is not narrowed to type never. if (!assumeTrue) { - return filterType(type, t => !isTypeSubtypeOf(t, candidate)); + return filterType(type, t => !isTypeSubtypeOf(t, candidate) || isTypeIdenticalTo(t, candidate) && t !== candidate); } // If the current type is a union type, remove all constituents that aren't assignable to // the candidate type. If one or more constituents remain, return a union of those. From 5ebfad6e4aecc6bdea21d0c63e5769ae57caaecb Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Aug 2016 17:40:27 -0700 Subject: [PATCH 109/508] Introduce isTypeInstanceOf function --- src/compiler/checker.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e2e09b80a72..d4599a47f4f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5919,6 +5919,13 @@ namespace ts { return isTypeRelatedTo(source, target, assignableRelation); } + // A type S is considered to be an instance of a type T if S and T are the same type or if S is a + // subtype of T but not structurally identical to T. This specifically means that two distinct but + // structurally identical types (such as two classes) are not considered instances of each other. + function isTypeInstanceOf(source: Type, target: Type): boolean { + return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + } + /** * This is *not* a bi-directional relationship. * If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'. @@ -8569,17 +8576,13 @@ namespace ts { } function getNarrowedType(type: Type, candidate: Type, assumeTrue: boolean) { - // In the false branch we keep types that aren't subtypes of the candidate type and we keep structurally - // identical types except for the current type itself. The latter rule means that given two structurally - // identical classes A and B and a variable x of type A, in the false branch of an 'x instanceof B' type - // guard x keeps type A and is not narrowed to type never. if (!assumeTrue) { - return filterType(type, t => !isTypeSubtypeOf(t, candidate) || isTypeIdenticalTo(t, candidate) && t !== candidate); + return filterType(type, t => !isTypeInstanceOf(t, candidate)); } - // If the current type is a union type, remove all constituents that aren't assignable to + // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. if (type.flags & TypeFlags.Union) { - const assignableConstituents = filter((type).types, t => isTypeAssignableTo(t, candidate)); + const assignableConstituents = filter((type).types, t => isTypeInstanceOf(t, candidate)); if (assignableConstituents.length) { return getUnionType(assignableConstituents); } From 9277b3f5addac8380a6b6eb2c501d22d82554bf2 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Aug 2016 17:40:53 -0700 Subject: [PATCH 110/508] Add test --- ...nstanceofWithStructurallyIdenticalTypes.ts | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts diff --git a/tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts b/tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts new file mode 100644 index 00000000000..564f7a9c22e --- /dev/null +++ b/tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts @@ -0,0 +1,69 @@ +// Repro from #7271 + +class C1 { item: string } +class C2 { item: string[] } +class C3 { item: string } + +function foo1(x: C1 | C2 | C3): string { + if (x instanceof C1) { + return x.item; + } + else if (x instanceof C2) { + return x.item[0]; + } + else if (x instanceof C3) { + return x.item; + } + return "error"; +} + +function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } +function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } +function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } + +function foo2(x: C1 | C2 | C3): string { + if (isC1(x)) { + return x.item; + } + else if (isC2(x)) { + return x.item[0]; + } + else if (isC3(x)) { + return x.item; + } + return "error"; +} + +// More tests + +class A { a: string } +class A1 extends A { } +class A2 { a: string } +class B extends A { b: string } + +function goo(x: A) { + if (x instanceof A) { + x; // A + } + else { + x; // never + } + if (x instanceof A1) { + x; // A1 + } + else { + x; // A + } + if (x instanceof A2) { + x; // A2 + } + else { + x; // A + } + if (x instanceof B) { + x; // B + } + else { + x; // A + } +} From fe1854e4410d342d5e18f7c7d8a285941604743c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 8 Aug 2016 17:43:41 -0700 Subject: [PATCH 111/508] Accept new baselines --- .../controlFlowBinaryOrExpression.symbols | 12 +- .../controlFlowBinaryOrExpression.types | 8 +- ...nstanceofWithStructurallyIdenticalTypes.js | 172 ++++++++++++++ ...ceofWithStructurallyIdenticalTypes.symbols | 192 ++++++++++++++++ ...anceofWithStructurallyIdenticalTypes.types | 211 ++++++++++++++++++ 5 files changed, 585 insertions(+), 10 deletions(-) create mode 100644 tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js create mode 100644 tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.symbols create mode 100644 tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.symbols b/tests/baselines/reference/controlFlowBinaryOrExpression.symbols index 5251973005f..217e11dc95d 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.symbols +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.symbols @@ -64,9 +64,9 @@ if (isNodeList(sourceObj)) { >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) sourceObj.length; ->sourceObj.length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>sourceObj.length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27)) >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) ->length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27)) } if (isHTMLCollection(sourceObj)) { @@ -74,9 +74,9 @@ if (isHTMLCollection(sourceObj)) { >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) sourceObj.length; ->sourceObj.length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>sourceObj.length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33)) >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) ->length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33)) } if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { @@ -86,8 +86,8 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) sourceObj.length; ->sourceObj.length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27)) +>sourceObj.length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) ->length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27)) +>length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) } diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.types b/tests/baselines/reference/controlFlowBinaryOrExpression.types index d24462316b4..7e92fcdbbd1 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.types +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.types @@ -80,7 +80,7 @@ if (isNodeList(sourceObj)) { sourceObj.length; >sourceObj.length : number ->sourceObj : NodeList | HTMLCollection +>sourceObj : NodeList >length : number } @@ -91,7 +91,7 @@ if (isHTMLCollection(sourceObj)) { sourceObj.length; >sourceObj.length : number ->sourceObj : NodeList | HTMLCollection +>sourceObj : HTMLCollection >length : number } @@ -102,11 +102,11 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { >sourceObj : EventTargetLike >isHTMLCollection(sourceObj) : boolean >isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection ->sourceObj : { a: string; } +>sourceObj : HTMLCollection | { a: string; } sourceObj.length; >sourceObj.length : number ->sourceObj : NodeList +>sourceObj : NodeList | HTMLCollection >length : number } diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js new file mode 100644 index 00000000000..97be2137722 --- /dev/null +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js @@ -0,0 +1,172 @@ +//// [instanceofWithStructurallyIdenticalTypes.ts] +// Repro from #7271 + +class C1 { item: string } +class C2 { item: string[] } +class C3 { item: string } + +function foo1(x: C1 | C2 | C3): string { + if (x instanceof C1) { + return x.item; + } + else if (x instanceof C2) { + return x.item[0]; + } + else if (x instanceof C3) { + return x.item; + } + return "error"; +} + +function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } +function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } +function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } + +function foo2(x: C1 | C2 | C3): string { + if (isC1(x)) { + return x.item; + } + else if (isC2(x)) { + return x.item[0]; + } + else if (isC3(x)) { + return x.item; + } + return "error"; +} + +// More tests + +class A { a: string } +class A1 extends A { } +class A2 { a: string } +class B extends A { b: string } + +function goo(x: A) { + if (x instanceof A) { + x; // A + } + else { + x; // never + } + if (x instanceof A1) { + x; // A1 + } + else { + x; // A + } + if (x instanceof A2) { + x; // A2 + } + else { + x; // A + } + if (x instanceof B) { + x; // B + } + else { + x; // A + } +} + + +//// [instanceofWithStructurallyIdenticalTypes.js] +// Repro from #7271 +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C1 = (function () { + function C1() { + } + return C1; +}()); +var C2 = (function () { + function C2() { + } + return C2; +}()); +var C3 = (function () { + function C3() { + } + return C3; +}()); +function foo1(x) { + if (x instanceof C1) { + return x.item; + } + else if (x instanceof C2) { + return x.item[0]; + } + else if (x instanceof C3) { + return x.item; + } + return "error"; +} +function isC1(c) { return c instanceof C1; } +function isC2(c) { return c instanceof C2; } +function isC3(c) { return c instanceof C3; } +function foo2(x) { + if (isC1(x)) { + return x.item; + } + else if (isC2(x)) { + return x.item[0]; + } + else if (isC3(x)) { + return x.item; + } + return "error"; +} +// More tests +var A = (function () { + function A() { + } + return A; +}()); +var A1 = (function (_super) { + __extends(A1, _super); + function A1() { + _super.apply(this, arguments); + } + return A1; +}(A)); +var A2 = (function () { + function A2() { + } + return A2; +}()); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +}(A)); +function goo(x) { + if (x instanceof A) { + x; // A + } + else { + x; // never + } + if (x instanceof A1) { + x; // A1 + } + else { + x; // A + } + if (x instanceof A2) { + x; // A2 + } + else { + x; // A + } + if (x instanceof B) { + x; // B + } + else { + x; // A + } +} diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.symbols b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.symbols new file mode 100644 index 00000000000..f2eb40eea47 --- /dev/null +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.symbols @@ -0,0 +1,192 @@ +=== tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts === +// Repro from #7271 + +class C1 { item: string } +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) + +class C2 { item: string[] } +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) + +class C3 { item: string } +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) + +function foo1(x: C1 | C2 | C3): string { +>foo1 : Symbol(foo1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 25)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) + + if (x instanceof C1) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) + + return x.item; +>x.item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) + } + else if (x instanceof C2) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) + + return x.item[0]; +>x.item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) + } + else if (x instanceof C3) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) + + return x.item; +>x.item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) + } + return "error"; +} + +function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } +>isC1 : Symbol(isC1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 17, 1)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) + +function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } +>isC2 : Symbol(isC2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 66)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 14)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 14)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) + +function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } +>isC3 : Symbol(isC3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 66)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 21, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 21, 14)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 21, 14)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) + +function foo2(x: C1 | C2 | C3): string { +>foo2 : Symbol(foo2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 21, 66)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) + + if (isC1(x)) { +>isC1 : Symbol(isC1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 17, 1)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) + + return x.item; +>x.item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) +>item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) + } + else if (isC2(x)) { +>isC2 : Symbol(isC2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 66)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) + + return x.item[0]; +>x.item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) +>item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) + } + else if (isC3(x)) { +>isC3 : Symbol(isC3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 66)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) + + return x.item; +>x.item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) +>item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) + } + return "error"; +} + +// More tests + +class A { a: string } +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) +>a : Symbol(A.a, Decl(instanceofWithStructurallyIdenticalTypes.ts, 38, 9)) + +class A1 extends A { } +>A1 : Symbol(A1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 38, 21)) +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) + +class A2 { a: string } +>A2 : Symbol(A2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 39, 22)) +>a : Symbol(A2.a, Decl(instanceofWithStructurallyIdenticalTypes.ts, 40, 10)) + +class B extends A { b: string } +>B : Symbol(B, Decl(instanceofWithStructurallyIdenticalTypes.ts, 40, 22)) +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) +>b : Symbol(B.b, Decl(instanceofWithStructurallyIdenticalTypes.ts, 41, 19)) + +function goo(x: A) { +>goo : Symbol(goo, Decl(instanceofWithStructurallyIdenticalTypes.ts, 41, 31)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) + + if (x instanceof A) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) + + x; // A +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + else { + x; // never +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + if (x instanceof A1) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>A1 : Symbol(A1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 38, 21)) + + x; // A1 +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + else { + x; // A +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + if (x instanceof A2) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>A2 : Symbol(A2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 39, 22)) + + x; // A2 +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + else { + x; // A +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + if (x instanceof B) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>B : Symbol(B, Decl(instanceofWithStructurallyIdenticalTypes.ts, 40, 22)) + + x; // B +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + else { + x; // A +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } +} + diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types new file mode 100644 index 00000000000..d98a6025796 --- /dev/null +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types @@ -0,0 +1,211 @@ +=== tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts === +// Repro from #7271 + +class C1 { item: string } +>C1 : C1 +>item : string + +class C2 { item: string[] } +>C2 : C2 +>item : string[] + +class C3 { item: string } +>C3 : C3 +>item : string + +function foo1(x: C1 | C2 | C3): string { +>foo1 : (x: C1 | C2 | C3) => string +>x : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 + + if (x instanceof C1) { +>x instanceof C1 : boolean +>x : C1 | C2 | C3 +>C1 : typeof C1 + + return x.item; +>x.item : string +>x : C1 +>item : string + } + else if (x instanceof C2) { +>x instanceof C2 : boolean +>x : C2 | C3 +>C2 : typeof C2 + + return x.item[0]; +>x.item[0] : string +>x.item : string[] +>x : C2 +>item : string[] +>0 : number + } + else if (x instanceof C3) { +>x instanceof C3 : boolean +>x : C3 +>C3 : typeof C3 + + return x.item; +>x.item : string +>x : C3 +>item : string + } + return "error"; +>"error" : string +} + +function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } +>isC1 : (c: C1 | C2 | C3) => c is C1 +>c : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 +>c : any +>C1 : C1 +>c instanceof C1 : boolean +>c : C1 | C2 | C3 +>C1 : typeof C1 + +function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } +>isC2 : (c: C1 | C2 | C3) => c is C2 +>c : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 +>c : any +>C2 : C2 +>c instanceof C2 : boolean +>c : C1 | C2 | C3 +>C2 : typeof C2 + +function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } +>isC3 : (c: C1 | C2 | C3) => c is C3 +>c : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 +>c : any +>C3 : C3 +>c instanceof C3 : boolean +>c : C1 | C2 | C3 +>C3 : typeof C3 + +function foo2(x: C1 | C2 | C3): string { +>foo2 : (x: C1 | C2 | C3) => string +>x : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 + + if (isC1(x)) { +>isC1(x) : boolean +>isC1 : (c: C1 | C2 | C3) => c is C1 +>x : C1 | C2 | C3 + + return x.item; +>x.item : string +>x : C1 +>item : string + } + else if (isC2(x)) { +>isC2(x) : boolean +>isC2 : (c: C1 | C2 | C3) => c is C2 +>x : C2 | C3 + + return x.item[0]; +>x.item[0] : string +>x.item : string[] +>x : C2 +>item : string[] +>0 : number + } + else if (isC3(x)) { +>isC3(x) : boolean +>isC3 : (c: C1 | C2 | C3) => c is C3 +>x : C3 + + return x.item; +>x.item : string +>x : C3 +>item : string + } + return "error"; +>"error" : string +} + +// More tests + +class A { a: string } +>A : A +>a : string + +class A1 extends A { } +>A1 : A1 +>A : A + +class A2 { a: string } +>A2 : A2 +>a : string + +class B extends A { b: string } +>B : B +>A : A +>b : string + +function goo(x: A) { +>goo : (x: A) => void +>x : A +>A : A + + if (x instanceof A) { +>x instanceof A : boolean +>x : A +>A : typeof A + + x; // A +>x : A + } + else { + x; // never +>x : never + } + if (x instanceof A1) { +>x instanceof A1 : boolean +>x : A +>A1 : typeof A1 + + x; // A1 +>x : A1 + } + else { + x; // A +>x : A + } + if (x instanceof A2) { +>x instanceof A2 : boolean +>x : A +>A2 : typeof A2 + + x; // A2 +>x : A2 + } + else { + x; // A +>x : A + } + if (x instanceof B) { +>x instanceof B : boolean +>x : A +>B : typeof B + + x; // B +>x : B + } + else { + x; // A +>x : A + } +} + From 4f54c6c228c5e3a7e9fd1115de81fa49327b974f Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 9 Aug 2016 06:42:14 -0700 Subject: [PATCH 112/508] Fix loop over array to use for-of instead of for-in --- src/harness/harness.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index f27e7e1c174..e8e0a11f615 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -750,7 +750,7 @@ namespace Harness { export function readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]) { const fs = new Utils.VirtualFileSystem(path, useCaseSensitiveFileNames()); - for (const file in listFiles(path)) { + for (const file of listFiles(path)) { fs.addFile(file); } return ts.matchFiles(path, extension, exclude, include, useCaseSensitiveFileNames(), getCurrentDirectory(), path => { From 7e115bbbef0e6e9cfe71ca63373d0881dd48e3be Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 9 Aug 2016 12:44:08 -0700 Subject: [PATCH 113/508] Use correct this in tuple type parameter constraints Instantiate this in tuple types used as type parameter constraints --- src/compiler/checker.ts | 8 ++- .../thisInTupleTypeParameterConstraints.js | 29 ++++++++ ...hisInTupleTypeParameterConstraints.symbols | 66 ++++++++++++++++++ .../thisInTupleTypeParameterConstraints.types | 67 +++++++++++++++++++ .../thisInTupleTypeParameterConstraints.ts | 22 ++++++ 5 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/thisInTupleTypeParameterConstraints.js create mode 100644 tests/baselines/reference/thisInTupleTypeParameterConstraints.symbols create mode 100644 tests/baselines/reference/thisInTupleTypeParameterConstraints.types create mode 100644 tests/cases/compiler/thisInTupleTypeParameterConstraints.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1f2eaea833d..8b31ef91930 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4000,6 +4000,10 @@ namespace ts { return createTypeReference((type).target, concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); } + if (type.flags & TypeFlags.Tuple) { + resolveTupleTypeMembers(type as TupleType, thisArgument); + return type; + } return type; } @@ -4100,10 +4104,10 @@ namespace ts { return members; } - function resolveTupleTypeMembers(type: TupleType) { + function resolveTupleTypeMembers(type: TupleType, thisArgument?: Type) { const arrayElementType = getUnionType(type.elementTypes); // Make the tuple type itself the 'this' type by including an extra type argument - const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); + const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, thisArgument || type])); const members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); diff --git a/tests/baselines/reference/thisInTupleTypeParameterConstraints.js b/tests/baselines/reference/thisInTupleTypeParameterConstraints.js new file mode 100644 index 00000000000..c63fbf61991 --- /dev/null +++ b/tests/baselines/reference/thisInTupleTypeParameterConstraints.js @@ -0,0 +1,29 @@ +//// [thisInTupleTypeParameterConstraints.ts] +/// + +interface Boolean {} +interface IArguments {} +interface Function {} +interface Number {} +interface RegExp {} +interface Object {} +interface String {} + +interface Array { + // 4 methods will run out of memory if this-types are not instantiated + // correctly for tuple types that are type parameter constraints + map(arg: this): void; + reduceRight(arg: this): void; + reduce(arg: this): void; + reduce2(arg: this): void; +} + +declare function f number]>(a: T): void; +let x: [(x: number) => number]; +f(x); + + +//// [thisInTupleTypeParameterConstraints.js] +/// +var x; +f(x); diff --git a/tests/baselines/reference/thisInTupleTypeParameterConstraints.symbols b/tests/baselines/reference/thisInTupleTypeParameterConstraints.symbols new file mode 100644 index 00000000000..4d2bef22c55 --- /dev/null +++ b/tests/baselines/reference/thisInTupleTypeParameterConstraints.symbols @@ -0,0 +1,66 @@ +=== tests/cases/compiler/thisInTupleTypeParameterConstraints.ts === +/// + +interface Boolean {} +>Boolean : Symbol(Boolean, Decl(thisInTupleTypeParameterConstraints.ts, 0, 0)) + +interface IArguments {} +>IArguments : Symbol(IArguments, Decl(thisInTupleTypeParameterConstraints.ts, 2, 20)) + +interface Function {} +>Function : Symbol(Function, Decl(thisInTupleTypeParameterConstraints.ts, 3, 23)) + +interface Number {} +>Number : Symbol(Number, Decl(thisInTupleTypeParameterConstraints.ts, 4, 21)) + +interface RegExp {} +>RegExp : Symbol(RegExp, Decl(thisInTupleTypeParameterConstraints.ts, 5, 19)) + +interface Object {} +>Object : Symbol(Object, Decl(thisInTupleTypeParameterConstraints.ts, 6, 19)) + +interface String {} +>String : Symbol(String, Decl(thisInTupleTypeParameterConstraints.ts, 7, 19)) + +interface Array { +>Array : Symbol(Array, Decl(thisInTupleTypeParameterConstraints.ts, 8, 19)) +>T : Symbol(T, Decl(thisInTupleTypeParameterConstraints.ts, 10, 16)) + + // 4 methods will run out of memory if this-types are not instantiated + // correctly for tuple types that are type parameter constraints + map(arg: this): void; +>map : Symbol(Array.map, Decl(thisInTupleTypeParameterConstraints.ts, 10, 20)) +>U : Symbol(U, Decl(thisInTupleTypeParameterConstraints.ts, 13, 8)) +>arg : Symbol(arg, Decl(thisInTupleTypeParameterConstraints.ts, 13, 11)) + + reduceRight(arg: this): void; +>reduceRight : Symbol(Array.reduceRight, Decl(thisInTupleTypeParameterConstraints.ts, 13, 28)) +>U : Symbol(U, Decl(thisInTupleTypeParameterConstraints.ts, 14, 16)) +>arg : Symbol(arg, Decl(thisInTupleTypeParameterConstraints.ts, 14, 19)) + + reduce(arg: this): void; +>reduce : Symbol(Array.reduce, Decl(thisInTupleTypeParameterConstraints.ts, 14, 36)) +>U : Symbol(U, Decl(thisInTupleTypeParameterConstraints.ts, 15, 11)) +>arg : Symbol(arg, Decl(thisInTupleTypeParameterConstraints.ts, 15, 14)) + + reduce2(arg: this): void; +>reduce2 : Symbol(Array.reduce2, Decl(thisInTupleTypeParameterConstraints.ts, 15, 31)) +>U : Symbol(U, Decl(thisInTupleTypeParameterConstraints.ts, 16, 12)) +>arg : Symbol(arg, Decl(thisInTupleTypeParameterConstraints.ts, 16, 15)) +} + +declare function f number]>(a: T): void; +>f : Symbol(f, Decl(thisInTupleTypeParameterConstraints.ts, 17, 1)) +>T : Symbol(T, Decl(thisInTupleTypeParameterConstraints.ts, 19, 19)) +>x : Symbol(x, Decl(thisInTupleTypeParameterConstraints.ts, 19, 31)) +>a : Symbol(a, Decl(thisInTupleTypeParameterConstraints.ts, 19, 54)) +>T : Symbol(T, Decl(thisInTupleTypeParameterConstraints.ts, 19, 19)) + +let x: [(x: number) => number]; +>x : Symbol(x, Decl(thisInTupleTypeParameterConstraints.ts, 20, 3)) +>x : Symbol(x, Decl(thisInTupleTypeParameterConstraints.ts, 20, 9)) + +f(x); +>f : Symbol(f, Decl(thisInTupleTypeParameterConstraints.ts, 17, 1)) +>x : Symbol(x, Decl(thisInTupleTypeParameterConstraints.ts, 20, 3)) + diff --git a/tests/baselines/reference/thisInTupleTypeParameterConstraints.types b/tests/baselines/reference/thisInTupleTypeParameterConstraints.types new file mode 100644 index 00000000000..7daafe02bfc --- /dev/null +++ b/tests/baselines/reference/thisInTupleTypeParameterConstraints.types @@ -0,0 +1,67 @@ +=== tests/cases/compiler/thisInTupleTypeParameterConstraints.ts === +/// + +interface Boolean {} +>Boolean : Boolean + +interface IArguments {} +>IArguments : IArguments + +interface Function {} +>Function : Function + +interface Number {} +>Number : Number + +interface RegExp {} +>RegExp : RegExp + +interface Object {} +>Object : Object + +interface String {} +>String : String + +interface Array { +>Array : T[] +>T : T + + // 4 methods will run out of memory if this-types are not instantiated + // correctly for tuple types that are type parameter constraints + map(arg: this): void; +>map : (arg: this) => void +>U : U +>arg : this + + reduceRight(arg: this): void; +>reduceRight : (arg: this) => void +>U : U +>arg : this + + reduce(arg: this): void; +>reduce : (arg: this) => void +>U : U +>arg : this + + reduce2(arg: this): void; +>reduce2 : (arg: this) => void +>U : U +>arg : this +} + +declare function f number]>(a: T): void; +>f : number]>(a: T) => void +>T : T +>x : number +>a : T +>T : T + +let x: [(x: number) => number]; +>x : [(x: number) => number] +>x : number + +f(x); +>f(x) : void +>f : number]>(a: T) => void +>x : [(x: number) => number] + diff --git a/tests/cases/compiler/thisInTupleTypeParameterConstraints.ts b/tests/cases/compiler/thisInTupleTypeParameterConstraints.ts new file mode 100644 index 00000000000..b6d0d338d85 --- /dev/null +++ b/tests/cases/compiler/thisInTupleTypeParameterConstraints.ts @@ -0,0 +1,22 @@ +/// + +interface Boolean {} +interface IArguments {} +interface Function {} +interface Number {} +interface RegExp {} +interface Object {} +interface String {} + +interface Array { + // 4 methods will run out of memory if this-types are not instantiated + // correctly for tuple types that are type parameter constraints + map(arg: this): void; + reduceRight(arg: this): void; + reduce(arg: this): void; + reduce2(arg: this): void; +} + +declare function f number]>(a: T): void; +let x: [(x: number) => number]; +f(x); From d34bbe5f5880170066a55301a576f6372634d47c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 9 Aug 2016 12:47:43 -0700 Subject: [PATCH 114/508] Add explanatory comment to resolveTupleTypeMembers --- src/compiler/checker.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8b31ef91930..546d8412c98 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4107,6 +4107,7 @@ namespace ts { function resolveTupleTypeMembers(type: TupleType, thisArgument?: Type) { const arrayElementType = getUnionType(type.elementTypes); // Make the tuple type itself the 'this' type by including an extra type argument + // (Unless it's provided in the case that the tuple is a type parameter constraint) const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, thisArgument || type])); const members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); From a5ea55ab6561b932a57d18593f89c81ad1d0f9f0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 9 Aug 2016 13:39:00 -0700 Subject: [PATCH 115/508] Ignore null, undefined, void when checking for discriminant property --- src/compiler/checker.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1f2eaea833d..c88ab16acd7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7837,14 +7837,17 @@ namespace ts { } function isDiscriminantProperty(type: Type, name: string) { - if (type && type.flags & TypeFlags.Union) { - const prop = getPropertyOfType(type, name); - if (prop && prop.flags & SymbolFlags.SyntheticProperty) { - if ((prop).isDiscriminantProperty === undefined) { - (prop).isDiscriminantProperty = !(prop).hasCommonType && - isUnitUnionType(getTypeOfSymbol(prop)); + if (type) { + const nonNullType = getNonNullableType(type); + if (nonNullType.flags & TypeFlags.Union) { + const prop = getPropertyOfType(nonNullType, name); + if (prop && prop.flags & SymbolFlags.SyntheticProperty) { + if ((prop).isDiscriminantProperty === undefined) { + (prop).isDiscriminantProperty = !(prop).hasCommonType && + isUnitUnionType(getTypeOfSymbol(prop)); + } + return (prop).isDiscriminantProperty; } - return (prop).isDiscriminantProperty; } } return false; From 6c0bca0ae583c6b68ae9e007c081338ce9047d51 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 9 Aug 2016 13:39:12 -0700 Subject: [PATCH 116/508] Add regression test --- .../discriminantsAndNullOrUndefined.js | 44 ++++++++++++ .../discriminantsAndNullOrUndefined.symbols | 61 +++++++++++++++++ .../discriminantsAndNullOrUndefined.types | 68 +++++++++++++++++++ .../discriminantsAndNullOrUndefined.ts | 25 +++++++ 4 files changed, 198 insertions(+) create mode 100644 tests/baselines/reference/discriminantsAndNullOrUndefined.js create mode 100644 tests/baselines/reference/discriminantsAndNullOrUndefined.symbols create mode 100644 tests/baselines/reference/discriminantsAndNullOrUndefined.types create mode 100644 tests/cases/compiler/discriminantsAndNullOrUndefined.ts diff --git a/tests/baselines/reference/discriminantsAndNullOrUndefined.js b/tests/baselines/reference/discriminantsAndNullOrUndefined.js new file mode 100644 index 00000000000..153950f8ab5 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndNullOrUndefined.js @@ -0,0 +1,44 @@ +//// [discriminantsAndNullOrUndefined.ts] + +// Repro from #10228 + +interface A { kind: 'A'; } +interface B { kind: 'B'; } + +type C = A | B | undefined; + +function never(_: never): never { + throw new Error(); +} + +function useA(_: A): void { } +function useB(_: B): void { } + +declare var c: C; + +if (c !== undefined) { + switch (c.kind) { + case 'A': useA(c); break; + case 'B': useB(c); break; + default: never(c); + } +} + +//// [discriminantsAndNullOrUndefined.js] +// Repro from #10228 +function never(_) { + throw new Error(); +} +function useA(_) { } +function useB(_) { } +if (c !== undefined) { + switch (c.kind) { + case 'A': + useA(c); + break; + case 'B': + useB(c); + break; + default: never(c); + } +} diff --git a/tests/baselines/reference/discriminantsAndNullOrUndefined.symbols b/tests/baselines/reference/discriminantsAndNullOrUndefined.symbols new file mode 100644 index 00000000000..3f95fcf3a3f --- /dev/null +++ b/tests/baselines/reference/discriminantsAndNullOrUndefined.symbols @@ -0,0 +1,61 @@ +=== tests/cases/compiler/discriminantsAndNullOrUndefined.ts === + +// Repro from #10228 + +interface A { kind: 'A'; } +>A : Symbol(A, Decl(discriminantsAndNullOrUndefined.ts, 0, 0)) +>kind : Symbol(A.kind, Decl(discriminantsAndNullOrUndefined.ts, 3, 13)) + +interface B { kind: 'B'; } +>B : Symbol(B, Decl(discriminantsAndNullOrUndefined.ts, 3, 26)) +>kind : Symbol(B.kind, Decl(discriminantsAndNullOrUndefined.ts, 4, 13)) + +type C = A | B | undefined; +>C : Symbol(C, Decl(discriminantsAndNullOrUndefined.ts, 4, 26)) +>A : Symbol(A, Decl(discriminantsAndNullOrUndefined.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndNullOrUndefined.ts, 3, 26)) + +function never(_: never): never { +>never : Symbol(never, Decl(discriminantsAndNullOrUndefined.ts, 6, 27)) +>_ : Symbol(_, Decl(discriminantsAndNullOrUndefined.ts, 8, 15)) + + throw new Error(); +>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +function useA(_: A): void { } +>useA : Symbol(useA, Decl(discriminantsAndNullOrUndefined.ts, 10, 1)) +>_ : Symbol(_, Decl(discriminantsAndNullOrUndefined.ts, 12, 14)) +>A : Symbol(A, Decl(discriminantsAndNullOrUndefined.ts, 0, 0)) + +function useB(_: B): void { } +>useB : Symbol(useB, Decl(discriminantsAndNullOrUndefined.ts, 12, 29)) +>_ : Symbol(_, Decl(discriminantsAndNullOrUndefined.ts, 13, 14)) +>B : Symbol(B, Decl(discriminantsAndNullOrUndefined.ts, 3, 26)) + +declare var c: C; +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) +>C : Symbol(C, Decl(discriminantsAndNullOrUndefined.ts, 4, 26)) + +if (c !== undefined) { +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) +>undefined : Symbol(undefined) + + switch (c.kind) { +>c.kind : Symbol(kind, Decl(discriminantsAndNullOrUndefined.ts, 3, 13), Decl(discriminantsAndNullOrUndefined.ts, 4, 13)) +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) +>kind : Symbol(kind, Decl(discriminantsAndNullOrUndefined.ts, 3, 13), Decl(discriminantsAndNullOrUndefined.ts, 4, 13)) + + case 'A': useA(c); break; +>useA : Symbol(useA, Decl(discriminantsAndNullOrUndefined.ts, 10, 1)) +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) + + case 'B': useB(c); break; +>useB : Symbol(useB, Decl(discriminantsAndNullOrUndefined.ts, 12, 29)) +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) + + default: never(c); +>never : Symbol(never, Decl(discriminantsAndNullOrUndefined.ts, 6, 27)) +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) + } +} diff --git a/tests/baselines/reference/discriminantsAndNullOrUndefined.types b/tests/baselines/reference/discriminantsAndNullOrUndefined.types new file mode 100644 index 00000000000..7a2918ab83b --- /dev/null +++ b/tests/baselines/reference/discriminantsAndNullOrUndefined.types @@ -0,0 +1,68 @@ +=== tests/cases/compiler/discriminantsAndNullOrUndefined.ts === + +// Repro from #10228 + +interface A { kind: 'A'; } +>A : A +>kind : "A" + +interface B { kind: 'B'; } +>B : B +>kind : "B" + +type C = A | B | undefined; +>C : C +>A : A +>B : B + +function never(_: never): never { +>never : (_: never) => never +>_ : never + + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor +} + +function useA(_: A): void { } +>useA : (_: A) => void +>_ : A +>A : A + +function useB(_: B): void { } +>useB : (_: B) => void +>_ : B +>B : B + +declare var c: C; +>c : C +>C : C + +if (c !== undefined) { +>c !== undefined : boolean +>c : C +>undefined : undefined + + switch (c.kind) { +>c.kind : "A" | "B" +>c : A | B +>kind : "A" | "B" + + case 'A': useA(c); break; +>'A' : "A" +>useA(c) : void +>useA : (_: A) => void +>c : A + + case 'B': useB(c); break; +>'B' : "B" +>useB(c) : void +>useB : (_: B) => void +>c : B + + default: never(c); +>never(c) : never +>never : (_: never) => never +>c : never + } +} diff --git a/tests/cases/compiler/discriminantsAndNullOrUndefined.ts b/tests/cases/compiler/discriminantsAndNullOrUndefined.ts new file mode 100644 index 00000000000..8346fa8adea --- /dev/null +++ b/tests/cases/compiler/discriminantsAndNullOrUndefined.ts @@ -0,0 +1,25 @@ +// @strictNullChecks: true + +// Repro from #10228 + +interface A { kind: 'A'; } +interface B { kind: 'B'; } + +type C = A | B | undefined; + +function never(_: never): never { + throw new Error(); +} + +function useA(_: A): void { } +function useB(_: B): void { } + +declare var c: C; + +if (c !== undefined) { + switch (c.kind) { + case 'A': useA(c); break; + case 'B': useB(c); break; + default: never(c); + } +} \ No newline at end of file From 6a8f4cb676f0df1ce6fd84c0766643b8ca42f98b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 9 Aug 2016 14:48:11 -0700 Subject: [PATCH 117/508] Delay tuple type constraint resolution Create a new tuple that stores the this-type. --- src/compiler/checker.ts | 20 ++++++++++++-------- src/compiler/types.ts | 1 + 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 546d8412c98..1ed8cb8c6ee 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4001,8 +4001,7 @@ namespace ts { concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); } if (type.flags & TypeFlags.Tuple) { - resolveTupleTypeMembers(type as TupleType, thisArgument); - return type; + return createTupleType((type as TupleType).elementTypes, thisArgument); } return type; } @@ -4104,11 +4103,11 @@ namespace ts { return members; } - function resolveTupleTypeMembers(type: TupleType, thisArgument?: Type) { + function resolveTupleTypeMembers(type: TupleType) { const arrayElementType = getUnionType(type.elementTypes); // Make the tuple type itself the 'this' type by including an extra type argument // (Unless it's provided in the case that the tuple is a type parameter constraint) - const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, thisArgument || type])); + const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type.thisType || type])); const members = createTupleTypeMemberSymbols(type.elementTypes); addInheritedMembers(members, arrayType.properties); setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); @@ -5235,15 +5234,20 @@ namespace ts { return links.resolvedType; } - function createTupleType(elementTypes: Type[]) { - const id = getTypeListId(elementTypes); - return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + function createTupleType(elementTypes: Type[], thisType?: Type) { + let id = getTypeListId(elementTypes); + if (thisType) { + id += ',' + thisType.id; + } + + return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes, thisType)); } - function createNewTupleType(elementTypes: Type[]) { + function createNewTupleType(elementTypes: Type[], thisType?: Type) { const propagatedFlags = getPropagatingFlagsOfTypes(elementTypes, /*excludeKinds*/ 0); const type = createObjectType(TypeFlags.Tuple | propagatedFlags); type.elementTypes = elementTypes; + type.thisType = thisType; return type; } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a6e860450c6..25630059bf0 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2371,6 +2371,7 @@ namespace ts { export interface TupleType extends ObjectType { elementTypes: Type[]; // Element types + thisType?: Type; // This-type of tuple (only needed for tuples that are constraints of type parameters) } export interface UnionOrIntersectionType extends Type { From 80963baf509fd7f22b81f13da3aa6b3840312c97 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 9 Aug 2016 15:37:15 -0700 Subject: [PATCH 118/508] Always use thisType when generating tuple id --- src/compiler/checker.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1ed8cb8c6ee..8fcd22f0ffb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1538,8 +1538,8 @@ namespace ts { function createType(flags: TypeFlags): Type { const result = new Type(checker, flags); - result.id = typeCount; typeCount++; + result.id = typeCount; return result; } @@ -5235,11 +5235,7 @@ namespace ts { } function createTupleType(elementTypes: Type[], thisType?: Type) { - let id = getTypeListId(elementTypes); - if (thisType) { - id += ',' + thisType.id; - } - + const id = getTypeListId(elementTypes) + ',' + (thisType ? thisType.id : 0); return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes, thisType)); } From 9d4547c5d08430a87304caac6a8fe164baed4c19 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 9 Aug 2016 16:33:45 -0700 Subject: [PATCH 119/508] Optimize format of type list id strings used in maps --- src/compiler/checker.ts | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1f2eaea833d..ac4ac3d506d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4941,24 +4941,27 @@ namespace ts { } function getTypeListId(types: Type[]) { + let result = ""; if (types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - let result = ""; - for (let i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; - } - result += types[i].id; - } - return result; + const length = types.length; + let i = 0; + while (i < length) { + const startId = types[i].id; + let count = 1; + while (i + count < length && types[i + count].id === startId + count) { + count++; + } + if (result.length) { + result += ","; + } + result += startId; + if (count > 1) { + result += ":" + count; + } + i += count; } } - return ""; + return result; } // This function is used to propagate certain flags when creating new object type references and union types. From 8975cd7024dc1057794af93fcb74f36844f8e1a5 Mon Sep 17 00:00:00 2001 From: joshaber Date: Tue, 9 Aug 2016 23:00:47 -0400 Subject: [PATCH 120/508] Make ReadonlyArray iterable. --- src/lib/es2015.iterable.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index e1b9d99762b..de339e2bf2c 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -63,6 +63,26 @@ interface ArrayConstructor { from(iterable: Iterable): Array; } +interface ReadonlyArray { + /** Iterator */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + interface IArguments { /** Iterator */ [Symbol.iterator](): IterableIterator; From ecc51af1ec712447be88fa97c4ba38612bd98f42 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 10 Aug 2016 10:01:16 -0700 Subject: [PATCH 121/508] Allow OSX to fail while we investigate (#10255) The random test timeouts are an issue. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4126683eb62..97c772f45ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,8 @@ matrix: node_js: stable osx_image: xcode7.3 env: workerCount=2 + allow_failures: + - os: osx branches: only: From 56cb07ae919372d96e98d9195375b7264555380e Mon Sep 17 00:00:00 2001 From: zhengbli Date: Wed, 10 Aug 2016 12:34:27 -0700 Subject: [PATCH 122/508] avoid using the global name --- src/harness/unittests/session.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index c5285544329..d5e6daa5d60 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -106,7 +106,7 @@ namespace ts.server { describe("onMessage", () => { it("should not throw when commands are executed with invalid arguments", () => { let i = 0; - for (name in CommandNames) { + for (const name in CommandNames) { if (!Object.prototype.hasOwnProperty.call(CommandNames, name)) { continue; } From 408780864c1199899ed5277aa0ed893a95528671 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 10 Aug 2016 14:09:52 -0700 Subject: [PATCH 123/508] Fix single-quote lint --- 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 8fcd22f0ffb..b8d7146efb7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5235,7 +5235,7 @@ namespace ts { } function createTupleType(elementTypes: Type[], thisType?: Type) { - const id = getTypeListId(elementTypes) + ',' + (thisType ? thisType.id : 0); + const id = getTypeListId(elementTypes) + "," + (thisType ? thisType.id : 0); return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes, thisType)); } From 65e1293b2e542165f668191a26dae2d446c54b74 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 10 Aug 2016 16:47:06 -0700 Subject: [PATCH 124/508] Optimize performance of maps --- src/compiler/binder.ts | 27 +- src/compiler/checker.ts | 280 ++++++++---------- src/compiler/commandLineParser.ts | 10 +- src/compiler/core.ts | 48 +-- src/compiler/declarationEmitter.ts | 2 +- src/compiler/emitter.ts | 24 +- src/compiler/parser.ts | 4 +- src/compiler/performance.ts | 4 +- src/compiler/program.ts | 16 +- src/compiler/scanner.ts | 4 +- src/compiler/sys.ts | 29 +- src/compiler/tsc.ts | 8 +- src/compiler/types.ts | 24 +- src/compiler/utilities.ts | 35 +-- src/harness/compilerRunner.ts | 6 +- src/harness/fourslash.ts | 14 +- src/harness/harness.ts | 4 +- src/harness/harnessLanguageService.ts | 6 +- src/harness/projectsRunner.ts | 2 +- .../unittests/cachingInServerLSHost.ts | 6 +- src/harness/unittests/moduleResolution.ts | 30 +- .../unittests/reuseProgramStructure.ts | 10 +- src/harness/unittests/session.ts | 4 +- .../unittests/tsserverProjectSystem.ts | 8 +- src/server/client.ts | 2 +- src/server/editorServices.ts | 16 +- src/server/session.ts | 2 +- src/services/jsTyping.ts | 4 +- src/services/navigationBar.ts | 2 +- src/services/patternMatcher.ts | 2 +- src/services/services.ts | 22 +- 31 files changed, 321 insertions(+), 334 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 8d8666a67ab..c7450ac88fb 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -135,7 +135,7 @@ namespace ts { options = opts; languageVersion = getEmitScriptTarget(options); inStrictMode = !!file.externalModuleIndicator; - classifiableNames = {}; + classifiableNames = createMap(); symbolCount = 0; Symbol = objectAllocator.getSymbolConstructor(); @@ -183,11 +183,11 @@ namespace ts { symbol.declarations.push(node); if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) { - symbol.exports = {}; + symbol.exports = createMap(); } if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) { - symbol.members = {}; + symbol.members = createMap(); } if (symbolFlags & SymbolFlags.Value) { @@ -318,9 +318,7 @@ namespace ts { // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = hasProperty(symbolTable, name) - ? symbolTable[name] - : (symbolTable[name] = createSymbol(SymbolFlags.None, name)); + symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name)); if (name && (includes & SymbolFlags.Classifiable)) { classifiableNames[name] = name; @@ -434,7 +432,7 @@ namespace ts { if (containerFlags & ContainerFlags.IsContainer) { container = blockScopeContainer = node; if (containerFlags & ContainerFlags.HasLocals) { - container.locals = {}; + container.locals = createMap(); } addToContainerChain(container); } @@ -1399,7 +1397,8 @@ namespace ts { const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); - typeLiteralSymbol.members = { [symbol.name]: symbol }; + typeLiteralSymbol.members = createMap(); + typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node: ObjectLiteralExpression) { @@ -1409,7 +1408,7 @@ namespace ts { } if (inStrictMode) { - const seen: Map = {}; + const seen = createMap(); for (const prop of node.properties) { if (prop.name.kind !== SyntaxKind.Identifier) { @@ -1465,7 +1464,7 @@ namespace ts { // fall through. default: if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; + blockScopeContainer.locals = createMap(); addToContainerChain(blockScopeContainer); } declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); @@ -1925,7 +1924,7 @@ namespace ts { } } - file.symbol.globalExports = file.symbol.globalExports || {}; + file.symbol.globalExports = file.symbol.globalExports || createMap(); declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); } @@ -1978,7 +1977,7 @@ namespace ts { else { return; } - assignee.symbol.members = assignee.symbol.members || {}; + assignee.symbol.members = assignee.symbol.members || createMap(); // It's acceptable for multiple 'this' assignments of the same identifier to occur declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); } @@ -2004,7 +2003,7 @@ namespace ts { // Set up the members collection if it doesn't exist already if (!funcSymbol.members) { - funcSymbol.members = {}; + funcSymbol.members = createMap(); } // Declare the method/property @@ -2053,7 +2052,7 @@ namespace ts { // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); - if (hasProperty(symbol.exports, prototypeSymbol.name)) { + if (symbol.exports[prototypeSymbol.name]) { if (node.name) { node.name.parent = node; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c88ab16acd7..6b3fb1076a1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -44,7 +44,7 @@ namespace ts { let symbolCount = 0; const emptyArray: any[] = []; - const emptySymbols: SymbolTable = {}; + const emptySymbols = createMap(); const compilerOptions = host.getCompilerOptions(); const languageVersion = compilerOptions.target || ScriptTarget.ES3; @@ -106,11 +106,11 @@ namespace ts { isOptionalParameter }; - const tupleTypes: Map = {}; - const unionTypes: Map = {}; - const intersectionTypes: Map = {}; - const stringLiteralTypes: Map = {}; - const numericLiteralTypes: Map = {}; + const tupleTypes = createMap(); + const unionTypes = createMap(); + const intersectionTypes = createMap(); + const stringLiteralTypes = createMap(); + const numericLiteralTypes = createMap(); const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); @@ -132,7 +132,7 @@ namespace ts { const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); const emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - emptyGenericType.instantiations = {}; + emptyGenericType.instantiations = createMap(); const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated @@ -146,7 +146,7 @@ namespace ts { const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); - const globals: SymbolTable = {}; + const globals = createMap(); /** * List of every ambient module with a "*" wildcard. * Unlike other ambient modules, these can't be stored in `globals` because symbol tables only deal with exact matches. @@ -283,7 +283,7 @@ namespace ts { NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy, } - const typeofEQFacts: Map = { + const typeofEQFacts: MapLike = { "string": TypeFacts.TypeofEQString, "number": TypeFacts.TypeofEQNumber, "boolean": TypeFacts.TypeofEQBoolean, @@ -293,7 +293,7 @@ namespace ts { "function": TypeFacts.TypeofEQFunction }; - const typeofNEFacts: Map = { + const typeofNEFacts: MapLike = { "string": TypeFacts.TypeofNEString, "number": TypeFacts.TypeofNENumber, "boolean": TypeFacts.TypeofNEBoolean, @@ -303,7 +303,7 @@ namespace ts { "function": TypeFacts.TypeofNEFunction }; - const typeofTypesByName: Map = { + const typeofTypesByName: MapLike = { "string": stringType, "number": numberType, "boolean": booleanType, @@ -313,7 +313,7 @@ namespace ts { let jsxElementType: ObjectType; /** Things we lazy load from the JSX namespace */ - const jsxTypes: Map = {}; + const jsxTypes = createMap(); const JsxNames = { JSX: "JSX", IntrinsicElements: "IntrinsicElements", @@ -324,10 +324,10 @@ namespace ts { IntrinsicClassAttributes: "IntrinsicClassAttributes" }; - const subtypeRelation: Map = {}; - const assignableRelation: Map = {}; - const comparableRelation: Map = {}; - const identityRelation: Map = {}; + const subtypeRelation = createMap(); + const assignableRelation = createMap(); + const comparableRelation = createMap(); + const identityRelation = createMap(); // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. let _displayBuilder: SymbolDisplayBuilder; @@ -341,9 +341,8 @@ namespace ts { ResolvedReturnType } - const builtinGlobals: SymbolTable = { - [undefinedSymbol.name]: undefinedSymbol - }; + const builtinGlobals = createMap(); + builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); @@ -426,11 +425,11 @@ namespace ts { target.declarations.push(node); }); if (source.members) { - if (!target.members) target.members = {}; + if (!target.members) target.members = createMap(); mergeSymbolTable(target.members, source.members); } if (source.exports) { - if (!target.exports) target.exports = {}; + if (!target.exports) target.exports = createMap(); mergeSymbolTable(target.exports, source.exports); } recordMergedSymbol(target, source); @@ -448,28 +447,24 @@ namespace ts { } function cloneSymbolTable(symbolTable: SymbolTable): SymbolTable { - const result: SymbolTable = {}; + const result = createMap(); for (const id in symbolTable) { - if (hasProperty(symbolTable, id)) { - result[id] = symbolTable[id]; - } + result[id] = symbolTable[id]; } return result; } function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { for (const id in source) { - if (hasProperty(source, id)) { - if (!hasProperty(target, id)) { - target[id] = source[id]; - } - else { - let symbol = target[id]; - if (!(symbol.flags & SymbolFlags.Merged)) { - target[id] = symbol = cloneSymbol(symbol); - } - mergeSymbol(symbol, source[id]); + let targetSymbol = target[id]; + if (!targetSymbol) { + target[id] = source[id]; + } + else { + if (!(targetSymbol.flags & SymbolFlags.Merged)) { + target[id] = targetSymbol = cloneSymbol(targetSymbol); } + mergeSymbol(targetSymbol, source[id]); } } } @@ -513,14 +508,12 @@ namespace ts { function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) { for (const id in source) { - if (hasProperty(source, id)) { - if (hasProperty(target, id)) { - // Error on redeclarations - forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); - } - else { - target[id] = source[id]; - } + if (target[id]) { + // Error on redeclarations + forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + } + else { + target[id] = source[id]; } } @@ -545,18 +538,20 @@ namespace ts { } function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { - if (meaning && hasProperty(symbols, name)) { + if (meaning) { const symbol = symbols[name]; - Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); - if (symbol.flags & meaning) { - return symbol; - } - if (symbol.flags & SymbolFlags.Alias) { - const target = resolveAlias(symbol); - // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors - if (target === unknownSymbol || target.flags & meaning) { + if (symbol) { + Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); + if (symbol.flags & meaning) { return symbol; } + if (symbol.flags & SymbolFlags.Alias) { + const target = resolveAlias(symbol); + // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors + if (target === unknownSymbol || target.flags & meaning) { + return symbol; + } + } } } // return undefined if we can't find a symbol. @@ -744,7 +739,7 @@ namespace ts { // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, // which is not the desired behavior. - if (hasProperty(moduleExports, name) && + if (moduleExports[name] && moduleExports[name].flags === SymbolFlags.Alias && getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) { break; @@ -1101,9 +1096,9 @@ namespace ts { function getExportOfModule(symbol: Symbol, name: string): Symbol { if (symbol.flags & SymbolFlags.Module) { - const exports = getExportsOfSymbol(symbol); - if (hasProperty(exports, name)) { - return resolveSymbol(exports[name]); + const exportedSymbol = getExportsOfSymbol(symbol)[name]; + if (exportedSymbol) { + return resolveSymbol(exportedSymbol); } } } @@ -1421,7 +1416,7 @@ namespace ts { */ function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map, exportNode?: ExportDeclaration) { for (const id in source) { - if (id !== "default" && !hasProperty(target, id)) { + if (id !== "default" && !target[id]) { target[id] = source[id]; if (lookupTable && exportNode) { lookupTable[id] = { @@ -1429,7 +1424,7 @@ namespace ts { } as ExportCollisionTracker; } } - else if (lookupTable && exportNode && id !== "default" && hasProperty(target, id) && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { + else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { if (!lookupTable[id].exportsWithDuplicate) { lookupTable[id].exportsWithDuplicate = [exportNode]; } @@ -1455,8 +1450,8 @@ namespace ts { // All export * declarations are collected in an __export symbol by the binder const exportStars = symbol.exports["__export"]; if (exportStars) { - const nestedSymbols: SymbolTable = {}; - const lookupTable: Map = {}; + const nestedSymbols = createMap(); + const lookupTable = createMap(); for (const node of exportStars.declarations) { const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier); const exportedSymbols = visit(resolvedModule); @@ -1470,7 +1465,7 @@ namespace ts { for (const id in lookupTable) { const { exportsWithDuplicate } = lookupTable[id]; // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || hasProperty(symbols, id)) { + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { continue; } for (const node of exportsWithDuplicate) { @@ -1576,13 +1571,11 @@ namespace ts { function getNamedMembers(members: SymbolTable): Symbol[] { let result: Symbol[]; for (const id in members) { - if (hasProperty(members, id)) { - if (!isReservedMemberName(id)) { - if (!result) result = []; - const symbol = members[id]; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id)) { + if (!result) result = []; + const symbol = members[id]; + if (symbolIsValue(symbol)) { + result.push(symbol); } } } @@ -1698,12 +1691,12 @@ namespace ts { let qualify = false; forEachSymbolTableInScope(enclosingDeclaration, symbolTable => { // If symbol of this name is not available in the symbol table we are ok - if (!hasProperty(symbolTable, symbol.name)) { + let symbolFromSymbolTable = symbolTable[symbol.name]; + if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; } // If the symbol with this name is present it should refer to the symbol - let symbolFromSymbolTable = symbolTable[symbol.name]; if (symbolFromSymbolTable === symbol) { // No need to qualify return true; @@ -3121,7 +3114,7 @@ namespace ts { // Return the type implied by an object binding pattern function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { - const members: SymbolTable = {}; + const members = createMap(); let hasComputedProperties = false; forEach(pattern.elements, e => { const name = e.propertyName || e.name; @@ -3709,7 +3702,7 @@ namespace ts { type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; - (type).instantiations = {}; + (type).instantiations = createMap(); (type).instantiations[getTypeListId(type.typeParameters)] = type; (type).target = type; (type).typeArguments = type.typeParameters; @@ -3751,7 +3744,7 @@ namespace ts { if (typeParameters) { // Initialize the instantiation cache for generic type aliases. The declared type corresponds to // an instantiation of the type alias with the type parameters supplied as type arguments. - links.instantiations = {}; + links.instantiations = createMap(); links.instantiations[getTypeListId(links.typeParameters)] = type; } } @@ -3772,7 +3765,7 @@ namespace ts { return expr.kind === SyntaxKind.NumericLiteral || expr.kind === SyntaxKind.PrefixUnaryExpression && (expr).operator === SyntaxKind.MinusToken && (expr).operand.kind === SyntaxKind.NumericLiteral || - expr.kind === SyntaxKind.Identifier && hasProperty(symbol.exports, (expr).text); + expr.kind === SyntaxKind.Identifier && !!symbol.exports[(expr).text]; } function enumHasLiteralMembers(symbol: Symbol) { @@ -3795,7 +3788,7 @@ namespace ts { enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { const memberTypeList: Type[] = []; - const memberTypes: Map = {}; + const memberTypes = createMap(); for (const declaration of enumType.symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { computeEnumMemberValues(declaration); @@ -3958,7 +3951,7 @@ namespace ts { } function createSymbolTable(symbols: Symbol[]): SymbolTable { - const result: SymbolTable = {}; + const result = createMap(); for (const symbol of symbols) { result[symbol.name] = symbol; } @@ -3968,7 +3961,7 @@ namespace ts { // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { - const result: SymbolTable = {}; + const result = createMap(); for (const symbol of symbols) { result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } @@ -3977,7 +3970,7 @@ namespace ts { function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) { for (const s of baseSymbols) { - if (!hasProperty(symbols, s.name)) { + if (!symbols[s.name]) { symbols[s.name] = s; } } @@ -4091,7 +4084,7 @@ namespace ts { } function createTupleTypeMemberSymbols(memberTypes: Type[]): SymbolTable { - const members: SymbolTable = {}; + const members = createMap(); for (let i = 0; i < memberTypes.length; i++) { const symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "" + i); symbol.type = memberTypes[i]; @@ -4313,11 +4306,9 @@ namespace ts { function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.ObjectType) { const resolved = resolveStructuredTypeMembers(type); - if (hasProperty(resolved.members, name)) { - const symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } + const symbol = resolved.members[name]; + if (symbol && symbolIsValue(symbol)) { + return symbol; } } } @@ -4446,13 +4437,13 @@ namespace ts { } function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: string): Symbol { - const properties = type.resolvedProperties || (type.resolvedProperties = {}); - if (hasProperty(properties, name)) { - return properties[name]; - } - const property = createUnionOrIntersectionProperty(type, name); - if (property) { - properties[name] = property; + const properties = type.resolvedProperties || (type.resolvedProperties = createMap()); + let property = properties[name]; + if (!property) { + property = createUnionOrIntersectionProperty(type, name); + if (property) { + properties[name] = property; + } } return property; } @@ -4469,11 +4460,9 @@ namespace ts { type = getApparentType(type); if (type.flags & TypeFlags.ObjectType) { const resolved = resolveStructuredTypeMembers(type); - if (hasProperty(resolved.members, name)) { - const symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } + const symbol = resolved.members[name]; + if (symbol && symbolIsValue(symbol)) { + return symbol; } if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { const symbol = getPropertyOfObjectType(globalFunctionType, name); @@ -5467,7 +5456,7 @@ namespace ts { function getLiteralTypeForText(flags: TypeFlags, text: string) { const map = flags & TypeFlags.StringLiteral ? stringLiteralTypes : numericLiteralTypes; - return hasProperty(map, text) ? map[text] : map[text] = createLiteralType(flags, text); + return map[text] || (map[text] = createLiteralType(flags, text)); } function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { @@ -6582,7 +6571,7 @@ namespace ts { } sourceStack[depth] = source; targetStack[depth] = target; - maybeStack[depth] = {}; + maybeStack[depth] = createMap(); maybeStack[depth][id] = RelationComparisonResult.Succeeded; depth++; const saveExpandingFlags = expandingFlags; @@ -7223,7 +7212,7 @@ namespace ts { } function transformTypeOfMembers(type: Type, f: (propertyType: Type) => Type) { - const members: SymbolTable = {}; + const members = createMap(); for (const property of getPropertiesOfObjectType(type)) { const original = getTypeOfSymbol(property); const updated = f(original); @@ -7447,7 +7436,7 @@ namespace ts { let targetStack: Type[]; let depth = 0; let inferiority = 0; - const visited: Map = {}; + const visited = createMap(); inferFromTypes(source, target); function isInProcess(source: Type, target: Type) { @@ -7581,7 +7570,7 @@ namespace ts { return; } const key = source.id + "," + target.id; - if (hasProperty(visited, key)) { + if (visited[key]) { return; } visited[key] = true; @@ -8338,7 +8327,7 @@ namespace ts { // If we have previously computed the control flow type for the reference at // this flow loop junction, return the cached type. const id = getFlowNodeId(flow); - const cache = flowLoopCaches[id] || (flowLoopCaches[id] = {}); + const cache = flowLoopCaches[id] || (flowLoopCaches[id] = createMap()); if (!key) { key = getFlowCacheKey(reference); } @@ -9933,7 +9922,7 @@ namespace ts { // Grammar checking checkGrammarObjectLiteralExpression(node, inDestructuringPattern); - const propertiesTable: SymbolTable = {}; + const propertiesTable = createMap(); const propertiesArray: Symbol[] = []; const contextualType = getApparentTypeOfContextualType(node); const contextualTypeHasPattern = contextualType && contextualType.pattern && @@ -10024,7 +10013,7 @@ namespace ts { // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { for (const prop of getPropertiesOfType(contextualType)) { - if (!hasProperty(propertiesTable, prop.name)) { + if (!propertiesTable[prop.name]) { if (!(prop.flags & SymbolFlags.Optional)) { error(prop.valueDeclaration || (prop).bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); @@ -10152,7 +10141,7 @@ namespace ts { for (const prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type - if (!hasProperty(nameTable, prop.name)) { + if (!nameTable[prop.name]) { const targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { const msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); @@ -10474,7 +10463,7 @@ namespace ts { const targetAttributesType = getJsxElementAttributesType(node); - const nameTable: Map = {}; + const nameTable = createMap(); // Process this array in right-to-left order so we know which // attributes (mostly from spreads) are being overwritten and // thus should have their types ignored @@ -10498,7 +10487,7 @@ namespace ts { const targetProperties = getPropertiesOfType(targetAttributesType); for (let i = 0; i < targetProperties.length; i++) { if (!(targetProperties[i].flags & SymbolFlags.Optional) && - !hasProperty(nameTable, targetProperties[i].name)) { + !nameTable[targetProperties[i].name]) { error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); } @@ -13782,8 +13771,8 @@ namespace ts { function checkClassForDuplicateDeclarations(node: ClassLikeDeclaration) { const getter = 1, setter = 2, property = getter | setter; - const instanceNames: Map = {}; - const staticNames: Map = {}; + const instanceNames = createMap(); + const staticNames = createMap(); for (const member of node.members) { if (member.kind === SyntaxKind.Constructor) { for (const param of (member as ConstructorDeclaration).parameters) { @@ -13816,8 +13805,8 @@ namespace ts { } function addName(names: Map, location: Node, name: string, meaning: number) { - if (hasProperty(names, name)) { - const prev = names[name]; + const prev = names[name]; + if (prev) { if (prev & meaning) { error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location)); } @@ -13832,7 +13821,7 @@ namespace ts { } function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) { - const names: Map = {}; + const names = createMap(); for (const member of node.members) { if (member.kind == SyntaxKind.PropertySignature) { let memberName: string; @@ -13846,7 +13835,7 @@ namespace ts { continue; } - if (hasProperty(names, memberName)) { + if (names[memberName]) { error(member.symbol.valueDeclaration.name, Diagnostics.Duplicate_identifier_0, memberName); error(member.name, Diagnostics.Duplicate_identifier_0, memberName); } @@ -15058,22 +15047,20 @@ namespace ts { function checkUnusedLocalsAndParameters(node: Node): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { for (const key in node.locals) { - if (hasProperty(node.locals, key)) { - const local = node.locals[key]; - if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) { - const parameter = local.valueDeclaration; - if (compilerOptions.noUnusedParameters && - !isParameterPropertyDeclaration(parameter) && - !parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(parameter)) { - error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); - } - } - else if (compilerOptions.noUnusedLocals) { - forEach(local.declarations, d => error(d.name || d, Diagnostics._0_is_declared_but_never_used, local.name)); + const local = node.locals[key]; + if (!local.isReferenced) { + if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) { + const parameter = local.valueDeclaration; + if (compilerOptions.noUnusedParameters && + !isParameterPropertyDeclaration(parameter) && + !parameterIsThisKeyword(parameter) && + !parameterNameStartsWithUnderscore(parameter)) { + error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } + else if (compilerOptions.noUnusedLocals) { + forEach(local.declarations, d => error(d.name || d, Diagnostics._0_is_declared_but_never_used, local.name)); + } } } } @@ -15130,13 +15117,11 @@ namespace ts { function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { - if (hasProperty(node.locals, key)) { - const local = node.locals[key]; - if (!local.isReferenced && !local.exportSymbol) { - for (const declaration of local.declarations) { - if (!isAmbientModule(declaration)) { - error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name); - } + const local = node.locals[key]; + if (!local.isReferenced && !local.exportSymbol) { + for (const declaration of local.declarations) { + if (!isAmbientModule(declaration)) { + error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } } @@ -16145,7 +16130,7 @@ namespace ts { else { const identifierName = (catchClause.variableDeclaration.name).text; const locals = catchClause.block.locals; - if (locals && hasProperty(locals, identifierName)) { + if (locals) { const localSymbol = locals[identifierName]; if (localSymbol && (localSymbol.flags & SymbolFlags.BlockScopedVariable) !== 0) { grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); @@ -16566,18 +16551,18 @@ namespace ts { return true; } - const seen: Map<{ prop: Symbol; containingType: Type }> = {}; + const seen = createMap<{ prop: Symbol; containingType: Type }>(); forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; }); let ok = true; for (const base of baseTypes) { const properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (const prop of properties) { - if (!hasProperty(seen, prop.name)) { + const existing = seen[prop.name]; + if (!existing) { seen[prop.name] = { prop: prop, containingType: base }; } else { - const existing = seen[prop.name]; const isInheritedProperty = existing.containingType !== type; if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { ok = false; @@ -17635,7 +17620,7 @@ namespace ts { } function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] { - const symbols: SymbolTable = {}; + const symbols = createMap(); let memberFlags: NodeFlags = 0; if (isInsideWithStatementBody(location)) { @@ -17713,7 +17698,7 @@ namespace ts { // We will copy all symbol regardless of its reserved name because // symbolsToArray will check whether the key is a reserved name and // it will not copy symbol with reserved name to the array - if (!hasProperty(symbols, id)) { + if (!symbols[id]) { symbols[id] = symbol; } } @@ -18134,7 +18119,7 @@ namespace ts { const propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, SignatureKind.Call).length || getSignaturesOfType(type, SignatureKind.Construct).length) { forEach(getPropertiesOfType(globalFunctionType), p => { - if (!hasProperty(propsByName, p.name)) { + if (!propsByName[p.name]) { propsByName[p.name] = p; } }); @@ -18482,7 +18467,7 @@ namespace ts { } function hasGlobalName(name: string): boolean { - return hasProperty(globals, name); + return !!globals[name]; } function getReferencedValueSymbol(reference: Identifier): Symbol { @@ -18506,9 +18491,6 @@ namespace ts { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = createFileMap(); for (const key in resolvedTypeReferenceDirectives) { - if (!hasProperty(resolvedTypeReferenceDirectives, key)) { - continue; - } const resolvedDirective = resolvedTypeReferenceDirectives[key]; if (!resolvedDirective) { continue; @@ -19297,7 +19279,7 @@ namespace ts { } function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression, inDestructuring: boolean) { - const seen: Map = {}; + const seen = createMap(); const Property = 1; const GetAccessor = 2; const SetAccessor = 4; @@ -19359,7 +19341,7 @@ namespace ts { continue; } - if (!hasProperty(seen, effectiveName)) { + if (!seen[effectiveName]) { seen[effectiveName] = currentKind; } else { @@ -19383,7 +19365,7 @@ namespace ts { } function checkGrammarJsxElement(node: JsxOpeningLikeElement) { - const seen: Map = {}; + const seen = createMap(); for (const attr of node.attributes) { if (attr.kind === SyntaxKind.JsxSpreadAttribute) { continue; @@ -19391,7 +19373,7 @@ namespace ts { const jsxAttr = (attr); const name = jsxAttr.name; - if (!hasProperty(seen, name.text)) { + if (!seen[name.text]) { seen[name.text] = true; } else { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 7e2c6eb8d33..eaf17f00dd0 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -470,8 +470,8 @@ namespace ts { return optionNameMapCache; } - const optionNameMap: Map = {}; - const shortOptionNames: Map = {}; + const optionNameMap = createMap(); + const shortOptionNames = createMap(); forEach(optionDeclarations, option => { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { @@ -958,12 +958,12 @@ namespace ts { // Literal file names (provided via the "files" array in tsconfig.json) are stored in a // file map with a possibly case insensitive key. We use this map later when when including // wildcard paths. - const literalFileMap: Map = {}; + const literalFileMap = createMap(); // Wildcard paths (provided via the "includes" array in tsconfig.json) are stored in a // file map with a possibly case insensitive key. We use this map to store paths matched // via wildcard, and to handle extension priority. - const wildcardFileMap: Map = {}; + const wildcardFileMap = createMap(); if (include) { include = validateSpecs(include, errors, /*allowTrailingRecursion*/ false); @@ -1063,7 +1063,7 @@ namespace ts { // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude"); const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - const wildcardDirectories: Map = {}; + const wildcardDirectories = createMap(); if (include !== undefined) { const recursiveKeys: string[] = []; for (const file of include) { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 6c87ad82955..db88305d2c5 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -19,8 +19,24 @@ namespace ts { True = -1 } + const createObject = Object.create; + + export function createMap(): Map { + /* tslint:disable:no-null-keyword */ + const map: Map = createObject(null); + /* tslint:enable:no-null-keyword */ + + // Using 'delete' on an object causes V8 to put the object in dictionary mode. + // This disables creation of hidden classes, which are expensive when an object is + // constantly changing shape. + map["__"] = undefined; + delete map["__"]; + + return map; + } + export function createFileMap(keyMapper?: (key: string) => string): FileMap { - let files: Map = {}; + let files = createMap(); return { get, set, @@ -55,7 +71,7 @@ namespace ts { } function clear() { - files = {}; + files = createMap(); } function toKey(path: Path): string { @@ -311,11 +327,11 @@ namespace ts { const hasOwnProperty = Object.prototype.hasOwnProperty; - export function hasProperty(map: Map, key: string): boolean { + export function hasProperty(map: MapLike, key: string): boolean { return hasOwnProperty.call(map, key); } - export function getKeys(map: Map): string[] { + export function getKeys(map: MapLike): string[] { const keys: string[] = []; for (const key in map) { keys.push(key); @@ -323,15 +339,15 @@ namespace ts { return keys; } - export function getProperty(map: Map, key: string): T | undefined { + export function getProperty(map: MapLike, key: string): T | undefined { return hasProperty(map, key) ? map[key] : undefined; } - export function getOrUpdateProperty(map: Map, key: string, makeValue: () => T): T { + export function getOrUpdateProperty(map: MapLike, key: string, makeValue: () => T): T { return hasProperty(map, key) ? map[key] : map[key] = makeValue(); } - export function isEmpty(map: Map) { + export function isEmpty(map: MapLike) { for (const id in map) { if (hasProperty(map, id)) { return false; @@ -348,7 +364,7 @@ namespace ts { return result; } - export function extend, T2 extends Map<{}>>(first: T1 , second: T2): T1 & T2 { + export function extend, T2 extends MapLike<{}>>(first: T1 , second: T2): T1 & T2 { const result: T1 & T2 = {}; for (const id in first) { (result as any)[id] = first[id]; @@ -361,7 +377,7 @@ namespace ts { return result; } - export function forEachValue(map: Map, callback: (value: T) => U): U { + export function forEachValue(map: MapLike, callback: (value: T) => U): U { let result: U; for (const id in map) { if (result = callback(map[id])) break; @@ -369,7 +385,7 @@ namespace ts { return result; } - export function forEachKey(map: Map, callback: (key: string) => U): U { + export function forEachKey(map: MapLike, callback: (key: string) => U): U { let result: U; for (const id in map) { if (result = callback(id)) break; @@ -377,11 +393,11 @@ namespace ts { return result; } - export function lookUp(map: Map, key: string): T { + export function lookUp(map: MapLike, key: string): T { return hasProperty(map, key) ? map[key] : undefined; } - export function copyMap(source: Map, target: Map): void { + export function copyMap(source: MapLike, target: MapLike): void { for (const p in source) { target[p] = source[p]; } @@ -398,7 +414,7 @@ namespace ts { * index in the array will be the one associated with the produced key. */ export function arrayToMap(array: T[], makeKey: (value: T) => string): Map { - const result: Map = {}; + const result = createMap(); forEach(array, value => { result[makeKey(value)] = value; @@ -414,7 +430,7 @@ namespace ts { * @param callback An aggregation function that is called for each entry in the map * @param initial The initial value for the reduction. */ - export function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { + export function reduceProperties(map: MapLike, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { let result = initial; if (map) { for (const key in map) { @@ -454,9 +470,7 @@ namespace ts { export let localizedDiagnosticMessages: Map = undefined; export function getLocaleSpecificMessage(message: DiagnosticMessage) { - return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] - ? localizedDiagnosticMessages[message.key] - : message.message; + return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message; } export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic; diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index d93a8a0aed0..113b79f33d4 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -269,7 +269,7 @@ namespace ts { } if (!usedTypeDirectiveReferences) { - usedTypeDirectiveReferences = {}; + usedTypeDirectiveReferences = createMap(); } for (const directive of typeReferenceDirectives) { if (!hasProperty(usedTypeDirectiveReferences, directive)) { diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index c8bd8072b24..1d62a4a4f46 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -24,7 +24,7 @@ namespace ts { Return = 1 << 3 } - const entities: Map = { + const entities: MapLike = { "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -489,13 +489,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function setLabeledJump(state: ConvertedLoopState, isBreak: boolean, labelText: string, labelMarker: string): void { if (isBreak) { if (!state.labeledNonLocalBreaks) { - state.labeledNonLocalBreaks = {}; + state.labeledNonLocalBreaks = createMap(); } state.labeledNonLocalBreaks[labelText] = labelMarker; } else { if (!state.labeledNonLocalContinues) { - state.labeledNonLocalContinues = {}; + state.labeledNonLocalContinues = createMap(); } state.labeledNonLocalContinues[labelText] = labelMarker; } @@ -531,7 +531,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge let currentText: string; let currentLineMap: number[]; let currentFileIdentifiers: Map; - let renamedDependencies: Map; + let renamedDependencies: MapLike; let isEs6Module: boolean; let isCurrentFileExternalModule: boolean; @@ -577,7 +577,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge const setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer: SourceMapWriter) { }; - const moduleEmitDelegates: Map<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = { + const moduleEmitDelegates: MapLike<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = { [ModuleKind.ES6]: emitES6Module, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, @@ -585,7 +585,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge [ModuleKind.CommonJS]: emitCommonJSModule, }; - const bundleEmitDelegates: Map<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = { + const bundleEmitDelegates: MapLike<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = { [ModuleKind.ES6]() {}, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, @@ -597,7 +597,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function doEmit(jsFilePath: string, sourceMapFilePath: string, sourceFiles: SourceFile[], isBundledEmit: boolean) { sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); - generatedNameSet = {}; + generatedNameSet = createMap(); nodeToGeneratedName = []; decoratedClassAliases = []; isOwnFileEmit = !isBundledEmit; @@ -3257,7 +3257,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge // Don't initialize seen unless we have at least one element. // Emit a comma to separate for all but the first element. if (!seen) { - seen = {}; + seen = createMap(); } else { write(", "); @@ -3856,7 +3856,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge if (convertedLoopState) { if (!convertedLoopState.labels) { - convertedLoopState.labels = {}; + convertedLoopState.labels = createMap(); } convertedLoopState.labels[node.label.text] = node.label.text; } @@ -6803,7 +6803,7 @@ const _super = (function (geti, seti) { function collectExternalModuleInfo(sourceFile: SourceFile) { externalImports = []; - exportSpecifiers = {}; + exportSpecifiers = createMap(); exportEquals = undefined; hasExportStarsToExportValues = false; for (const node of sourceFile.statements) { @@ -7081,7 +7081,7 @@ const _super = (function (geti, seti) { if (hoistedVars) { writeLine(); write("var "); - const seen: Map = {}; + const seen = createMap(); for (let i = 0; i < hoistedVars.length; i++) { const local = hoistedVars[i]; const name = local.kind === SyntaxKind.Identifier @@ -7447,7 +7447,7 @@ const _super = (function (geti, seti) { writeModuleName(node, emitRelativePathAsModuleName); write("["); - const groupIndices: Map = {}; + const groupIndices = createMap(); const dependencyGroups: DependencyGroup[] = []; for (let i = 0; i < externalImports.length; i++) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 014d0926213..6f38783d5ed 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -595,7 +595,7 @@ namespace ts { parseDiagnostics = []; parsingContext = 0; - identifiers = {}; + identifiers = createMap(); identifierCount = 0; nodeCount = 0; @@ -1084,7 +1084,7 @@ namespace ts { function internIdentifier(text: string): string { text = escapeIdentifier(text); - return hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); + return identifiers[text] || (identifiers[text] = text); } // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index 89db876ae5e..e496353fde8 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -10,8 +10,8 @@ namespace ts.performance { /** Performance measurements for the compiler. */ declare const onProfilerEvent: { (markName: string): void; profiler: boolean; }; let profilerEvent: (markName: string) => void; - let counters: Map; - let measures: Map; + let counters: MapLike; + let measures: MapLike; /** * Emit a performance event if ts-profiler is connected. This is primarily used diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 7d40b2f3219..c26e748da9a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -846,7 +846,7 @@ namespace ts { } export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { - const existingDirectories: Map = {}; + const existingDirectories = createMap(); function getCanonicalFileName(fileName: string): string { // if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form. @@ -899,7 +899,7 @@ namespace ts { function writeFileIfUpdated(fileName: string, data: string, writeByteOrderMark: boolean): void { if (!outputFingerprints) { - outputFingerprints = {}; + outputFingerprints = createMap(); } const hash = sys.createHash(data); @@ -1040,7 +1040,7 @@ namespace ts { return []; } const resolutions: T[] = []; - const cache: Map = {}; + const cache = createMap(); for (const name of names) { let result: T; if (hasProperty(cache, name)) { @@ -1095,7 +1095,7 @@ namespace ts { let noDiagnosticsTypeChecker: TypeChecker; let classifiableNames: Map; - let resolvedTypeReferenceDirectives: Map = {}; + let resolvedTypeReferenceDirectives = createMap(); let fileProcessingDiagnostics = createDiagnosticCollection(); // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules. @@ -1110,10 +1110,10 @@ namespace ts { // If a module has some of its imports skipped due to being at the depth limit under node_modules, then track // this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed. - const modulesWithElidedImports: Map = {}; + const modulesWithElidedImports = createMap(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. - const sourceFilesFoundSearchingNodeModules: Map = {}; + const sourceFilesFoundSearchingNodeModules = createMap(); const start = performance.mark(); @@ -1241,7 +1241,7 @@ namespace ts { if (!classifiableNames) { // Initialize a checker so that all our files are bound. getTypeChecker(); - classifiableNames = {}; + classifiableNames = createMap(); for (const sourceFile of files) { copyMap(sourceFile.classifiableNames, classifiableNames); @@ -2082,7 +2082,7 @@ namespace ts { function processImportedModules(file: SourceFile, basePath: string) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { - file.resolvedModules = {}; + file.resolvedModules = createMap(); const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory)); for (let i = 0; i < moduleNames.length; i++) { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 6dd84298008..134dc489b2a 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -55,7 +55,7 @@ namespace ts { tryScan(callback: () => T): T; } - const textToToken: Map = { + const textToToken: MapLike = { "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, @@ -271,7 +271,7 @@ namespace ts { lookupInUnicodeMap(code, unicodeES3IdentifierPart); } - function makeReverseMap(source: Map): string[] { + function makeReverseMap(source: MapLike): string[] { const result: string[] = []; for (const name in source) { if (source.hasOwnProperty(name)) { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 29ae2c60af1..350d75429b7 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -233,15 +233,15 @@ namespace ts { const useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { - const dirWatchers: Map = {}; + const dirWatchers = createMap(); // One file can have multiple watchers - const fileWatcherCallbacks: Map = {}; + const fileWatcherCallbacks = createMap(); return { addFile, removeFile }; function reduceDirWatcherRefCountForFile(fileName: string) { const dirName = getDirectoryPath(fileName); - if (hasProperty(dirWatchers, dirName)) { - const watcher = dirWatchers[dirName]; + const watcher = dirWatchers[dirName]; + if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); @@ -251,13 +251,12 @@ namespace ts { } function addDirWatcher(dirPath: string): void { - if (hasProperty(dirWatchers, dirPath)) { - const watcher = dirWatchers[dirPath]; + let watcher = dirWatchers[dirPath]; + if (watcher) { watcher.referenceCount += 1; return; } - - const watcher: DirectoryWatcher = _fs.watch( + watcher = _fs.watch( dirPath, { persistent: true }, (eventName: string, relativeFileName: string) => fileEventHandler(eventName, relativeFileName, dirPath) @@ -268,12 +267,7 @@ namespace ts { } function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void { - if (hasProperty(fileWatcherCallbacks, filePath)) { - fileWatcherCallbacks[filePath].push(callback); - } - else { - fileWatcherCallbacks[filePath] = [callback]; - } + (fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback); } function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { @@ -289,8 +283,9 @@ namespace ts { } function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) { - if (hasProperty(fileWatcherCallbacks, filePath)) { - const newCallbacks = copyListRemovingItem(callback, fileWatcherCallbacks[filePath]); + const callbacks = fileWatcherCallbacks[filePath]; + if (callbacks) { + const newCallbacks = copyListRemovingItem(callback, callbacks); if (newCallbacks.length === 0) { delete fileWatcherCallbacks[filePath]; } @@ -306,7 +301,7 @@ namespace ts { ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && hasProperty(fileWatcherCallbacks, fileName)) { + if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { for (const fileCallback of fileWatcherCallbacks[fileName]) { fileCallback(fileName); } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 10538d0c009..3b588edd101 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -122,7 +122,7 @@ namespace ts { const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; - const categoryFormatMap: Map = { + const categoryFormatMap: MapLike = { [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, [DiagnosticCategory.Error]: redForegroundEscapeSequence, [DiagnosticCategory.Message]: blueForegroundEscapeSequence, @@ -432,7 +432,7 @@ namespace ts { } // reset the cache of existing files - cachedExistingFiles = {}; + cachedExistingFiles = createMap(); const compileResult = compile(rootFileNames, compilerOptions, compilerHost); @@ -676,7 +676,7 @@ namespace ts { const usageColumn: string[] = []; // Things like "-d, --declaration" go in here. const descriptionColumn: string[] = []; - const optionsDescriptionMap: Map = {}; // Map between option.description and list of option.type if it is a kind + const optionsDescriptionMap = createMap(); // Map between option.description and list of option.type if it is a kind for (let i = 0; i < optsList.length; i++) { const option = optsList[i]; @@ -786,7 +786,7 @@ namespace ts { return; function serializeCompilerOptions(options: CompilerOptions): Map { - const result: Map = {}; + const result = createMap(); const optionsNameMap = getOptionNameMap().optionNameMap; for (const name in options) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a6e860450c6..dad60775baf 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,9 +1,13 @@ - namespace ts { - export interface Map { + + export interface MapLike { [index: string]: T; } + export interface Map extends MapLike { + __mapBrand: any; + } + // branded string type used to store absolute, normalized and canonicalized paths // arbitrary file name can be converted to Path via toPath function export type Path = string & { __pathBrand: any }; @@ -1640,7 +1644,7 @@ namespace ts { // this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling) /* @internal */ - renamedDependencies?: Map; + renamedDependencies?: MapLike; /** * lib.d.ts should have a reference comment like @@ -2172,9 +2176,7 @@ namespace ts { /* @internal */ export interface TransientSymbol extends Symbol, SymbolLinks { } - export interface SymbolTable { - [index: string]: Symbol; - } + export type SymbolTable = Map; /** Represents a "prefix*suffix" pattern. */ /* @internal */ @@ -2557,7 +2559,7 @@ namespace ts { } export type RootPaths = string[]; - export type PathSubstitutions = Map; + export type PathSubstitutions = MapLike; export type TsConfigOnlyOptions = RootPaths | PathSubstitutions; export type CompilerOptionsValue = string | number | boolean | (string | number)[] | TsConfigOnlyOptions; @@ -2717,7 +2719,7 @@ namespace ts { fileNames: string[]; raw?: any; errors: Diagnostic[]; - wildcardDirectories?: Map; + wildcardDirectories?: MapLike; } export const enum WatchDirectoryFlags { @@ -2727,13 +2729,13 @@ namespace ts { export interface ExpandResult { fileNames: string[]; - wildcardDirectories: Map; + wildcardDirectories: MapLike; } /* @internal */ export interface CommandLineOptionBase { name: string; - type: "string" | "number" | "boolean" | "object" | "list" | Map; // a value of a primitive type, or an object literal mapping named values to actual values + type: "string" | "number" | "boolean" | "object" | "list" | MapLike; // a value of a primitive type, or an object literal mapping named values to actual values isFilePath?: boolean; // True if option value is a path or fileName shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does @@ -2749,7 +2751,7 @@ namespace ts { /* @internal */ export interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: Map; // an object literal mapping named values to actual values + type: MapLike; // an object literal mapping named values to actual values } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 2cfaf1f5cfb..e0b3700c6f1 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -87,14 +87,14 @@ namespace ts { return node.end - node.pos; } - export function mapIsEqualTo(map1: Map, map2: Map): boolean { + export function mapIsEqualTo(map1: MapLike, map2: MapLike): boolean { if (!map1 || !map2) { return map1 === map2; } return containsAll(map1, map2) && containsAll(map2, map1); } - function containsAll(map: Map, other: Map): boolean { + function containsAll(map: MapLike, other: MapLike): boolean { for (const key in map) { if (!hasProperty(map, key)) { continue; @@ -126,7 +126,7 @@ namespace ts { } export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean { - return sourceFile.resolvedModules && hasProperty(sourceFile.resolvedModules, moduleNameText); + return !!(sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); } export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule { @@ -135,7 +135,7 @@ namespace ts { export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void { if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = {}; + sourceFile.resolvedModules = createMap(); } sourceFile.resolvedModules[moduleNameText] = resolvedModule; @@ -143,7 +143,7 @@ namespace ts { export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = {}; + sourceFile.resolvedTypeReferenceDirectiveNames = createMap(); } sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; @@ -166,7 +166,7 @@ namespace ts { } for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; - const oldResolution = oldResolutions && hasProperty(oldResolutions, names[i]) ? oldResolutions[names[i]] : undefined; + const oldResolution = oldResolutions && oldResolutions[names[i]]; const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) @@ -1966,7 +1966,7 @@ namespace ts { export function createDiagnosticCollection(): DiagnosticCollection { let nonFileDiagnostics: Diagnostic[] = []; - const fileDiagnostics: Map = {}; + const fileDiagnostics = createMap(); let diagnosticsModified = false; let modificationCount = 0; @@ -1984,12 +1984,11 @@ namespace ts { } function reattachFileDiagnostics(newFile: SourceFile): void { - if (!hasProperty(fileDiagnostics, newFile.fileName)) { - return; - } - - for (const diagnostic of fileDiagnostics[newFile.fileName]) { - diagnostic.file = newFile; + const diagnostics = fileDiagnostics[newFile.fileName]; + if (diagnostics) { + for (const diagnostic of diagnostics) { + diagnostic.file = newFile; + } } } @@ -2030,9 +2029,7 @@ namespace ts { forEach(nonFileDiagnostics, pushDiagnostic); for (const key in fileDiagnostics) { - if (hasProperty(fileDiagnostics, key)) { - forEach(fileDiagnostics[key], pushDiagnostic); - } + forEach(fileDiagnostics[key], pushDiagnostic); } return sortAndDeduplicateDiagnostics(allDiagnostics); @@ -2047,9 +2044,7 @@ namespace ts { nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics); for (const key in fileDiagnostics) { - if (hasProperty(fileDiagnostics, key)) { - fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]); } } } @@ -2060,7 +2055,7 @@ namespace ts { // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. const escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - const escapedCharsMap: Map = { + const escapedCharsMap: MapLike = { "\0": "\\0", "\t": "\\t", "\v": "\\v", diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index ecdc18394b0..5d4bdf7db32 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -291,8 +291,8 @@ class CompilerBaselineRunner extends RunnerBase { const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true); - const fullResults: ts.Map = {}; - const pullResults: ts.Map = {}; + const fullResults: ts.MapLike = {}; + const pullResults: ts.MapLike = {}; for (const sourceFile of allFiles) { fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); @@ -338,7 +338,7 @@ class CompilerBaselineRunner extends RunnerBase { } } - function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { + function generateBaseLine(typeWriterResults: ts.MapLike, isSymbolBaseline: boolean): string { const typeLines: string[] = []; const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a42abbbc609..fed7751eb4a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -95,7 +95,7 @@ namespace FourSlash { export import IndentStyle = ts.IndentStyle; - const entityMap: ts.Map = { + const entityMap: ts.MapLike = { "&": "&", "\"": """, "'": "'", @@ -204,7 +204,7 @@ namespace FourSlash { public formatCodeOptions: ts.FormatCodeOptions; - private inputFiles: ts.Map = {}; // Map between inputFile's fileName and its content for easily looking up when resolving references + private inputFiles: ts.MapLike = {}; // Map between inputFile's fileName and its content for easily looking up when resolving references // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified @@ -593,7 +593,7 @@ namespace FourSlash { public noItemsWithSameNameButDifferentKind(): void { const completions = this.getCompletionListAtCaret(); - const uniqueItems: ts.Map = {}; + const uniqueItems: ts.MapLike = {}; for (const item of completions.entries) { if (!ts.hasProperty(uniqueItems, item.name)) { uniqueItems[item.name] = item.kind; @@ -1638,8 +1638,8 @@ namespace FourSlash { return this.testData.ranges; } - public rangesByText(): ts.Map { - const result: ts.Map = {}; + public rangesByText(): ts.MapLike { + const result: ts.MapLike = {}; for (const range of this.getRanges()) { const text = this.rangeText(range); (ts.getProperty(result, text) || (result[text] = [])).push(range); @@ -1897,7 +1897,7 @@ namespace FourSlash { public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) { - const openBraceMap: ts.Map = { + const openBraceMap: ts.MapLike = { "(": ts.CharacterCodes.openParen, "{": ts.CharacterCodes.openBrace, "[": ts.CharacterCodes.openBracket, @@ -2772,7 +2772,7 @@ namespace FourSlashInterface { return this.state.getRanges(); } - public rangesByText(): ts.Map { + public rangesByText(): ts.MapLike { return this.state.rangesByText(); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index e8e0a11f615..5ae33303d55 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -848,7 +848,7 @@ namespace Harness { export const defaultLibFileName = "lib.d.ts"; export const es2015DefaultLibFileName = "lib.es2015.d.ts"; - const libFileNameSourceFileMap: ts.Map = { + const libFileNameSourceFileMap: ts.MapLike = { [defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest) }; @@ -1002,7 +1002,7 @@ namespace Harness { { name: "symlink", type: "string" } ]; - let optionsIndex: ts.Map; + let optionsIndex: ts.MapLike; function getCommandLineOption(name: string): ts.CommandLineOption { if (!optionsIndex) { optionsIndex = {}; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index d7ed04b627f..4f95f19e144 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -123,7 +123,7 @@ namespace Harness.LanguageService { } export class LanguageServiceAdapterHost { - protected fileNameToScript: ts.Map = {}; + protected fileNameToScript: ts.MapLike = {}; constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, protected settings = ts.getDefaultCompilerOptions()) { @@ -235,7 +235,7 @@ namespace Harness.LanguageService { this.getModuleResolutionsForFile = (fileName) => { const scriptInfo = this.getScriptInfo(fileName); const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true); - const imports: ts.Map = {}; + const imports: ts.MapLike = {}; for (const module of preprocessInfo.importedFiles) { const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); if (resolutionInfo.resolvedModule) { @@ -248,7 +248,7 @@ namespace Harness.LanguageService { const scriptInfo = this.getScriptInfo(fileName); if (scriptInfo) { const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false); - const resolutions: ts.Map = {}; + const resolutions: ts.MapLike = {}; const settings = this.nativeHost.getCompilationSettings(); for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) { const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost); diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 038b2dbe359..be3030a6dd6 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -253,7 +253,7 @@ class ProjectRunner extends RunnerBase { moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future }; // Set the values specified using json - const optionNameMap: ts.Map = {}; + const optionNameMap: ts.MapLike = {}; ts.forEach(ts.optionDeclarations, option => { optionNameMap[option.name] = option; }); diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index e0ce09391fb..a1e010b97df 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -6,8 +6,8 @@ namespace ts { content: string; } - function createDefaultServerHost(fileMap: Map): server.ServerHost { - const existingDirectories: Map = {}; + function createDefaultServerHost(fileMap: MapLike): server.ServerHost { + const existingDirectories: MapLike = {}; forEachValue(fileMap, v => { let dir = getDirectoryPath(v.name); let previous: string; @@ -193,7 +193,7 @@ namespace ts { content: `export var y = 1` }; - const fileMap: Map = { [root.name]: root }; + const fileMap: MapLike = { [root.name]: root }; const serverHost = createDefaultServerHost(fileMap); const originalFileExists = serverHost.fileExists; diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 5f63889b084..4b5ef9f24f1 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -10,7 +10,7 @@ namespace ts { const map = arrayToMap(files, f => f.name); if (hasDirectoryExists) { - const directories: Map = {}; + const directories: MapLike = {}; for (const f of files) { let name = getDirectoryPath(f.name); while (true) { @@ -282,7 +282,7 @@ namespace ts { }); describe("Module resolution - relative imports", () => { - function test(files: Map, currentDirectory: string, rootFiles: string[], expectedFilesCount: number, relativeNamesToCheck: string[]) { + function test(files: MapLike, currentDirectory: string, rootFiles: string[], expectedFilesCount: number, relativeNamesToCheck: string[]) { const options: CompilerOptions = { module: ModuleKind.CommonJS }; const host: CompilerHost = { getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { @@ -318,7 +318,7 @@ namespace ts { } it("should find all modules", () => { - const files: Map = { + const files: MapLike = { "/a/b/c/first/shared.ts": ` class A {} export = A`, @@ -337,7 +337,7 @@ export = C; }); it("should find modules in node_modules", () => { - const files: Map = { + const files: MapLike = { "/parent/node_modules/mod/index.d.ts": "export var x", "/parent/app/myapp.ts": `import {x} from "mod"` }; @@ -345,7 +345,7 @@ export = C; }); it("should find file referenced via absolute and relative names", () => { - const files: Map = { + const files: MapLike = { "/a/b/c.ts": `/// `, "/a/b/b.ts": "var x" }; @@ -355,10 +355,10 @@ export = C; describe("Files with different casing", () => { const library = createSourceFile("lib.d.ts", "", ScriptTarget.ES5); - function test(files: Map, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { + function test(files: MapLike, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); if (!useCaseSensitiveFileNames) { - const f: Map = {}; + const f: MapLike = {}; for (const fileName in files) { f[getCanonicalFileName(fileName)] = files[fileName]; } @@ -395,7 +395,7 @@ export = C; } it("should succeed when the same file is referenced using absolute and relative names", () => { - const files: Map = { + const files: MapLike = { "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" }; @@ -403,7 +403,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (tripleslash references)", () => { - const files: Map = { + const files: MapLike = { "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" }; @@ -411,7 +411,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (imports)", () => { - const files: Map = { + const files: MapLike = { "/a/b/c.ts": `import {x} from "D"`, "/a/b/d.ts": "export var x" }; @@ -419,7 +419,7 @@ export = C; }); it("should fail when two files used in program differ only in casing (imports, relative module names)", () => { - const files: Map = { + const files: MapLike = { "moduleA.ts": `import {x} from "./ModuleB"`, "moduleB.ts": "export var x" }; @@ -427,7 +427,7 @@ export = C; }); it("should fail when two files exist on disk that differs only in casing", () => { - const files: Map = { + const files: MapLike = { "/a/b/c.ts": `import {x} from "D"`, "/a/b/D.ts": "export var x", "/a/b/d.ts": "export var y" @@ -436,7 +436,7 @@ export = C; }); it("should fail when module name in 'require' calls has inconsistent casing", () => { - const files: Map = { + const files: MapLike = { "moduleA.ts": `import a = require("./ModuleC")`, "moduleB.ts": `import a = require("./moduleC")`, "moduleC.ts": "export var x" @@ -445,7 +445,7 @@ export = C; }); it("should fail when module names in 'require' calls has inconsistent casing and current directory has uppercase chars", () => { - const files: Map = { + const files: MapLike = { "/a/B/c/moduleA.ts": `import a = require("./ModuleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", @@ -457,7 +457,7 @@ import b = require("./moduleB.ts"); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], [1149]); }); it("should not fail when module names in 'require' calls has consistent casing and current directory has uppercase chars", () => { - const files: Map = { + const files: MapLike = { "/a/B/c/moduleA.ts": `import a = require("./moduleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 8b2b15c15b3..76015667232 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -96,7 +96,7 @@ namespace ts { } function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget): CompilerHost { - const files: Map = {}; + const files: MapLike = {}; for (const t of texts) { const file = createSourceFile(t.name, t.text.getFullText(), target); file.sourceText = t.text; @@ -152,7 +152,7 @@ namespace ts { return program; } - function getSizeOfMap(map: Map): number { + function getSizeOfMap(map: MapLike): number { let size = 0; for (const id in map) { if (hasProperty(map, id)) { @@ -174,7 +174,7 @@ namespace ts { assert.isTrue(expected.primary === actual.primary, `'primary': expected '${expected.primary}' to be equal to '${actual.primary}'`); } - function checkCache(caption: string, program: Program, fileName: string, expectedContent: Map, getCache: (f: SourceFile) => Map, entryChecker: (expected: T, original: T) => void): void { + function checkCache(caption: string, program: Program, fileName: string, expectedContent: MapLike, getCache: (f: SourceFile) => MapLike, entryChecker: (expected: T, original: T) => void): void { const file = program.getSourceFile(fileName); assert.isTrue(file !== undefined, `cannot find file ${fileName}`); const cache = getCache(file); @@ -203,11 +203,11 @@ namespace ts { } } - function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { + function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: MapLike): void { checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, checkResolvedModule); } - function checkResolvedTypeDirectivesCache(program: Program, fileName: string, expectedContent: Map): void { + function checkResolvedTypeDirectivesCache(program: Program, fileName: string, expectedContent: MapLike): void { checkCache("resolved type directives", program, fileName, expectedContent, f => f.resolvedTypeReferenceDirectiveNames, checkResolvedTypeDirective); } diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index c5285544329..8e7faa94a7a 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -362,8 +362,8 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks: ts.Map<(resp: protocol.Response) => void> = {}; - private eventHandlers: ts.Map<(args: any) => void> = {}; + private callbacks: ts.MapLike<(resp: protocol.Response) => void> = {}; + private eventHandlers: ts.MapLike<(args: any) => void> = {}; handle(msg: protocol.Message): void { if (msg.type === "response") { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 7a375c50b8a..74b9e303cf7 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -68,7 +68,7 @@ namespace ts { return entry; } - function sizeOfMap(map: Map): number { + function sizeOfMap(map: MapLike): number { let n = 0; for (const name in map) { if (hasProperty(map, name)) { @@ -78,7 +78,7 @@ namespace ts { return n; } - function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { + function checkMapKeys(caption: string, map: MapLike, expectedKeys: string[]) { assert.equal(sizeOfMap(map), expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { assert.isTrue(hasProperty(map, name), `${caption} is expected to contain ${name}, actual keys: ${getKeys(map)}`); @@ -126,8 +126,8 @@ namespace ts { private getCanonicalFileName: (s: string) => string; private toPath: (f: string) => Path; private callbackQueue: TimeOutCallback[] = []; - readonly watchedDirectories: Map<{ cb: DirectoryWatcherCallback, recursive: boolean }[]> = {}; - readonly watchedFiles: Map = {}; + readonly watchedDirectories: MapLike<{ cb: DirectoryWatcherCallback, recursive: boolean }[]> = {}; + readonly watchedFiles: MapLike = {}; constructor(public useCaseSensitiveFileNames: boolean, private executingFilePath: string, private currentDirectory: string, fileOrFolderList: FileOrFolder[]) { this.getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); diff --git a/src/server/client.ts b/src/server/client.ts index f04dbd8dc02..3547ac52602 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -21,7 +21,7 @@ namespace ts.server { export class SessionClient implements LanguageService { private sequence: number = 0; - private lineMaps: ts.Map = {}; + private lineMaps: ts.Map = ts.createMap(); private messages: string[] = []; private lastRenameEntry: RenameEntry; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6e9adad7f47..a14c42f471e 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -130,7 +130,7 @@ namespace ts.server { const path = toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); const currentResolutionsInFile = cache.get(path); - const newResolutions: Map = {}; + const newResolutions = createMap(); const resolvedModules: R[] = []; const compilerOptions = this.getCompilationSettings(); @@ -378,7 +378,7 @@ namespace ts.server { export interface ProjectOptions { // these fields can be present in the project file files?: string[]; - wildcardDirectories?: ts.Map; + wildcardDirectories?: ts.MapLike; compilerOptions?: ts.CompilerOptions; } @@ -391,7 +391,7 @@ namespace ts.server { // Used to keep track of what directories are watched for this project directoriesWatchedForTsconfig: string[] = []; program: ts.Program; - filenameToSourceFile: ts.Map = {}; + filenameToSourceFile = ts.createMap(); updateGraphSeq = 0; /** Used for configured projects which may have multiple open roots */ openRefCount = 0; @@ -504,7 +504,7 @@ namespace ts.server { return; } - this.filenameToSourceFile = {}; + this.filenameToSourceFile = createMap(); const sourceFiles = this.program.getSourceFiles(); for (let i = 0, len = sourceFiles.length; i < len; i++) { const normFilename = ts.normalizePath(sourceFiles[i].fileName); @@ -613,7 +613,7 @@ namespace ts.server { } export class ProjectService { - filenameToScriptInfo: ts.Map = {}; + filenameToScriptInfo = ts.createMap(); // open, non-configured root files openFileRoots: ScriptInfo[] = []; // projects built from openFileRoots @@ -625,12 +625,12 @@ namespace ts.server { // open files that are roots of a configured project openFileRootsConfigured: ScriptInfo[] = []; // a path to directory watcher map that detects added tsconfig files - directoryWatchersForTsconfig: ts.Map = {}; + directoryWatchersForTsconfig = ts.createMap(); // count of how many projects are using the directory watcher. If the // number becomes 0 for a watcher, then we should close it. - directoryWatchersRefCount: ts.Map = {}; + directoryWatchersRefCount = ts.createMap(); hostConfiguration: HostConfiguration; - timerForDetectingProjectFileListChanges: Map = {}; + timerForDetectingProjectFileListChanges = createMap(); constructor(public host: ServerHost, public psLogger: Logger, public eventHandler?: ProjectServiceEventHandler) { // ts.disableIncrementalParsing = true; diff --git a/src/server/session.ts b/src/server/session.ts index 7e1ca81e2af..13b0e6d6ce4 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1061,7 +1061,7 @@ namespace ts.server { return { response, responseRequired: true }; } - private handlers: Map<(request: protocol.Request) => { response?: any, responseRequired?: boolean }> = { + private handlers: MapLike<(request: protocol.Request) => { response?: any, responseRequired?: boolean }> = { [CommandNames.Exit]: () => { this.exit(); return { responseRequired: false }; diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 3b013a4a924..05de0061d39 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -47,7 +47,7 @@ namespace ts.JsTyping { { cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } { // A typing name to typing file path mapping - const inferredTypings: Map = {}; + const inferredTypings = createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; @@ -62,7 +62,7 @@ namespace ts.JsTyping { safeList = result.config; } else { - safeList = {}; + safeList = createMap(); }; } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index f105a9fa6e2..ebd6936ea85 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -234,7 +234,7 @@ namespace ts.NavigationBar { /** Merge declarations of the same kind. */ function mergeChildren(children: NavigationBarNode[]): void { - const nameToItems: Map = {}; + const nameToItems = createMap(); filterMutate(children, child => { const decl = child.node; const name = decl.name && nodeText(decl.name); diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index 3d20337eca7..cff3f591f8a 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -113,7 +113,7 @@ namespace ts { // we see the name of a module that is used everywhere, or the name of an overload). As // such, we cache the information we compute about the candidate for the life of this // pattern matcher so we don't have to compute it multiple times. - const stringToWordSpans: Map = {}; + const stringToWordSpans = createMap(); pattern = pattern.trim(); diff --git a/src/services/services.ts b/src/services/services.ts index aea4d5f872e..850e29030d8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -975,7 +975,7 @@ namespace ts { } private computeNamedDeclarations(): Map { - const result: Map = {}; + const result = createMap(); forEachChild(this, visit); @@ -2025,7 +2025,7 @@ namespace ts { fileName?: string; reportDiagnostics?: boolean; moduleName?: string; - renamedDependencies?: Map; + renamedDependencies?: MapLike; } export interface TranspileOutput { @@ -2243,7 +2243,7 @@ namespace ts { export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory = ""): DocumentRegistry { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. - const buckets: Map> = {}; + const buckets = createMap>(); const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey { @@ -4102,7 +4102,7 @@ namespace ts { * do not occur at the current position and have not otherwise been typed. */ function filterNamedImportOrExportCompletionItems(exportsOfModule: Symbol[], namedImportsOrExports: ImportOrExportSpecifier[]): Symbol[] { - const existingImportsOrExports: Map = {}; + const existingImportsOrExports = createMap(); for (const element of namedImportsOrExports) { // If this is the current item we are editing right now, do not filter it out @@ -4132,7 +4132,7 @@ namespace ts { return contextualMemberSymbols; } - const existingMemberNames: Map = {}; + const existingMemberNames = createMap(); for (const m of existingMembers) { // Ignore omitted expressions for missing members if (m.kind !== SyntaxKind.PropertyAssignment && @@ -4175,7 +4175,7 @@ namespace ts { * do not occur at the current position and have not otherwise been typed. */ function filterJsxAttributes(symbols: Symbol[], attributes: NodeArray): Symbol[] { - const seenNames: Map = {}; + const seenNames = createMap(); for (const attr of attributes) { // If this is the current item we are editing right now, do not filter it out if (attr.getStart() <= position && position <= attr.getEnd()) { @@ -4317,7 +4317,7 @@ namespace ts { function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[], location: Node, performCharacterChecks: boolean): Map { const start = timestamp(); - const uniqueNames: Map = {}; + const uniqueNames = createMap(); if (symbols) { for (const symbol of symbols) { const entry = createCompletionEntry(symbol, location, performCharacterChecks); @@ -5318,7 +5318,7 @@ namespace ts { return undefined; } - const fileNameToDocumentHighlights: Map = {}; + const fileNameToDocumentHighlights = createMap(); const result: DocumentHighlights[] = []; for (const referencedSymbol of referencedSymbols) { for (const referenceEntry of referencedSymbol.references) { @@ -6713,7 +6713,7 @@ namespace ts { // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {}); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); } }); @@ -6834,7 +6834,7 @@ namespace ts { // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { const result: Symbol[] = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {}); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); } @@ -8318,7 +8318,7 @@ namespace ts { } function initializeNameTable(sourceFile: SourceFile): void { - const nameTable: Map = {}; + const nameTable = createMap(); walk(sourceFile); sourceFile.nameTable = nameTable; From cba2e1aacb6c8544629a4114fd4316d85fa1dcb3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 10 Aug 2016 16:47:35 -0700 Subject: [PATCH 125/508] Update API sample --- tests/baselines/reference/APISample_watcher.js | 2 +- tests/cases/compiler/APISample_watcher.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 7573f2ba99e..cb7fc3a4c5c 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -20,7 +20,7 @@ declare var path: any; import * as ts from "typescript"; function watch(rootFileNames: string[], options: ts.CompilerOptions) { - const files: ts.Map<{ version: number }> = {}; + const files: ts.MapLike<{ version: number }> = {}; // initialize the list of files rootFileNames.forEach(fileName => { diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index 34baa04c850..07922bd35c7 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -23,7 +23,7 @@ declare var path: any; import * as ts from "typescript"; function watch(rootFileNames: string[], options: ts.CompilerOptions) { - const files: ts.Map<{ version: number }> = {}; + const files: ts.MapLike<{ version: number }> = {}; // initialize the list of files rootFileNames.forEach(fileName => { From 3ff89f794f8707e9b4a8dd8219b6b5d1f8e43149 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 10 Aug 2016 17:28:52 -0700 Subject: [PATCH 126/508] Fix processDiagnosticMessages script --- scripts/processDiagnosticMessages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index 26632ba6bab..431cf460180 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -69,7 +69,7 @@ function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosti } function buildUniqueNameMap(names: string[]): ts.Map { - var nameMap: ts.Map = {}; + var nameMap = ts.createMap(); var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined); From fa991b51750d7b6951733bf521d0f18ef888fc9e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Wed, 10 Aug 2016 23:45:24 -0700 Subject: [PATCH 127/508] Have travis take shallow clones of the repo (#10275) Just cloning TS on travis takes 23 seconds on linux (68 seconds on mac), hopefully having it do a shallow clone will help. We don't rely on any tagging/artifacts from the travis servers which clone depth could impact, so this shouldn't impact anything other than build speed. --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 97c772f45ac..bfc07e2b510 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,3 +34,6 @@ install: cache: directories: - node_modules + +git: + depth: 1 From c9f62f33d4d87dbb4a40ba5a28bb1085c683def2 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 11 Aug 2016 09:53:38 -0700 Subject: [PATCH 128/508] Add folds to travis log (#10269) --- Gulpfile.ts | 3 +++ Jakefile.js | 27 +++++++++++++++++++++++++-- package.json | 3 ++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index b9b5d2068b2..d677b042250 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -35,6 +35,7 @@ import merge2 = require("merge2"); import intoStream = require("into-stream"); import * as os from "os"; import Linter = require("tslint"); +import fold = require("travis-fold"); const gulp = helpMaker(originalGulp); const mochaParallel = require("./scripts/mocha-parallel.js"); const {runTestsInParallel} = mochaParallel; @@ -964,6 +965,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: const fileMatcher = RegExp(cmdLineOptions["files"]); const lintOptions = getLinterOptions(); let failed = 0; + if (fold.isTravis()) console.log(fold.start("lint")); return gulp.src(lintTargets) .pipe(insert.transform((contents, file) => { if (!fileMatcher.test(file.path)) return contents; @@ -975,6 +977,7 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: return contents; // TODO (weswig): Automatically apply fixes? :3 })) .on("end", () => { + if (fold.isTravis()) console.log(fold.end("lint")); if (failed > 0) { console.error("Linter errors."); process.exit(1); diff --git a/Jakefile.js b/Jakefile.js index a5650a56b16..0624c92f162 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -5,6 +5,7 @@ var os = require("os"); var path = require("path"); var child_process = require("child_process"); var Linter = require("tslint"); +var fold = require("travis-fold"); var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel; // Variables @@ -560,9 +561,19 @@ compileFile( desc("Builds language service server library"); task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]); +desc("Emit the start of the build fold"); +task("build-fold-start", [] , function() { + if (fold.isTravis()) console.log(fold.start("build")); +}); + +desc("Emit the end of the build fold"); +task("build-fold-end", [] , function() { + if (fold.isTravis()) console.log(fold.end("build")); +}); + // Local target to build the compiler and services desc("Builds the full compiler and services"); -task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl"]); +task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]); // Local target to build only tsc.js desc("Builds only the compiler"); @@ -998,12 +1009,22 @@ var tslintRulesOutFiles = tslintRules.map(function(p) { return path.join(builtLocalDirectory, "tslint", p + ".js"); }); desc("Compiles tslint rules to js"); -task("build-rules", tslintRulesOutFiles); +task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"])); tslintRulesFiles.forEach(function(ruleFile, i) { compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint")}); }); +desc("Emit the start of the build-rules fold"); +task("build-rules-start", [] , function() { + if (fold.isTravis()) console.log(fold.start("build-rules")); +}); + +desc("Emit the end of the build-rules fold"); +task("build-rules-end", [] , function() { + if (fold.isTravis()) console.log(fold.end("build-rules")); +}); + function getLinterOptions() { return { configuration: require("./tslint.json"), @@ -1047,6 +1068,7 @@ var lintTargets = compilerSources desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex"); task("lint", ["build-rules"], function() { + if (fold.isTravis()) console.log(fold.start("lint")); var lintOptions = getLinterOptions(); var failed = 0; var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || ""); @@ -1062,6 +1084,7 @@ task("lint", ["build-rules"], function() { done[target] = true; } } + if (fold.isTravis()) console.log(fold.end("lint")); if (failed > 0) { fail('Linter errors.', failed); } diff --git a/package.json b/package.json index 9f3122c3374..25d8f0c42ea 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ }, "devDependencies": { "@types/browserify": "latest", - "@types/convert-source-map": "latest", "@types/chai": "latest", + "@types/convert-source-map": "latest", "@types/del": "latest", "@types/glob": "latest", "@types/gulp": "latest", @@ -72,6 +72,7 @@ "run-sequence": "latest", "sorcery": "latest", "through2": "latest", + "travis-fold": "latest", "ts-node": "latest", "tslint": "next", "typescript": "next" From 24d8d848f1b85b627482e8a56e50f398b1520cfd Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Aug 2016 10:23:27 -0700 Subject: [PATCH 129/508] Optimize filterType to only call getUnionType if necessary --- src/compiler/checker.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 43ec22df403..2ae238b9175 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8172,9 +8172,26 @@ namespace ts { } function filterType(type: Type, f: (t: Type) => boolean): Type { - return type.flags & TypeFlags.Union ? - getUnionType(filter((type).types, f)) : - f(type) ? type : neverType; + if (!(type.flags & TypeFlags.Union)) { + return f(type) ? type : neverType; + } + let types = (type).types; + let length = types.length; + let i = 0; + while (i < length && f(types[i])) i++; + if (i === length) { + return type; + } + let filtered = types.slice(0, i); + i++; + while (i < length) { + const t = types[i]; + if (f(t)) { + filtered.push(t); + } + i++; + } + return getUnionType(filtered); } function isIncomplete(flowType: FlowType) { From 9ac13abfd196f662ce606d8d99cb8791c2ad61fe Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 11 Aug 2016 11:58:23 -0700 Subject: [PATCH 130/508] Add shorthand types declaration for travis-fold (#10293) --- scripts/types/ambient.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/types/ambient.d.ts b/scripts/types/ambient.d.ts index e77e3fe8c5a..e83489801d7 100644 --- a/scripts/types/ambient.d.ts +++ b/scripts/types/ambient.d.ts @@ -22,3 +22,4 @@ declare module "into-stream" { } declare module "sorcery"; +declare module "travis-fold"; From a3845a95d56cd190fcc0a3fa359aaad37cbb4c74 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Aug 2016 13:44:51 -0700 Subject: [PATCH 131/508] Optimize getTypeWithFacts --- src/compiler/checker.ts | 49 +++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2ae238b9175..e4f650691d5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7924,6 +7924,14 @@ namespace ts { return result; } + function isFunctionObjectType(type: ObjectType): boolean { + // We do a quick check for a "bind" property before performing the more expensive subtype + // check. This gives us a quicker out in the common case where an object type is not a function. + const resolved = resolveStructuredTypeMembers(type); + return !!(resolved.callSignatures.length || resolved.constructSignatures.length || + hasProperty(resolved.members, "bind") && isTypeSubtypeOf(type, globalFunctionType)); + } + function getTypeFacts(type: Type): TypeFacts { const flags = type.flags; if (flags & TypeFlags.String) { @@ -7952,8 +7960,7 @@ namespace ts { type === falseType ? TypeFacts.FalseFacts : TypeFacts.TrueFacts; } if (flags & TypeFlags.ObjectType) { - const resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length || resolved.constructSignatures.length || isTypeSubtypeOf(type, globalFunctionType) ? + return isFunctionObjectType(type) ? strictNullChecks ? TypeFacts.FunctionStrictFacts : TypeFacts.FunctionFacts : strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; } @@ -7980,23 +7987,23 @@ namespace ts { if (!(type.flags & TypeFlags.Union)) { return getTypeFacts(type) & include ? type : neverType; } - let firstType: Type; - let types: Type[]; - for (const t of (type as UnionType).types) { - if (getTypeFacts(t) & include) { - if (!firstType) { - firstType = t; - } - else { - if (!types) { - types = [firstType]; - } - types.push(t); - } - } + const types = (type).types; + const length = types.length; + let i = 0; + while (i < length && getTypeFacts(types[i]) & include) i++; + if (i === length) { + return type; } - return types ? getUnionType(types) : - firstType ? firstType : neverType; + const filtered = types.slice(0, i); + i++; + while (i < length) { + const t = types[i]; + if (getTypeFacts(t) & include) { + filtered.push(t); + } + i++; + } + return getUnionType(filtered); } function getTypeWithDefault(type: Type, defaultExpression: Expression) { @@ -8175,14 +8182,14 @@ namespace ts { if (!(type.flags & TypeFlags.Union)) { return f(type) ? type : neverType; } - let types = (type).types; - let length = types.length; + const types = (type).types; + const length = types.length; let i = 0; while (i < length && f(types[i])) i++; if (i === length) { return type; } - let filtered = types.slice(0, i); + const filtered = types.slice(0, i); i++; while (i < length) { const t = types[i]; From c22a54fb9507d25ca0b81f1ff82de4b26154cb9a Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Aug 2016 13:46:06 -0700 Subject: [PATCH 132/508] Filter out nullable and primitive types in isDiscriminantProperty --- src/compiler/checker.ts | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e4f650691d5..0ba44b34f89 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -245,7 +245,8 @@ namespace ts { NEUndefinedOrNull = 1 << 19, // x != undefined / x != null Truthy = 1 << 20, // x Falsy = 1 << 21, // !x - All = (1 << 22) - 1, + Discriminatable = 1 << 22, // May have discriminant property + All = (1 << 23) - 1, // The following members encode facts about particular kinds of types for use in the getTypeFacts function. // The presence of a particular fact means that the given test is true for some (and possibly all) values // of that kind of type. @@ -275,9 +276,9 @@ namespace ts { TrueFacts = BaseBooleanFacts | Truthy, SymbolStrictFacts = TypeofEQSymbol | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNEObject | TypeofNEFunction | TypeofNEHostObject | NEUndefined | NENull | NEUndefinedOrNull | Truthy, SymbolFacts = SymbolStrictFacts | EQUndefined | EQNull | EQUndefinedOrNull | Falsy, - ObjectStrictFacts = TypeofEQObject | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | NEUndefined | NENull | NEUndefinedOrNull | Truthy, + ObjectStrictFacts = TypeofEQObject | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | NEUndefined | NENull | NEUndefinedOrNull | Truthy | Discriminatable, ObjectFacts = ObjectStrictFacts | EQUndefined | EQNull | EQUndefinedOrNull | Falsy, - FunctionStrictFacts = TypeofEQFunction | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | NEUndefined | NENull | NEUndefinedOrNull | Truthy, + FunctionStrictFacts = TypeofEQFunction | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | NEUndefined | NENull | NEUndefinedOrNull | Truthy | Discriminatable, FunctionFacts = FunctionStrictFacts | EQUndefined | EQNull | EQUndefinedOrNull | Falsy, UndefinedFacts = TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | TypeofNEFunction | TypeofNEHostObject | EQUndefined | EQUndefinedOrNull | NENull | Falsy, NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy, @@ -7848,18 +7849,25 @@ namespace ts { } function isDiscriminantProperty(type: Type, name: string) { - if (type) { - const nonNullType = getNonNullableType(type); - if (nonNullType.flags & TypeFlags.Union) { - const prop = getPropertyOfType(nonNullType, name); - if (prop && prop.flags & SymbolFlags.SyntheticProperty) { - if ((prop).isDiscriminantProperty === undefined) { - (prop).isDiscriminantProperty = !(prop).hasCommonType && - isUnitUnionType(getTypeOfSymbol(prop)); - } - return (prop).isDiscriminantProperty; + if (type && type.flags & TypeFlags.Union) { + let prop = getPropertyOfType(type, name); + if (!prop) { + // The type may be a union that includes nullable or primtive types. If filtering + // those out produces a different type, get the property from that type instead. + // Effectively, we're checking if this *could* be a discriminant property once nullable + // and primitive types are removed by other type guards. + const filteredType = getTypeWithFacts(type, TypeFacts.Discriminatable); + if (filteredType !== type && filteredType.flags & TypeFlags.Union) { + prop = getPropertyOfType(type, name); } } + if (prop && prop.flags & SymbolFlags.SyntheticProperty) { + if ((prop).isDiscriminantProperty === undefined) { + (prop).isDiscriminantProperty = !(prop).hasCommonType && + isUnitUnionType(getTypeOfSymbol(prop)); + } + return (prop).isDiscriminantProperty; + } } return false; } From b336c693eed9745efdabb0c7736a81080d481eb0 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Aug 2016 14:38:01 -0700 Subject: [PATCH 133/508] Fix typo --- 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 0ba44b34f89..b6d03737810 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7858,7 +7858,7 @@ namespace ts { // and primitive types are removed by other type guards. const filteredType = getTypeWithFacts(type, TypeFacts.Discriminatable); if (filteredType !== type && filteredType.flags & TypeFlags.Union) { - prop = getPropertyOfType(type, name); + prop = getPropertyOfType(filteredType, name); } } if (prop && prop.flags & SymbolFlags.SyntheticProperty) { From 29ae2b2cf153ef7d28a50053c85e637ea2d02915 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Aug 2016 14:38:17 -0700 Subject: [PATCH 134/508] Add regression tests --- .../reference/discriminantsAndPrimitives.js | 84 +++++++++++ .../discriminantsAndPrimitives.symbols | 117 +++++++++++++++ .../discriminantsAndPrimitives.types | 141 ++++++++++++++++++ .../compiler/discriminantsAndPrimitives.ts | 49 ++++++ 4 files changed, 391 insertions(+) create mode 100644 tests/baselines/reference/discriminantsAndPrimitives.js create mode 100644 tests/baselines/reference/discriminantsAndPrimitives.symbols create mode 100644 tests/baselines/reference/discriminantsAndPrimitives.types create mode 100644 tests/cases/compiler/discriminantsAndPrimitives.ts diff --git a/tests/baselines/reference/discriminantsAndPrimitives.js b/tests/baselines/reference/discriminantsAndPrimitives.js new file mode 100644 index 00000000000..1d11781a707 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndPrimitives.js @@ -0,0 +1,84 @@ +//// [discriminantsAndPrimitives.ts] + +// Repro from #10257 plus other tests + +interface Foo { + kind: "foo"; + name: string; +} + +interface Bar { + kind: "bar"; + length: string; +} + +function f1(x: Foo | Bar | string) { + if (typeof x !== 'string') { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f2(x: Foo | Bar | string | undefined) { + if (typeof x === "object") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f3(x: Foo | Bar | string | null) { + if (x && typeof x !== "string") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f4(x: Foo | Bar | string | number | null) { + if (x && typeof x === "object") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +//// [discriminantsAndPrimitives.js] +// Repro from #10257 plus other tests +function f1(x) { + if (typeof x !== 'string') { + switch (x.kind) { + case 'foo': + x.name; + } + } +} +function f2(x) { + if (typeof x === "object") { + switch (x.kind) { + case 'foo': + x.name; + } + } +} +function f3(x) { + if (x && typeof x !== "string") { + switch (x.kind) { + case 'foo': + x.name; + } + } +} +function f4(x) { + if (x && typeof x === "object") { + switch (x.kind) { + case 'foo': + x.name; + } + } +} diff --git a/tests/baselines/reference/discriminantsAndPrimitives.symbols b/tests/baselines/reference/discriminantsAndPrimitives.symbols new file mode 100644 index 00000000000..c84f32cd990 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndPrimitives.symbols @@ -0,0 +1,117 @@ +=== tests/cases/compiler/discriminantsAndPrimitives.ts === + +// Repro from #10257 plus other tests + +interface Foo { +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) + + kind: "foo"; +>kind : Symbol(Foo.kind, Decl(discriminantsAndPrimitives.ts, 3, 15)) + + name: string; +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +} + +interface Bar { +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + kind: "bar"; +>kind : Symbol(Bar.kind, Decl(discriminantsAndPrimitives.ts, 8, 15)) + + length: string; +>length : Symbol(Bar.length, Decl(discriminantsAndPrimitives.ts, 9, 16)) +} + +function f1(x: Foo | Bar | string) { +>f1 : Symbol(f1, Decl(discriminantsAndPrimitives.ts, 11, 1)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 13, 12)) +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + if (typeof x !== 'string') { +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 13, 12)) + + switch(x.kind) { +>x.kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 13, 12)) +>kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) + + case 'foo': + x.name; +>x.name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 13, 12)) +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) + } + } +} + +function f2(x: Foo | Bar | string | undefined) { +>f2 : Symbol(f2, Decl(discriminantsAndPrimitives.ts, 20, 1)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 22, 12)) +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + if (typeof x === "object") { +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 22, 12)) + + switch(x.kind) { +>x.kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 22, 12)) +>kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) + + case 'foo': + x.name; +>x.name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 22, 12)) +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) + } + } +} + +function f3(x: Foo | Bar | string | null) { +>f3 : Symbol(f3, Decl(discriminantsAndPrimitives.ts, 29, 1)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + if (x && typeof x !== "string") { +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) + + switch(x.kind) { +>x.kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) +>kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) + + case 'foo': + x.name; +>x.name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) + } + } +} + +function f4(x: Foo | Bar | string | number | null) { +>f4 : Symbol(f4, Decl(discriminantsAndPrimitives.ts, 38, 1)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + if (x && typeof x === "object") { +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) + + switch(x.kind) { +>x.kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) +>kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) + + case 'foo': + x.name; +>x.name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) + } + } +} diff --git a/tests/baselines/reference/discriminantsAndPrimitives.types b/tests/baselines/reference/discriminantsAndPrimitives.types new file mode 100644 index 00000000000..d3e1b70e599 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndPrimitives.types @@ -0,0 +1,141 @@ +=== tests/cases/compiler/discriminantsAndPrimitives.ts === + +// Repro from #10257 plus other tests + +interface Foo { +>Foo : Foo + + kind: "foo"; +>kind : "foo" + + name: string; +>name : string +} + +interface Bar { +>Bar : Bar + + kind: "bar"; +>kind : "bar" + + length: string; +>length : string +} + +function f1(x: Foo | Bar | string) { +>f1 : (x: string | Foo | Bar) => void +>x : string | Foo | Bar +>Foo : Foo +>Bar : Bar + + if (typeof x !== 'string') { +>typeof x !== 'string' : boolean +>typeof x : string +>x : string | Foo | Bar +>'string' : "string" + + switch(x.kind) { +>x.kind : "foo" | "bar" +>x : Foo | Bar +>kind : "foo" | "bar" + + case 'foo': +>'foo' : "foo" + + x.name; +>x.name : string +>x : Foo +>name : string + } + } +} + +function f2(x: Foo | Bar | string | undefined) { +>f2 : (x: string | Foo | Bar | undefined) => void +>x : string | Foo | Bar | undefined +>Foo : Foo +>Bar : Bar + + if (typeof x === "object") { +>typeof x === "object" : boolean +>typeof x : string +>x : string | Foo | Bar | undefined +>"object" : "object" + + switch(x.kind) { +>x.kind : "foo" | "bar" +>x : Foo | Bar +>kind : "foo" | "bar" + + case 'foo': +>'foo' : "foo" + + x.name; +>x.name : string +>x : Foo +>name : string + } + } +} + +function f3(x: Foo | Bar | string | null) { +>f3 : (x: string | Foo | Bar | null) => void +>x : string | Foo | Bar | null +>Foo : Foo +>Bar : Bar +>null : null + + if (x && typeof x !== "string") { +>x && typeof x !== "string" : boolean | "" | null +>x : string | Foo | Bar | null +>typeof x !== "string" : boolean +>typeof x : string +>x : string | Foo | Bar +>"string" : "string" + + switch(x.kind) { +>x.kind : "foo" | "bar" +>x : Foo | Bar +>kind : "foo" | "bar" + + case 'foo': +>'foo' : "foo" + + x.name; +>x.name : string +>x : Foo +>name : string + } + } +} + +function f4(x: Foo | Bar | string | number | null) { +>f4 : (x: string | number | Foo | Bar | null) => void +>x : string | number | Foo | Bar | null +>Foo : Foo +>Bar : Bar +>null : null + + if (x && typeof x === "object") { +>x && typeof x === "object" : boolean | "" | 0 | null +>x : string | number | Foo | Bar | null +>typeof x === "object" : boolean +>typeof x : string +>x : string | number | Foo | Bar +>"object" : "object" + + switch(x.kind) { +>x.kind : "foo" | "bar" +>x : Foo | Bar +>kind : "foo" | "bar" + + case 'foo': +>'foo' : "foo" + + x.name; +>x.name : string +>x : Foo +>name : string + } + } +} diff --git a/tests/cases/compiler/discriminantsAndPrimitives.ts b/tests/cases/compiler/discriminantsAndPrimitives.ts new file mode 100644 index 00000000000..6352d741808 --- /dev/null +++ b/tests/cases/compiler/discriminantsAndPrimitives.ts @@ -0,0 +1,49 @@ +// @strictNullChecks: true + +// Repro from #10257 plus other tests + +interface Foo { + kind: "foo"; + name: string; +} + +interface Bar { + kind: "bar"; + length: string; +} + +function f1(x: Foo | Bar | string) { + if (typeof x !== 'string') { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f2(x: Foo | Bar | string | undefined) { + if (typeof x === "object") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f3(x: Foo | Bar | string | null) { + if (x && typeof x !== "string") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f4(x: Foo | Bar | string | number | null) { + if (x && typeof x === "object") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} \ No newline at end of file From 644d6554fb3d4d9d2afb3ea494d695a303ae7712 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Aug 2016 16:04:46 -0700 Subject: [PATCH 135/508] Optimize core filter function to only allocate when necessary --- src/compiler/core.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 549410159b0..1d89d0092f3 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -147,17 +147,29 @@ namespace ts { return count; } + /** + * Filters an array by a predicate function. Returns the same array instance if the predicate is + * true for all elements, otherwise returns a new array instance containing the filtered subset. + */ export function filter(array: T[], f: (x: T) => boolean): T[] { - let result: T[]; if (array) { - result = []; - for (const item of array) { - if (f(item)) { - result.push(item); + const len = array.length; + let i = 0; + while (i < len && f(array[i])) i++; + if (i < len) { + const result = array.slice(0, i); + i++; + while (i < len) { + const item = array[i]; + if (f(item)) { + result.push(item); + } + i++; } + return result; } } - return result; + return array; } export function filterMutate(array: T[], f: (x: T) => boolean): void { From f1ea145e052cea7af3a9cbdf42f07d4f2728cb45 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 11 Aug 2016 16:06:03 -0700 Subject: [PATCH 136/508] Address CR comments + more optimizations --- src/compiler/checker.ts | 57 +++++++++-------------------------------- 1 file changed, 12 insertions(+), 45 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b6d03737810..0fb626e6281 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7852,7 +7852,7 @@ namespace ts { if (type && type.flags & TypeFlags.Union) { let prop = getPropertyOfType(type, name); if (!prop) { - // The type may be a union that includes nullable or primtive types. If filtering + // The type may be a union that includes nullable or primitive types. If filtering // those out produces a different type, get the property from that type instead. // Effectively, we're checking if this *could* be a discriminant property once nullable // and primitive types are removed by other type guards. @@ -7915,10 +7915,10 @@ namespace ts { // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean, // we remove type string. function getAssignmentReducedType(declaredType: UnionType, assignedType: Type) { - if (declaredType !== assignedType && declaredType.flags & TypeFlags.Union) { - const reducedTypes = filter(declaredType.types, t => typeMaybeAssignableTo(assignedType, t)); - if (reducedTypes.length) { - return reducedTypes.length === 1 ? reducedTypes[0] : getUnionType(reducedTypes); + if (declaredType !== assignedType) { + const reducedType = filterType(declaredType, t => typeMaybeAssignableTo(assignedType, t)); + if (reducedType !== neverType) { + return reducedType; } } return declaredType; @@ -7992,26 +7992,7 @@ namespace ts { } function getTypeWithFacts(type: Type, include: TypeFacts) { - if (!(type.flags & TypeFlags.Union)) { - return getTypeFacts(type) & include ? type : neverType; - } - const types = (type).types; - const length = types.length; - let i = 0; - while (i < length && getTypeFacts(types[i]) & include) i++; - if (i === length) { - return type; - } - const filtered = types.slice(0, i); - i++; - while (i < length) { - const t = types[i]; - if (getTypeFacts(t) & include) { - filtered.push(t); - } - i++; - } - return getUnionType(filtered); + return filterType(type, t => (getTypeFacts(t) & include) !== 0); } function getTypeWithDefault(type: Type, defaultExpression: Expression) { @@ -8191,22 +8172,8 @@ namespace ts { return f(type) ? type : neverType; } const types = (type).types; - const length = types.length; - let i = 0; - while (i < length && f(types[i])) i++; - if (i === length) { - return type; - } - const filtered = types.slice(0, i); - i++; - while (i < length) { - const t = types[i]; - if (f(t)) { - filtered.push(t); - } - i++; - } - return getUnionType(filtered); + const filtered = filter(types, f); + return filtered === types ? type : getUnionType(filtered); } function isIncomplete(flowType: FlowType) { @@ -8544,7 +8511,7 @@ namespace ts { } if (assumeTrue && !(type.flags & TypeFlags.Union)) { // We narrow a non-union type to an exact primitive type if the non-union type - // is a supertype of that primtive type. For example, type 'any' can be narrowed + // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. const targetType = getProperty(typeofTypesByName, literal.text); if (targetType && isTypeSubtypeOf(targetType, type)) { @@ -8633,9 +8600,9 @@ namespace ts { // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. if (type.flags & TypeFlags.Union) { - const assignableConstituents = filter((type).types, t => isTypeInstanceOf(t, candidate)); - if (assignableConstituents.length) { - return getUnionType(assignableConstituents); + const assignableType = filterType(type, t => isTypeInstanceOf(t, candidate)); + if (assignableType !== neverType) { + return assignableType; } } // If the candidate type is a subtype of the target type, narrow to the candidate type. From e64675eb85ad9bf346e0cd7495cb98e258be221d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Fri, 12 Aug 2016 06:54:51 -0700 Subject: [PATCH 137/508] Faster path for creating union types from filterType --- src/compiler/checker.ts | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0fb626e6281..4e04c5fc11a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5352,12 +5352,12 @@ namespace ts { } } - // We deduplicate the constituent types based on object identity. If the subtypeReduction flag is - // specified we also reduce the constituent type set to only include types that aren't subtypes of - // other types. Subtype reduction is expensive for large union types and is possible only when union + // We sort and deduplicate the constituent types based on object identity. If the subtypeReduction + // flag is specified we also reduce the constituent type set to only include types that aren't subtypes + // of other types. Subtype reduction is expensive for large union types and is possible only when union // types are known not to circularly reference themselves (as is the case with union types created by // expression constructs such as array literals and the || and ?: operators). Named types can - // circularly reference themselves and therefore cannot be deduplicated during their declaration. + // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types: Type[], subtypeReduction?: boolean, aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type { if (types.length === 0) { @@ -5379,15 +5379,23 @@ namespace ts { typeSet.containsUndefined ? typeSet.containsNonWideningType ? undefinedType : undefinedWideningType : neverType; } - else if (typeSet.length === 1) { - return typeSet[0]; + return getUnionTypeFromSortedList(typeSet, aliasSymbol, aliasTypeArguments); + } + + // This function assumes the constituent type list is sorted and deduplicated. + function getUnionTypeFromSortedList(types: Type[], aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type { + if (types.length === 0) { + return neverType; } - const id = getTypeListId(typeSet); + if (types.length === 1) { + return types[0]; + } + const id = getTypeListId(types); let type = unionTypes[id]; if (!type) { - const propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); + const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); type = unionTypes[id] = createObjectType(TypeFlags.Union | propagatedFlags); - type.types = typeSet; + type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } @@ -8168,12 +8176,12 @@ namespace ts { } function filterType(type: Type, f: (t: Type) => boolean): Type { - if (!(type.flags & TypeFlags.Union)) { - return f(type) ? type : neverType; + if (type.flags & TypeFlags.Union) { + const types = (type).types; + const filtered = filter(types, f); + return filtered === types ? type : getUnionTypeFromSortedList(filtered); } - const types = (type).types; - const filtered = filter(types, f); - return filtered === types ? type : getUnionType(filtered); + return f(type) ? type : neverType; } function isIncomplete(flowType: FlowType) { From df739fdd50b3ea3fcd8a5bd04614fe2093a4aa39 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 11 Aug 2016 12:26:22 -0700 Subject: [PATCH 138/508] Allow an @types direcotry to have a package.json which specifies `"typings": null` to disclude it from automatically included typings. --- src/compiler/program.ts | 89 ++++++++++--------- src/harness/compilerRunner.ts | 2 +- src/harness/fourslash.ts | 19 ++-- tests/baselines/reference/typingsLookup2.js | 9 ++ .../reference/typingsLookup2.symbols | 3 + .../reference/typingsLookup2.trace.json | 1 + .../baselines/reference/typingsLookup2.types | 3 + .../conformance/typings/typingsLookup2.ts | 13 +++ 8 files changed, 86 insertions(+), 53 deletions(-) create mode 100644 tests/baselines/reference/typingsLookup2.js create mode 100644 tests/baselines/reference/typingsLookup2.symbols create mode 100644 tests/baselines/reference/typingsLookup2.trace.json create mode 100644 tests/baselines/reference/typingsLookup2.types create mode 100644 tests/cases/conformance/typings/typingsLookup2.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 7d40b2f3219..67a93606cc6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -119,49 +119,31 @@ namespace ts { } function tryReadTypesSection(packageJsonPath: string, baseDirectory: string, state: ModuleResolutionState): string { - let jsonContent: { typings?: string, types?: string, main?: string }; - try { - const jsonText = state.host.readFile(packageJsonPath); - jsonContent = jsonText ? <{ typings?: string, types?: string, main?: string }>JSON.parse(jsonText) : {}; - } - catch (e) { - // gracefully handle if readFile fails or returns not JSON - jsonContent = {}; + const jsonContent = readJson(packageJsonPath, state.host); + + function tryReadFromField(fieldName: string) { + if (hasProperty(jsonContent, fieldName)) { + const typesFile = (jsonContent)[fieldName]; + if (typeof typesFile === "string") { + const typesFilePath = normalizePath(combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); + } + return typesFilePath; + } + else { + if (state.traceEnabled) { + trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } } - let typesFile: string; - let fieldName: string; - // first try to read content of 'typings' section (backward compatibility) - if (jsonContent.typings) { - if (typeof jsonContent.typings === "string") { - fieldName = "typings"; - typesFile = jsonContent.typings; - } - else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, "typings", typeof jsonContent.typings); - } - } - } - // then read 'types' - if (!typesFile && jsonContent.types) { - if (typeof jsonContent.types === "string") { - fieldName = "types"; - typesFile = jsonContent.types; - } - else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, "types", typeof jsonContent.types); - } - } - } - if (typesFile) { - const typesFilePath = normalizePath(combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } + const typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { return typesFilePath; } + // Use the main module for inferring types if no types package specified and the allowJs is set if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { if (state.traceEnabled) { @@ -173,6 +155,17 @@ namespace ts { return undefined; } + function readJson(path: string, host: ModuleResolutionHost): { typings?: string, types?: string, main?: string } { + try { + const jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + return {}; + } + } + const typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) { @@ -717,7 +710,7 @@ namespace ts { } function loadNodeModuleFromDirectory(extensions: string[], candidate: string, failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string { - const packageJsonPath = combinePaths(candidate, "package.json"); + const packageJsonPath = pathToPackageJson(candidate); const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); if (directoryExists && state.host.fileExists(packageJsonPath)) { if (state.traceEnabled) { @@ -747,6 +740,10 @@ namespace ts { return loadModuleFromFile(combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); } + function pathToPackageJson(directory: string): string { + return combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState): string { const nodeModulesFolder = combinePaths(directory, "node_modules"); const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); @@ -1070,15 +1067,21 @@ namespace ts { } // Walk the primary type lookup locations - let result: string[] = []; + const result: string[] = []; if (host.directoryExists && host.getDirectories) { const typeRoots = getEffectiveTypeRoots(options, host); if (typeRoots) { for (const root of typeRoots) { if (host.directoryExists(root)) { for (const typeDirectivePath of host.getDirectories(root)) { - // Return just the type directive names - result = result.concat(getBaseFileName(normalizePath(typeDirectivePath))); + const normalized = normalizePath(typeDirectivePath); + const packageJsonPath = pathToPackageJson(combinePaths(root, normalized)); + // tslint:disable-next-line:no-null-keyword + const isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + // Return just the type directive names + result.push(getBaseFileName(normalized)); + } } } } diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index ecdc18394b0..35e09c9c0d0 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -52,7 +52,7 @@ class CompilerBaselineRunner extends RunnerBase { private makeUnitName(name: string, root: string) { const path = ts.toPath(name, root, (fileName) => Harness.Compiler.getCanonicalFileName(fileName)); const pathStart = ts.toPath(Harness.IO.getCurrentDirectory(), "", (fileName) => Harness.Compiler.getCanonicalFileName(fileName)); - return path.replace(pathStart, "/"); + return pathStart ? path.replace(pathStart, "/") : path; }; public checkTestCodeOutput(fileName: string) { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a42abbbc609..620eee584e7 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2395,13 +2395,14 @@ ${code} // Comment line, check for global/file @options and record them const match = optionRegex.exec(line.substr(2)); if (match) { - const fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); + const [key, value] = match.slice(1); + const fileMetadataNamesIndex = fileMetadataNames.indexOf(key); if (fileMetadataNamesIndex === -1) { // Check if the match is already existed in the global options - if (globalOptions[match[1]] !== undefined) { - throw new Error("Global Option : '" + match[1] + "' is already existed"); + if (globalOptions[key] !== undefined) { + throw new Error(`Global option '${key}' already exists`); } - globalOptions[match[1]] = match[2]; + globalOptions[key] = value; } else { if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { @@ -2416,12 +2417,12 @@ ${code} resetLocalData(); } - currentFileName = basePath + "/" + match[2]; - currentFileOptions[match[1]] = match[2]; + currentFileName = basePath + "/" + value; + currentFileOptions[key] = value; } else { // Add other fileMetadata flag - currentFileOptions[match[1]] = match[2]; + currentFileOptions[key] = value; } } } @@ -2509,7 +2510,7 @@ ${code} } const marker: Marker = { - fileName: fileName, + fileName, position: location.position, data: markerValue }; @@ -2526,7 +2527,7 @@ ${code} function recordMarker(fileName: string, location: LocationInformation, name: string, markerMap: MarkerMap, markers: Marker[]): Marker { const marker: Marker = { - fileName: fileName, + fileName, position: location.position }; diff --git a/tests/baselines/reference/typingsLookup2.js b/tests/baselines/reference/typingsLookup2.js new file mode 100644 index 00000000000..3e816526af2 --- /dev/null +++ b/tests/baselines/reference/typingsLookup2.js @@ -0,0 +1,9 @@ +//// [tests/cases/conformance/typings/typingsLookup2.ts] //// + +//// [package.json] +{ "typings": null } + +//// [a.ts] + + +//// [a.js] diff --git a/tests/baselines/reference/typingsLookup2.symbols b/tests/baselines/reference/typingsLookup2.symbols new file mode 100644 index 00000000000..7223c8589a6 --- /dev/null +++ b/tests/baselines/reference/typingsLookup2.symbols @@ -0,0 +1,3 @@ +=== /a.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup2.trace.json b/tests/baselines/reference/typingsLookup2.trace.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/tests/baselines/reference/typingsLookup2.trace.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup2.types b/tests/baselines/reference/typingsLookup2.types new file mode 100644 index 00000000000..7223c8589a6 --- /dev/null +++ b/tests/baselines/reference/typingsLookup2.types @@ -0,0 +1,3 @@ +=== /a.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/cases/conformance/typings/typingsLookup2.ts b/tests/cases/conformance/typings/typingsLookup2.ts new file mode 100644 index 00000000000..90e1e463f0a --- /dev/null +++ b/tests/cases/conformance/typings/typingsLookup2.ts @@ -0,0 +1,13 @@ +// @traceResolution: true +// @noImplicitReferences: true +// @currentDirectory: / +// This tests that an @types package with `"typings": null` is not automatically included. +// (If it were, this test would break because there are no typings to be found.) + +// @filename: /tsconfig.json +{} + +// @filename: /node_modules/@types/angular2/package.json +{ "typings": null } + +// @filename: /a.ts From b0a4e2785d3febd578b88a825a363a9401285e6c Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 12 Aug 2016 13:36:54 -0700 Subject: [PATCH 139/508] Lint --- Gulpfile.ts | 11 +++-------- src/harness/harness.ts | 2 +- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index e2d37277bcf..f0e274f3f1e 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -531,8 +531,6 @@ const localRwcBaseline = path.join(internalTests, "baselines/rwc/local"); const refRwcBaseline = path.join(internalTests, "baselines/rwc/reference"); const localTest262Baseline = path.join(internalTests, "baselines/test262/local"); -const refTest262Baseline = path.join(internalTests, "baselines/test262/reference"); - gulp.task("tests", "Builds the test infrastructure using the built compiler", [run]); gulp.task("tests-debug", "Builds the test sources and automation in debug mode", () => { @@ -811,8 +809,6 @@ gulp.task("diff-rwc", "Diffs the RWC baselines using the diff tool specified by exec(getDiffTool(), [refRwcBaseline, localRwcBaseline], done, done); }); - -const deleteEnding = '.delete'; gulp.task("baseline-accept", "Makes the most recent test results the new baseline, overwriting the old baseline", () => { return baselineAccept(""); }); @@ -827,13 +823,12 @@ function baselineCopy(subfolder = "") { } function baselineDelete(subfolder = "") { - return gulp.src(['tests/baselines/local/**/*.delete']) + return gulp.src(["tests/baselines/local/**/*.delete"]) .pipe(insert.transform((content, fileObj) => { - const target = path.join(refBaseline, fileObj.relative.substr(0, fileObj.relative.length - '.delete'.length)); - console.log(target); + const target = path.join(refBaseline, fileObj.relative.substr(0, fileObj.relative.length - ".delete".length)); del.sync(target); del.sync(fileObj.path); - return ''; + return ""; })); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 18a440c789b..81567265d3f 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1667,7 +1667,7 @@ namespace Harness { const encoded_actual = Utils.encodeString(actual); if (expected !== encoded_actual) { if (actual === NoContent) { - IO.writeFile(relativeFileName + '.delete', ''); + IO.writeFile(relativeFileName + ".delete", ""); } else { IO.writeFile(relativeFileName, actual); From d2060466590a9cf3064da589cd321f405525f43f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 12 Aug 2016 14:00:50 -0700 Subject: [PATCH 140/508] Collect timing information for commands running on travis (#10308) --- Jakefile.js | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/Jakefile.js b/Jakefile.js index 0624c92f162..01aac82a47a 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -33,6 +33,28 @@ if (process.env.path !== undefined) { process.env.PATH = nodeModulesPathPrefix + process.env.PATH; } +function toNs(diff) { + return diff[0] * 1e9 + diff[1]; +} + +function mark() { + if (!fold.isTravis()) return; + var stamp = process.hrtime(); + var id = Math.floor(Math.random() * 0xFFFFFFFF).toString(16); + console.log("travis_time:start:" + id + "\r"); + return { + stamp: stamp, + id: id + }; +} + +function measure(marker) { + if (!fold.isTravis()) return; + var diff = process.hrtime(marker.stamp); + var total = [marker.stamp[0] + diff[0], marker.stamp[1] + diff[1]]; + console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r"); +} + var compilerSources = [ "core.ts", "performance.ts", @@ -286,6 +308,7 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); */ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) { file(outFile, prereqs, function() { + var startCompileTime = mark(); opts = opts || {}; var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types " @@ -362,11 +385,13 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts callback(); } + measure(startCompileTime); complete(); }); ex.addListener("error", function() { fs.unlinkSync(outFile); fail("Compilation of " + outFile + " unsuccessful"); + measure(startCompileTime); }); ex.run(); }, {async: true}); @@ -769,6 +794,7 @@ function runConsoleTests(defaultReporter, runInParallel) { // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer if(!runInParallel) { + var startTime = mark(); tests = tests ? ' -g "' + tests + '"' : ''; var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run; console.log(cmd); @@ -777,10 +803,12 @@ function runConsoleTests(defaultReporter, runInParallel) { process.env.NODE_ENV = "development"; exec(cmd, function () { process.env.NODE_ENV = savedNodeEnv; + measure(startTime); runLinter(); finish(); }, function(e, status) { process.env.NODE_ENV = savedNodeEnv; + measure(startTime); finish(status); }); @@ -788,9 +816,10 @@ function runConsoleTests(defaultReporter, runInParallel) { else { var savedNodeEnv = process.env.NODE_ENV; process.env.NODE_ENV = "development"; + var startTime = mark(); runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) { process.env.NODE_ENV = savedNodeEnv; - + measure(startTime); // last worker clean everything and runs linter in case if there were no errors deleteTemporaryProjectOutput(); jake.rmRf(taskConfigsFolder); @@ -1069,6 +1098,7 @@ var lintTargets = compilerSources desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex"); task("lint", ["build-rules"], function() { if (fold.isTravis()) console.log(fold.start("lint")); + var startTime = mark(); var lintOptions = getLinterOptions(); var failed = 0; var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || ""); @@ -1084,6 +1114,7 @@ task("lint", ["build-rules"], function() { done[target] = true; } } + measure(startTime); if (fold.isTravis()) console.log(fold.end("lint")); if (failed > 0) { fail('Linter errors.', failed); From c81624435a798249530f6d2b12687db3fa391bde Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Fri, 12 Aug 2016 16:34:35 -0700 Subject: [PATCH 141/508] Simplifies performance API --- src/compiler/binder.ts | 5 +- src/compiler/checker.ts | 7 +-- src/compiler/parser.ts | 6 +- src/compiler/performance.ts | 116 ++++++++++++++++-------------------- src/compiler/program.ts | 21 ++++--- src/compiler/sourcemap.ts | 10 +++- 6 files changed, 80 insertions(+), 85 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index c355d6c9186..ff5a8b77cfd 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -89,9 +89,10 @@ namespace ts { const binder = createBinder(); export function bindSourceFile(file: SourceFile, options: CompilerOptions) { - const start = performance.mark(); + performance.mark("bindStart"); binder(file, options); - performance.measure("Bind", start); + performance.mark("bindEnd"); + performance.measure("Bind", "bindStart", "bindEnd"); } function createBinder(): (file: SourceFile, options: CompilerOptions) => void { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b7b659e1a6..f1fff6737a3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17535,11 +17535,10 @@ namespace ts { } function checkSourceFile(node: SourceFile) { - const start = performance.mark(); - + performance.mark("checkStart"); checkSourceFileWorker(node); - - performance.measure("Check", start); + performance.mark("checkEnd"); + performance.measure("Check", "checkStart", "checkEnd"); } // Fully type check a source file and collect the relevant diagnostics. diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 6f38783d5ed..cbf767a5410 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -421,10 +421,10 @@ namespace ts { } export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false, scriptKind?: ScriptKind): SourceFile { - const start = performance.mark(); + performance.mark("parseStart"); const result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); - - performance.measure("Parse", start); + performance.mark("parseEnd"); + performance.measure("Parse", "parseStart", "parseEnd"); return result; } diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index e496353fde8..e8f064e81cd 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -6,71 +6,57 @@ namespace ts { } /*@internal*/ +/** Performance measurements for the compiler. */ namespace ts.performance { - /** Performance measurements for the compiler. */ declare const onProfilerEvent: { (markName: string): void; profiler: boolean; }; - let profilerEvent: (markName: string) => void; - let counters: MapLike; - let measures: MapLike; + + const profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true + ? onProfilerEvent + : (markName: string) => { }; + + let enabled = false; + let profilerStart = 0; + let counts: Map; + let marks: Map; + let measures: Map; /** - * Emit a performance event if ts-profiler is connected. This is primarily used - * to generate heap snapshots. + * Marks a performance event. * - * @param eventName A name for the event. + * @param markName The name of the mark. */ - export function emit(eventName: string) { - if (profilerEvent) { - profilerEvent(eventName); + export function mark(markName: string) { + if (enabled) { + marks[markName] = timestamp(); + counts[markName] = (counts[markName] || 0) + 1; + profilerEvent(markName); } } - /** - * Increments a counter with the specified name. - * - * @param counterName The name of the counter. - */ - export function increment(counterName: string) { - if (counters) { - counters[counterName] = (getProperty(counters, counterName) || 0) + 1; - } - } - - /** - * Gets the value of the counter with the specified name. - * - * @param counterName The name of the counter. - */ - export function getCount(counterName: string) { - return counters && getProperty(counters, counterName) || 0; - } - - /** - * Marks the start of a performance measurement. - */ - export function mark() { - return measures ? timestamp() : 0; - } - /** * Adds a performance measurement with the specified name. * * @param measureName The name of the performance measurement. - * @param marker The timestamp of the starting mark. + * @param startMarkName The name of the starting mark. If not supplied, the point at which the + * profiler was enabled is used. + * @param endMarkName The name of the ending mark. If not supplied, the current timestamp is + * used. */ - export function measure(measureName: string, marker: number) { - if (measures) { - measures[measureName] = (getProperty(measures, measureName) || 0) + (timestamp() - marker); + export function measure(measureName: string, startMarkName?: string, endMarkName?: string) { + if (enabled) { + const end = endMarkName && marks[endMarkName] || timestamp(); + const start = startMarkName && marks[startMarkName] || profilerStart; + measures[measureName] = (measures[measureName] || 0) + (end - start); } } /** - * Iterate over each measure, performing some action - * - * @param cb The action to perform for each measure + * Gets the number of times a marker was encountered. + * + * @param markName The name of the mark. */ - export function forEachMeasure(cb: (measureName: string, duration: number) => void) { - return forEachKey(measures, key => cb(key, measures[key])); + export function getCount(markName: string) { + return counts && counts[markName] || 0; } /** @@ -79,31 +65,31 @@ namespace ts.performance { * @param measureName The name of the measure whose durations should be accumulated. */ export function getDuration(measureName: string) { - return measures && getProperty(measures, measureName) || 0; + return measures && measures[measureName] || 0; + } + + /** + * Iterate over each measure, performing some action + * + * @param cb The action to perform for each measure + */ + export function forEachMeasure(cb: (measureName: string, duration: number) => void) { + for (const key in measures) { + cb(key, measures[key]); + } } /** Enables (and resets) performance measurements for the compiler. */ export function enable() { - counters = { }; - measures = { - "I/O Read": 0, - "I/O Write": 0, - "Program": 0, - "Parse": 0, - "Bind": 0, - "Check": 0, - "Emit": 0, - }; - - profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true - ? onProfilerEvent - : undefined; + counts = createMap(); + marks = createMap(); + measures = createMap(); + enabled = true; + profilerStart = timestamp(); } - /** Disables (and clears) performance measurements for the compiler. */ + /** Disables performance measurements for the compiler. */ export function disable() { - counters = undefined; - measures = undefined; - profilerEvent = undefined; + enabled = false; } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index eb50548750d..a632eed7fd2 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -857,9 +857,10 @@ namespace ts { function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile { let text: string; try { - const start = performance.mark(); + performance.mark("ioReadStart"); text = sys.readFile(fileName, options.charset); - performance.measure("I/O Read", start); + performance.mark("ioReadEnd"); + performance.measure("I/O Read", "ioReadStart", "ioReadEnd"); } catch (e) { if (onError) { @@ -926,7 +927,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { try { - const start = performance.mark(); + performance.mark("ioWriteStart"); ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); if (isWatchSet(options) && sys.createHash && sys.getModifiedTime) { @@ -936,7 +937,8 @@ namespace ts { sys.writeFile(fileName, data, writeByteOrderMark); } - performance.measure("I/O Write", start); + performance.mark("ioWriteEnd"); + performance.measure("I/O Write", "ioWriteStart", "ioWriteEnd"); } catch (e) { if (onError) { @@ -1118,7 +1120,7 @@ namespace ts { // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. const sourceFilesFoundSearchingNodeModules = createMap(); - const start = performance.mark(); + performance.mark("programStart"); host = host || createCompilerHost(options); @@ -1216,8 +1218,8 @@ namespace ts { }; verifyCompilerOptions(); - - performance.measure("Program", start); + performance.mark("programEnd"); + performance.measure("Program", "programStart", "programEnd"); return program; @@ -1460,14 +1462,15 @@ namespace ts { // checked is to not pass the file to getEmitResolver. const emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - const start = performance.mark(); + performance.mark("emitStart"); const emitResult = emitFiles( emitResolver, getEmitHost(writeFileCallback), sourceFile); - performance.measure("Emit", start); + performance.mark("emitEnd"); + performance.measure("Emit", "emitStart", "emitEnd"); return emitResult; } diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 2d8c36a3d02..52e8975db76 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -46,6 +46,7 @@ namespace ts { export function createSourceMapWriter(host: EmitHost, writer: EmitTextWriter): SourceMapWriter { const compilerOptions = host.getCompilerOptions(); + const extendedDiagnostics = compilerOptions.extendedDiagnostics; let currentSourceFile: SourceFile; let sourceMapDir: string; // The directory in which sourcemap will be let stopOverridingSpan = false; @@ -240,7 +241,9 @@ namespace ts { return; } - const start = performance.mark(); + if (extendedDiagnostics) { + performance.mark("sourcemapStart"); + } const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); @@ -282,7 +285,10 @@ namespace ts { updateLastEncodedAndRecordedSpans(); - performance.measure("Source Map", start); + if (extendedDiagnostics) { + performance.mark("sourcemapEnd"); + performance.measure("Source Map", "sourcemapStart", "sourcemapEnd"); + } } function getStartPos(range: TextRange) { From 73d53e82988ff93fa2a20346127a683333e6ab94 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Sat, 13 Aug 2016 12:18:39 -0700 Subject: [PATCH 142/508] Use 'MapLike' instead of 'Map' in 'preferConstRule.ts'. --- scripts/tslint/preferConstRule.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/scripts/tslint/preferConstRule.ts b/scripts/tslint/preferConstRule.ts index aaa1b0e53d5..1d316692468 100644 --- a/scripts/tslint/preferConstRule.ts +++ b/scripts/tslint/preferConstRule.ts @@ -1,7 +1,6 @@ import * as Lint from "tslint/lib/lint"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static FAILURE_STRING_FACTORY = (identifier: string) => `Identifier '${identifier}' never appears on the LHS of an assignment - use const instead of let for its declaration.`; @@ -64,7 +63,7 @@ interface DeclarationUsages { } class PreferConstWalker extends Lint.RuleWalker { - private inScopeLetDeclarations: ts.Map[] = []; + private inScopeLetDeclarations: ts.MapLike[] = []; private errors: Lint.RuleFailure[] = []; private markAssignment(identifier: ts.Identifier) { const name = identifier.text; @@ -172,7 +171,7 @@ class PreferConstWalker extends Lint.RuleWalker { } private visitAnyForStatement(node: ts.ForOfStatement | ts.ForInStatement) { - const names: ts.Map = {}; + const names: ts.MapLike = {}; if (isLet(node.initializer)) { if (node.initializer.kind === ts.SyntaxKind.VariableDeclarationList) { this.collectLetIdentifiers(node.initializer as ts.VariableDeclarationList, names); @@ -194,7 +193,7 @@ class PreferConstWalker extends Lint.RuleWalker { } visitBlock(node: ts.Block) { - const names: ts.Map = {}; + const names: ts.MapLike = {}; for (const statement of node.statements) { if (statement.kind === ts.SyntaxKind.VariableStatement) { this.collectLetIdentifiers((statement as ts.VariableStatement).declarationList, names); @@ -205,7 +204,7 @@ class PreferConstWalker extends Lint.RuleWalker { this.popDeclarations(); } - private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.Map) { + private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.MapLike) { for (const node of list.declarations) { if (isLet(node) && !isExported(node)) { this.collectNameIdentifiers(node, node.name, ret); @@ -213,7 +212,7 @@ class PreferConstWalker extends Lint.RuleWalker { } } - private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.Map) { + private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.MapLike) { if (node.kind === ts.SyntaxKind.Identifier) { table[(node as ts.Identifier).text] = { declaration, usages: 0 }; } @@ -222,7 +221,7 @@ class PreferConstWalker extends Lint.RuleWalker { } } - private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.Map) { + private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.MapLike) { for (const element of pattern.elements) { this.collectNameIdentifiers(value, element.name, table); } From 38353027aaa9813c646cce62900eb9694012bae5 Mon Sep 17 00:00:00 2001 From: yortus Date: Sat, 13 Aug 2016 13:57:18 +0800 Subject: [PATCH 143/508] narrow from 'any' in most situations instanceof and user-defined typeguards narrow from 'any' unless the narrowed-to type is exactly 'Object' or 'Function'. This is a breaking change. --- src/compiler/checker.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b7b659e1a6..85e33c5e4a1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8548,10 +8548,6 @@ namespace ts { } return type; } - // We never narrow type any in an instanceof guard - if (isTypeAny(type)) { - return type; - } // Check that right operand is a function type with a prototype property const rightType = checkExpression(expr.right); @@ -8569,6 +8565,11 @@ namespace ts { } } + // Don't narrow from 'any' if the target type is exactly 'Object' or 'Function' + if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) { + return type; + } + if (!targetType) { // Target type is type of construct signature let constructSignatures: Signature[]; @@ -8615,7 +8616,7 @@ namespace ts { } function narrowTypeByTypePredicate(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type { - if (type.flags & TypeFlags.Any || !hasMatchingArgument(callExpression, reference)) { + if (!hasMatchingArgument(callExpression, reference)) { return type; } const signature = getResolvedSignature(callExpression); @@ -8623,6 +8624,12 @@ namespace ts { if (!predicate) { return type; } + + // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' + if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { + return type; + } + if (isIdentifierTypePredicate(predicate)) { const predicateArgument = callExpression.arguments[predicate.parameterIndex]; if (predicateArgument) { From 59c09d90e638a709ae3fbbecf5662f1e86cefdca Mon Sep 17 00:00:00 2001 From: yortus Date: Sat, 13 Aug 2016 14:49:56 +0800 Subject: [PATCH 144/508] Update instanceof conformance tests --- ...rdsWithInstanceOfByConstructorSignature.ts | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts index b81dd26652b..0817954c35c 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts @@ -13,7 +13,7 @@ if (obj1 instanceof A) { // narrowed to A. } var obj2: any; -if (obj2 instanceof A) { // can't narrow type from 'any' +if (obj2 instanceof A) { obj2.foo; obj2.bar; } @@ -35,7 +35,7 @@ if (obj3 instanceof B) { // narrowed to B. } var obj4: any; -if (obj4 instanceof B) { // can't narrow type from 'any' +if (obj4 instanceof B) { obj4.foo = "str"; obj4.foo = 1; obj4.bar = "str"; @@ -67,7 +67,7 @@ if (obj5 instanceof C) { // narrowed to C1|C2. } var obj6: any; -if (obj6 instanceof C) { // can't narrow type from 'any' +if (obj6 instanceof C) { obj6.foo; obj6.bar1; obj6.bar2; @@ -86,7 +86,7 @@ if (obj7 instanceof D) { // narrowed to D. } var obj8: any; -if (obj8 instanceof D) { // can't narrow type from 'any' +if (obj8 instanceof D) { obj8.foo; obj8.bar; } @@ -113,7 +113,7 @@ if (obj9 instanceof E) { // narrowed to E1 | E2 } var obj10: any; -if (obj10 instanceof E) { // can't narrow type from 'any' +if (obj10 instanceof E) { obj10.foo; obj10.bar1; obj10.bar2; @@ -136,7 +136,7 @@ if (obj11 instanceof F) { // can't type narrowing, construct signature returns a } var obj12: any; -if (obj12 instanceof F) { // can't narrow type from 'any' +if (obj12 instanceof F) { obj12.foo; obj12.bar; } @@ -161,7 +161,7 @@ if (obj13 instanceof G) { // narrowed to G1. G1 is return type of prototype prop } var obj14: any; -if (obj14 instanceof G) { // can't narrow type from 'any' +if (obj14 instanceof G) { obj14.foo1; obj14.foo2; } @@ -183,7 +183,19 @@ if (obj15 instanceof H) { // narrowed to H. } var obj16: any; -if (obj16 instanceof H) { // can't narrow type from 'any' +if (obj16 instanceof H) { obj16.foo1; obj16.foo2; } + +var obj17: any; +if (obj17 instanceof Object) { // can't narrow type from 'any' to 'Object' + obj17.foo1; + obj17.foo2; +} + +var obj18: any; +if (obj18 instanceof Function) { // can't narrow type from 'any' to 'Function' + obj18.foo1; + obj18.foo2; +} From cc8f3269611565ac098aa644d1cc1522a4642bf5 Mon Sep 17 00:00:00 2001 From: yortus Date: Sun, 14 Aug 2016 21:42:31 +0800 Subject: [PATCH 145/508] accept new baselines --- ...nstanceOfByConstructorSignature.errors.txt | 60 ++++++++++++++++--- ...rdsWithInstanceOfByConstructorSignature.js | 38 +++++++++--- 2 files changed, 81 insertions(+), 17 deletions(-) diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt index c574118f91d..b67f7328856 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt @@ -1,16 +1,26 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(12,10): error TS2339: Property 'bar' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(18,10): error TS2339: Property 'bar' does not exist on type 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(33,5): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(34,10): error TS2339: Property 'bar' does not exist on type 'B'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(41,10): error TS2339: Property 'bar' does not exist on type 'B'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(66,10): error TS2339: Property 'bar2' does not exist on type 'C1'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(72,10): error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(73,10): error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(85,10): error TS2339: Property 'bar' does not exist on type 'D'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(91,10): error TS2339: Property 'bar' does not exist on type 'D'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(112,10): error TS2339: Property 'bar2' does not exist on type 'E1'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(118,11): error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(119,11): error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(134,11): error TS2339: Property 'foo' does not exist on type 'string | F'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(135,11): error TS2339: Property 'bar' does not exist on type 'string | F'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(160,11): error TS2339: Property 'foo2' does not exist on type 'G1'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(166,11): error TS2339: Property 'foo2' does not exist on type 'G1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(182,11): error TS2339: Property 'bar' does not exist on type 'H'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(187,11): error TS2339: Property 'foo1' does not exist on type 'H'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(188,11): error TS2339: Property 'foo2' does not exist on type 'H'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts (10 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts (20 errors) ==== interface AConstructor { new (): A; } @@ -28,9 +38,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj2: any; - if (obj2 instanceof A) { // can't narrow type from 'any' + if (obj2 instanceof A) { obj2.foo; obj2.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'A'. } // a construct signature with generics @@ -54,10 +66,12 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj4: any; - if (obj4 instanceof B) { // can't narrow type from 'any' + if (obj4 instanceof B) { obj4.foo = "str"; obj4.foo = 1; obj4.bar = "str"; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'B'. } // has multiple construct signature @@ -88,10 +102,14 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj6: any; - if (obj6 instanceof C) { // can't narrow type from 'any' + if (obj6 instanceof C) { obj6.foo; obj6.bar1; + ~~~~ +!!! error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. obj6.bar2; + ~~~~ +!!! error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. } // with object type literal @@ -109,9 +127,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj8: any; - if (obj8 instanceof D) { // can't narrow type from 'any' + if (obj8 instanceof D) { obj8.foo; obj8.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'D'. } // a construct signature that returns a union type @@ -138,10 +158,14 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj10: any; - if (obj10 instanceof E) { // can't narrow type from 'any' + if (obj10 instanceof E) { obj10.foo; obj10.bar1; + ~~~~ +!!! error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. obj10.bar2; + ~~~~ +!!! error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. } // a construct signature that returns any @@ -165,7 +189,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj12: any; - if (obj12 instanceof F) { // can't narrow type from 'any' + if (obj12 instanceof F) { obj12.foo; obj12.bar; } @@ -192,9 +216,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj14: any; - if (obj14 instanceof G) { // can't narrow type from 'any' + if (obj14 instanceof G) { obj14.foo1; obj14.foo2; + ~~~~ +!!! error TS2339: Property 'foo2' does not exist on type 'G1'. } // a type with a prototype that has any type @@ -216,8 +242,24 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj16: any; - if (obj16 instanceof H) { // can't narrow type from 'any' + if (obj16 instanceof H) { obj16.foo1; + ~~~~ +!!! error TS2339: Property 'foo1' does not exist on type 'H'. obj16.foo2; + ~~~~ +!!! error TS2339: Property 'foo2' does not exist on type 'H'. + } + + var obj17: any; + if (obj17 instanceof Object) { // can't narrow type from 'any' to 'Object' + obj17.foo1; + obj17.foo2; + } + + var obj18: any; + if (obj18 instanceof Function) { // can't narrow type from 'any' to 'Function' + obj18.foo1; + obj18.foo2; } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js index 7e6b3324470..40ef6587e75 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js @@ -14,7 +14,7 @@ if (obj1 instanceof A) { // narrowed to A. } var obj2: any; -if (obj2 instanceof A) { // can't narrow type from 'any' +if (obj2 instanceof A) { obj2.foo; obj2.bar; } @@ -36,7 +36,7 @@ if (obj3 instanceof B) { // narrowed to B. } var obj4: any; -if (obj4 instanceof B) { // can't narrow type from 'any' +if (obj4 instanceof B) { obj4.foo = "str"; obj4.foo = 1; obj4.bar = "str"; @@ -68,7 +68,7 @@ if (obj5 instanceof C) { // narrowed to C1|C2. } var obj6: any; -if (obj6 instanceof C) { // can't narrow type from 'any' +if (obj6 instanceof C) { obj6.foo; obj6.bar1; obj6.bar2; @@ -87,7 +87,7 @@ if (obj7 instanceof D) { // narrowed to D. } var obj8: any; -if (obj8 instanceof D) { // can't narrow type from 'any' +if (obj8 instanceof D) { obj8.foo; obj8.bar; } @@ -114,7 +114,7 @@ if (obj9 instanceof E) { // narrowed to E1 | E2 } var obj10: any; -if (obj10 instanceof E) { // can't narrow type from 'any' +if (obj10 instanceof E) { obj10.foo; obj10.bar1; obj10.bar2; @@ -137,7 +137,7 @@ if (obj11 instanceof F) { // can't type narrowing, construct signature returns a } var obj12: any; -if (obj12 instanceof F) { // can't narrow type from 'any' +if (obj12 instanceof F) { obj12.foo; obj12.bar; } @@ -162,7 +162,7 @@ if (obj13 instanceof G) { // narrowed to G1. G1 is return type of prototype prop } var obj14: any; -if (obj14 instanceof G) { // can't narrow type from 'any' +if (obj14 instanceof G) { obj14.foo1; obj14.foo2; } @@ -184,10 +184,22 @@ if (obj15 instanceof H) { // narrowed to H. } var obj16: any; -if (obj16 instanceof H) { // can't narrow type from 'any' +if (obj16 instanceof H) { obj16.foo1; obj16.foo2; } + +var obj17: any; +if (obj17 instanceof Object) { // can't narrow type from 'any' to 'Object' + obj17.foo1; + obj17.foo2; +} + +var obj18: any; +if (obj18 instanceof Function) { // can't narrow type from 'any' to 'Function' + obj18.foo1; + obj18.foo2; +} //// [typeGuardsWithInstanceOfByConstructorSignature.js] @@ -278,3 +290,13 @@ if (obj16 instanceof H) { obj16.foo1; obj16.foo2; } +var obj17; +if (obj17 instanceof Object) { + obj17.foo1; + obj17.foo2; +} +var obj18; +if (obj18 instanceof Function) { + obj18.foo1; + obj18.foo2; +} From 66047c8b184f231cbf77e6c3ca5d78909e038388 Mon Sep 17 00:00:00 2001 From: yortus Date: Sun, 14 Aug 2016 22:56:36 +0800 Subject: [PATCH 146/508] add tests --- .../narrowExceptionVariableInCatchClause.ts | 23 +++++++++++++ .../types/any/narrowFromAnyWithInstanceof.ts | 23 +++++++++++++ .../any/narrowFromAnyWithTypePredicate.ts | 34 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts create mode 100644 tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts create mode 100644 tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts diff --git a/tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts b/tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts new file mode 100644 index 00000000000..dfa60a415f9 --- /dev/null +++ b/tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts @@ -0,0 +1,23 @@ +declare function isFooError(x: any): x is { type: 'foo'; dontPanic(); }; + +function tryCatch() { + try { + // do stuff... + } + catch (err) { // err is implicitly 'any' and cannot be annotated + + if (isFooError(err)) { + err.dontPanic(); // OK + err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' + } + + else if (err instanceof Error) { + err.message; + err.massage; // ERROR: Property 'massage' does not exist on type 'Error' + } + + else { + throw err; + } + } +} diff --git a/tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts b/tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts new file mode 100644 index 00000000000..4fbfc46060a --- /dev/null +++ b/tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts @@ -0,0 +1,23 @@ +declare var x: any; + +if (x instanceof Function) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} + +if (x instanceof Object) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); +} + +if (x instanceof Error) { // 'any' is narrowed to types other than 'Function'/'Object' + x.message; + x.mesage; +} + +if (x instanceof Date) { + x.getDate(); + x.getHuors(); +} diff --git a/tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts b/tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts new file mode 100644 index 00000000000..473bd349b5f --- /dev/null +++ b/tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts @@ -0,0 +1,34 @@ +declare var x: any; +declare function isFunction(x): x is Function; +declare function isObject(x): x is Object; +declare function isAnything(x): x is {}; +declare function isError(x): x is Error; +declare function isDate(x): x is Date; + + +if (isFunction(x)) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} + +if (isObject(x)) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); +} + +if (isAnything(x)) { // 'any' is narrowed to types other than 'Function'/'Object' (including {}) + x.method(); + x(); +} + +if (isError(x)) { + x.message; + x.mesage; +} + +if (isDate(x)) { + x.getDate(); + x.getHuors(); +} From 837688f0bec2dcbe15242609fe9f75b02224c2fd Mon Sep 17 00:00:00 2001 From: yortus Date: Sun, 14 Aug 2016 22:58:21 +0800 Subject: [PATCH 147/508] accept new baselines --- ...wExceptionVariableInCatchClause.errors.txt | 33 ++++++++++ .../narrowExceptionVariableInCatchClause.js | 44 ++++++++++++++ .../narrowFromAnyWithInstanceof.errors.txt | 33 ++++++++++ .../reference/narrowFromAnyWithInstanceof.js | 45 ++++++++++++++ .../narrowFromAnyWithTypePredicate.errors.txt | 50 ++++++++++++++++ .../narrowFromAnyWithTypePredicate.js | 60 +++++++++++++++++++ 6 files changed, 265 insertions(+) create mode 100644 tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt create mode 100644 tests/baselines/reference/narrowExceptionVariableInCatchClause.js create mode 100644 tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt create mode 100644 tests/baselines/reference/narrowFromAnyWithInstanceof.js create mode 100644 tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt create mode 100644 tests/baselines/reference/narrowFromAnyWithTypePredicate.js diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt new file mode 100644 index 00000000000..e435b98050d --- /dev/null +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(11,17): error TS2339: Property 'doPanic' does not exist on type '{ type: "foo"; dontPanic(): any; }'. +tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(16,17): error TS2339: Property 'massage' does not exist on type 'Error'. + + +==== tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts (2 errors) ==== + declare function isFooError(x: any): x is { type: 'foo'; dontPanic(); }; + + function tryCatch() { + try { + // do stuff... + } + catch (err) { // err is implicitly 'any' and cannot be annotated + + if (isFooError(err)) { + err.dontPanic(); // OK + err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' + ~~~~~~~ +!!! error TS2339: Property 'doPanic' does not exist on type '{ type: "foo"; dontPanic(): any; }'. + } + + else if (err instanceof Error) { + err.message; + err.massage; // ERROR: Property 'massage' does not exist on type 'Error' + ~~~~~~~ +!!! error TS2339: Property 'massage' does not exist on type 'Error'. + } + + else { + throw err; + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.js b/tests/baselines/reference/narrowExceptionVariableInCatchClause.js new file mode 100644 index 00000000000..5808ed76826 --- /dev/null +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.js @@ -0,0 +1,44 @@ +//// [narrowExceptionVariableInCatchClause.ts] +declare function isFooError(x: any): x is { type: 'foo'; dontPanic(); }; + +function tryCatch() { + try { + // do stuff... + } + catch (err) { // err is implicitly 'any' and cannot be annotated + + if (isFooError(err)) { + err.dontPanic(); // OK + err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' + } + + else if (err instanceof Error) { + err.message; + err.massage; // ERROR: Property 'massage' does not exist on type 'Error' + } + + else { + throw err; + } + } +} + + +//// [narrowExceptionVariableInCatchClause.js] +function tryCatch() { + try { + } + catch (err) { + if (isFooError(err)) { + err.dontPanic(); // OK + err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' + } + else if (err instanceof Error) { + err.message; + err.massage; // ERROR: Property 'massage' does not exist on type 'Error' + } + else { + throw err; + } + } +} diff --git a/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt new file mode 100644 index 00000000000..3e152b0faf4 --- /dev/null +++ b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(17,7): error TS2339: Property 'mesage' does not exist on type 'Error'. +tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS2339: Property 'getHuors' does not exist on type 'Date'. + + +==== tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts (2 errors) ==== + declare var x: any; + + if (x instanceof Function) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; + } + + if (x instanceof Object) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); + } + + if (x instanceof Error) { // 'any' is narrowed to types other than 'Function'/'Object' + x.message; + x.mesage; + ~~~~~~ +!!! error TS2339: Property 'mesage' does not exist on type 'Error'. + } + + if (x instanceof Date) { + x.getDate(); + x.getHuors(); + ~~~~~~~~ +!!! error TS2339: Property 'getHuors' does not exist on type 'Date'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/narrowFromAnyWithInstanceof.js b/tests/baselines/reference/narrowFromAnyWithInstanceof.js new file mode 100644 index 00000000000..4cf1ca174aa --- /dev/null +++ b/tests/baselines/reference/narrowFromAnyWithInstanceof.js @@ -0,0 +1,45 @@ +//// [narrowFromAnyWithInstanceof.ts] +declare var x: any; + +if (x instanceof Function) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} + +if (x instanceof Object) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); +} + +if (x instanceof Error) { // 'any' is narrowed to types other than 'Function'/'Object' + x.message; + x.mesage; +} + +if (x instanceof Date) { + x.getDate(); + x.getHuors(); +} + + +//// [narrowFromAnyWithInstanceof.js] +if (x instanceof Function) { + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} +if (x instanceof Object) { + x.method(); + x(); +} +if (x instanceof Error) { + x.message; + x.mesage; +} +if (x instanceof Date) { + x.getDate(); + x.getHuors(); +} diff --git a/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt new file mode 100644 index 00000000000..94f41becdad --- /dev/null +++ b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(22,7): error TS2339: Property 'method' does not exist on type '{}'. +tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(23,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(28,7): error TS2339: Property 'mesage' does not exist on type 'Error'. +tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error TS2339: Property 'getHuors' does not exist on type 'Date'. + + +==== tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts (4 errors) ==== + declare var x: any; + declare function isFunction(x): x is Function; + declare function isObject(x): x is Object; + declare function isAnything(x): x is {}; + declare function isError(x): x is Error; + declare function isDate(x): x is Date; + + + if (isFunction(x)) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; + } + + if (isObject(x)) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); + } + + if (isAnything(x)) { // 'any' is narrowed to types other than 'Function'/'Object' (including {}) + x.method(); + ~~~~~~ +!!! error TS2339: Property 'method' does not exist on type '{}'. + x(); + ~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + } + + if (isError(x)) { + x.message; + x.mesage; + ~~~~~~ +!!! error TS2339: Property 'mesage' does not exist on type 'Error'. + } + + if (isDate(x)) { + x.getDate(); + x.getHuors(); + ~~~~~~~~ +!!! error TS2339: Property 'getHuors' does not exist on type 'Date'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/narrowFromAnyWithTypePredicate.js b/tests/baselines/reference/narrowFromAnyWithTypePredicate.js new file mode 100644 index 00000000000..958a3cfd70d --- /dev/null +++ b/tests/baselines/reference/narrowFromAnyWithTypePredicate.js @@ -0,0 +1,60 @@ +//// [narrowFromAnyWithTypePredicate.ts] +declare var x: any; +declare function isFunction(x): x is Function; +declare function isObject(x): x is Object; +declare function isAnything(x): x is {}; +declare function isError(x): x is Error; +declare function isDate(x): x is Date; + + +if (isFunction(x)) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} + +if (isObject(x)) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); +} + +if (isAnything(x)) { // 'any' is narrowed to types other than 'Function'/'Object' (including {}) + x.method(); + x(); +} + +if (isError(x)) { + x.message; + x.mesage; +} + +if (isDate(x)) { + x.getDate(); + x.getHuors(); +} + + +//// [narrowFromAnyWithTypePredicate.js] +if (isFunction(x)) { + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} +if (isObject(x)) { + x.method(); + x(); +} +if (isAnything(x)) { + x.method(); + x(); +} +if (isError(x)) { + x.message; + x.mesage; +} +if (isDate(x)) { + x.getDate(); + x.getHuors(); +} From f7da7e900683db2924e2edbfff4e7e8d3e92d621 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Sun, 14 Aug 2016 19:27:33 -0400 Subject: [PATCH 148/508] More helpful error messaging when a type is used as a value --- src/compiler/checker.ts | 19 +++++++++++++++++- src/compiler/diagnosticMessages.json | 4 ++++ tests/cases/compiler/typeUsedAsValueError.ts | 21 ++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 tests/cases/compiler/typeUsedAsValueError.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b7b659e1a6..87569ce83e2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -879,7 +879,8 @@ namespace ts { if (nameNotFoundMessage) { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && - !checkAndReportErrorForExtendingInterface(errorLocation)) { + !checkAndReportErrorForExtendingInterface(errorLocation) && + !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning, nameNotFoundMessage, nameArg)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); } } @@ -989,6 +990,22 @@ namespace ts { } } + function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): boolean { + const strictlyValueMeanings = SymbolFlags.Value & ~SymbolFlags.Type; + const strictlyTypeMeanings = SymbolFlags.Type & ~SymbolFlags.Value; + + if (!(meaning & strictlyValueMeanings)) { + return false; + } + + const nameAsType = resolveName(errorLocation, name, strictlyTypeMeanings, nameNotFoundMessage, nameArg); + if (nameAsType) { + error(errorLocation, Diagnostics.Cannot_find_name_0_A_type_exists_with_this_name_but_no_value, name); + return true; + } + + return false; + } function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8126d5c605e..3a2fec2ff02 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1951,6 +1951,10 @@ "category": "Error", "code": 2690 }, + "Cannot find name '{0}'. A type exists with this name, but no value.": { + "category": "Error", + "code": 2691 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/cases/compiler/typeUsedAsValueError.ts b/tests/cases/compiler/typeUsedAsValueError.ts new file mode 100644 index 00000000000..0e0eceb6c3b --- /dev/null +++ b/tests/cases/compiler/typeUsedAsValueError.ts @@ -0,0 +1,21 @@ +interface Interface { + +} + +class Class { + +} + +type typeAliasForClass = Class; +type typeAliasForNumber = number; +type objectType = { x: number }; + +function func(a: number) { + +} + +let one = Interface; +let two = typeAliasForClass; +let three = typeAliasForNumber; +let four = objectType; +func(typeAliasForNumber); \ No newline at end of file From affa6db3db721d739e3229609edefe95c3788ec3 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Sun, 14 Aug 2016 22:26:45 -0400 Subject: [PATCH 149/508] Accept baselines --- .../aliasOnMergedModuleInterface.errors.txt | 4 +- .../reference/assignments.errors.txt | 4 +- ...assExtendsInterfaceInExpression.errors.txt | 4 +- .../errorsOnImportedSymbol.errors.txt | 8 +-- .../es6ExportEqualsInterop.errors.txt | 4 +- ...ignmentOfDeclaredExternalModule.errors.txt | 8 +-- ...onstructInvocationWithNoTypeArg.errors.txt | 4 +- ...inheritFromGenericTypeParameter.errors.txt | 4 +- .../reference/intTypeCheck.errors.txt | 32 ++++++------ .../interfaceNameAsIdentifier.errors.txt | 4 +- .../reference/interfaceNaming1.errors.txt | 8 +-- .../invalidImportAliasIdentifiers.errors.txt | 4 +- .../invalidUndefinedAssignments.errors.txt | 4 +- ...singES6ArrayWithOnlyES6ArrayLib.errors.txt | 4 +- .../reference/newOperator.errors.txt | 4 +- .../reservedNamesInAliases.errors.txt | 4 +- .../reference/returnTypeParameter.errors.txt | 4 +- ...eReservedWordInClassDeclaration.errors.txt | 8 +-- .../typeParameterAsBaseClass.errors.txt | 4 +- .../typeParameterAsBaseType.errors.txt | 8 +-- .../reference/typeUsedAsValueError.errors.txt | 50 +++++++++++++++++++ .../reference/typeUsedAsValueError.js | 41 +++++++++++++++ .../reference/typeofSimple.errors.txt | 4 +- .../reference/typeofTypeParameter.errors.txt | 4 +- .../reference/validNullAssignments.errors.txt | 4 +- tests/cases/compiler/typeUsedAsValueError.ts | 20 ++++---- 26 files changed, 172 insertions(+), 79 deletions(-) create mode 100644 tests/baselines/reference/typeUsedAsValueError.errors.txt create mode 100644 tests/baselines/reference/typeUsedAsValueError.js diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt b/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt index 009d405c0f5..9361e201edc 100644 --- a/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2304: Cannot find name 'foo'. +tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2691: Cannot find name 'foo'. A type exists with this name, but no value. ==== tests/cases/compiler/aliasOnMergedModuleInterface_1.ts (1 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2304: Cann z.bar("hello"); // This should be ok var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be error ~~~ -!!! error TS2304: Cannot find name 'foo'. +!!! error TS2691: Cannot find name 'foo'. A type exists with this name, but no value. ==== tests/cases/compiler/aliasOnMergedModuleInterface_0.ts (0 errors) ==== declare module "foo" diff --git a/tests/baselines/reference/assignments.errors.txt b/tests/baselines/reference/assignments.errors.txt index 05bc4ce1794..04a68499690 100644 --- a/tests/baselines/reference/assignments.errors.txt +++ b/tests/baselines/reference/assignments.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): er tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2304: Cannot find name 'I'. +tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. ==== tests/cases/conformance/expressions/valuesAndReferences/assignments.ts (6 errors) ==== @@ -49,4 +49,4 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): er interface I { } I = null; // Error ~ -!!! error TS2304: Cannot find name 'I'. \ No newline at end of file +!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt b/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt index 64b160ea766..084933bae6f 100644 --- a/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt +++ b/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2304: Cannot find name 'A'. +tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2691: Cannot find name 'A'. A type exists with this name, but no value. ==== tests/cases/compiler/classExtendsInterfaceInExpression.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2304: C class C extends factory(A) {} ~ -!!! error TS2304: Cannot find name 'A'. +!!! error TS2691: Cannot find name 'A'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt index 19839e4e544..f64eb864445 100644 --- a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt +++ b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/errorsOnImportedSymbol_1.ts(2,13): error TS2304: Cannot find name 'Sammy'. -tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2304: Cannot find name 'Sammy'. +tests/cases/compiler/errorsOnImportedSymbol_1.ts(2,13): error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. +tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. ==== tests/cases/compiler/errorsOnImportedSymbol_1.ts (2 errors) ==== import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); ~~~~~ -!!! error TS2304: Cannot find name 'Sammy'. +!!! error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. var y = Sammy.Sammy(); ~~~~~ -!!! error TS2304: Cannot find name 'Sammy'. +!!! error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. ==== tests/cases/compiler/errorsOnImportedSymbol_0.ts (0 errors) ==== diff --git a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt index 98e39cf73e7..038449bff1f 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt +++ b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/main.ts(15,1): error TS2304: Cannot find name 'z1'. +tests/cases/compiler/main.ts(15,1): error TS2691: Cannot find name 'z1'. A type exists with this name, but no value. tests/cases/compiler/main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'. tests/cases/compiler/main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'. tests/cases/compiler/main.ts(27,8): error TS1192: Module '"interface"' has no default export. @@ -49,7 +49,7 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses z1.a; ~~ -!!! error TS2304: Cannot find name 'z1'. +!!! error TS2691: Cannot find name 'z1'. A type exists with this name, but no value. z2.a; z3.a; z4.a; diff --git a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt index b0bfac0adfd..dc4c48e29ea 100644 --- a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt +++ b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(3,13): error TS2304: Cannot find name 'Sammy'. -tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error TS2304: Cannot find name 'Sammy'. +tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(3,13): error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. +tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. ==== tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error T import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol ~~~~~ -!!! error TS2304: Cannot find name 'Sammy'. +!!! error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. var y = Sammy(); // error to use interface name as call target ~~~~~ -!!! error TS2304: Cannot find name 'Sammy'. +!!! error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. var z: Sammy; // no error - z is of type interface Sammy from module 'M' var a = new z(); // constructor - no error var b = z(); // call signature - no error diff --git a/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt b/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt index f155140f4dc..208a354619c 100644 --- a/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt +++ b/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2691: Cannot find name 'Foo'. A type exists with this name, but no value. ==== tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2 } var f2: Foo = new Foo(3); ~~~ -!!! error TS2304: Cannot find name 'Foo'. +!!! error TS2691: Cannot find name 'Foo'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt index c043e37575c..0b958ddce21 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2304: Cannot find name 'T'. +tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface. ==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ==== class C extends T { } ~ -!!! error TS2304: Cannot find name 'T'. +!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. interface I extends T { } ~ !!! error TS2312: An interface may only extend a class or another interface. \ No newline at end of file diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index 0d19c6b2b6e..27ee53da1f8 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -10,7 +10,7 @@ tests/cases/compiler/intTypeCheck.ts(103,5): error TS2322: Type '() => void' is Property 'p' is missing in type '() => void'. tests/cases/compiler/intTypeCheck.ts(106,5): error TS2322: Type 'boolean' is not assignable to type 'i1'. tests/cases/compiler/intTypeCheck.ts(106,20): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(106,21): error TS2304: Cannot find name 'i1'. +tests/cases/compiler/intTypeCheck.ts(106,21): error TS2691: Cannot find name 'i1'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(107,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(112,5): error TS2322: Type '{}' is not assignable to type 'i2'. Type '{}' provides no match for the signature '(): any' @@ -21,7 +21,7 @@ tests/cases/compiler/intTypeCheck.ts(115,5): error TS2322: Type 'Base' is not as Type 'Base' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(120,5): error TS2322: Type 'boolean' is not assignable to type 'i2'. tests/cases/compiler/intTypeCheck.ts(120,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(120,22): error TS2304: Cannot find name 'i2'. +tests/cases/compiler/intTypeCheck.ts(120,22): error TS2691: Cannot find name 'i2'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(121,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(126,5): error TS2322: Type '{}' is not assignable to type 'i3'. Type '{}' provides no match for the signature 'new (): any' @@ -33,12 +33,12 @@ tests/cases/compiler/intTypeCheck.ts(131,5): error TS2322: Type '() => void' is Type '() => void' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not assignable to type 'i3'. tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(134,22): error TS2304: Cannot find name 'i3'. +tests/cases/compiler/intTypeCheck.ts(134,22): error TS2691: Cannot find name 'i3'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'. tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(148,22): error TS2304: Cannot find name 'i4'. +tests/cases/compiler/intTypeCheck.ts(148,22): error TS2691: Cannot find name 'i4'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(154,5): error TS2322: Type '{}' is not assignable to type 'i5'. Property 'p' is missing in type '{}'. @@ -51,7 +51,7 @@ tests/cases/compiler/intTypeCheck.ts(159,5): error TS2322: Type '() => void' is Property 'p' is missing in type '() => void'. tests/cases/compiler/intTypeCheck.ts(162,5): error TS2322: Type 'boolean' is not assignable to type 'i5'. tests/cases/compiler/intTypeCheck.ts(162,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(162,22): error TS2304: Cannot find name 'i5'. +tests/cases/compiler/intTypeCheck.ts(162,22): error TS2691: Cannot find name 'i5'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(163,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(168,5): error TS2322: Type '{}' is not assignable to type 'i6'. Type '{}' provides no match for the signature '(): any' @@ -64,7 +64,7 @@ tests/cases/compiler/intTypeCheck.ts(173,5): error TS2322: Type '() => void' is Type 'void' is not assignable to type 'number'. tests/cases/compiler/intTypeCheck.ts(176,5): error TS2322: Type 'boolean' is not assignable to type 'i6'. tests/cases/compiler/intTypeCheck.ts(176,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(176,22): error TS2304: Cannot find name 'i6'. +tests/cases/compiler/intTypeCheck.ts(176,22): error TS2691: Cannot find name 'i6'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(177,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(182,5): error TS2322: Type '{}' is not assignable to type 'i7'. Type '{}' provides no match for the signature 'new (): any' @@ -76,12 +76,12 @@ tests/cases/compiler/intTypeCheck.ts(187,5): error TS2322: Type '() => void' is Type '() => void' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not assignable to type 'i7'. tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(190,22): error TS2304: Cannot find name 'i7'. +tests/cases/compiler/intTypeCheck.ts(190,22): error TS2691: Cannot find name 'i7'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'. tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(204,22): error TS2304: Cannot find name 'i8'. +tests/cases/compiler/intTypeCheck.ts(204,22): error TS2691: Cannot find name 'i8'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -214,7 +214,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2304: Cannot find name 'i1'. +!!! error TS2691: Cannot find name 'i1'. A type exists with this name, but no value. var obj10: i1 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -247,7 +247,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2304: Cannot find name 'i2'. +!!! error TS2691: Cannot find name 'i2'. A type exists with this name, but no value. var obj21: i2 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -281,7 +281,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2304: Cannot find name 'i3'. +!!! error TS2691: Cannot find name 'i3'. A type exists with this name, but no value. var obj32: i3 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -305,7 +305,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2304: Cannot find name 'i4'. +!!! error TS2691: Cannot find name 'i4'. A type exists with this name, but no value. var obj43: i4 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -341,7 +341,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2304: Cannot find name 'i5'. +!!! error TS2691: Cannot find name 'i5'. A type exists with this name, but no value. var obj54: i5 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -377,7 +377,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2304: Cannot find name 'i6'. +!!! error TS2691: Cannot find name 'i6'. A type exists with this name, but no value. var obj65: i6 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -411,7 +411,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2304: Cannot find name 'i7'. +!!! error TS2691: Cannot find name 'i7'. A type exists with this name, but no value. var obj76: i7 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -435,7 +435,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2304: Cannot find name 'i8'. +!!! error TS2691: Cannot find name 'i8'. A type exists with this name, but no value. var obj87: i8 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt b/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt index 4be4d858d7b..48e55e299a1 100644 --- a/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt +++ b/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/interfaceNameAsIdentifier.ts(4,1): error TS2304: Cannot find name 'C'. +tests/cases/compiler/interfaceNameAsIdentifier.ts(4,1): error TS2691: Cannot find name 'C'. A type exists with this name, but no value. tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2304: Cannot find name 'm2'. @@ -8,7 +8,7 @@ tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2304: Cannot fi } C(); ~ -!!! error TS2304: Cannot find name 'C'. +!!! error TS2691: Cannot find name 'C'. A type exists with this name, but no value. module m2 { export interface C { diff --git a/tests/baselines/reference/interfaceNaming1.errors.txt b/tests/baselines/reference/interfaceNaming1.errors.txt index 99e0b5c02fa..850b458913c 100644 --- a/tests/baselines/reference/interfaceNaming1.errors.txt +++ b/tests/baselines/reference/interfaceNaming1.errors.txt @@ -1,19 +1,19 @@ -tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2304: Cannot find name 'interface'. +tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2691: Cannot find name 'interface'. A type exists with this name, but no value. tests/cases/compiler/interfaceNaming1.ts(1,11): error TS1005: ';' expected. -tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2304: Cannot find name 'interface'. +tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2691: Cannot find name 'interface'. A type exists with this name, but no value. tests/cases/compiler/interfaceNaming1.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ==== tests/cases/compiler/interfaceNaming1.ts (4 errors) ==== interface { } ~~~~~~~~~ -!!! error TS2304: Cannot find name 'interface'. +!!! error TS2691: Cannot find name 'interface'. A type exists with this name, but no value. ~ !!! error TS1005: ';' expected. interface interface{ } interface & { } ~~~~~~~~~ -!!! error TS2304: Cannot find name 'interface'. +!!! error TS2691: Cannot find name 'interface'. A type exists with this name, but no value. ~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt b/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt index afe7472570d..522799766bb 100644 --- a/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt +++ b/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(5,12): error TS2503: Cannot find namespace 'V'. tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(11,12): error TS2503: Cannot find namespace 'C'. -tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(23,12): error TS2503: Cannot find namespace 'I'. +tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(23,12): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. ==== tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts (3 errors) ==== @@ -32,5 +32,5 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIde import i = I; ~ -!!! error TS2503: Cannot find namespace 'I'. +!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/invalidUndefinedAssignments.errors.txt b/tests/baselines/reference/invalidUndefinedAssignments.errors.txt index 5eff2e7ff1a..d04607455fc 100644 --- a/tests/baselines/reference/invalidUndefinedAssignments.errors.txt +++ b/tests/baselines/reference/invalidUndefinedAssignments.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(4,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(9,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2304: Cannot find name 'I'. +tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression. @@ -28,7 +28,7 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.t g = x; I = x; ~ -!!! error TS2304: Cannot find name 'I'. +!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt index f796092fb14..48e4d1f9c9f 100644 --- a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt +++ b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt @@ -1,7 +1,7 @@ error TS2318: Cannot find global type 'Boolean'. error TS2318: Cannot find global type 'IArguments'. error TS2318: Cannot find global type 'Number'. -tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2304: Cannot find name 'Array'. +tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2691: Cannot find name 'Array'. A type exists with this name, but no value. !!! error TS2318: Cannot find global type 'Boolean'. @@ -13,7 +13,7 @@ tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib function f(x: number, y: number, z: number) { return Array.from(arguments); ~~~~~ -!!! error TS2304: Cannot find name 'Array'. +!!! error TS2691: Cannot find name 'Array'. A type exists with this name, but no value. } f(1, 2, 3); diff --git a/tests/baselines/reference/newOperator.errors.txt b/tests/baselines/reference/newOperator.errors.txt index 7998217f2e5..00d33b13723 100644 --- a/tests/baselines/reference/newOperator.errors.txt +++ b/tests/baselines/reference/newOperator.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/newOperator.ts(3,13): error TS2304: Cannot find name 'ifc'. +tests/cases/compiler/newOperator.ts(3,13): error TS2691: Cannot find name 'ifc'. A type exists with this name, but no value. tests/cases/compiler/newOperator.ts(10,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/newOperator.ts(11,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/newOperator.ts(12,5): error TS2304: Cannot find name 'string'. @@ -17,7 +17,7 @@ tests/cases/compiler/newOperator.ts(45,23): error TS1150: 'new T[]' cannot be us // Attempting to 'new' an interface yields poor error var i = new ifc(); ~~~ -!!! error TS2304: Cannot find name 'ifc'. +!!! error TS2691: Cannot find name 'ifc'. A type exists with this name, but no value. // Parens are optional var x = new Date; diff --git a/tests/baselines/reference/reservedNamesInAliases.errors.txt b/tests/baselines/reference/reservedNamesInAliases.errors.txt index 5c17158053e..c999841a322 100644 --- a/tests/baselines/reference/reservedNamesInAliases.errors.txt +++ b/tests/baselines/reference/reservedNamesInAliases.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(5,6): error tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error TS2304: Cannot find name 'type'. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected. -tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2304: Cannot find name 'I'. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. ==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (8 errors) ==== @@ -30,4 +30,4 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error ~ !!! error TS1109: Expression expected. ~ -!!! error TS2304: Cannot find name 'I'. \ No newline at end of file +!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/returnTypeParameter.errors.txt b/tests/baselines/reference/returnTypeParameter.errors.txt index 1bd9f6a63f6..cfb5d4759ca 100644 --- a/tests/baselines/reference/returnTypeParameter.errors.txt +++ b/tests/baselines/reference/returnTypeParameter.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/returnTypeParameter.ts(1,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2304: Cannot find name 'T'. +tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. ==== tests/cases/compiler/returnTypeParameter.ts (2 errors) ==== @@ -8,4 +8,4 @@ tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2304: Cannot find nam !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function f2(a: T): T { return T; } // bug was that this satisfied the return statement requirement ~ -!!! error TS2304: Cannot find name 'T'. \ No newline at end of file +!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt index 0b868960bed..a1f75152ddf 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt @@ -16,9 +16,9 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,9): error TS tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,17): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(23,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2503: Cannot find namespace 'public'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2691: Cannot find name 'public'. A type exists with this name, but no value. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2503: Cannot find namespace 'public'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2691: Cannot find name 'public'. A type exists with this name, but no value. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS2304: Cannot find name 'package'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. @@ -88,12 +88,12 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ -!!! error TS2503: Cannot find namespace 'public'. +!!! error TS2691: Cannot find name 'public'. A type exists with this name, but no value. class F1 implements public.private.implements { } ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ -!!! error TS2503: Cannot find namespace 'public'. +!!! error TS2691: Cannot find name 'public'. A type exists with this name, but no value. class G extends package { } ~~~~~~~ !!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. diff --git a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt index dec7f7f2a4a..2f4d0dd46b9 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2304: Cannot find name 'T'. +tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface. ==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ==== class C extends T {} ~ -!!! error TS2304: Cannot find name 'T'. +!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. class C2 implements T {} ~ !!! error TS2422: A class may only implement another class or interface. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseType.errors.txt b/tests/baselines/reference/typeParameterAsBaseType.errors.txt index 835b2369948..7f56299bd6e 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseType.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2304: Cannot find name 'T'. -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2304: Cannot find name 'U'. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2691: Cannot find name 'U'. A type exists with this name, but no value. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface. @@ -10,10 +10,10 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e class C extends T { } ~ -!!! error TS2304: Cannot find name 'T'. +!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. class C2 extends U { } ~ -!!! error TS2304: Cannot find name 'U'. +!!! error TS2691: Cannot find name 'U'. A type exists with this name, but no value. interface I extends T { } ~ diff --git a/tests/baselines/reference/typeUsedAsValueError.errors.txt b/tests/baselines/reference/typeUsedAsValueError.errors.txt new file mode 100644 index 00000000000..af637231585 --- /dev/null +++ b/tests/baselines/reference/typeUsedAsValueError.errors.txt @@ -0,0 +1,50 @@ +tests/cases/compiler/typeUsedAsValueError.ts(16,11): error TS2691: Cannot find name 'Interface'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(17,11): error TS2304: Cannot find name 'InterfaceNotFound'. +tests/cases/compiler/typeUsedAsValueError.ts(18,13): error TS2691: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(19,16): error TS2691: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(20,16): error TS2304: Cannot find name 'TypeAliasForSomeClassNotFound'. +tests/cases/compiler/typeUsedAsValueError.ts(21,11): error TS2691: Cannot find name 'someType'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(22,17): error TS2691: Cannot find name 'someType'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(23,17): error TS2304: Cannot find name 'someTypeNotFound'. + + +==== tests/cases/compiler/typeUsedAsValueError.ts (8 errors) ==== + interface Interface { + + } + + class SomeClass { + + } + + type TypeAliasForSomeClass = SomeClass; + type someType = { x: number }; + + function acceptsSomeType(a: someType) { + + } + + let one = Interface; + ~~~~~~~~~ +!!! error TS2691: Cannot find name 'Interface'. A type exists with this name, but no value. + let two = InterfaceNotFound; + ~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'InterfaceNotFound'. + let three = TypeAliasForSomeClass; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2691: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. + let four = new TypeAliasForSomeClass(); + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2691: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. + let five = new TypeAliasForSomeClassNotFound(); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'TypeAliasForSomeClassNotFound'. + let six = someType; + ~~~~~~~~ +!!! error TS2691: Cannot find name 'someType'. A type exists with this name, but no value. + acceptsSomeType(someType); + ~~~~~~~~ +!!! error TS2691: Cannot find name 'someType'. A type exists with this name, but no value. + acceptsSomeType(someTypeNotFound); + ~~~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'someTypeNotFound'. \ No newline at end of file diff --git a/tests/baselines/reference/typeUsedAsValueError.js b/tests/baselines/reference/typeUsedAsValueError.js new file mode 100644 index 00000000000..d45299564c0 --- /dev/null +++ b/tests/baselines/reference/typeUsedAsValueError.js @@ -0,0 +1,41 @@ +//// [typeUsedAsValueError.ts] +interface Interface { + +} + +class SomeClass { + +} + +type TypeAliasForSomeClass = SomeClass; +type someType = { x: number }; + +function acceptsSomeType(a: someType) { + +} + +let one = Interface; +let two = InterfaceNotFound; +let three = TypeAliasForSomeClass; +let four = new TypeAliasForSomeClass(); +let five = new TypeAliasForSomeClassNotFound(); +let six = someType; +acceptsSomeType(someType); +acceptsSomeType(someTypeNotFound); + +//// [typeUsedAsValueError.js] +var SomeClass = (function () { + function SomeClass() { + } + return SomeClass; +}()); +function acceptsSomeType(a) { +} +var one = Interface; +var two = InterfaceNotFound; +var three = TypeAliasForSomeClass; +var four = new TypeAliasForSomeClass(); +var five = new TypeAliasForSomeClassNotFound(); +var six = someType; +acceptsSomeType(someType); +acceptsSomeType(someTypeNotFound); diff --git a/tests/baselines/reference/typeofSimple.errors.txt b/tests/baselines/reference/typeofSimple.errors.txt index 845a9fbbce3..08bbb8ff10c 100644 --- a/tests/baselines/reference/typeofSimple.errors.txt +++ b/tests/baselines/reference/typeofSimple.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeofSimple.ts(3,5): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/typeofSimple.ts(8,21): error TS2304: Cannot find name 'J'. +tests/cases/compiler/typeofSimple.ts(8,21): error TS2691: Cannot find name 'J'. A type exists with this name, but no value. ==== tests/cases/compiler/typeofSimple.ts (2 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/typeofSimple.ts(8,21): error TS2304: Cannot find name 'J'. var numberJ: typeof J; //Error, cannot reference type in typeof ~ -!!! error TS2304: Cannot find name 'J'. +!!! error TS2691: Cannot find name 'J'. A type exists with this name, but no value. var numberI: I; var fun: () => I; diff --git a/tests/baselines/reference/typeofTypeParameter.errors.txt b/tests/baselines/reference/typeofTypeParameter.errors.txt index f610b4696ca..7843ee38cc6 100644 --- a/tests/baselines/reference/typeofTypeParameter.errors.txt +++ b/tests/baselines/reference/typeofTypeParameter.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts(3,19): error TS2304: Cannot find name 'T'. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts(3,19): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. ==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts var a: typeof x; var y: typeof T; ~ -!!! error TS2304: Cannot find name 'T'. +!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. return a; } \ No newline at end of file diff --git a/tests/baselines/reference/validNullAssignments.errors.txt b/tests/baselines/reference/validNullAssignments.errors.txt index 057d6ce4791..7cf05cd9f6c 100644 --- a/tests/baselines/reference/validNullAssignments.errors.txt +++ b/tests/baselines/reference/validNullAssignments.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/primitives/null/validNullAssignments.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(15,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/primitives/null/validNullAssignments.ts(20,1): error TS2304: Cannot find name 'I'. +tests/cases/conformance/types/primitives/null/validNullAssignments.ts(20,1): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(30,1): error TS2364: Invalid left-hand side of assignment expression. @@ -31,7 +31,7 @@ tests/cases/conformance/types/primitives/null/validNullAssignments.ts(30,1): err g = null; // ok I = null; // error ~ -!!! error TS2304: Cannot find name 'I'. +!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. module M { export var x = 1; } M = null; // error diff --git a/tests/cases/compiler/typeUsedAsValueError.ts b/tests/cases/compiler/typeUsedAsValueError.ts index 0e0eceb6c3b..16c1e396d70 100644 --- a/tests/cases/compiler/typeUsedAsValueError.ts +++ b/tests/cases/compiler/typeUsedAsValueError.ts @@ -2,20 +2,22 @@ interface Interface { } -class Class { +class SomeClass { } -type typeAliasForClass = Class; -type typeAliasForNumber = number; -type objectType = { x: number }; +type TypeAliasForSomeClass = SomeClass; +type someType = { x: number }; -function func(a: number) { +function acceptsSomeType(a: someType) { } let one = Interface; -let two = typeAliasForClass; -let three = typeAliasForNumber; -let four = objectType; -func(typeAliasForNumber); \ No newline at end of file +let two = InterfaceNotFound; +let three = TypeAliasForSomeClass; +let four = new TypeAliasForSomeClass(); +let five = new TypeAliasForSomeClassNotFound(); +let six = someType; +acceptsSomeType(someType); +acceptsSomeType(someTypeNotFound); \ No newline at end of file From fde0a2898871ff1f7e07766bf8d183e6cdd7911e Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Mon, 15 Aug 2016 02:23:39 -0400 Subject: [PATCH 150/508] Preserve 'Cannot find namespace' errors --- src/compiler/checker.ts | 2 +- .../reference/invalidImportAliasIdentifiers.errors.txt | 4 ++-- .../strictModeReservedWordInClassDeclaration.errors.txt | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 87569ce83e2..18da3916652 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -994,7 +994,7 @@ namespace ts { const strictlyValueMeanings = SymbolFlags.Value & ~SymbolFlags.Type; const strictlyTypeMeanings = SymbolFlags.Type & ~SymbolFlags.Value; - if (!(meaning & strictlyValueMeanings)) { + if (!(meaning & strictlyValueMeanings) || meaning & SymbolFlags.NamespaceModule) { return false; } diff --git a/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt b/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt index 522799766bb..afe7472570d 100644 --- a/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt +++ b/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(5,12): error TS2503: Cannot find namespace 'V'. tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(11,12): error TS2503: Cannot find namespace 'C'. -tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(23,12): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(23,12): error TS2503: Cannot find namespace 'I'. ==== tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts (3 errors) ==== @@ -32,5 +32,5 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIde import i = I; ~ -!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. +!!! error TS2503: Cannot find namespace 'I'. \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt index a1f75152ddf..0b868960bed 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt @@ -16,9 +16,9 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,9): error TS tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,17): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(23,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2691: Cannot find name 'public'. A type exists with this name, but no value. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2503: Cannot find namespace 'public'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2691: Cannot find name 'public'. A type exists with this name, but no value. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2503: Cannot find namespace 'public'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS2304: Cannot find name 'package'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. @@ -88,12 +88,12 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ -!!! error TS2691: Cannot find name 'public'. A type exists with this name, but no value. +!!! error TS2503: Cannot find namespace 'public'. class F1 implements public.private.implements { } ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ -!!! error TS2691: Cannot find name 'public'. A type exists with this name, but no value. +!!! error TS2503: Cannot find namespace 'public'. class G extends package { } ~~~~~~~ !!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. From 54735edc72d18966e264132a5be00465c9568e5d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 07:40:25 -0700 Subject: [PATCH 151/508] Use lowercase names for type reference directives --- src/compiler/program.ts | 7 ++++--- tests/baselines/reference/typingsLookup3.js | 13 +++++++++++++ tests/baselines/reference/typingsLookup3.symbols | 12 ++++++++++++ .../baselines/reference/typingsLookup3.trace.json | 12 ++++++++++++ tests/baselines/reference/typingsLookup3.types | 12 ++++++++++++ tests/cases/conformance/typings/typingsLookup3.ts | 14 ++++++++++++++ 6 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/reference/typingsLookup3.js create mode 100644 tests/baselines/reference/typingsLookup3.symbols create mode 100644 tests/baselines/reference/typingsLookup3.trace.json create mode 100644 tests/baselines/reference/typingsLookup3.types create mode 100644 tests/cases/conformance/typings/typingsLookup3.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index eb50548750d..5befec5ebc0 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2012,15 +2012,16 @@ namespace ts { } function processTypeReferenceDirectives(file: SourceFile) { - const typeDirectives = map(file.typeReferenceDirectives, l => l.fileName); + const typeDirectives = map(file.typeReferenceDirectives, ref => ref.fileName.toLocaleLowerCase()); const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.fileName); for (let i = 0; i < typeDirectives.length; i++) { const ref = file.typeReferenceDirectives[i]; const resolvedTypeReferenceDirective = resolutions[i]; // store resolved type directive on the file - setResolvedTypeReferenceDirective(file, ref.fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(ref.fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + const fileName = ref.fileName.toLocaleLowerCase(); + setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); } } diff --git a/tests/baselines/reference/typingsLookup3.js b/tests/baselines/reference/typingsLookup3.js new file mode 100644 index 00000000000..b3be036b4ae --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.js @@ -0,0 +1,13 @@ +//// [tests/cases/conformance/typings/typingsLookup3.ts] //// + +//// [index.d.ts] +declare var $: { x: any }; + +//// [a.ts] +/// +$.x; + + +//// [a.js] +/// +$.x; diff --git a/tests/baselines/reference/typingsLookup3.symbols b/tests/baselines/reference/typingsLookup3.symbols new file mode 100644 index 00000000000..e641afb183b --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.symbols @@ -0,0 +1,12 @@ +=== /a.ts === +/// +$.x; +>$.x : Symbol(x, Decl(index.d.ts, 0, 16)) +>$ : Symbol($, Decl(index.d.ts, 0, 11)) +>x : Symbol(x, Decl(index.d.ts, 0, 16)) + +=== /node_modules/@types/jquery/index.d.ts === +declare var $: { x: any }; +>$ : Symbol($, Decl(index.d.ts, 0, 11)) +>x : Symbol(x, Decl(index.d.ts, 0, 16)) + diff --git a/tests/baselines/reference/typingsLookup3.trace.json b/tests/baselines/reference/typingsLookup3.trace.json new file mode 100644 index 00000000000..83b0e91d6c7 --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.trace.json @@ -0,0 +1,12 @@ +[ + "======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup3.types b/tests/baselines/reference/typingsLookup3.types new file mode 100644 index 00000000000..f57a974077e --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.types @@ -0,0 +1,12 @@ +=== /a.ts === +/// +$.x; +>$.x : any +>$ : { x: any; } +>x : any + +=== /node_modules/@types/jquery/index.d.ts === +declare var $: { x: any }; +>$ : { x: any; } +>x : any + diff --git a/tests/cases/conformance/typings/typingsLookup3.ts b/tests/cases/conformance/typings/typingsLookup3.ts new file mode 100644 index 00000000000..a0bb15476b9 --- /dev/null +++ b/tests/cases/conformance/typings/typingsLookup3.ts @@ -0,0 +1,14 @@ +// @traceResolution: true +// @noImplicitReferences: true +// @currentDirectory: / +// This tests that `types` references are automatically lowercased. + +// @filename: /tsconfig.json +{ "files": "a.ts" } + +// @filename: /node_modules/@types/jquery/index.d.ts +declare var $: { x: any }; + +// @filename: /a.ts +/// +$.x; From 592805f486e9ccb755f0e286413af8343e4d0a3a Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 07:56:45 -0700 Subject: [PATCH 152/508] Use proper response codes in web tests --- tests/webTestServer.ts | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index ac5f046c1dd..4d2cb7d4672 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -117,19 +117,21 @@ function handleResolutionRequest(filePath: string, res: http.ServerResponse) { let resolvedPath = path.resolve(filePath, ""); resolvedPath = resolvedPath.substring(resolvedPath.indexOf("tests")); resolvedPath = switchToForwardSlashes(resolvedPath); - send("success", res, resolvedPath); - return; + send(ResponseCode.Success, res, resolvedPath); } -function send(result: "fail", res: http.ServerResponse, contents: string, contentType?: string): void; -function send(result: "success", res: http.ServerResponse, contents: string, contentType?: string): void; -function send(result: "unknown", res: http.ServerResponse, contents: string, contentType?: string): void; -function send(result: string, res: http.ServerResponse, contents: string, contentType?: string): void -function send(result: string, res: http.ServerResponse, contents: string, contentType = "binary"): void { - const responseCode = result === "success" ? 200 : result === "fail" ? 500 : result === "unknown" ? 404 : parseInt(result); +const enum ResponseCode { + Success = 200, + BadRequest = 400, + NotFound = 404, + MethodNotAllowed = 405, + PayloadTooLarge = 413, + Fail = 500 +} + +function send(responseCode: number, res: http.ServerResponse, contents: string, contentType = "binary"): void { res.writeHead(responseCode, { "Content-Type": contentType }); res.end(contents); - return; } // Reads the data from a post request and passes it to the given callback @@ -142,7 +144,7 @@ function processPost(req: http.ServerRequest, res: http.ServerResponse, callback queryData += data; if (queryData.length > 1e8) { queryData = ""; - send("413", res, undefined); + send(ResponseCode.PayloadTooLarge, res, undefined); console.log("ERROR: destroying connection"); req.connection.destroy(); } @@ -155,7 +157,7 @@ function processPost(req: http.ServerRequest, res: http.ServerResponse, callback } else { - send("405", res, undefined); + send(ResponseCode.MethodNotAllowed, res, undefined); } } @@ -201,16 +203,16 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons switch (operation) { case RequestType.GetDir: const filesInFolder = dir(reqPath, "", { recursive: true }); - send("success", res, filesInFolder.join(",")); + send(ResponseCode.Success, res, filesInFolder.join(",")); break; case RequestType.GetFile: fs.readFile(reqPath, (err, file) => { const contentType = contentTypeForExtension(path.extname(reqPath)); if (err) { - send("fail", res, err.message, contentType); + send(ResponseCode.NotFound, res, err.message, contentType); } else { - send("success", res, file, contentType); + send(ResponseCode.Success, res, file, contentType); } }); break; @@ -222,33 +224,33 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons processPost(req, res, (data) => { writeFile(reqPath, data, { recursive: true }); }); - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.WriteDir: fs.mkdirSync(reqPath); - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.DeleteFile: if (fs.existsSync(reqPath)) { fs.unlinkSync(reqPath); } - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.DeleteDir: if (fs.existsSync(reqPath)) { fs.rmdirSync(reqPath); } - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.AppendFile: processPost(req, res, (data) => { fs.appendFileSync(reqPath, data); }); - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.Unknown: default: - send("unknown", res, undefined); + send(ResponseCode.BadRequest, res, undefined); break; } From ccf5bab8ad0a99c099ea21568ae602e6db165fbe Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 08:51:15 -0700 Subject: [PATCH 153/508] Treat ambient shorthand declarations as explicit uses of the `any` type --- src/compiler/checker.ts | 5 ----- .../reference/ambientShorthand_isImplicitAny.errors.txt | 8 -------- .../baselines/reference/ambientShorthand_isImplicitAny.js | 5 ----- .../conformance/ambient/ambientShorthand_isImplicitAny.ts | 2 -- 4 files changed, 20 deletions(-) delete mode 100644 tests/baselines/reference/ambientShorthand_isImplicitAny.errors.txt delete mode 100644 tests/baselines/reference/ambientShorthand_isImplicitAny.js delete mode 100644 tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 85e33c5e4a1..bf721a96bc3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17034,11 +17034,6 @@ namespace ts { } } - if (compilerOptions.noImplicitAny && !node.body) { - // Ambient shorthand module is an implicit any - reportImplicitAnyError(node, anyType); - } - if (node.body) { checkSourceElement(node.body); if (!isGlobalScopeAugmentation(node)) { diff --git a/tests/baselines/reference/ambientShorthand_isImplicitAny.errors.txt b/tests/baselines/reference/ambientShorthand_isImplicitAny.errors.txt deleted file mode 100644 index 875a656202d..00000000000 --- a/tests/baselines/reference/ambientShorthand_isImplicitAny.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts(1,16): error TS7005: Variable '"jquery"' implicitly has an 'any' type. - - -==== tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts (1 errors) ==== - declare module "jquery"; - ~~~~~~~~ -!!! error TS7005: Variable '"jquery"' implicitly has an 'any' type. - \ No newline at end of file diff --git a/tests/baselines/reference/ambientShorthand_isImplicitAny.js b/tests/baselines/reference/ambientShorthand_isImplicitAny.js deleted file mode 100644 index ab05d2a9979..00000000000 --- a/tests/baselines/reference/ambientShorthand_isImplicitAny.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [ambientShorthand_isImplicitAny.ts] -declare module "jquery"; - - -//// [ambientShorthand_isImplicitAny.js] diff --git a/tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts b/tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts deleted file mode 100644 index bf7de709ef2..00000000000 --- a/tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts +++ /dev/null @@ -1,2 +0,0 @@ -// @noImplicitAny: true -declare module "jquery"; From 2eb159e269f79f1c7d86723b2a0d9c44739627fd Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 10:34:07 -0700 Subject: [PATCH 154/508] Rename 'find' functions --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 9 ++++++--- src/compiler/utilities.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 583ae5a1f35..37f13dbf807 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1032,7 +1032,7 @@ namespace ts { } function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration { - return find(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); + return findMap(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); } function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration): Symbol { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 36db85061b0..d2ea69b304d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -110,7 +110,7 @@ namespace ts { } /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ - export function tryFind(array: T[], predicate: (element: T, index: number) => boolean): T | undefined { + export function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined { for (let i = 0, len = array.length; i < len; i++) { const value = array[i]; if (predicate(value, i)) { @@ -120,8 +120,11 @@ namespace ts { return undefined; } - /** Like `forEach`, but assumes existence of array and fails if no truthy value is found. */ - export function find(array: T[], callback: (element: T, index: number) => U | undefined): U { + /** + * Returns the first truthy result of `callback`, or else fails. + * This is like `forEach`, but never returns undefined. + */ + export function findMap(array: T[], callback: (element: T, index: number) => U | undefined): U { for (let i = 0, len = array.length; i < len; i++) { const result = callback(array[i], i); if (result) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0598c34bd7b..8b32d5351ea 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2715,7 +2715,7 @@ namespace ts { /** Return ".ts" or ".tsx" if that is the extension. */ export function tryExtractTypeScriptExtension(fileName: string): string | undefined { - return tryFind(supportedTypescriptExtensionsWithDtsFirst, extension => fileExtensionIs(fileName, extension)); + return find(supportedTypescriptExtensionsWithDtsFirst, extension => fileExtensionIs(fileName, extension)); } // Must have '.d.ts' first because if '.ts' goes first, that will be detected as the extension instead of '.d.ts'. const supportedTypescriptExtensionsWithDtsFirst = supportedTypeScriptExtensions.slice().reverse(); From a1dad91120378406332af99c81a5e9946e08e13e Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 15 Aug 2016 10:45:46 -0700 Subject: [PATCH 155/508] Parallel linting (#10313) * A perilous thing, a parallel lint * Use work queue rather than scheduling work * Dont read files for lint on main thread * Fix style --- Gulpfile.ts | 98 ++++++++++++++++----------- Jakefile.js | 142 ++++++++++++++++----------------------- scripts/parallel-lint.js | 45 +++++++++++++ 3 files changed, 162 insertions(+), 123 deletions(-) create mode 100644 scripts/parallel-lint.js diff --git a/Gulpfile.ts b/Gulpfile.ts index d677b042250..2d17325c4d8 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -34,7 +34,6 @@ import through2 = require("through2"); import merge2 = require("merge2"); import intoStream = require("into-stream"); import * as os from "os"; -import Linter = require("tslint"); import fold = require("travis-fold"); const gulp = helpMaker(originalGulp); const mochaParallel = require("./scripts/mocha-parallel.js"); @@ -929,26 +928,6 @@ gulp.task("build-rules", "Compiles tslint rules to js", () => { .pipe(gulp.dest(dest)); }); -function getLinterOptions() { - return { - configuration: require("./tslint.json"), - formatter: "prose", - formattersDirectory: undefined, - rulesDirectory: "built/local/tslint" - }; -} - -function lintFileContents(options, path, contents) { - const ll = new Linter(path, contents, options); - console.log("Linting '" + path + "'."); - return ll.lint(); -} - -function lintFile(options, path) { - const contents = fs.readFileSync(path, "utf8"); - return lintFileContents(options, path, contents); -} - const lintTargets = [ "Gulpfile.ts", "src/compiler/**/*.ts", @@ -960,29 +939,72 @@ const lintTargets = [ "tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively ]; +function sendNextFile(files: {path: string}[], child: cp.ChildProcess, callback: (failures: number) => void, failures: number) { + const file = files.pop(); + if (file) { + console.log(`Linting '${file.path}'.`); + child.send({ kind: "file", name: file.path }); + } + else { + child.send({ kind: "close" }); + callback(failures); + } +} + +function spawnLintWorker(files: {path: string}[], callback: (failures: number) => void) { + const child = cp.fork("./scripts/parallel-lint"); + let failures = 0; + child.on("message", function(data) { + switch (data.kind) { + case "result": + if (data.failures > 0) { + failures += data.failures; + console.log(data.output); + } + sendNextFile(files, child, callback, failures); + break; + case "error": + console.error(data.error); + failures++; + sendNextFile(files, child, callback, failures); + break; + } + }); + sendNextFile(files, child, callback, failures); +} gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => { const fileMatcher = RegExp(cmdLineOptions["files"]); - const lintOptions = getLinterOptions(); - let failed = 0; if (fold.isTravis()) console.log(fold.start("lint")); - return gulp.src(lintTargets) - .pipe(insert.transform((contents, file) => { - if (!fileMatcher.test(file.path)) return contents; - const result = lintFile(lintOptions, file.path); - if (result.failureCount > 0) { - console.log(result.output); - failed += result.failureCount; + + const files: {stat: fs.Stats, path: string}[] = []; + return gulp.src(lintTargets, { read: false }) + .pipe(through2.obj((chunk, enc, cb) => { + files.push(chunk); + cb(); + }, (cb) => { + files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size); + const workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; + for (let i = 0; i < workerCount; i++) { + spawnLintWorker(files, finished); } - return contents; // TODO (weswig): Automatically apply fixes? :3 - })) - .on("end", () => { - if (fold.isTravis()) console.log(fold.end("lint")); - if (failed > 0) { - console.error("Linter errors."); - process.exit(1); + + let completed = 0; + let failures = 0; + function finished(fails) { + completed++; + failures += fails; + if (completed === workerCount) { + if (fold.isTravis()) console.log(fold.end("lint")); + if (failures > 0) { + throw new Error(`Linter errors: ${failures}`); + } + else { + cb(); + } + } } - }); + })); }); diff --git a/Jakefile.js b/Jakefile.js index 01aac82a47a..e4aaf330dc7 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -4,7 +4,6 @@ var fs = require("fs"); var os = require("os"); var path = require("path"); var child_process = require("child_process"); -var Linter = require("tslint"); var fold = require("travis-fold"); var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel; @@ -1054,36 +1053,6 @@ task("build-rules-end", [] , function() { if (fold.isTravis()) console.log(fold.end("build-rules")); }); -function getLinterOptions() { - return { - configuration: require("./tslint.json"), - formatter: "prose", - formattersDirectory: undefined, - rulesDirectory: "built/local/tslint" - }; -} - -function lintFileContents(options, path, contents) { - var ll = new Linter(path, contents, options); - console.log("Linting '" + path + "'."); - return ll.lint(); -} - -function lintFile(options, path) { - var contents = fs.readFileSync(path, "utf8"); - return lintFileContents(options, path, contents); -} - -function lintFileAsync(options, path, cb) { - fs.readFile(path, "utf8", function(err, contents) { - if (err) { - return cb(err); - } - var result = lintFileContents(options, path, contents); - cb(undefined, result); - }); -} - var lintTargets = compilerSources .concat(harnessSources) // Other harness sources @@ -1094,75 +1063,78 @@ var lintTargets = compilerSources .concat(["Gulpfile.ts"]) .concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]); +function sendNextFile(files, child, callback, failures) { + var file = files.pop(); + if (file) { + console.log("Linting '" + file + "'."); + child.send({kind: "file", name: file}); + } + else { + child.send({kind: "close"}); + callback(failures); + } +} + +function spawnLintWorker(files, callback) { + var child = child_process.fork("./scripts/parallel-lint"); + var failures = 0; + child.on("message", function(data) { + switch (data.kind) { + case "result": + if (data.failures > 0) { + failures += data.failures; + console.log(data.output); + } + sendNextFile(files, child, callback, failures); + break; + case "error": + console.error(data.error); + failures++; + sendNextFile(files, child, callback, failures); + break; + } + }); + sendNextFile(files, child, callback, failures); +} desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex"); task("lint", ["build-rules"], function() { if (fold.isTravis()) console.log(fold.start("lint")); var startTime = mark(); - var lintOptions = getLinterOptions(); var failed = 0; var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || ""); var done = {}; for (var i in lintTargets) { var target = lintTargets[i]; if (!done[target] && fileMatcher.test(target)) { - var result = lintFile(lintOptions, target); - if (result.failureCount > 0) { - console.log(result.output); - failed += result.failureCount; - } - done[target] = true; + done[target] = fs.statSync(target).size; } } - measure(startTime); - if (fold.isTravis()) console.log(fold.end("lint")); - if (failed > 0) { - fail('Linter errors.', failed); - } -}); -/** - * This is required because file watches on Windows get fires _twice_ - * when a file changes on some node/windows version configuations - * (node v4 and win 10, for example). By not running a lint for a file - * which already has a pending lint, we avoid duplicating our work. - * (And avoid printing duplicate results!) - */ -var lintSemaphores = {}; + var workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; -function lintWatchFile(filename) { - fs.watch(filename, {persistent: true}, function(event) { - if (event !== "change") { - return; - } - - if (!lintSemaphores[filename]) { - lintSemaphores[filename] = true; - lintFileAsync(getLinterOptions(), filename, function(err, result) { - delete lintSemaphores[filename]; - if (err) { - console.log(err); - return; - } - if (result.failureCount > 0) { - console.log("***Lint failure***"); - for (var i = 0; i < result.failures.length; i++) { - var failure = result.failures[i]; - var start = failure.startPosition.lineAndCharacter; - var end = failure.endPosition.lineAndCharacter; - console.log("warning " + filename + " (" + (start.line + 1) + "," + (start.character + 1) + "," + (end.line + 1) + "," + (end.character + 1) + "): " + failure.failure); - } - console.log("*** Total " + result.failureCount + " failures."); - } - }); - } + var names = Object.keys(done).sort(function(namea, nameb) { + return done[namea] - done[nameb]; }); -} -desc("Watches files for changes to rerun a lint pass"); -task("lint-server", ["build-rules"], function() { - console.log("Watching ./src for changes to linted files"); - for (var i = 0; i < lintTargets.length; i++) { - lintWatchFile(lintTargets[i]); + for (var i = 0; i < workerCount; i++) { + spawnLintWorker(names, finished); } -}); + + var completed = 0; + var failures = 0; + function finished(fails) { + completed++; + failures += fails; + if (completed === workerCount) { + measure(startTime); + if (fold.isTravis()) console.log(fold.end("lint")); + if (failures > 0) { + fail('Linter errors.', failed); + } + else { + complete(); + } + } + } +}, {async: true}); diff --git a/scripts/parallel-lint.js b/scripts/parallel-lint.js new file mode 100644 index 00000000000..a9aec06c2df --- /dev/null +++ b/scripts/parallel-lint.js @@ -0,0 +1,45 @@ +var Linter = require("tslint"); +var fs = require("fs"); + +function getLinterOptions() { + return { + configuration: require("../tslint.json"), + formatter: "prose", + formattersDirectory: undefined, + rulesDirectory: "built/local/tslint" + }; +} + +function lintFileContents(options, path, contents) { + var ll = new Linter(path, contents, options); + return ll.lint(); +} + +function lintFileAsync(options, path, cb) { + fs.readFile(path, "utf8", function (err, contents) { + if (err) { + return cb(err); + } + var result = lintFileContents(options, path, contents); + cb(undefined, result); + }); +} + +process.on("message", function (data) { + switch (data.kind) { + case "file": + var target = data.name; + var lintOptions = getLinterOptions(); + lintFileAsync(lintOptions, target, function (err, result) { + if (err) { + process.send({ kind: "error", error: err.toString() }); + return; + } + process.send({ kind: "result", failures: result.failureCount, output: result.output }); + }); + break; + case "close": + process.exit(0); + break; + } +}); \ No newline at end of file From 2d1b68fdac39cf65fff40125d7d6cc10ebfb4ecb Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Mon, 15 Aug 2016 11:00:57 -0700 Subject: [PATCH 156/508] Fix the style fix (#10344) --- Gulpfile.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 2d17325c4d8..2718669b1f7 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -977,13 +977,13 @@ gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: const fileMatcher = RegExp(cmdLineOptions["files"]); if (fold.isTravis()) console.log(fold.start("lint")); - const files: {stat: fs.Stats, path: string}[] = []; + let files: {stat: fs.Stats, path: string}[] = []; return gulp.src(lintTargets, { read: false }) .pipe(through2.obj((chunk, enc, cb) => { files.push(chunk); cb(); }, (cb) => { - files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size); + files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size); const workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; for (let i = 0; i < workerCount; i++) { spawnLintWorker(files, finished); From 4e04b75d4bc4652408b99ab233de3aaa803a9467 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 15 Aug 2016 11:07:49 -0700 Subject: [PATCH 157/508] Aligned mark names with values used by ts-perf. --- src/compiler/binder.ts | 6 +++--- src/compiler/checker.ts | 6 +++--- src/compiler/parser.ts | 6 +++--- src/compiler/program.ts | 24 ++++++++++++------------ src/compiler/sourcemap.ts | 6 +++--- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ff5a8b77cfd..b5ab2306989 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -89,10 +89,10 @@ namespace ts { const binder = createBinder(); export function bindSourceFile(file: SourceFile, options: CompilerOptions) { - performance.mark("bindStart"); + performance.mark("beforeBind"); binder(file, options); - performance.mark("bindEnd"); - performance.measure("Bind", "bindStart", "bindEnd"); + performance.mark("afterBind"); + performance.measure("Bind", "beforeBind", "afterBind"); } function createBinder(): (file: SourceFile, options: CompilerOptions) => void { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f1fff6737a3..b2b6b9442ac 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -17535,10 +17535,10 @@ namespace ts { } function checkSourceFile(node: SourceFile) { - performance.mark("checkStart"); + performance.mark("beforeCheck"); checkSourceFileWorker(node); - performance.mark("checkEnd"); - performance.measure("Check", "checkStart", "checkEnd"); + performance.mark("afterCheck"); + performance.measure("Check", "beforeCheck", "afterCheck"); } // Fully type check a source file and collect the relevant diagnostics. diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index cbf767a5410..aca7d745730 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -421,10 +421,10 @@ namespace ts { } export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false, scriptKind?: ScriptKind): SourceFile { - performance.mark("parseStart"); + performance.mark("beforeParse"); const result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); - performance.mark("parseEnd"); - performance.measure("Parse", "parseStart", "parseEnd"); + performance.mark("afterParse"); + performance.measure("Parse", "beforeParse", "afterParse"); return result; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index a632eed7fd2..767fcb488bb 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -857,10 +857,10 @@ namespace ts { function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile { let text: string; try { - performance.mark("ioReadStart"); + performance.mark("beforeIORead"); text = sys.readFile(fileName, options.charset); - performance.mark("ioReadEnd"); - performance.measure("I/O Read", "ioReadStart", "ioReadEnd"); + performance.mark("afterIORead"); + performance.measure("I/O Read", "beforeIORead", "afterIORead"); } catch (e) { if (onError) { @@ -927,7 +927,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { try { - performance.mark("ioWriteStart"); + performance.mark("beforeIOWrite"); ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); if (isWatchSet(options) && sys.createHash && sys.getModifiedTime) { @@ -937,8 +937,8 @@ namespace ts { sys.writeFile(fileName, data, writeByteOrderMark); } - performance.mark("ioWriteEnd"); - performance.measure("I/O Write", "ioWriteStart", "ioWriteEnd"); + performance.mark("afterIOWrite"); + performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); } catch (e) { if (onError) { @@ -1120,7 +1120,7 @@ namespace ts { // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. const sourceFilesFoundSearchingNodeModules = createMap(); - performance.mark("programStart"); + performance.mark("beforeProgram"); host = host || createCompilerHost(options); @@ -1218,8 +1218,8 @@ namespace ts { }; verifyCompilerOptions(); - performance.mark("programEnd"); - performance.measure("Program", "programStart", "programEnd"); + performance.mark("afterProgram"); + performance.measure("Program", "beforeProgram", "afterProgram"); return program; @@ -1462,15 +1462,15 @@ namespace ts { // checked is to not pass the file to getEmitResolver. const emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - performance.mark("emitStart"); + performance.mark("beforeEmit"); const emitResult = emitFiles( emitResolver, getEmitHost(writeFileCallback), sourceFile); - performance.mark("emitEnd"); - performance.measure("Emit", "emitStart", "emitEnd"); + performance.mark("afterEmit"); + performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; } diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 52e8975db76..4046867faf1 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -242,7 +242,7 @@ namespace ts { } if (extendedDiagnostics) { - performance.mark("sourcemapStart"); + performance.mark("beforeSourcemap"); } const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); @@ -286,8 +286,8 @@ namespace ts { updateLastEncodedAndRecordedSpans(); if (extendedDiagnostics) { - performance.mark("sourcemapEnd"); - performance.measure("Source Map", "sourcemapStart", "sourcemapEnd"); + performance.mark("afterSourcemap"); + performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); } } From 2953c7f0b2f187aa68664d1e8f7fb4118f777992 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 11:16:36 -0700 Subject: [PATCH 158/508] Use an enum in checkClassForDuplicateDeclarations to aid readability --- src/compiler/checker.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ab76950ec4a..6f5d2dce121 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13794,15 +13794,19 @@ namespace ts { } function checkClassForDuplicateDeclarations(node: ClassLikeDeclaration) { - const getter = 1, setter = 2, property = getter | setter; + const enum Meaning { + Getter = 1, + Setter = 2, + Property = Getter | Setter + } - const instanceNames = createMap(); - const staticNames = createMap(); + const instanceNames = createMap(); + const staticNames = createMap(); for (const member of node.members) { if (member.kind === SyntaxKind.Constructor) { for (const param of (member as ConstructorDeclaration).parameters) { if (isParameterPropertyDeclaration(param)) { - addName(instanceNames, param.name, (param.name as Identifier).text, property); + addName(instanceNames, param.name, (param.name as Identifier).text, Meaning.Property); } } } @@ -13814,22 +13818,22 @@ namespace ts { if (memberName) { switch (member.kind) { case SyntaxKind.GetAccessor: - addName(names, member.name, memberName, getter); + addName(names, member.name, memberName, Meaning.Getter); break; case SyntaxKind.SetAccessor: - addName(names, member.name, memberName, setter); + addName(names, member.name, memberName, Meaning.Setter); break; case SyntaxKind.PropertyDeclaration: - addName(names, member.name, memberName, property); + addName(names, member.name, memberName, Meaning.Property); break; } } } } - function addName(names: Map, location: Node, name: string, meaning: number) { + function addName(names: Map, location: Node, name: string, meaning: Meaning) { const prev = names[name]; if (prev) { if (prev & meaning) { From 8f1960fd3474fdbfd70d3dd1d0d86aa6d3e17a2e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 11:43:40 -0700 Subject: [PATCH 159/508] Rename to Accessor --- src/compiler/checker.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6f5d2dce121..6e51e418ee4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13794,19 +13794,19 @@ namespace ts { } function checkClassForDuplicateDeclarations(node: ClassLikeDeclaration) { - const enum Meaning { + const enum Accessor { Getter = 1, Setter = 2, Property = Getter | Setter } - const instanceNames = createMap(); - const staticNames = createMap(); + const instanceNames = createMap(); + const staticNames = createMap(); for (const member of node.members) { if (member.kind === SyntaxKind.Constructor) { for (const param of (member as ConstructorDeclaration).parameters) { if (isParameterPropertyDeclaration(param)) { - addName(instanceNames, param.name, (param.name as Identifier).text, Meaning.Property); + addName(instanceNames, param.name, (param.name as Identifier).text, Accessor.Property); } } } @@ -13818,22 +13818,22 @@ namespace ts { if (memberName) { switch (member.kind) { case SyntaxKind.GetAccessor: - addName(names, member.name, memberName, Meaning.Getter); + addName(names, member.name, memberName, Accessor.Getter); break; case SyntaxKind.SetAccessor: - addName(names, member.name, memberName, Meaning.Setter); + addName(names, member.name, memberName, Accessor.Setter); break; case SyntaxKind.PropertyDeclaration: - addName(names, member.name, memberName, Meaning.Property); + addName(names, member.name, memberName, Accessor.Property); break; } } } } - function addName(names: Map, location: Node, name: string, meaning: Meaning) { + function addName(names: Map, location: Node, name: string, meaning: Accessor) { const prev = names[name]; if (prev) { if (prev & meaning) { From 5ad7729357430d7238e7f37f751789793b73fe85 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 11:00:08 -0700 Subject: [PATCH 160/508] Use `removeItem` instead of `copyListRemovingItem` --- src/compiler/core.ts | 16 ++++++++++------ src/compiler/sys.ts | 7 ++----- src/server/editorServices.ts | 22 ++++++---------------- src/server/server.ts | 4 ++-- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 168a201c388..cd378a889d2 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1394,14 +1394,18 @@ namespace ts { } } - export function copyListRemovingItem(item: T, list: T[]) { - const copiedList: T[] = []; - for (const e of list) { - if (e !== item) { - copiedList.push(e); + export function removeItem(item: T, array: T[]): void { + for (let i = 0; i < array.length; i++) { + if (array[i] === item) { + // Move everything over to the left. + // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. + for (; i < array.length - 1; i++) { + array[i] = array[i + 1]; + } + array.pop(); + break; } } - return copiedList; } export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string { diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 350d75429b7..7953a2f42e8 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -285,13 +285,10 @@ namespace ts { function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) { const callbacks = fileWatcherCallbacks[filePath]; if (callbacks) { - const newCallbacks = copyListRemovingItem(callback, callbacks); - if (newCallbacks.length === 0) { + removeItem(callback, callbacks); + if (callbacks.length === 0) { delete fileWatcherCallbacks[filePath]; } - else { - fileWatcherCallbacks[filePath] = newCallbacks; - } } } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index a14c42f471e..0a12bf68d79 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -275,7 +275,7 @@ namespace ts.server { removeRoot(info: ScriptInfo) { if (this.filenameToScript.contains(info.path)) { this.filenameToScript.remove(info.path); - this.roots = copyListRemovingItem(info, this.roots); + removeItem(info, this.roots); this.resolvedModuleNames.remove(info.path); this.resolvedTypeReferenceDirectives.remove(info.path); } @@ -585,16 +585,6 @@ namespace ts.server { project?: Project; } - function copyListRemovingItem(item: T, list: T[]) { - const copiedList: T[] = []; - for (let i = 0, len = list.length; i < len; i++) { - if (list[i] != item) { - copiedList.push(list[i]); - } - } - return copiedList; - } - /** * This helper funciton processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project. */ @@ -859,7 +849,7 @@ namespace ts.server { project.directoryWatcher.close(); forEachValue(project.directoriesWatchedForWildcards, watcher => { watcher.close(); }); delete project.directoriesWatchedForWildcards; - this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); + removeItem(project, this.configuredProjects); } else { for (const directory of project.directoriesWatchedForTsconfig) { @@ -871,7 +861,7 @@ namespace ts.server { delete project.projectService.directoryWatchersForTsconfig[directory]; } } - this.inferredProjects = copyListRemovingItem(project, this.inferredProjects); + removeItem(project, this.inferredProjects); } const fileNames = project.getFileNames(); @@ -996,7 +986,7 @@ namespace ts.server { } } else { - this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + removeItem(info, this.openFilesReferenced); } info.close(); } @@ -1506,13 +1496,13 @@ namespace ts.server { // openFileRoots or openFileReferenced. if (info.isOpen) { if (this.openFileRoots.indexOf(info) >= 0) { - this.openFileRoots = copyListRemovingItem(info, this.openFileRoots); + removeItem(info, this.openFileRoots); if (info.defaultProject && !info.defaultProject.isConfiguredProject()) { this.removeProject(info.defaultProject); } } if (this.openFilesReferenced.indexOf(info) >= 0) { - this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced); + removeItem(info, this.openFilesReferenced); } this.openFileRootsConfigured.push(info); info.defaultProject = project; diff --git a/src/server/server.ts b/src/server/server.ts index 17ecfdaa1c9..b0f852b14f1 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -204,7 +204,7 @@ namespace ts.server { // average async stat takes about 30 microseconds // set chunk size to do 30 files in < 1 millisecond function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) { - let watchedFiles: WatchedFile[] = []; + const watchedFiles: WatchedFile[] = []; let nextFileToCheck = 0; let watchTimer: any; @@ -267,7 +267,7 @@ namespace ts.server { } function removeFile(file: WatchedFile) { - watchedFiles = copyListRemovingItem(file, watchedFiles); + removeItem(file, watchedFiles); } return { From de6707e1d507074538a49dfcf14d52133d71d7de Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 14:01:52 -0700 Subject: [PATCH 161/508] Use removal helpers in more places --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 24 +++++++++++++------ src/compiler/tsc.ts | 5 +--- src/harness/harness.ts | 2 +- .../unittests/tsserverProjectSystem.ts | 16 ++++--------- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ab76950ec4a..abae979a25d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5336,7 +5336,7 @@ namespace ts { while (i > 0) { i--; if (isSubtypeOfAny(types[i], types)) { - types.splice(i, 1); + removeItemAt(types, i); } } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index cd378a889d2..dd4ba822243 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1394,15 +1394,25 @@ namespace ts { } } + /** Remove an item from an array, moving everything to its right one space left. */ + export function removeItemAt(array: T[], index: number): void { + // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. + for (let i = index; i < array.length - 1; i++) { + array[i] = array[i + 1]; + } + array.pop(); + } + + /** Remove the *first* occurrence of `item` from the array. */ export function removeItem(item: T, array: T[]): void { + removeFirstItemWhere(array, element => element === item); + } + + /** Remove the *first* element satisfying `predicate`. */ + export function removeFirstItemWhere(array: T[], predicate: (element: T) => boolean): void { for (let i = 0; i < array.length; i++) { - if (array[i] === item) { - // Move everything over to the left. - // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. - for (; i < array.length - 1; i++) { - array[i] = array[i + 1]; - } - array.pop(); + if (predicate(array[i])) { + removeItemAt(array, i); break; } } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 3b588edd101..02a97c01132 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -490,10 +490,7 @@ namespace ts { sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; if (removed) { - const index = rootFileNames.indexOf(sourceFile.fileName); - if (index >= 0) { - rootFileNames.splice(index, 1); - } + removeItem(sourceFile.fileName, rootFileNames); } startTimerForRecompilation(); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 5ae33303d55..3b36381146f 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1558,7 +1558,7 @@ namespace Harness { tsConfig.options.configFilePath = data.name; // delete entry from the list - testUnitData.splice(i, 1); + ts.removeItemAt(testUnitData, i); break; } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 74b9e303cf7..cd87164245a 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -214,12 +214,7 @@ namespace ts { referenceCount: 0, directoryName, close: () => { - for (let i = 0; i < callbacks.length; i++) { - if (callbacks[i].cb === callback) { - callbacks.splice(i, 1); - break; - } - } + removeFirstItemWhere(callbacks, cb => cb.cb === callback); if (!callbacks.length) { delete this.watchedDirectories[path]; } @@ -253,8 +248,7 @@ namespace ts { callbacks.push(callback); return { close: () => { - const i = callbacks.indexOf(callback); - callbacks.splice(i, 1); + removeItem(callback, callbacks); if (!callbacks.length) { delete this.watchedFiles[path]; } @@ -269,7 +263,7 @@ namespace ts { }; readonly clearTimeout = (timeoutId: any): void => { if (typeof timeoutId === "number") { - this.callbackQueue.splice(timeoutId, 1); + removeItemAt(this.callbackQueue, timeoutId); } }; @@ -594,7 +588,7 @@ namespace ts { content: `{ "compilerOptions": { "target": "es6" - }, + }, "files": [ "main.ts" ] }` }; @@ -621,7 +615,7 @@ namespace ts { content: `{ "compilerOptions": { "target": "es6" - }, + }, "files": [ "main.ts" ] }` }; From 5762519071635bf966d1ab706e77b76f66cb1ff9 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Mon, 15 Aug 2016 03:32:21 -0400 Subject: [PATCH 162/508] Resolve aliases to preserve 'Cannot find name' errors for namespace imports --- src/compiler/checker.ts | 15 ++++++-- .../aliasOnMergedModuleInterface.errors.txt | 4 +- .../typeUsedAsValueError2.errors.txt | 28 ++++++++++++++ .../reference/typeUsedAsValueError2.js | 37 +++++++++++++++++++ tests/cases/compiler/typeUsedAsValueError2.ts | 21 +++++++++++ 5 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/typeUsedAsValueError2.errors.txt create mode 100644 tests/baselines/reference/typeUsedAsValueError2.js create mode 100644 tests/cases/compiler/typeUsedAsValueError2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 18da3916652..dbf84b41f85 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -999,12 +999,19 @@ namespace ts { } const nameAsType = resolveName(errorLocation, name, strictlyTypeMeanings, nameNotFoundMessage, nameArg); - if (nameAsType) { - error(errorLocation, Diagnostics.Cannot_find_name_0_A_type_exists_with_this_name_but_no_value, name); - return true; + if (!nameAsType) { + return false; } - return false; + if (nameAsType.flags & SymbolFlags.Alias) { + const resolvedSymbol = resolveAlias(nameAsType); + if (resolvedSymbol.flags & SymbolFlags.NamespaceModule) { + return false; + } + } + + error(errorLocation, Diagnostics.Cannot_find_name_0_A_type_exists_with_this_name_but_no_value, name); + return true; } function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { diff --git a/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt b/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt index 9361e201edc..009d405c0f5 100644 --- a/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt +++ b/tests/baselines/reference/aliasOnMergedModuleInterface.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2691: Cannot find name 'foo'. A type exists with this name, but no value. +tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2304: Cannot find name 'foo'. ==== tests/cases/compiler/aliasOnMergedModuleInterface_1.ts (1 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/aliasOnMergedModuleInterface_1.ts(5,16): error TS2691: Cann z.bar("hello"); // This should be ok var x: foo.A = foo.bar("hello"); // foo.A should be ok but foo.bar should be error ~~~ -!!! error TS2691: Cannot find name 'foo'. A type exists with this name, but no value. +!!! error TS2304: Cannot find name 'foo'. ==== tests/cases/compiler/aliasOnMergedModuleInterface_0.ts (0 errors) ==== declare module "foo" diff --git a/tests/baselines/reference/typeUsedAsValueError2.errors.txt b/tests/baselines/reference/typeUsedAsValueError2.errors.txt new file mode 100644 index 00000000000..8849a904bdf --- /dev/null +++ b/tests/baselines/reference/typeUsedAsValueError2.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/world.ts(4,1): error TS2691: Cannot find name 'HelloInterface'. A type exists with this name, but no value. +tests/cases/compiler/world.ts(5,1): error TS2304: Cannot find name 'HelloNamespace'. + + +==== tests/cases/compiler/world.ts (2 errors) ==== + import HelloInterface = require("helloInterface"); + import HelloNamespace = require("helloNamespace"); + + HelloInterface.world; + ~~~~~~~~~~~~~~ +!!! error TS2691: Cannot find name 'HelloInterface'. A type exists with this name, but no value. + HelloNamespace.world; + ~~~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'HelloNamespace'. +==== tests/cases/compiler/helloInterface.ts (0 errors) ==== + interface HelloInterface { + world: any; + } + + export = HelloInterface; + +==== tests/cases/compiler/helloNamespace.ts (0 errors) ==== + namespace HelloNamespace { + export type world = any; + } + + export = HelloNamespace; + \ No newline at end of file diff --git a/tests/baselines/reference/typeUsedAsValueError2.js b/tests/baselines/reference/typeUsedAsValueError2.js new file mode 100644 index 00000000000..c3bd736cbb7 --- /dev/null +++ b/tests/baselines/reference/typeUsedAsValueError2.js @@ -0,0 +1,37 @@ +//// [tests/cases/compiler/typeUsedAsValueError2.ts] //// + +//// [helloInterface.ts] +interface HelloInterface { + world: any; +} + +export = HelloInterface; + +//// [helloNamespace.ts] +namespace HelloNamespace { + export type world = any; +} + +export = HelloNamespace; + +//// [world.ts] +import HelloInterface = require("helloInterface"); +import HelloNamespace = require("helloNamespace"); + +HelloInterface.world; +HelloNamespace.world; + +//// [helloInterface.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [helloNamespace.js] +define(["require", "exports"], function (require, exports) { + "use strict"; +}); +//// [world.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + HelloInterface.world; + HelloNamespace.world; +}); diff --git a/tests/cases/compiler/typeUsedAsValueError2.ts b/tests/cases/compiler/typeUsedAsValueError2.ts new file mode 100644 index 00000000000..dd89225ef96 --- /dev/null +++ b/tests/cases/compiler/typeUsedAsValueError2.ts @@ -0,0 +1,21 @@ +// @module: amd +// @filename: helloInterface.ts +interface HelloInterface { + world: any; +} + +export = HelloInterface; + +// @filename: helloNamespace.ts +namespace HelloNamespace { + export type world = any; +} + +export = HelloNamespace; + +// @filename: world.ts +import HelloInterface = require("helloInterface"); +import HelloNamespace = require("helloNamespace"); + +HelloInterface.world; +HelloNamespace.world; \ No newline at end of file From 7f0a02ff024a33fcf7b056b4273506e364dbde15 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 15 Aug 2016 12:03:39 -0700 Subject: [PATCH 163/508] Migrated more MapLikes to Maps --- src/compiler/checker.ts | 24 +- src/compiler/commandLineParser.ts | 33 +- src/compiler/core.ts | 287 +++++++++++++----- src/compiler/declarationEmitter.ts | 10 +- src/compiler/emitter.ts | 20 +- src/compiler/program.ts | 27 +- src/compiler/tsc.ts | 16 +- src/compiler/utilities.ts | 21 +- src/harness/fourslash.ts | 8 +- src/harness/harness.ts | 2 +- src/harness/harnessLanguageService.ts | 4 +- .../unittests/cachingInServerLSHost.ts | 2 +- .../unittests/reuseProgramStructure.ts | 16 +- .../unittests/tsserverProjectSystem.ts | 26 +- src/server/client.ts | 2 +- src/server/editorServices.ts | 20 +- src/services/jsTyping.ts | 8 +- src/services/navigateTo.ts | 2 +- src/services/navigationBar.ts | 2 +- src/services/services.ts | 28 +- src/services/shims.ts | 8 +- src/services/signatureHelp.ts | 2 +- tslint.json | 3 +- 23 files changed, 319 insertions(+), 252 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b2b6b9442ac..6a7cc108625 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -403,8 +403,8 @@ namespace ts { result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; - if (symbol.members) result.members = cloneSymbolTable(symbol.members); - if (symbol.exports) result.exports = cloneSymbolTable(symbol.exports); + if (symbol.members) result.members = cloneMap(symbol.members); + if (symbol.exports) result.exports = cloneMap(symbol.exports); recordMergedSymbol(result, symbol); return result; } @@ -447,14 +447,6 @@ namespace ts { } } - function cloneSymbolTable(symbolTable: SymbolTable): SymbolTable { - const result = createMap(); - for (const id in symbolTable) { - result[id] = symbolTable[id]; - } - return result; - } - function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { for (const id in source) { let targetSymbol = target[id]; @@ -1450,7 +1442,7 @@ namespace ts { return; } visitedSymbols.push(symbol); - const symbols = cloneSymbolTable(symbol.exports); + const symbols = cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder const exportStars = symbol.exports["__export"]; if (exportStars) { @@ -1655,12 +1647,12 @@ namespace ts { } // If symbol is directly available by its name in the symbol table - if (isAccessible(lookUp(symbols, symbol.name))) { + if (isAccessible(symbols[symbol.name])) { return [symbol]; } // Check if symbol is any of the alias - return forEachValue(symbols, symbolFromSymbolTable => { + return forEachProperty(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { @@ -6622,7 +6614,7 @@ namespace ts { const maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up const destinationCache = (result === Ternary.True || depth === 0) ? relation : maybeStack[depth - 1]; - copyMap(maybeCache, destinationCache); + copyProperties(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it @@ -7934,7 +7926,7 @@ namespace ts { // check. This gives us a quicker out in the common case where an object type is not a function. const resolved = resolveStructuredTypeMembers(type); return !!(resolved.callSignatures.length || resolved.constructSignatures.length || - hasProperty(resolved.members, "bind") && isTypeSubtypeOf(type, globalFunctionType)); + resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); } function getTypeFacts(type: Type): TypeFacts { @@ -18192,7 +18184,7 @@ namespace ts { // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & SymbolFlags.Value) - : forEachValue(getExportsOfModule(moduleSymbol), isValue); + : forEachProperty(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index eaf17f00dd0..44befb3943d 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -486,10 +486,11 @@ namespace ts { /* @internal */ export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic { const namesOfType: string[] = []; - forEachKey(opt.type, key => { - namesOfType.push(` '${key}'`); - }); - + for (const key in opt.type) { + if (hasProperty(opt.type, key)) { + namesOfType.push(` '${key}'`); + } + } return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType); } @@ -551,11 +552,11 @@ namespace ts { s = s.slice(s.charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase(); // Try to translate short option names to their full equivalents. - if (hasProperty(shortOptionNames, s)) { + if (s in shortOptionNames) { s = shortOptionNames[s]; } - if (hasProperty(optionNameMap, s)) { + if (s in optionNameMap) { const opt = optionNameMap[s]; if (opt.isTSConfigOnly) { @@ -811,7 +812,7 @@ namespace ts { const optionNameMap = arrayToMap(optionDeclarations, opt => opt.name); for (const id in jsonOptions) { - if (hasProperty(optionNameMap, id)) { + if (id in optionNameMap) { const opt = optionNameMap[id]; defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } @@ -1011,14 +1012,14 @@ namespace ts { removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); const key = keyMapper(file); - if (!hasProperty(literalFileMap, key) && !hasProperty(wildcardFileMap, key)) { + if (!(key in literalFileMap) && !(key in wildcardFileMap)) { wildcardFileMap[key] = file; } } } - const literalFiles = reduceProperties(literalFileMap, addFileToOutput, []); - const wildcardFiles = reduceProperties(wildcardFileMap, addFileToOutput, []); + const literalFiles = reduceOwnProperties(literalFileMap, addFileToOutput, []); + const wildcardFiles = reduceOwnProperties(wildcardFileMap, addFileToOutput, []); wildcardFiles.sort(host.useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); return { fileNames: literalFiles.concat(wildcardFiles), @@ -1076,7 +1077,7 @@ namespace ts { if (match) { const key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); const flags = watchRecursivePattern.test(name) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None; - const existingFlags = getProperty(wildcardDirectories, key); + const existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; if (flags === WatchDirectoryFlags.Recursive) { @@ -1088,11 +1089,9 @@ namespace ts { // Remove any subpaths under an existing recursively watched directory. for (const key in wildcardDirectories) { - if (hasProperty(wildcardDirectories, key)) { - for (const recursiveKey of recursiveKeys) { - if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } + for (const recursiveKey of recursiveKeys) { + if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; } } } @@ -1115,7 +1114,7 @@ namespace ts { for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) { const higherPriorityExtension = extensions[i]; const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension)); - if (hasProperty(literalFiles, higherPriorityPath) || hasProperty(wildcardFiles, higherPriorityPath)) { + if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { return true; } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 168a201c388..7bb5dbef2c5 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -21,10 +21,8 @@ namespace ts { const createObject = Object.create; - export function createMap(): Map { - /* tslint:disable:no-null-keyword */ - const map: Map = createObject(null); - /* tslint:enable:no-null-keyword */ + export function createMap(template?: MapLike): Map { + const map: Map = createObject(null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is @@ -32,6 +30,10 @@ namespace ts { map["__"] = undefined; delete map["__"]; + if (template) { + copyOwnProperties(template, map); + } + return map; } @@ -62,7 +64,7 @@ namespace ts { } function contains(path: Path) { - return hasProperty(files, toKey(path)); + return toKey(path) in files; } function remove(path: Path) { @@ -350,82 +352,192 @@ namespace ts { const hasOwnProperty = Object.prototype.hasOwnProperty; + /** + * Indicates whether a map-like contains an own property with the specified key. + * + * NOTE: This is intended for use only with MapLike objects. For Map objects, use + * the 'in' operator. + * + * @param map A map-like. + * @param key A property key. + */ export function hasProperty(map: MapLike, key: string): boolean { return hasOwnProperty.call(map, key); } - export function getKeys(map: MapLike): string[] { + /** + * Gets the value of an owned property in a map-like. + * + * NOTE: This is intended for use only with MapLike objects. For Map objects, use + * an indexer. + * + * @param map A map-like. + * @param key A property key. + */ + export function getProperty(map: MapLike, key: string): T | undefined { + return hasOwnProperty.call(map, key) ? map[key] : undefined; + } + + /** + * Gets the owned, enumerable property keys of a map-like. + * + * @param map A map-like. + */ + export function getOwnKeys(map: MapLike): string[] { const keys: string[] = []; - for (const key in map) { + for (const key in map) if (hasOwnProperty.call(map, key)) { keys.push(key); } return keys; } - export function getProperty(map: MapLike, key: string): T | undefined { - return hasProperty(map, key) ? map[key] : undefined; + /** + * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. + * + * NOTE: This is intended for use with Map objects. For MapLike objects, use + * forEachOwnProperties instead as it offers better runtime safety. + * + * @param map A map for which properties should be enumerated. + * @param callback A callback to invoke for each property. + */ + export function forEachProperty(map: Map, callback: (value: T, key: string) => U): U { + let result: U; + for (const key in map) { + if (result = callback(map[key], key)) break; + } + return result; } - export function getOrUpdateProperty(map: MapLike, key: string, makeValue: () => T): T { - return hasProperty(map, key) ? map[key] : map[key] = makeValue(); + /** + * Enumerates the owned properties of a MapLike, invoking a callback and returning the first truthy result. + * + * NOTE: This is intended for use with MapLike objects. For Map objects, use + * forEachProperty instead as it offers better performance. + * + * @param map A map for which properties should be enumerated. + * @param callback A callback to invoke for each property. + */ + export function forEachOwnProperty(map: MapLike, callback: (value: T, key: string) => U): U { + let result: U; + for (const key in map) if (hasOwnProperty.call(map, key)) { + if (result = callback(map[key], key)) break; + } + return result; } - export function isEmpty(map: MapLike) { - for (const id in map) { - if (hasProperty(map, id)) { - return false; + /** + * Returns true if a Map has some matching property. + * + * @param map A map whose properties should be tested. + * @param predicate An optional callback used to test each property. + */ + export function someProperties(map: Map, predicate?: (value: T, key: string) => boolean) { + for (const key in map) { + if (!predicate || predicate(map[key], key)) return true; + } + return false; + } + + /** + * Performs a shallow copy of the properties from a source Map to a target MapLike + * + * NOTE: This is intended for use with Map objects. For MapLike objects, use + * copyOwnProperties instead as it offers better runtime safety. + * + * @param source A map from which properties should be copied. + * @param target A map to which properties should be copied. + */ + export function copyProperties(source: Map, target: MapLike): void { + for (const key in source) { + target[key] = source[key]; + } + } + + /** + * Performs a shallow copy of the owned properties from a source map to a target map-like. + * + * NOTE: This is intended for use with MapLike objects. For Map objects, use + * copyProperties instead as it offers better performance. + * + * @param source A map-like from which properties should be copied. + * @param target A map-like to which properties should be copied. + */ + export function copyOwnProperties(source: MapLike, target: MapLike): void { + for (const key in source) if (hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + + /** + * Reduce the properties of a map. + * + * NOTE: This is intended for use with Map objects. For MapLike objects, use + * reduceOwnProperties instead as it offers better runtime safety. + * + * @param map The map to reduce + * @param callback An aggregation function that is called for each entry in the map + * @param initial The initial value for the reduction. + */ + export function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { + let result = initial; + for (const key in map) { + result = callback(result, map[key], String(key)); + } + return result; + } + + /** + * Reduce the properties defined on a map-like (but not from its prototype chain). + * + * NOTE: This is intended for use with MapLike objects. For Map objects, use + * reduceProperties instead as it offers better performance. + * + * @param map The map-like to reduce + * @param callback An aggregation function that is called for each entry in the map + * @param initial The initial value for the reduction. + */ + export function reduceOwnProperties(map: MapLike, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { + let result = initial; + for (const key in map) if (hasOwnProperty.call(map, key)) { + result = callback(result, map[key], String(key)); + } + return result; + } + + /** + * Counts the owned properties of a map-like. + * + * @param map A map-like whose properties should be counted. + * @param predicate An optional callback used to limit which properties should be counted. + */ + export function countOwnProperties(map: MapLike, predicate?: (value: T, key: string) => boolean) { + let count = 0; + for (const key in map) if (hasOwnProperty.call(map, key)) { + if (!predicate || predicate(map[key], key)) { + count++; } } + return count; + } + + /** + * Performs a shallow equality comparison of the contents of two map-likes. + * + * @param left A map whose properties should be compared. + * @param right A map whose properties should be compared. + */ + export function equalOwnProperties(left: MapLike, right: MapLike) { + if (left === right) return true; + if (!left || !right) return false; + for (const key in left) if (hasOwnProperty.call(left, key)) { + if (!hasOwnProperty.call(right, key) === undefined || left[key] !== right[key]) return false; + } + for (const key in right) if (hasOwnProperty.call(right, key)) { + if (!hasOwnProperty.call(left, key)) return false; + } return true; } - export function clone(object: T): T { - const result: any = {}; - for (const id in object) { - result[id] = (object)[id]; - } - return result; - } - - export function extend, T2 extends MapLike<{}>>(first: T1 , second: T2): T1 & T2 { - const result: T1 & T2 = {}; - for (const id in first) { - (result as any)[id] = first[id]; - } - for (const id in second) { - if (!hasProperty(result, id)) { - (result as any)[id] = second[id]; - } - } - return result; - } - - export function forEachValue(map: MapLike, callback: (value: T) => U): U { - let result: U; - for (const id in map) { - if (result = callback(map[id])) break; - } - return result; - } - - export function forEachKey(map: MapLike, callback: (key: string) => U): U { - let result: U; - for (const id in map) { - if (result = callback(id)) break; - } - return result; - } - - export function lookUp(map: MapLike, key: string): T { - return hasProperty(map, key) ? map[key] : undefined; - } - - export function copyMap(source: MapLike, target: MapLike): void { - for (const p in source) { - target[p] = source[p]; - } - } - /** * Creates a map from the elements of an array. * @@ -436,33 +548,42 @@ namespace ts { * the same key with the given 'makeKey' function, then the element with the higher * index in the array will be the one associated with the produced key. */ - export function arrayToMap(array: T[], makeKey: (value: T) => string): Map { - const result = createMap(); - - forEach(array, value => { - result[makeKey(value)] = value; - }); - + export function arrayToMap(array: T[], makeKey: (value: T) => string): Map; + export function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue: (value: T) => U): Map; + export function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue?: (value: T) => U): Map { + const result = createMap(); + for (const value of array) { + result[makeKey(value)] = makeValue ? makeValue(value) : value; + } return result; } - /** - * Reduce the properties of a map. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - export function reduceProperties(map: MapLike, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { - let result = initial; - if (map) { - for (const key in map) { - if (hasProperty(map, key)) { - result = callback(result, map[key], String(key)); - } + export function cloneMap(map: Map) { + const clone = createMap(); + copyProperties(map, clone); + return clone; + } + + export function clone(object: T): T { + const result: any = {}; + for (const id in object) { + if (hasOwnProperty.call(object, id)) { + result[id] = (object)[id]; } } + return result; + } + export function extend, T2 extends MapLike<{}>>(first: T1 , second: T2): T1 & T2 { + const result: T1 & T2 = {}; + for (const id in first) { + (result as any)[id] = first[id]; + } + for (const id in second) { + if (!hasProperty(result, id)) { + (result as any)[id] = second[id]; + } + } return result; } diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 56ff206ab01..3642ee7f10a 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -157,9 +157,7 @@ namespace ts { if (usedTypeDirectiveReferences) { for (const directive in usedTypeDirectiveReferences) { - if (hasProperty(usedTypeDirectiveReferences, directive)) { - referencesOutput += `/// ${newLine}`; - } + referencesOutput += `/// ${newLine}`; } } @@ -272,7 +270,7 @@ namespace ts { usedTypeDirectiveReferences = createMap(); } for (const directive of typeReferenceDirectives) { - if (!hasProperty(usedTypeDirectiveReferences, directive)) { + if (!(directive in usedTypeDirectiveReferences)) { usedTypeDirectiveReferences[directive] = directive; } } @@ -537,14 +535,14 @@ namespace ts { // do not need to keep track of created temp names. function getExportDefaultTempVariableName(): string { const baseName = "_default"; - if (!hasProperty(currentIdentifiers, baseName)) { + if (!(baseName in currentIdentifiers)) { return baseName; } let count = 0; while (true) { count++; const name = baseName + "_" + count; - if (!hasProperty(currentIdentifiers, name)) { + if (!(name in currentIdentifiers)) { return name; } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 1d62a4a4f46..47495cc69bb 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -407,7 +407,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function isUniqueLocalName(name: string, container: Node): boolean { for (let node = container; isNodeDescendentOf(node, container); node = node.nextContainer) { - if (node.locals && hasProperty(node.locals, name)) { + if (node.locals && name in node.locals) { // We conservatively include alias symbols to cover cases where they're emitted as locals if (node.locals[name].flags & (SymbolFlags.Value | SymbolFlags.ExportValue | SymbolFlags.Alias)) { return false; @@ -669,8 +669,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function isUniqueName(name: string): boolean { return !resolver.hasGlobalName(name) && - !hasProperty(currentFileIdentifiers, name) && - !hasProperty(generatedNameSet, name); + !(name in currentFileIdentifiers) && + !(name in generatedNameSet); } // Return the next available name in the pattern _a ... _z, _0, _1, ... @@ -2646,7 +2646,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge return false; } - return !exportEquals && exportSpecifiers && hasProperty(exportSpecifiers, (node).text); + return !exportEquals && exportSpecifiers && (node).text in exportSpecifiers; } function emitPrefixUnaryExpression(node: PrefixUnaryExpression) { @@ -3263,7 +3263,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge write(", "); } - if (!hasProperty(seen, id.text)) { + if (!(id.text in seen)) { emit(id); seen[id.text] = id.text; } @@ -3970,7 +3970,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge return; } - if (!exportEquals && exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { + if (!exportEquals && exportSpecifiers && name.text in exportSpecifiers) { for (const specifier of exportSpecifiers[name.text]) { writeLine(); emitStart(specifier.name); @@ -6842,7 +6842,7 @@ const _super = (function (geti, seti) { // export { x, y } for (const specifier of (node).exportClause.elements) { const name = (specifier.propertyName || specifier.name).text; - getOrUpdateProperty(exportSpecifiers, name, () => []).push(specifier); + (exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier); } } break; @@ -6941,7 +6941,7 @@ const _super = (function (geti, seti) { } // local names set should only be added if we have anything exported - if (!exportedDeclarations && isEmpty(exportSpecifiers)) { + if (!exportedDeclarations && !someProperties(exportSpecifiers)) { // no exported declarations (export var ...) or export specifiers (export {x}) // check if we have any non star export declarations. let hasExportDeclarationWithExportClause = false; @@ -7091,7 +7091,7 @@ const _super = (function (geti, seti) { if (name) { // do not emit duplicate entries (in case of declaration merging) in the list of hoisted variables const text = unescapeIdentifier(name.text); - if (hasProperty(seen, text)) { + if (text in seen) { continue; } else { @@ -7460,7 +7460,7 @@ const _super = (function (geti, seti) { // for deduplication purposes in key remove leading and trailing quotes so 'a' and "a" will be considered the same const key = text.substr(1, text.length - 2); - if (hasProperty(groupIndices, key)) { + if (key in groupIndices) { // deduplicate/group entries in dependency list by the dependency name const groupIndex = groupIndices[key]; dependencyGroups[groupIndex].push(externalImports[i]); diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 767fcb488bb..0bf67b0ddb0 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -501,7 +501,7 @@ namespace ts { if (state.traceEnabled) { trace(state.host, Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } - matchedPattern = matchPatternOrExact(getKeys(state.compilerOptions.paths), moduleName); + matchedPattern = matchPatternOrExact(getOwnKeys(state.compilerOptions.paths), moduleName); } if (matchedPattern) { @@ -875,7 +875,7 @@ namespace ts { } function directoryExists(directoryPath: string): boolean { - if (hasProperty(existingDirectories, directoryPath)) { + if (directoryPath in existingDirectories) { return true; } if (sys.directoryExists(directoryPath)) { @@ -903,7 +903,7 @@ namespace ts { const hash = sys.createHash(data); const mtimeBefore = sys.getModifiedTime(fileName); - if (mtimeBefore && hasProperty(outputFingerprints, fileName)) { + if (mtimeBefore && fileName in outputFingerprints) { const fingerprint = outputFingerprints[fileName]; // If output has not been changed, and the file has no external modification @@ -1041,14 +1041,9 @@ namespace ts { const resolutions: T[] = []; const cache = createMap(); for (const name of names) { - let result: T; - if (hasProperty(cache, name)) { - result = cache[name]; - } - else { - result = loader(name, containingFile); - cache[name] = result; - } + const result = name in cache + ? cache[name] + : cache[name] = loader(name, containingFile); resolutions.push(result); } return resolutions; @@ -1249,7 +1244,7 @@ namespace ts { classifiableNames = createMap(); for (const sourceFile of files) { - copyMap(sourceFile.classifiableNames, classifiableNames); + copyProperties(sourceFile.classifiableNames, classifiableNames); } } @@ -1277,7 +1272,7 @@ namespace ts { (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || !arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || !arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || - !mapIsEqualTo(oldOptions.paths, options.paths)) { + !equalOwnProperties(oldOptions.paths, options.paths)) { return false; } @@ -1399,7 +1394,7 @@ namespace ts { getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromExternalLibrary: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path), + isSourceFileFromExternalLibrary: (file: SourceFile) => !!sourceFilesFoundSearchingNodeModules[file.path], writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, @@ -1937,7 +1932,7 @@ namespace ts { // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file && lookUp(sourceFilesFoundSearchingNodeModules, file.path) && currentNodeModulesDepth == 0) { + if (file && sourceFilesFoundSearchingNodeModules[file.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file.path] = false; if (!options.noResolve) { processReferencedFiles(file, getDirectoryPath(fileName), isDefaultLib); @@ -1948,7 +1943,7 @@ namespace ts { processImportedModules(file, getDirectoryPath(fileName)); } // See if we need to reprocess the imports due to prior skipped imports - else if (file && lookUp(modulesWithElidedImports, file.path)) { + else if (file && modulesWithElidedImports[file.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file.path] = false; processImportedModules(file, getDirectoryPath(fileName)); diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 3b588edd101..73cf8e9c4e2 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -445,10 +445,9 @@ namespace ts { } function cachedFileExists(fileName: string): boolean { - if (hasProperty(cachedExistingFiles, fileName)) { - return cachedExistingFiles[fileName]; - } - return cachedExistingFiles[fileName] = hostFileExists(fileName); + return fileName in cachedExistingFiles + ? cachedExistingFiles[fileName] + : cachedExistingFiles[fileName] = hostFileExists(fileName); } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { @@ -704,9 +703,12 @@ namespace ts { description = getDiagnosticText(option.description); const options: string[] = []; const element = (option).element; - forEachKey(>element.type, key => { - options.push(`'${key}'`); - }); + const typeMap = >element.type; + for (const key in typeMap) { + if (hasProperty(typeMap, key)) { + options.push(`'${key}'`); + } + } optionsDescriptionMap[description] = options; } else { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index fcda8f0ce1a..779e479cc43 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -87,25 +87,6 @@ namespace ts { return node.end - node.pos; } - export function mapIsEqualTo(map1: MapLike, map2: MapLike): boolean { - if (!map1 || !map2) { - return map1 === map2; - } - return containsAll(map1, map2) && containsAll(map2, map1); - } - - function containsAll(map: MapLike, other: MapLike): boolean { - for (const key in map) { - if (!hasProperty(map, key)) { - continue; - } - if (!hasProperty(other, key) || map[key] !== other[key]) { - return false; - } - } - return true; - } - export function arrayIsEqualTo(array1: T[], array2: T[], equaler?: (a: T, b: T) => boolean): boolean { if (!array1 || !array2) { return array1 === array2; @@ -2792,7 +2773,7 @@ namespace ts { } function stringifyObject(value: any) { - return `{${reduceProperties(value, stringifyProperty, "")}}`; + return `{${reduceOwnProperties(value, stringifyProperty, "")}}`; } function stringifyProperty(memo: string, value: any, key: string) { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index e7e076a9eae..345ce19f6ae 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -204,7 +204,7 @@ namespace FourSlash { public formatCodeOptions: ts.FormatCodeOptions; - private inputFiles: ts.MapLike = {}; // Map between inputFile's fileName and its content for easily looking up when resolving references + private inputFiles = ts.createMap(); // Map between inputFile's fileName and its content for easily looking up when resolving references // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified @@ -300,11 +300,11 @@ namespace FourSlash { } else { // resolveReference file-option is not specified then do not resolve any files and include all inputFiles - ts.forEachKey(this.inputFiles, fileName => { + for (const fileName in this.inputFiles) { if (!Harness.isDefaultLibraryFile(fileName)) { this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName], /*isRootFile*/ true); } - }); + } this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.getDefaultLibrarySourceFile().text, /*isRootFile*/ false); } @@ -773,7 +773,7 @@ namespace FourSlash { } public verifyRangesWithSameTextReferenceEachOther() { - ts.forEachValue(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); + ts.forEachOwnProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); } private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 5ae33303d55..1f7c48d21bc 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1011,7 +1011,7 @@ namespace Harness { optionsIndex[option.name.toLowerCase()] = option; } } - return ts.lookUp(optionsIndex, name.toLowerCase()); + return ts.getProperty(optionsIndex, name.toLowerCase()); } export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 4f95f19e144..b03d8788165 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -135,7 +135,7 @@ namespace Harness.LanguageService { public getFilenames(): string[] { const fileNames: string[] = []; - ts.forEachValue(this.fileNameToScript, (scriptInfo) => { + ts.forEachOwnProperty(this.fileNameToScript, (scriptInfo) => { if (scriptInfo.isRootFile) { // only include root files here // usually it means that we won't include lib.d.ts in the list of root files so it won't mess the computation of compilation root dir. @@ -146,7 +146,7 @@ namespace Harness.LanguageService { } public getScriptInfo(fileName: string): ScriptInfo { - return ts.lookUp(this.fileNameToScript, fileName); + return ts.getProperty(this.fileNameToScript, fileName); } public addScript(fileName: string, content: string, isRootFile: boolean): void { diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index a1e010b97df..61ab38b2d8f 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -8,7 +8,7 @@ namespace ts { function createDefaultServerHost(fileMap: MapLike): server.ServerHost { const existingDirectories: MapLike = {}; - forEachValue(fileMap, v => { + forEachOwnProperty(fileMap, v => { let dir = getDirectoryPath(v.name); let previous: string; do { diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 76015667232..9d8b176a6a8 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -130,7 +130,7 @@ namespace ts { }, fileExists: fileName => hasProperty(files, fileName), readFile: fileName => { - const file = lookUp(files, fileName); + const file = getProperty(files, fileName); return file && file.text; } }; @@ -152,16 +152,6 @@ namespace ts { return program; } - function getSizeOfMap(map: MapLike): number { - let size = 0; - for (const id in map) { - if (hasProperty(map, id)) { - size++; - } - } - return size; - } - function checkResolvedModule(expected: ResolvedModule, actual: ResolvedModule): void { assert.isTrue(actual !== undefined); assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); @@ -183,8 +173,8 @@ namespace ts { } else { assert.isTrue(cache !== undefined, `expected ${caption} to be set`); - const actualCacheSize = getSizeOfMap(cache); - const expectedSize = getSizeOfMap(expectedContent); + const actualCacheSize = countOwnProperties(cache); + const expectedSize = countOwnProperties(expectedContent); assert.isTrue(actualCacheSize === expectedSize, `expected actual size: ${actualCacheSize} to be equal to ${expectedSize}`); for (const id in expectedContent) { diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 74b9e303cf7..1e76a636c9a 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -68,20 +68,10 @@ namespace ts { return entry; } - function sizeOfMap(map: MapLike): number { - let n = 0; - for (const name in map) { - if (hasProperty(map, name)) { - n++; - } - } - return n; - } - function checkMapKeys(caption: string, map: MapLike, expectedKeys: string[]) { - assert.equal(sizeOfMap(map), expectedKeys.length, `${caption}: incorrect size of map`); + assert.equal(countOwnProperties(map), expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { - assert.isTrue(hasProperty(map, name), `${caption} is expected to contain ${name}, actual keys: ${getKeys(map)}`); + assert.isTrue(hasProperty(map, name), `${caption} is expected to contain ${name}, actual keys: ${getOwnKeys(map)}`); } } @@ -208,7 +198,7 @@ namespace ts { watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher { const path = this.toPath(directoryName); - const callbacks = lookUp(this.watchedDirectories, path) || (this.watchedDirectories[path] = []); + const callbacks = getProperty(this.watchedDirectories, path) || (this.watchedDirectories[path] = []); callbacks.push({ cb: callback, recursive }); return { referenceCount: 0, @@ -229,7 +219,7 @@ namespace ts { triggerDirectoryWatcherCallback(directoryName: string, fileName: string): void { const path = this.toPath(directoryName); - const callbacks = lookUp(this.watchedDirectories, path); + const callbacks = getProperty(this.watchedDirectories, path); if (callbacks) { for (const callback of callbacks) { callback.cb(fileName); @@ -239,7 +229,7 @@ namespace ts { triggerFileWatcherCallback(fileName: string, removed?: boolean): void { const path = this.toPath(fileName); - const callbacks = lookUp(this.watchedFiles, path); + const callbacks = getProperty(this.watchedFiles, path); if (callbacks) { for (const callback of callbacks) { callback(path, removed); @@ -249,7 +239,7 @@ namespace ts { watchFile(fileName: string, callback: FileWatcherCallback) { const path = this.toPath(fileName); - const callbacks = lookUp(this.watchedFiles, path) || (this.watchedFiles[path] = []); + const callbacks = getProperty(this.watchedFiles, path) || (this.watchedFiles[path] = []); callbacks.push(callback); return { close: () => { @@ -594,7 +584,7 @@ namespace ts { content: `{ "compilerOptions": { "target": "es6" - }, + }, "files": [ "main.ts" ] }` }; @@ -621,7 +611,7 @@ namespace ts { content: `{ "compilerOptions": { "target": "es6" - }, + }, "files": [ "main.ts" ] }` }; diff --git a/src/server/client.ts b/src/server/client.ts index 3547ac52602..88177e91fad 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -37,7 +37,7 @@ namespace ts.server { } private getLineMap(fileName: string): number[] { - let lineMap = ts.lookUp(this.lineMaps, fileName); + let lineMap = this.lineMaps[fileName]; if (!lineMap) { const scriptSnapshot = this.host.getScriptSnapshot(fileName); lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength())); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index a14c42f471e..9ba243d9704 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -136,9 +136,9 @@ namespace ts.server { for (const name of names) { // check if this is a duplicate entry in the list - let resolution = lookUp(newResolutions, name); + let resolution = newResolutions[name]; if (!resolution) { - const existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, name); + const existingResolution = currentResolutionsInFile && currentResolutionsInFile[name]; if (moduleResolutionIsValid(existingResolution)) { // ok, it is safe to use existing name resolution results resolution = existingResolution; @@ -563,7 +563,7 @@ namespace ts.server { } let strBuilder = ""; - ts.forEachValue(this.filenameToSourceFile, + ts.forEachProperty(this.filenameToSourceFile, sourceFile => { strBuilder += sourceFile.fileName + "\n"; }); return strBuilder; } @@ -857,7 +857,7 @@ namespace ts.server { if (project.isConfiguredProject()) { project.projectFileWatcher.close(); project.directoryWatcher.close(); - forEachValue(project.directoriesWatchedForWildcards, watcher => { watcher.close(); }); + forEachProperty(project.directoriesWatchedForWildcards, watcher => { watcher.close(); }); delete project.directoriesWatchedForWildcards; this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); } @@ -1124,7 +1124,7 @@ namespace ts.server { getScriptInfo(filename: string) { filename = ts.normalizePath(filename); - return ts.lookUp(this.filenameToScriptInfo, filename); + return this.filenameToScriptInfo[filename]; } /** @@ -1133,7 +1133,7 @@ namespace ts.server { */ openFile(fileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind) { fileName = ts.normalizePath(fileName); - let info = ts.lookUp(this.filenameToScriptInfo, fileName); + let info = this.filenameToScriptInfo[fileName]; if (!info) { let content: string; if (this.host.fileExists(fileName)) { @@ -1246,7 +1246,7 @@ namespace ts.server { * @param filename is absolute pathname */ closeClientFile(filename: string) { - const info = ts.lookUp(this.filenameToScriptInfo, filename); + const info = this.filenameToScriptInfo[filename]; if (info) { this.closeOpenFile(info); info.isOpen = false; @@ -1255,14 +1255,14 @@ namespace ts.server { } getProjectForFile(filename: string) { - const scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); + const scriptInfo = this.filenameToScriptInfo[filename]; if (scriptInfo) { return scriptInfo.defaultProject; } } printProjectsForFile(filename: string) { - const scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); + const scriptInfo = this.filenameToScriptInfo[filename]; if (scriptInfo) { this.psLogger.startGroup(); this.psLogger.info("Projects for " + filename); @@ -1419,7 +1419,7 @@ namespace ts.server { /*recursive*/ true ); - project.directoriesWatchedForWildcards = reduceProperties(projectOptions.wildcardDirectories, (watchers, flag, directory) => { + project.directoriesWatchedForWildcards = reduceOwnProperties(projectOptions.wildcardDirectories, (watchers, flag, directory) => { if (comparePaths(configDirectoryPath, directory, ".", !this.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; this.log(`Add ${ recursive ? "recursive " : ""}watcher for: ${directory}`); diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 05de0061d39..bac33a6bdfb 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -139,16 +139,16 @@ namespace ts.JsTyping { const jsonConfig: PackageJson = result.config; filesToWatch.push(jsonPath); if (jsonConfig.dependencies) { - mergeTypings(getKeys(jsonConfig.dependencies)); + mergeTypings(getOwnKeys(jsonConfig.dependencies)); } if (jsonConfig.devDependencies) { - mergeTypings(getKeys(jsonConfig.devDependencies)); + mergeTypings(getOwnKeys(jsonConfig.devDependencies)); } if (jsonConfig.optionalDependencies) { - mergeTypings(getKeys(jsonConfig.optionalDependencies)); + mergeTypings(getOwnKeys(jsonConfig.optionalDependencies)); } if (jsonConfig.peerDependencies) { - mergeTypings(getKeys(jsonConfig.peerDependencies)); + mergeTypings(getOwnKeys(jsonConfig.peerDependencies)); } } } diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index e9afb6925b5..ccded188e61 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -15,7 +15,7 @@ namespace ts.NavigateTo { const nameToDeclarations = sourceFile.getNamedDeclarations(); for (const name in nameToDeclarations) { - const declarations = getProperty(nameToDeclarations, name); + const declarations = nameToDeclarations[name]; if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index ebd6936ea85..dda9ef485d2 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -243,7 +243,7 @@ namespace ts.NavigationBar { return true; } - const itemsWithSameName = getProperty(nameToItems, name); + const itemsWithSameName = nameToItems[name]; if (!itemsWithSameName) { nameToItems[name] = child; return true; diff --git a/src/services/services.ts b/src/services/services.ts index 850e29030d8..0c1f5929fbf 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -990,7 +990,7 @@ namespace ts { } function getDeclarations(name: string) { - return getProperty(result, name) || (result[name] = []); + return result[name] || (result[name] = []); } function getDeclarationName(declaration: Declaration) { @@ -2042,7 +2042,7 @@ namespace ts { function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, o => - typeof o.type === "object" && !forEachValue(>o.type, v => typeof v !== "number")); + typeof o.type === "object" && !forEachOwnProperty(>o.type, v => typeof v !== "number")); options = clone(options); @@ -2058,7 +2058,7 @@ namespace ts { options[opt.name] = parseCustomTypeOption(opt, value, diagnostics); } else { - if (!forEachValue(opt.type, v => v === value)) { + if (!forEachOwnProperty(opt.type, v => v === value)) { // Supplied value isn't a valid enum value. diagnostics.push(createCompilerDiagnosticForInvalidCustomType(opt)); } @@ -2251,7 +2251,7 @@ namespace ts { } function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap { - let bucket = lookUp(buckets, key); + let bucket = buckets[key]; if (!bucket && createIfMissing) { buckets[key] = bucket = createFileMap(); } @@ -2260,7 +2260,7 @@ namespace ts { function reportStats() { const bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === "_").map(name => { - const entries = lookUp(buckets, name); + const entries = buckets[name]; const sourceFiles: { name: string; refCount: number; references: string[]; }[] = []; entries.forEachValue((key, entry) => { sourceFiles.push({ @@ -3099,7 +3099,7 @@ namespace ts { oldSettings.allowJs !== newSettings.allowJs || oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || oldSettings.baseUrl !== newSettings.baseUrl || - !mapIsEqualTo(oldSettings.paths, newSettings.paths)); + !equalOwnProperties(oldSettings.paths, newSettings.paths)); // Now create a new compiler const compilerHost: CompilerHost = { @@ -4114,11 +4114,11 @@ namespace ts { existingImportsOrExports[name.text] = true; } - if (isEmpty(existingImportsOrExports)) { + if (!someProperties(existingImportsOrExports)) { return filter(exportsOfModule, e => e.name !== "default"); } - return filter(exportsOfModule, e => e.name !== "default" && !lookUp(existingImportsOrExports, e.name)); + return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports[e.name]); } /** @@ -4165,7 +4165,7 @@ namespace ts { existingMemberNames[existingName] = true; } - return filter(contextualMemberSymbols, m => !lookUp(existingMemberNames, m.name)); + return filter(contextualMemberSymbols, m => !existingMemberNames[m.name]); } /** @@ -4187,7 +4187,7 @@ namespace ts { } } - return filter(symbols, a => !lookUp(seenNames, a.name)); + return filter(symbols, a => !seenNames[a.name]); } } @@ -4323,7 +4323,7 @@ namespace ts { const entry = createCompletionEntry(symbol, location, performCharacterChecks); if (entry) { const id = escapeIdentifier(entry.name); - if (!lookUp(uniqueNames, id)) { + if (!uniqueNames[id]) { entries.push(entry); uniqueNames[id] = id; } @@ -5151,7 +5151,7 @@ namespace ts { // Type reference directives const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - const referenceFile = lookUp(program.getResolvedTypeReferenceDirectives(), typeReferenceDirective.fileName); + const referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; if (referenceFile && referenceFile.resolvedFileName) { return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } @@ -5323,7 +5323,7 @@ namespace ts { for (const referencedSymbol of referencedSymbols) { for (const referenceEntry of referencedSymbol.references) { const fileName = referenceEntry.fileName; - let documentHighlights = getProperty(fileNameToDocumentHighlights, fileName); + let documentHighlights = fileNameToDocumentHighlights[fileName]; if (!documentHighlights) { documentHighlights = { fileName, highlightSpans: [] }; @@ -6068,7 +6068,7 @@ namespace ts { const nameTable = getNameTable(sourceFile); - if (lookUp(nameTable, internedName) !== undefined) { + if (nameTable[internedName] !== undefined) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } diff --git a/src/services/shims.ts b/src/services/shims.ts index 45c4b284ae7..ff57dd9cf7a 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -311,9 +311,9 @@ namespace ts { // 'in' does not have this effect. if ("getModuleResolutionsForFile" in this.shimHost) { this.resolveModuleNames = (moduleNames: string[], containingFile: string) => { - const resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); + const resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); return map(moduleNames, name => { - const result = lookUp(resolutionsInFile, name); + const result = getProperty(resolutionsInFile, name); return result ? { resolvedFileName: result } : undefined; }); }; @@ -323,8 +323,8 @@ namespace ts { } if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { this.resolveTypeReferenceDirectives = (typeDirectiveNames: string[], containingFile: string) => { - const typeDirectivesForFile = >JSON.parse(this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return map(typeDirectiveNames, name => lookUp(typeDirectivesForFile, name)); + const typeDirectivesForFile = >JSON.parse(this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return map(typeDirectiveNames, name => getProperty(typeDirectivesForFile, name)); }; } } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 50378aa64b1..211e55b23ba 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -237,7 +237,7 @@ namespace ts.SignatureHelp { const typeChecker = program.getTypeChecker(); for (const sourceFile of program.getSourceFiles()) { const nameToDeclarations = sourceFile.getNamedDeclarations(); - const declarations = getProperty(nameToDeclarations, name.text); + const declarations = nameToDeclarations[name.text]; if (declarations) { for (const declaration of declarations) { diff --git a/tslint.json b/tslint.json index a46e58f8c29..f058eab3dd6 100644 --- a/tslint.json +++ b/tslint.json @@ -32,7 +32,7 @@ "property-declaration": "nospace", "variable-declaration": "nospace" }], - "next-line": [true, + "next-line": [true, "check-catch", "check-else" ], @@ -44,7 +44,6 @@ "boolean-trivia": true, "type-operator-spacing": true, "prefer-const": true, - "no-in-operator": true, "no-increment-decrement": true, "object-literal-surrounding-space": true, "no-type-assertion-whitespace": true From 9c83243f33ee7084eaa07b3ee944f9f53559a930 Mon Sep 17 00:00:00 2001 From: Yui Date: Mon, 15 Aug 2016 15:16:54 -0700 Subject: [PATCH 164/508] Add ES2015 Date constructor signature that accepts another Date (#10353) --- src/lib/es2015.core.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index 980f610ca7d..15fbb1b77c5 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -68,6 +68,10 @@ interface ArrayConstructor { of(...items: T[]): Array; } +interface DateConstructor { + new (value: Date): Date; +} + interface Function { /** * Returns the name of the function. Function names are read-only and can not be changed. From 8f847c50340e03f39f369e6faace627bd76fd91c Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 15 Aug 2016 15:20:58 -0700 Subject: [PATCH 165/508] Parameters with no assignments implicitly considered const --- src/compiler/checker.ts | 80 ++++++++++++++++++++++++++++++----------- src/compiler/types.ts | 20 ++++++----- 2 files changed, 70 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1b7b659e1a6..8a32e23e1ff 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -531,7 +531,7 @@ namespace ts { function getNodeLinks(node: Node): NodeLinks { const nodeId = getNodeId(node); - return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node: Node) { @@ -8185,7 +8185,7 @@ namespace ts { return incomplete ? { flags: 0, type } : type; } - function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, includeOuterFunctions: boolean) { + function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, flowContainer: Node) { let key: string; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; @@ -8237,7 +8237,7 @@ namespace ts { else if (flow.flags & FlowFlags.Start) { // Check if we should continue with the control flow of the containing function. const container = (flow).container; - if (container && includeOuterFunctions) { + if (container && container !== flowContainer && reference.kind !== SyntaxKind.PropertyAccessExpression) { flow = container.flowNode; continue; } @@ -8708,21 +8708,52 @@ namespace ts { function getControlFlowContainer(node: Node): Node { while (true) { node = node.parent; - if (isFunctionLike(node) || node.kind === SyntaxKind.ModuleBlock || node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.PropertyDeclaration) { + if (isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node) || + node.kind === SyntaxKind.ModuleBlock || + node.kind === SyntaxKind.SourceFile || + node.kind === SyntaxKind.PropertyDeclaration) { return node; } } } - function isDeclarationIncludedInFlow(reference: Node, declaration: Declaration, includeOuterFunctions: boolean) { - const declarationContainer = getControlFlowContainer(declaration); - let container = getControlFlowContainer(reference); - while (container !== declarationContainer && - (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.ArrowFunction) && - (includeOuterFunctions || getImmediatelyInvokedFunctionExpression(container))) { - container = getControlFlowContainer(container); + // Check if a parameter is assigned anywhere within its declaring function. + function isParameterAssigned(symbol: Symbol) { + const func = getRootDeclaration(symbol.valueDeclaration).parent; + const links = getNodeLinks(func); + if (!(links.flags & NodeCheckFlags.AssignmentsMarked)) { + links.flags |= NodeCheckFlags.AssignmentsMarked; + if (!hasParentWithAssignmentsMarked(func)) { + markParameterAssignments(func); + } + } + return symbol.isAssigned || false; + } + + function hasParentWithAssignmentsMarked(node: Node) { + while (true) { + node = node.parent; + if (!node) { + return false; + } + if (isFunctionLike(node) && getNodeLinks(node).flags & NodeCheckFlags.AssignmentsMarked) { + return true; + } + } + } + + function markParameterAssignments(node: Node) { + if (node.kind === SyntaxKind.Identifier) { + if (isAssignmentTarget(node)) { + const symbol = getResolvedSymbol(node); + if (symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration).kind === SyntaxKind.Parameter) { + symbol.isAssigned = true; + } + } + } + else { + forEachChild(node, markParameterAssignments); } - return container === declarationContainer; } function checkIdentifier(node: Identifier): Type { @@ -8777,15 +8808,22 @@ namespace ts { checkNestedBlockScopedBinding(node, symbol); const type = getTypeOfSymbol(localOrExportSymbol); - if (!(localOrExportSymbol.flags & SymbolFlags.Variable) || isAssignmentTarget(node)) { + const declaration = localOrExportSymbol.valueDeclaration; + if (!(localOrExportSymbol.flags & SymbolFlags.Variable) || isAssignmentTarget(node) || !declaration) { return type; } - const declaration = localOrExportSymbol.valueDeclaration; - const includeOuterFunctions = isReadonlySymbol(localOrExportSymbol); - const assumeInitialized = !strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || !declaration || - getRootDeclaration(declaration).kind === SyntaxKind.Parameter || isInAmbientContext(declaration) || - !isDeclarationIncludedInFlow(node, declaration, includeOuterFunctions); - const flowType = getFlowTypeOfReference(node, type, assumeInitialized, includeOuterFunctions); + + const isParameter = getRootDeclaration(declaration).kind === SyntaxKind.Parameter; + const declarationContainer = getControlFlowContainer(declaration); + let flowContainer = getControlFlowContainer(node); + while (flowContainer !== declarationContainer && + (flowContainer.kind === SyntaxKind.FunctionExpression || flowContainer.kind === SyntaxKind.ArrowFunction) && + (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + flowContainer = getControlFlowContainer(flowContainer); + } + const assumeInitialized = !strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isParameter || + flowContainer !== declarationContainer || isInAmbientContext(declaration); + const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) { error(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors @@ -9038,7 +9076,7 @@ namespace ts { if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); const type = container.flags & NodeFlags.Static ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; - return getFlowTypeOfReference(node, type, /*assumeInitialized*/ true, /*includeOuterFunctions*/ true); + return getFlowTypeOfReference(node, type, /*assumeInitialized*/ true, /*flowContainer*/ undefined); } if (isInJavaScriptFile(node)) { @@ -10699,7 +10737,7 @@ namespace ts { !(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) { return propType; } - return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*includeOuterFunctions*/ false); + return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); } function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d144c984a3f..cca94c0adc1 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2157,6 +2157,7 @@ namespace ts { /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums /* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere + /* @internal */ isAssigned?: boolean; // True if the symbol has assignments } /* @internal */ @@ -2209,23 +2210,24 @@ namespace ts { AsyncMethodWithSuper = 0x00000800, // An async method that reads a value from a member of 'super'. AsyncMethodWithSuperBinding = 0x00001000, // An async method that assigns a value to a member of 'super'. CaptureArguments = 0x00002000, // Lexical 'arguments' used in body (for async functions) - EnumValuesComputed = 0x00004000, // Values for enum members have been computed, and any errors have been reported for them. - LexicalModuleMergesWithClass = 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration. - LoopWithCapturedBlockScopedBinding = 0x00010000, // Loop that contains block scoped variable captured in closure - CapturedBlockScopedBinding = 0x00020000, // Block-scoped binding that is captured in some function - BlockScopedBindingInLoop = 0x00040000, // Block-scoped binding with declaration nested inside iteration statement - ClassWithBodyScopedClassBinding = 0x00080000, // Decorated class that contains a binding to itself inside of the class body. - BodyScopedClassBinding = 0x00100000, // Binding to a decorated class inside of the class's body. - NeedsLoopOutParameter = 0x00200000, // Block scoped binding whose value should be explicitly copied outside of the converted loop + EnumValuesComputed = 0x00004000, // Values for enum members have been computed, and any errors have been reported for them. + LexicalModuleMergesWithClass = 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration. + LoopWithCapturedBlockScopedBinding = 0x00010000, // Loop that contains block scoped variable captured in closure + CapturedBlockScopedBinding = 0x00020000, // Block-scoped binding that is captured in some function + BlockScopedBindingInLoop = 0x00040000, // Block-scoped binding with declaration nested inside iteration statement + ClassWithBodyScopedClassBinding = 0x00080000, // Decorated class that contains a binding to itself inside of the class body. + BodyScopedClassBinding = 0x00100000, // Binding to a decorated class inside of the class's body. + NeedsLoopOutParameter = 0x00200000, // Block scoped binding whose value should be explicitly copied outside of the converted loop + AssignmentsMarked = 0x00400000, // Parameter assignments have been marked } /* @internal */ export interface NodeLinks { + flags?: NodeCheckFlags; // Set of flags specific to Node resolvedType?: Type; // Cached type of type node resolvedSignature?: Signature; // Cached signature of signature node or call expression resolvedSymbol?: Symbol; // Cached name resolution result resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result - flags?: NodeCheckFlags; // Set of flags specific to Node enumMemberValue?: number; // Constant value of enum member isVisible?: boolean; // Is this node visible hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context From 15dae3fd8a9f76ecec3dde1b1098ca73a3263c92 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 15 Aug 2016 15:21:12 -0700 Subject: [PATCH 166/508] Add tests --- .../implicitConstParameters.errors.txt | 65 +++++++++++ .../reference/implicitConstParameters.js | 106 ++++++++++++++++++ .../cases/compiler/implicitConstParameters.ts | 57 ++++++++++ 3 files changed, 228 insertions(+) create mode 100644 tests/baselines/reference/implicitConstParameters.errors.txt create mode 100644 tests/baselines/reference/implicitConstParameters.js create mode 100644 tests/cases/compiler/implicitConstParameters.ts diff --git a/tests/baselines/reference/implicitConstParameters.errors.txt b/tests/baselines/reference/implicitConstParameters.errors.txt new file mode 100644 index 00000000000..95ff60d71f8 --- /dev/null +++ b/tests/baselines/reference/implicitConstParameters.errors.txt @@ -0,0 +1,65 @@ +tests/cases/compiler/implicitConstParameters.ts(39,27): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/implicitConstParameters.ts(45,27): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/implicitConstParameters.ts (2 errors) ==== + + function doSomething(cb: () => void) { + cb(); + } + + function fn(x: number | string) { + if (typeof x === 'number') { + doSomething(() => x.toFixed()); + } + } + + function f1(x: string | undefined) { + if (!x) { + return; + } + doSomething(() => x.length); + } + + function f2(x: string | undefined) { + if (x) { + doSomething(() => { + doSomething(() => x.length); + }); + } + } + + function f3(x: string | undefined) { + inner(); + function inner() { + if (x) { + doSomething(() => x.length); + } + } + } + + function f4(x: string | undefined) { + x = "abc"; // causes x to be considered non-const + if (x) { + doSomething(() => x.length); + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + + function f5(x: string | undefined) { + if (x) { + doSomething(() => x.length); + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + x = "abc"; // causes x to be considered non-const + } + + + function f6(x: string | undefined) { + const y = x || ""; + if (x) { + doSomething(() => y.length); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/implicitConstParameters.js b/tests/baselines/reference/implicitConstParameters.js new file mode 100644 index 00000000000..a5faf5b1253 --- /dev/null +++ b/tests/baselines/reference/implicitConstParameters.js @@ -0,0 +1,106 @@ +//// [implicitConstParameters.ts] + +function doSomething(cb: () => void) { + cb(); +} + +function fn(x: number | string) { + if (typeof x === 'number') { + doSomething(() => x.toFixed()); + } +} + +function f1(x: string | undefined) { + if (!x) { + return; + } + doSomething(() => x.length); +} + +function f2(x: string | undefined) { + if (x) { + doSomething(() => { + doSomething(() => x.length); + }); + } +} + +function f3(x: string | undefined) { + inner(); + function inner() { + if (x) { + doSomething(() => x.length); + } + } +} + +function f4(x: string | undefined) { + x = "abc"; // causes x to be considered non-const + if (x) { + doSomething(() => x.length); + } +} + +function f5(x: string | undefined) { + if (x) { + doSomething(() => x.length); + } + x = "abc"; // causes x to be considered non-const +} + + +function f6(x: string | undefined) { + const y = x || ""; + if (x) { + doSomething(() => y.length); + } +} + +//// [implicitConstParameters.js] +function doSomething(cb) { + cb(); +} +function fn(x) { + if (typeof x === 'number') { + doSomething(function () { return x.toFixed(); }); + } +} +function f1(x) { + if (!x) { + return; + } + doSomething(function () { return x.length; }); +} +function f2(x) { + if (x) { + doSomething(function () { + doSomething(function () { return x.length; }); + }); + } +} +function f3(x) { + inner(); + function inner() { + if (x) { + doSomething(function () { return x.length; }); + } + } +} +function f4(x) { + x = "abc"; // causes x to be considered non-const + if (x) { + doSomething(function () { return x.length; }); + } +} +function f5(x) { + if (x) { + doSomething(function () { return x.length; }); + } + x = "abc"; // causes x to be considered non-const +} +function f6(x) { + var y = x || ""; + if (x) { + doSomething(function () { return y.length; }); + } +} diff --git a/tests/cases/compiler/implicitConstParameters.ts b/tests/cases/compiler/implicitConstParameters.ts new file mode 100644 index 00000000000..97996789124 --- /dev/null +++ b/tests/cases/compiler/implicitConstParameters.ts @@ -0,0 +1,57 @@ +// @strictNullChecks: true + +function doSomething(cb: () => void) { + cb(); +} + +function fn(x: number | string) { + if (typeof x === 'number') { + doSomething(() => x.toFixed()); + } +} + +function f1(x: string | undefined) { + if (!x) { + return; + } + doSomething(() => x.length); +} + +function f2(x: string | undefined) { + if (x) { + doSomething(() => { + doSomething(() => x.length); + }); + } +} + +function f3(x: string | undefined) { + inner(); + function inner() { + if (x) { + doSomething(() => x.length); + } + } +} + +function f4(x: string | undefined) { + x = "abc"; // causes x to be considered non-const + if (x) { + doSomething(() => x.length); + } +} + +function f5(x: string | undefined) { + if (x) { + doSomething(() => x.length); + } + x = "abc"; // causes x to be considered non-const +} + + +function f6(x: string | undefined) { + const y = x || ""; + if (x) { + doSomething(() => y.length); + } +} \ No newline at end of file From 1dc495adf83e143e3d5558157c939e529106beba Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 15 Aug 2016 16:41:32 -0700 Subject: [PATCH 167/508] Migrate additional MapLikes to Maps. --- src/compiler/checker.ts | 30 ++--- src/compiler/commandLineParser.ts | 32 +++--- src/compiler/core.ts | 108 +++++++++++++++++- src/compiler/emitter.ts | 16 +-- src/compiler/scanner.ts | 10 +- src/compiler/tsc.ts | 15 +-- src/compiler/types.ts | 6 +- src/compiler/utilities.ts | 4 +- src/harness/compilerRunner.ts | 6 +- src/harness/fourslash.ts | 21 ++-- src/harness/harness.ts | 10 +- src/harness/harnessLanguageService.ts | 8 +- src/harness/projectsRunner.ts | 9 +- .../unittests/cachingInServerLSHost.ts | 20 ++-- src/harness/unittests/moduleResolution.ts | 78 ++++++------- .../unittests/reuseProgramStructure.ts | 82 +++++++------ src/harness/unittests/session.ts | 8 +- .../unittests/tsserverProjectSystem.ts | 18 +-- src/server/session.ts | 7 +- src/services/jsTyping.ts | 13 +-- src/services/patternMatcher.ts | 2 +- src/services/services.ts | 8 +- 22 files changed, 295 insertions(+), 216 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6a7cc108625..c309b9e36c0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -284,7 +284,7 @@ namespace ts { NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy, } - const typeofEQFacts: MapLike = { + const typeofEQFacts = createMap({ "string": TypeFacts.TypeofEQString, "number": TypeFacts.TypeofEQNumber, "boolean": TypeFacts.TypeofEQBoolean, @@ -292,9 +292,9 @@ namespace ts { "undefined": TypeFacts.EQUndefined, "object": TypeFacts.TypeofEQObject, "function": TypeFacts.TypeofEQFunction - }; + }); - const typeofNEFacts: MapLike = { + const typeofNEFacts = createMap({ "string": TypeFacts.TypeofNEString, "number": TypeFacts.TypeofNENumber, "boolean": TypeFacts.TypeofNEBoolean, @@ -302,15 +302,15 @@ namespace ts { "undefined": TypeFacts.NEUndefined, "object": TypeFacts.TypeofNEObject, "function": TypeFacts.TypeofNEFunction - }; + }); - const typeofTypesByName: MapLike = { + const typeofTypesByName = createMap({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType - }; + }); let jsxElementType: ObjectType; /** Things we lazy load from the JSX namespace */ @@ -8467,11 +8467,11 @@ namespace ts { return type; } const doubleEquals = operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsToken; - const facts = doubleEquals ? - assumeTrue ? TypeFacts.EQUndefinedOrNull : TypeFacts.NEUndefinedOrNull : - value.kind === SyntaxKind.NullKeyword ? - assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull : - assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; + const facts = doubleEquals + ? assumeTrue ? TypeFacts.EQUndefinedOrNull : TypeFacts.NEUndefinedOrNull + : value.kind === SyntaxKind.NullKeyword + ? assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull + : assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; return getTypeWithFacts(type, facts); } if (type.flags & TypeFlags.NotUnionOrUnit) { @@ -8502,14 +8502,14 @@ namespace ts { // We narrow a non-union type to an exact primitive type if the non-union type // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - const targetType = getProperty(typeofTypesByName, literal.text); + const targetType = typeofTypesByName[literal.text]; if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } - const facts = assumeTrue ? - getProperty(typeofEQFacts, literal.text) || TypeFacts.TypeofEQHostObject : - getProperty(typeofNEFacts, literal.text) || TypeFacts.TypeofNEHostObject; + const facts = assumeTrue + ? typeofEQFacts[literal.text] || TypeFacts.TypeofEQHostObject + : typeofNEFacts[literal.text] || TypeFacts.TypeofNEHostObject; return getTypeWithFacts(type, facts); } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 44befb3943d..35140855d81 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -61,10 +61,10 @@ namespace ts { }, { name: "jsx", - type: { + type: createMap({ "preserve": JsxEmit.Preserve, "react": JsxEmit.React - }, + }), paramType: Diagnostics.KIND, description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, @@ -91,7 +91,7 @@ namespace ts { { name: "module", shortName: "m", - type: { + type: createMap({ "none": ModuleKind.None, "commonjs": ModuleKind.CommonJS, "amd": ModuleKind.AMD, @@ -99,16 +99,16 @@ namespace ts { "umd": ModuleKind.UMD, "es6": ModuleKind.ES6, "es2015": ModuleKind.ES2015, - }, + }), description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: Diagnostics.KIND, }, { name: "newLine", - type: { + type: createMap({ "crlf": NewLineKind.CarriageReturnLineFeed, "lf": NewLineKind.LineFeed - }, + }), description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, paramType: Diagnostics.NEWLINE, }, @@ -250,12 +250,12 @@ namespace ts { { name: "target", shortName: "t", - type: { + type: createMap({ "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6, "es2015": ScriptTarget.ES2015, - }, + }), description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: Diagnostics.VERSION, }, @@ -284,10 +284,10 @@ namespace ts { }, { name: "moduleResolution", - type: { + type: createMap({ "node": ModuleResolutionKind.NodeJs, "classic": ModuleResolutionKind.Classic, - }, + }), description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { @@ -392,7 +392,7 @@ namespace ts { type: "list", element: { name: "lib", - type: { + type: createMap({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", @@ -417,7 +417,7 @@ namespace ts { "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }, + }), }, description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -487,9 +487,7 @@ namespace ts { export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic { const namesOfType: string[] = []; for (const key in opt.type) { - if (hasProperty(opt.type, key)) { - namesOfType.push(` '${key}'`); - } + namesOfType.push(` '${key}'`); } return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType); } @@ -498,7 +496,7 @@ namespace ts { export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { const key = trimString((value || "")).toLowerCase(); const map = opt.type; - if (hasProperty(map, key)) { + if (key in map) { return map[key]; } else { @@ -849,7 +847,7 @@ namespace ts { function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { const key = value.toLowerCase(); - if (hasProperty(opt.type, key)) { + if (key in opt.type) { return opt.type[key]; } else { diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 7bb5dbef2c5..d10d76b3492 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -190,6 +190,21 @@ namespace ts { return array; } + export function removeWhere(array: T[], f: (x: T) => boolean): boolean { + let outIndex = 0; + for (const item of array) { + if (!f(item)) { + array[outIndex] = item; + outIndex++; + } + } + if (outIndex !== array.length) { + array.length = outIndex; + return true; + } + return false; + } + export function filterMutate(array: T[], f: (x: T) => boolean): void { let outIndex = 0; for (const item of array) { @@ -381,6 +396,9 @@ namespace ts { /** * Gets the owned, enumerable property keys of a map-like. * + * NOTE: This is intended for use with MapLike objects. For Map objects, use + * Object.keys instead as it offers better performance. + * * @param map A map-like. */ export function getOwnKeys(map: MapLike): string[] { @@ -425,6 +443,36 @@ namespace ts { return result; } + /** + * Maps key-value pairs of a map into a new map. + * + * NOTE: The key-value pair passed to the callback is *not* safe to cache between invocations + * of the callback. + * + * @param map A map. + * @param callback A callback that maps a key-value pair into a new key-value pair. + */ + export function mapPairs(map: Map, callback: (entry: [string, T]) => [string, U]): Map { + let result: Map; + if (map) { + result = createMap(); + let inPair: [string, T]; + for (const key in map) { + if (inPair) { + inPair[0] = key; + inPair[1] = map[key]; + } + else { + inPair = [key, map[key]]; + } + + const outPair = callback(inPair); + result[outPair[0]] = outPair[1]; + } + } + return result; + } + /** * Returns true if a Map has some matching property. * @@ -504,9 +552,31 @@ namespace ts { return result; } + /** + * Counts the properties of a map. + * + * NOTE: This is intended for use with Map objects. For MapLike objects, use + * countOwnProperties instead as it offers better runtime safety. + * + * @param map A map whose properties should be counted. + * @param predicate An optional callback used to limit which properties should be counted. + */ + export function countProperties(map: Map, predicate?: (value: T, key: string) => boolean) { + let count = 0; + for (const key in map) { + if (!predicate || predicate(map[key], key)) { + count++; + } + } + return count; + } + /** * Counts the owned properties of a map-like. * + * NOTE: This is intended for use with MapLike objects. For Map objects, use + * countProperties instead as it offers better performance. + * * @param map A map-like whose properties should be counted. * @param predicate An optional callback used to limit which properties should be counted. */ @@ -521,16 +591,42 @@ namespace ts { } /** - * Performs a shallow equality comparison of the contents of two map-likes. + * Performs a shallow equality comparison of the contents of two maps. + * + * NOTE: This is intended for use with Map objects. For MapLike objects, use + * equalOwnProperties instead as it offers better runtime safety. * * @param left A map whose properties should be compared. * @param right A map whose properties should be compared. */ - export function equalOwnProperties(left: MapLike, right: MapLike) { + export function equalProperties(left: Map, right: Map, equalityComparer?: (left: T, right: T) => boolean) { + if (left === right) return true; + if (!left || !right) return false; + for (const key in left) { + if (!(key in right)) return false; + if (equalityComparer ? !equalityComparer(left[key], right[key]) : left[key] !== right[key]) return false; + } + for (const key in right) { + if (!(key in left)) return false; + } + return true; + } + + /** + * Performs a shallow equality comparison of the contents of two map-likes. + * + * NOTE: This is intended for use with MapLike objects. For Map objects, use + * equalProperties instead as it offers better performance. + * + * @param left A map-like whose properties should be compared. + * @param right A map-like whose properties should be compared. + */ + export function equalOwnProperties(left: MapLike, right: MapLike, equalityComparer?: (left: T, right: T) => boolean) { if (left === right) return true; if (!left || !right) return false; for (const key in left) if (hasOwnProperty.call(left, key)) { - if (!hasOwnProperty.call(right, key) === undefined || left[key] !== right[key]) return false; + if (!hasOwnProperty.call(right, key) === undefined) return false; + if (equalityComparer ? !equalityComparer(left[key], right[key]) : left[key] !== right[key]) return false; } for (const key in right) if (hasOwnProperty.call(right, key)) { if (!hasOwnProperty.call(left, key)) return false; @@ -577,10 +673,12 @@ namespace ts { export function extend, T2 extends MapLike<{}>>(first: T1 , second: T2): T1 & T2 { const result: T1 & T2 = {}; for (const id in first) { - (result as any)[id] = first[id]; + if (hasOwnProperty.call(first, id)) { + (result as any)[id] = first[id]; + } } for (const id in second) { - if (!hasProperty(result, id)) { + if (hasOwnProperty.call(second, id) && !hasOwnProperty.call(result, id)) { (result as any)[id] = second[id]; } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 47495cc69bb..5c834ad0ac2 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -24,7 +24,7 @@ namespace ts { Return = 1 << 3 } - const entities: MapLike = { + const entities = createMap({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -278,7 +278,7 @@ namespace ts { "clubs": 0x2663, "hearts": 0x2665, "diams": 0x2666 - }; + }); // Flags enum to track count of temp variables and a few dedicated names const enum TempFlags { @@ -531,7 +531,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge let currentText: string; let currentLineMap: number[]; let currentFileIdentifiers: Map; - let renamedDependencies: MapLike; + let renamedDependencies: Map; let isEs6Module: boolean; let isCurrentFileExternalModule: boolean; @@ -577,21 +577,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge const setSourceMapWriterEmit = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? changeSourceMapEmit : function (writer: SourceMapWriter) { }; - const moduleEmitDelegates: MapLike<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = { + const moduleEmitDelegates = createMap<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void>({ [ModuleKind.ES6]: emitES6Module, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, [ModuleKind.UMD]: emitUMDModule, [ModuleKind.CommonJS]: emitCommonJSModule, - }; + }); - const bundleEmitDelegates: MapLike<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void> = { + const bundleEmitDelegates = createMap<(node: SourceFile, emitRelativePathAsModuleName?: boolean) => void>({ [ModuleKind.ES6]() {}, [ModuleKind.AMD]: emitAMDModule, [ModuleKind.System]: emitSystemModule, [ModuleKind.UMD]() {}, [ModuleKind.CommonJS]() {}, - }; + }); return doEmit; @@ -6461,7 +6461,7 @@ const _super = (function (geti, seti) { * Here we check if alternative name was provided for a given moduleName and return it if possible. */ function tryRenameExternalModule(moduleName: LiteralExpression): string { - if (renamedDependencies && hasProperty(renamedDependencies, moduleName.text)) { + if (renamedDependencies && moduleName.text in renamedDependencies) { return `"${renamedDependencies[moduleName.text]}"`; } return undefined; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 134dc489b2a..c1431ca23ed 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -55,7 +55,7 @@ namespace ts { tryScan(callback: () => T): T; } - const textToToken: MapLike = { + const textToToken = createMap({ "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, @@ -179,7 +179,7 @@ namespace ts { "|=": SyntaxKind.BarEqualsToken, "^=": SyntaxKind.CaretEqualsToken, "@": SyntaxKind.AtToken, - }; + }); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -271,12 +271,10 @@ namespace ts { lookupInUnicodeMap(code, unicodeES3IdentifierPart); } - function makeReverseMap(source: MapLike): string[] { + function makeReverseMap(source: Map): string[] { const result: string[] = []; for (const name in source) { - if (source.hasOwnProperty(name)) { - result[source[name]] = name; - } + result[source[name]] = name; } return result; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 73cf8e9c4e2..8b445bcb626 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -122,11 +122,11 @@ namespace ts { const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; - const categoryFormatMap: MapLike = { + const categoryFormatMap = createMap({ [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, [DiagnosticCategory.Error]: redForegroundEscapeSequence, [DiagnosticCategory.Message]: blueForegroundEscapeSequence, - }; + }); function formatAndReset(text: string, formatStyle: string) { return formatStyle + text + resetEscapeSequence; @@ -703,11 +703,9 @@ namespace ts { description = getDiagnosticText(option.description); const options: string[] = []; const element = (option).element; - const typeMap = >element.type; + const typeMap = >element.type; for (const key in typeMap) { - if (hasProperty(typeMap, key)) { - options.push(`'${key}'`); - } + options.push(`'${key}'`); } optionsDescriptionMap[description] = options; } @@ -814,9 +812,8 @@ namespace ts { // Enum const typeMap = >optionDefinition.type; for (const key in typeMap) { - if (hasProperty(typeMap, key)) { - if (typeMap[key] === value) - result[name] = key; + if (typeMap[key] === value) { + result[name] = key; } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d144c984a3f..83d299583d2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1650,7 +1650,7 @@ namespace ts { // this map is used by transpiler to supply alternative names for dependencies (i.e. in case of bundling) /* @internal */ - renamedDependencies?: MapLike; + renamedDependencies?: Map; /** * lib.d.ts should have a reference comment like @@ -2742,7 +2742,7 @@ namespace ts { /* @internal */ export interface CommandLineOptionBase { name: string; - type: "string" | "number" | "boolean" | "object" | "list" | MapLike; // a value of a primitive type, or an object literal mapping named values to actual values + type: "string" | "number" | "boolean" | "object" | "list" | Map; // a value of a primitive type, or an object literal mapping named values to actual values isFilePath?: boolean; // True if option value is a path or fileName shortName?: string; // A short mnemonic for convenience - for instance, 'h' can be used in place of 'help' description?: DiagnosticMessage; // The message describing what the command line switch does @@ -2758,7 +2758,7 @@ namespace ts { /* @internal */ export interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: MapLike; // an object literal mapping named values to actual values + type: Map; // an object literal mapping named values to actual values } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 779e479cc43..0a1f43203ce 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2040,7 +2040,7 @@ namespace ts { // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. const escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - const escapedCharsMap: MapLike = { + const escapedCharsMap = createMap({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -2053,7 +2053,7 @@ namespace ts { "\u2028": "\\u2028", // lineSeparator "\u2029": "\\u2029", // paragraphSeparator "\u0085": "\\u0085" // nextLine - }; + }); /** diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index fe8986984d3..66396293dc2 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -291,8 +291,8 @@ class CompilerBaselineRunner extends RunnerBase { const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true); - const fullResults: ts.MapLike = {}; - const pullResults: ts.MapLike = {}; + const fullResults = ts.createMap(); + const pullResults = ts.createMap(); for (const sourceFile of allFiles) { fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); @@ -338,7 +338,7 @@ class CompilerBaselineRunner extends RunnerBase { } } - function generateBaseLine(typeWriterResults: ts.MapLike, isSymbolBaseline: boolean): string { + function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { const typeLines: string[] = []; const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 345ce19f6ae..ba1994c8141 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -95,14 +95,14 @@ namespace FourSlash { export import IndentStyle = ts.IndentStyle; - const entityMap: ts.MapLike = { + const entityMap = ts.createMap({ "&": "&", "\"": """, "'": "'", "/": "/", "<": "<", ">": ">" - }; + }); export function escapeXmlAttributeValue(s: string) { return s.replace(/[&<>"'\/]/g, ch => entityMap[ch]); @@ -593,9 +593,9 @@ namespace FourSlash { public noItemsWithSameNameButDifferentKind(): void { const completions = this.getCompletionListAtCaret(); - const uniqueItems: ts.MapLike = {}; + const uniqueItems = ts.createMap(); for (const item of completions.entries) { - if (!ts.hasProperty(uniqueItems, item.name)) { + if (!(item.name in uniqueItems)) { uniqueItems[item.name] = item.kind; } else { @@ -1638,11 +1638,12 @@ namespace FourSlash { return this.testData.ranges; } - public rangesByText(): ts.MapLike { - const result: ts.MapLike = {}; + public rangesByText(): ts.Map { + const result = ts.createMap(); for (const range of this.getRanges()) { const text = this.rangeText(range); - (ts.getProperty(result, text) || (result[text] = [])).push(range); + const ranges = result[text] || (result[text] = []); + ranges.push(range); } return result; } @@ -1897,7 +1898,7 @@ namespace FourSlash { public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) { - const openBraceMap: ts.MapLike = { + const openBraceMap = ts.createMap({ "(": ts.CharacterCodes.openParen, "{": ts.CharacterCodes.openBrace, "[": ts.CharacterCodes.openBracket, @@ -1905,7 +1906,7 @@ namespace FourSlash { '"': ts.CharacterCodes.doubleQuote, "`": ts.CharacterCodes.backtick, "<": ts.CharacterCodes.lessThan - }; + }); const charCode = openBraceMap[openingBrace]; @@ -2773,7 +2774,7 @@ namespace FourSlashInterface { return this.state.getRanges(); } - public rangesByText(): ts.MapLike { + public rangesByText(): ts.Map { return this.state.rangesByText(); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 1f7c48d21bc..e3bcb001863 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -848,9 +848,9 @@ namespace Harness { export const defaultLibFileName = "lib.d.ts"; export const es2015DefaultLibFileName = "lib.es2015.d.ts"; - const libFileNameSourceFileMap: ts.MapLike = { + const libFileNameSourceFileMap= ts.createMap({ [defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest) - }; + }); export function getDefaultLibrarySourceFile(fileName = defaultLibFileName): ts.SourceFile { if (!isDefaultLibraryFile(fileName)) { @@ -1002,16 +1002,16 @@ namespace Harness { { name: "symlink", type: "string" } ]; - let optionsIndex: ts.MapLike; + let optionsIndex: ts.Map; function getCommandLineOption(name: string): ts.CommandLineOption { if (!optionsIndex) { - optionsIndex = {}; + optionsIndex = ts.createMap(); const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations); for (const option of optionDeclarations) { optionsIndex[option.name.toLowerCase()] = option; } } - return ts.getProperty(optionsIndex, name.toLowerCase()); + return optionsIndex[name.toLowerCase()]; } export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index b03d8788165..b37a6a90899 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -123,7 +123,7 @@ namespace Harness.LanguageService { } export class LanguageServiceAdapterHost { - protected fileNameToScript: ts.MapLike = {}; + protected fileNameToScript = ts.createMap(); constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, protected settings = ts.getDefaultCompilerOptions()) { @@ -146,7 +146,7 @@ namespace Harness.LanguageService { } public getScriptInfo(fileName: string): ScriptInfo { - return ts.getProperty(this.fileNameToScript, fileName); + return this.fileNameToScript[fileName]; } public addScript(fileName: string, content: string, isRootFile: boolean): void { @@ -235,7 +235,7 @@ namespace Harness.LanguageService { this.getModuleResolutionsForFile = (fileName) => { const scriptInfo = this.getScriptInfo(fileName); const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true); - const imports: ts.MapLike = {}; + const imports = ts.createMap(); for (const module of preprocessInfo.importedFiles) { const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); if (resolutionInfo.resolvedModule) { @@ -248,7 +248,7 @@ namespace Harness.LanguageService { const scriptInfo = this.getScriptInfo(fileName); if (scriptInfo) { const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false); - const resolutions: ts.MapLike = {}; + const resolutions = ts.createMap(); const settings = this.nativeHost.getCompilationSettings(); for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) { const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost); diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index be3030a6dd6..76f042834bb 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -253,18 +253,15 @@ class ProjectRunner extends RunnerBase { moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future }; // Set the values specified using json - const optionNameMap: ts.MapLike = {}; - ts.forEach(ts.optionDeclarations, option => { - optionNameMap[option.name] = option; - }); + const optionNameMap = ts.arrayToMap(ts.optionDeclarations, option => option.name); for (const name in testCase) { - if (name !== "mapRoot" && name !== "sourceRoot" && ts.hasProperty(optionNameMap, name)) { + if (name !== "mapRoot" && name !== "sourceRoot" && name in optionNameMap) { const option = optionNameMap[name]; const optType = option.type; let value = testCase[name]; if (typeof optType !== "string") { const key = value.toLowerCase(); - if (ts.hasProperty(optType, key)) { + if (key in optType) { value = optType[key]; } } diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 61ab38b2d8f..2885b310605 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -6,17 +6,17 @@ namespace ts { content: string; } - function createDefaultServerHost(fileMap: MapLike): server.ServerHost { - const existingDirectories: MapLike = {}; - forEachOwnProperty(fileMap, v => { - let dir = getDirectoryPath(v.name); + function createDefaultServerHost(fileMap: Map): server.ServerHost { + const existingDirectories = createMap(); + for (const name in fileMap) { + let dir = getDirectoryPath(name); let previous: string; do { existingDirectories[dir] = true; previous = dir; dir = getDirectoryPath(dir); } while (dir !== previous); - }); + } return { args: [], newLine: "\r\n", @@ -24,7 +24,7 @@ namespace ts { write: (s: string) => { }, readFile: (path: string, encoding?: string): string => { - return hasProperty(fileMap, path) && fileMap[path].content; + return path in fileMap ? fileMap[path].content : undefined; }, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => { throw new Error("NYI"); @@ -33,10 +33,10 @@ namespace ts { throw new Error("NYI"); }, fileExists: (path: string): boolean => { - return hasProperty(fileMap, path); + return path in fileMap; }, directoryExists: (path: string): boolean => { - return hasProperty(existingDirectories, path); + return existingDirectories[path] || false; }, createDirectory: (path: string) => { }, @@ -101,7 +101,7 @@ namespace ts { content: `foo()` }; - const serverHost = createDefaultServerHost({ [root.name]: root, [imported.name]: imported }); + const serverHost = createDefaultServerHost(createMap({ [root.name]: root, [imported.name]: imported })); const { project, rootScriptInfo } = createProject(root.name, serverHost); // ensure that imported file was found @@ -193,7 +193,7 @@ namespace ts { content: `export var y = 1` }; - const fileMap: MapLike = { [root.name]: root }; + const fileMap = createMap({ [root.name]: root }); const serverHost = createDefaultServerHost(fileMap); const originalFileExists = serverHost.fileExists; diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 4b5ef9f24f1..ff0151c40a5 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -10,7 +10,7 @@ namespace ts { const map = arrayToMap(files, f => f.name); if (hasDirectoryExists) { - const directories: MapLike = {}; + const directories = createMap(); for (const f of files) { let name = getDirectoryPath(f.name); while (true) { @@ -25,19 +25,19 @@ namespace ts { return { readFile, directoryExists: path => { - return hasProperty(directories, path); + return path in directories; }, fileExists: path => { - assert.isTrue(hasProperty(directories, getDirectoryPath(path)), `'fileExists' '${path}' request in non-existing directory`); - return hasProperty(map, path); + assert.isTrue(getDirectoryPath(path) in directories, `'fileExists' '${path}' request in non-existing directory`); + return path in map; } }; } else { - return { readFile, fileExists: path => hasProperty(map, path), }; + return { readFile, fileExists: path => path in map, }; } function readFile(path: string): string { - return hasProperty(map, path) ? map[path].content : undefined; + return path in map ? map[path].content : undefined; } } @@ -282,12 +282,12 @@ namespace ts { }); describe("Module resolution - relative imports", () => { - function test(files: MapLike, currentDirectory: string, rootFiles: string[], expectedFilesCount: number, relativeNamesToCheck: string[]) { + function test(files: Map, currentDirectory: string, rootFiles: string[], expectedFilesCount: number, relativeNamesToCheck: string[]) { const options: CompilerOptions = { module: ModuleKind.CommonJS }; const host: CompilerHost = { getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined; + return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, @@ -298,7 +298,7 @@ namespace ts { useCaseSensitiveFileNames: () => false, fileExists: fileName => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return hasProperty(files, path); + return path in files; }, readFile: (fileName): string => { throw new Error("NotImplemented"); } }; @@ -318,7 +318,7 @@ namespace ts { } it("should find all modules", () => { - const files: MapLike = { + const files = createMap({ "/a/b/c/first/shared.ts": ` class A {} export = A`, @@ -332,37 +332,33 @@ import Shared = require('../first/shared'); class C {} export = C; ` - }; + }); test(files, "/a/b/c/first/second", ["class_a.ts"], 3, ["../../../c/third/class_c.ts"]); }); it("should find modules in node_modules", () => { - const files: MapLike = { + const files = createMap({ "/parent/node_modules/mod/index.d.ts": "export var x", "/parent/app/myapp.ts": `import {x} from "mod"` - }; + }); test(files, "/parent/app", ["myapp.ts"], 2, []); }); it("should find file referenced via absolute and relative names", () => { - const files: MapLike = { + const files = createMap({ "/a/b/c.ts": `/// `, "/a/b/b.ts": "var x" - }; + }); test(files, "/a/b", ["c.ts", "/a/b/b.ts"], 2, []); }); }); describe("Files with different casing", () => { const library = createSourceFile("lib.d.ts", "", ScriptTarget.ES5); - function test(files: MapLike, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { + function test(files: Map, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); if (!useCaseSensitiveFileNames) { - const f: MapLike = {}; - for (const fileName in files) { - f[getCanonicalFileName(fileName)] = files[fileName]; - } - files = f; + files = mapPairs(files, ([fileName, file]) => [getCanonicalFileName(fileName), file]); } const host: CompilerHost = { @@ -371,7 +367,7 @@ export = C; return library; } const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined; + return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, @@ -382,7 +378,7 @@ export = C; useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, fileExists: fileName => { const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return hasProperty(files, path); + return path in files; }, readFile: (fileName): string => { throw new Error("NotImplemented"); } }; @@ -395,57 +391,57 @@ export = C; } it("should succeed when the same file is referenced using absolute and relative names", () => { - const files: MapLike = { + const files = createMap({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" - }; + }); test(files, { module: ts.ModuleKind.AMD }, "/a/b", /*useCaseSensitiveFileNames*/ false, ["c.ts", "/a/b/d.ts"], []); }); it("should fail when two files used in program differ only in casing (tripleslash references)", () => { - const files: MapLike = { + const files = createMap({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" - }; + }); test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /*useCaseSensitiveFileNames*/ false, ["c.ts", "d.ts"], [1149]); }); it("should fail when two files used in program differ only in casing (imports)", () => { - const files: MapLike = { + const files = createMap({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/d.ts": "export var x" - }; + }); test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /*useCaseSensitiveFileNames*/ false, ["c.ts", "d.ts"], [1149]); }); it("should fail when two files used in program differ only in casing (imports, relative module names)", () => { - const files: MapLike = { + const files = createMap({ "moduleA.ts": `import {x} from "./ModuleB"`, "moduleB.ts": "export var x" - }; + }); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /*useCaseSensitiveFileNames*/ false, ["moduleA.ts", "moduleB.ts"], [1149]); }); it("should fail when two files exist on disk that differs only in casing", () => { - const files: MapLike = { + const files = createMap({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/D.ts": "export var x", "/a/b/d.ts": "export var y" - }; + }); test(files, { module: ts.ModuleKind.AMD }, "/a/b", /*useCaseSensitiveFileNames*/ true, ["c.ts", "d.ts"], [1149]); }); it("should fail when module name in 'require' calls has inconsistent casing", () => { - const files: MapLike = { + const files = createMap({ "moduleA.ts": `import a = require("./ModuleC")`, "moduleB.ts": `import a = require("./moduleC")`, "moduleC.ts": "export var x" - }; + }); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /*useCaseSensitiveFileNames*/ false, ["moduleA.ts", "moduleB.ts", "moduleC.ts"], [1149, 1149]); }); it("should fail when module names in 'require' calls has inconsistent casing and current directory has uppercase chars", () => { - const files: MapLike = { + const files = createMap({ "/a/B/c/moduleA.ts": `import a = require("./ModuleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", @@ -453,11 +449,11 @@ export = C; import a = require("./moduleA.ts"); import b = require("./moduleB.ts"); ` - }; + }); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], [1149]); }); it("should not fail when module names in 'require' calls has consistent casing and current directory has uppercase chars", () => { - const files: MapLike = { + const files = createMap({ "/a/B/c/moduleA.ts": `import a = require("./moduleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", @@ -465,7 +461,7 @@ import b = require("./moduleB.ts"); import a = require("./moduleA.ts"); import b = require("./moduleB.ts"); ` - }; + }); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], []); }); }); @@ -1023,7 +1019,7 @@ import b = require("./moduleB.ts"); const names = map(files, f => f.name); const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES6)), f => f.fileName); const compilerHost: CompilerHost = { - fileExists : fileName => hasProperty(sourceFiles, fileName), + fileExists : fileName => fileName in sourceFiles, getSourceFile: fileName => sourceFiles[fileName], getDefaultLibFileName: () => "lib.d.ts", writeFile(file, text) { @@ -1034,7 +1030,7 @@ import b = require("./moduleB.ts"); getCanonicalFileName: f => f.toLowerCase(), getNewLine: () => "\r\n", useCaseSensitiveFileNames: () => false, - readFile: fileName => hasProperty(sourceFiles, fileName) ? sourceFiles[fileName].text : undefined + readFile: fileName => fileName in sourceFiles ? sourceFiles[fileName].text : undefined }; const program1 = createProgram(names, {}, compilerHost); const diagnostics1 = program1.getFileProcessingDiagnostics().getDiagnostics(); diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 9d8b176a6a8..9f2b0c343c2 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -95,13 +95,14 @@ namespace ts { } } + function createSourceFileWithText(fileName: string, sourceText: SourceText, target: ScriptTarget) { + const file = createSourceFile(fileName, sourceText.getFullText(), target); + file.sourceText = sourceText; + return file; + } + function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget): CompilerHost { - const files: MapLike = {}; - for (const t of texts) { - const file = createSourceFile(t.name, t.text.getFullText(), target); - file.sourceText = t.text; - files[t.name] = file; - } + const files = arrayToMap(texts, t => t.name, t => createSourceFileWithText(t.name, t.text, target)); return { getSourceFile(fileName): SourceFile { @@ -128,10 +129,9 @@ namespace ts { getNewLine(): string { return sys ? sys.newLine : newLine; }, - fileExists: fileName => hasProperty(files, fileName), + fileExists: fileName => fileName in files, readFile: fileName => { - const file = getProperty(files, fileName); - return file && file.text; + return fileName in files ? files[fileName].text : undefined; } }; } @@ -152,19 +152,29 @@ namespace ts { return program; } - function checkResolvedModule(expected: ResolvedModule, actual: ResolvedModule): void { - assert.isTrue(actual !== undefined); - assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); - assert.isTrue(expected.isExternalLibraryImport === actual.isExternalLibraryImport, `'isExternalLibraryImport': expected '${expected.isExternalLibraryImport}' to be equal to '${actual.isExternalLibraryImport}'`); + function checkResolvedModule(expected: ResolvedModule, actual: ResolvedModule): boolean { + if (!expected === !actual) { + if (expected) { + assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); + assert.isTrue(expected.isExternalLibraryImport === actual.isExternalLibraryImport, `'isExternalLibraryImport': expected '${expected.isExternalLibraryImport}' to be equal to '${actual.isExternalLibraryImport}'`); + } + return true; + } + return false; } - function checkResolvedTypeDirective(expected: ResolvedTypeReferenceDirective, actual: ResolvedTypeReferenceDirective): void { - assert.isTrue(actual !== undefined); - assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); - assert.isTrue(expected.primary === actual.primary, `'primary': expected '${expected.primary}' to be equal to '${actual.primary}'`); + function checkResolvedTypeDirective(expected: ResolvedTypeReferenceDirective, actual: ResolvedTypeReferenceDirective): boolean { + if (!expected === !actual) { + if (expected) { + assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); + assert.isTrue(expected.primary === actual.primary, `'primary': expected '${expected.primary}' to be equal to '${actual.primary}'`); + } + return true; + } + return false; } - function checkCache(caption: string, program: Program, fileName: string, expectedContent: MapLike, getCache: (f: SourceFile) => MapLike, entryChecker: (expected: T, original: T) => void): void { + function checkCache(caption: string, program: Program, fileName: string, expectedContent: Map, getCache: (f: SourceFile) => Map, entryChecker: (expected: T, original: T) => boolean): void { const file = program.getSourceFile(fileName); assert.isTrue(file !== undefined, `cannot find file ${fileName}`); const cache = getCache(file); @@ -173,31 +183,15 @@ namespace ts { } else { assert.isTrue(cache !== undefined, `expected ${caption} to be set`); - const actualCacheSize = countOwnProperties(cache); - const expectedSize = countOwnProperties(expectedContent); - assert.isTrue(actualCacheSize === expectedSize, `expected actual size: ${actualCacheSize} to be equal to ${expectedSize}`); - - for (const id in expectedContent) { - if (hasProperty(expectedContent, id)) { - - if (expectedContent[id]) { - const expected = expectedContent[id]; - const actual = cache[id]; - entryChecker(expected, actual); - } - } - else { - assert.isTrue(cache[id] === undefined); - } - } + assert.isTrue(equalProperties(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); } } - function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: MapLike): void { + function checkResolvedModulesCache(program: Program, fileName: string, expectedContent: Map): void { checkCache("resolved modules", program, fileName, expectedContent, f => f.resolvedModules, checkResolvedModule); } - function checkResolvedTypeDirectivesCache(program: Program, fileName: string, expectedContent: MapLike): void { + function checkResolvedTypeDirectivesCache(program: Program, fileName: string, expectedContent: Map): void { checkCache("resolved type directives", program, fileName, expectedContent, f => f.resolvedTypeReferenceDirectiveNames, checkResolvedTypeDirective); } @@ -303,6 +297,8 @@ namespace ts { }); it("resolution cache follows imports", () => { + (Error).stackTraceLimit = Infinity; + const files = [ { name: "a.ts", text: SourceText.New("", "import {_} from 'b'", "var x = 1") }, { name: "b.ts", text: SourceText.New("", "", "var y = 2") }, @@ -310,7 +306,7 @@ namespace ts { const options: CompilerOptions = { target }; const program_1 = newProgram(files, ["a.ts"], options); - checkResolvedModulesCache(program_1, "a.ts", { "b": { resolvedFileName: "b.ts" } }); + checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": { resolvedFileName: "b.ts" } })); checkResolvedModulesCache(program_1, "b.ts", undefined); const program_2 = updateProgram(program_1, ["a.ts"], options, files => { @@ -319,7 +315,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedModulesCache(program_1, "a.ts", { "b": { resolvedFileName: "b.ts" } }); + checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": { resolvedFileName: "b.ts" } })); checkResolvedModulesCache(program_1, "b.ts", undefined); // imports has changed - program is not reused @@ -336,7 +332,7 @@ namespace ts { files[0].text = files[0].text.updateImportsAndExports(newImports); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedModulesCache(program_4, "a.ts", { "b": { resolvedFileName: "b.ts" }, "c": undefined }); + checkResolvedModulesCache(program_4, "a.ts", createMap({ "b": { resolvedFileName: "b.ts" }, "c": undefined })); }); it("resolved type directives cache follows type directives", () => { @@ -347,7 +343,7 @@ namespace ts { const options: CompilerOptions = { target, typeRoots: ["/types"] }; const program_1 = newProgram(files, ["/a.ts"], options); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", { "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); const program_2 = updateProgram(program_1, ["/a.ts"], options, files => { @@ -356,7 +352,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedTypeDirectivesCache(program_1, "/a.ts", { "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); // type reference directives has changed - program is not reused @@ -374,7 +370,7 @@ namespace ts { files[0].text = files[0].text.updateReferences(newReferences); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", { "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); }); }); diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index e8e06da7bad..cf7486acb40 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -362,13 +362,13 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks: ts.MapLike<(resp: protocol.Response) => void> = {}; - private eventHandlers: ts.MapLike<(args: any) => void> = {}; + private callbacks = createMap<(resp: protocol.Response) => void>(); + private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { if (msg.type === "response") { const response = msg; - if (this.callbacks[response.request_seq]) { + if (response.request_seq in this.callbacks) { this.callbacks[response.request_seq](response); delete this.callbacks[response.request_seq]; } @@ -380,7 +380,7 @@ namespace ts.server { } emit(name: string, args: any): void { - if (this.eventHandlers[name]) { + if (name in this.eventHandlers) { this.eventHandlers[name](args); } } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 1e76a636c9a..9887573436e 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -68,10 +68,10 @@ namespace ts { return entry; } - function checkMapKeys(caption: string, map: MapLike, expectedKeys: string[]) { - assert.equal(countOwnProperties(map), expectedKeys.length, `${caption}: incorrect size of map`); + function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { + assert.equal(countProperties(map), expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { - assert.isTrue(hasProperty(map, name), `${caption} is expected to contain ${name}, actual keys: ${getOwnKeys(map)}`); + assert.isTrue(name in map, `${caption} is expected to contain ${name}, actual keys: ${Object.keys(map)}`); } } @@ -116,8 +116,8 @@ namespace ts { private getCanonicalFileName: (s: string) => string; private toPath: (f: string) => Path; private callbackQueue: TimeOutCallback[] = []; - readonly watchedDirectories: MapLike<{ cb: DirectoryWatcherCallback, recursive: boolean }[]> = {}; - readonly watchedFiles: MapLike = {}; + readonly watchedDirectories = createMap<{ cb: DirectoryWatcherCallback, recursive: boolean }[]>(); + readonly watchedFiles = createMap(); constructor(public useCaseSensitiveFileNames: boolean, private executingFilePath: string, private currentDirectory: string, fileOrFolderList: FileOrFolder[]) { this.getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -198,7 +198,7 @@ namespace ts { watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher { const path = this.toPath(directoryName); - const callbacks = getProperty(this.watchedDirectories, path) || (this.watchedDirectories[path] = []); + const callbacks = this.watchedDirectories[path] || (this.watchedDirectories[path] = []); callbacks.push({ cb: callback, recursive }); return { referenceCount: 0, @@ -219,7 +219,7 @@ namespace ts { triggerDirectoryWatcherCallback(directoryName: string, fileName: string): void { const path = this.toPath(directoryName); - const callbacks = getProperty(this.watchedDirectories, path); + const callbacks = this.watchedDirectories[path]; if (callbacks) { for (const callback of callbacks) { callback.cb(fileName); @@ -229,7 +229,7 @@ namespace ts { triggerFileWatcherCallback(fileName: string, removed?: boolean): void { const path = this.toPath(fileName); - const callbacks = getProperty(this.watchedFiles, path); + const callbacks = this.watchedFiles[path]; if (callbacks) { for (const callback of callbacks) { callback(path, removed); @@ -239,7 +239,7 @@ namespace ts { watchFile(fileName: string, callback: FileWatcherCallback) { const path = this.toPath(fileName); - const callbacks = getProperty(this.watchedFiles, path) || (this.watchedFiles[path] = []); + const callbacks = this.watchedFiles[path] || (this.watchedFiles[path] = []); callbacks.push(callback); return { close: () => { diff --git a/src/server/session.ts b/src/server/session.ts index 13b0e6d6ce4..9383a54bd48 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -1061,7 +1061,7 @@ namespace ts.server { return { response, responseRequired: true }; } - private handlers: MapLike<(request: protocol.Request) => { response?: any, responseRequired?: boolean }> = { + private handlers = createMap<(request: protocol.Request) => { response?: any, responseRequired?: boolean }>({ [CommandNames.Exit]: () => { this.exit(); return { responseRequired: false }; @@ -1198,9 +1198,10 @@ namespace ts.server { this.reloadProjects(); return { responseRequired: false }; } - }; + }); + public addProtocolHandler(command: string, handler: (request: protocol.Request) => { response?: any, responseRequired: boolean }) { - if (this.handlers[command]) { + if (command in this.handlers) { throw new Error(`Protocol handler already exists for command "${command}"`); } this.handlers[command] = handler; diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index bac33a6bdfb..4f0e06244d2 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -58,12 +58,7 @@ namespace ts.JsTyping { if (!safeList) { const result = readConfigFile(safeListPath, (path: string) => host.readFile(path)); - if (result.config) { - safeList = result.config; - } - else { - safeList = createMap(); - }; + safeList = createMap(result.config); } const filesToWatch: string[] = []; @@ -93,7 +88,7 @@ namespace ts.JsTyping { // Add the cached typing locations for inferred typings that are already installed for (const name in packageNameToTypingLocation) { - if (hasProperty(inferredTypings, name) && !inferredTypings[name]) { + if (name in inferredTypings && !inferredTypings[name]) { inferredTypings[name] = packageNameToTypingLocation[name]; } } @@ -124,7 +119,7 @@ namespace ts.JsTyping { } for (const typing of typingNames) { - if (!hasProperty(inferredTypings, typing)) { + if (!(typing in inferredTypings)) { inferredTypings[typing] = undefined; } } @@ -167,7 +162,7 @@ namespace ts.JsTyping { mergeTypings(cleanedTypingNames); } else { - mergeTypings(filter(cleanedTypingNames, f => hasProperty(safeList, f))); + mergeTypings(filter(cleanedTypingNames, f => f in safeList)); } const hasJsxFile = forEach(fileNames, f => scriptKindIs(f, /*LanguageServiceHost*/ undefined, ScriptKind.JSX)); diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index cff3f591f8a..b4f67ca056d 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -188,7 +188,7 @@ namespace ts { } function getWordSpans(word: string): TextSpan[] { - if (!hasProperty(stringToWordSpans, word)) { + if (!(word in stringToWordSpans)) { stringToWordSpans[word] = breakIntoWordSpans(word); } diff --git a/src/services/services.ts b/src/services/services.ts index 0c1f5929fbf..87093645e2a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2042,7 +2042,7 @@ namespace ts { function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, o => - typeof o.type === "object" && !forEachOwnProperty(>o.type, v => typeof v !== "number")); + typeof o.type === "object" && !forEachProperty(o.type, v => typeof v !== "number")); options = clone(options); @@ -2117,7 +2117,9 @@ namespace ts { sourceFile.moduleName = transpileOptions.moduleName; } - sourceFile.renamedDependencies = transpileOptions.renamedDependencies; + if (transpileOptions.renamedDependencies) { + sourceFile.renamedDependencies = createMap(transpileOptions.renamedDependencies); + } const newLine = getNewLineCharacter(options); @@ -6745,7 +6747,7 @@ namespace ts { // the function will add any found symbol of the property-name, then its sub-routine will call // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (hasProperty(previousIterationSymbolsCache, symbol.name)) { + if (symbol.name in previousIterationSymbolsCache) { return; } From f7f50073d3e8166b04647617e94f438e69db5595 Mon Sep 17 00:00:00 2001 From: Yui Date: Tue, 16 Aug 2016 08:47:21 -0700 Subject: [PATCH 168/508] Fix 10625: JSX Not validating when index signature is present (#10352) * Check for type of property declaration before using index signature * Add tests and baselines * fix linting error --- src/compiler/checker.ts | 7 ++- .../tsxAttributeResolution14.errors.txt | 38 +++++++++++++++ .../reference/tsxAttributeResolution14.js | 47 +++++++++++++++++++ .../jsx/tsxAttributeResolution14.tsx | 32 +++++++++++++ 4 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 tests/baselines/reference/tsxAttributeResolution14.errors.txt create mode 100644 tests/baselines/reference/tsxAttributeResolution14.js create mode 100644 tests/cases/conformance/jsx/tsxAttributeResolution14.tsx diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 984cedbf5ad..25a35c307f4 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10140,10 +10140,9 @@ namespace ts { const correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); if (isUnhyphenatedJsxName(node.name.text)) { - // Maybe there's a string indexer? - const indexerType = getIndexTypeOfType(elementAttributesType, IndexKind.String); - if (indexerType) { - correspondingPropType = indexerType; + const attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, IndexKind.String); + if (attributeType) { + correspondingPropType = attributeType; } else { // If there's no corresponding property with this name, error diff --git a/tests/baselines/reference/tsxAttributeResolution14.errors.txt b/tests/baselines/reference/tsxAttributeResolution14.errors.txt new file mode 100644 index 00000000000..81d42e49059 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution14.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/jsx/file.tsx(14,28): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'boolean' is not assignable to type 'string | number'. + + +==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any; + } + interface ElementAttributesProperty { prop: any } + } + +==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== + + interface IProps { + primaryText: string, + [propName: string]: string | number + } + + function VerticalNavMenuItem(prop: IProps) { + return
props.primaryText
+ } + + function VerticalNav() { + return ( +
+ // error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + // ok + // error + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. +
+ ) + } \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution14.js b/tests/baselines/reference/tsxAttributeResolution14.js new file mode 100644 index 00000000000..d920179458c --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution14.js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/jsx/tsxAttributeResolution14.tsx] //// + +//// [react.d.ts] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any; + } + interface ElementAttributesProperty { prop: any } +} + +//// [file.tsx] + +interface IProps { + primaryText: string, + [propName: string]: string | number +} + +function VerticalNavMenuItem(prop: IProps) { + return
props.primaryText
+} + +function VerticalNav() { + return ( +
+ // error + // ok + // error +
+ ) +} + +//// [file.jsx] +function VerticalNavMenuItem(prop) { + return
props.primaryText
; +} +function VerticalNav() { + return (
+ // error + // error + // ok + // ok + // error + // error +
); +} diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx new file mode 100644 index 00000000000..1e4418e7fba --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx @@ -0,0 +1,32 @@ +//@jsx: preserve +//@module: amd + +//@filename: react.d.ts +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any; + } + interface ElementAttributesProperty { prop: any } +} + +//@filename: file.tsx + +interface IProps { + primaryText: string, + [propName: string]: string | number +} + +function VerticalNavMenuItem(prop: IProps) { + return
props.primaryText
+} + +function VerticalNav() { + return ( +
+ // error + // ok + // error +
+ ) +} \ No newline at end of file From 57701575044e8acbd55845cddb5bd7a7f08331b6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Tue, 16 Aug 2016 09:41:33 -0700 Subject: [PATCH 169/508] Adding more comments --- src/compiler/checker.ts | 15 ++++++++++++++- src/compiler/types.ts | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8a32e23e1ff..685b32f796f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8809,21 +8809,34 @@ namespace ts { const type = getTypeOfSymbol(localOrExportSymbol); const declaration = localOrExportSymbol.valueDeclaration; + // We only narrow variables and parameters occurring in a non-assignment position. For all other + // entities we simply return the declared type. if (!(localOrExportSymbol.flags & SymbolFlags.Variable) || isAssignmentTarget(node) || !declaration) { return type; } - + // The declaration container is the innermost function that encloses the declaration of the variable + // or parameter. The flow container is the innermost function starting with which we analyze the control + // flow graph to determine the control flow based type. const isParameter = getRootDeclaration(declaration).kind === SyntaxKind.Parameter; const declarationContainer = getControlFlowContainer(declaration); let flowContainer = getControlFlowContainer(node); + // When the control flow originates in a function expression or arrow function and we are referencing + // a const variable or parameter from an outer function, we extend the origin of the control flow + // analysis to include the immediately enclosing function. while (flowContainer !== declarationContainer && (flowContainer.kind === SyntaxKind.FunctionExpression || flowContainer.kind === SyntaxKind.ArrowFunction) && (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } + // We only look for uninitialized variables in strict null checking mode, and only when we can analyze + // the entire control flow graph from the variable's declaration (i.e. when the flow container and + // declaration container are the same). const assumeInitialized = !strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isParameter || flowContainer !== declarationContainer || isInAmbientContext(declaration); const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + // A variable is considered uninitialized when it is possible to analyze the entire control flow graph + // from declaration to use, and when the variable's declared type doesn't include undefined but the + // control flow based type does include undefined. if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) { error(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors diff --git a/src/compiler/types.ts b/src/compiler/types.ts index cca94c0adc1..8e9953ee64d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2157,7 +2157,7 @@ namespace ts { /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums /* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere - /* @internal */ isAssigned?: boolean; // True if the symbol has assignments + /* @internal */ isAssigned?: boolean; // True if the symbol is a parameter with assignments } /* @internal */ From 889e5ac7ae00d9aefd664d11ec942c13acdd79a4 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 16 Aug 2016 11:15:15 -0700 Subject: [PATCH 170/508] Clean up/move some Map helper functions. --- src/compiler/commandLineParser.ts | 4 +- src/compiler/core.ts | 151 ++---------------- src/harness/fourslash.ts | 2 +- src/harness/harnessLanguageService.ts | 2 +- src/harness/unittests/moduleResolution.ts | 2 +- .../unittests/reuseProgramStructure.ts | 2 +- .../unittests/tsserverProjectSystem.ts | 2 +- src/server/editorServices.ts | 2 +- src/services/services.ts | 2 +- 9 files changed, 18 insertions(+), 151 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 35140855d81..616bf5e70c0 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1016,8 +1016,8 @@ namespace ts { } } - const literalFiles = reduceOwnProperties(literalFileMap, addFileToOutput, []); - const wildcardFiles = reduceOwnProperties(wildcardFileMap, addFileToOutput, []); + const literalFiles = reduceProperties(literalFileMap, addFileToOutput, []); + const wildcardFiles = reduceProperties(wildcardFileMap, addFileToOutput, []); wildcardFiles.sort(host.useCaseSensitiveFileNames ? compareStrings : compareStringsCaseInsensitive); return { fileNames: literalFiles.concat(wildcardFiles), diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d10d76b3492..40341929c02 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -30,8 +30,10 @@ namespace ts { map["__"] = undefined; delete map["__"]; - if (template) { - copyOwnProperties(template, map); + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (const key in template) if (hasOwnProperty.call(template, key)) { + map[key] = template[key]; } return map; @@ -412,9 +414,6 @@ namespace ts { /** * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * forEachOwnProperties instead as it offers better runtime safety. - * * @param map A map for which properties should be enumerated. * @param callback A callback to invoke for each property. */ @@ -426,53 +425,6 @@ namespace ts { return result; } - /** - * Enumerates the owned properties of a MapLike, invoking a callback and returning the first truthy result. - * - * NOTE: This is intended for use with MapLike objects. For Map objects, use - * forEachProperty instead as it offers better performance. - * - * @param map A map for which properties should be enumerated. - * @param callback A callback to invoke for each property. - */ - export function forEachOwnProperty(map: MapLike, callback: (value: T, key: string) => U): U { - let result: U; - for (const key in map) if (hasOwnProperty.call(map, key)) { - if (result = callback(map[key], key)) break; - } - return result; - } - - /** - * Maps key-value pairs of a map into a new map. - * - * NOTE: The key-value pair passed to the callback is *not* safe to cache between invocations - * of the callback. - * - * @param map A map. - * @param callback A callback that maps a key-value pair into a new key-value pair. - */ - export function mapPairs(map: Map, callback: (entry: [string, T]) => [string, U]): Map { - let result: Map; - if (map) { - result = createMap(); - let inPair: [string, T]; - for (const key in map) { - if (inPair) { - inPair[0] = key; - inPair[1] = map[key]; - } - else { - inPair = [key, map[key]]; - } - - const outPair = callback(inPair); - result[outPair[0]] = outPair[1]; - } - } - return result; - } - /** * Returns true if a Map has some matching property. * @@ -489,9 +441,6 @@ namespace ts { /** * Performs a shallow copy of the properties from a source Map to a target MapLike * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * copyOwnProperties instead as it offers better runtime safety. - * * @param source A map from which properties should be copied. * @param target A map to which properties should be copied. */ @@ -501,21 +450,6 @@ namespace ts { } } - /** - * Performs a shallow copy of the owned properties from a source map to a target map-like. - * - * NOTE: This is intended for use with MapLike objects. For Map objects, use - * copyProperties instead as it offers better performance. - * - * @param source A map-like from which properties should be copied. - * @param target A map-like to which properties should be copied. - */ - export function copyOwnProperties(source: MapLike, target: MapLike): void { - for (const key in source) if (hasOwnProperty.call(source, key)) { - target[key] = source[key]; - } - } - /** * Reduce the properties of a map. * @@ -552,72 +486,9 @@ namespace ts { return result; } - /** - * Counts the properties of a map. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * countOwnProperties instead as it offers better runtime safety. - * - * @param map A map whose properties should be counted. - * @param predicate An optional callback used to limit which properties should be counted. - */ - export function countProperties(map: Map, predicate?: (value: T, key: string) => boolean) { - let count = 0; - for (const key in map) { - if (!predicate || predicate(map[key], key)) { - count++; - } - } - return count; - } - - /** - * Counts the owned properties of a map-like. - * - * NOTE: This is intended for use with MapLike objects. For Map objects, use - * countProperties instead as it offers better performance. - * - * @param map A map-like whose properties should be counted. - * @param predicate An optional callback used to limit which properties should be counted. - */ - export function countOwnProperties(map: MapLike, predicate?: (value: T, key: string) => boolean) { - let count = 0; - for (const key in map) if (hasOwnProperty.call(map, key)) { - if (!predicate || predicate(map[key], key)) { - count++; - } - } - return count; - } - - /** - * Performs a shallow equality comparison of the contents of two maps. - * - * NOTE: This is intended for use with Map objects. For MapLike objects, use - * equalOwnProperties instead as it offers better runtime safety. - * - * @param left A map whose properties should be compared. - * @param right A map whose properties should be compared. - */ - export function equalProperties(left: Map, right: Map, equalityComparer?: (left: T, right: T) => boolean) { - if (left === right) return true; - if (!left || !right) return false; - for (const key in left) { - if (!(key in right)) return false; - if (equalityComparer ? !equalityComparer(left[key], right[key]) : left[key] !== right[key]) return false; - } - for (const key in right) { - if (!(key in left)) return false; - } - return true; - } - /** * Performs a shallow equality comparison of the contents of two map-likes. * - * NOTE: This is intended for use with MapLike objects. For Map objects, use - * equalProperties instead as it offers better performance. - * * @param left A map-like whose properties should be compared. * @param right A map-like whose properties should be compared. */ @@ -670,17 +541,13 @@ namespace ts { return result; } - export function extend, T2 extends MapLike<{}>>(first: T1 , second: T2): T1 & T2 { + export function extend(first: T1 , second: T2): T1 & T2 { const result: T1 & T2 = {}; - for (const id in first) { - if (hasOwnProperty.call(first, id)) { - (result as any)[id] = first[id]; - } + for (const id in second) if (hasOwnProperty.call(second, id)) { + (result as any)[id] = (second as any)[id]; } - for (const id in second) { - if (hasOwnProperty.call(second, id) && !hasOwnProperty.call(result, id)) { - (result as any)[id] = second[id]; - } + for (const id in first) if (hasOwnProperty.call(first, id)) { + (result as any)[id] = (first as any)[id]; } return result; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index ba1994c8141..f9fdd5a1159 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -773,7 +773,7 @@ namespace FourSlash { } public verifyRangesWithSameTextReferenceEachOther() { - ts.forEachOwnProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); + ts.forEachProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); } private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index b37a6a90899..94124432780 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -135,7 +135,7 @@ namespace Harness.LanguageService { public getFilenames(): string[] { const fileNames: string[] = []; - ts.forEachOwnProperty(this.fileNameToScript, (scriptInfo) => { + ts.forEachProperty(this.fileNameToScript, (scriptInfo) => { if (scriptInfo.isRootFile) { // only include root files here // usually it means that we won't include lib.d.ts in the list of root files so it won't mess the computation of compilation root dir. diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index ff0151c40a5..09febd2300a 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -358,7 +358,7 @@ export = C; function test(files: Map, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); if (!useCaseSensitiveFileNames) { - files = mapPairs(files, ([fileName, file]) => [getCanonicalFileName(fileName), file]); + files = reduceProperties(files, (files, file, fileName) => (files[getCanonicalFileName(fileName)] = file, files), createMap()); } const host: CompilerHost = { diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 9f2b0c343c2..60687d34c55 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -183,7 +183,7 @@ namespace ts { } else { assert.isTrue(cache !== undefined, `expected ${caption} to be set`); - assert.isTrue(equalProperties(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); + assert.isTrue(equalOwnProperties(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); } } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 9887573436e..49f033b9def 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -69,7 +69,7 @@ namespace ts { } function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { - assert.equal(countProperties(map), expectedKeys.length, `${caption}: incorrect size of map`); + assert.equal(reduceProperties(map, count => count + 1, 0), expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { assert.isTrue(name in map, `${caption} is expected to contain ${name}, actual keys: ${Object.keys(map)}`); } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 9ba243d9704..db9bdd5043b 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1419,7 +1419,7 @@ namespace ts.server { /*recursive*/ true ); - project.directoriesWatchedForWildcards = reduceOwnProperties(projectOptions.wildcardDirectories, (watchers, flag, directory) => { + project.directoriesWatchedForWildcards = reduceProperties(createMap(projectOptions.wildcardDirectories), (watchers, flag, directory) => { if (comparePaths(configDirectoryPath, directory, ".", !this.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; this.log(`Add ${ recursive ? "recursive " : ""}watcher for: ${directory}`); diff --git a/src/services/services.ts b/src/services/services.ts index 87093645e2a..1153e2e9e3d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2058,7 +2058,7 @@ namespace ts { options[opt.name] = parseCustomTypeOption(opt, value, diagnostics); } else { - if (!forEachOwnProperty(opt.type, v => v === value)) { + if (!forEachProperty(opt.type, v => v === value)) { // Supplied value isn't a valid enum value. diagnostics.push(createCompilerDiagnosticForInvalidCustomType(opt)); } From c0146556e863f39eaa1922d66b1dda6b173f7b8a Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Tue, 16 Aug 2016 11:18:24 -0700 Subject: [PATCH 171/508] Revert some formatting changes. --- src/compiler/checker.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index c309b9e36c0..73ae7fc750d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8467,11 +8467,11 @@ namespace ts { return type; } const doubleEquals = operator === SyntaxKind.EqualsEqualsToken || operator === SyntaxKind.ExclamationEqualsToken; - const facts = doubleEquals - ? assumeTrue ? TypeFacts.EQUndefinedOrNull : TypeFacts.NEUndefinedOrNull - : value.kind === SyntaxKind.NullKeyword - ? assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull - : assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; + const facts = doubleEquals ? + assumeTrue ? TypeFacts.EQUndefinedOrNull : TypeFacts.NEUndefinedOrNull : + value.kind === SyntaxKind.NullKeyword ? + assumeTrue ? TypeFacts.EQNull : TypeFacts.NENull : + assumeTrue ? TypeFacts.EQUndefined : TypeFacts.NEUndefined; return getTypeWithFacts(type, facts); } if (type.flags & TypeFlags.NotUnionOrUnit) { @@ -8507,9 +8507,9 @@ namespace ts { return targetType; } } - const facts = assumeTrue - ? typeofEQFacts[literal.text] || TypeFacts.TypeofEQHostObject - : typeofNEFacts[literal.text] || TypeFacts.TypeofNEHostObject; + const facts = assumeTrue ? + typeofEQFacts[literal.text] || TypeFacts.TypeofEQHostObject : + typeofNEFacts[literal.text] || TypeFacts.TypeofNEHostObject; return getTypeWithFacts(type, facts); } From ce5e2078eed31c10c785150c22b4e31442f641e9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Tue, 16 Aug 2016 11:29:09 -0700 Subject: [PATCH 172/508] Improve ReadonlyArray.concat to match Array The Array-based signature was incorrect and also out-of-date. --- src/lib/es5.d.ts | 7 ++- ...typeIsAssignableToReadonlyArray.errors.txt | 46 ++++++++++++++++ ...rayOfSubtypeIsAssignableToReadonlyArray.js | 54 +++++++++++++++++++ ...rayOfSubtypeIsAssignableToReadonlyArray.ts | 18 +++++++ 4 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt create mode 100644 tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js create mode 100644 tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 496df578c19..e4cbe323c68 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1006,7 +1006,12 @@ interface ReadonlyArray { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: T[]): T[]; + concat(...items: T[][]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: (T | T[])[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt new file mode 100644 index 00000000000..6f4a0ef9d6d --- /dev/null +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -0,0 +1,46 @@ +tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray'. + Types of property 'concat' are incompatible. + Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. + Type 'A[]' is not assignable to type 'B[]'. + Type 'A' is not assignable to type 'B'. + Property 'b' is missing in type 'A'. +tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C' is not assignable to type 'ReadonlyArray'. + Types of property 'concat' are incompatible. + Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. + Type 'A[]' is not assignable to type 'B[]'. + Type 'A' is not assignable to type 'B'. + + +==== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts (2 errors) ==== + class A { a } + class B extends A { b } + class C extends Array { c } + declare var ara: A[]; + declare var arb: B[]; + declare var cra: C; + declare var crb: C; + declare var rra: ReadonlyArray; + declare var rrb: ReadonlyArray; + rra = ara; + rrb = arb; // OK, Array is assignable to ReadonlyArray + rra = arb; + rrb = ara; // error: 'A' is not assignable to 'B' + ~~~ +!!! error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray'. +!!! error TS2322: Types of property 'concat' are incompatible. +!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. +!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Property 'b' is missing in type 'A'. + + rra = cra; + rra = crb; // OK, C is assignable to ReadonlyArray + rrb = crb; + rrb = cra; // error: 'A' is not assignable to 'B' + ~~~ +!!! error TS2322: Type 'C' is not assignable to type 'ReadonlyArray'. +!!! error TS2322: Types of property 'concat' are incompatible. +!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. +!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. + \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js new file mode 100644 index 00000000000..255b52e16c9 --- /dev/null +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js @@ -0,0 +1,54 @@ +//// [arrayOfSubtypeIsAssignableToReadonlyArray.ts] +class A { a } +class B extends A { b } +class C extends Array { c } +declare var ara: A[]; +declare var arb: B[]; +declare var cra: C; +declare var crb: C; +declare var rra: ReadonlyArray; +declare var rrb: ReadonlyArray; +rra = ara; +rrb = arb; // OK, Array is assignable to ReadonlyArray +rra = arb; +rrb = ara; // error: 'A' is not assignable to 'B' + +rra = cra; +rra = crb; // OK, C is assignable to ReadonlyArray +rrb = crb; +rrb = cra; // error: 'A' is not assignable to 'B' + + +//// [arrayOfSubtypeIsAssignableToReadonlyArray.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +}(A)); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +}(Array)); +rra = ara; +rrb = arb; // OK, Array is assignable to ReadonlyArray +rra = arb; +rrb = ara; // error: 'A' is not assignable to 'B' +rra = cra; +rra = crb; // OK, C is assignable to ReadonlyArray +rrb = crb; +rrb = cra; // error: 'A' is not assignable to 'B' diff --git a/tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts b/tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts new file mode 100644 index 00000000000..d621cf460bc --- /dev/null +++ b/tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts @@ -0,0 +1,18 @@ +class A { a } +class B extends A { b } +class C extends Array { c } +declare var ara: A[]; +declare var arb: B[]; +declare var cra: C; +declare var crb: C; +declare var rra: ReadonlyArray; +declare var rrb: ReadonlyArray; +rra = ara; +rrb = arb; // OK, Array is assignable to ReadonlyArray +rra = arb; +rrb = ara; // error: 'A' is not assignable to 'B' + +rra = cra; +rra = crb; // OK, C is assignable to ReadonlyArray +rrb = crb; +rrb = cra; // error: 'A' is not assignable to 'B' From dcf3946b6876d6a9408bebef297f434b05168b33 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 16 Aug 2016 11:31:32 -0700 Subject: [PATCH 173/508] Fix link to blog --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fca2890bc77..d16bc363b26 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). +[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). ## Installing From a6974474a1fb850529378570da9e914f8a44040a Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 16 Aug 2016 13:51:17 -0700 Subject: [PATCH 174/508] Remove old assertion about when we're allowed to use fileExists --- src/services/services.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 850e29030d8..5876da74f15 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3114,7 +3114,6 @@ namespace ts { getCurrentDirectory: () => currentDirectory, fileExists: (fileName): boolean => { // stub missing host functionality - Debug.assert(!host.resolveModuleNames || !host.resolveTypeReferenceDirectives); return hostCache.getOrCreateEntry(fileName) !== undefined; }, readFile: (fileName): string => { From a66b38af56ab1b18e106829c23cbaf43ca4d38bb Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Tue, 16 Aug 2016 13:59:13 -0700 Subject: [PATCH 175/508] Set isNewIdentifierLocation to true for JavaScript files --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index aea4d5f872e..80eb0b3f46d 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4247,7 +4247,7 @@ namespace ts { addRange(entries, keywordCompletions); } - return { isMemberCompletion, isNewIdentifierLocation, entries }; + return { isMemberCompletion, isNewIdentifierLocation: isSourceFileJavaScript(sourceFile) ? true : isNewIdentifierLocation, entries }; function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map): CompletionEntry[] { const entries: CompletionEntry[] = []; From a36e15558e3e0608fc03986b422877a9a59d1b86 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Tue, 16 Aug 2016 14:04:02 -0700 Subject: [PATCH 176/508] Update error message for conflicting type definitions Fixes #10370 --- src/compiler/diagnosticMessages.json | 2 +- src/compiler/program.ts | 2 +- tests/baselines/reference/library-reference-5.errors.txt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index c1eead94f14..c6a3698ea16 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2231,7 +2231,7 @@ "category": "Error", "code": 4082 }, - "Conflicting library definitions for '{0}' found at '{1}' and '{2}'. Copy the correct file to the 'typings' folder to resolve this conflict.": { + "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": { "category": "Message", "code": 4090 }, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 767fcb488bb..3f698e82758 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2048,7 +2048,7 @@ namespace ts { const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, - Diagnostics.Conflicting_library_definitions_for_0_found_at_1_and_2_Copy_the_correct_file_to_the_typings_folder_to_resolve_this_conflict, + Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName diff --git a/tests/baselines/reference/library-reference-5.errors.txt b/tests/baselines/reference/library-reference-5.errors.txt index a3729bc3a99..c23b49c61de 100644 --- a/tests/baselines/reference/library-reference-5.errors.txt +++ b/tests/baselines/reference/library-reference-5.errors.txt @@ -1,4 +1,4 @@ -/node_modules/bar/index.d.ts(1,1): message TS4090: Conflicting library definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict. +/node_modules/bar/index.d.ts(1,1): message TS4090: Conflicting definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Consider installing a specific version of this library to resolve the conflict. ==== /src/root.ts (0 errors) ==== @@ -18,7 +18,7 @@ ==== /node_modules/bar/index.d.ts (1 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! message TS4090: Conflicting library definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict. +!!! message TS4090: Conflicting definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Consider installing a specific version of this library to resolve the conflict. declare var bar: any; ==== /node_modules/bar/node_modules/alpha/index.d.ts (0 errors) ==== From 2f4a855ab8631d5efe5c56a6c8a8334ccef55d2b Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 16 Aug 2016 14:55:19 -0700 Subject: [PATCH 177/508] Use rooted paths in the fourslash virtual file system --- src/compiler/checker.ts | 2 +- src/harness/fourslash.ts | 10 +++++++--- src/harness/harness.ts | 3 +++ src/harness/harnessLanguageService.ts | 20 ++++--------------- src/harness/virtualFileSystem.ts | 10 +++++++++- src/services/services.ts | 4 +--- ...sWhenEmitBlockingErrorOnOtherFile.baseline | 4 ++-- .../reference/getEmitOutput-pp.baseline | 8 ++++---- .../reference/getEmitOutput.baseline | 8 ++++---- ...etEmitOutputDeclarationMultiFiles.baseline | 8 ++++---- .../reference/getEmitOutputNoErrors.baseline | 2 +- .../getEmitOutputOnlyOneFile.baseline | 2 +- .../reference/getEmitOutputSourceMap.baseline | 4 ++-- .../getEmitOutputSourceRoot.baseline | 4 ++-- ...getEmitOutputSourceRootMultiFiles.baseline | 8 ++++---- .../getEmitOutputTsxFile_Preserve.baseline | 12 +++++------ .../getEmitOutputTsxFile_React.baseline | 12 +++++------ .../getEmitOutputWithDeclarationFile.baseline | 2 +- ...getEmitOutputWithDeclarationFile2.baseline | 4 ++-- ...mitOutputWithEarlySyntacticErrors.baseline | 2 +- .../getEmitOutputWithEmitterErrors.baseline | 2 +- .../getEmitOutputWithEmitterErrors2.baseline | 2 +- .../getEmitOutputWithSemanticErrors.baseline | 2 +- .../getEmitOutputWithSemanticErrors2.baseline | 4 ++-- ...ithSemanticErrorsForMultipleFiles.baseline | 4 ++-- ...thSyntacticErrorsForMultipleFiles.baseline | 2 +- .../getEmitOutputWithSyntaxErrors.baseline | 2 +- ...mpletionForStringLiteralRelativeImport4.ts | 2 +- .../fourslash/getEmitOutputSingleFile2.ts | 2 +- .../fourslash/renameForDefaultExport04.ts | 2 +- .../fourslash/renameForDefaultExport05.ts | 2 +- .../fourslash/renameForDefaultExport06.ts | 2 +- .../fourslash/renameForDefaultExport07.ts | 2 +- .../fourslash/renameForDefaultExport08.ts | 2 +- 34 files changed, 81 insertions(+), 80 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 498e8228e7a..d8504081070 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19892,7 +19892,7 @@ namespace ts { function getAmbientModules(): Symbol[] { const result: Symbol[] = []; for (const sym in globals) { - if (globals.hasOwnProperty(sym) && ambientModuleSymbolRegex.test(sym)) { + if (hasProperty(globals, sym) && ambientModuleSymbolRegex.test(sym)) { result.push(globals[sym]); } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 61041d1ab45..3ba8f5e3b17 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2352,12 +2352,16 @@ namespace FourSlash { } export function runFourSlashTestContent(basePath: string, testType: FourSlashTestType, content: string, fileName: string): void { + // Give file paths an absolute path for the virtual file system + const absoluteBasePath = ts.combinePaths(Harness.virtualFileSystemRoot, basePath); + const absoluteFileName = ts.combinePaths(Harness.virtualFileSystemRoot, fileName); + // Parse out the files and their metadata - const testData = parseTestData(basePath, content, fileName); - const state = new TestState(basePath, testType, testData); + const testData = parseTestData(absoluteBasePath, content, absoluteFileName); + const state = new TestState(absoluteBasePath, testType, testData); const output = ts.transpileModule(content, { reportDiagnostics: true }); if (output.diagnostics.length > 0) { - throw new Error(`Syntax error in ${basePath}: ${output.diagnostics[0].messageText}`); + throw new Error(`Syntax error in ${absoluteBasePath}: ${output.diagnostics[0].messageText}`); } runCode(output.outputText, state); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 6efb9400b37..35921f868e8 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -458,6 +458,9 @@ namespace Harness { // harness always uses one kind of new line const harnessNewLine = "\r\n"; + // Roote for file paths that are stored in a virtual file system + export const virtualFileSystemRoot = "/"; + namespace IOImpl { declare class Enumerator { public atEnd(): boolean; diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 50e3d425882..89997aeeab5 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -123,7 +123,7 @@ namespace Harness.LanguageService { } export class LanguageServiceAdapterHost { - protected virtualFileSystem: Utils.VirtualFileSystem = new Utils.VirtualFileSystem(/*root*/"c:", /*useCaseSensitiveFilenames*/false); + protected virtualFileSystem: Utils.VirtualFileSystem = new Utils.VirtualFileSystem(virtualFileSystemRoot, /*useCaseSensitiveFilenames*/false); constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, protected settings = ts.getDefaultCompilerOptions()) { @@ -191,7 +191,7 @@ namespace Harness.LanguageService { } return []; } - getCurrentDirectory(): string { return ""; } + getCurrentDirectory(): string { return virtualFileSystemRoot } getDefaultLibFileName(): string { return Harness.Compiler.defaultLibFileName; } getScriptFileNames(): string[] { return this.getFilenames(); } getScriptSnapshot(fileName: string): ts.IScriptSnapshot { @@ -211,7 +211,7 @@ namespace Harness.LanguageService { readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] { return ts.matchFiles(path, extensions, exclude, include, /*useCaseSensitiveFileNames*/false, - /*currentDirectory*/"/", + this.getCurrentDirectory(), (p) => this.virtualFileSystem.getAccessibleFileSystemEntries(p)); } readFile(path: string, encoding?: string): string { @@ -220,19 +220,7 @@ namespace Harness.LanguageService { } resolvePath(path: string): string { if (!ts.isRootedDiskPath(path)) { - // An "absolute" path for fourslash is one that is contained within the tests directory - const components = ts.getNormalizedPathComponents(path, this.getCurrentDirectory()); - if (components.length) { - // If this is still a relative path after normalization (i.e. currentDirectory is relative), the root will be the empty string - if (!components[0]) { - components.splice(0, 1); - if (components[0] !== "tests") { - // If not contained within test, assume its relative to the directory containing the test files - return ts.normalizePath(ts.combinePaths("tests/cases/fourslash", components.join(ts.directorySeparator))); - } - } - return ts.normalizePath(components.join(ts.directorySeparator)); - } + path = ts.combinePaths(this.getCurrentDirectory(), path); } return ts.normalizePath(path); } diff --git a/src/harness/virtualFileSystem.ts b/src/harness/virtualFileSystem.ts index c2502bbc80f..036965f75de 100644 --- a/src/harness/virtualFileSystem.ts +++ b/src/harness/virtualFileSystem.ts @@ -111,6 +111,7 @@ namespace Utils { getFileSystemEntries() { return this.root.getFileSystemEntries(); } addDirectory(path: string) { + path = this.normalizePathRoot(path); const components = ts.getNormalizedPathComponents(path, this.currentDirectory); let directory: VirtualDirectory = this.root; for (const component of components) { @@ -124,7 +125,7 @@ namespace Utils { } addFile(path: string, content?: T) { - const absolutePath = ts.getNormalizedAbsolutePath(path, this.currentDirectory); + const absolutePath = this.normalizePathRoot(ts.getNormalizedAbsolutePath(path, this.currentDirectory)); const fileName = ts.getBaseFileName(path); const directoryPath = ts.getDirectoryPath(absolutePath); const directory = this.addDirectory(directoryPath); @@ -141,6 +142,7 @@ namespace Utils { } traversePath(path: string) { + path = this.normalizePathRoot(path); let directory: VirtualDirectory = this.root; for (const component of ts.getNormalizedPathComponents(path, this.currentDirectory)) { const entry = directory.getFileSystemEntry(component); @@ -192,7 +194,13 @@ namespace Utils { } } + normalizePathRoot(path: string) { + const components = ts.getNormalizedPathComponents(path, this.currentDirectory); + // Toss the root component + components[0] = ""; + return components.join(ts.directorySeparator); + } } export class MockParseConfigHost extends VirtualFileSystem implements ts.ParseConfigHost { diff --git a/src/services/services.ts b/src/services/services.ts index bbcc9f95040..30500189111 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3154,9 +3154,7 @@ namespace ts { writeFile: (fileName, data, writeByteOrderMark) => { }, getCurrentDirectory: () => currentDirectory, fileExists: (fileName): boolean => { - // stub missing host functionality - Debug.assert(!host.resolveModuleNames || !host.resolveTypeReferenceDirectives); - return hostCache.getOrCreateEntry(fileName) !== undefined; + return host.fileExists(fileName); }, readFile: (fileName): string => { // stub missing host functionality diff --git a/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline b/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline index f9bcca268ec..a088006d145 100644 --- a/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline +++ b/tests/baselines/reference/compileOnSaveWorksWhenEmitBlockingErrorOnOtherFile.baseline @@ -1,8 +1,8 @@ EmitSkipped: true Diagnostics: - Cannot write file 'tests/cases/fourslash/b.js' because it would overwrite input file. + Cannot write file '/tests/cases/fourslash/b.js' because it would overwrite input file. EmitSkipped: false -FileName : tests/cases/fourslash/a.js +FileName : /tests/cases/fourslash/a.js function foo2() { return 30; } // no error - should emit a.js diff --git a/tests/baselines/reference/getEmitOutput-pp.baseline b/tests/baselines/reference/getEmitOutput-pp.baseline index d6952e4537d..683b454a275 100644 --- a/tests/baselines/reference/getEmitOutput-pp.baseline +++ b/tests/baselines/reference/getEmitOutput-pp.baseline @@ -1,12 +1,12 @@ EmitSkipped: false -FileName : tests/cases/fourslash/shims-pp/inputFile1.js +FileName : /tests/cases/fourslash/shims-pp/inputFile1.js var x = 5; var Bar = (function () { function Bar() { } return Bar; }()); -FileName : tests/cases/fourslash/shims-pp/inputFile1.d.ts +FileName : /tests/cases/fourslash/shims-pp/inputFile1.d.ts declare var x: number; declare class Bar { x: string; @@ -14,14 +14,14 @@ declare class Bar { } EmitSkipped: false -FileName : tests/cases/fourslash/shims-pp/inputFile2.js +FileName : /tests/cases/fourslash/shims-pp/inputFile2.js var x1 = "hello world"; var Foo = (function () { function Foo() { } return Foo; }()); -FileName : tests/cases/fourslash/shims-pp/inputFile2.d.ts +FileName : /tests/cases/fourslash/shims-pp/inputFile2.d.ts declare var x1: string; declare class Foo { x: string; diff --git a/tests/baselines/reference/getEmitOutput.baseline b/tests/baselines/reference/getEmitOutput.baseline index 52c7d8a7aae..8251850e1bb 100644 --- a/tests/baselines/reference/getEmitOutput.baseline +++ b/tests/baselines/reference/getEmitOutput.baseline @@ -1,12 +1,12 @@ EmitSkipped: false -FileName : tests/cases/fourslash/shims/inputFile1.js +FileName : /tests/cases/fourslash/shims/inputFile1.js var x = 5; var Bar = (function () { function Bar() { } return Bar; }()); -FileName : tests/cases/fourslash/shims/inputFile1.d.ts +FileName : /tests/cases/fourslash/shims/inputFile1.d.ts declare var x: number; declare class Bar { x: string; @@ -14,14 +14,14 @@ declare class Bar { } EmitSkipped: false -FileName : tests/cases/fourslash/shims/inputFile2.js +FileName : /tests/cases/fourslash/shims/inputFile2.js var x1 = "hello world"; var Foo = (function () { function Foo() { } return Foo; }()); -FileName : tests/cases/fourslash/shims/inputFile2.d.ts +FileName : /tests/cases/fourslash/shims/inputFile2.d.ts declare var x1: string; declare class Foo { x: string; diff --git a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline index 5a6fb434b1f..56eb932fb5d 100644 --- a/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputDeclarationMultiFiles.baseline @@ -1,12 +1,12 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile1.js +FileName : /tests/cases/fourslash/inputFile1.js var x = 5; var Bar = (function () { function Bar() { } return Bar; }()); -FileName : tests/cases/fourslash/inputFile1.d.ts +FileName : /tests/cases/fourslash/inputFile1.d.ts declare var x: number; declare class Bar { x: string; @@ -14,14 +14,14 @@ declare class Bar { } EmitSkipped: false -FileName : tests/cases/fourslash/inputFile2.js +FileName : /tests/cases/fourslash/inputFile2.js var x1 = "hello world"; var Foo = (function () { function Foo() { } return Foo; }()); -FileName : tests/cases/fourslash/inputFile2.d.ts +FileName : /tests/cases/fourslash/inputFile2.d.ts declare var x1: string; declare class Foo { x: string; diff --git a/tests/baselines/reference/getEmitOutputNoErrors.baseline b/tests/baselines/reference/getEmitOutputNoErrors.baseline index 461cba4ea05..6469ab3d1a7 100644 --- a/tests/baselines/reference/getEmitOutputNoErrors.baseline +++ b/tests/baselines/reference/getEmitOutputNoErrors.baseline @@ -1,5 +1,5 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile.js +FileName : /tests/cases/fourslash/inputFile.js var x; var M = (function () { function M() { diff --git a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline index 4d1c88e45b4..dbcfe28afaa 100644 --- a/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline +++ b/tests/baselines/reference/getEmitOutputOnlyOneFile.baseline @@ -1,5 +1,5 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile2.js +FileName : /tests/cases/fourslash/inputFile2.js var x; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/getEmitOutputSourceMap.baseline b/tests/baselines/reference/getEmitOutputSourceMap.baseline index 65257d63607..25667b8b701 100644 --- a/tests/baselines/reference/getEmitOutputSourceMap.baseline +++ b/tests/baselines/reference/getEmitOutputSourceMap.baseline @@ -1,6 +1,6 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile.js.map -{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile.js +FileName : /tests/cases/fourslash/inputFile.js.map +{"version":3,"file":"inputFile.js","sourceRoot":"","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile.js var x = 109; var foo = "hello world"; var M = (function () { diff --git a/tests/baselines/reference/getEmitOutputSourceRoot.baseline b/tests/baselines/reference/getEmitOutputSourceRoot.baseline index d38078a08e3..5881a61f22a 100644 --- a/tests/baselines/reference/getEmitOutputSourceRoot.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRoot.baseline @@ -1,6 +1,6 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile.js.map -{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile.js +FileName : /tests/cases/fourslash/inputFile.js.map +{"version":3,"file":"inputFile.js","sourceRoot":"sourceRootDir/","sources":["inputFile.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile.js var x = 109; var foo = "hello world"; var M = (function () { diff --git a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline index 50a6ad68605..62e3f2eb7e5 100644 --- a/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline +++ b/tests/baselines/reference/getEmitOutputSourceRootMultiFiles.baseline @@ -1,6 +1,6 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +FileName : /tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"sourceRootDir/","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,GAAG,CAAC;AACZ,IAAI,GAAG,GAAG,aAAa,CAAC;AACxB;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js var x = 109; var foo = "hello world"; var M = (function () { @@ -10,8 +10,8 @@ var M = (function () { }()); //# sourceMappingURL=inputFile1.js.map EmitSkipped: false -FileName : tests/cases/fourslash/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile2.js +FileName : /tests/cases/fourslash/inputFile2.js.map +{"version":3,"file":"inputFile2.js","sourceRoot":"sourceRootDir/","sources":["inputFile2.ts"],"names":[],"mappings":"AAAA,IAAI,GAAG,GAAG,wBAAwB,CAAC;AACnC;IAAA;IAGA,CAAC;IAAD,QAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile2.js var bar = "hello world Typescript"; var C = (function () { function C() { diff --git a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline index bebd1ff1dd1..015ddba07d9 100644 --- a/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline +++ b/tests/baselines/reference/getEmitOutputTsxFile_Preserve.baseline @@ -1,6 +1,6 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +FileName : /tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js // regular ts file var t = 5; var Bar = (function () { @@ -8,7 +8,7 @@ var Bar = (function () { } return Bar; }()); -//# sourceMappingURL=inputFile1.js.mapFileName : tests/cases/fourslash/inputFile1.d.ts +//# sourceMappingURL=inputFile1.js.mapFileName : /tests/cases/fourslash/inputFile1.d.ts declare var t: number; declare class Bar { x: string; @@ -16,11 +16,11 @@ declare class Bar { } EmitSkipped: false -FileName : tests/cases/fourslash/inputFile2.jsx.map -{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.jsx +FileName : /tests/cases/fourslash/inputFile2.jsx.map +{"version":3,"file":"inputFile2.jsx","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,CAAC,CAAC,EAAG,CAAA"}FileName : /tests/cases/fourslash/inputFile2.jsx var y = "my div"; var x =
; -//# sourceMappingURL=inputFile2.jsx.mapFileName : tests/cases/fourslash/inputFile2.d.ts +//# sourceMappingURL=inputFile2.jsx.mapFileName : /tests/cases/fourslash/inputFile2.d.ts declare var y: string; declare var x: any; diff --git a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline index 5b668fd65e8..b78cbecf6c3 100644 --- a/tests/baselines/reference/getEmitOutputTsxFile_React.baseline +++ b/tests/baselines/reference/getEmitOutputTsxFile_React.baseline @@ -1,6 +1,6 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile1.js.map -{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : tests/cases/fourslash/inputFile1.js +FileName : /tests/cases/fourslash/inputFile1.js.map +{"version":3,"file":"inputFile1.js","sourceRoot":"","sources":["inputFile1.ts"],"names":[],"mappings":"AAAA,kBAAkB;AACjB,IAAI,CAAC,GAAW,CAAC,CAAC;AAClB;IAAA;IAGA,CAAC;IAAD,UAAC;AAAD,CAAC,AAHD,IAGC"}FileName : /tests/cases/fourslash/inputFile1.js // regular ts file var t = 5; var Bar = (function () { @@ -8,7 +8,7 @@ var Bar = (function () { } return Bar; }()); -//# sourceMappingURL=inputFile1.js.mapFileName : tests/cases/fourslash/inputFile1.d.ts +//# sourceMappingURL=inputFile1.js.mapFileName : /tests/cases/fourslash/inputFile1.d.ts declare var t: number; declare class Bar { x: string; @@ -16,11 +16,11 @@ declare class Bar { } EmitSkipped: false -FileName : tests/cases/fourslash/inputFile2.js.map -{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,IAAC,IAAI,EAAG,CAAE,EAAG,CAAA"}FileName : tests/cases/fourslash/inputFile2.js +FileName : /tests/cases/fourslash/inputFile2.js.map +{"version":3,"file":"inputFile2.js","sourceRoot":"","sources":["inputFile2.tsx"],"names":[],"mappings":"AACA,IAAI,CAAC,GAAG,QAAQ,CAAC;AACjB,IAAI,CAAC,GAAG,qBAAC,GAAG,IAAC,IAAI,EAAG,CAAE,EAAG,CAAA"}FileName : /tests/cases/fourslash/inputFile2.js var y = "my div"; var x = React.createElement("div", {name: y}); -//# sourceMappingURL=inputFile2.js.mapFileName : tests/cases/fourslash/inputFile2.d.ts +//# sourceMappingURL=inputFile2.js.mapFileName : /tests/cases/fourslash/inputFile2.d.ts declare var React: any; declare var y: string; declare var x: any; diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline index af4ccd10580..a10ef5967b0 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile.baseline @@ -1,7 +1,7 @@ EmitSkipped: false EmitSkipped: false -FileName : tests/cases/fourslash/inputFile2.js +FileName : /tests/cases/fourslash/inputFile2.js var x1 = "hello world"; var Foo = (function () { function Foo() { diff --git a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline index 8e43219e005..5c865321691 100644 --- a/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline +++ b/tests/baselines/reference/getEmitOutputWithDeclarationFile2.baseline @@ -1,7 +1,7 @@ EmitSkipped: false EmitSkipped: false -FileName : tests/cases/fourslash/inputFile2.js +FileName : /tests/cases/fourslash/inputFile2.js "use strict"; var Foo = (function () { function Foo() { @@ -11,6 +11,6 @@ var Foo = (function () { exports.Foo = Foo; EmitSkipped: false -FileName : tests/cases/fourslash/inputFile3.js +FileName : /tests/cases/fourslash/inputFile3.js var x = "hello"; diff --git a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline index 9e2e9978f46..6609554a299 100644 --- a/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEarlySyntacticErrors.baseline @@ -1,5 +1,5 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile1.js +FileName : /tests/cases/fourslash/inputFile1.js // File contains early errors. All outputs should be skipped. var uninitialized_const_error; diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline index 8ba493e04b7..326d547ae1b 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors.baseline @@ -1,7 +1,7 @@ EmitSkipped: true Diagnostics: Exported variable 'foo' has or is using private name 'C'. -FileName : tests/cases/fourslash/inputFile.js +FileName : /tests/cases/fourslash/inputFile.js var M; (function (M) { var C = (function () { diff --git a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline index bf12bd35548..a181526eb27 100644 --- a/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithEmitterErrors2.baseline @@ -1,7 +1,7 @@ EmitSkipped: true Diagnostics: Exported variable 'foo' has or is using private name 'C'. -FileName : tests/cases/fourslash/inputFile.js +FileName : /tests/cases/fourslash/inputFile.js define(["require", "exports"], function (require, exports) { "use strict"; var C = (function () { diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline index b6249822131..55a58ea041f 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors.baseline @@ -1,4 +1,4 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile.js +FileName : /tests/cases/fourslash/inputFile.js var x = "hello world"; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline index 396e220bdb6..b5848da3457 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrors2.baseline @@ -1,6 +1,6 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile.js +FileName : /tests/cases/fourslash/inputFile.js var x = "hello world"; -FileName : tests/cases/fourslash/inputFile.d.ts +FileName : /tests/cases/fourslash/inputFile.d.ts declare var x: number; diff --git a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline index 7f012b6a546..4c22a7e3f93 100644 --- a/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline +++ b/tests/baselines/reference/getEmitOutputWithSemanticErrorsForMultipleFiles.baseline @@ -1,8 +1,8 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile1.js +FileName : /tests/cases/fourslash/inputFile1.js // File to emit, does not contain semantic errors // expected to be emitted correctelly regardless of the semantic errors in the other file var noErrors = true; -FileName : tests/cases/fourslash/inputFile1.d.ts +FileName : /tests/cases/fourslash/inputFile1.d.ts declare var noErrors: boolean; diff --git a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline index 701b275eb31..f51782cc75d 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntacticErrorsForMultipleFiles.baseline @@ -1,5 +1,5 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile1.js +FileName : /tests/cases/fourslash/inputFile1.js // File to emit, does not contain syntactic errors // expected to be emitted correctelly regardless of the syntactic errors in the other file var noErrors = true; diff --git a/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline b/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline index 2c341821fb0..8aa81ba60ce 100644 --- a/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline +++ b/tests/baselines/reference/getEmitOutputWithSyntaxErrors.baseline @@ -1,4 +1,4 @@ EmitSkipped: false -FileName : tests/cases/fourslash/inputFile.js +FileName : /tests/cases/fourslash/inputFile.js var x; diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index df30b925d11..ba9f95a08c2 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -2,7 +2,7 @@ // Should give completions for directories that are merged via the rootDirs compiler option -// @rootDirs: sub/src1,src2 +// @rootDirs: tests/cases/fourslash/sub/src1,tests/cases/fourslash/src2 // @Filename: src2/test0.ts //// import * as foo1 from "./mo/*import_as0*/ diff --git a/tests/cases/fourslash/getEmitOutputSingleFile2.ts b/tests/cases/fourslash/getEmitOutputSingleFile2.ts index 5dd0276a936..5d616b19e13 100644 --- a/tests/cases/fourslash/getEmitOutputSingleFile2.ts +++ b/tests/cases/fourslash/getEmitOutputSingleFile2.ts @@ -4,7 +4,7 @@ // @module: CommonJS // @declaration: true // @out: declSingleFile.js -// @outDir: tests/cases/fourslash/ +// @outDir: /tests/cases/fourslash/ // @Filename: inputFile1.ts //// var x: number = 5; diff --git a/tests/cases/fourslash/renameForDefaultExport04.ts b/tests/cases/fourslash/renameForDefaultExport04.ts index ba40374e262..b225c47b2b2 100644 --- a/tests/cases/fourslash/renameForDefaultExport04.ts +++ b/tests/cases/fourslash/renameForDefaultExport04.ts @@ -12,4 +12,4 @@ ////var y = new DefaultExportedClass; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass", '"/tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport05.ts b/tests/cases/fourslash/renameForDefaultExport05.ts index 099f878bda1..2e5fcd847d8 100644 --- a/tests/cases/fourslash/renameForDefaultExport05.ts +++ b/tests/cases/fourslash/renameForDefaultExport05.ts @@ -12,4 +12,4 @@ ////var y = new DefaultExportedClass; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass", '"/tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport06.ts b/tests/cases/fourslash/renameForDefaultExport06.ts index 3ec067b7029..ba7f8cac7d7 100644 --- a/tests/cases/fourslash/renameForDefaultExport06.ts +++ b/tests/cases/fourslash/renameForDefaultExport06.ts @@ -12,4 +12,4 @@ ////var y = new /**/[|DefaultExportedClass|]; goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedClass", '"tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedClass", '"/tests/cases/fourslash/foo".DefaultExportedClass'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport07.ts b/tests/cases/fourslash/renameForDefaultExport07.ts index b65f348f2a0..9e3b4741b55 100644 --- a/tests/cases/fourslash/renameForDefaultExport07.ts +++ b/tests/cases/fourslash/renameForDefaultExport07.ts @@ -13,4 +13,4 @@ ////var y = DefaultExportedFunction(); goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedFunction", '"/tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file diff --git a/tests/cases/fourslash/renameForDefaultExport08.ts b/tests/cases/fourslash/renameForDefaultExport08.ts index 9b3f23db2c1..ad8a2b8242f 100644 --- a/tests/cases/fourslash/renameForDefaultExport08.ts +++ b/tests/cases/fourslash/renameForDefaultExport08.ts @@ -13,4 +13,4 @@ ////var y = DefaultExportedFunction(); goTo.marker(); -verify.renameInfoSucceeded("DefaultExportedFunction", '"tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file +verify.renameInfoSucceeded("DefaultExportedFunction", '"/tests/cases/fourslash/foo".DefaultExportedFunction'); \ No newline at end of file From 310bce44591f2f8208a4381d9b15664b20c403f2 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 16 Aug 2016 15:18:25 -0700 Subject: [PATCH 178/508] Removing resolvePath from language service host --- src/harness/harnessLanguageService.ts | 9 --------- src/server/editorServices.ts | 5 ----- src/services/services.ts | 24 +++++++++--------------- src/services/shims.ts | 5 ----- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 89997aeeab5..9a6f9ef77ca 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -218,12 +218,6 @@ namespace Harness.LanguageService { const snapshot = this.getScriptSnapshot(path); return snapshot.getText(0, snapshot.getLength()); } - resolvePath(path: string): string { - if (!ts.isRootedDiskPath(path)) { - path = ts.combinePaths(this.getCurrentDirectory(), path); - } - return ts.normalizePath(path); - } log(s: string): void { } @@ -329,9 +323,6 @@ namespace Harness.LanguageService { const snapshot = this.nativeHost.getScriptSnapshot(fileName); return snapshot && snapshot.getText(0, snapshot.getLength()); } - resolvePath(path: string): string { - return this.nativeHost.resolvePath(path); - } log(s: string): void { this.nativeHost.log(s); } trace(s: string): void { this.nativeHost.trace(s); } error(s: string): void { this.nativeHost.error(s); } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6b2cdb804c4..3a1a4556e03 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -306,11 +306,6 @@ namespace ts.server { throw new Error("No script with name '" + filename + "'"); } - resolvePath(path: string): string { - const result = this.host.resolvePath(path); - return result; - } - fileExists(path: string): boolean { const result = this.host.fileExists(path); return result; diff --git a/src/services/services.ts b/src/services/services.ts index 30500189111..6108e1e976a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1159,7 +1159,6 @@ namespace ts { useCaseSensitiveFileNames?(): boolean; readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; - resolvePath(path: string): string; readFile(path: string, encoding?: string): string; fileExists(path: string): boolean; @@ -4589,7 +4588,7 @@ namespace ts { } const absolutePath = normalizeAndPreserveTrailingSlash(isRootedDiskPath(fragment) ? fragment : combinePaths(scriptPath, fragment)); - const baseDirectory = host.resolvePath(getDirectoryPath(absolutePath)); + const baseDirectory = getDirectoryPath(absolutePath); const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); if (directoryProbablyExists(baseDirectory, host)) { @@ -4827,7 +4826,14 @@ namespace ts { }); } else if (host.getDirectories && options.typeRoots) { - const absoluteRoots = map(options.typeRoots, rootDirectory => getAbsoluteProjectPath(rootDirectory, host, options.project)); + const absoluteRoots = map(options.typeRoots, rootDirectory => { + if (isRootedDiskPath(rootDirectory)) { + return normalizePath(rootDirectory); + } + + const basePath = options.project || host.getCurrentDirectory(); + return normalizePath(combinePaths(basePath, rootDirectory)); + }); forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectories(host, options, absoluteRoot, result)); } @@ -4842,18 +4848,6 @@ namespace ts { return result; } - function getAbsoluteProjectPath(path: string, host: LanguageServiceHost, projectDir?: string) { - if (isRootedDiskPath(path)) { - return normalizePath(path); - } - - if (projectDir) { - return normalizePath(combinePaths(projectDir, path)); - } - - return normalizePath(host.resolvePath(path)); - } - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: ImportCompletionEntry[]) { if (host.getDirectories && directoryProbablyExists(directory, host)) { forEach(host.getDirectories(directory), typeDirectory => { diff --git a/src/services/shims.ts b/src/services/shims.ts index 401137a28e9..b5ae306c71f 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -69,7 +69,6 @@ namespace ts { readDirectory(rootDir: string, extension: string, basePaths?: string, excludeEx?: string, includeFileEx?: string, includeDirEx?: string, depth?: number): string; readFile(path: string, encoding?: string): string; - resolvePath(path: string): string; fileExists(path: string): boolean; getModuleResolutionsForFile?(fileName: string): string; @@ -446,10 +445,6 @@ namespace ts { return this.shimHost.readFile(path, encoding); } - public resolvePath(path: string): string { - return this.shimHost.resolvePath(path); - } - public fileExists(path: string): boolean { return this.shimHost.fileExists(path); } From c42f1cb0d0fd298039bf6fe374e1d2a6acfe6214 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 17 Aug 2016 06:21:49 -0700 Subject: [PATCH 179/508] Explain why we lower-case type reference directives --- src/compiler/program.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 004f4102667..1c491aeeaac 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2010,6 +2010,7 @@ namespace ts { } function processTypeReferenceDirectives(file: SourceFile) { + // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. const typeDirectives = map(file.typeReferenceDirectives, ref => ref.fileName.toLocaleLowerCase()); const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.fileName); From 07a8f31a2d294fb7d9aca3fe937cab0bb5345e21 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 17 Aug 2016 10:43:02 -0700 Subject: [PATCH 180/508] Correctly merge bindThisPropertyAssignment Also simply it considerably after noticing that it's *only* called for Javascript files, so there was a lot of dead code for TS cases that never happened. --- src/compiler/binder.ts | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index ee82a88d7a5..5aaf6f50183 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1977,33 +1977,25 @@ namespace ts { } function bindThisPropertyAssignment(node: BinaryExpression) { + Debug.assert(isInJavaScriptFile(node)); // Declare a 'member' if the container is an ES5 class or ES6 constructor - let assignee: Node; if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) { - assignee = container; + container.symbol.members = container.symbol.members || createMap(); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); } else if (container.kind === SyntaxKind.Constructor) { - if (isInJavaScriptFile(node)) { - // this.foo assignment in a JavaScript class - // Bind this property to the containing class - const saveContainer = container; - container = container.parent; - bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.None); - container = saveContainer; - return; - } - else { - assignee = container.parent; + // this.foo assignment in a JavaScript class + // Bind this property to the containing class + const saveContainer = container; + container = container.parent; + // AND it can be overwritten by subsequent method declarations + const symbol = bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.None); + if (symbol) { + (symbol as Symbol).isReplaceableByMethod = true; } + container = saveContainer; } - else { - return; - } - assignee.symbol.members = assignee.symbol.members || createMap(); - // It's acceptable for multiple 'this' assignments of the same identifier to occur - // AND it can be overwritten by subsequent method declarations - const symbol = declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); - symbol.isReplaceableByMethod = true; } function bindPrototypePropertyAssignment(node: BinaryExpression) { From c73efe2fb629bcb3a283eaf7979d7070705546cc Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 17 Aug 2016 10:45:35 -0700 Subject: [PATCH 181/508] Fix comment --- src/compiler/binder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 5aaf6f50183..d8017d601ad 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1989,9 +1989,9 @@ namespace ts { // Bind this property to the containing class const saveContainer = container; container = container.parent; - // AND it can be overwritten by subsequent method declarations const symbol = bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.None); if (symbol) { + // constructor-declared symbols can be overwritten by subsequent method declarations (symbol as Symbol).isReplaceableByMethod = true; } container = saveContainer; From 2d1639fac81af24c2d015a5eca107a3c45ee11d4 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 17 Aug 2016 13:30:03 -0700 Subject: [PATCH 182/508] Property handle imcomplete control flow types in nested loops --- src/compiler/checker.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3d7fb7eb7e1..24fe429c6e3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8364,13 +8364,18 @@ namespace ts { // each antecedent code path. const antecedentTypes: Type[] = []; let subtypeReduction = false; + let firstAntecedentType: FlowType; flowLoopNodes[flowLoopCount] = flow; flowLoopKeys[flowLoopCount] = key; flowLoopTypes[flowLoopCount] = antecedentTypes; for (const antecedent of flow.antecedents) { flowLoopCount++; - const type = getTypeFromFlowType(getTypeAtFlowNode(antecedent)); + const flowType = getTypeAtFlowNode(antecedent); flowLoopCount--; + if (!firstAntecedentType) { + firstAntecedentType = flowType; + } + const type = getTypeFromFlowType(flowType); // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. @@ -8393,7 +8398,13 @@ namespace ts { break; } } - return cache[key] = getUnionType(antecedentTypes, subtypeReduction); + // The result is incomplete if the first antecedent (the non-looping control flow path) + // is incomplete. + const result = getUnionType(antecedentTypes, subtypeReduction); + if (isIncomplete(firstAntecedentType)) { + return createFlowType(result, /*incomplete*/ true); + } + return cache[key] = result; } function isMatchingReferenceDiscriminant(expr: Expression) { From 44476f1984959180370e10397b835619b448b11b Mon Sep 17 00:00:00 2001 From: Jason Ramsay Date: Wed, 17 Aug 2016 13:30:03 -0700 Subject: [PATCH 183/508] Update due to CR suggestion --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 80eb0b3f46d..1dd44577d7f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4247,7 +4247,7 @@ namespace ts { addRange(entries, keywordCompletions); } - return { isMemberCompletion, isNewIdentifierLocation: isSourceFileJavaScript(sourceFile) ? true : isNewIdentifierLocation, entries }; + return { isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation || isSourceFileJavaScript(sourceFile), entries }; function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map): CompletionEntry[] { const entries: CompletionEntry[] = []; From b93cdecdf5165ad0b569ca9a6b9d54626b4855b6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 17 Aug 2016 13:30:13 -0700 Subject: [PATCH 184/508] Add regression test --- .../reference/nestedLoopTypeGuards.js | 63 ++++++++++++ .../reference/nestedLoopTypeGuards.symbols | 66 +++++++++++++ .../reference/nestedLoopTypeGuards.types | 96 +++++++++++++++++++ tests/cases/compiler/nestedLoopTypeGuards.ts | 31 ++++++ 4 files changed, 256 insertions(+) create mode 100644 tests/baselines/reference/nestedLoopTypeGuards.js create mode 100644 tests/baselines/reference/nestedLoopTypeGuards.symbols create mode 100644 tests/baselines/reference/nestedLoopTypeGuards.types create mode 100644 tests/cases/compiler/nestedLoopTypeGuards.ts diff --git a/tests/baselines/reference/nestedLoopTypeGuards.js b/tests/baselines/reference/nestedLoopTypeGuards.js new file mode 100644 index 00000000000..ab1148413ef --- /dev/null +++ b/tests/baselines/reference/nestedLoopTypeGuards.js @@ -0,0 +1,63 @@ +//// [nestedLoopTypeGuards.ts] +// Repros from #10378 + +function f1() { + var a: boolean | number | string; + if (typeof a !== 'boolean') { + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { + for (var j = 0; j < 1; j++) {} + if (typeof a === 'string') { + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { + a.length; // Should not error here + } + } + } + } +} + +function f2() { + var a: string | number; + if (typeof a === 'string') { + while (1) { + while (1) {} + if (typeof a === 'string') { + while (1) { + a.length; // Should not error here + } + } + } + } +} + +//// [nestedLoopTypeGuards.js] +// Repros from #10378 +function f1() { + var a; + if (typeof a !== 'boolean') { + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { + for (var j = 0; j < 1; j++) { } + if (typeof a === 'string') { + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { + a.length; // Should not error here + } + } + } + } +} +function f2() { + var a; + if (typeof a === 'string') { + while (1) { + while (1) { } + if (typeof a === 'string') { + while (1) { + a.length; // Should not error here + } + } + } + } +} diff --git a/tests/baselines/reference/nestedLoopTypeGuards.symbols b/tests/baselines/reference/nestedLoopTypeGuards.symbols new file mode 100644 index 00000000000..74426576d5a --- /dev/null +++ b/tests/baselines/reference/nestedLoopTypeGuards.symbols @@ -0,0 +1,66 @@ +=== tests/cases/compiler/nestedLoopTypeGuards.ts === +// Repros from #10378 + +function f1() { +>f1 : Symbol(f1, Decl(nestedLoopTypeGuards.ts, 0, 0)) + + var a: boolean | number | string; +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 3, 7)) + + if (typeof a !== 'boolean') { +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 3, 7)) + + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { +>i : Symbol(i, Decl(nestedLoopTypeGuards.ts, 6, 16)) +>i : Symbol(i, Decl(nestedLoopTypeGuards.ts, 6, 16)) +>i : Symbol(i, Decl(nestedLoopTypeGuards.ts, 6, 16)) + + for (var j = 0; j < 1; j++) {} +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) + + if (typeof a === 'string') { +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 3, 7)) + + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) + + a.length; // Should not error here +>a.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 3, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } + } + } + } +} + +function f2() { +>f2 : Symbol(f2, Decl(nestedLoopTypeGuards.ts, 16, 1)) + + var a: string | number; +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 19, 7)) + + if (typeof a === 'string') { +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 19, 7)) + + while (1) { + while (1) {} + if (typeof a === 'string') { +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 19, 7)) + + while (1) { + a.length; // Should not error here +>a.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 19, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } + } + } + } +} diff --git a/tests/baselines/reference/nestedLoopTypeGuards.types b/tests/baselines/reference/nestedLoopTypeGuards.types new file mode 100644 index 00000000000..9611fba2fbf --- /dev/null +++ b/tests/baselines/reference/nestedLoopTypeGuards.types @@ -0,0 +1,96 @@ +=== tests/cases/compiler/nestedLoopTypeGuards.ts === +// Repros from #10378 + +function f1() { +>f1 : () => void + + var a: boolean | number | string; +>a : string | number | boolean + + if (typeof a !== 'boolean') { +>typeof a !== 'boolean' : boolean +>typeof a : string +>a : string | number | boolean +>'boolean' : "boolean" + + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { +>i : number +>0 : number +>i < 1 : boolean +>i : number +>1 : number +>i++ : number +>i : number + + for (var j = 0; j < 1; j++) {} +>j : number +>0 : number +>j < 1 : boolean +>j : number +>1 : number +>j++ : number +>j : number + + if (typeof a === 'string') { +>typeof a === 'string' : boolean +>typeof a : string +>a : string | number +>'string' : "string" + + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { +>j : number +>0 : number +>j < 1 : boolean +>j : number +>1 : number +>j++ : number +>j : number + + a.length; // Should not error here +>a.length : number +>a : string +>length : number + } + } + } + } +} + +function f2() { +>f2 : () => void + + var a: string | number; +>a : string | number + + if (typeof a === 'string') { +>typeof a === 'string' : boolean +>typeof a : string +>a : string | number +>'string' : "string" + + while (1) { +>1 : number + + while (1) {} +>1 : number + + if (typeof a === 'string') { +>typeof a === 'string' : boolean +>typeof a : string +>a : string +>'string' : "string" + + while (1) { +>1 : number + + a.length; // Should not error here +>a.length : number +>a : string +>length : number + } + } + } + } +} diff --git a/tests/cases/compiler/nestedLoopTypeGuards.ts b/tests/cases/compiler/nestedLoopTypeGuards.ts new file mode 100644 index 00000000000..90d7912dec5 --- /dev/null +++ b/tests/cases/compiler/nestedLoopTypeGuards.ts @@ -0,0 +1,31 @@ +// Repros from #10378 + +function f1() { + var a: boolean | number | string; + if (typeof a !== 'boolean') { + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { + for (var j = 0; j < 1; j++) {} + if (typeof a === 'string') { + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { + a.length; // Should not error here + } + } + } + } +} + +function f2() { + var a: string | number; + if (typeof a === 'string') { + while (1) { + while (1) {} + if (typeof a === 'string') { + while (1) { + a.length; // Should not error here + } + } + } + } +} \ No newline at end of file From 0f483d6546296da0dd4805eb7e7cdbdb1f436fd9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 17 Aug 2016 14:21:49 -0700 Subject: [PATCH 185/508] Assign and instantiate contextual this type if not present --- src/compiler/checker.ts | 17 +++-- ...instantiateContextuallyTypedGenericThis.js | 2 +- ...ntiateContextuallyTypedGenericThis.symbols | 4 +- ...tantiateContextuallyTypedGenericThis.types | 13 ++-- .../reference/thisTypeInFunctions.symbols | 18 ++--- .../reference/thisTypeInFunctions.types | 70 +++++++++---------- .../reference/thisTypeInFunctions2.symbols | 7 +- .../reference/thisTypeInFunctions2.types | 6 +- ...instantiateContextuallyTypedGenericThis.ts | 2 +- 9 files changed, 72 insertions(+), 67 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1aeeb1f2c17..17cfdf8976f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4785,9 +4785,6 @@ namespace ts { function getThisTypeOfSignature(signature: Signature): Type | undefined { if (signature.thisParameter) { - if (signature.mapper) { - signature = instantiateSignature(signature, signature.mapper); - } return getTypeOfSymbol(signature.thisParameter); } } @@ -9085,15 +9082,15 @@ namespace ts { return getInferredClassType(classSymbol); } } - const type = getContextuallyTypedThisType(container); - if (type) { - return type; - } const thisType = getThisTypeOfDeclaration(container); if (thisType) { return thisType; } + const type = getContextuallyTypedThisType(container); + if (type) { + return type; + } } if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); @@ -12277,8 +12274,10 @@ namespace ts { function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); if (context.thisParameter) { - // save the mapper in case we need to type `this` later - context.mapper = mapper; + if (!signature.thisParameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); } for (let i = 0; i < len; i++) { const parameter = signature.parameters[i]; diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js index 0233180873d..176df15985f 100644 --- a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js @@ -2,7 +2,7 @@ interface JQuery { each( collection: T[], callback: (this: T, dit: T) => T - ): any; + ): T[]; } let $: JQuery; diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols index 34a477b706a..1db5b30dd0b 100644 --- a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols @@ -16,7 +16,8 @@ interface JQuery { >T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) >T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) - ): any; + ): T[]; +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) } let $: JQuery; @@ -38,6 +39,7 @@ $.each(lines, function(dit) { >dit : Symbol(dit, Decl(instantiateContextuallyTypedGenericThis.ts, 8, 23)) >charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) >this.charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) +>this : Symbol(this, Decl(instantiateContextuallyTypedGenericThis.ts, 2, 36)) >charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) }); diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types index 060d35be21a..5cdce6b99fe 100644 --- a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types @@ -3,7 +3,7 @@ interface JQuery { >JQuery : JQuery each( ->each : (collection: T[], callback: (this: T, dit: T) => T) => any +>each : (collection: T[], callback: (this: T, dit: T) => T) => T[] >T : T collection: T[], callback: (this: T, dit: T) => T @@ -16,7 +16,8 @@ interface JQuery { >T : T >T : T - ): any; + ): T[]; +>T : T } let $: JQuery; @@ -27,12 +28,12 @@ let lines: string[]; >lines : string[] $.each(lines, function(dit) { ->$.each(lines, function(dit) { return dit.charAt(0) + this.charAt(1);}) : any ->$.each : (collection: T[], callback: (this: T, dit: T) => T) => any +>$.each(lines, function(dit) { return dit.charAt(0) + this.charAt(1);}) : string[] +>$.each : (collection: T[], callback: (this: T, dit: T) => T) => T[] >$ : JQuery ->each : (collection: T[], callback: (this: T, dit: T) => T) => any +>each : (collection: T[], callback: (this: T, dit: T) => T) => T[] >lines : string[] ->function(dit) { return dit.charAt(0) + this.charAt(1);} : (dit: string) => string +>function(dit) { return dit.charAt(0) + this.charAt(1);} : (this: string, dit: string) => string >dit : string return dit.charAt(0) + this.charAt(1); diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 8a0be7427ed..ad16785f288 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -135,7 +135,7 @@ let impl: I = { return this.a; >this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 24, 28)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 24, 23)) >a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) }, @@ -144,7 +144,7 @@ let impl: I = { return this.a; >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 22)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) }, @@ -153,7 +153,7 @@ let impl: I = { return this.a; >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 17)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) }, @@ -173,7 +173,7 @@ impl.explicitStructural = function() { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) >explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) >this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 24, 28)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 24, 23)) >a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) impl.explicitInterface = function() { return this.a; }; @@ -181,7 +181,7 @@ impl.explicitInterface = function() { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) >explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 22)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) impl.explicitStructural = () => 12; @@ -199,7 +199,7 @@ impl.explicitThis = function () { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) >explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 17)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) // parameter checking @@ -536,7 +536,7 @@ c.explicitC = function(m) { return this.n + m }; >explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 23)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 9, 14)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 23)) @@ -546,7 +546,7 @@ c.explicitProperty = function(m) { return this.n + m }; >explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 30)) >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 21)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 30)) @@ -556,7 +556,7 @@ c.explicitThis = function(m) { return this.n + m }; >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 6, 17)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 24c4fb87baf..863ecbce628 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -132,7 +132,7 @@ function implicitThis(n: number): number { let impl: I = { >impl : I >I : I ->{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; },} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(): number; explicitInterface(): number; explicitThis(): number; } +>{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; },} : { a: number; explicitVoid2: () => any; explicitVoid1(this: void): number; explicitStructural(this: { a: number; }): number; explicitInterface(this: I): number; explicitThis(this: I): number; } a: 12, >a : number @@ -146,11 +146,11 @@ let impl: I = { >a : any explicitVoid1() { return 12; }, ->explicitVoid1 : () => number +>explicitVoid1 : (this: void) => number >12 : number explicitStructural() { ->explicitStructural : () => number +>explicitStructural : (this: { a: number; }) => number return this.a; >this.a : number @@ -159,7 +159,7 @@ let impl: I = { }, explicitInterface() { ->explicitInterface : () => number +>explicitInterface : (this: I) => number return this.a; >this.a : number @@ -168,7 +168,7 @@ let impl: I = { }, explicitThis() { ->explicitThis : () => number +>explicitThis : (this: I) => number return this.a; >this.a : number @@ -178,11 +178,11 @@ let impl: I = { }, } impl.explicitVoid1 = function () { return 12; }; ->impl.explicitVoid1 = function () { return 12; } : () => number +>impl.explicitVoid1 = function () { return 12; } : (this: void) => number >impl.explicitVoid1 : (this: void) => number >impl : I >explicitVoid1 : (this: void) => number ->function () { return 12; } : () => number +>function () { return 12; } : (this: void) => number >12 : number impl.explicitVoid2 = () => 12; @@ -194,21 +194,21 @@ impl.explicitVoid2 = () => 12; >12 : number impl.explicitStructural = function() { return this.a; }; ->impl.explicitStructural = function() { return this.a; } : () => number +>impl.explicitStructural = function() { return this.a; } : (this: { a: number; }) => number >impl.explicitStructural : (this: { a: number; }) => number >impl : I >explicitStructural : (this: { a: number; }) => number ->function() { return this.a; } : () => number +>function() { return this.a; } : (this: { a: number; }) => number >this.a : number >this : { a: number; } >a : number impl.explicitInterface = function() { return this.a; }; ->impl.explicitInterface = function() { return this.a; } : () => number +>impl.explicitInterface = function() { return this.a; } : (this: I) => number >impl.explicitInterface : (this: I) => number >impl : I >explicitInterface : (this: I) => number ->function() { return this.a; } : () => number +>function() { return this.a; } : (this: I) => number >this.a : number >this : I >a : number @@ -230,11 +230,11 @@ impl.explicitInterface = () => 12; >12 : number impl.explicitThis = function () { return this.a; }; ->impl.explicitThis = function () { return this.a; } : () => number +>impl.explicitThis = function () { return this.a; } : (this: I) => number >impl.explicitThis : (this: I) => number >impl : I >explicitThis : (this: I) => number ->function () { return this.a; } : () => number +>function () { return this.a; } : (this: I) => number >this.a : number >this : I >a : number @@ -433,7 +433,7 @@ let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + th >this : { y: number; } >y : number >x : number ->x => x + this.y : (x: number) => any +>x => x + this.y : (this: { y: number; }, x: number) => any >x : number >x + this.y : any >x : number @@ -472,7 +472,7 @@ let specifiedLambda: (this: void, x: number) => number = x => x + 12; >specifiedLambda : (this: void, x: number) => number >this : void >x : number ->x => x + 12 : (x: number) => number +>x => x + 12 : (this: void, x: number) => number >x : number >x + 12 : number >x : number @@ -560,40 +560,40 @@ c.explicitProperty = reconstructed.explicitProperty; // lambdas are assignable to anything c.explicitC = m => m; ->c.explicitC = m => m : (m: number) => number +>c.explicitC = m => m : (this: C, m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->m => m : (m: number) => number +>m => m : (this: C, m: number) => number >m : number >m : number c.explicitThis = m => m; ->c.explicitThis = m => m : (m: number) => number +>c.explicitThis = m => m : (this: C, m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->m => m : (m: number) => number +>m => m : (this: C, m: number) => number >m : number >m : number c.explicitProperty = m => m; ->c.explicitProperty = m => m : (m: number) => number +>c.explicitProperty = m => m : (this: { n: number; }, m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->m => m : (m: number) => number +>m => m : (this: { n: number; }, m: number) => number >m : number >m : number // this inside lambdas refer to outer scope // the outer-scoped lambda at top-level is still just `any` c.explicitC = m => m + this.n; ->c.explicitC = m => m + this.n : (m: number) => any +>c.explicitC = m => m + this.n : (this: C, m: number) => any >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->m => m + this.n : (m: number) => any +>m => m + this.n : (this: C, m: number) => any >m : number >m + this.n : any >m : number @@ -602,11 +602,11 @@ c.explicitC = m => m + this.n; >n : any c.explicitThis = m => m + this.n; ->c.explicitThis = m => m + this.n : (m: number) => any +>c.explicitThis = m => m + this.n : (this: C, m: number) => any >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->m => m + this.n : (m: number) => any +>m => m + this.n : (this: C, m: number) => any >m : number >m + this.n : any >m : number @@ -615,11 +615,11 @@ c.explicitThis = m => m + this.n; >n : any c.explicitProperty = m => m + this.n; ->c.explicitProperty = m => m + this.n : (m: number) => any +>c.explicitProperty = m => m + this.n : (this: { n: number; }, m: number) => any >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->m => m + this.n : (m: number) => any +>m => m + this.n : (this: { n: number; }, m: number) => any >m : number >m + this.n : any >m : number @@ -652,11 +652,11 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC = function(m) { return this.n + m } : (m: number) => number +>c.explicitC = function(m) { return this.n + m } : (this: C, m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: C, m: number) => number >m : number >this.n + m : number >this.n : number @@ -665,11 +665,11 @@ c.explicitC = function(m) { return this.n + m }; >m : number c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty = function(m) { return this.n + m } : (m: number) => number +>c.explicitProperty = function(m) { return this.n + m } : (this: { n: number; }, m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: { n: number; }, m: number) => number >m : number >this.n + m : number >this.n : number @@ -678,11 +678,11 @@ c.explicitProperty = function(m) { return this.n + m }; >m : number c.explicitThis = function(m) { return this.n + m }; ->c.explicitThis = function(m) { return this.n + m } : (m: number) => number +>c.explicitThis = function(m) { return this.n + m } : (this: C, m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: C, m: number) => number >m : number >this.n + m : number >this.n : number @@ -723,11 +723,11 @@ c.explicitC = function(this: B, m: number) { return this.n + m }; // this:void compatibility c.explicitVoid = n => n; ->c.explicitVoid = n => n : (n: number) => number +>c.explicitVoid = n => n : (this: void, n: number) => number >c.explicitVoid : (this: void, m: number) => number >c : C >explicitVoid : (this: void, m: number) => number ->n => n : (n: number) => number +>n => n : (this: void, n: number) => number >n : number >n : number diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols index cdc7fb321d4..5cc26e3ad43 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.symbols +++ b/tests/baselines/reference/thisTypeInFunctions2.symbols @@ -61,12 +61,12 @@ extend1({ >init : Symbol(init, Decl(thisTypeInFunctions2.ts, 20, 9)) this // this: IndexedWithThis because of contextual typing. ->this : Symbol(IndexedWithThis, Decl(thisTypeInFunctions2.ts, 0, 0)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 2, 12)) // this.mine this.willDestroy >this.willDestroy : Symbol(IndexedWithThis.willDestroy, Decl(thisTypeInFunctions2.ts, 2, 32)) ->this : Symbol(IndexedWithThis, Decl(thisTypeInFunctions2.ts, 0, 0)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 2, 12)) >willDestroy : Symbol(IndexedWithThis.willDestroy, Decl(thisTypeInFunctions2.ts, 2, 32)) }, @@ -77,7 +77,10 @@ extend1({ >foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 26, 13)) this.url; // this: any because 'foo' matches the string indexer +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 4, 87)) + this.willDestroy; +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 4, 87)) } }); extend2({ diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types index 371b5f5cafc..25fb2f28a60 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.types +++ b/tests/baselines/reference/thisTypeInFunctions2.types @@ -58,10 +58,10 @@ declare function simple(arg: SimpleInterface): void; extend1({ >extend1({ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }}) : void >extend1 : (args: IndexedWithThis) => void ->{ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }} : { init(): void; mine: number; foo(): void; } +>{ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }} : { init(this: IndexedWithThis): void; mine: number; foo(this: any): void; } init() { ->init : () => void +>init : (this: IndexedWithThis) => void this // this: IndexedWithThis because of contextual typing. >this : IndexedWithThis @@ -78,7 +78,7 @@ extend1({ >12 : number foo() { ->foo : () => void +>foo : (this: any) => void this.url; // this: any because 'foo' matches the string indexer >this.url : any diff --git a/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts b/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts index f25e66ecfb8..f06f06ee7a1 100644 --- a/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts +++ b/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts @@ -1,7 +1,7 @@ interface JQuery { each( collection: T[], callback: (this: T, dit: T) => T - ): any; + ): T[]; } let $: JQuery; From da8fc5d5a90dc18e83a137ba7e04d38854fc1c7d Mon Sep 17 00:00:00 2001 From: Yui Date: Wed, 17 Aug 2016 15:23:28 -0700 Subject: [PATCH 186/508] Fix 10289: correctly generate tsconfig.json with --lib (#10355) * Separate generate tsconfig into its own function and implement init with --lib # Conflicts: # src/compiler/tsc.ts * Add tests and baselines; Update function name Add unittests and baselines Add unittests and baselines for generating tsconfig Move unittest into harness folder Update harness tsconfig.json USe correct function name * Use new MapLike interstead. Update unittest # Conflicts: # src/compiler/commandLineParser.ts * Update JakeFile * Add tests for incorrect cases * Address PR : remove explicity write node_modules --- Jakefile.js | 3 +- src/compiler/commandLineParser.ts | 96 +++++++++++++++++++ src/compiler/program.ts | 8 -- src/compiler/tsc.ts | 58 +---------- src/compiler/types.ts | 2 +- src/harness/tsconfig.json | 3 +- src/harness/unittests/initializeTSConfig.ts | 44 +++++++++ .../tsconfig.json | 8 ++ .../tsconfig.json | 9 ++ .../tsconfig.json | 9 ++ .../tsconfig.json | 13 +++ .../tsconfig.json | 12 +++ .../tsconfig.json | 8 ++ .../tsconfig.json | 12 +++ .../tsconfig.json | 12 +++ 15 files changed, 229 insertions(+), 68 deletions(-) create mode 100644 src/harness/unittests/initializeTSConfig.ts create mode 100644 tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json create mode 100644 tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json create mode 100644 tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json create mode 100644 tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json create mode 100644 tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json create mode 100644 tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json create mode 100644 tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json create mode 100644 tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json diff --git a/Jakefile.js b/Jakefile.js index 992839a8661..441f6aef4f9 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -180,7 +180,8 @@ var harnessSources = harnessCoreSources.concat([ "convertCompilerOptionsFromJson.ts", "convertTypingOptionsFromJson.ts", "tsserverProjectSystem.ts", - "matchFiles.ts" + "matchFiles.ts", + "initializeTSConfig.ts", ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 51dc2b498f1..6406455d713 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -466,6 +466,14 @@ namespace ts { shortOptionNames: Map; } + /* @internal */ + export const defaultInitCompilerOptions: CompilerOptions = { + module: ModuleKind.CommonJS, + target: ScriptTarget.ES5, + noImplicitAny: false, + sourceMap: false, + }; + let optionNameMapCache: OptionNameMap; /* @internal */ @@ -671,6 +679,94 @@ namespace ts { } } + /** + * Generate tsconfig configuration when running command line "--init" + * @param options commandlineOptions to be generated into tsconfig.json + * @param fileNames array of filenames to be generated into tsconfig.json + */ + /* @internal */ + export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: Map } { + const compilerOptions = extend(options, defaultInitCompilerOptions); + const configurations: any = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + // only set the files property if we have at least one file + configurations.files = fileNames; + } + + return configurations; + + function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map | undefined { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + // this is of a type CommandLineOptionOfPrimitiveType + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption((optionDefinition).element); + } + else { + return (optionDefinition).type; + } + } + + function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: MapLike): string | undefined { + // There is a typeMap associated with this command-line option so use it to map value back to its name + for (const key in customTypeMap) { + if (customTypeMap[key] === value) { + return key; + } + } + return undefined; + } + + function serializeCompilerOptions(options: CompilerOptions): Map { + const result = createMap(); + const optionsNameMap = getOptionNameMap().optionNameMap; + + for (const name in options) { + if (hasProperty(options, name)) { + // tsconfig only options cannot be specified via command line, + // so we can assume that only types that can appear here string | number | boolean + switch (name) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + const value = options[name]; + let optionDefinition = optionsNameMap[name.toLowerCase()]; + if (optionDefinition) { + const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + const convertedValue: string[] = []; + for (const element of value as (string | number)[]) { + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name] = convertedValue; + } + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; + } + } + } + return result; + } + } + /** * Remove the comments from a json like text. * Comments can be single line comments (starting with # or //) or multiline comments using / * * / diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 1c491aeeaac..e732fe21872 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -828,14 +828,6 @@ namespace ts { : { resolvedModule: undefined, failedLookupLocations }; } - /* @internal */ - export const defaultInitCompilerOptions: CompilerOptions = { - module: ModuleKind.CommonJS, - target: ScriptTarget.ES5, - noImplicitAny: false, - sourceMap: false, - }; - interface OutputFingerprint { hash: string; byteOrderMark: boolean; diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 8b445bcb626..62b58609086 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -763,67 +763,11 @@ namespace ts { reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* host */ undefined); } else { - const compilerOptions = extend(options, defaultInitCompilerOptions); - const configurations: any = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - - if (fileNames && fileNames.length) { - // only set the files property if we have at least one file - configurations.files = fileNames; - } - else { - configurations.exclude = ["node_modules"]; - if (compilerOptions.outDir) { - configurations.exclude.push(compilerOptions.outDir); - } - } - - sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + sys.writeFile(file, JSON.stringify(generateTSConfig(options, fileNames), undefined, 4)); reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* host */ undefined); } return; - - function serializeCompilerOptions(options: CompilerOptions): Map { - const result = createMap(); - const optionsNameMap = getOptionNameMap().optionNameMap; - - for (const name in options) { - if (hasProperty(options, name)) { - // tsconfig only options cannot be specified via command line, - // so we can assume that only types that can appear here string | number | boolean - const value = options[name]; - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - let optionDefinition = optionsNameMap[name.toLowerCase()]; - if (optionDefinition) { - if (typeof optionDefinition.type === "string") { - // string, number or boolean - result[name] = value; - } - else { - // Enum - const typeMap = >optionDefinition.type; - for (const key in typeMap) { - if (typeMap[key] === value) { - result[name] = key; - } - } - } - } - break; - } - } - } - return result; - } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0bbbd99bdd5..7594d2c3fb8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2766,7 +2766,7 @@ namespace ts { /* @internal */ export interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: Map; // an object literal mapping named values to actual values + type: Map; // an object literal mapping named values to actual values } /* @internal */ diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 3b9025c27c3..a21faf9dd07 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -89,6 +89,7 @@ "./unittests/convertCompilerOptionsFromJson.ts", "./unittests/convertTypingOptionsFromJson.ts", "./unittests/tsserverProjectSystem.ts", - "./unittests/matchFiles.ts" + "./unittests/matchFiles.ts", + "./unittests/initializeTSConfig.ts" ] } diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts new file mode 100644 index 00000000000..059f07e0115 --- /dev/null +++ b/src/harness/unittests/initializeTSConfig.ts @@ -0,0 +1,44 @@ +/// +/// + +namespace ts { + describe("initTSConfig", () => { + function initTSConfigCorrectly(name: string, commandLinesArgs: string[]) { + describe(name, () => { + const commandLine = parseCommandLine(commandLinesArgs); + const initResult = generateTSConfig(commandLine.options, commandLine.fileNames); + const outputFileName = `tsConfig/${name.replace(/[^a-z0-9\-. ]/ig, "")}/tsconfig.json`; + + it(`Correct output for ${outputFileName}`, () => { + Harness.Baseline.runBaseline("Correct output", outputFileName, () => { + if (initResult) { + return JSON.stringify(initResult, undefined, 4); + } + else { + // This can happen if compiler recieve invalid compiler-options + /* tslint:disable:no-null-keyword */ + return null; + /* tslint:enable:no-null-keyword */ + } + }); + }); + }); + } + + initTSConfigCorrectly("Default initialized TSConfig", ["--init"]); + + initTSConfigCorrectly("Initialized TSConfig with files options", ["--init", "file0.st", "file1.ts", "file2.ts"]); + + initTSConfigCorrectly("Initialized TSConfig with boolean value compiler options", ["--init", "--noUnusedLocals"]); + + initTSConfigCorrectly("Initialized TSConfig with enum value compiler options", ["--init", "--target", "es5", "--jsx", "react"]); + + initTSConfigCorrectly("Initialized TSConfig with list compiler options", ["--init", "--types", "jquery,mocha"]); + + initTSConfigCorrectly("Initialized TSConfig with list compiler options with enum value", ["--init", "--lib", "es5,es2015.core"]); + + initTSConfigCorrectly("Initialized TSConfig with incorrect compiler option", ["--init", "--someNonExistOption"]); + + initTSConfigCorrectly("Initialized TSConfig with incorrect compiler option value", ["--init", "--lib", "nonExistLib,es5,es2015.promise"]); + }); +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json new file mode 100644 index 00000000000..ea891967cb5 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json new file mode 100644 index 00000000000..abe135b4f16 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "noUnusedLocals": true + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json new file mode 100644 index 00000000000..e28b66c8c2b --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "jsx": "react" + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json new file mode 100644 index 00000000000..5273b3cb7c8 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + }, + "files": [ + "file0.st", + "file1.ts", + "file2.ts" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json new file mode 100644 index 00000000000..fa9cb6cad84 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "lib": [ + "es5", + "es2015.promise" + ] + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json new file mode 100644 index 00000000000..ea891967cb5 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json new file mode 100644 index 00000000000..3ff8208d9d6 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "lib": [ + "es5", + "es2015.core" + ] + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json new file mode 100644 index 00000000000..b1740ac4c12 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "types": [ + "jquery", + "mocha" + ] + } +} \ No newline at end of file From aa834d7f17933c913015a772b7e0bab1af18dde8 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 17 Aug 2016 15:49:57 -0700 Subject: [PATCH 187/508] JSDoc supports null, undefined and never types --- src/compiler/checker.ts | 6 ++++++ src/compiler/parser.ts | 5 ++++- src/compiler/types.ts | 5 ++++- .../reference/jsdocNeverUndefinedNull.js | 20 +++++++++++++++++++ .../reference/jsdocNeverUndefinedNull.symbols | 14 +++++++++++++ .../reference/jsdocNeverUndefinedNull.types | 14 +++++++++++++ .../jsdoc/jsdocNeverUndefinedNull.ts | 11 ++++++++++ 7 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/jsdocNeverUndefinedNull.js create mode 100644 tests/baselines/reference/jsdocNeverUndefinedNull.symbols create mode 100644 tests/baselines/reference/jsdocNeverUndefinedNull.types create mode 100644 tests/cases/conformance/jsdoc/jsdocNeverUndefinedNull.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 01f75dc12da..62a252b6d8d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5547,6 +5547,12 @@ namespace ts { return nullType; case SyntaxKind.NeverKeyword: return neverType; + case SyntaxKind.JSDocNullKeyword: + return nullType; + case SyntaxKind.JSDocUndefinedKeyword: + return undefinedType; + case SyntaxKind.JSDocNeverKeyword: + return neverType; case SyntaxKind.ThisType: case SyntaxKind.ThisKeyword: return getTypeFromThisTypeNode(node); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b05451340d1..f78346fd5cd 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1241,7 +1241,7 @@ namespace ts { // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === SyntaxKind.SemicolonToken && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === SyntaxKind.SemicolonToken && !inErrorRecovery); case ParsingContext.EnumMembers: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. @@ -5890,6 +5890,9 @@ namespace ts { case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: + case SyntaxKind.NullKeyword: + case SyntaxKind.UndefinedKeyword: + case SyntaxKind.NeverKeyword: return parseTokenNode(); case SyntaxKind.StringLiteral: case SyntaxKind.NumericLiteral: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 0bbbd99bdd5..1ada1e547f2 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -351,6 +351,9 @@ namespace ts { JSDocPropertyTag, JSDocTypeLiteral, JSDocLiteralType, + JSDocNullKeyword, + JSDocUndefinedKeyword, + JSDocNeverKeyword, // Synthesized list SyntaxList, @@ -383,7 +386,7 @@ namespace ts { FirstJSDocNode = JSDocTypeExpression, LastJSDocNode = JSDocLiteralType, FirstJSDocTagNode = JSDocComment, - LastJSDocTagNode = JSDocLiteralType + LastJSDocTagNode = JSDocNeverKeyword } export const enum NodeFlags { diff --git a/tests/baselines/reference/jsdocNeverUndefinedNull.js b/tests/baselines/reference/jsdocNeverUndefinedNull.js new file mode 100644 index 00000000000..e57b7091a3b --- /dev/null +++ b/tests/baselines/reference/jsdocNeverUndefinedNull.js @@ -0,0 +1,20 @@ +//// [in.js] +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +} + + +//// [out.js] +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +} diff --git a/tests/baselines/reference/jsdocNeverUndefinedNull.symbols b/tests/baselines/reference/jsdocNeverUndefinedNull.symbols new file mode 100644 index 00000000000..a57636ed344 --- /dev/null +++ b/tests/baselines/reference/jsdocNeverUndefinedNull.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/jsdoc/in.js === +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +>f : Symbol(f, Decl(in.js, 0, 0)) +>p1 : Symbol(p1, Decl(in.js, 6, 11)) +>p2 : Symbol(p2, Decl(in.js, 6, 14)) +>p3 : Symbol(p3, Decl(in.js, 6, 18)) +} + diff --git a/tests/baselines/reference/jsdocNeverUndefinedNull.types b/tests/baselines/reference/jsdocNeverUndefinedNull.types new file mode 100644 index 00000000000..fe57cc298e2 --- /dev/null +++ b/tests/baselines/reference/jsdocNeverUndefinedNull.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/jsdoc/in.js === +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +>f : (p1: never, p2: undefined, p3: null) => void +>p1 : never +>p2 : undefined +>p3 : null +} + diff --git a/tests/cases/conformance/jsdoc/jsdocNeverUndefinedNull.ts b/tests/cases/conformance/jsdoc/jsdocNeverUndefinedNull.ts new file mode 100644 index 00000000000..c095bc1c920 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocNeverUndefinedNull.ts @@ -0,0 +1,11 @@ +// @allowJs: true +// @filename: in.js +// @out: out.js +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +} From 164beb38d8606e6bf062ca2a0606dffaf8a14f3e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Wed, 17 Aug 2016 16:11:45 -0700 Subject: [PATCH 188/508] Update baselines in jsDocParsing unit tests --- src/compiler/parser.ts | 2 +- src/harness/unittests/jsDocParsing.ts | 24 +++++------------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f78346fd5cd..ea69a0270c1 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -1241,7 +1241,7 @@ namespace ts { // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === SyntaxKind.SemicolonToken && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === SyntaxKind.SemicolonToken && !inErrorRecovery); case ParsingContext.EnumMembers: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index d1ca42f3861..a9987ef3176 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -767,16 +767,9 @@ namespace ts { parsesCorrectly( "{null}", `{ - "kind": "JSDocTypeReference", + "kind": "NullKeyword", "pos": 1, - "end": 5, - "name": { - "kind": "Identifier", - "pos": 1, - "end": 5, - "originalKeywordKind": "NullKeyword", - "text": "null" - } + "end": 5 }`); }); @@ -784,16 +777,9 @@ namespace ts { parsesCorrectly( "{undefined}", `{ - "kind": "JSDocTypeReference", + "kind": "UndefinedKeyword", "pos": 1, - "end": 10, - "name": { - "kind": "Identifier", - "pos": 1, - "end": 10, - "originalKeywordKind": "UndefinedKeyword", - "text": "undefined" - } + "end": 10 }`); }); @@ -2379,4 +2365,4 @@ namespace ts { }); }); }); -} \ No newline at end of file +} From 73a857b306d9d86d95ef346abb932c7964e70554 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 17 Aug 2016 18:10:06 -0700 Subject: [PATCH 189/508] Restored comments to explain spreading 'arguments' into calls to 'super'. --- src/compiler/emitter.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 15220438d23..292a77a309f 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -5311,6 +5311,21 @@ const _super = (function (geti, seti) { emitSignatureParameters(ctor); } else { + // The ES2015 spec specifies in 14.5.14. Runtime Semantics: ClassDefinitionEvaluation: + // If constructor is empty, then + // If ClassHeritag_eopt is present and protoParent is not null, then + // Let constructor be the result of parsing the source text + // constructor(...args) { super (...args);} + // using the syntactic grammar with the goal symbol MethodDefinition[~Yield]. + // Else, + // Let constructor be the result of parsing the source text + // constructor( ){ } + // using the syntactic grammar with the goal symbol MethodDefinition[~Yield]. + // + // While we could emit the '...args' rest parameter, certain later tools in the pipeline might + // downlevel the '...args' portion less efficiently by naively copying the contents of 'arguments' to an array. + // Instead, we'll avoid using a rest parameter and spread into the super call as + // 'super(...arguments)' instead of 'super(...args)', as you can see below. write("()"); } } @@ -5349,6 +5364,7 @@ const _super = (function (geti, seti) { write("_super.apply(this, arguments);"); } else { + // See comment above on using '...arguments' instead of '...args'. write("super(...arguments);"); } emitEnd(baseTypeElement); From 2b72751de91512c193bc59fb674a407c5398020d Mon Sep 17 00:00:00 2001 From: Kevin Lang Date: Wed, 17 Aug 2016 20:08:01 -0700 Subject: [PATCH 190/508] make (no) space after type assertion user configurable --- src/harness/fourslash.ts | 1 + src/server/editorServices.ts | 1 + src/services/formatting/rules.ts | 12 +++++++++--- src/services/formatting/rulesProvider.ts | 9 ++++++++- src/services/services.ts | 1 + tests/cases/fourslash/formattingOptionsChange.ts | 2 ++ tests/cases/fourslash/fourslash.ts | 1 + 7 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index b5fa53763cb..3bd2f9ca077 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -326,6 +326,7 @@ namespace FourSlash { InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + InsertSpaceAfterTypeAssertion: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, }; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index db9bdd5043b..44121b622fa 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -1584,6 +1584,7 @@ namespace ts.server { InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false, InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false, InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false, + InsertSpaceAfterTypeAssertion: false, PlaceOpenBraceOnNewLineForFunctions: false, PlaceOpenBraceOnNewLineForControlBlocks: false, }); diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 1839726b9ad..13755f31d36 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -136,7 +136,6 @@ namespace ts.formatting { public NoSpaceAfterOpenAngularBracket: Rule; public NoSpaceBeforeCloseAngularBracket: Rule; public NoSpaceAfterCloseAngularBracket: Rule; - public NoSpaceAfterTypeAssertion: Rule; // Remove spaces in empty interface literals. e.g.: x: {} public NoSpaceBetweenEmptyInterfaceBraceBrackets: Rule; @@ -238,6 +237,10 @@ namespace ts.formatting { public NoSpaceBeforeEqualInJsxAttribute: Rule; public NoSpaceAfterEqualInJsxAttribute: Rule; + // No space after type assertions + public NoSpaceAfterTypeAssertion: Rule; + public SpaceAfterTypeAssertion: Rule; + constructor() { /// /// Common Rules @@ -371,7 +374,6 @@ namespace ts.formatting { this.NoSpaceAfterOpenAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.LessThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete)); this.NoSpaceBeforeCloseAngularBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.GreaterThanToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete)); this.NoSpaceAfterCloseAngularBracket = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.FromTokens([SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.GreaterThanToken, SyntaxKind.CommaToken])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), RuleAction.Delete)); - this.NoSpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Delete)); // Remove spaces in empty interface literals. e.g.: x: {} this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), RuleAction.Delete)); @@ -443,7 +445,6 @@ namespace ts.formatting { this.NoSpaceAfterOpenAngularBracket, this.NoSpaceBeforeCloseAngularBracket, this.NoSpaceAfterCloseAngularBracket, - this.NoSpaceAfterTypeAssertion, this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, @@ -522,6 +523,11 @@ namespace ts.formatting { // Insert space after function keyword for anonymous functions this.SpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); this.NoSpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Delete)); + + // No space after type assertion + this.NoSpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Delete)); + this.SpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Space)); + } /// diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index 1be0f9e912d..7e98f0a2290 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -124,9 +124,16 @@ namespace ts.formatting { rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); } + if (options.InsertSpaceAfterTypeAssertion) { + rules.push(this.globalRules.SpaceAfterTypeAssertion); + } + else { + rules.push(this.globalRules.NoSpaceAfterTypeAssertion); + } + rules = rules.concat(this.globalRules.LowPriorityCommonRules); return rules; } } -} \ No newline at end of file +} diff --git a/src/services/services.ts b/src/services/services.ts index ea85caf1332..1130a97d9ce 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1356,6 +1356,7 @@ namespace ts { InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + InsertSpaceAfterTypeAssertion: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string | undefined; diff --git a/tests/cases/fourslash/formattingOptionsChange.ts b/tests/cases/fourslash/formattingOptionsChange.ts index f266a8e96c1..d93f729f85f 100644 --- a/tests/cases/fourslash/formattingOptionsChange.ts +++ b/tests/cases/fourslash/formattingOptionsChange.ts @@ -8,6 +8,7 @@ /////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis*/(1 ) /////*InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets*/[1 ]; [ ]; []; [,]; /////*InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces*/`${1}`;`${ 1 }` +/////*InsertSpaceAfterTypeAssertion*/const bar = Thing.getFoo(); /////*PlaceOpenBraceOnNewLineForFunctions*/class foo { ////} /////*PlaceOpenBraceOnNewLineForControlBlocks*/if (true) { @@ -21,6 +22,7 @@ runTest("InsertSpaceAfterFunctionKeywordForAnonymousFunctions", "(function () { runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis", " ( 1 )", " (1)"); runTest("InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets", "[ 1 ];[];[];[ , ];", "[1];[];[];[,];"); runTest("InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces", "`${ 1 }`; `${ 1 }`", "`${1}`; `${1}`"); +runTest("InsertSpaceAfterTypeAssertion", "const bar = Thing.getFoo();", "const bar = Thing.getFoo();"); runTest("PlaceOpenBraceOnNewLineForFunctions", "class foo", "class foo {"); runTest("PlaceOpenBraceOnNewLineForControlBlocks", "if ( true )", "if ( true ) {"); diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 9ce3197a46f..aeded34093b 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -83,6 +83,7 @@ declare namespace FourSlashInterface { InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: boolean; InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: boolean; InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean; + InsertSpaceAfterTypeAssertion: boolean; PlaceOpenBraceOnNewLineForFunctions: boolean; PlaceOpenBraceOnNewLineForControlBlocks: boolean; [s: string]: boolean | number | string | undefined; From 111b7c55f892817c728720f398502428d370154e Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 17 Aug 2016 20:09:09 -0700 Subject: [PATCH 191/508] Added test. --- .../completionListInObjectLiteral4.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/cases/fourslash/completionListInObjectLiteral4.ts diff --git a/tests/cases/fourslash/completionListInObjectLiteral4.ts b/tests/cases/fourslash/completionListInObjectLiteral4.ts new file mode 100644 index 00000000000..c00462c8255 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectLiteral4.ts @@ -0,0 +1,28 @@ +/// + +// @strictNullChecks: true +////interface Thing { +//// hello: number; +//// world: string; +////} +//// +////declare function funcA(x : Thing): void; +////declare function funcB(x?: Thing): void; +////declare function funcC(x : Thing | null): void; +////declare function funcD(x : Thing | undefined): void; +////declare function funcE(x : Thing | null | undefined): void; +////declare function funcF(x?: Thing | null | undefined): void; +//// +////funcA({ /*A*/ }); +////funcB({ /*B*/ }); +////funcC({ /*C*/ }); +////funcD({ /*D*/ }); +////funcE({ /*E*/ }); +////funcF({ /*F*/ }); + + +for (const marker of test.markers()) { + goTo.position(marker.position); + verify.completionListContains("hello"); + verify.completionListContains("world"); +} From c1e70c97c066065fceade318af77e8b49f867dc7 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 17 Aug 2016 20:32:52 -0700 Subject: [PATCH 192/508] Use the non-nullable type of the contextual type for object completions. --- src/services/services.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index ea85caf1332..9ef14315cb6 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -3789,7 +3789,11 @@ namespace ts { // other than those within the declared type. isNewIdentifierLocation = true; + // If the object literal is being assigned to something of type 'null | { hello: string }', + // it clearly isn't trying to satisfy the 'null' type. So we grab the non-nullable type if possible. typeForObject = typeChecker.getContextualType(objectLikeContainer); + typeForObject = typeForObject && typeForObject.getNonNullableType(); + existingMembers = (objectLikeContainer).properties; } else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) { @@ -3801,7 +3805,7 @@ namespace ts { // We don't want to complete using the type acquired by the shape // of the binding pattern; we are only interested in types acquired // through type declaration or inference. - // Also proceed if rootDeclaration is parameter and if its containing function expression\arrow function is contextually typed - + // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function let canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); if (!canGetType && rootDeclaration.kind === SyntaxKind.Parameter) { From d24afc2ad0af8834b635afd8305b44b1f5ad6f77 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 18 Aug 2016 00:06:48 -0700 Subject: [PATCH 193/508] Return non-JsDocComment children ... to make syntactic classification work --- src/services/services.ts | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 148d3af427c..c4b42f94226 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -21,6 +21,7 @@ namespace ts { getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; + getNonJsDocCommentChildren?(sourceFile?: SourceFile): Node[]; getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; @@ -196,6 +197,7 @@ namespace ts { public parent: Node; public jsDocComments: JSDocComment[]; private _children: Node[]; + private _nonJsDocCommentChildren: Node[]; constructor(kind: SyntaxKind, pos: number, end: number) { this.pos = pos; @@ -273,20 +275,22 @@ namespace ts { } private createChildren(sourceFile?: SourceFile) { - let children: Node[]; + let jsDocCommentChildren: Node[]; + let nonJsDocCommentChildren: Node[]; if (this.kind >= SyntaxKind.FirstNode) { scanner.setText((sourceFile || this.getSourceFile()).text); - children = []; + jsDocCommentChildren = []; + nonJsDocCommentChildren = []; let pos = this.pos; const useJSDocScanner = this.kind >= SyntaxKind.FirstJSDocTagNode && this.kind <= SyntaxKind.LastJSDocTagNode; - const processNode = (node: Node) => { + const processNode = (node: Node, children = nonJsDocCommentChildren) => { if (pos < node.pos) { pos = this.addSyntheticNodes(children, pos, node.pos, useJSDocScanner); } children.push(node); pos = node.end; }; - const processNodes = (nodes: NodeArray) => { + const processNodes = (nodes: NodeArray, children = nonJsDocCommentChildren) => { if (pos < nodes.pos) { pos = this.addSyntheticNodes(children, pos, nodes.pos, useJSDocScanner); } @@ -296,16 +300,21 @@ namespace ts { // jsDocComments need to be the first children if (this.jsDocComments) { for (const jsDocComment of this.jsDocComments) { - processNode(jsDocComment); + processNode(jsDocComment, jsDocCommentChildren); } } + // For syntactic classifications, all trivia are classcified together, including jsdoc comments. + // For that to work, the jsdoc comments should still be the leading trivia of the first child. + // Restoring the scanner position ensures that. + pos = this.pos; forEachChild(this, processNode, processNodes); if (pos < this.end) { - this.addSyntheticNodes(children, pos, this.end); + this.addSyntheticNodes(nonJsDocCommentChildren, pos, this.end); } scanner.setText(undefined); } - this._children = children || emptyArray; + this._nonJsDocCommentChildren = nonJsDocCommentChildren || emptyArray; + this._children = concatenate(jsDocCommentChildren, this._nonJsDocCommentChildren); } public getChildCount(sourceFile?: SourceFile): number { @@ -323,6 +332,18 @@ namespace ts { return this._children; } + public getNonJsDocCommentChildren(sourceFile?: SourceFile): Node[] { + // If the cached children were cleared, that means some node before the current node has changed. + // so even if we have a cached nonJsDocCommentChildren, it would be outdated as well. + if (!this._children) { + this.createChildren(sourceFile); + } + // If the node has cached children but not nonJsDocCommentChildren, it means the children is not created + // via calling the "createChildren" method, so it can only be a SyntaxList. As SyntaxList cannot have jsDocCommentChildren + // anyways, we can just return its children. + return this._nonJsDocCommentChildren ? this._nonJsDocCommentChildren : this._children; + } + public getFirstToken(sourceFile?: SourceFile): Node { const children = this.getChildren(sourceFile); if (!children.length) { @@ -7725,7 +7746,7 @@ namespace ts { if (decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(element.kind); - const children = element.getChildren(sourceFile); + const children = element.getNonJsDocCommentChildren ? element.getNonJsDocCommentChildren(sourceFile) : element.getChildren(sourceFile); for (let i = 0, n = children.length; i < n; i++) { const child = children[i]; if (!tryClassifyNode(child)) { From 2e572201fdac48ca459380080e1a388fef8bc862 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 18 Aug 2016 07:38:20 -0700 Subject: [PATCH 194/508] Add more tests for `export = foo.bar`. --- .../reference/exportDefaultProperty2.js | 33 +++++++++++++++++++ .../reference/exportDefaultProperty2.symbols | 32 ++++++++++++++++++ .../reference/exportDefaultProperty2.types | 33 +++++++++++++++++++ .../reference/exportEqualsProperty2.js | 32 ++++++++++++++++++ .../reference/exportEqualsProperty2.symbols | 32 ++++++++++++++++++ .../reference/exportEqualsProperty2.types | 33 +++++++++++++++++++ .../cases/compiler/exportDefaultProperty2.ts | 15 +++++++++ tests/cases/compiler/exportEqualsProperty2.ts | 15 +++++++++ 8 files changed, 225 insertions(+) create mode 100644 tests/baselines/reference/exportDefaultProperty2.js create mode 100644 tests/baselines/reference/exportDefaultProperty2.symbols create mode 100644 tests/baselines/reference/exportDefaultProperty2.types create mode 100644 tests/baselines/reference/exportEqualsProperty2.js create mode 100644 tests/baselines/reference/exportEqualsProperty2.symbols create mode 100644 tests/baselines/reference/exportEqualsProperty2.types create mode 100644 tests/cases/compiler/exportDefaultProperty2.ts create mode 100644 tests/cases/compiler/exportEqualsProperty2.ts diff --git a/tests/baselines/reference/exportDefaultProperty2.js b/tests/baselines/reference/exportDefaultProperty2.js new file mode 100644 index 00000000000..88f0fbb4e20 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty2.js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/exportDefaultProperty2.ts] //// + +//// [a.ts] +// This test is just like exportEqualsProperty2, but with `export default`. + +class C { + static B: number; +} +namespace C { + export interface B { c: number } +} + +export default C.B; + +//// [b.ts] +import B from "./a.ts"; +const x: B = { c: B }; + + +//// [a.js] +// This test is just like exportEqualsProperty2, but with `export default`. +"use strict"; +var C = (function () { + function C() { + } + return C; +}()); +exports.__esModule = true; +exports["default"] = C.B; +//// [b.js] +"use strict"; +var a_ts_1 = require("./a.ts"); +var x = { c: a_ts_1["default"] }; diff --git a/tests/baselines/reference/exportDefaultProperty2.symbols b/tests/baselines/reference/exportDefaultProperty2.symbols new file mode 100644 index 00000000000..7ac99d53a08 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty2.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/a.ts === +// This test is just like exportEqualsProperty2, but with `export default`. + +class C { +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) + + static B: number; +>B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +} +namespace C { +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) + + export interface B { c: number } +>B : Symbol(B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>c : Symbol(B.c, Decl(a.ts, 6, 24)) +} + +export default C.B; +>C.B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) +>B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) + +=== tests/cases/compiler/b.ts === +import B from "./a.ts"; +>B : Symbol(B, Decl(b.ts, 0, 6)) + +const x: B = { c: B }; +>x : Symbol(x, Decl(b.ts, 1, 5)) +>B : Symbol(B, Decl(b.ts, 0, 6)) +>c : Symbol(c, Decl(b.ts, 1, 14)) +>B : Symbol(B, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/exportDefaultProperty2.types b/tests/baselines/reference/exportDefaultProperty2.types new file mode 100644 index 00000000000..8dff23f1c89 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty2.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/a.ts === +// This test is just like exportEqualsProperty2, but with `export default`. + +class C { +>C : C + + static B: number; +>B : number +} +namespace C { +>C : typeof C + + export interface B { c: number } +>B : B +>c : number +} + +export default C.B; +>C.B : number +>C : typeof C +>B : number + +=== tests/cases/compiler/b.ts === +import B from "./a.ts"; +>B : number + +const x: B = { c: B }; +>x : B +>B : B +>{ c: B } : { c: number; } +>c : number +>B : number + diff --git a/tests/baselines/reference/exportEqualsProperty2.js b/tests/baselines/reference/exportEqualsProperty2.js new file mode 100644 index 00000000000..283fa3996a7 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty2.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/exportEqualsProperty2.ts] //// + +//// [a.ts] +// This test is just like exportDefaultProperty2, but with `export =`. + +class C { + static B: number; +} +namespace C { + export interface B { c: number } +} + +export = C.B; + +//// [b.ts] +import B = require("./a.ts"); +const x: B = { c: B }; + + +//// [a.js] +// This test is just like exportDefaultProperty2, but with `export =`. +"use strict"; +var C = (function () { + function C() { + } + return C; +}()); +module.exports = C.B; +//// [b.js] +"use strict"; +var B = require("./a.ts"); +var x = { c: B }; diff --git a/tests/baselines/reference/exportEqualsProperty2.symbols b/tests/baselines/reference/exportEqualsProperty2.symbols new file mode 100644 index 00000000000..a765e95bdf3 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty2.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/b.ts === +import B = require("./a.ts"); +>B : Symbol(B, Decl(b.ts, 0, 0)) + +const x: B = { c: B }; +>x : Symbol(x, Decl(b.ts, 1, 5)) +>B : Symbol(B, Decl(b.ts, 0, 0)) +>c : Symbol(c, Decl(b.ts, 1, 14)) +>B : Symbol(B, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/a.ts === +// This test is just like exportDefaultProperty2, but with `export =`. + +class C { +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) + + static B: number; +>B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +} +namespace C { +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) + + export interface B { c: number } +>B : Symbol(B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>c : Symbol(B.c, Decl(a.ts, 6, 24)) +} + +export = C.B; +>C.B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) +>B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) + diff --git a/tests/baselines/reference/exportEqualsProperty2.types b/tests/baselines/reference/exportEqualsProperty2.types new file mode 100644 index 00000000000..90b239e7bb6 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty2.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/b.ts === +import B = require("./a.ts"); +>B : number + +const x: B = { c: B }; +>x : B +>B : B +>{ c: B } : { c: number; } +>c : number +>B : number + +=== tests/cases/compiler/a.ts === +// This test is just like exportDefaultProperty2, but with `export =`. + +class C { +>C : C + + static B: number; +>B : number +} +namespace C { +>C : typeof C + + export interface B { c: number } +>B : B +>c : number +} + +export = C.B; +>C.B : number +>C : typeof C +>B : number + diff --git a/tests/cases/compiler/exportDefaultProperty2.ts b/tests/cases/compiler/exportDefaultProperty2.ts new file mode 100644 index 00000000000..180a58a22d4 --- /dev/null +++ b/tests/cases/compiler/exportDefaultProperty2.ts @@ -0,0 +1,15 @@ +// This test is just like exportEqualsProperty2, but with `export default`. + +// @Filename: a.ts +class C { + static B: number; +} +namespace C { + export interface B { c: number } +} + +export default C.B; + +// @Filename: b.ts +import B from "./a.ts"; +const x: B = { c: B }; diff --git a/tests/cases/compiler/exportEqualsProperty2.ts b/tests/cases/compiler/exportEqualsProperty2.ts new file mode 100644 index 00000000000..6a07837334a --- /dev/null +++ b/tests/cases/compiler/exportEqualsProperty2.ts @@ -0,0 +1,15 @@ +// This test is just like exportDefaultProperty2, but with `export =`. + +// @Filename: a.ts +class C { + static B: number; +} +namespace C { + export interface B { c: number } +} + +export = C.B; + +// @Filename: b.ts +import B = require("./a.ts"); +const x: B = { c: B }; From 67b6c56ee8eacb554f5780e08ce887481f7934c4 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 18 Aug 2016 07:44:20 -0700 Subject: [PATCH 195/508] Output test baselines to tests/baselines/local instead of root --- src/harness/harness.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 9ed817eae49..db8c30ddcc9 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1667,10 +1667,10 @@ namespace Harness { const encoded_actual = Utils.encodeString(actual); if (expected !== encoded_actual) { if (actual === NoContent) { - IO.writeFile(relativeFileName + ".delete", ""); + IO.writeFile(localPath(relativeFileName + ".delete"), ""); } else { - IO.writeFile(relativeFileName, actual); + IO.writeFile(localPath(relativeFileName), actual); } // Overwrite & issue error const errMsg = "The baseline file " + relativeFileName + " has changed."; @@ -1678,6 +1678,7 @@ namespace Harness { } } + export function runBaseline( descriptionForDescribe: string, relativeFileName: string, From 8fc17afa003d53aa7baf914883f2b20606e8a879 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 18 Aug 2016 14:11:30 -0700 Subject: [PATCH 196/508] Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeScriptExtensions and rename --- src/compiler/core.ts | 2 ++ src/compiler/utilities.ts | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index d2ea69b304d..808f8a538df 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1243,6 +1243,8 @@ namespace ts { * List of supported extensions in order of file resolution precedence. */ export const supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"]; + /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ + export const supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"]; export const supportedJavascriptExtensions = [".js", ".jsx"]; const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 8b32d5351ea..faf210e461f 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2713,12 +2713,10 @@ namespace ts { return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension)); } - /** Return ".ts" or ".tsx" if that is the extension. */ + /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ export function tryExtractTypeScriptExtension(fileName: string): string | undefined { - return find(supportedTypescriptExtensionsWithDtsFirst, extension => fileExtensionIs(fileName, extension)); + return find(supportedTypescriptExtensionsForExtractExtension, extension => fileExtensionIs(fileName, extension)); } - // Must have '.d.ts' first because if '.ts' goes first, that will be detected as the extension instead of '.d.ts'. - const supportedTypescriptExtensionsWithDtsFirst = supportedTypeScriptExtensions.slice().reverse(); /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences From 952d2fecc1817eb86d241a9aa6f93ac560be1d27 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 18 Aug 2016 14:19:17 -0700 Subject: [PATCH 197/508] Fix comment --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 68753fdb638..361e293011b 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3386,7 +3386,7 @@ namespace ts { * 6) - UnaryExpression[?yield] * 7) ~ UnaryExpression[?yield] * 8) ! UnaryExpression[?yield] - * 9) [+Await] await AwaitExpression[?yield] + * 9) [+Await] await UnaryExpression[?yield] */ function parseSimpleUnaryExpression(): UnaryExpression { switch (token) { From b8963ba8f1bc17da896c4ade47e7a1f199ffda57 Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 18 Aug 2016 14:39:15 -0700 Subject: [PATCH 198/508] Fix RWC Runner (#10420) * Use /// +/// import fs = require('fs'); import path = require('path'); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 1266ffa5d37..7ea191e3c83 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -198,7 +198,8 @@ namespace RWC { } // Do not include the library in the baselines to avoid noise const baselineFiles = inputFiles.concat(otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName)); - return Harness.Compiler.getErrorBaseline(baselineFiles, compilerResult.errors); + const errors = compilerResult.errors.filter(e => !Harness.isDefaultLibraryFile(e.file.fileName)); + return Harness.Compiler.getErrorBaseline(baselineFiles, errors); }, false, baselineOpts); }); From 03dcdda44342a07ea10701ae1725f174941d2d97 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Thu, 18 Aug 2016 17:12:40 -0700 Subject: [PATCH 199/508] Treat special property access symbol differently ... when retriving documentation --- src/services/services.ts | 18 +++++++++++++++++ .../completionEntryDetailAcrossFiles01.ts | 20 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts diff --git a/src/services/services.ts b/src/services/services.ts index ea85caf1332..64b872d14a7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4913,6 +4913,24 @@ namespace ts { if (!documentation) { documentation = symbol.getDocumentationComment(); + if ((!documentation || documentation.length === 0) && symbol.flags & SymbolFlags.Property) { + // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` + // there documentation comments might be attached to the right hand side symbol of their declarations. + // The pattern of such special property access is that the parent symbol is the symbol of the file. + if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) { + forEach(symbol.declarations, declaration => { + if (declaration.parent && declaration.parent.kind === SyntaxKind.BinaryExpression) { + const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((declaration.parent).right); + if (rhsSymbol) { + documentation = rhsSymbol.getDocumentationComment(); + if (documentation && documentation.length > 0) { + return true; + } + } + } + }); + } + } } return { displayParts, documentation, symbolKind }; diff --git a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts new file mode 100644 index 00000000000..243975fde2d --- /dev/null +++ b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts @@ -0,0 +1,20 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: a.js +//// /** +//// * Modify the parameter +//// * @param {string} p1 +//// */ +//// var foo = function (p1) { } +//// exports.foo = foo; +//// fo/*1*/ + +// @Filename: b.ts +//// import a = require("./a"); +//// a.fo/*2*/ + +goTo.marker('1'); +verify.completionEntryDetailIs("foo", "var foo: (p1: string) => void", "Modify the parameter"); +goTo.marker('2'); +verify.completionEntryDetailIs("foo", "(property) a.foo: (p1: string) => void", "Modify the parameter"); From b452469419cfed00dc5b04f4d286c2c700ef2619 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 19 Aug 2016 06:14:28 -0700 Subject: [PATCH 200/508] Fix tests --- tests/baselines/reference/exportDefaultProperty2.js | 6 +++--- tests/baselines/reference/exportDefaultProperty2.symbols | 2 +- tests/baselines/reference/exportDefaultProperty2.types | 2 +- tests/baselines/reference/exportEqualsProperty2.js | 4 ++-- tests/baselines/reference/exportEqualsProperty2.symbols | 2 +- tests/baselines/reference/exportEqualsProperty2.types | 2 +- tests/cases/compiler/exportDefaultProperty2.ts | 2 +- tests/cases/compiler/exportEqualsProperty2.ts | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/baselines/reference/exportDefaultProperty2.js b/tests/baselines/reference/exportDefaultProperty2.js index 88f0fbb4e20..2b0a5dce526 100644 --- a/tests/baselines/reference/exportDefaultProperty2.js +++ b/tests/baselines/reference/exportDefaultProperty2.js @@ -13,7 +13,7 @@ namespace C { export default C.B; //// [b.ts] -import B from "./a.ts"; +import B from "./a"; const x: B = { c: B }; @@ -29,5 +29,5 @@ exports.__esModule = true; exports["default"] = C.B; //// [b.js] "use strict"; -var a_ts_1 = require("./a.ts"); -var x = { c: a_ts_1["default"] }; +var a_1 = require("./a"); +var x = { c: a_1["default"] }; diff --git a/tests/baselines/reference/exportDefaultProperty2.symbols b/tests/baselines/reference/exportDefaultProperty2.symbols index 7ac99d53a08..d3d7519aa94 100644 --- a/tests/baselines/reference/exportDefaultProperty2.symbols +++ b/tests/baselines/reference/exportDefaultProperty2.symbols @@ -21,7 +21,7 @@ export default C.B; >B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) === tests/cases/compiler/b.ts === -import B from "./a.ts"; +import B from "./a"; >B : Symbol(B, Decl(b.ts, 0, 6)) const x: B = { c: B }; diff --git a/tests/baselines/reference/exportDefaultProperty2.types b/tests/baselines/reference/exportDefaultProperty2.types index 8dff23f1c89..2fc9d3a4750 100644 --- a/tests/baselines/reference/exportDefaultProperty2.types +++ b/tests/baselines/reference/exportDefaultProperty2.types @@ -21,7 +21,7 @@ export default C.B; >B : number === tests/cases/compiler/b.ts === -import B from "./a.ts"; +import B from "./a"; >B : number const x: B = { c: B }; diff --git a/tests/baselines/reference/exportEqualsProperty2.js b/tests/baselines/reference/exportEqualsProperty2.js index 283fa3996a7..b5d91431722 100644 --- a/tests/baselines/reference/exportEqualsProperty2.js +++ b/tests/baselines/reference/exportEqualsProperty2.js @@ -13,7 +13,7 @@ namespace C { export = C.B; //// [b.ts] -import B = require("./a.ts"); +import B = require("./a"); const x: B = { c: B }; @@ -28,5 +28,5 @@ var C = (function () { module.exports = C.B; //// [b.js] "use strict"; -var B = require("./a.ts"); +var B = require("./a"); var x = { c: B }; diff --git a/tests/baselines/reference/exportEqualsProperty2.symbols b/tests/baselines/reference/exportEqualsProperty2.symbols index a765e95bdf3..df7eda76661 100644 --- a/tests/baselines/reference/exportEqualsProperty2.symbols +++ b/tests/baselines/reference/exportEqualsProperty2.symbols @@ -1,5 +1,5 @@ === tests/cases/compiler/b.ts === -import B = require("./a.ts"); +import B = require("./a"); >B : Symbol(B, Decl(b.ts, 0, 0)) const x: B = { c: B }; diff --git a/tests/baselines/reference/exportEqualsProperty2.types b/tests/baselines/reference/exportEqualsProperty2.types index 90b239e7bb6..4594cbfd015 100644 --- a/tests/baselines/reference/exportEqualsProperty2.types +++ b/tests/baselines/reference/exportEqualsProperty2.types @@ -1,5 +1,5 @@ === tests/cases/compiler/b.ts === -import B = require("./a.ts"); +import B = require("./a"); >B : number const x: B = { c: B }; diff --git a/tests/cases/compiler/exportDefaultProperty2.ts b/tests/cases/compiler/exportDefaultProperty2.ts index 180a58a22d4..0db617c93e1 100644 --- a/tests/cases/compiler/exportDefaultProperty2.ts +++ b/tests/cases/compiler/exportDefaultProperty2.ts @@ -11,5 +11,5 @@ namespace C { export default C.B; // @Filename: b.ts -import B from "./a.ts"; +import B from "./a"; const x: B = { c: B }; diff --git a/tests/cases/compiler/exportEqualsProperty2.ts b/tests/cases/compiler/exportEqualsProperty2.ts index 6a07837334a..61f117f1629 100644 --- a/tests/cases/compiler/exportEqualsProperty2.ts +++ b/tests/cases/compiler/exportEqualsProperty2.ts @@ -11,5 +11,5 @@ namespace C { export = C.B; // @Filename: b.ts -import B = require("./a.ts"); +import B = require("./a"); const x: B = { c: B }; From 949c517fdd1526eaadc70f906cd98829db97e4e5 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 15 Aug 2016 13:45:33 -0700 Subject: [PATCH 201/508] Add `multiMapAdd` helper --- src/compiler/core.ts | 15 +++++++++++++++ src/compiler/emitter.ts | 2 +- src/compiler/sys.ts | 2 +- src/harness/fourslash.ts | 3 +-- src/harness/unittests/tsserverProjectSystem.ts | 6 ++---- src/services/services.ts | 3 +-- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 27b27bc6532..8ac46f9df0d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -566,6 +566,21 @@ namespace ts { return result; } + /** + * Adds the value to an array of values associated with the key, and returns the array. + * Creates the array if it does not already exist. + */ + export function multiMapAdd(map: Map, key: string, value: V): V[] { + const values = map[key]; + if (values) { + values.push(value); + return values; + } + else { + return map[key] = [value]; + } + } + /** * Tests whether a value is an array. */ diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 357a15507a4..74553dac20e 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6847,7 +6847,7 @@ const _super = (function (geti, seti) { // export { x, y } for (const specifier of (node).exportClause.elements) { const name = (specifier.propertyName || specifier.name).text; - (exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier); + multiMapAdd(exportSpecifiers, name, specifier); } } break; diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 350d75429b7..458cbc99a47 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -267,7 +267,7 @@ namespace ts { } function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void { - (fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback); + multiMapAdd(fileWatcherCallbacks, filePath, callback); } function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index b5fa53763cb..aece7b5c3ec 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1635,8 +1635,7 @@ namespace FourSlash { const result = ts.createMap(); for (const range of this.getRanges()) { const text = this.rangeText(range); - const ranges = result[text] || (result[text] = []); - ranges.push(range); + ts.multiMapAdd(result, text, range); } return result; } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 49f033b9def..89def128f9e 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -198,8 +198,7 @@ namespace ts { watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher { const path = this.toPath(directoryName); - const callbacks = this.watchedDirectories[path] || (this.watchedDirectories[path] = []); - callbacks.push({ cb: callback, recursive }); + const callbacks = multiMapAdd(this.watchedDirectories, path, { cb: callback, recursive }); return { referenceCount: 0, directoryName, @@ -239,8 +238,7 @@ namespace ts { watchFile(fileName: string, callback: FileWatcherCallback) { const path = this.toPath(fileName); - const callbacks = this.watchedFiles[path] || (this.watchedFiles[path] = []); - callbacks.push(callback); + const callbacks = multiMapAdd(this.watchedFiles, path, callback); return { close: () => { const i = callbacks.indexOf(callback); diff --git a/src/services/services.ts b/src/services/services.ts index 9ef14315cb6..1c28495dcac 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -984,8 +984,7 @@ namespace ts { function addDeclaration(declaration: Declaration) { const name = getDeclarationName(declaration); if (name) { - const declarations = getDeclarations(name); - declarations.push(declaration); + multiMapAdd(result, name, declaration); } } From 7f6e36c7e1308bc4c87dacb9eb458059d4377b77 Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 19 Aug 2016 10:03:23 -0700 Subject: [PATCH 202/508] Update shim version to be 2.1 (#10424) --- src/services/shims.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/shims.ts b/src/services/shims.ts index ff57dd9cf7a..9a581ed6be1 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -1203,6 +1203,6 @@ namespace TypeScript.Services { // TODO: it should be moved into a namespace though. /* @internal */ -const toolsVersion = "1.9"; +const toolsVersion = "2.1"; /* tslint:enable:no-unused-variable */ From 0168ab2051bc9a364f8f148296cf71848fc4bba9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 19 Aug 2016 13:34:06 -0700 Subject: [PATCH 203/508] Check return code paths on getters (#10102) * Check return paths on getters * Remove TODO comment --- src/compiler/checker.ts | 12 ++--- .../getterControlFlowStrictNull.errors.txt | 27 +++++++++++ .../reference/getterControlFlowStrictNull.js | 47 +++++++++++++++++++ .../compiler/getterControlFlowStrictNull.ts | 20 ++++++++ 4 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/getterControlFlowStrictNull.errors.txt create mode 100644 tests/baselines/reference/getterControlFlowStrictNull.js create mode 100644 tests/cases/compiler/getterControlFlowStrictNull.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d954ea51170..8568cd5feed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -14126,12 +14126,7 @@ namespace ts { checkSignatureDeclaration(node); if (node.kind === SyntaxKind.GetAccessor) { if (!isInAmbientContext(node) && nodeIsPresent(node.body) && (node.flags & NodeFlags.HasImplicitReturn)) { - if (node.flags & NodeFlags.HasExplicitReturn) { - if (compilerOptions.noImplicitReturns) { - error(node.name, Diagnostics.Not_all_code_paths_return_a_value); - } - } - else { + if (!(node.flags & NodeFlags.HasExplicitReturn)) { error(node.name, Diagnostics.A_get_accessor_must_return_a_value); } } @@ -14161,7 +14156,10 @@ namespace ts { checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } - getTypeOfAccessors(getSymbolOfNode(node)); + const returnType = getTypeOfAccessors(getSymbolOfNode(node)); + if (node.kind === SyntaxKind.GetAccessor) { + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); + } } if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) { checkSourceElement(node.body); diff --git a/tests/baselines/reference/getterControlFlowStrictNull.errors.txt b/tests/baselines/reference/getterControlFlowStrictNull.errors.txt new file mode 100644 index 00000000000..1c4f02d6a75 --- /dev/null +++ b/tests/baselines/reference/getterControlFlowStrictNull.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/getterControlFlowStrictNull.ts(2,9): error TS2366: Function lacks ending return statement and return type does not include 'undefined'. +tests/cases/compiler/getterControlFlowStrictNull.ts(11,14): error TS2366: Function lacks ending return statement and return type does not include 'undefined'. + + +==== tests/cases/compiler/getterControlFlowStrictNull.ts (2 errors) ==== + class A { + a(): string | null { + ~~~~~~~~~~~~~ +!!! error TS2366: Function lacks ending return statement and return type does not include 'undefined'. + if (Math.random() > 0.5) { + return ''; + } + + // it does error here as expected + } + } + class B { + get a(): string | null { + ~~~~~~~~~~~~~ +!!! error TS2366: Function lacks ending return statement and return type does not include 'undefined'. + if (Math.random() > 0.5) { + return ''; + } + + // it should error here because it returns undefined + } + } \ No newline at end of file diff --git a/tests/baselines/reference/getterControlFlowStrictNull.js b/tests/baselines/reference/getterControlFlowStrictNull.js new file mode 100644 index 00000000000..c3f7e410d0a --- /dev/null +++ b/tests/baselines/reference/getterControlFlowStrictNull.js @@ -0,0 +1,47 @@ +//// [getterControlFlowStrictNull.ts] +class A { + a(): string | null { + if (Math.random() > 0.5) { + return ''; + } + + // it does error here as expected + } +} +class B { + get a(): string | null { + if (Math.random() > 0.5) { + return ''; + } + + // it should error here because it returns undefined + } +} + +//// [getterControlFlowStrictNull.js] +var A = (function () { + function A() { + } + A.prototype.a = function () { + if (Math.random() > 0.5) { + return ''; + } + // it does error here as expected + }; + return A; +}()); +var B = (function () { + function B() { + } + Object.defineProperty(B.prototype, "a", { + get: function () { + if (Math.random() > 0.5) { + return ''; + } + // it should error here because it returns undefined + }, + enumerable: true, + configurable: true + }); + return B; +}()); diff --git a/tests/cases/compiler/getterControlFlowStrictNull.ts b/tests/cases/compiler/getterControlFlowStrictNull.ts new file mode 100644 index 00000000000..44fbe359789 --- /dev/null +++ b/tests/cases/compiler/getterControlFlowStrictNull.ts @@ -0,0 +1,20 @@ +//@strictNullChecks: true +//@target: ES5 +class A { + a(): string | null { + if (Math.random() > 0.5) { + return ''; + } + + // it does error here as expected + } +} +class B { + get a(): string | null { + if (Math.random() > 0.5) { + return ''; + } + + // it should error here because it returns undefined + } +} \ No newline at end of file From da6d95101fd8adfacbdb5209782dc560cf09c62f Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 19 Aug 2016 13:56:27 -0700 Subject: [PATCH 204/508] Remove extraneous arguments from harness's runBaseline (#10419) * Remove extraneous arguments from runBaseline * Address comments from @yuit --- src/harness/compilerRunner.ts | 16 ++-- src/harness/fourslash.ts | 12 +-- src/harness/harness.ts | 84 +++++++++------------ src/harness/projectsRunner.ts | 10 +-- src/harness/rwcRunner.ts | 24 +++--- src/harness/test262Runner.ts | 12 +-- src/harness/unittests/initializeTSConfig.ts | 2 +- src/harness/unittests/transpile.ts | 8 +- 8 files changed, 73 insertions(+), 95 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 66396293dc2..88e81ffcf34 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -147,7 +147,7 @@ class CompilerBaselineRunner extends RunnerBase { // check errors it("Correct errors for " + fileName, () => { if (this.errors) { - Harness.Baseline.runBaseline("Correct errors for " + fileName, justName.replace(/\.tsx?$/, ".errors.txt"), (): string => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".errors.txt"), (): string => { if (result.errors.length === 0) return null; return getErrorBaseline(toBeCompiled, otherFiles, result); }); @@ -156,7 +156,7 @@ class CompilerBaselineRunner extends RunnerBase { it (`Correct module resolution tracing for ${fileName}`, () => { if (options.traceResolution) { - Harness.Baseline.runBaseline("Correct module resolution tracing for " + fileName, justName.replace(/\.tsx?$/, ".trace.json"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".trace.json"), () => { return JSON.stringify(result.traceResults || [], undefined, 4); }); } @@ -165,7 +165,7 @@ class CompilerBaselineRunner extends RunnerBase { // Source maps? it("Correct sourcemap content for " + fileName, () => { if (options.sourceMap || options.inlineSourceMap) { - Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => { const record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { // Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required. @@ -183,7 +183,7 @@ class CompilerBaselineRunner extends RunnerBase { } // check js output - Harness.Baseline.runBaseline("Correct JS output for " + fileName, justName.replace(/\.tsx?/, ".js"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, ".js"), () => { let tsCode = ""; const tsSources = otherFiles.concat(toBeCompiled); if (tsSources.length > 1) { @@ -242,7 +242,7 @@ class CompilerBaselineRunner extends RunnerBase { throw new Error("Number of sourcemap files should be same as js files."); } - Harness.Baseline.runBaseline("Correct Sourcemap output for " + fileName, justName.replace(/\.tsx?/, ".js.map"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, ".js.map"), () => { if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { // We need to return null here or the runBaseLine will actually create a empty file. // Baselining isn't required here because there is no output. @@ -330,11 +330,11 @@ class CompilerBaselineRunner extends RunnerBase { const pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull"; if (fullBaseLine !== pullBaseLine) { - Harness.Baseline.runBaseline("Correct full information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); - Harness.Baseline.runBaseline("Correct pull information for " + fileName, justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); + Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); } else { - Harness.Baseline.runBaseline("Correct information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); } } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index b5fa53763cb..63731417f48 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1132,12 +1132,10 @@ namespace FourSlash { } Harness.Baseline.runBaseline( - "Breakpoint Locations for " + this.activeFile.fileName, baselineFile, () => { return this.baselineCurrentFileLocations(pos => this.getBreakpointStatementLocation(pos)); - }, - true /* run immediately */); + }); } public baselineGetEmitOutput() { @@ -1159,7 +1157,6 @@ namespace FourSlash { } Harness.Baseline.runBaseline( - "Generate getEmitOutput baseline : " + emitFiles.join(" "), this.testData.globalOptions[metadataOptionNames.baselineFile], () => { let resultString = ""; @@ -1185,8 +1182,7 @@ namespace FourSlash { }); return resultString; - }, - true /* run immediately */); + }); } public printBreakpointLocation(pos: number) { @@ -1730,13 +1726,11 @@ namespace FourSlash { public baselineCurrentFileNameOrDottedNameSpans() { Harness.Baseline.runBaseline( - "Name OrDottedNameSpans for " + this.activeFile.fileName, this.testData.globalOptions[metadataOptionNames.baselineFile], () => { return this.baselineCurrentFileLocations(pos => this.getNameOrDottedNameSpan(pos)); - }, - true /* run immediately */); + }); } public printNameOrDottedNameSpans(pos: number) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index db8c30ddcc9..3375b8e47e7 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1604,31 +1604,7 @@ namespace Harness { } const fileCache: { [idx: string]: boolean } = {}; - function generateActual(actualFileName: string, generateContent: () => string): string { - // For now this is written using TypeScript, because sys is not available when running old test cases. - // But we need to move to sys once we have - // Creates the directory including its parent if not already present - function createDirectoryStructure(dirName: string) { - if (fileCache[dirName] || IO.directoryExists(dirName)) { - fileCache[dirName] = true; - return; - } - - const parentDirectory = IO.directoryName(dirName); - if (parentDirectory != "") { - createDirectoryStructure(parentDirectory); - } - IO.createDirectory(dirName); - fileCache[dirName] = true; - } - - // Create folders if needed - createDirectoryStructure(Harness.IO.directoryName(actualFileName)); - - // Delete the actual file in case it fails - if (IO.fileExists(actualFileName)) { - IO.deleteFile(actualFileName); - } + function generateActual(generateContent: () => string): string { const actual = generateContent(); @@ -1663,43 +1639,51 @@ namespace Harness { return { expected, actual }; } - function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) { + function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string) { + // For now this is written using TypeScript, because sys is not available when running old test cases. + // But we need to move to sys once we have + // Creates the directory including its parent if not already present + function createDirectoryStructure(dirName: string) { + if (fileCache[dirName] || IO.directoryExists(dirName)) { + fileCache[dirName] = true; + return; + } + + const parentDirectory = IO.directoryName(dirName); + if (parentDirectory != "") { + createDirectoryStructure(parentDirectory); + } + IO.createDirectory(dirName); + fileCache[dirName] = true; + } + + // Create folders if needed + createDirectoryStructure(Harness.IO.directoryName(actualFileName)); + + // Delete the actual file in case it fails + if (IO.fileExists(actualFileName)) { + IO.deleteFile(actualFileName); + } + const encoded_actual = Utils.encodeString(actual); if (expected !== encoded_actual) { if (actual === NoContent) { - IO.writeFile(localPath(relativeFileName + ".delete"), ""); + IO.writeFile(actualFileName + ".delete", ""); } else { - IO.writeFile(localPath(relativeFileName), actual); + IO.writeFile(actualFileName, actual); } - // Overwrite & issue error - const errMsg = "The baseline file " + relativeFileName + " has changed."; - throw new Error(errMsg); + throw new Error(`The baseline file ${relativeFileName} has changed.`); } } + export function runBaseline(relativeFileName: string, generateContent: () => string, opts?: BaselineOptions): void { - export function runBaseline( - descriptionForDescribe: string, - relativeFileName: string, - generateContent: () => string, - runImmediately = false, - opts?: BaselineOptions): void { - - let actual = undefined; const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); - if (runImmediately) { - actual = generateActual(actualFileName, generateContent); - const comparison = compareToBaseline(actual, relativeFileName, opts); - writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe); - } - else { - actual = generateActual(actualFileName, generateContent); - - const comparison = compareToBaseline(actual, relativeFileName, opts); - writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe); - } + const actual = generateActual(generateContent); + const comparison = compareToBaseline(actual, relativeFileName, opts); + writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName); } } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 76f042834bb..080c6edfa87 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -459,7 +459,7 @@ class ProjectRunner extends RunnerBase { }); it("Resolution information of (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { - Harness.Baseline.runBaseline("Resolution information of (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".json", () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".json", () => { return JSON.stringify(getCompilerResolutionInfo(), undefined, " "); }); }); @@ -467,7 +467,7 @@ class ProjectRunner extends RunnerBase { it("Errors for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { if (compilerResult.errors.length) { - Harness.Baseline.runBaseline("Errors for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".errors.txt", () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".errors.txt", () => { return getErrorsBaseline(compilerResult); }); } @@ -481,7 +481,7 @@ class ProjectRunner extends RunnerBase { // There may be multiple files with different baselines. Run all and report at the end, else // it stops copying the remaining emitted files from 'local/projectOutput' to 'local/project'. try { - Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { try { return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); } @@ -503,7 +503,7 @@ class ProjectRunner extends RunnerBase { it("SourceMapRecord for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { if (compilerResult.sourceMapData) { - Harness.Baseline.runBaseline("SourceMapRecord for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => { return Harness.SourceMapRecorder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program, ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName))); }); @@ -516,7 +516,7 @@ class ProjectRunner extends RunnerBase { if (!compilerResult.errors.length && testCase.declaration) { const dTsCompileResult = compileCompileDTsFiles(compilerResult); if (dTsCompileResult && dTsCompileResult.errors.length) { - Harness.Baseline.runBaseline("Errors in generated Dts files for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => { return getErrorsBaseline(dTsCompileResult); }); } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 7ea191e3c83..17346016fbb 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -158,41 +158,41 @@ namespace RWC { it("has the expected emitted code", () => { - Harness.Baseline.runBaseline("has the expected emitted code", baseName + ".output.js", () => { + Harness.Baseline.runBaseline(baseName + ".output.js", () => { return Harness.Compiler.collateOutputs(compilerResult.files); - }, false, baselineOpts); + }, baselineOpts); }); it("has the expected declaration file content", () => { - Harness.Baseline.runBaseline("has the expected declaration file content", baseName + ".d.ts", () => { + Harness.Baseline.runBaseline(baseName + ".d.ts", () => { if (!compilerResult.declFilesCode.length) { return null; } return Harness.Compiler.collateOutputs(compilerResult.declFilesCode); - }, false, baselineOpts); + }, baselineOpts); }); it("has the expected source maps", () => { - Harness.Baseline.runBaseline("has the expected source maps", baseName + ".map", () => { + Harness.Baseline.runBaseline(baseName + ".map", () => { if (!compilerResult.sourceMaps.length) { return null; } return Harness.Compiler.collateOutputs(compilerResult.sourceMaps); - }, false, baselineOpts); + }, baselineOpts); }); /*it("has correct source map record", () => { if (compilerOptions.sourceMap) { - Harness.Baseline.runBaseline("has correct source map record", baseName + ".sourcemap.txt", () => { + Harness.Baseline.runBaseline(baseName + ".sourcemap.txt", () => { return compilerResult.getSourceMapRecord(); - }, false, baselineOpts); + }, baselineOpts); } });*/ it("has the expected errors", () => { - Harness.Baseline.runBaseline("has the expected errors", baseName + ".errors.txt", () => { + Harness.Baseline.runBaseline(baseName + ".errors.txt", () => { if (compilerResult.errors.length === 0) { return null; } @@ -200,14 +200,14 @@ namespace RWC { const baselineFiles = inputFiles.concat(otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName)); const errors = compilerResult.errors.filter(e => !Harness.isDefaultLibraryFile(e.file.fileName)); return Harness.Compiler.getErrorBaseline(baselineFiles, errors); - }, false, baselineOpts); + }, baselineOpts); }); // Ideally, a generated declaration file will have no errors. But we allow generated // declaration file errors as part of the baseline. it("has the expected errors in generated declaration files", () => { if (compilerOptions.declaration && !compilerResult.errors.length) { - Harness.Baseline.runBaseline("has the expected errors in generated declaration files", baseName + ".dts.errors.txt", () => { + Harness.Baseline.runBaseline(baseName + ".dts.errors.txt", () => { const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles( inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory); @@ -218,7 +218,7 @@ namespace RWC { return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + Harness.IO.newLine() + Harness.IO.newLine() + Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); - }, false, baselineOpts); + }, baselineOpts); } }); diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index c44b2286b83..66cf474824b 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -67,21 +67,21 @@ class Test262BaselineRunner extends RunnerBase { }); it("has the expected emitted code", () => { - Harness.Baseline.runBaseline("has the expected emitted code", testState.filename + ".output.js", () => { + Harness.Baseline.runBaseline(testState.filename + ".output.js", () => { const files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath); return Harness.Compiler.collateOutputs(files); - }, false, Test262BaselineRunner.baselineOptions); + }, Test262BaselineRunner.baselineOptions); }); it("has the expected errors", () => { - Harness.Baseline.runBaseline("has the expected errors", testState.filename + ".errors.txt", () => { + Harness.Baseline.runBaseline(testState.filename + ".errors.txt", () => { const errors = testState.compilerResult.errors; if (errors.length === 0) { return null; } return Harness.Compiler.getErrorBaseline(testState.inputFiles, errors); - }, false, Test262BaselineRunner.baselineOptions); + }, Test262BaselineRunner.baselineOptions); }); it("satisfies invariants", () => { @@ -90,10 +90,10 @@ class Test262BaselineRunner extends RunnerBase { }); it("has the expected AST", () => { - Harness.Baseline.runBaseline("has the expected AST", testState.filename + ".AST.txt", () => { + Harness.Baseline.runBaseline(testState.filename + ".AST.txt", () => { const sourceFile = testState.compilerResult.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); return Utils.sourceFileToJSON(sourceFile); - }, false, Test262BaselineRunner.baselineOptions); + }, Test262BaselineRunner.baselineOptions); }); }); } diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts index 059f07e0115..cb995212a94 100644 --- a/src/harness/unittests/initializeTSConfig.ts +++ b/src/harness/unittests/initializeTSConfig.ts @@ -10,7 +10,7 @@ namespace ts { const outputFileName = `tsConfig/${name.replace(/[^a-z0-9\-. ]/ig, "")}/tsconfig.json`; it(`Correct output for ${outputFileName}`, () => { - Harness.Baseline.runBaseline("Correct output", outputFileName, () => { + Harness.Baseline.runBaseline(outputFileName, () => { if (initResult) { return JSON.stringify(initResult, undefined, 4); } diff --git a/src/harness/unittests/transpile.ts b/src/harness/unittests/transpile.ts index 547d10b9fbc..2dd9c89a1cb 100644 --- a/src/harness/unittests/transpile.ts +++ b/src/harness/unittests/transpile.ts @@ -62,7 +62,7 @@ namespace ts { }); it("Correct errors for " + justName, () => { - Harness.Baseline.runBaseline("Correct errors", justName.replace(/\.tsx?$/, ".errors.txt"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".errors.txt"), () => { if (transpileResult.diagnostics.length === 0) { /* tslint:disable:no-null-keyword */ return null; @@ -75,7 +75,7 @@ namespace ts { if (canUseOldTranspile) { it("Correct errors (old transpile) for " + justName, () => { - Harness.Baseline.runBaseline("Correct errors", justName.replace(/\.tsx?$/, ".oldTranspile.errors.txt"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".oldTranspile.errors.txt"), () => { if (oldTranspileDiagnostics.length === 0) { /* tslint:disable:no-null-keyword */ return null; @@ -88,7 +88,7 @@ namespace ts { } it("Correct output for " + justName, () => { - Harness.Baseline.runBaseline("Correct output", justName.replace(/\.tsx?$/, ".js"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".js"), () => { if (transpileResult.outputText) { return transpileResult.outputText; } @@ -104,7 +104,7 @@ namespace ts { if (canUseOldTranspile) { it("Correct output (old transpile) for " + justName, () => { - Harness.Baseline.runBaseline("Correct output", justName.replace(/\.tsx?$/, ".oldTranspile.js"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".oldTranspile.js"), () => { return oldTranspileResult; }); }); From 6c60e5b1050c7c1fcd76c016aaac804368dd6d23 Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 19 Aug 2016 14:34:14 -0700 Subject: [PATCH 205/508] Remove needless call to basename --- Jakefile.js | 323 +++++++++++++++++++++++++++------------------------- 1 file changed, 167 insertions(+), 156 deletions(-) diff --git a/Jakefile.js b/Jakefile.js index 441f6aef4f9..4c751945c87 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -27,9 +27,9 @@ var thirdParty = "ThirdPartyNoticeText.txt"; // add node_modules to path so we don't need global modules, prefer the modules by adding them first var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter; if (process.env.path !== undefined) { - process.env.path = nodeModulesPathPrefix + process.env.path; + process.env.path = nodeModulesPathPrefix + process.env.path; } else if (process.env.PATH !== undefined) { - process.env.PATH = nodeModulesPathPrefix + process.env.PATH; + process.env.PATH = nodeModulesPathPrefix + process.env.PATH; } function toNs(diff) { @@ -205,11 +205,11 @@ var es2015LibrarySources = [ "es2015.symbol.wellknown.d.ts" ]; -var es2015LibrarySourceMap = es2015LibrarySources.map(function(source) { - return { target: "lib." + source, sources: ["header.d.ts", source] }; +var es2015LibrarySourceMap = es2015LibrarySources.map(function (source) { + return { target: "lib." + source, sources: ["header.d.ts", source] }; }); -var es2016LibrarySource = [ "es2016.array.include.d.ts" ]; +var es2016LibrarySource = ["es2016.array.include.d.ts"]; var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) { return { target: "lib." + source, sources: ["header.d.ts", source] }; @@ -227,21 +227,21 @@ var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) { var hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"]; var librarySourceMap = [ - // Host library - { target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] }, - { target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] }, - { target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] }, - { target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] }, + // Host library + { target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] }, + { target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] }, + { target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] }, + { target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] }, - // JavaScript library - { target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] }, - { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, - { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, - { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, + // JavaScript library + { target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] }, + { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, + { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, + { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, - // JavaScript + all host library - { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, - { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } + // JavaScript + all host library + { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, + { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } ].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap); var libraryTargets = librarySourceMap.map(function (f) { @@ -257,7 +257,7 @@ function prependFile(prefixFile, destinationFile) { fail(destinationFile + " failed to be created!"); } var temp = "temptemp"; - jake.cpR(prefixFile, temp, {silent: true}); + jake.cpR(prefixFile, temp, { silent: true }); fs.appendFileSync(temp, fs.readFileSync(destinationFile)); fs.renameSync(temp, destinationFile); } @@ -269,11 +269,11 @@ function concatenateFiles(destinationFile, sourceFiles) { if (!fs.existsSync(sourceFiles[0])) { fail(sourceFiles[0] + " does not exist!"); } - jake.cpR(sourceFiles[0], temp, {silent: true}); + jake.cpR(sourceFiles[0], temp, { silent: true }); // append all files in sequence for (var i = 1; i < sourceFiles.length; i++) { if (!fs.existsSync(sourceFiles[i])) { - fail(sourceFiles[i] + " does not exist!"); + fail(sourceFiles[i] + " does not exist!"); } fs.appendFileSync(temp, fs.readFileSync(sourceFiles[i])); } @@ -307,11 +307,11 @@ var builtLocalCompiler = path.join(builtLocalDirectory, compilerFilename); * @param callback: a function to execute after the compilation process ends */ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts, callback) { - file(outFile, prereqs, function() { + file(outFile, prereqs, function () { var startCompileTime = mark(); opts = opts || {}; var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; - var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types " + var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types " if (opts.types) { options += opts.types.join(","); } @@ -341,7 +341,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --module commonjs"; } - if(opts.noResolve) { + if (opts.noResolve) { options += " --noResolve"; } @@ -368,13 +368,13 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts var ex = jake.createExec([cmd]); // Add listeners for output and error - ex.addListener("stdout", function(output) { + ex.addListener("stdout", function (output) { process.stdout.write(output); }); - ex.addListener("stderr", function(error) { + ex.addListener("stderr", function (error) { process.stderr.write(error); }); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { if (!useDebugMode && prefixes && fs.existsSync(outFile)) { for (var i in prefixes) { prependFile(prefixes[i], outFile); @@ -388,13 +388,13 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts measure(startCompileTime); complete(); }); - ex.addListener("error", function() { + ex.addListener("error", function () { fs.unlinkSync(outFile); fail("Compilation of " + outFile + " unsuccessful"); measure(startCompileTime); }); ex.run(); - }, {async: true}); + }, { async: true }); } // Prerequisite task for built directory and library typings @@ -407,7 +407,7 @@ for (var i in libraryTargets) { var sources = [copyright].concat(entry.sources.map(function (s) { return path.join(libraryDirectory, s); })); - file(target, [builtLocalDirectory].concat(sources), function() { + file(target, [builtLocalDirectory].concat(sources), function () { concatenateFiles(target, sources); }); })(i); @@ -430,30 +430,30 @@ file(processDiagnosticMessagesTs); // processDiagnosticMessages script compileFile(processDiagnosticMessagesJs, - [processDiagnosticMessagesTs], - [processDiagnosticMessagesTs], - [], + [processDiagnosticMessagesTs], + [processDiagnosticMessagesTs], + [], /*useBuiltCompiler*/ false); // The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () { - var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; + var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; console.log(cmd); var ex = jake.createExec([cmd]); // Add listeners for output and error - ex.addListener("stdout", function(output) { + ex.addListener("stdout", function (output) { process.stdout.write(output); }); - ex.addListener("stderr", function(error) { + ex.addListener("stderr", function (error) { process.stderr.write(error); }); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { complete(); }); ex.run(); -}, {async: true}); +}, { async: true }); -file(builtGeneratedDiagnosticMessagesJSON,[generatedDiagnosticMessagesJSON], function() { +file(builtGeneratedDiagnosticMessagesJSON, [generatedDiagnosticMessagesJSON], function () { if (fs.existsSync(builtLocalDirectory)) { jake.cpR(generatedDiagnosticMessagesJSON, builtGeneratedDiagnosticMessagesJSON); } @@ -471,17 +471,17 @@ var programTs = path.join(compilerDirectory, "program.ts"); file(configureNightlyTs); compileFile(/*outfile*/configureNightlyJs, - /*sources*/ [configureNightlyTs], - /*prereqs*/ [configureNightlyTs], - /*prefixes*/ [], + /*sources*/[configureNightlyTs], + /*prereqs*/[configureNightlyTs], + /*prefixes*/[], /*useBuiltCompiler*/ false, - { noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false }); + { noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false }); -task("setDebugMode", function() { +task("setDebugMode", function () { useDebugMode = true; }); -task("configure-nightly", [configureNightlyJs], function() { +task("configure-nightly", [configureNightlyJs], function () { var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs; console.log(cmd); exec(cmd); @@ -522,63 +522,65 @@ var nodePackageFile = path.join(builtLocalDirectory, "typescript.js"); var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts"); var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_standalone.d.ts"); -compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), - /*prefixes*/ [copyright], +compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), + /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - /*opts*/ { noOutFile: false, - generateDeclarations: true, - preserveConstEnums: true, - keepComments: true, - noResolve: false, - stripInternal: true - }, + /*opts*/ { + noOutFile: false, + generateDeclarations: true, + preserveConstEnums: true, + keepComments: true, + noResolve: false, + stripInternal: true + }, /*callback*/ function () { - jake.cpR(servicesFile, nodePackageFile, {silent: true}); + jake.cpR(servicesFile, nodePackageFile, { silent: true }); - prependFile(copyright, standaloneDefinitionsFile); + prependFile(copyright, standaloneDefinitionsFile); - // Stanalone/web definition file using global 'ts' namespace - jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true}); - var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); - definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4'); - fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents); + // Stanalone/web definition file using global 'ts' namespace + jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, { silent: true }); + var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); + definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4'); + fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents); - // Official node package definition file, pointed to by 'typings' in package.json - // Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module - var nodeDefinitionsFileContents = definitionFileContents + "\r\nexport = ts;"; - fs.writeFileSync(nodeDefinitionsFile, nodeDefinitionsFileContents); + // Official node package definition file, pointed to by 'typings' in package.json + // Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module + var nodeDefinitionsFileContents = definitionFileContents + "\r\nexport = ts;"; + fs.writeFileSync(nodeDefinitionsFile, nodeDefinitionsFileContents); - // Node package definition file to be distributed without the package. Created by replacing - // 'ts' namespace with '"typescript"' as a module. - var nodeStandaloneDefinitionsFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); - fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents); - }); + // Node package definition file to be distributed without the package. Created by replacing + // 'ts' namespace with '"typescript"' as a module. + var nodeStandaloneDefinitionsFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); + fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents); + }); compileFile( servicesFileInBrowserTest, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), - /*prefixes*/ [copyright], + /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - { noOutFile: false, - generateDeclarations: true, - preserveConstEnums: true, - keepComments: true, - noResolve: false, - stripInternal: true, - noMapRoot: true, - inlineSourceMap: true - }); + { + noOutFile: false, + generateDeclarations: true, + preserveConstEnums: true, + keepComments: true, + noResolve: false, + stripInternal: true, + noMapRoot: true, + inlineSourceMap: true + }); var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"] }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/[copyright], /*useBuiltCompiler*/ true, { types: ["node"] }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( tsserverLibraryFile, languageServiceLibrarySources, [builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets), - /*prefixes*/ [copyright], + /*prefixes*/[copyright], /*useBuiltCompiler*/ true, { noOutFile: false, generateDeclarations: true }); @@ -587,12 +589,12 @@ desc("Builds language service server library"); task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]); desc("Emit the start of the build fold"); -task("build-fold-start", [] , function() { +task("build-fold-start", [], function () { if (fold.isTravis()) console.log(fold.start("build")); }); desc("Emit the end of the build fold"); -task("build-fold-end", [] , function() { +task("build-fold-end", [], function () { if (fold.isTravis()) console.log(fold.end("build")); }); @@ -606,7 +608,7 @@ task("tsc", ["generate-diagnostics", "lib", tscFile]); // Local target to build the compiler and services desc("Sets release mode flag"); -task("release", function() { +task("release", function () { useDebugMode = false; }); @@ -616,7 +618,7 @@ task("default", ["local"]); // Cleans the built directory desc("Cleans the compiler output, declare files, and tests"); -task("clean", function() { +task("clean", function () { jake.rmRf(builtDirectory); }); @@ -630,9 +632,9 @@ file(word2mdTs); // word2md script compileFile(word2mdJs, - [word2mdTs], - [word2mdTs], - [], + [word2mdTs], + [word2mdTs], + [], /*useBuiltCompiler*/ false); // The generated spec.md; built for the 'generate-spec' task @@ -644,7 +646,7 @@ file(specMd, [word2mdJs, specWord], function () { child_process.exec(cmd, function () { complete(); }); -}, {async: true}); +}, { async: true }); desc("Generates a Markdown version of the Language Specification"); @@ -653,14 +655,14 @@ task("generate-spec", [specMd]); // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory desc("Makes a new LKG out of the built js files"); -task("LKG", ["clean", "release", "local"].concat(libraryTargets), function() { +task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () { var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets); var missingFiles = expectedFiles.filter(function (f) { return !fs.existsSync(f); }); if (missingFiles.length > 0) { fail("Cannot replace the LKG unless all built targets are present in directory " + builtLocalDirectory + - ". The following files are missing:\n" + missingFiles.join("\n")); + ". The following files are missing:\n" + missingFiles.join("\n")); } // Copy all the targets into the LKG directory jake.mkdirP(LKGDirectory); @@ -681,8 +683,8 @@ var run = path.join(builtLocalDirectory, "run.js"); compileFile( /*outFile*/ run, /*source*/ harnessSources, - /*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources), - /*prefixes*/ [], + /*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources), + /*prefixes*/[], /*useBuiltCompiler:*/ true, /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] }); @@ -701,22 +703,22 @@ desc("Builds the test infrastructure using the built compiler"); task("tests", ["local", run].concat(libraryTargets)); function exec(cmd, completeHandler, errorHandler) { - var ex = jake.createExec([cmd], {windowsVerbatimArguments: true}); + var ex = jake.createExec([cmd], { windowsVerbatimArguments: true }); // Add listeners for output and error - ex.addListener("stdout", function(output) { + ex.addListener("stdout", function (output) { process.stdout.write(output); }); - ex.addListener("stderr", function(error) { + ex.addListener("stderr", function (error) { process.stderr.write(error); }); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { if (completeHandler) { completeHandler(); } complete(); }); - ex.addListener("error", function(e, status) { - if(errorHandler) { + ex.addListener("error", function (e, status) { + if (errorHandler) { errorHandler(e, status); } else { fail("Process exited with code " + status); @@ -760,7 +762,7 @@ function runConsoleTests(defaultReporter, runInParallel) { tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; var testConfigFile = 'test.config'; - if(fs.existsSync(testConfigFile)) { + if (fs.existsSync(testConfigFile)) { fs.unlinkSync(testConfigFile); } var workerCount, taskConfigsFolder; @@ -793,7 +795,7 @@ function runConsoleTests(defaultReporter, runInParallel) { // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer - if(!runInParallel) { + if (!runInParallel) { var startTime = mark(); tests = tests ? ' -g "' + tests + '"' : ''; var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run; @@ -806,7 +808,7 @@ function runConsoleTests(defaultReporter, runInParallel) { measure(startTime); runLinter(); finish(); - }, function(e, status) { + }, function (e, status) { process.env.NODE_ENV = savedNodeEnv; measure(startTime); finish(status); @@ -860,14 +862,14 @@ function runConsoleTests(defaultReporter, runInParallel) { var testTimeout = 20000; desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true."); -task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function() { +task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function () { runConsoleTests('min', /*runInParallel*/ true); -}, {async: true}); +}, { async: true }); desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|] d[ebug]=true color[s]=false lint=true bail=false."); -task("runtests", ["build-rules", "tests", builtLocalDirectory], function() { +task("runtests", ["build-rules", "tests", builtLocalDirectory], function () { runConsoleTests('mocha-fivemat-progress-reporter', /*runInParallel*/ false); -}, {async: true}); +}, { async: true }); desc("Generates code coverage data via instanbul"); task("generate-code-coverage", ["tests", builtLocalDirectory], function () { @@ -882,23 +884,23 @@ var nodeServerInFile = "tests/webTestServer.ts"; compileFile(nodeServerOutFile, [nodeServerInFile], [builtLocalDirectory, tscFile], [], /*useBuiltCompiler:*/ true, { noOutFile: true }); desc("Runs browserify on run.js to produce a file suitable for running tests in the browser"); -task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() { +task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function () { var cmd = 'browserify built/local/run.js -d -o built/local/bundle.js'; exec(cmd); -}, {async: true}); +}, { async: true }); desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], browser=[chrome|IE]"); -task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() { +task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function () { cleanTestDirs(); host = "node"; browser = process.env.browser || process.env.b || "IE"; tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; var testConfigFile = 'test.config'; - if(fs.existsSync(testConfigFile)) { + if (fs.existsSync(testConfigFile)) { fs.unlinkSync(testConfigFile); } - if(tests || light) { + if (tests || light) { writeTestConfigFile(tests, light); } @@ -906,7 +908,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi var cmd = host + " tests/webTestServer.js " + browser + " " + JSON.stringify(tests); console.log(cmd); exec(cmd); -}, {async: true}); +}, { async: true }); function getDiffTool() { var program = process.env['DIFF']; @@ -919,17 +921,17 @@ function getDiffTool() { // Baseline Diff desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable"); task('diff', function () { - var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline; + var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline; console.log(cmd); exec(cmd); -}, {async: true}); +}, { async: true }); desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable"); task('diff-rwc', function () { - var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline; + var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline; console.log(cmd); exec(cmd); -}, {async: true}); +}, { async: true }); desc("Builds the test sources and automation in debug mode"); task("tests-debug", ["setDebugMode", "tests"]); @@ -937,30 +939,39 @@ task("tests-debug", ["setDebugMode", "tests"]); // Makes the test results the new baseline desc("Makes the most recent test results the new baseline, overwriting the old baseline"); -task("baseline-accept", function(hardOrSoft) { - var files = jake.readdirR(localBaseline); - var deleteEnding = '.delete'; - for (var i in files) { - if (files[i].substr(files[i].length - deleteEnding.length) === deleteEnding) { - var filename = path.basename(files[i]); - filename = filename.substr(0, filename.length - deleteEnding.length); - fs.unlink(path.join(refBaseline, filename)); - } else { - jake.cpR(files[i], refBaseline); - } - } +task("baseline-accept", function () { + acceptBaseline(""); }); +function acceptBaseline(containerFolder) { + var sourceFolder = path.join(localBaseline, containerFolder); + var targetFolder = path.join(refBaseline, containerFolder); + console.log('Accept baselines from ' + sourceFolder + ' to ' + targetFolder); + var files = fs.readdirSync(sourceFolder); + var deleteEnding = '.delete'; + for (var i in files) { + var filename = files[i]; + if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) { + filename = filename.substr(0, filename.length - deleteEnding.length); + fs.unlinkSync(path.join(targetFolder, filename)); + } else { + var target = path.join(targetFolder, filename); + if (fs.existsSync(target)) { + fs.unlinkSync(target); + } + fs.renameSync(path.join(sourceFolder, filename), target); + } + } +} + desc("Makes the most recent rwc test results the new baseline, overwriting the old baseline"); -task("baseline-accept-rwc", function() { - jake.rmRf(refRwcBaseline); - fs.renameSync(localRwcBaseline, refRwcBaseline); +task("baseline-accept-rwc", function () { + acceptBaseline("rwc"); }); desc("Makes the most recent test262 test results the new baseline, overwriting the old baseline"); -task("baseline-accept-test262", function() { - jake.rmRf(refTest262Baseline); - fs.renameSync(localTest262Baseline, refTest262Baseline); +task("baseline-accept-test262", function () { + acceptBaseline("test262"); }); @@ -970,8 +981,8 @@ var webhostJsPath = "tests/webhost/webtsc.js"; compileFile(webhostJsPath, [webhostPath], [tscFile, webhostPath].concat(libraryTargets), [], /*useBuiltCompiler*/true); desc("Builds the tsc web host"); -task("webhost", [webhostJsPath], function() { - jake.cpR(path.join(builtLocalDirectory, "lib.d.ts"), "tests/webhost/", {silent: true}); +task("webhost", [webhostJsPath], function () { + jake.cpR(path.join(builtLocalDirectory, "lib.d.ts"), "tests/webhost/", { silent: true }); }); // Perf compiler @@ -984,38 +995,38 @@ task("perftsc", [perftscJsPath]); // Instrumented compiler var loggedIOpath = harnessDirectory + 'loggedIO.ts'; var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js'; -file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() { +file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function () { var temp = builtLocalDirectory + 'temp'; jake.mkdirP(temp); var options = "--outdir " + temp + ' ' + loggedIOpath; var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " "; console.log(cmd + "\n"); var ex = jake.createExec([cmd]); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { fs.renameSync(temp + '/harness/loggedIO.js', loggedIOJsPath); jake.rmRf(temp); complete(); }); ex.run(); -}, {async: true}); +}, { async: true }); var instrumenterPath = harnessDirectory + 'instrumenter.ts'; var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js'; compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true); desc("Builds an instrumented tsc.js"); -task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() { +task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function () { var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename; console.log(cmd); var ex = jake.createExec([cmd]); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { complete(); }); ex.run(); }, { async: true }); desc("Updates the sublime plugin's tsserver"); -task("update-sublime", ["local", serverFile], function() { +task("update-sublime", ["local", serverFile], function () { jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/"); jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); }); @@ -1031,33 +1042,33 @@ var tslintRules = [ "objectLiteralSurroundingSpaceRule", "noTypeAssertionWhitespaceRule" ]; -var tslintRulesFiles = tslintRules.map(function(p) { +var tslintRulesFiles = tslintRules.map(function (p) { return path.join(tslintRuleDir, p + ".ts"); }); -var tslintRulesOutFiles = tslintRules.map(function(p) { +var tslintRulesOutFiles = tslintRules.map(function (p) { return path.join(builtLocalDirectory, "tslint", p + ".js"); }); desc("Compiles tslint rules to js"); task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"])); -tslintRulesFiles.forEach(function(ruleFile, i) { +tslintRulesFiles.forEach(function (ruleFile, i) { compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, - { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint")}); + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") }); }); desc("Emit the start of the build-rules fold"); -task("build-rules-start", [] , function() { +task("build-rules-start", [], function () { if (fold.isTravis()) console.log(fold.start("build-rules")); }); desc("Emit the end of the build-rules fold"); -task("build-rules-end", [] , function() { +task("build-rules-end", [], function () { if (fold.isTravis()) console.log(fold.end("build-rules")); }); var lintTargets = compilerSources .concat(harnessSources) // Other harness sources - .concat(["instrumenter.ts"].map(function(f) { return path.join(harnessDirectory, f) })) + .concat(["instrumenter.ts"].map(function (f) { return path.join(harnessDirectory, f) })) .concat(serverCoreSources) .concat(tslintRulesFiles) .concat(servicesSources) @@ -1068,10 +1079,10 @@ function sendNextFile(files, child, callback, failures) { var file = files.pop(); if (file) { console.log("Linting '" + file + "'."); - child.send({kind: "file", name: file}); + child.send({ kind: "file", name: file }); } else { - child.send({kind: "close"}); + child.send({ kind: "close" }); callback(failures); } } @@ -1079,7 +1090,7 @@ function sendNextFile(files, child, callback, failures) { function spawnLintWorker(files, callback) { var child = child_process.fork("./scripts/parallel-lint"); var failures = 0; - child.on("message", function(data) { + child.on("message", function (data) { switch (data.kind) { case "result": if (data.failures > 0) { @@ -1099,7 +1110,7 @@ function spawnLintWorker(files, callback) { } desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex"); -task("lint", ["build-rules"], function() { +task("lint", ["build-rules"], function () { if (fold.isTravis()) console.log(fold.start("lint")); var startTime = mark(); var failed = 0; @@ -1114,7 +1125,7 @@ task("lint", ["build-rules"], function() { var workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; - var names = Object.keys(done).sort(function(namea, nameb) { + var names = Object.keys(done).sort(function (namea, nameb) { return done[namea] - done[nameb]; }); @@ -1138,4 +1149,4 @@ task("lint", ["build-rules"], function() { } } } -}, {async: true}); +}, { async: true }); From 8ad2744e9a7d0d7eb30286f0b6718b7b5f6cc4f9 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Fri, 19 Aug 2016 15:44:14 -0700 Subject: [PATCH 206/508] Refactor baseliners out of compiler runner (#10440) --- src/harness/compilerRunner.ts | 222 ++-------------------------------- src/harness/harness.ts | 214 ++++++++++++++++++++++++++++++++ src/harness/rwcRunner.ts | 7 +- 3 files changed, 227 insertions(+), 216 deletions(-) diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 88e81ffcf34..a64435b7ddc 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -1,8 +1,6 @@ /// /// /// -// In harness baselines, null is different than undefined. See `generateActual` in `harness.ts`. -/* tslint:disable:no-null-keyword */ const enum CompilerTestType { Conformance, @@ -136,21 +134,10 @@ class CompilerBaselineRunner extends RunnerBase { otherFiles = undefined; }); - function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string { - return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : ""; - } - - function getErrorBaseline(toBeCompiled: Harness.Compiler.TestFile[], otherFiles: Harness.Compiler.TestFile[], result: Harness.Compiler.CompilerResult) { - return Harness.Compiler.getErrorBaseline(toBeCompiled.concat(otherFiles), result.errors); - } - // check errors it("Correct errors for " + fileName, () => { if (this.errors) { - Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".errors.txt"), (): string => { - if (result.errors.length === 0) return null; - return getErrorBaseline(toBeCompiled, otherFiles, result); - }); + Harness.Compiler.doErrorBaseline(justName, toBeCompiled.concat(otherFiles), result.errors); } }); @@ -168,8 +155,10 @@ class CompilerBaselineRunner extends RunnerBase { Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => { const record = result.getSourceMapRecord(); if (options.noEmitOnError && result.errors.length !== 0 && record === undefined) { - // Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required. + // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. + /* tslint:disable:no-null-keyword */ return null; + /* tslint:enable:no-null-keyword */ } return record; }); @@ -178,87 +167,12 @@ class CompilerBaselineRunner extends RunnerBase { it("Correct JS output for " + fileName, () => { if (hasNonDtsFiles && this.emit) { - if (!options.noEmit && result.files.length === 0 && result.errors.length === 0) { - throw new Error("Expected at least one js file to be emitted or at least one error to be created."); - } - - // check js output - Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, ".js"), () => { - let tsCode = ""; - const tsSources = otherFiles.concat(toBeCompiled); - if (tsSources.length > 1) { - tsCode += "//// [" + fileName + "] ////\r\n\r\n"; - } - for (let i = 0; i < tsSources.length; i++) { - tsCode += "//// [" + Harness.Path.getFileName(tsSources[i].unitName) + "]\r\n"; - tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? "\r\n" : ""); - } - - let jsCode = ""; - for (let i = 0; i < result.files.length; i++) { - jsCode += "//// [" + Harness.Path.getFileName(result.files[i].fileName) + "]\r\n"; - jsCode += getByteOrderMarkText(result.files[i]); - jsCode += result.files[i].code; - } - - if (result.declFilesCode.length > 0) { - jsCode += "\r\n\r\n"; - for (let i = 0; i < result.declFilesCode.length; i++) { - jsCode += "//// [" + Harness.Path.getFileName(result.declFilesCode[i].fileName) + "]\r\n"; - jsCode += getByteOrderMarkText(result.declFilesCode[i]); - jsCode += result.declFilesCode[i].code; - } - } - - const declFileCompilationResult = - Harness.Compiler.compileDeclarationFiles( - toBeCompiled, otherFiles, result, harnessSettings, options, /*currentDirectory*/ undefined); - - if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) { - jsCode += "\r\n\r\n//// [DtsFileErrors]\r\n"; - jsCode += "\r\n\r\n"; - jsCode += getErrorBaseline(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles, declFileCompilationResult.declResult); - } - - if (jsCode.length > 0) { - return tsCode + "\r\n\r\n" + jsCode; - } - else { - return null; - } - }); + Harness.Compiler.doJsEmitBaseline(justName, fileName, options, result, toBeCompiled, otherFiles, harnessSettings); } }); it("Correct Sourcemap output for " + fileName, () => { - if (options.inlineSourceMap) { - if (result.sourceMaps.length > 0) { - throw new Error("No sourcemap files should be generated if inlineSourceMaps was set."); - } - return null; - } - else if (options.sourceMap) { - if (result.sourceMaps.length !== result.files.length) { - throw new Error("Number of sourcemap files should be same as js files."); - } - - Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, ".js.map"), () => { - if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { - // We need to return null here or the runBaseLine will actually create a empty file. - // Baselining isn't required here because there is no output. - return null; - } - - let sourceMapCode = ""; - for (let i = 0; i < result.sourceMaps.length; i++) { - sourceMapCode += "//// [" + Harness.Path.getFileName(result.sourceMaps[i].fileName) + "]\r\n"; - sourceMapCode += getByteOrderMarkText(result.sourceMaps[i]); - sourceMapCode += result.sourceMaps[i].code; - } - - return sourceMapCode; - }); - } + Harness.Compiler.doSourcemapBaseline(justName, options, result); }); it("Correct type/symbol baselines for " + fileName, () => { @@ -266,129 +180,7 @@ class CompilerBaselineRunner extends RunnerBase { return; } - // NEWTODO: Type baselines - if (result.errors.length !== 0) { - return; - } - - // The full walker simulates the types that you would get from doing a full - // compile. The pull walker simulates the types you get when you just do - // a type query for a random node (like how the LS would do it). Most of the - // time, these will be the same. However, occasionally, they can be different. - // Specifically, when the compiler internally depends on symbol IDs to order - // things, then we may see different results because symbols can be created in a - // different order with 'pull' operations, and thus can produce slightly differing - // output. - // - // For example, with a full type check, we may see a type displayed as: number | string - // But with a pull type check, we may see it as: string | number - // - // These types are equivalent, but depend on what order the compiler observed - // certain parts of the program. - - const program = result.program; - const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName)); - - const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true); - - const fullResults = ts.createMap(); - const pullResults = ts.createMap(); - - for (const sourceFile of allFiles) { - fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); - pullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); - } - - // Produce baselines. The first gives the types for all expressions. - // The second gives symbols for all identifiers. - let e1: Error, e2: Error; - try { - checkBaseLines(/*isSymbolBaseLine*/ false); - } - catch (e) { - e1 = e; - } - - try { - checkBaseLines(/*isSymbolBaseLine*/ true); - } - catch (e) { - e2 = e; - } - - if (e1 || e2) { - throw e1 || e2; - } - - return; - - function checkBaseLines(isSymbolBaseLine: boolean) { - const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); - const pullBaseLine = generateBaseLine(pullResults, isSymbolBaseLine); - - const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; - const pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull"; - - if (fullBaseLine !== pullBaseLine) { - Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); - Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); - } - else { - Harness.Baseline.runBaseline(justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); - } - } - - function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { - const typeLines: string[] = []; - const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; - - allFiles.forEach(file => { - const codeLines = file.content.split("\n"); - typeWriterResults[file.unitName].forEach(result => { - if (isSymbolBaseline && !result.symbol) { - return; - } - - const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; - const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; - if (!typeMap[file.unitName]) { - typeMap[file.unitName] = {}; - } - - let typeInfo = [formattedLine]; - const existingTypeInfo = typeMap[file.unitName][result.line]; - if (existingTypeInfo) { - typeInfo = existingTypeInfo.concat(typeInfo); - } - typeMap[file.unitName][result.line] = typeInfo; - }); - - typeLines.push("=== " + file.unitName + " ===\r\n"); - for (let i = 0; i < codeLines.length; i++) { - const currentCodeLine = codeLines[i]; - typeLines.push(currentCodeLine + "\r\n"); - if (typeMap[file.unitName]) { - const typeInfo = typeMap[file.unitName][i]; - if (typeInfo) { - typeInfo.forEach(ty => { - typeLines.push(">" + ty + "\r\n"); - }); - if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === "")) { - } - else { - typeLines.push("\r\n"); - } - } - } - else { - typeLines.push("No type information for this code."); - } - } - }); - - return typeLines.join(""); - } - + Harness.Compiler.doTypeAndSymbolBaseline(justName, result, toBeCompiled.concat(otherFiles).filter(file => !!result.program.getSourceFile(file.unitName))); }); }); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 3375b8e47e7..14cb3147c32 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1328,6 +1328,220 @@ namespace Harness { Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n"); } + export function doErrorBaseline(baselinePath: string, inputFiles: TestFile[], errors: ts.Diagnostic[]) { + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?$/, ".errors.txt"), (): string => { + if (errors.length === 0) { + /* tslint:disable:no-null-keyword */ + return null; + /* tslint:enable:no-null-keyword */ + } + return getErrorBaseline(inputFiles, errors); + }); + } + + export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[]) { + if (result.errors.length !== 0) { + return; + } + // The full walker simulates the types that you would get from doing a full + // compile. The pull walker simulates the types you get when you just do + // a type query for a random node (like how the LS would do it). Most of the + // time, these will be the same. However, occasionally, they can be different. + // Specifically, when the compiler internally depends on symbol IDs to order + // things, then we may see different results because symbols can be created in a + // different order with 'pull' operations, and thus can produce slightly differing + // output. + // + // For example, with a full type check, we may see a type displayed as: number | string + // But with a pull type check, we may see it as: string | number + // + // These types are equivalent, but depend on what order the compiler observed + // certain parts of the program. + + const program = result.program; + + const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true); + + const fullResults = ts.createMap(); + + for (const sourceFile of allFiles) { + fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); + } + + // Produce baselines. The first gives the types for all expressions. + // The second gives symbols for all identifiers. + let e1: Error, e2: Error; + try { + checkBaseLines(/*isSymbolBaseLine*/ false); + } + catch (e) { + e1 = e; + } + + try { + checkBaseLines(/*isSymbolBaseLine*/ true); + } + catch (e) { + e2 = e; + } + + if (e1 || e2) { + throw e1 || e2; + } + + return; + + function checkBaseLines(isSymbolBaseLine: boolean) { + const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); + + const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; + + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + } + + function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { + const typeLines: string[] = []; + const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; + + allFiles.forEach(file => { + const codeLines = file.content.split("\n"); + typeWriterResults[file.unitName].forEach(result => { + if (isSymbolBaseline && !result.symbol) { + return; + } + + const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; + const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; + if (!typeMap[file.unitName]) { + typeMap[file.unitName] = {}; + } + + let typeInfo = [formattedLine]; + const existingTypeInfo = typeMap[file.unitName][result.line]; + if (existingTypeInfo) { + typeInfo = existingTypeInfo.concat(typeInfo); + } + typeMap[file.unitName][result.line] = typeInfo; + }); + + typeLines.push("=== " + file.unitName + " ===\r\n"); + for (let i = 0; i < codeLines.length; i++) { + const currentCodeLine = codeLines[i]; + typeLines.push(currentCodeLine + "\r\n"); + if (typeMap[file.unitName]) { + const typeInfo = typeMap[file.unitName][i]; + if (typeInfo) { + typeInfo.forEach(ty => { + typeLines.push(">" + ty + "\r\n"); + }); + if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === "")) { + } + else { + typeLines.push("\r\n"); + } + } + } + else { + typeLines.push("No type information for this code."); + } + } + }); + + return typeLines.join(""); + } + } + + function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string { + return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : ""; + } + + export function doSourcemapBaseline(baselinePath: string, options: ts.CompilerOptions, result: CompilerResult) { + if (options.inlineSourceMap) { + if (result.sourceMaps.length > 0) { + throw new Error("No sourcemap files should be generated if inlineSourceMaps was set."); + } + return; + } + else if (options.sourceMap) { + if (result.sourceMaps.length !== result.files.length) { + throw new Error("Number of sourcemap files should be same as js files."); + } + + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, ".js.map"), () => { + if (options.noEmitOnError && result.errors.length !== 0 && result.sourceMaps.length === 0) { + // We need to return null here or the runBaseLine will actually create a empty file. + // Baselining isn't required here because there is no output. + /* tslint:disable:no-null-keyword */ + return null; + /* tslint:enable:no-null-keyword */ + } + + let sourceMapCode = ""; + for (let i = 0; i < result.sourceMaps.length; i++) { + sourceMapCode += "//// [" + Harness.Path.getFileName(result.sourceMaps[i].fileName) + "]\r\n"; + sourceMapCode += getByteOrderMarkText(result.sourceMaps[i]); + sourceMapCode += result.sourceMaps[i].code; + } + + return sourceMapCode; + }); + } + } + + export function doJsEmitBaseline(baselinePath: string, header: string, options: ts.CompilerOptions, result: CompilerResult, toBeCompiled: Harness.Compiler.TestFile[], otherFiles: Harness.Compiler.TestFile[], harnessSettings: Harness.TestCaseParser.CompilerSettings) { + if (!options.noEmit && result.files.length === 0 && result.errors.length === 0) { + throw new Error("Expected at least one js file to be emitted or at least one error to be created."); + } + + // check js output + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, ".js"), () => { + let tsCode = ""; + const tsSources = otherFiles.concat(toBeCompiled); + if (tsSources.length > 1) { + tsCode += "//// [" + header + "] ////\r\n\r\n"; + } + for (let i = 0; i < tsSources.length; i++) { + tsCode += "//// [" + Harness.Path.getFileName(tsSources[i].unitName) + "]\r\n"; + tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? "\r\n" : ""); + } + + let jsCode = ""; + for (let i = 0; i < result.files.length; i++) { + jsCode += "//// [" + Harness.Path.getFileName(result.files[i].fileName) + "]\r\n"; + jsCode += getByteOrderMarkText(result.files[i]); + jsCode += result.files[i].code; + } + + if (result.declFilesCode.length > 0) { + jsCode += "\r\n\r\n"; + for (let i = 0; i < result.declFilesCode.length; i++) { + jsCode += "//// [" + Harness.Path.getFileName(result.declFilesCode[i].fileName) + "]\r\n"; + jsCode += getByteOrderMarkText(result.declFilesCode[i]); + jsCode += result.declFilesCode[i].code; + } + } + + const declFileCompilationResult = + Harness.Compiler.compileDeclarationFiles( + toBeCompiled, otherFiles, result, harnessSettings, options, /*currentDirectory*/ undefined); + + if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) { + jsCode += "\r\n\r\n//// [DtsFileErrors]\r\n"; + jsCode += "\r\n\r\n"; + jsCode += Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); + } + + if (jsCode.length > 0) { + return tsCode + "\r\n\r\n" + jsCode; + } + else { + /* tslint:disable:no-null-keyword */ + return null; + /* tslint:enable:no-null-keyword */ + } + }); + } + export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { // Collect, test, and sort the fileNames outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 17346016fbb..5720f9b541c 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -222,7 +222,12 @@ namespace RWC { } }); - // TODO: Type baselines (need to refactor out from compilerRunner) + it("has the expected types", () => { + Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles + .concat(otherFiles) + .filter(file => !!compilerResult.program.getSourceFile(file.unitName)) + .filter(e => !Harness.isDefaultLibraryFile(e.unitName))); + }); }); } } From 057357be88319368da2e1380da93915075ed05fc Mon Sep 17 00:00:00 2001 From: zhengbli Date: Fri, 19 Aug 2016 15:48:46 -0700 Subject: [PATCH 207/508] CR feedback --- src/services/services.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 64b872d14a7..94b69113da7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4913,22 +4913,24 @@ namespace ts { if (!documentation) { documentation = symbol.getDocumentationComment(); - if ((!documentation || documentation.length === 0) && symbol.flags & SymbolFlags.Property) { + if (documentation.length === 0 && symbol.flags & SymbolFlags.Property) { // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) { - forEach(symbol.declarations, declaration => { - if (declaration.parent && declaration.parent.kind === SyntaxKind.BinaryExpression) { - const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((declaration.parent).right); - if (rhsSymbol) { - documentation = rhsSymbol.getDocumentationComment(); - if (documentation && documentation.length > 0) { - return true; - } + for(const declaration of symbol.declarations) { + if (!declaration.parent || declaration.parent.kind !== SyntaxKind.BinaryExpression) { + continue; + } + + const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((declaration.parent).right); + if (rhsSymbol) { + documentation = rhsSymbol.getDocumentationComment(); + if (documentation.length > 0) { + return; } } - }); + } } } } From cf7feb3faace557964447214cae150ae92ec7a80 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 19 Aug 2016 16:49:55 -0700 Subject: [PATCH 208/508] Responding to PR feedback --- src/compiler/program.ts | 2 +- src/harness/harness.ts | 6 +- src/harness/harnessLanguageService.ts | 8 +- src/harness/virtualFileSystem.ts | 84 +++++++++---------- src/services/services.ts | 2 +- ...mpletionForStringLiteralRelativeImport3.ts | 18 ++-- .../completionForTripleSlashReference3.ts | 6 +- 7 files changed, 59 insertions(+), 67 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index e8b8e0aa359..834cba1358a 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -10,7 +10,7 @@ namespace ts { const defaultTypeRoots = ["node_modules/@types"]; - export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName="tsconfig.json"): string { + export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string { while (true) { const fileName = combinePaths(searchPath, configName); if (fileExists(fileName)) { diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 35921f868e8..41227c9bff2 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -458,7 +458,7 @@ namespace Harness { // harness always uses one kind of new line const harnessNewLine = "\r\n"; - // Roote for file paths that are stored in a virtual file system + // Root for file paths that are stored in a virtual file system export const virtualFileSystemRoot = "/"; namespace IOImpl { @@ -752,14 +752,14 @@ namespace Harness { } export function readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]) { - const fs = new Utils.VirtualFileSystem(path, useCaseSensitiveFileNames()); + const fs = new Utils.VirtualFileSystem(path, useCaseSensitiveFileNames()); for (const file of listFiles(path)) { fs.addFile(file); } return ts.matchFiles(path, extension, exclude, include, useCaseSensitiveFileNames(), getCurrentDirectory(), path => { const entry = fs.traversePath(path); if (entry && entry.isDirectory()) { - const directory = >entry; + const directory = entry; return { files: ts.map(directory.getFiles(), f => f.name), directories: ts.map(directory.getDirectories(), d => d.name) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 9a6f9ef77ca..a694002d703 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -123,7 +123,7 @@ namespace Harness.LanguageService { } export class LanguageServiceAdapterHost { - protected virtualFileSystem: Utils.VirtualFileSystem = new Utils.VirtualFileSystem(virtualFileSystemRoot, /*useCaseSensitiveFilenames*/false); + protected virtualFileSystem: Utils.VirtualFileSystem = new Utils.VirtualFileSystem(virtualFileSystemRoot, /*useCaseSensitiveFilenames*/false); constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, protected settings = ts.getDefaultCompilerOptions()) { @@ -148,7 +148,7 @@ namespace Harness.LanguageService { public getScriptInfo(fileName: string): ScriptInfo { const fileEntry = this.virtualFileSystem.traversePath(fileName); - return fileEntry && fileEntry.isFile() ? (>fileEntry).content : undefined; + return fileEntry && fileEntry.isFile() ? (fileEntry).content : undefined; } public addScript(fileName: string, content: string, isRootFile: boolean): void { @@ -187,11 +187,11 @@ namespace Harness.LanguageService { getDirectories(path: string): string[] { const dir = this.virtualFileSystem.traversePath(path); if (dir && dir.isDirectory()) { - return ts.map((>dir).getDirectories(), (d) => ts.combinePaths(path, d.name)); + return ts.map((dir).getDirectories(), (d) => ts.combinePaths(path, d.name)); } return []; } - getCurrentDirectory(): string { return virtualFileSystemRoot } + getCurrentDirectory(): string { return virtualFileSystemRoot; } getDefaultLibFileName(): string { return Harness.Compiler.defaultLibFileName; } getScriptFileNames(): string[] { return this.getFilenames(); } getScriptSnapshot(fileName: string): ts.IScriptSnapshot { diff --git a/src/harness/virtualFileSystem.ts b/src/harness/virtualFileSystem.ts index 036965f75de..b6d234acd59 100644 --- a/src/harness/virtualFileSystem.ts +++ b/src/harness/virtualFileSystem.ts @@ -1,11 +1,11 @@ /// /// namespace Utils { - export class VirtualFileSystemEntry { - fileSystem: VirtualFileSystem; + export class VirtualFileSystemEntry { + fileSystem: VirtualFileSystem; name: string; - constructor(fileSystem: VirtualFileSystem, name: string) { + constructor(fileSystem: VirtualFileSystem, name: string) { this.fileSystem = fileSystem; this.name = name; } @@ -15,15 +15,15 @@ namespace Utils { isFileSystem() { return false; } } - export class VirtualFile extends VirtualFileSystemEntry { - content: T; + export class VirtualFile extends VirtualFileSystemEntry { + content?: Harness.LanguageService.ScriptInfo; isFile() { return true; } } - export abstract class VirtualFileSystemContainer extends VirtualFileSystemEntry { - abstract getFileSystemEntries(): VirtualFileSystemEntry[]; + export abstract class VirtualFileSystemContainer extends VirtualFileSystemEntry { + abstract getFileSystemEntries(): VirtualFileSystemEntry[]; - getFileSystemEntry(name: string): VirtualFileSystemEntry { + getFileSystemEntry(name: string): VirtualFileSystemEntry { for (const entry of this.getFileSystemEntries()) { if (this.fileSystem.sameName(entry.name, name)) { return entry; @@ -32,57 +32,57 @@ namespace Utils { return undefined; } - getDirectories(): VirtualDirectory[] { - return []>ts.filter(this.getFileSystemEntries(), entry => entry.isDirectory()); + getDirectories(): VirtualDirectory[] { + return ts.filter(this.getFileSystemEntries(), entry => entry.isDirectory()); } - getFiles(): VirtualFile[] { - return []>ts.filter(this.getFileSystemEntries(), entry => entry.isFile()); + getFiles(): VirtualFile[] { + return ts.filter(this.getFileSystemEntries(), entry => entry.isFile()); } - getDirectory(name: string): VirtualDirectory { + getDirectory(name: string): VirtualDirectory { const entry = this.getFileSystemEntry(name); - return entry.isDirectory() ? >entry : undefined; + return entry.isDirectory() ? entry : undefined; } - getFile(name: string): VirtualFile { + getFile(name: string): VirtualFile { const entry = this.getFileSystemEntry(name); - return entry.isFile() ? >entry : undefined; + return entry.isFile() ? entry : undefined; } } - export class VirtualDirectory extends VirtualFileSystemContainer { - private entries: VirtualFileSystemEntry[] = []; + export class VirtualDirectory extends VirtualFileSystemContainer { + private entries: VirtualFileSystemEntry[] = []; isDirectory() { return true; } getFileSystemEntries() { return this.entries.slice(); } - addDirectory(name: string): VirtualDirectory { + addDirectory(name: string): VirtualDirectory { const entry = this.getFileSystemEntry(name); if (entry === undefined) { - const directory = new VirtualDirectory(this.fileSystem, name); + const directory = new VirtualDirectory(this.fileSystem, name); this.entries.push(directory); return directory; } else if (entry.isDirectory()) { - return >entry; + return entry; } else { return undefined; } } - addFile(name: string, content?: T): VirtualFile { + addFile(name: string, content?: Harness.LanguageService.ScriptInfo): VirtualFile { const entry = this.getFileSystemEntry(name); if (entry === undefined) { - const file = new VirtualFile(this.fileSystem, name); + const file = new VirtualFile(this.fileSystem, name); file.content = content; this.entries.push(file); return file; } else if (entry.isFile()) { - const file = >entry; + const file = entry; file.content = content; return file; } @@ -92,8 +92,8 @@ namespace Utils { } } - export class VirtualFileSystem extends VirtualFileSystemContainer { - private root: VirtualDirectory; + export class VirtualFileSystem extends VirtualFileSystemContainer { + private root: VirtualDirectory; currentDirectory: string; useCaseSensitiveFileNames: boolean; @@ -101,7 +101,7 @@ namespace Utils { constructor(currentDirectory: string, useCaseSensitiveFileNames: boolean) { super(undefined, ""); this.fileSystem = this; - this.root = new VirtualDirectory(this, ""); + this.root = new VirtualDirectory(this, ""); this.currentDirectory = currentDirectory; this.useCaseSensitiveFileNames = useCaseSensitiveFileNames; } @@ -111,9 +111,9 @@ namespace Utils { getFileSystemEntries() { return this.root.getFileSystemEntries(); } addDirectory(path: string) { - path = this.normalizePathRoot(path); + path = ts.normalizePath(path); const components = ts.getNormalizedPathComponents(path, this.currentDirectory); - let directory: VirtualDirectory = this.root; + let directory: VirtualDirectory = this.root; for (const component of components) { directory = directory.addDirectory(component); if (directory === undefined) { @@ -124,8 +124,8 @@ namespace Utils { return directory; } - addFile(path: string, content?: T) { - const absolutePath = this.normalizePathRoot(ts.getNormalizedAbsolutePath(path, this.currentDirectory)); + addFile(path: string, content?: Harness.LanguageService.ScriptInfo) { + const absolutePath = ts.normalizePath(ts.getNormalizedAbsolutePath(path, this.currentDirectory)); const fileName = ts.getBaseFileName(path); const directoryPath = ts.getDirectoryPath(absolutePath); const directory = this.addDirectory(directoryPath); @@ -142,15 +142,15 @@ namespace Utils { } traversePath(path: string) { - path = this.normalizePathRoot(path); - let directory: VirtualDirectory = this.root; + path = ts.normalizePath(path); + let directory: VirtualDirectory = this.root; for (const component of ts.getNormalizedPathComponents(path, this.currentDirectory)) { const entry = directory.getFileSystemEntry(component); if (entry === undefined) { return undefined; } else if (entry.isDirectory()) { - directory = >entry; + directory = entry; } else { return entry; @@ -168,7 +168,7 @@ namespace Utils { getAccessibleFileSystemEntries(path: string) { const entry = this.traversePath(path); if (entry && entry.isDirectory()) { - const directory = >entry; + const directory = entry; return { files: ts.map(directory.getFiles(), f => f.name), directories: ts.map(directory.getDirectories(), d => d.name) @@ -178,11 +178,11 @@ namespace Utils { } getAllFileEntries() { - const fileEntries: VirtualFile[] = []; + const fileEntries: VirtualFile[] = []; getFilesRecursive(this.root, fileEntries); return fileEntries; - function getFilesRecursive(dir: VirtualDirectory, result: VirtualFile[]) { + function getFilesRecursive(dir: VirtualDirectory, result: VirtualFile[]) { const files = dir.getFiles(); const dirs = dir.getDirectories(); for (const file of files) { @@ -193,17 +193,9 @@ namespace Utils { } } } - - normalizePathRoot(path: string) { - const components = ts.getNormalizedPathComponents(path, this.currentDirectory); - - // Toss the root component - components[0] = ""; - return components.join(ts.directorySeparator); - } } - export class MockParseConfigHost extends VirtualFileSystem implements ts.ParseConfigHost { + export class MockParseConfigHost extends VirtualFileSystem implements ts.ParseConfigHost { constructor(currentDirectory: string, ignoreCase: boolean, files: string[]) { super(currentDirectory, ignoreCase); for (const file of files) { diff --git a/src/services/services.ts b/src/services/services.ts index 6108e1e976a..49fc48b6ea8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1171,7 +1171,7 @@ namespace ts { resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists?(directoryName: string): boolean; - /** + /* * getDirectories is also required for full import and type reference completions. Without it defined, certain * completions will not be provided */ diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts index a2035ee7fdb..82c3ea7d1e4 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -3,17 +3,17 @@ // Should give completions for absolute paths // @Filename: tests/test0.ts -//// import * as foo1 from "c:/tests/cases/f/*import_as0*/ -//// import * as foo2 from "c:/tests/cases/fourslash/*import_as1*/ -//// import * as foo3 from "c:/tests/cases/fourslash//*import_as2*/ +//// import * as foo1 from "/tests/cases/f/*import_as0*/ +//// import * as foo2 from "/tests/cases/fourslash/*import_as1*/ +//// import * as foo3 from "/tests/cases/fourslash//*import_as2*/ -//// import foo4 = require("c:/tests/cases/f/*import_equals0*/ -//// import foo5 = require("c:/tests/cases/fourslash/*import_equals1*/ -//// import foo6 = require("c:/tests/cases/fourslash//*import_equals2*/ +//// import foo4 = require("/tests/cases/f/*import_equals0*/ +//// import foo5 = require("/tests/cases/fourslash/*import_equals1*/ +//// import foo6 = require("/tests/cases/fourslash//*import_equals2*/ -//// var foo7 = require("c:/tests/cases/f/*require0*/ -//// var foo8 = require("c:/tests/cases/fourslash/*require1*/ -//// var foo9 = require("c:/tests/cases/fourslash//*require2*/ +//// var foo7 = require("/tests/cases/f/*require0*/ +//// var foo8 = require("/tests/cases/fourslash/*require1*/ +//// var foo9 = require("/tests/cases/fourslash//*require2*/ // @Filename: f1.ts //// /*f1*/ diff --git a/tests/cases/fourslash/completionForTripleSlashReference3.ts b/tests/cases/fourslash/completionForTripleSlashReference3.ts index 2f92de19a21..d27d0e658c2 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference3.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference3.ts @@ -3,13 +3,13 @@ // Should give completions for absolute paths // @Filename: tests/test0.ts -//// /// Date: Fri, 19 Aug 2016 16:53:36 -0700 Subject: [PATCH 209/508] fix broken tests --- src/services/services.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 94b69113da7..c59551457ba 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4918,17 +4918,19 @@ namespace ts { // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) { - for(const declaration of symbol.declarations) { + for (const declaration of symbol.declarations) { if (!declaration.parent || declaration.parent.kind !== SyntaxKind.BinaryExpression) { continue; } const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((declaration.parent).right); - if (rhsSymbol) { - documentation = rhsSymbol.getDocumentationComment(); - if (documentation.length > 0) { - return; - } + if (!rhsSymbol) { + continue; + } + + documentation = rhsSymbol.getDocumentationComment(); + if (documentation.length > 0) { + break; } } } From a531b87b3c668f56a4140699f89b7fcc4160dfbc Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 19 Aug 2016 17:06:05 -0700 Subject: [PATCH 210/508] Pass in baselineOpts into types baselines so that RWC baselines can be written to internal folder (#10443) --- src/harness/harness.ts | 4 ++-- src/harness/rwcRunner.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 14cb3147c32..9e27f500b80 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1339,7 +1339,7 @@ namespace Harness { }); } - export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[]) { + export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[], opts?: Harness.Baseline.BaselineOptions) { if (result.errors.length !== 0) { return; } @@ -1396,7 +1396,7 @@ namespace Harness { const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; - Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, fullExtension), () => fullBaseLine); + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, fullExtension), () => fullBaseLine, opts); } function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 5720f9b541c..d56e8d6d35f 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -226,7 +226,7 @@ namespace RWC { Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles .concat(otherFiles) .filter(file => !!compilerResult.program.getSourceFile(file.unitName)) - .filter(e => !Harness.isDefaultLibraryFile(e.unitName))); + .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts); }); }); } From 00facc2084ef928000338566e1cf7a7858021191 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 19 Aug 2016 17:06:59 -0700 Subject: [PATCH 211/508] Removing hasProperty check --- 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 3cf7528abbe..603d9c6dea0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -19958,7 +19958,7 @@ namespace ts { function getAmbientModules(): Symbol[] { const result: Symbol[] = []; for (const sym in globals) { - if (hasProperty(globals, sym) && ambientModuleSymbolRegex.test(sym)) { + if (ambientModuleSymbolRegex.test(sym)) { result.push(globals[sym]); } } From 0ebd19618d4b8b5aa64a0c7b2676898cef09308e Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 19 Aug 2016 17:17:49 -0700 Subject: [PATCH 212/508] Fixing regex for triple slash references --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index a10383ae09f..4c199de1869 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2070,7 +2070,7 @@ namespace ts { * for completions. * For example, this matches /// Date: Sat, 20 Aug 2016 12:36:57 +0900 Subject: [PATCH 213/508] Add error message Add error message when trying to relate primitives to the boxed/apparent backing types. --- src/compiler/checker.ts | 9 +++++- src/compiler/diagnosticMessages.json | 4 +++ .../apparentTypeSubtyping.errors.txt | 2 ++ .../apparentTypeSupertype.errors.txt | 2 ++ .../reference/arrayLiterals3.errors.txt | 2 ++ .../assignFromBooleanInterface.errors.txt | 2 ++ .../assignFromBooleanInterface2.errors.txt | 2 ++ .../assignFromNumberInterface.errors.txt | 2 ++ .../assignFromNumberInterface2.errors.txt | 2 ++ .../assignFromStringInterface.errors.txt | 2 ++ .../assignFromStringInterface2.errors.txt | 2 ++ .../reference/nativeToBoxedTypes.errors.txt | 29 +++++++++++++++++++ .../baselines/reference/nativeToBoxedTypes.js | 23 +++++++++++++++ .../reference/primitiveMembers.errors.txt | 2 ++ tests/cases/compiler/nativeToBoxedTypes.ts | 11 +++++++ 15 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/nativeToBoxedTypes.errors.txt create mode 100644 tests/baselines/reference/nativeToBoxedTypes.js create mode 100644 tests/cases/compiler/nativeToBoxedTypes.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8568cd5feed..bc8af9e6322 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6258,13 +6258,20 @@ namespace ts { targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); } + // check if trying to relate primitives to the boxed/apparent backing types. + if ((sourceType === "Number" && targetType === "number") || + (sourceType === "String" && targetType === "string") || + (sourceType === "Boolean" && targetType === "boolean")) { + reportError(Diagnostics._0_is_a_primitive_type_while_1_is_a_boxed_object_Prefer_using_0_when_possible, targetType, sourceType); + } + if (!message) { message = relation === comparableRelation ? Diagnostics.Type_0_is_not_comparable_to_type_1 : Diagnostics.Type_0_is_not_assignable_to_type_1; } - reportError(message, sourceType, targetType); + reportError(message, sourceType, targetType); } // Compare two types and return diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6210a20afa6..fb8bc21ec95 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1955,6 +1955,10 @@ "category": "Error", "code": 2691 }, + "'{0}' is a primitive type while '{1}' is a boxed object. Prefer using '{0}' when possible.": { + "category": "Error", + "code": 2692 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/apparentTypeSubtyping.errors.txt b/tests/baselines/reference/apparentTypeSubtyping.errors.txt index e1a53ef6a73..c19cfa44360 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.errors.txt +++ b/tests/baselines/reference/apparentTypeSubtyping.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(9,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. Types of property 'x' are incompatible. Type 'String' is not assignable to type 'string'. + 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (1 errors) ==== @@ -17,6 +18,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi !!! error TS2415: Class 'Derived' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'x' are incompatible. !!! error TS2415: Type 'String' is not assignable to type 'string'. +!!! error TS2415: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. x: String; } diff --git a/tests/baselines/reference/apparentTypeSupertype.errors.txt b/tests/baselines/reference/apparentTypeSupertype.errors.txt index 5fe5c92a5b3..b7195557e8d 100644 --- a/tests/baselines/reference/apparentTypeSupertype.errors.txt +++ b/tests/baselines/reference/apparentTypeSupertype.errors.txt @@ -2,6 +2,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty Types of property 'x' are incompatible. Type 'U' is not assignable to type 'string'. Type 'String' is not assignable to type 'string'. + 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (1 errors) ==== @@ -19,5 +20,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty !!! error TS2415: Types of property 'x' are incompatible. !!! error TS2415: Type 'U' is not assignable to type 'string'. !!! error TS2415: Type 'String' is not assignable to type 'string'. +!!! error TS2415: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. x: U; } \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index 8e6c7eccf81..eb0c6dc51b7 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -18,6 +18,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error Types of parameters 'items' and 'items' are incompatible. Type 'Number' is not assignable to type 'string | number'. Type 'Number' is not assignable to type 'number'. + 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. ==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ==== @@ -81,4 +82,5 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error !!! error TS2322: Types of parameters 'items' and 'items' are incompatible. !!! error TS2322: Type 'Number' is not assignable to type 'string | number'. !!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. \ No newline at end of file diff --git a/tests/baselines/reference/assignFromBooleanInterface.errors.txt b/tests/baselines/reference/assignFromBooleanInterface.errors.txt index 4b06603a9bf..f5c92a47569 100644 --- a/tests/baselines/reference/assignFromBooleanInterface.errors.txt +++ b/tests/baselines/reference/assignFromBooleanInterface.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts(3,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. + 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. ==== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts (1 errors) ==== @@ -7,4 +8,5 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts(3 x = a; ~ !!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. +!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromBooleanInterface2.errors.txt b/tests/baselines/reference/assignFromBooleanInterface2.errors.txt index c03eab60c74..bfbf56eec5a 100644 --- a/tests/baselines/reference/assignFromBooleanInterface2.errors.txt +++ b/tests/baselines/reference/assignFromBooleanInterface2.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts( Type '() => Object' is not assignable to type '() => boolean'. Type 'Object' is not assignable to type 'boolean'. tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(19,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. + 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(20,1): error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'. @@ -33,6 +34,7 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts( x = a; // expected error ~ !!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. +!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/assignFromNumberInterface.errors.txt b/tests/baselines/reference/assignFromNumberInterface.errors.txt index 0c8c4a5f5ac..e68ec76f68f 100644 --- a/tests/baselines/reference/assignFromNumberInterface.errors.txt +++ b/tests/baselines/reference/assignFromNumberInterface.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts(3,1): error TS2322: Type 'Number' is not assignable to type 'number'. + 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. ==== tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts (1 errors) ==== @@ -7,4 +8,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts(3,1 x = a; ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromNumberInterface2.errors.txt b/tests/baselines/reference/assignFromNumberInterface2.errors.txt index 85639cdeeaf..5cae4654760 100644 --- a/tests/baselines/reference/assignFromNumberInterface2.errors.txt +++ b/tests/baselines/reference/assignFromNumberInterface2.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(24,1): error TS2322: Type 'Number' is not assignable to type 'number'. + 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(25,1): error TS2322: Type 'NotNumber' is not assignable to type 'number'. @@ -29,6 +30,7 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(25 x = a; // expected error ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotNumber' is not assignable to type 'number'. diff --git a/tests/baselines/reference/assignFromStringInterface.errors.txt b/tests/baselines/reference/assignFromStringInterface.errors.txt index 6ec8afad120..80268f4b06a 100644 --- a/tests/baselines/reference/assignFromStringInterface.errors.txt +++ b/tests/baselines/reference/assignFromStringInterface.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts(3,1): error TS2322: Type 'String' is not assignable to type 'string'. + 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts (1 errors) ==== @@ -7,4 +8,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts(3,1 x = a; ~ !!! error TS2322: Type 'String' is not assignable to type 'string'. +!!! error TS2322: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromStringInterface2.errors.txt b/tests/baselines/reference/assignFromStringInterface2.errors.txt index 4e09eb6eacb..d20bdaaba32 100644 --- a/tests/baselines/reference/assignFromStringInterface2.errors.txt +++ b/tests/baselines/reference/assignFromStringInterface2.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(47,1): error TS2322: Type 'String' is not assignable to type 'string'. + 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(48,1): error TS2322: Type 'NotString' is not assignable to type 'string'. @@ -52,6 +53,7 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(48 x = a; // expected error ~ !!! error TS2322: Type 'String' is not assignable to type 'string'. +!!! error TS2322: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotString' is not assignable to type 'string'. diff --git a/tests/baselines/reference/nativeToBoxedTypes.errors.txt b/tests/baselines/reference/nativeToBoxedTypes.errors.txt new file mode 100644 index 00000000000..c471e6b0e7b --- /dev/null +++ b/tests/baselines/reference/nativeToBoxedTypes.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/nativeToBoxedTypes.ts(3,1): error TS2322: Type 'Number' is not assignable to type 'number'. + 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. +tests/cases/compiler/nativeToBoxedTypes.ts(7,1): error TS2322: Type 'String' is not assignable to type 'string'. + 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. +tests/cases/compiler/nativeToBoxedTypes.ts(11,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. + 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. + + +==== tests/cases/compiler/nativeToBoxedTypes.ts (3 errors) ==== + var N = new Number(); + var n = 100; + n = N; + ~ +!!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. + + var S = new String(); + var s = "foge"; + s = S; + ~ +!!! error TS2322: Type 'String' is not assignable to type 'string'. +!!! error TS2322: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. + + var B = new Boolean(); + var b = true; + b = B; + ~ +!!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. +!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. \ No newline at end of file diff --git a/tests/baselines/reference/nativeToBoxedTypes.js b/tests/baselines/reference/nativeToBoxedTypes.js new file mode 100644 index 00000000000..074b39fa08d --- /dev/null +++ b/tests/baselines/reference/nativeToBoxedTypes.js @@ -0,0 +1,23 @@ +//// [nativeToBoxedTypes.ts] +var N = new Number(); +var n = 100; +n = N; + +var S = new String(); +var s = "foge"; +s = S; + +var B = new Boolean(); +var b = true; +b = B; + +//// [nativeToBoxedTypes.js] +var N = new Number(); +var n = 100; +n = N; +var S = new String(); +var s = "foge"; +s = S; +var B = new Boolean(); +var b = true; +b = B; diff --git a/tests/baselines/reference/primitiveMembers.errors.txt b/tests/baselines/reference/primitiveMembers.errors.txt index da8b75f9bc5..24f02486d00 100644 --- a/tests/baselines/reference/primitiveMembers.errors.txt +++ b/tests/baselines/reference/primitiveMembers.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/primitiveMembers.ts(5,3): error TS2339: Property 'toBAZ' does not exist on type 'number'. tests/cases/compiler/primitiveMembers.ts(11,1): error TS2322: Type 'Number' is not assignable to type 'number'. + 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. ==== tests/cases/compiler/primitiveMembers.ts (2 errors) ==== @@ -18,6 +19,7 @@ tests/cases/compiler/primitiveMembers.ts(11,1): error TS2322: Type 'Number' is n n = N; // should not work, as 'number' has a different brand ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. N = n; // should work var o: Object = {} diff --git a/tests/cases/compiler/nativeToBoxedTypes.ts b/tests/cases/compiler/nativeToBoxedTypes.ts new file mode 100644 index 00000000000..6cd51251b06 --- /dev/null +++ b/tests/cases/compiler/nativeToBoxedTypes.ts @@ -0,0 +1,11 @@ +var N = new Number(); +var n = 100; +n = N; + +var S = new String(); +var s = "foge"; +s = S; + +var B = new Boolean(); +var b = true; +b = B; \ No newline at end of file From 37a9e6a9ccee232831238fe03446610b2645828d Mon Sep 17 00:00:00 2001 From: Yuichi Nukiyama Date: Sat, 20 Aug 2016 13:44:09 +0900 Subject: [PATCH 214/508] fix linting error --- 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 bc8af9e6322..e279b07bb1f 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6271,7 +6271,7 @@ namespace ts { Diagnostics.Type_0_is_not_assignable_to_type_1; } - reportError(message, sourceType, targetType); + reportError(message, sourceType, targetType); } // Compare two types and return From ab2750a631281b90b626810494055e6ef7c763f9 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Sat, 20 Aug 2016 00:39:41 -0700 Subject: [PATCH 215/508] Improves Promise type definition. Fixes #4903 --- src/lib/es2015.promise.d.ts | 139 ++- .../reference/inferenceLimit.symbols | 8 +- .../baselines/reference/inferenceLimit.types | 8 +- ...ibrary_NoErrorDuplicateLibOptions1.symbols | 4 +- ...eLibrary_NoErrorDuplicateLibOptions1.types | 4 +- ...ibrary_NoErrorDuplicateLibOptions2.symbols | 4 +- ...eLibrary_NoErrorDuplicateLibOptions2.types | 4 +- ...larizeLibrary_TargetES5UsingES6Lib.symbols | 4 +- ...dularizeLibrary_TargetES5UsingES6Lib.types | 4 +- tests/baselines/reference/promiseType.js | 116 ++- tests/baselines/reference/promiseType.symbols | 447 ++++++++- tests/baselines/reference/promiseType.types | 653 ++++++++++++- .../reference/promiseTypeStrictNull.js | 316 ++++++ .../reference/promiseTypeStrictNull.symbols | 640 +++++++++++++ .../reference/promiseTypeStrictNull.types | 900 ++++++++++++++++++ .../promiseVoidErrorCallback.symbols | 8 +- .../reference/promiseVoidErrorCallback.types | 8 +- tests/cases/compiler/promiseType.ts | 64 +- tests/cases/compiler/promiseTypeStrictNull.ts | 157 +++ 19 files changed, 3403 insertions(+), 85 deletions(-) create mode 100644 tests/baselines/reference/promiseTypeStrictNull.js create mode 100644 tests/baselines/reference/promiseTypeStrictNull.symbols create mode 100644 tests/baselines/reference/promiseTypeStrictNull.types create mode 100644 tests/cases/compiler/promiseTypeStrictNull.ts diff --git a/src/lib/es2015.promise.d.ts b/src/lib/es2015.promise.d.ts index c5af984f7e0..0f46b2d6783 100644 --- a/src/lib/es2015.promise.d.ts +++ b/src/lib/es2015.promise.d.ts @@ -3,20 +3,17 @@ */ interface Promise { /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. + * Creates a new Promise with the same internal state of this Promise. + * @returns A Promise. */ - then(onfulfilled: (value: T) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; + then(): Promise; /** * Attaches callbacks for the resolution and/or rejection of the Promise. * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. * @returns A Promise for the completion of which ever callback is executed. */ - then(onfulfilled: (value: T) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; + then(onfulfilled: undefined | null): Promise; /** * Attaches callbacks for the resolution and/or rejection of the Promise. @@ -25,11 +22,50 @@ interface Promise { */ then(onfulfilled: (value: T) => TResult | PromiseLike): Promise; + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled: undefined | null, onrejected: undefined | null): Promise; + + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled: undefined | null, onrejected: (reason: any) => TResult | PromiseLike): Promise; + + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled: (value: T) => TResult | PromiseLike, onrejected: undefined | null): Promise; + + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled: (value: T) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; + /** * Creates a new Promise with the same internal state of this Promise. * @returns A Promise. */ - then(): Promise; + catch(): Promise; + + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected: undefined | null): Promise; /** * Attaches a callback for only the rejection of the Promise. @@ -37,13 +73,6 @@ interface Promise { * @returns A Promise for the completion of the callback. */ catch(onrejected: (reason: any) => TResult | PromiseLike): Promise; - - /** - * Attaches a callback for only the rejection of the Promise. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of the callback. - */ - catch(onrejected: (reason: any) => T | PromiseLike): Promise; } interface PromiseConstructor { @@ -140,6 +169,86 @@ interface PromiseConstructor { */ all(values: (T | PromiseLike)[]): Promise; + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: [T1 | PromiseLike, T2 | PromiseLike]): Promise; + + /** + * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * or rejected. + * @param values An array of Promises. + * @returns A new Promise. + */ + race(values: (T | PromiseLike)[]): Promise; + /** * Creates a new rejected promise for the provided reason. * @param reason The reason the promise was rejected. diff --git a/tests/baselines/reference/inferenceLimit.symbols b/tests/baselines/reference/inferenceLimit.symbols index 4601de27b51..b8d6663e974 100644 --- a/tests/baselines/reference/inferenceLimit.symbols +++ b/tests/baselines/reference/inferenceLimit.symbols @@ -37,14 +37,14 @@ export class BrokenClass { >reject : Symbol(reject, Decl(file1.ts, 13, 34)) this.doStuff(order.id) ->this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>this.doStuff(order.id) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >this.doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3)) >this : Symbol(BrokenClass, Decl(file1.ts, 1, 39)) >doStuff : Symbol(BrokenClass.doStuff, Decl(file1.ts, 27, 3)) >order : Symbol(order, Decl(file1.ts, 12, 25)) .then((items) => { ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >items : Symbol(items, Decl(file1.ts, 15, 17)) order.items = items; @@ -60,7 +60,7 @@ export class BrokenClass { }; return Promise.all(result.map(populateItems)) ->Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.all(result.map(populateItems)) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise.all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) >all : Symbol(PromiseConstructor.all, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) @@ -70,7 +70,7 @@ export class BrokenClass { >populateItems : Symbol(populateItems, Decl(file1.ts, 12, 7)) .then((orders: Array) => { ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >orders : Symbol(orders, Decl(file1.ts, 23, 13)) >Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --)) >MyModule : Symbol(MyModule, Decl(file1.ts, 1, 6)) diff --git a/tests/baselines/reference/inferenceLimit.types b/tests/baselines/reference/inferenceLimit.types index 37b51e49644..d5cf7c6d428 100644 --- a/tests/baselines/reference/inferenceLimit.types +++ b/tests/baselines/reference/inferenceLimit.types @@ -46,7 +46,7 @@ export class BrokenClass { this.doStuff(order.id) >this.doStuff(order.id) .then((items) => { order.items = items; resolve(order); }) : Promise ->this.doStuff(order.id) .then : { (onfulfilled: (value: void) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: void) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: void) => TResult | PromiseLike): Promise; (): Promise; } +>this.doStuff(order.id) .then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: void) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: void) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: void) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >this.doStuff(order.id) : Promise >this.doStuff : (id: number) => Promise >this : this @@ -56,7 +56,7 @@ export class BrokenClass { >id : any .then((items) => { ->then : { (onfulfilled: (value: void) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: void) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: void) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: void) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: void) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: void) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >(items) => { order.items = items; resolve(order); } : (items: void) => void >items : void @@ -78,7 +78,7 @@ export class BrokenClass { return Promise.all(result.map(populateItems)) >Promise.all(result.map(populateItems)) .then((orders: Array) => { resolve(orders); }) : Promise ->Promise.all(result.map(populateItems)) .then : { (onfulfilled: (value: {}[]) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: {}[]) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}[]) => TResult | PromiseLike): Promise; (): Promise<{}[]>; } +>Promise.all(result.map(populateItems)) .then : { (): Promise<{}[]>; (onfulfilled: null): Promise<{}[]>; (onfulfilled: (value: {}[]) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise<{}[]>; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise<{}[] | TResult>; (onfulfilled: (value: {}[]) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: {}[]) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >Promise.all(result.map(populateItems)) : Promise<{}[]> >Promise.all : { (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike, T10 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike, T9 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike, T8 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike, T7 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6, T7]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike, T6 | PromiseLike]): Promise<[T1, T2, T3, T4, T5, T6]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike, T5 | PromiseLike]): Promise<[T1, T2, T3, T4, T5]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike, T4 | PromiseLike]): Promise<[T1, T2, T3, T4]>; (values: [T1 | PromiseLike, T2 | PromiseLike, T3 | PromiseLike]): Promise<[T1, T2, T3]>; (values: [T1 | PromiseLike, T2 | PromiseLike]): Promise<[T1, T2]>; (values: (T | PromiseLike)[]): Promise; (values: Iterable>): Promise; } >Promise : PromiseConstructor @@ -90,7 +90,7 @@ export class BrokenClass { >populateItems : (order: any) => Promise<{}> .then((orders: Array) => { ->then : { (onfulfilled: (value: {}[]) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: {}[]) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}[]) => TResult | PromiseLike): Promise; (): Promise<{}[]>; } +>then : { (): Promise<{}[]>; (onfulfilled: null): Promise<{}[]>; (onfulfilled: (value: {}[]) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise<{}[]>; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise<{}[] | TResult>; (onfulfilled: (value: {}[]) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: {}[]) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >(orders: Array) => { resolve(orders); } : (orders: MyModule.MyModel[]) => void >orders : MyModule.MyModel[] >Array : T[] diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols index d8520698e6c..11d2d0997de 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.symbols @@ -121,9 +121,9 @@ declare var console: any; >console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11)) out().then(() => { ->out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 45, 37)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) console.log("Yea!"); >console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions1.ts, 52, 11)) diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types index 3851714cad8..4232468c5e7 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types @@ -148,10 +148,10 @@ declare var console: any; out().then(() => { >out().then(() => { console.log("Yea!");}) : Promise ->out().then : { (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (): Promise<{}>; } +>out().then : { (): Promise<{}>; (onfulfilled: null): Promise<{}>; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise<{}>; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >out() : Promise<{}> >out : () => Promise<{}> ->then : { (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (): Promise<{}>; } +>then : { (): Promise<{}>; (onfulfilled: null): Promise<{}>; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise<{}>; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >() => { console.log("Yea!");} : () => void console.log("Yea!"); diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols index ea1eb599c6f..a4d4ed570b8 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.symbols @@ -121,9 +121,9 @@ declare var console: any; >console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11)) out().then(() => { ->out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >out : Symbol(out, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 45, 37)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) console.log("Yea!"); >console : Symbol(console, Decl(modularizeLibrary_NoErrorDuplicateLibOptions2.ts, 52, 11)) diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types index f9c1894f86f..762eba862f0 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types @@ -148,10 +148,10 @@ declare var console: any; out().then(() => { >out().then(() => { console.log("Yea!");}) : Promise ->out().then : { (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (): Promise<{}>; } +>out().then : { (): Promise<{}>; (onfulfilled: null): Promise<{}>; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise<{}>; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >out() : Promise<{}> >out : () => Promise<{}> ->then : { (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (): Promise<{}>; } +>then : { (): Promise<{}>; (onfulfilled: null): Promise<{}>; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise<{}>; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >() => { console.log("Yea!");} : () => void console.log("Yea!"); diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols index ed1fb96ded3..f39ed8bb3c1 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.symbols @@ -121,9 +121,9 @@ declare var console: any; >console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11)) out().then(() => { ->out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>out().then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >out : Symbol(out, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 45, 37)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) console.log("Yea!"); >console : Symbol(console, Decl(modularizeLibrary_TargetES5UsingES6Lib.ts, 52, 11)) diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types index 8728176c2c1..28dc89acd6e 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types @@ -148,10 +148,10 @@ declare var console: any; out().then(() => { >out().then(() => { console.log("Yea!");}) : Promise ->out().then : { (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (): Promise<{}>; } +>out().then : { (): Promise<{}>; (onfulfilled: null): Promise<{}>; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise<{}>; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >out() : Promise<{}> >out : () => Promise<{}> ->then : { (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (): Promise<{}>; } +>then : { (): Promise<{}>; (onfulfilled: null): Promise<{}>; (onfulfilled: (value: {}) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise<{}>; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise<{} | TResult>; (onfulfilled: (value: {}) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: {}) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >() => { console.log("Yea!");} : () => void console.log("Yea!"); diff --git a/tests/baselines/reference/promiseType.js b/tests/baselines/reference/promiseType.js index 6b8d292a2b0..fc49dda9db4 100644 --- a/tests/baselines/reference/promiseType.js +++ b/tests/baselines/reference/promiseType.js @@ -91,7 +91,69 @@ async function I() { catch (e) { return Promise.reject(Error()); } -} +} + +// addresses github issue #4903: + +const p00 = p.catch(); +const p01 = p.catch(undefined); +const p07 = p.catch(null); +const p02 = p.catch(() => 1); +const p03 = p.catch(() => {}); +const p04 = p.catch(() => {throw 1}); +const p05 = p.catch(() => Promise.reject(1)); +const p06 = p.catch(() => Promise.resolve(1)); + +const p10 = p.then(); + +const p20 = p.then(undefined); +const p21 = p.then(() => 1); +const p22 = p.then(() => {}); +const p23 = p.then(() => {throw 1}); +const p24 = p.then(() => Promise.resolve(1)); +const p25 = p.then(() => Promise.reject(1)); + +const p30 = p.then(undefined, undefined); +const p31 = p.then(undefined, () => 1); +const p32 = p.then(undefined, () => {}); +const p33 = p.then(undefined, () => {throw 1}); +const p34 = p.then(undefined, () => Promise.resolve(1)); +const p35 = p.then(undefined, () => Promise.reject(1)); + +const p40 = p.then(() => "1", undefined); +const p41 = p.then(() => "1", () => 1); +const p42 = p.then(() => "1", () => {}); +const p43 = p.then(() => "1", () => {throw 1}); +const p44 = p.then(() => "1", () => Promise.resolve(1)); +const p45 = p.then(() => "1", () => Promise.reject(1)); + +const p50 = p.then(() => {}, undefined); +const p51 = p.then(() => {}, () => 1); +const p52 = p.then(() => {}, () => {}); +const p53 = p.then(() => {}, () => {throw 1}); +const p54 = p.then(() => {}, () => Promise.resolve(1)); +const p55 = p.then(() => {}, () => Promise.reject(1)); + +const p60 = p.then(() => {throw 1}, undefined); +const p61 = p.then(() => {throw 1}, () => 1); +const p62 = p.then(() => {throw 1}, () => {}); +const p63 = p.then(() => {throw 1}, () => {throw 1}); +const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); +const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); + +const p70 = p.then(() => Promise.resolve("1"), undefined); +const p71 = p.then(() => Promise.resolve("1"), () => 1); +const p72 = p.then(() => Promise.resolve("1"), () => {}); +const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); + +const p80 = p.then(() => Promise.reject(1), undefined); +const p81 = p.then(() => Promise.reject(1), () => 1); +const p82 = p.then(() => Promise.reject(1), () => {}); +const p83 = p.then(() => Promise.reject(1), () => {throw 1}); +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); //// [promiseType.js] var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { @@ -200,3 +262,55 @@ function I() { } }); } +// addresses github issue #4903: +const p00 = p.catch(); +const p01 = p.catch(undefined); +const p07 = p.catch(null); +const p02 = p.catch(() => 1); +const p03 = p.catch(() => { }); +const p04 = p.catch(() => { throw 1; }); +const p05 = p.catch(() => Promise.reject(1)); +const p06 = p.catch(() => Promise.resolve(1)); +const p10 = p.then(); +const p20 = p.then(undefined); +const p21 = p.then(() => 1); +const p22 = p.then(() => { }); +const p23 = p.then(() => { throw 1; }); +const p24 = p.then(() => Promise.resolve(1)); +const p25 = p.then(() => Promise.reject(1)); +const p30 = p.then(undefined, undefined); +const p31 = p.then(undefined, () => 1); +const p32 = p.then(undefined, () => { }); +const p33 = p.then(undefined, () => { throw 1; }); +const p34 = p.then(undefined, () => Promise.resolve(1)); +const p35 = p.then(undefined, () => Promise.reject(1)); +const p40 = p.then(() => "1", undefined); +const p41 = p.then(() => "1", () => 1); +const p42 = p.then(() => "1", () => { }); +const p43 = p.then(() => "1", () => { throw 1; }); +const p44 = p.then(() => "1", () => Promise.resolve(1)); +const p45 = p.then(() => "1", () => Promise.reject(1)); +const p50 = p.then(() => { }, undefined); +const p51 = p.then(() => { }, () => 1); +const p52 = p.then(() => { }, () => { }); +const p53 = p.then(() => { }, () => { throw 1; }); +const p54 = p.then(() => { }, () => Promise.resolve(1)); +const p55 = p.then(() => { }, () => Promise.reject(1)); +const p60 = p.then(() => { throw 1; }, undefined); +const p61 = p.then(() => { throw 1; }, () => 1); +const p62 = p.then(() => { throw 1; }, () => { }); +const p63 = p.then(() => { throw 1; }, () => { throw 1; }); +const p64 = p.then(() => { throw 1; }, () => Promise.resolve(1)); +const p65 = p.then(() => { throw 1; }, () => Promise.reject(1)); +const p70 = p.then(() => Promise.resolve("1"), undefined); +const p71 = p.then(() => Promise.resolve("1"), () => 1); +const p72 = p.then(() => Promise.resolve("1"), () => { }); +const p73 = p.then(() => Promise.resolve("1"), () => { throw 1; }); +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +const p80 = p.then(() => Promise.reject(1), undefined); +const p81 = p.then(() => Promise.reject(1), () => 1); +const p82 = p.then(() => Promise.reject(1), () => { }); +const p83 = p.then(() => Promise.reject(1), () => { throw 1; }); +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); diff --git a/tests/baselines/reference/promiseType.symbols b/tests/baselines/reference/promiseType.symbols index fde4cf4f6f2..afc0c5f31d6 100644 --- a/tests/baselines/reference/promiseType.symbols +++ b/tests/baselines/reference/promiseType.symbols @@ -5,47 +5,47 @@ declare var p: Promise; const a = p.then(); >a : Symbol(a, Decl(promiseType.ts, 2, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) const b = p.then(b => 1); >b : Symbol(b, Decl(promiseType.ts, 3, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >b : Symbol(b, Decl(promiseType.ts, 3, 17)) const c = p.then(b => 1, e => 'error'); >c : Symbol(c, Decl(promiseType.ts, 4, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >b : Symbol(b, Decl(promiseType.ts, 4, 17)) >e : Symbol(e, Decl(promiseType.ts, 4, 24)) const d = p.then(b => 1, e => { }); >d : Symbol(d, Decl(promiseType.ts, 5, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >b : Symbol(b, Decl(promiseType.ts, 5, 17)) >e : Symbol(e, Decl(promiseType.ts, 5, 24)) const e = p.then(b => 1, e => { throw Error(); }); >e : Symbol(e, Decl(promiseType.ts, 6, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >b : Symbol(b, Decl(promiseType.ts, 6, 17)) >e : Symbol(e, Decl(promiseType.ts, 6, 24)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) const f = p.then(b => 1, e => Promise.reject(Error())); >f : Symbol(f, Decl(promiseType.ts, 7, 5)) ->p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >b : Symbol(b, Decl(promiseType.ts, 7, 17)) >e : Symbol(e, Decl(promiseType.ts, 7, 24)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) @@ -55,31 +55,31 @@ const f = p.then(b => 1, e => Promise.reject(Error())); const g = p.catch(e => 'error'); >g : Symbol(g, Decl(promiseType.ts, 8, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >e : Symbol(e, Decl(promiseType.ts, 8, 18)) const h = p.catch(e => { }); >h : Symbol(h, Decl(promiseType.ts, 9, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >e : Symbol(e, Decl(promiseType.ts, 9, 18)) const i = p.catch(e => { throw Error(); }); >i : Symbol(i, Decl(promiseType.ts, 10, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >e : Symbol(e, Decl(promiseType.ts, 10, 18)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) const j = p.catch(e => Promise.reject(Error())); >j : Symbol(j, Decl(promiseType.ts, 11, 5)) ->p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >p : Symbol(p, Decl(promiseType.ts, 0, 11)) ->catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >e : Symbol(e, Decl(promiseType.ts, 11, 18)) >Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) @@ -231,3 +231,410 @@ async function I() { >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) } } + +// addresses github issue #4903: + +const p00 = p.catch(); +>p00 : Symbol(p00, Decl(promiseType.ts, 96, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p01 = p.catch(undefined); +>p01 : Symbol(p01, Decl(promiseType.ts, 97, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p07 = p.catch(null); +>p07 : Symbol(p07, Decl(promiseType.ts, 98, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p02 = p.catch(() => 1); +>p02 : Symbol(p02, Decl(promiseType.ts, 99, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p03 = p.catch(() => {}); +>p03 : Symbol(p03, Decl(promiseType.ts, 100, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p04 = p.catch(() => {throw 1}); +>p04 : Symbol(p04, Decl(promiseType.ts, 101, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p05 = p.catch(() => Promise.reject(1)); +>p05 : Symbol(p05, Decl(promiseType.ts, 102, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p06 = p.catch(() => Promise.resolve(1)); +>p06 : Symbol(p06, Decl(promiseType.ts, 103, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p10 = p.then(); +>p10 : Symbol(p10, Decl(promiseType.ts, 105, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p20 = p.then(undefined); +>p20 : Symbol(p20, Decl(promiseType.ts, 107, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p21 = p.then(() => 1); +>p21 : Symbol(p21, Decl(promiseType.ts, 108, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p22 = p.then(() => {}); +>p22 : Symbol(p22, Decl(promiseType.ts, 109, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p23 = p.then(() => {throw 1}); +>p23 : Symbol(p23, Decl(promiseType.ts, 110, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p24 = p.then(() => Promise.resolve(1)); +>p24 : Symbol(p24, Decl(promiseType.ts, 111, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p25 = p.then(() => Promise.reject(1)); +>p25 : Symbol(p25, Decl(promiseType.ts, 112, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p30 = p.then(undefined, undefined); +>p30 : Symbol(p30, Decl(promiseType.ts, 114, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +const p31 = p.then(undefined, () => 1); +>p31 : Symbol(p31, Decl(promiseType.ts, 115, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p32 = p.then(undefined, () => {}); +>p32 : Symbol(p32, Decl(promiseType.ts, 116, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p33 = p.then(undefined, () => {throw 1}); +>p33 : Symbol(p33, Decl(promiseType.ts, 117, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p34 = p.then(undefined, () => Promise.resolve(1)); +>p34 : Symbol(p34, Decl(promiseType.ts, 118, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p35 = p.then(undefined, () => Promise.reject(1)); +>p35 : Symbol(p35, Decl(promiseType.ts, 119, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p40 = p.then(() => "1", undefined); +>p40 : Symbol(p40, Decl(promiseType.ts, 121, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p41 = p.then(() => "1", () => 1); +>p41 : Symbol(p41, Decl(promiseType.ts, 122, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p42 = p.then(() => "1", () => {}); +>p42 : Symbol(p42, Decl(promiseType.ts, 123, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p43 = p.then(() => "1", () => {throw 1}); +>p43 : Symbol(p43, Decl(promiseType.ts, 124, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p44 = p.then(() => "1", () => Promise.resolve(1)); +>p44 : Symbol(p44, Decl(promiseType.ts, 125, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p45 = p.then(() => "1", () => Promise.reject(1)); +>p45 : Symbol(p45, Decl(promiseType.ts, 126, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p50 = p.then(() => {}, undefined); +>p50 : Symbol(p50, Decl(promiseType.ts, 128, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p51 = p.then(() => {}, () => 1); +>p51 : Symbol(p51, Decl(promiseType.ts, 129, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p52 = p.then(() => {}, () => {}); +>p52 : Symbol(p52, Decl(promiseType.ts, 130, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p53 = p.then(() => {}, () => {throw 1}); +>p53 : Symbol(p53, Decl(promiseType.ts, 131, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p54 = p.then(() => {}, () => Promise.resolve(1)); +>p54 : Symbol(p54, Decl(promiseType.ts, 132, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p55 = p.then(() => {}, () => Promise.reject(1)); +>p55 : Symbol(p55, Decl(promiseType.ts, 133, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p60 = p.then(() => {throw 1}, undefined); +>p60 : Symbol(p60, Decl(promiseType.ts, 135, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p61 = p.then(() => {throw 1}, () => 1); +>p61 : Symbol(p61, Decl(promiseType.ts, 136, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p62 = p.then(() => {throw 1}, () => {}); +>p62 : Symbol(p62, Decl(promiseType.ts, 137, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p63 = p.then(() => {throw 1}, () => {throw 1}); +>p63 : Symbol(p63, Decl(promiseType.ts, 138, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); +>p64 : Symbol(p64, Decl(promiseType.ts, 139, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); +>p65 : Symbol(p65, Decl(promiseType.ts, 140, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p70 = p.then(() => Promise.resolve("1"), undefined); +>p70 : Symbol(p70, Decl(promiseType.ts, 142, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p71 = p.then(() => Promise.resolve("1"), () => 1); +>p71 : Symbol(p71, Decl(promiseType.ts, 143, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p72 = p.then(() => Promise.resolve("1"), () => {}); +>p72 : Symbol(p72, Decl(promiseType.ts, 144, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); +>p73 : Symbol(p73, Decl(promiseType.ts, 145, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +>p74 : Symbol(p74, Decl(promiseType.ts, 146, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +>p75 : Symbol(p75, Decl(promiseType.ts, 147, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p80 = p.then(() => Promise.reject(1), undefined); +>p80 : Symbol(p80, Decl(promiseType.ts, 149, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p81 = p.then(() => Promise.reject(1), () => 1); +>p81 : Symbol(p81, Decl(promiseType.ts, 150, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p82 = p.then(() => Promise.reject(1), () => {}); +>p82 : Symbol(p82, Decl(promiseType.ts, 151, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p83 = p.then(() => Promise.reject(1), () => {throw 1}); +>p83 : Symbol(p83, Decl(promiseType.ts, 152, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +>p84 : Symbol(p84, Decl(promiseType.ts, 153, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); +>p85 : Symbol(p85, Decl(promiseType.ts, 154, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseType.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + diff --git a/tests/baselines/reference/promiseType.types b/tests/baselines/reference/promiseType.types index 1608182d6e9..94ec3a367ec 100644 --- a/tests/baselines/reference/promiseType.types +++ b/tests/baselines/reference/promiseType.types @@ -6,16 +6,16 @@ declare var p: Promise; const a = p.then(); >a : Promise >p.then() : Promise ->p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >p : Promise ->then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } const b = p.then(b => 1); >b : Promise >p.then(b => 1) : Promise ->p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >p : Promise ->then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >b => 1 : (b: boolean) => number >b : boolean >1 : number @@ -23,9 +23,9 @@ const b = p.then(b => 1); const c = p.then(b => 1, e => 'error'); >c : Promise >p.then(b => 1, e => 'error') : Promise ->p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >p : Promise ->then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >b => 1 : (b: boolean) => number >b : boolean >1 : number @@ -36,9 +36,9 @@ const c = p.then(b => 1, e => 'error'); const d = p.then(b => 1, e => { }); >d : Promise >p.then(b => 1, e => { }) : Promise ->p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >p : Promise ->then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >b => 1 : (b: boolean) => number >b : boolean >1 : number @@ -48,9 +48,9 @@ const d = p.then(b => 1, e => { }); const e = p.then(b => 1, e => { throw Error(); }); >e : Promise >p.then(b => 1, e => { throw Error(); }) : Promise ->p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >p : Promise ->then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >b => 1 : (b: boolean) => number >b : boolean >1 : number @@ -62,9 +62,9 @@ const e = p.then(b => 1, e => { throw Error(); }); const f = p.then(b => 1, e => Promise.reject(Error())); >f : Promise >p.then(b => 1, e => Promise.reject(Error())) : Promise ->p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >p : Promise ->then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >b => 1 : (b: boolean) => number >b : boolean >1 : number @@ -80,9 +80,9 @@ const f = p.then(b => 1, e => Promise.reject(Error())); const g = p.catch(e => 'error'); >g : Promise >p.catch(e => 'error') : Promise ->p.catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } >p : Promise ->catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } >e => 'error' : (e: any) => string >e : any >'error' : string @@ -90,18 +90,18 @@ const g = p.catch(e => 'error'); const h = p.catch(e => { }); >h : Promise >p.catch(e => { }) : Promise ->p.catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } >p : Promise ->catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } >e => { } : (e: any) => void >e : any const i = p.catch(e => { throw Error(); }); >i : Promise >p.catch(e => { throw Error(); }) : Promise ->p.catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } >p : Promise ->catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } >e => { throw Error(); } : (e: any) => never >e : any >Error() : Error @@ -110,9 +110,9 @@ const i = p.catch(e => { throw Error(); }); const j = p.catch(e => Promise.reject(Error())); >j : Promise >p.catch(e => Promise.reject(Error())) : Promise ->p.catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } >p : Promise ->catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } >e => Promise.reject(Error()) : (e: any) => Promise >e : any >Promise.reject(Error()) : Promise @@ -285,3 +285,616 @@ async function I() { >Error : ErrorConstructor } } + +// addresses github issue #4903: + +const p00 = p.catch(); +>p00 : Promise +>p.catch() : Promise +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } + +const p01 = p.catch(undefined); +>p01 : Promise +>p.catch(undefined) : Promise +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>undefined : undefined + +const p07 = p.catch(null); +>p07 : Promise +>p.catch(null) : Promise +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>null : null + +const p02 = p.catch(() => 1); +>p02 : Promise +>p.catch(() => 1) : Promise +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => 1 : () => number +>1 : number + +const p03 = p.catch(() => {}); +>p03 : Promise +>p.catch(() => {}) : Promise +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => {} : () => void + +const p04 = p.catch(() => {throw 1}); +>p04 : Promise +>p.catch(() => {throw 1}) : Promise +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number + +const p05 = p.catch(() => Promise.reject(1)); +>p05 : Promise +>p.catch(() => Promise.reject(1)) : Promise +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p06 = p.catch(() => Promise.resolve(1)); +>p06 : Promise +>p.catch(() => Promise.resolve(1)) : Promise +>p.catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p10 = p.then(); +>p10 : Promise +>p.then() : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } + +const p20 = p.then(undefined); +>p20 : Promise +>p.then(undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined + +const p21 = p.then(() => 1); +>p21 : Promise +>p.then(() => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => 1 : () => number +>1 : number + +const p22 = p.then(() => {}); +>p22 : Promise +>p.then(() => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void + +const p23 = p.then(() => {throw 1}); +>p23 : Promise +>p.then(() => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number + +const p24 = p.then(() => Promise.resolve(1)); +>p24 : Promise +>p.then(() => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p25 = p.then(() => Promise.reject(1)); +>p25 : Promise +>p.then(() => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p30 = p.then(undefined, undefined); +>p30 : Promise +>p.then(undefined, undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>undefined : undefined + +const p31 = p.then(undefined, () => 1); +>p31 : Promise +>p.then(undefined, () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => 1 : () => number +>1 : number + +const p32 = p.then(undefined, () => {}); +>p32 : Promise +>p.then(undefined, () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => {} : () => void + +const p33 = p.then(undefined, () => {throw 1}); +>p33 : Promise +>p.then(undefined, () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => {throw 1} : () => never +>1 : number + +const p34 = p.then(undefined, () => Promise.resolve(1)); +>p34 : Promise +>p.then(undefined, () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p35 = p.then(undefined, () => Promise.reject(1)); +>p35 : Promise +>p.then(undefined, () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p40 = p.then(() => "1", undefined); +>p40 : Promise +>p.then(() => "1", undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>undefined : undefined + +const p41 = p.then(() => "1", () => 1); +>p41 : Promise +>p.then(() => "1", () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => 1 : () => number +>1 : number + +const p42 = p.then(() => "1", () => {}); +>p42 : Promise +>p.then(() => "1", () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => {} : () => void + +const p43 = p.then(() => "1", () => {throw 1}); +>p43 : Promise +>p.then(() => "1", () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => {throw 1} : () => never +>1 : number + +const p44 = p.then(() => "1", () => Promise.resolve(1)); +>p44 : Promise +>p.then(() => "1", () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p45 = p.then(() => "1", () => Promise.reject(1)); +>p45 : Promise +>p.then(() => "1", () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p50 = p.then(() => {}, undefined); +>p50 : Promise +>p.then(() => {}, undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>undefined : undefined + +const p51 = p.then(() => {}, () => 1); +>p51 : Promise +>p.then(() => {}, () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => 1 : () => number +>1 : number + +const p52 = p.then(() => {}, () => {}); +>p52 : Promise +>p.then(() => {}, () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => {} : () => void + +const p53 = p.then(() => {}, () => {throw 1}); +>p53 : Promise +>p.then(() => {}, () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => {throw 1} : () => never +>1 : number + +const p54 = p.then(() => {}, () => Promise.resolve(1)); +>p54 : Promise +>p.then(() => {}, () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p55 = p.then(() => {}, () => Promise.reject(1)); +>p55 : Promise +>p.then(() => {}, () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p60 = p.then(() => {throw 1}, undefined); +>p60 : Promise +>p.then(() => {throw 1}, undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>undefined : undefined + +const p61 = p.then(() => {throw 1}, () => 1); +>p61 : Promise +>p.then(() => {throw 1}, () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => 1 : () => number +>1 : number + +const p62 = p.then(() => {throw 1}, () => {}); +>p62 : Promise +>p.then(() => {throw 1}, () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => {} : () => void + +const p63 = p.then(() => {throw 1}, () => {throw 1}); +>p63 : Promise +>p.then(() => {throw 1}, () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => {throw 1} : () => never +>1 : number + +const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); +>p64 : Promise +>p.then(() => {throw 1}, () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); +>p65 : Promise +>p.then(() => {throw 1}, () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p70 = p.then(() => Promise.resolve("1"), undefined); +>p70 : Promise +>p.then(() => Promise.resolve("1"), undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>undefined : undefined + +const p71 = p.then(() => Promise.resolve("1"), () => 1); +>p71 : Promise +>p.then(() => Promise.resolve("1"), () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => 1 : () => number +>1 : number + +const p72 = p.then(() => Promise.resolve("1"), () => {}); +>p72 : Promise +>p.then(() => Promise.resolve("1"), () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => {} : () => void + +const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); +>p73 : Promise +>p.then(() => Promise.resolve("1"), () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => {throw 1} : () => never +>1 : number + +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +>p74 : Promise +>p.then(() => Promise.resolve("1"), () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +>p75 : Promise +>p.then(() => Promise.resolve("1"), () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p80 = p.then(() => Promise.reject(1), undefined); +>p80 : Promise +>p.then(() => Promise.reject(1), undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>undefined : undefined + +const p81 = p.then(() => Promise.reject(1), () => 1); +>p81 : Promise +>p.then(() => Promise.reject(1), () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => 1 : () => number +>1 : number + +const p82 = p.then(() => Promise.reject(1), () => {}); +>p82 : Promise +>p.then(() => Promise.reject(1), () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => {} : () => void + +const p83 = p.then(() => Promise.reject(1), () => {throw 1}); +>p83 : Promise +>p.then(() => Promise.reject(1), () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => {throw 1} : () => never +>1 : number + +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +>p84 : Promise +>p.then(() => Promise.reject(1), () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); +>p85 : Promise +>p.then(() => Promise.reject(1), () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + diff --git a/tests/baselines/reference/promiseTypeStrictNull.js b/tests/baselines/reference/promiseTypeStrictNull.js new file mode 100644 index 00000000000..cba4f7735ce --- /dev/null +++ b/tests/baselines/reference/promiseTypeStrictNull.js @@ -0,0 +1,316 @@ +//// [promiseTypeStrictNull.ts] +declare var p: Promise; + +const a = p.then(); +const b = p.then(b => 1); +const c = p.then(b => 1, e => 'error'); +const d = p.then(b => 1, e => { }); +const e = p.then(b => 1, e => { throw Error(); }); +const f = p.then(b => 1, e => Promise.reject(Error())); +const g = p.catch(e => 'error'); +const h = p.catch(e => { }); +const i = p.catch(e => { throw Error(); }); +const j = p.catch(e => Promise.reject(Error())); + +async function A() { + const a = await p; + return a; +} + +async function B() { + const a = await p; + return 1; +} + +// NOTE: This reports a "No best comment type exists among return expressions." error, and is +// ignored to get the types result for the test. +// async function C() { +// try { +// const a = await p; +// return 1; +// } +// catch (e) { +// return 'error'; +// } +// } + +async function D() { + try { + const a = await p; + return 1; + } + catch (e) { + } +} + +async function E() { + try { + const a = await p; + return 1; + } + catch (e) { + throw Error(); + } +} + +async function F() { + try { + const a = await p; + return 1; + } + catch (e) { + return Promise.reject(Error()); + } +} + +async function G() { + try { + const a = await p; + return a; + } + catch (e) { + return; + } +} + +async function H() { + try { + const a = await p; + return a; + } + catch (e) { + throw Error(); + } +} + +async function I() { + try { + const a = await p; + return a; + } + catch (e) { + return Promise.reject(Error()); + } +} + +// addresses github issue #4903: + +const p00 = p.catch(); +const p01 = p.catch(undefined); +const p07 = p.catch(null); +const p02 = p.catch(() => 1); +const p03 = p.catch(() => {}); +const p04 = p.catch(() => {throw 1}); +const p05 = p.catch(() => Promise.reject(1)); +const p06 = p.catch(() => Promise.resolve(1)); + +const p10 = p.then(); + +const p20 = p.then(undefined); +const p21 = p.then(() => 1); +const p22 = p.then(() => {}); +const p23 = p.then(() => {throw 1}); +const p24 = p.then(() => Promise.resolve(1)); +const p25 = p.then(() => Promise.reject(1)); + +const p30 = p.then(undefined, undefined); +const p31 = p.then(undefined, () => 1); +const p32 = p.then(undefined, () => {}); +const p33 = p.then(undefined, () => {throw 1}); +const p34 = p.then(undefined, () => Promise.resolve(1)); +const p35 = p.then(undefined, () => Promise.reject(1)); + +const p40 = p.then(() => "1", undefined); +const p41 = p.then(() => "1", () => 1); +const p42 = p.then(() => "1", () => {}); +const p43 = p.then(() => "1", () => {throw 1}); +const p44 = p.then(() => "1", () => Promise.resolve(1)); +const p45 = p.then(() => "1", () => Promise.reject(1)); + +const p50 = p.then(() => {}, undefined); +const p51 = p.then(() => {}, () => 1); +const p52 = p.then(() => {}, () => {}); +const p53 = p.then(() => {}, () => {throw 1}); +const p54 = p.then(() => {}, () => Promise.resolve(1)); +const p55 = p.then(() => {}, () => Promise.reject(1)); + +const p60 = p.then(() => {throw 1}, undefined); +const p61 = p.then(() => {throw 1}, () => 1); +const p62 = p.then(() => {throw 1}, () => {}); +const p63 = p.then(() => {throw 1}, () => {throw 1}); +const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); +const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); + +const p70 = p.then(() => Promise.resolve("1"), undefined); +const p71 = p.then(() => Promise.resolve("1"), () => 1); +const p72 = p.then(() => Promise.resolve("1"), () => {}); +const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); + +const p80 = p.then(() => Promise.reject(1), undefined); +const p81 = p.then(() => Promise.reject(1), () => 1); +const p82 = p.then(() => Promise.reject(1), () => {}); +const p83 = p.then(() => Promise.reject(1), () => {throw 1}); +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); + +//// [promiseTypeStrictNull.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +const a = p.then(); +const b = p.then(b => 1); +const c = p.then(b => 1, e => 'error'); +const d = p.then(b => 1, e => { }); +const e = p.then(b => 1, e => { throw Error(); }); +const f = p.then(b => 1, e => Promise.reject(Error())); +const g = p.catch(e => 'error'); +const h = p.catch(e => { }); +const i = p.catch(e => { throw Error(); }); +const j = p.catch(e => Promise.reject(Error())); +function A() { + return __awaiter(this, void 0, void 0, function* () { + const a = yield p; + return a; + }); +} +function B() { + return __awaiter(this, void 0, void 0, function* () { + const a = yield p; + return 1; + }); +} +// NOTE: This reports a "No best comment type exists among return expressions." error, and is +// ignored to get the types result for the test. +// async function C() { +// try { +// const a = await p; +// return 1; +// } +// catch (e) { +// return 'error'; +// } +// } +function D() { + return __awaiter(this, void 0, void 0, function* () { + try { + const a = yield p; + return 1; + } + catch (e) { + } + }); +} +function E() { + return __awaiter(this, void 0, void 0, function* () { + try { + const a = yield p; + return 1; + } + catch (e) { + throw Error(); + } + }); +} +function F() { + return __awaiter(this, void 0, void 0, function* () { + try { + const a = yield p; + return 1; + } + catch (e) { + return Promise.reject(Error()); + } + }); +} +function G() { + return __awaiter(this, void 0, void 0, function* () { + try { + const a = yield p; + return a; + } + catch (e) { + return; + } + }); +} +function H() { + return __awaiter(this, void 0, void 0, function* () { + try { + const a = yield p; + return a; + } + catch (e) { + throw Error(); + } + }); +} +function I() { + return __awaiter(this, void 0, void 0, function* () { + try { + const a = yield p; + return a; + } + catch (e) { + return Promise.reject(Error()); + } + }); +} +// addresses github issue #4903: +const p00 = p.catch(); +const p01 = p.catch(undefined); +const p07 = p.catch(null); +const p02 = p.catch(() => 1); +const p03 = p.catch(() => { }); +const p04 = p.catch(() => { throw 1; }); +const p05 = p.catch(() => Promise.reject(1)); +const p06 = p.catch(() => Promise.resolve(1)); +const p10 = p.then(); +const p20 = p.then(undefined); +const p21 = p.then(() => 1); +const p22 = p.then(() => { }); +const p23 = p.then(() => { throw 1; }); +const p24 = p.then(() => Promise.resolve(1)); +const p25 = p.then(() => Promise.reject(1)); +const p30 = p.then(undefined, undefined); +const p31 = p.then(undefined, () => 1); +const p32 = p.then(undefined, () => { }); +const p33 = p.then(undefined, () => { throw 1; }); +const p34 = p.then(undefined, () => Promise.resolve(1)); +const p35 = p.then(undefined, () => Promise.reject(1)); +const p40 = p.then(() => "1", undefined); +const p41 = p.then(() => "1", () => 1); +const p42 = p.then(() => "1", () => { }); +const p43 = p.then(() => "1", () => { throw 1; }); +const p44 = p.then(() => "1", () => Promise.resolve(1)); +const p45 = p.then(() => "1", () => Promise.reject(1)); +const p50 = p.then(() => { }, undefined); +const p51 = p.then(() => { }, () => 1); +const p52 = p.then(() => { }, () => { }); +const p53 = p.then(() => { }, () => { throw 1; }); +const p54 = p.then(() => { }, () => Promise.resolve(1)); +const p55 = p.then(() => { }, () => Promise.reject(1)); +const p60 = p.then(() => { throw 1; }, undefined); +const p61 = p.then(() => { throw 1; }, () => 1); +const p62 = p.then(() => { throw 1; }, () => { }); +const p63 = p.then(() => { throw 1; }, () => { throw 1; }); +const p64 = p.then(() => { throw 1; }, () => Promise.resolve(1)); +const p65 = p.then(() => { throw 1; }, () => Promise.reject(1)); +const p70 = p.then(() => Promise.resolve("1"), undefined); +const p71 = p.then(() => Promise.resolve("1"), () => 1); +const p72 = p.then(() => Promise.resolve("1"), () => { }); +const p73 = p.then(() => Promise.resolve("1"), () => { throw 1; }); +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +const p80 = p.then(() => Promise.reject(1), undefined); +const p81 = p.then(() => Promise.reject(1), () => 1); +const p82 = p.then(() => Promise.reject(1), () => { }); +const p83 = p.then(() => Promise.reject(1), () => { throw 1; }); +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); diff --git a/tests/baselines/reference/promiseTypeStrictNull.symbols b/tests/baselines/reference/promiseTypeStrictNull.symbols new file mode 100644 index 00000000000..56365baa678 --- /dev/null +++ b/tests/baselines/reference/promiseTypeStrictNull.symbols @@ -0,0 +1,640 @@ +=== tests/cases/compiler/promiseTypeStrictNull.ts === +declare var p: Promise; +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + +const a = p.then(); +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 2, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const b = p.then(b => 1); +>b : Symbol(b, Decl(promiseTypeStrictNull.ts, 3, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>b : Symbol(b, Decl(promiseTypeStrictNull.ts, 3, 17)) + +const c = p.then(b => 1, e => 'error'); +>c : Symbol(c, Decl(promiseTypeStrictNull.ts, 4, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>b : Symbol(b, Decl(promiseTypeStrictNull.ts, 4, 17)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 4, 24)) + +const d = p.then(b => 1, e => { }); +>d : Symbol(d, Decl(promiseTypeStrictNull.ts, 5, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>b : Symbol(b, Decl(promiseTypeStrictNull.ts, 5, 17)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 5, 24)) + +const e = p.then(b => 1, e => { throw Error(); }); +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 6, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>b : Symbol(b, Decl(promiseTypeStrictNull.ts, 6, 17)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 6, 24)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +const f = p.then(b => 1, e => Promise.reject(Error())); +>f : Symbol(f, Decl(promiseTypeStrictNull.ts, 7, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>b : Symbol(b, Decl(promiseTypeStrictNull.ts, 7, 17)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 7, 24)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +const g = p.catch(e => 'error'); +>g : Symbol(g, Decl(promiseTypeStrictNull.ts, 8, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 8, 18)) + +const h = p.catch(e => { }); +>h : Symbol(h, Decl(promiseTypeStrictNull.ts, 9, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 9, 18)) + +const i = p.catch(e => { throw Error(); }); +>i : Symbol(i, Decl(promiseTypeStrictNull.ts, 10, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 10, 18)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +const j = p.catch(e => Promise.reject(Error())); +>j : Symbol(j, Decl(promiseTypeStrictNull.ts, 11, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 11, 18)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + +async function A() { +>A : Symbol(A, Decl(promiseTypeStrictNull.ts, 11, 48)) + + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 14, 9)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return a; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 14, 9)) +} + +async function B() { +>B : Symbol(B, Decl(promiseTypeStrictNull.ts, 16, 1)) + + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 19, 9)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return 1; +} + +// NOTE: This reports a "No best comment type exists among return expressions." error, and is +// ignored to get the types result for the test. +// async function C() { +// try { +// const a = await p; +// return 1; +// } +// catch (e) { +// return 'error'; +// } +// } + +async function D() { +>D : Symbol(D, Decl(promiseTypeStrictNull.ts, 21, 1)) + + try { + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 37, 13)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return 1; + } + catch (e) { +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 40, 11)) + } +} + +async function E() { +>E : Symbol(E, Decl(promiseTypeStrictNull.ts, 42, 1)) + + try { + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 46, 13)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return 1; + } + catch (e) { +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 49, 11)) + + throw Error(); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +async function F() { +>F : Symbol(F, Decl(promiseTypeStrictNull.ts, 52, 1)) + + try { + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 56, 13)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return 1; + } + catch (e) { +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 59, 11)) + + return Promise.reject(Error()); +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +async function G() { +>G : Symbol(G, Decl(promiseTypeStrictNull.ts, 62, 1)) + + try { + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 66, 13)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return a; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 66, 13)) + } + catch (e) { +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 69, 11)) + + return; + } +} + +async function H() { +>H : Symbol(H, Decl(promiseTypeStrictNull.ts, 72, 1)) + + try { + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 76, 13)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return a; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 76, 13)) + } + catch (e) { +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 79, 11)) + + throw Error(); +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +async function I() { +>I : Symbol(I, Decl(promiseTypeStrictNull.ts, 82, 1)) + + try { + const a = await p; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 86, 13)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) + + return a; +>a : Symbol(a, Decl(promiseTypeStrictNull.ts, 86, 13)) + } + catch (e) { +>e : Symbol(e, Decl(promiseTypeStrictNull.ts, 89, 11)) + + return Promise.reject(Error()); +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) + } +} + +// addresses github issue #4903: + +const p00 = p.catch(); +>p00 : Symbol(p00, Decl(promiseTypeStrictNull.ts, 96, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p01 = p.catch(undefined); +>p01 : Symbol(p01, Decl(promiseTypeStrictNull.ts, 97, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p07 = p.catch(null); +>p07 : Symbol(p07, Decl(promiseTypeStrictNull.ts, 98, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p02 = p.catch(() => 1); +>p02 : Symbol(p02, Decl(promiseTypeStrictNull.ts, 99, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p03 = p.catch(() => {}); +>p03 : Symbol(p03, Decl(promiseTypeStrictNull.ts, 100, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p04 = p.catch(() => {throw 1}); +>p04 : Symbol(p04, Decl(promiseTypeStrictNull.ts, 101, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p05 = p.catch(() => Promise.reject(1)); +>p05 : Symbol(p05, Decl(promiseTypeStrictNull.ts, 102, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p06 = p.catch(() => Promise.resolve(1)); +>p06 : Symbol(p06, Decl(promiseTypeStrictNull.ts, 103, 5)) +>p.catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>catch : Symbol(Promise.catch, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p10 = p.then(); +>p10 : Symbol(p10, Decl(promiseTypeStrictNull.ts, 105, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p20 = p.then(undefined); +>p20 : Symbol(p20, Decl(promiseTypeStrictNull.ts, 107, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p21 = p.then(() => 1); +>p21 : Symbol(p21, Decl(promiseTypeStrictNull.ts, 108, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p22 = p.then(() => {}); +>p22 : Symbol(p22, Decl(promiseTypeStrictNull.ts, 109, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p23 = p.then(() => {throw 1}); +>p23 : Symbol(p23, Decl(promiseTypeStrictNull.ts, 110, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p24 = p.then(() => Promise.resolve(1)); +>p24 : Symbol(p24, Decl(promiseTypeStrictNull.ts, 111, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p25 = p.then(() => Promise.reject(1)); +>p25 : Symbol(p25, Decl(promiseTypeStrictNull.ts, 112, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p30 = p.then(undefined, undefined); +>p30 : Symbol(p30, Decl(promiseTypeStrictNull.ts, 114, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) +>undefined : Symbol(undefined) + +const p31 = p.then(undefined, () => 1); +>p31 : Symbol(p31, Decl(promiseTypeStrictNull.ts, 115, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p32 = p.then(undefined, () => {}); +>p32 : Symbol(p32, Decl(promiseTypeStrictNull.ts, 116, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p33 = p.then(undefined, () => {throw 1}); +>p33 : Symbol(p33, Decl(promiseTypeStrictNull.ts, 117, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p34 = p.then(undefined, () => Promise.resolve(1)); +>p34 : Symbol(p34, Decl(promiseTypeStrictNull.ts, 118, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p35 = p.then(undefined, () => Promise.reject(1)); +>p35 : Symbol(p35, Decl(promiseTypeStrictNull.ts, 119, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p40 = p.then(() => "1", undefined); +>p40 : Symbol(p40, Decl(promiseTypeStrictNull.ts, 121, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p41 = p.then(() => "1", () => 1); +>p41 : Symbol(p41, Decl(promiseTypeStrictNull.ts, 122, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p42 = p.then(() => "1", () => {}); +>p42 : Symbol(p42, Decl(promiseTypeStrictNull.ts, 123, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p43 = p.then(() => "1", () => {throw 1}); +>p43 : Symbol(p43, Decl(promiseTypeStrictNull.ts, 124, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p44 = p.then(() => "1", () => Promise.resolve(1)); +>p44 : Symbol(p44, Decl(promiseTypeStrictNull.ts, 125, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p45 = p.then(() => "1", () => Promise.reject(1)); +>p45 : Symbol(p45, Decl(promiseTypeStrictNull.ts, 126, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p50 = p.then(() => {}, undefined); +>p50 : Symbol(p50, Decl(promiseTypeStrictNull.ts, 128, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p51 = p.then(() => {}, () => 1); +>p51 : Symbol(p51, Decl(promiseTypeStrictNull.ts, 129, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p52 = p.then(() => {}, () => {}); +>p52 : Symbol(p52, Decl(promiseTypeStrictNull.ts, 130, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p53 = p.then(() => {}, () => {throw 1}); +>p53 : Symbol(p53, Decl(promiseTypeStrictNull.ts, 131, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p54 = p.then(() => {}, () => Promise.resolve(1)); +>p54 : Symbol(p54, Decl(promiseTypeStrictNull.ts, 132, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p55 = p.then(() => {}, () => Promise.reject(1)); +>p55 : Symbol(p55, Decl(promiseTypeStrictNull.ts, 133, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p60 = p.then(() => {throw 1}, undefined); +>p60 : Symbol(p60, Decl(promiseTypeStrictNull.ts, 135, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p61 = p.then(() => {throw 1}, () => 1); +>p61 : Symbol(p61, Decl(promiseTypeStrictNull.ts, 136, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p62 = p.then(() => {throw 1}, () => {}); +>p62 : Symbol(p62, Decl(promiseTypeStrictNull.ts, 137, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p63 = p.then(() => {throw 1}, () => {throw 1}); +>p63 : Symbol(p63, Decl(promiseTypeStrictNull.ts, 138, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); +>p64 : Symbol(p64, Decl(promiseTypeStrictNull.ts, 139, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); +>p65 : Symbol(p65, Decl(promiseTypeStrictNull.ts, 140, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p70 = p.then(() => Promise.resolve("1"), undefined); +>p70 : Symbol(p70, Decl(promiseTypeStrictNull.ts, 142, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p71 = p.then(() => Promise.resolve("1"), () => 1); +>p71 : Symbol(p71, Decl(promiseTypeStrictNull.ts, 143, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p72 = p.then(() => Promise.resolve("1"), () => {}); +>p72 : Symbol(p72, Decl(promiseTypeStrictNull.ts, 144, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); +>p73 : Symbol(p73, Decl(promiseTypeStrictNull.ts, 145, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +>p74 : Symbol(p74, Decl(promiseTypeStrictNull.ts, 146, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +>p75 : Symbol(p75, Decl(promiseTypeStrictNull.ts, 147, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p80 = p.then(() => Promise.reject(1), undefined); +>p80 : Symbol(p80, Decl(promiseTypeStrictNull.ts, 149, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>undefined : Symbol(undefined) + +const p81 = p.then(() => Promise.reject(1), () => 1); +>p81 : Symbol(p81, Decl(promiseTypeStrictNull.ts, 150, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p82 = p.then(() => Promise.reject(1), () => {}); +>p82 : Symbol(p82, Decl(promiseTypeStrictNull.ts, 151, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p83 = p.then(() => Promise.reject(1), () => {throw 1}); +>p83 : Symbol(p83, Decl(promiseTypeStrictNull.ts, 152, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +>p84 : Symbol(p84, Decl(promiseTypeStrictNull.ts, 153, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>resolve : Symbol(PromiseConstructor.resolve, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); +>p85 : Symbol(p85, Decl(promiseTypeStrictNull.ts, 154, 5)) +>p.then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>p : Symbol(p, Decl(promiseTypeStrictNull.ts, 0, 11)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise.reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) +>reject : Symbol(PromiseConstructor.reject, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) + diff --git a/tests/baselines/reference/promiseTypeStrictNull.types b/tests/baselines/reference/promiseTypeStrictNull.types new file mode 100644 index 00000000000..41086d00363 --- /dev/null +++ b/tests/baselines/reference/promiseTypeStrictNull.types @@ -0,0 +1,900 @@ +=== tests/cases/compiler/promiseTypeStrictNull.ts === +declare var p: Promise; +>p : Promise +>Promise : Promise + +const a = p.then(); +>a : Promise +>p.then() : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } + +const b = p.then(b => 1); +>b : Promise +>p.then(b => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>b => 1 : (b: boolean) => number +>b : boolean +>1 : number + +const c = p.then(b => 1, e => 'error'); +>c : Promise +>p.then(b => 1, e => 'error') : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>b => 1 : (b: boolean) => number +>b : boolean +>1 : number +>e => 'error' : (e: any) => string +>e : any +>'error' : string + +const d = p.then(b => 1, e => { }); +>d : Promise +>p.then(b => 1, e => { }) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>b => 1 : (b: boolean) => number +>b : boolean +>1 : number +>e => { } : (e: any) => void +>e : any + +const e = p.then(b => 1, e => { throw Error(); }); +>e : Promise +>p.then(b => 1, e => { throw Error(); }) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>b => 1 : (b: boolean) => number +>b : boolean +>1 : number +>e => { throw Error(); } : (e: any) => never +>e : any +>Error() : Error +>Error : ErrorConstructor + +const f = p.then(b => 1, e => Promise.reject(Error())); +>f : Promise +>p.then(b => 1, e => Promise.reject(Error())) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>b => 1 : (b: boolean) => number +>b : boolean +>1 : number +>e => Promise.reject(Error()) : (e: any) => Promise +>e : any +>Promise.reject(Error()) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>Error() : Error +>Error : ErrorConstructor + +const g = p.catch(e => 'error'); +>g : Promise +>p.catch(e => 'error') : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>e => 'error' : (e: any) => string +>e : any +>'error' : string + +const h = p.catch(e => { }); +>h : Promise +>p.catch(e => { }) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>e => { } : (e: any) => void +>e : any + +const i = p.catch(e => { throw Error(); }); +>i : Promise +>p.catch(e => { throw Error(); }) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>e => { throw Error(); } : (e: any) => never +>e : any +>Error() : Error +>Error : ErrorConstructor + +const j = p.catch(e => Promise.reject(Error())); +>j : Promise +>p.catch(e => Promise.reject(Error())) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>e => Promise.reject(Error()) : (e: any) => Promise +>e : any +>Promise.reject(Error()) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>Error() : Error +>Error : ErrorConstructor + +async function A() { +>A : () => Promise + + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return a; +>a : boolean +} + +async function B() { +>B : () => Promise + + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return 1; +>1 : number +} + +// NOTE: This reports a "No best comment type exists among return expressions." error, and is +// ignored to get the types result for the test. +// async function C() { +// try { +// const a = await p; +// return 1; +// } +// catch (e) { +// return 'error'; +// } +// } + +async function D() { +>D : () => Promise + + try { + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return 1; +>1 : number + } + catch (e) { +>e : any + } +} + +async function E() { +>E : () => Promise + + try { + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return 1; +>1 : number + } + catch (e) { +>e : any + + throw Error(); +>Error() : Error +>Error : ErrorConstructor + } +} + +async function F() { +>F : () => Promise + + try { + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return 1; +>1 : number + } + catch (e) { +>e : any + + return Promise.reject(Error()); +>Promise.reject(Error()) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>Error() : Error +>Error : ErrorConstructor + } +} + +async function G() { +>G : () => Promise + + try { + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return a; +>a : boolean + } + catch (e) { +>e : any + + return; + } +} + +async function H() { +>H : () => Promise + + try { + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return a; +>a : boolean + } + catch (e) { +>e : any + + throw Error(); +>Error() : Error +>Error : ErrorConstructor + } +} + +async function I() { +>I : () => Promise + + try { + const a = await p; +>a : boolean +>await p : boolean +>p : Promise + + return a; +>a : boolean + } + catch (e) { +>e : any + + return Promise.reject(Error()); +>Promise.reject(Error()) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>Error() : Error +>Error : ErrorConstructor + } +} + +// addresses github issue #4903: + +const p00 = p.catch(); +>p00 : Promise +>p.catch() : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } + +const p01 = p.catch(undefined); +>p01 : Promise +>p.catch(undefined) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>undefined : undefined + +const p07 = p.catch(null); +>p07 : Promise +>p.catch(null) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>null : null + +const p02 = p.catch(() => 1); +>p02 : Promise +>p.catch(() => 1) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => 1 : () => number +>1 : number + +const p03 = p.catch(() => {}); +>p03 : Promise +>p.catch(() => {}) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => {} : () => void + +const p04 = p.catch(() => {throw 1}); +>p04 : Promise +>p.catch(() => {throw 1}) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number + +const p05 = p.catch(() => Promise.reject(1)); +>p05 : Promise +>p.catch(() => Promise.reject(1)) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p06 = p.catch(() => Promise.resolve(1)); +>p06 : Promise +>p.catch(() => Promise.resolve(1)) : Promise +>p.catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>p : Promise +>catch : { (): Promise; (onrejected: null | undefined): Promise; (onrejected: (reason: any) => TResult | PromiseLike): Promise; } +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p10 = p.then(); +>p10 : Promise +>p.then() : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } + +const p20 = p.then(undefined); +>p20 : Promise +>p.then(undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined + +const p21 = p.then(() => 1); +>p21 : Promise +>p.then(() => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => 1 : () => number +>1 : number + +const p22 = p.then(() => {}); +>p22 : Promise +>p.then(() => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void + +const p23 = p.then(() => {throw 1}); +>p23 : Promise +>p.then(() => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number + +const p24 = p.then(() => Promise.resolve(1)); +>p24 : Promise +>p.then(() => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p25 = p.then(() => Promise.reject(1)); +>p25 : Promise +>p.then(() => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p30 = p.then(undefined, undefined); +>p30 : Promise +>p.then(undefined, undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>undefined : undefined + +const p31 = p.then(undefined, () => 1); +>p31 : Promise +>p.then(undefined, () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => 1 : () => number +>1 : number + +const p32 = p.then(undefined, () => {}); +>p32 : Promise +>p.then(undefined, () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => {} : () => void + +const p33 = p.then(undefined, () => {throw 1}); +>p33 : Promise +>p.then(undefined, () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => {throw 1} : () => never +>1 : number + +const p34 = p.then(undefined, () => Promise.resolve(1)); +>p34 : Promise +>p.then(undefined, () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p35 = p.then(undefined, () => Promise.reject(1)); +>p35 : Promise +>p.then(undefined, () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>undefined : undefined +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p40 = p.then(() => "1", undefined); +>p40 : Promise +>p.then(() => "1", undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>undefined : undefined + +const p41 = p.then(() => "1", () => 1); +>p41 : Promise +>p.then(() => "1", () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => 1 : () => number +>1 : number + +const p42 = p.then(() => "1", () => {}); +>p42 : Promise +>p.then(() => "1", () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => {} : () => void + +const p43 = p.then(() => "1", () => {throw 1}); +>p43 : Promise +>p.then(() => "1", () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => {throw 1} : () => never +>1 : number + +const p44 = p.then(() => "1", () => Promise.resolve(1)); +>p44 : Promise +>p.then(() => "1", () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p45 = p.then(() => "1", () => Promise.reject(1)); +>p45 : Promise +>p.then(() => "1", () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => "1" : () => string +>"1" : string +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p50 = p.then(() => {}, undefined); +>p50 : Promise +>p.then(() => {}, undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>undefined : undefined + +const p51 = p.then(() => {}, () => 1); +>p51 : Promise +>p.then(() => {}, () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => 1 : () => number +>1 : number + +const p52 = p.then(() => {}, () => {}); +>p52 : Promise +>p.then(() => {}, () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => {} : () => void + +const p53 = p.then(() => {}, () => {throw 1}); +>p53 : Promise +>p.then(() => {}, () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => {throw 1} : () => never +>1 : number + +const p54 = p.then(() => {}, () => Promise.resolve(1)); +>p54 : Promise +>p.then(() => {}, () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p55 = p.then(() => {}, () => Promise.reject(1)); +>p55 : Promise +>p.then(() => {}, () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {} : () => void +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p60 = p.then(() => {throw 1}, undefined); +>p60 : Promise +>p.then(() => {throw 1}, undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>undefined : undefined + +const p61 = p.then(() => {throw 1}, () => 1); +>p61 : Promise +>p.then(() => {throw 1}, () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => 1 : () => number +>1 : number + +const p62 = p.then(() => {throw 1}, () => {}); +>p62 : Promise +>p.then(() => {throw 1}, () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => {} : () => void + +const p63 = p.then(() => {throw 1}, () => {throw 1}); +>p63 : Promise +>p.then(() => {throw 1}, () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => {throw 1} : () => never +>1 : number + +const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); +>p64 : Promise +>p.then(() => {throw 1}, () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); +>p65 : Promise +>p.then(() => {throw 1}, () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => {throw 1} : () => never +>1 : number +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p70 = p.then(() => Promise.resolve("1"), undefined); +>p70 : Promise +>p.then(() => Promise.resolve("1"), undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>undefined : undefined + +const p71 = p.then(() => Promise.resolve("1"), () => 1); +>p71 : Promise +>p.then(() => Promise.resolve("1"), () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => 1 : () => number +>1 : number + +const p72 = p.then(() => Promise.resolve("1"), () => {}); +>p72 : Promise +>p.then(() => Promise.resolve("1"), () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => {} : () => void + +const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); +>p73 : Promise +>p.then(() => Promise.resolve("1"), () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => {throw 1} : () => never +>1 : number + +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +>p74 : Promise +>p.then(() => Promise.resolve("1"), () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); +>p75 : Promise +>p.then(() => Promise.resolve("1"), () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.resolve("1") : () => Promise +>Promise.resolve("1") : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>"1" : string +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + +const p80 = p.then(() => Promise.reject(1), undefined); +>p80 : Promise +>p.then(() => Promise.reject(1), undefined) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>undefined : undefined + +const p81 = p.then(() => Promise.reject(1), () => 1); +>p81 : Promise +>p.then(() => Promise.reject(1), () => 1) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => 1 : () => number +>1 : number + +const p82 = p.then(() => Promise.reject(1), () => {}); +>p82 : Promise +>p.then(() => Promise.reject(1), () => {}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => {} : () => void + +const p83 = p.then(() => Promise.reject(1), () => {throw 1}); +>p83 : Promise +>p.then(() => Promise.reject(1), () => {throw 1}) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => {throw 1} : () => never +>1 : number + +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +>p84 : Promise +>p.then(() => Promise.reject(1), () => Promise.resolve(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => Promise.resolve(1) : () => Promise +>Promise.resolve(1) : Promise +>Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>Promise : PromiseConstructor +>resolve : { (value: T | PromiseLike): Promise; (): Promise; } +>1 : number + +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); +>p85 : Promise +>p.then(() => Promise.reject(1), () => Promise.reject(1)) : Promise +>p.then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>p : Promise +>then : { (): Promise; (onfulfilled: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (onfulfilled: null | undefined, onrejected: null | undefined): Promise; (onfulfilled: null | undefined, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: null | undefined): Promise; (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number +>() => Promise.reject(1) : () => Promise +>Promise.reject(1) : Promise +>Promise.reject : { (reason: any): Promise; (reason: any): Promise; } +>Promise : PromiseConstructor +>reject : { (reason: any): Promise; (reason: any): Promise; } +>1 : number + diff --git a/tests/baselines/reference/promiseVoidErrorCallback.symbols b/tests/baselines/reference/promiseVoidErrorCallback.symbols index 67747f5f150..97b78b654ed 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.symbols +++ b/tests/baselines/reference/promiseVoidErrorCallback.symbols @@ -47,12 +47,12 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Symbol(x3, Decl(promiseVoidErrorCallback.ts, 20, 3)) ->f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) ->f1() .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>f1() .then(f2, (e: Error) => { throw e;}) .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>f1() .then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >f1 : Symbol(f1, Decl(promiseVoidErrorCallback.ts, 10, 1)) .then(f2, (e: Error) => { ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >f2 : Symbol(f2, Decl(promiseVoidErrorCallback.ts, 14, 1)) >e : Symbol(e, Decl(promiseVoidErrorCallback.ts, 21, 15)) >Error : Symbol(Error, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) @@ -62,7 +62,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) +>then : Symbol(Promise.then, Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --)) >x : Symbol(x, Decl(promiseVoidErrorCallback.ts, 24, 11)) >T2 : Symbol(T2, Decl(promiseVoidErrorCallback.ts, 2, 1)) diff --git a/tests/baselines/reference/promiseVoidErrorCallback.types b/tests/baselines/reference/promiseVoidErrorCallback.types index 94773394ade..a13c962d708 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.types +++ b/tests/baselines/reference/promiseVoidErrorCallback.types @@ -54,14 +54,14 @@ function f2(x: T1): T2 { var x3 = f1() >x3 : Promise<{ __t3: string; }> >f1() .then(f2, (e: Error) => { throw e;}) .then((x: T2) => { return { __t3: x.__t2 + "bar" };}) : Promise<{ __t3: string; }> ->f1() .then(f2, (e: Error) => { throw e;}) .then : { (onfulfilled: (value: T2) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike): Promise; (): Promise; } +>f1() .then(f2, (e: Error) => { throw e;}) .then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: T2) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >f1() .then(f2, (e: Error) => { throw e;}) : Promise ->f1() .then : { (onfulfilled: (value: T1) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike): Promise; (): Promise; } +>f1() .then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: T1) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >f1() : Promise >f1 : () => Promise .then(f2, (e: Error) => { ->then : { (onfulfilled: (value: T1) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T1) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: T1) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >f2 : (x: T1) => T2 >(e: Error) => { throw e;} : (e: Error) => never >e : Error @@ -72,7 +72,7 @@ var x3 = f1() }) .then((x: T2) => { ->then : { (onfulfilled: (value: T2) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike): Promise; (): Promise; } +>then : { (): Promise; (onfulfilled: null): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike): Promise; (onfulfilled: null, onrejected: null): Promise; (onfulfilled: null, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: T2) => TResult | PromiseLike, onrejected: null): Promise; (onfulfilled: (value: T2) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; } >(x: T2) => { return { __t3: x.__t2 + "bar" };} : (x: T2) => { __t3: string; } >x : T2 >T2 : T2 diff --git a/tests/cases/compiler/promiseType.ts b/tests/cases/compiler/promiseType.ts index c1b795b6cc7..b105485b244 100644 --- a/tests/cases/compiler/promiseType.ts +++ b/tests/cases/compiler/promiseType.ts @@ -91,4 +91,66 @@ async function I() { catch (e) { return Promise.reject(Error()); } -} \ No newline at end of file +} + +// addresses github issue #4903: + +const p00 = p.catch(); +const p01 = p.catch(undefined); +const p07 = p.catch(null); +const p02 = p.catch(() => 1); +const p03 = p.catch(() => {}); +const p04 = p.catch(() => {throw 1}); +const p05 = p.catch(() => Promise.reject(1)); +const p06 = p.catch(() => Promise.resolve(1)); + +const p10 = p.then(); + +const p20 = p.then(undefined); +const p21 = p.then(() => 1); +const p22 = p.then(() => {}); +const p23 = p.then(() => {throw 1}); +const p24 = p.then(() => Promise.resolve(1)); +const p25 = p.then(() => Promise.reject(1)); + +const p30 = p.then(undefined, undefined); +const p31 = p.then(undefined, () => 1); +const p32 = p.then(undefined, () => {}); +const p33 = p.then(undefined, () => {throw 1}); +const p34 = p.then(undefined, () => Promise.resolve(1)); +const p35 = p.then(undefined, () => Promise.reject(1)); + +const p40 = p.then(() => "1", undefined); +const p41 = p.then(() => "1", () => 1); +const p42 = p.then(() => "1", () => {}); +const p43 = p.then(() => "1", () => {throw 1}); +const p44 = p.then(() => "1", () => Promise.resolve(1)); +const p45 = p.then(() => "1", () => Promise.reject(1)); + +const p50 = p.then(() => {}, undefined); +const p51 = p.then(() => {}, () => 1); +const p52 = p.then(() => {}, () => {}); +const p53 = p.then(() => {}, () => {throw 1}); +const p54 = p.then(() => {}, () => Promise.resolve(1)); +const p55 = p.then(() => {}, () => Promise.reject(1)); + +const p60 = p.then(() => {throw 1}, undefined); +const p61 = p.then(() => {throw 1}, () => 1); +const p62 = p.then(() => {throw 1}, () => {}); +const p63 = p.then(() => {throw 1}, () => {throw 1}); +const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); +const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); + +const p70 = p.then(() => Promise.resolve("1"), undefined); +const p71 = p.then(() => Promise.resolve("1"), () => 1); +const p72 = p.then(() => Promise.resolve("1"), () => {}); +const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); + +const p80 = p.then(() => Promise.reject(1), undefined); +const p81 = p.then(() => Promise.reject(1), () => 1); +const p82 = p.then(() => Promise.reject(1), () => {}); +const p83 = p.then(() => Promise.reject(1), () => {throw 1}); +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); \ No newline at end of file diff --git a/tests/cases/compiler/promiseTypeStrictNull.ts b/tests/cases/compiler/promiseTypeStrictNull.ts new file mode 100644 index 00000000000..ce6dcd36461 --- /dev/null +++ b/tests/cases/compiler/promiseTypeStrictNull.ts @@ -0,0 +1,157 @@ +// @target: es6 +// @strictNullChecks: true +declare var p: Promise; + +const a = p.then(); +const b = p.then(b => 1); +const c = p.then(b => 1, e => 'error'); +const d = p.then(b => 1, e => { }); +const e = p.then(b => 1, e => { throw Error(); }); +const f = p.then(b => 1, e => Promise.reject(Error())); +const g = p.catch(e => 'error'); +const h = p.catch(e => { }); +const i = p.catch(e => { throw Error(); }); +const j = p.catch(e => Promise.reject(Error())); + +async function A() { + const a = await p; + return a; +} + +async function B() { + const a = await p; + return 1; +} + +// NOTE: This reports a "No best comment type exists among return expressions." error, and is +// ignored to get the types result for the test. +// async function C() { +// try { +// const a = await p; +// return 1; +// } +// catch (e) { +// return 'error'; +// } +// } + +async function D() { + try { + const a = await p; + return 1; + } + catch (e) { + } +} + +async function E() { + try { + const a = await p; + return 1; + } + catch (e) { + throw Error(); + } +} + +async function F() { + try { + const a = await p; + return 1; + } + catch (e) { + return Promise.reject(Error()); + } +} + +async function G() { + try { + const a = await p; + return a; + } + catch (e) { + return; + } +} + +async function H() { + try { + const a = await p; + return a; + } + catch (e) { + throw Error(); + } +} + +async function I() { + try { + const a = await p; + return a; + } + catch (e) { + return Promise.reject(Error()); + } +} + +// addresses github issue #4903: + +const p00 = p.catch(); +const p01 = p.catch(undefined); +const p07 = p.catch(null); +const p02 = p.catch(() => 1); +const p03 = p.catch(() => {}); +const p04 = p.catch(() => {throw 1}); +const p05 = p.catch(() => Promise.reject(1)); +const p06 = p.catch(() => Promise.resolve(1)); + +const p10 = p.then(); + +const p20 = p.then(undefined); +const p21 = p.then(() => 1); +const p22 = p.then(() => {}); +const p23 = p.then(() => {throw 1}); +const p24 = p.then(() => Promise.resolve(1)); +const p25 = p.then(() => Promise.reject(1)); + +const p30 = p.then(undefined, undefined); +const p31 = p.then(undefined, () => 1); +const p32 = p.then(undefined, () => {}); +const p33 = p.then(undefined, () => {throw 1}); +const p34 = p.then(undefined, () => Promise.resolve(1)); +const p35 = p.then(undefined, () => Promise.reject(1)); + +const p40 = p.then(() => "1", undefined); +const p41 = p.then(() => "1", () => 1); +const p42 = p.then(() => "1", () => {}); +const p43 = p.then(() => "1", () => {throw 1}); +const p44 = p.then(() => "1", () => Promise.resolve(1)); +const p45 = p.then(() => "1", () => Promise.reject(1)); + +const p50 = p.then(() => {}, undefined); +const p51 = p.then(() => {}, () => 1); +const p52 = p.then(() => {}, () => {}); +const p53 = p.then(() => {}, () => {throw 1}); +const p54 = p.then(() => {}, () => Promise.resolve(1)); +const p55 = p.then(() => {}, () => Promise.reject(1)); + +const p60 = p.then(() => {throw 1}, undefined); +const p61 = p.then(() => {throw 1}, () => 1); +const p62 = p.then(() => {throw 1}, () => {}); +const p63 = p.then(() => {throw 1}, () => {throw 1}); +const p64 = p.then(() => {throw 1}, () => Promise.resolve(1)); +const p65 = p.then(() => {throw 1}, () => Promise.reject(1)); + +const p70 = p.then(() => Promise.resolve("1"), undefined); +const p71 = p.then(() => Promise.resolve("1"), () => 1); +const p72 = p.then(() => Promise.resolve("1"), () => {}); +const p73 = p.then(() => Promise.resolve("1"), () => {throw 1}); +const p74 = p.then(() => Promise.resolve("1"), () => Promise.resolve(1)); +const p75 = p.then(() => Promise.resolve("1"), () => Promise.reject(1)); + +const p80 = p.then(() => Promise.reject(1), undefined); +const p81 = p.then(() => Promise.reject(1), () => 1); +const p82 = p.then(() => Promise.reject(1), () => {}); +const p83 = p.then(() => Promise.reject(1), () => {throw 1}); +const p84 = p.then(() => Promise.reject(1), () => Promise.resolve(1)); +const p85 = p.then(() => Promise.reject(1), () => Promise.reject(1)); \ No newline at end of file From 0c01874b310e5fe677aa39b92fc50e81823080a5 Mon Sep 17 00:00:00 2001 From: Yuichi Nukiyama Date: Sat, 20 Aug 2016 21:24:46 +0900 Subject: [PATCH 216/508] follow advise --- src/compiler/checker.ts | 24 +++++++++++++------ .../reference/symbolType15.errors.txt | 4 +++- tests/cases/compiler/nativeToBoxedTypes.ts | 6 ++++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e279b07bb1f..279517bc1ec 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6258,13 +6258,6 @@ namespace ts { targetType = typeToString(target, /*enclosingDeclaration*/ undefined, TypeFormatFlags.UseFullyQualifiedType); } - // check if trying to relate primitives to the boxed/apparent backing types. - if ((sourceType === "Number" && targetType === "number") || - (sourceType === "String" && targetType === "string") || - (sourceType === "Boolean" && targetType === "boolean")) { - reportError(Diagnostics._0_is_a_primitive_type_while_1_is_a_boxed_object_Prefer_using_0_when_possible, targetType, sourceType); - } - if (!message) { message = relation === comparableRelation ? Diagnostics.Type_0_is_not_comparable_to_type_1 : @@ -6274,6 +6267,19 @@ namespace ts { reportError(message, sourceType, targetType); } + function tryElaborateErrorsForPrimitivesAndObjects(source: Type, target: Type) { + const sourceType = typeToString(source); + const targetType = typeToString(target); + + if ((globalStringType === source && stringType === target) || + (globalNumberType === source && numberType === target) || + (globalBooleanType === source && booleanType === target) || + (getGlobalESSymbolType() === source && esSymbolType === target)) { + console.log(source);console.log(target); + reportError(Diagnostics._0_is_a_primitive_type_while_1_is_a_boxed_object_Prefer_using_0_when_possible, targetType, sourceType); + } + } + // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -6396,6 +6402,10 @@ namespace ts { } } + if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) { + tryElaborateErrorsForPrimitivesAndObjects(source, target); + } + if (reportErrors) { reportRelationError(headMessage, source, target); } diff --git a/tests/baselines/reference/symbolType15.errors.txt b/tests/baselines/reference/symbolType15.errors.txt index eb63e5798d5..4a27ea24c59 100644 --- a/tests/baselines/reference/symbolType15.errors.txt +++ b/tests/baselines/reference/symbolType15.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/es6/Symbols/symbolType15.ts(5,1): error TS2322: Type 'Symbol' is not assignable to type 'symbol'. + 'symbol' is a primitive type while 'Symbol' is a boxed object. Prefer using 'symbol' when possible. ==== tests/cases/conformance/es6/Symbols/symbolType15.ts (1 errors) ==== @@ -8,4 +9,5 @@ tests/cases/conformance/es6/Symbols/symbolType15.ts(5,1): error TS2322: Type 'Sy symObj = sym; sym = symObj; ~~~ -!!! error TS2322: Type 'Symbol' is not assignable to type 'symbol'. \ No newline at end of file +!!! error TS2322: Type 'Symbol' is not assignable to type 'symbol'. +!!! error TS2322: 'symbol' is a primitive type while 'Symbol' is a boxed object. Prefer using 'symbol' when possible. \ No newline at end of file diff --git a/tests/cases/compiler/nativeToBoxedTypes.ts b/tests/cases/compiler/nativeToBoxedTypes.ts index 6cd51251b06..a34dd5cdd3b 100644 --- a/tests/cases/compiler/nativeToBoxedTypes.ts +++ b/tests/cases/compiler/nativeToBoxedTypes.ts @@ -8,4 +8,8 @@ s = S; var B = new Boolean(); var b = true; -b = B; \ No newline at end of file +b = B; + +var sym: symbol; +var Sym: Symbol; +sym = Sym; \ No newline at end of file From bc0c137a89ed8313655d7f77848a13554fa555a9 Mon Sep 17 00:00:00 2001 From: Yuichi Nukiyama Date: Sat, 20 Aug 2016 21:36:17 +0900 Subject: [PATCH 217/508] remove extra code --- src/compiler/checker.ts | 1 - .../baselines/reference/nativeToBoxedTypes.errors.txt | 11 +++++++++-- tests/baselines/reference/nativeToBoxedTypes.js | 9 ++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 279517bc1ec..7ff5b5b19ed 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6275,7 +6275,6 @@ namespace ts { (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || (getGlobalESSymbolType() === source && esSymbolType === target)) { - console.log(source);console.log(target); reportError(Diagnostics._0_is_a_primitive_type_while_1_is_a_boxed_object_Prefer_using_0_when_possible, targetType, sourceType); } } diff --git a/tests/baselines/reference/nativeToBoxedTypes.errors.txt b/tests/baselines/reference/nativeToBoxedTypes.errors.txt index c471e6b0e7b..255e0414fd9 100644 --- a/tests/baselines/reference/nativeToBoxedTypes.errors.txt +++ b/tests/baselines/reference/nativeToBoxedTypes.errors.txt @@ -4,9 +4,10 @@ tests/cases/compiler/nativeToBoxedTypes.ts(7,1): error TS2322: Type 'String' is 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. tests/cases/compiler/nativeToBoxedTypes.ts(11,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. +tests/cases/compiler/nativeToBoxedTypes.ts(14,10): error TS2304: Cannot find name 'Symbol'. -==== tests/cases/compiler/nativeToBoxedTypes.ts (3 errors) ==== +==== tests/cases/compiler/nativeToBoxedTypes.ts (4 errors) ==== var N = new Number(); var n = 100; n = N; @@ -26,4 +27,10 @@ tests/cases/compiler/nativeToBoxedTypes.ts(11,1): error TS2322: Type 'Boolean' i b = B; ~ !!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. -!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. \ No newline at end of file +!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. + + var sym: symbol; + var Sym: Symbol; + ~~~~~~ +!!! error TS2304: Cannot find name 'Symbol'. + sym = Sym; \ No newline at end of file diff --git a/tests/baselines/reference/nativeToBoxedTypes.js b/tests/baselines/reference/nativeToBoxedTypes.js index 074b39fa08d..db47c72fa10 100644 --- a/tests/baselines/reference/nativeToBoxedTypes.js +++ b/tests/baselines/reference/nativeToBoxedTypes.js @@ -9,7 +9,11 @@ s = S; var B = new Boolean(); var b = true; -b = B; +b = B; + +var sym: symbol; +var Sym: Symbol; +sym = Sym; //// [nativeToBoxedTypes.js] var N = new Number(); @@ -21,3 +25,6 @@ s = S; var B = new Boolean(); var b = true; b = B; +var sym; +var Sym; +sym = Sym; From f11fef6b4ced3b602f7b04971bbc08772e1791b8 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Sat, 20 Aug 2016 21:25:49 -0400 Subject: [PATCH 218/508] Update error code number --- src/compiler/diagnosticMessages.json | 4 +++ .../reference/assignments.errors.txt | 4 +-- ...assExtendsInterfaceInExpression.errors.txt | 4 +-- .../errorsOnImportedSymbol.errors.txt | 8 ++--- .../es6ExportEqualsInterop.errors.txt | 4 +-- ...ignmentOfDeclaredExternalModule.errors.txt | 8 ++--- ...onstructInvocationWithNoTypeArg.errors.txt | 4 +-- ...inheritFromGenericTypeParameter.errors.txt | 4 +-- .../reference/intTypeCheck.errors.txt | 32 +++++++++---------- .../interfaceNameAsIdentifier.errors.txt | 4 +-- .../reference/interfaceNaming1.errors.txt | 8 ++--- .../invalidUndefinedAssignments.errors.txt | 4 +-- ...singES6ArrayWithOnlyES6ArrayLib.errors.txt | 4 +-- .../reference/newOperator.errors.txt | 4 +-- .../reservedNamesInAliases.errors.txt | 4 +-- .../reference/returnTypeParameter.errors.txt | 4 +-- .../typeParameterAsBaseClass.errors.txt | 4 +-- .../typeParameterAsBaseType.errors.txt | 8 ++--- .../reference/typeUsedAsValueError.errors.txt | 20 ++++++------ .../typeUsedAsValueError2.errors.txt | 4 +-- .../reference/typeofSimple.errors.txt | 4 +-- .../reference/typeofTypeParameter.errors.txt | 4 +-- .../reference/validNullAssignments.errors.txt | 4 +-- 23 files changed, 78 insertions(+), 74 deletions(-) diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 6210a20afa6..7e2b429dd9f 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1955,6 +1955,10 @@ "category": "Error", "code": 2691 }, + "Cannot find name '{0}'. A type exists with this name, but no value.": { + "category": "Error", + "code": 2692 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/assignments.errors.txt b/tests/baselines/reference/assignments.errors.txt index 04a68499690..99457ed5837 100644 --- a/tests/baselines/reference/assignments.errors.txt +++ b/tests/baselines/reference/assignments.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): er tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value. ==== tests/cases/conformance/expressions/valuesAndReferences/assignments.ts (6 errors) ==== @@ -49,4 +49,4 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): er interface I { } I = null; // Error ~ -!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file +!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt b/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt index 084933bae6f..3bfaba31113 100644 --- a/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt +++ b/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2691: Cannot find name 'A'. A type exists with this name, but no value. +tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2692: Cannot find name 'A'. A type exists with this name, but no value. ==== tests/cases/compiler/classExtendsInterfaceInExpression.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2691: C class C extends factory(A) {} ~ -!!! error TS2691: Cannot find name 'A'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'A'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt index f64eb864445..960e707cfee 100644 --- a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt +++ b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/errorsOnImportedSymbol_1.ts(2,13): error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. -tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. +tests/cases/compiler/errorsOnImportedSymbol_1.ts(2,13): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. +tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. ==== tests/cases/compiler/errorsOnImportedSymbol_1.ts (2 errors) ==== import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); ~~~~~ -!!! error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. var y = Sammy.Sammy(); ~~~~~ -!!! error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. ==== tests/cases/compiler/errorsOnImportedSymbol_0.ts (0 errors) ==== diff --git a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt index 038449bff1f..e5ca006133b 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt +++ b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/main.ts(15,1): error TS2691: Cannot find name 'z1'. A type exists with this name, but no value. +tests/cases/compiler/main.ts(15,1): error TS2692: Cannot find name 'z1'. A type exists with this name, but no value. tests/cases/compiler/main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'. tests/cases/compiler/main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'. tests/cases/compiler/main.ts(27,8): error TS1192: Module '"interface"' has no default export. @@ -49,7 +49,7 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses z1.a; ~~ -!!! error TS2691: Cannot find name 'z1'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'z1'. A type exists with this name, but no value. z2.a; z3.a; z4.a; diff --git a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt index dc4c48e29ea..2d54bfd7e6d 100644 --- a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt +++ b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(3,13): error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. -tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. +tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(3,13): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. +tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. ==== tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error T import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol ~~~~~ -!!! error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. var y = Sammy(); // error to use interface name as call target ~~~~~ -!!! error TS2691: Cannot find name 'Sammy'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. var z: Sammy; // no error - z is of type interface Sammy from module 'M' var a = new z(); // constructor - no error var b = z(); // call signature - no error diff --git a/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt b/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt index 208a354619c..cef121150fb 100644 --- a/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt +++ b/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2691: Cannot find name 'Foo'. A type exists with this name, but no value. +tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2692: Cannot find name 'Foo'. A type exists with this name, but no value. ==== tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2 } var f2: Foo = new Foo(3); ~~~ -!!! error TS2691: Cannot find name 'Foo'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'Foo'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt index 0b958ddce21..86cbc3ac1d6 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface. ==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ==== class C extends T { } ~ -!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. interface I extends T { } ~ !!! error TS2312: An interface may only extend a class or another interface. \ No newline at end of file diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index 27ee53da1f8..3cd1997dc5a 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -10,7 +10,7 @@ tests/cases/compiler/intTypeCheck.ts(103,5): error TS2322: Type '() => void' is Property 'p' is missing in type '() => void'. tests/cases/compiler/intTypeCheck.ts(106,5): error TS2322: Type 'boolean' is not assignable to type 'i1'. tests/cases/compiler/intTypeCheck.ts(106,20): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(106,21): error TS2691: Cannot find name 'i1'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(106,21): error TS2692: Cannot find name 'i1'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(107,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(112,5): error TS2322: Type '{}' is not assignable to type 'i2'. Type '{}' provides no match for the signature '(): any' @@ -21,7 +21,7 @@ tests/cases/compiler/intTypeCheck.ts(115,5): error TS2322: Type 'Base' is not as Type 'Base' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(120,5): error TS2322: Type 'boolean' is not assignable to type 'i2'. tests/cases/compiler/intTypeCheck.ts(120,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(120,22): error TS2691: Cannot find name 'i2'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(120,22): error TS2692: Cannot find name 'i2'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(121,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(126,5): error TS2322: Type '{}' is not assignable to type 'i3'. Type '{}' provides no match for the signature 'new (): any' @@ -33,12 +33,12 @@ tests/cases/compiler/intTypeCheck.ts(131,5): error TS2322: Type '() => void' is Type '() => void' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not assignable to type 'i3'. tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(134,22): error TS2691: Cannot find name 'i3'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(134,22): error TS2692: Cannot find name 'i3'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'. tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(148,22): error TS2691: Cannot find name 'i4'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(148,22): error TS2692: Cannot find name 'i4'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(154,5): error TS2322: Type '{}' is not assignable to type 'i5'. Property 'p' is missing in type '{}'. @@ -51,7 +51,7 @@ tests/cases/compiler/intTypeCheck.ts(159,5): error TS2322: Type '() => void' is Property 'p' is missing in type '() => void'. tests/cases/compiler/intTypeCheck.ts(162,5): error TS2322: Type 'boolean' is not assignable to type 'i5'. tests/cases/compiler/intTypeCheck.ts(162,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(162,22): error TS2691: Cannot find name 'i5'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(162,22): error TS2692: Cannot find name 'i5'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(163,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(168,5): error TS2322: Type '{}' is not assignable to type 'i6'. Type '{}' provides no match for the signature '(): any' @@ -64,7 +64,7 @@ tests/cases/compiler/intTypeCheck.ts(173,5): error TS2322: Type '() => void' is Type 'void' is not assignable to type 'number'. tests/cases/compiler/intTypeCheck.ts(176,5): error TS2322: Type 'boolean' is not assignable to type 'i6'. tests/cases/compiler/intTypeCheck.ts(176,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(176,22): error TS2691: Cannot find name 'i6'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(176,22): error TS2692: Cannot find name 'i6'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(177,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(182,5): error TS2322: Type '{}' is not assignable to type 'i7'. Type '{}' provides no match for the signature 'new (): any' @@ -76,12 +76,12 @@ tests/cases/compiler/intTypeCheck.ts(187,5): error TS2322: Type '() => void' is Type '() => void' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not assignable to type 'i7'. tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(190,22): error TS2691: Cannot find name 'i7'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(190,22): error TS2692: Cannot find name 'i7'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'. tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(204,22): error TS2691: Cannot find name 'i8'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(204,22): error TS2692: Cannot find name 'i8'. A type exists with this name, but no value. tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -214,7 +214,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2691: Cannot find name 'i1'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'i1'. A type exists with this name, but no value. var obj10: i1 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -247,7 +247,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2691: Cannot find name 'i2'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'i2'. A type exists with this name, but no value. var obj21: i2 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -281,7 +281,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2691: Cannot find name 'i3'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'i3'. A type exists with this name, but no value. var obj32: i3 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -305,7 +305,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2691: Cannot find name 'i4'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'i4'. A type exists with this name, but no value. var obj43: i4 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -341,7 +341,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2691: Cannot find name 'i5'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'i5'. A type exists with this name, but no value. var obj54: i5 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -377,7 +377,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2691: Cannot find name 'i6'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'i6'. A type exists with this name, but no value. var obj65: i6 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -411,7 +411,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2691: Cannot find name 'i7'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'i7'. A type exists with this name, but no value. var obj76: i7 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -435,7 +435,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2691: Cannot find name 'i8'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'i8'. A type exists with this name, but no value. var obj87: i8 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt b/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt index 48e55e299a1..f3ee47573f7 100644 --- a/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt +++ b/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/interfaceNameAsIdentifier.ts(4,1): error TS2691: Cannot find name 'C'. A type exists with this name, but no value. +tests/cases/compiler/interfaceNameAsIdentifier.ts(4,1): error TS2692: Cannot find name 'C'. A type exists with this name, but no value. tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2304: Cannot find name 'm2'. @@ -8,7 +8,7 @@ tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2304: Cannot fi } C(); ~ -!!! error TS2691: Cannot find name 'C'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'C'. A type exists with this name, but no value. module m2 { export interface C { diff --git a/tests/baselines/reference/interfaceNaming1.errors.txt b/tests/baselines/reference/interfaceNaming1.errors.txt index 850b458913c..bdd3ca6c1f8 100644 --- a/tests/baselines/reference/interfaceNaming1.errors.txt +++ b/tests/baselines/reference/interfaceNaming1.errors.txt @@ -1,19 +1,19 @@ -tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2691: Cannot find name 'interface'. A type exists with this name, but no value. +tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2692: Cannot find name 'interface'. A type exists with this name, but no value. tests/cases/compiler/interfaceNaming1.ts(1,11): error TS1005: ';' expected. -tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2691: Cannot find name 'interface'. A type exists with this name, but no value. +tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2692: Cannot find name 'interface'. A type exists with this name, but no value. tests/cases/compiler/interfaceNaming1.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ==== tests/cases/compiler/interfaceNaming1.ts (4 errors) ==== interface { } ~~~~~~~~~ -!!! error TS2691: Cannot find name 'interface'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'interface'. A type exists with this name, but no value. ~ !!! error TS1005: ';' expected. interface interface{ } interface & { } ~~~~~~~~~ -!!! error TS2691: Cannot find name 'interface'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'interface'. A type exists with this name, but no value. ~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/invalidUndefinedAssignments.errors.txt b/tests/baselines/reference/invalidUndefinedAssignments.errors.txt index d04607455fc..2e9f6efb137 100644 --- a/tests/baselines/reference/invalidUndefinedAssignments.errors.txt +++ b/tests/baselines/reference/invalidUndefinedAssignments.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(4,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(9,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression. @@ -28,7 +28,7 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.t g = x; I = x; ~ -!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt index 48e4d1f9c9f..372d2e797e0 100644 --- a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt +++ b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt @@ -1,7 +1,7 @@ error TS2318: Cannot find global type 'Boolean'. error TS2318: Cannot find global type 'IArguments'. error TS2318: Cannot find global type 'Number'. -tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2691: Cannot find name 'Array'. A type exists with this name, but no value. +tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2692: Cannot find name 'Array'. A type exists with this name, but no value. !!! error TS2318: Cannot find global type 'Boolean'. @@ -13,7 +13,7 @@ tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib function f(x: number, y: number, z: number) { return Array.from(arguments); ~~~~~ -!!! error TS2691: Cannot find name 'Array'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'Array'. A type exists with this name, but no value. } f(1, 2, 3); diff --git a/tests/baselines/reference/newOperator.errors.txt b/tests/baselines/reference/newOperator.errors.txt index 00d33b13723..e8d834824e5 100644 --- a/tests/baselines/reference/newOperator.errors.txt +++ b/tests/baselines/reference/newOperator.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/newOperator.ts(3,13): error TS2691: Cannot find name 'ifc'. A type exists with this name, but no value. +tests/cases/compiler/newOperator.ts(3,13): error TS2692: Cannot find name 'ifc'. A type exists with this name, but no value. tests/cases/compiler/newOperator.ts(10,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/newOperator.ts(11,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/newOperator.ts(12,5): error TS2304: Cannot find name 'string'. @@ -17,7 +17,7 @@ tests/cases/compiler/newOperator.ts(45,23): error TS1150: 'new T[]' cannot be us // Attempting to 'new' an interface yields poor error var i = new ifc(); ~~~ -!!! error TS2691: Cannot find name 'ifc'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'ifc'. A type exists with this name, but no value. // Parens are optional var x = new Date; diff --git a/tests/baselines/reference/reservedNamesInAliases.errors.txt b/tests/baselines/reference/reservedNamesInAliases.errors.txt index c999841a322..99dc5137714 100644 --- a/tests/baselines/reference/reservedNamesInAliases.errors.txt +++ b/tests/baselines/reference/reservedNamesInAliases.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(5,6): error tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error TS2304: Cannot find name 'type'. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected. -tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2692: Cannot find name 'I'. A type exists with this name, but no value. ==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (8 errors) ==== @@ -30,4 +30,4 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error ~ !!! error TS1109: Expression expected. ~ -!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file +!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/returnTypeParameter.errors.txt b/tests/baselines/reference/returnTypeParameter.errors.txt index cfb5d4759ca..7b762f0938a 100644 --- a/tests/baselines/reference/returnTypeParameter.errors.txt +++ b/tests/baselines/reference/returnTypeParameter.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/returnTypeParameter.ts(1,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. ==== tests/cases/compiler/returnTypeParameter.ts (2 errors) ==== @@ -8,4 +8,4 @@ tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2691: Cannot find nam !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function f2(a: T): T { return T; } // bug was that this satisfied the return statement requirement ~ -!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. \ No newline at end of file +!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt index 2f4d0dd46b9..8254f12cb1c 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface. ==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ==== class C extends T {} ~ -!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. class C2 implements T {} ~ !!! error TS2422: A class may only implement another class or interface. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseType.errors.txt b/tests/baselines/reference/typeParameterAsBaseType.errors.txt index 7f56299bd6e..f6b82a85681 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseType.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2691: Cannot find name 'U'. A type exists with this name, but no value. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2692: Cannot find name 'U'. A type exists with this name, but no value. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface. @@ -10,10 +10,10 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e class C extends T { } ~ -!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. class C2 extends U { } ~ -!!! error TS2691: Cannot find name 'U'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'U'. A type exists with this name, but no value. interface I extends T { } ~ diff --git a/tests/baselines/reference/typeUsedAsValueError.errors.txt b/tests/baselines/reference/typeUsedAsValueError.errors.txt index af637231585..75a83134162 100644 --- a/tests/baselines/reference/typeUsedAsValueError.errors.txt +++ b/tests/baselines/reference/typeUsedAsValueError.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/typeUsedAsValueError.ts(16,11): error TS2691: Cannot find name 'Interface'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(16,11): error TS2692: Cannot find name 'Interface'. A type exists with this name, but no value. tests/cases/compiler/typeUsedAsValueError.ts(17,11): error TS2304: Cannot find name 'InterfaceNotFound'. -tests/cases/compiler/typeUsedAsValueError.ts(18,13): error TS2691: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. -tests/cases/compiler/typeUsedAsValueError.ts(19,16): error TS2691: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(18,13): error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(19,16): error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. tests/cases/compiler/typeUsedAsValueError.ts(20,16): error TS2304: Cannot find name 'TypeAliasForSomeClassNotFound'. -tests/cases/compiler/typeUsedAsValueError.ts(21,11): error TS2691: Cannot find name 'someType'. A type exists with this name, but no value. -tests/cases/compiler/typeUsedAsValueError.ts(22,17): error TS2691: Cannot find name 'someType'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(21,11): error TS2692: Cannot find name 'someType'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(22,17): error TS2692: Cannot find name 'someType'. A type exists with this name, but no value. tests/cases/compiler/typeUsedAsValueError.ts(23,17): error TS2304: Cannot find name 'someTypeNotFound'. @@ -26,25 +26,25 @@ tests/cases/compiler/typeUsedAsValueError.ts(23,17): error TS2304: Cannot find n let one = Interface; ~~~~~~~~~ -!!! error TS2691: Cannot find name 'Interface'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'Interface'. A type exists with this name, but no value. let two = InterfaceNotFound; ~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'InterfaceNotFound'. let three = TypeAliasForSomeClass; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2691: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. let four = new TypeAliasForSomeClass(); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2691: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. let five = new TypeAliasForSomeClassNotFound(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeAliasForSomeClassNotFound'. let six = someType; ~~~~~~~~ -!!! error TS2691: Cannot find name 'someType'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'someType'. A type exists with this name, but no value. acceptsSomeType(someType); ~~~~~~~~ -!!! error TS2691: Cannot find name 'someType'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'someType'. A type exists with this name, but no value. acceptsSomeType(someTypeNotFound); ~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'someTypeNotFound'. \ No newline at end of file diff --git a/tests/baselines/reference/typeUsedAsValueError2.errors.txt b/tests/baselines/reference/typeUsedAsValueError2.errors.txt index 8849a904bdf..8707ffaaafb 100644 --- a/tests/baselines/reference/typeUsedAsValueError2.errors.txt +++ b/tests/baselines/reference/typeUsedAsValueError2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/world.ts(4,1): error TS2691: Cannot find name 'HelloInterface'. A type exists with this name, but no value. +tests/cases/compiler/world.ts(4,1): error TS2692: Cannot find name 'HelloInterface'. A type exists with this name, but no value. tests/cases/compiler/world.ts(5,1): error TS2304: Cannot find name 'HelloNamespace'. @@ -8,7 +8,7 @@ tests/cases/compiler/world.ts(5,1): error TS2304: Cannot find name 'HelloNamespa HelloInterface.world; ~~~~~~~~~~~~~~ -!!! error TS2691: Cannot find name 'HelloInterface'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'HelloInterface'. A type exists with this name, but no value. HelloNamespace.world; ~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'HelloNamespace'. diff --git a/tests/baselines/reference/typeofSimple.errors.txt b/tests/baselines/reference/typeofSimple.errors.txt index 08bbb8ff10c..977a8b34d45 100644 --- a/tests/baselines/reference/typeofSimple.errors.txt +++ b/tests/baselines/reference/typeofSimple.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeofSimple.ts(3,5): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/typeofSimple.ts(8,21): error TS2691: Cannot find name 'J'. A type exists with this name, but no value. +tests/cases/compiler/typeofSimple.ts(8,21): error TS2692: Cannot find name 'J'. A type exists with this name, but no value. ==== tests/cases/compiler/typeofSimple.ts (2 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/typeofSimple.ts(8,21): error TS2691: Cannot find name 'J'. var numberJ: typeof J; //Error, cannot reference type in typeof ~ -!!! error TS2691: Cannot find name 'J'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'J'. A type exists with this name, but no value. var numberI: I; var fun: () => I; diff --git a/tests/baselines/reference/typeofTypeParameter.errors.txt b/tests/baselines/reference/typeofTypeParameter.errors.txt index 7843ee38cc6..a4fc868197d 100644 --- a/tests/baselines/reference/typeofTypeParameter.errors.txt +++ b/tests/baselines/reference/typeofTypeParameter.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts(3,19): error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts(3,19): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. ==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts var a: typeof x; var y: typeof T; ~ -!!! error TS2691: Cannot find name 'T'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. return a; } \ No newline at end of file diff --git a/tests/baselines/reference/validNullAssignments.errors.txt b/tests/baselines/reference/validNullAssignments.errors.txt index 7cf05cd9f6c..d3c403b4ae4 100644 --- a/tests/baselines/reference/validNullAssignments.errors.txt +++ b/tests/baselines/reference/validNullAssignments.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/primitives/null/validNullAssignments.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(15,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/primitives/null/validNullAssignments.ts(20,1): error TS2691: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/types/primitives/null/validNullAssignments.ts(20,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(30,1): error TS2364: Invalid left-hand side of assignment expression. @@ -31,7 +31,7 @@ tests/cases/conformance/types/primitives/null/validNullAssignments.ts(30,1): err g = null; // ok I = null; // error ~ -!!! error TS2691: Cannot find name 'I'. A type exists with this name, but no value. +!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value. module M { export var x = 1; } M = null; // error From eeec775da0f3dabe9c73254c02b5254bab84c882 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Sat, 20 Aug 2016 19:12:11 -0700 Subject: [PATCH 219/508] Add more test for 10426 --- .../completionEntryDetailAcrossFiles02.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts diff --git a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts new file mode 100644 index 00000000000..2c5e53ea224 --- /dev/null +++ b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts @@ -0,0 +1,20 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: a.js +//// /** +//// * Modify the parameter +//// * @param {string} p1 +//// */ +//// var foo = function (p1) { } +//// module.exports.foo = foo; +//// fo/*1*/ + +// @Filename: b.ts +//// import a = require("./a"); +//// a.fo/*2*/ + +goTo.marker('1'); +verify.completionEntryDetailIs("foo", "var foo: (p1: string) => void", "Modify the parameter"); +goTo.marker('2'); +verify.completionEntryDetailIs("foo", "(property) a.foo: (p1: string) => void", "Modify the parameter"); From dc7b18e4e24796a40fc24801b3c5425e71200f1d Mon Sep 17 00:00:00 2001 From: Yuichi Nukiyama Date: Sun, 21 Aug 2016 11:42:41 +0900 Subject: [PATCH 220/508] fix some errors --- src/compiler/checker.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 7ff5b5b19ed..3a6608c71d1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6401,11 +6401,10 @@ namespace ts { } } - if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) { - tryElaborateErrorsForPrimitivesAndObjects(source, target); - } - if (reportErrors) { + if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) { + tryElaborateErrorsForPrimitivesAndObjects(source, target); + } reportRelationError(headMessage, source, target); } return Ternary.False; From 794d3e91d07021409ef4a985dd90fc431f4f04c5 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Sat, 20 Aug 2016 20:35:58 -0700 Subject: [PATCH 221/508] routine update of dom libs --- src/lib/dom.generated.d.ts | 70 +++++++++++++++++++++++++------- src/lib/webworker.generated.d.ts | 2 +- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index d2938f6e983..ee657f64a65 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -126,6 +126,7 @@ interface KeyAlgorithm { } interface KeyboardEventInit extends EventModifierInit { + code?: string; key?: string; location?: number; repeat?: boolean; @@ -2288,7 +2289,7 @@ declare var DeviceRotationRate: { new(): DeviceRotationRate; } -interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent { +interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode { /** * Sets or gets the URL for the current document. */ @@ -3351,7 +3352,7 @@ declare var Document: { new(): Document; } -interface DocumentFragment extends Node, NodeSelector { +interface DocumentFragment extends Node, NodeSelector, ParentNode { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3420,7 +3421,7 @@ declare var EXT_texture_filter_anisotropic: { readonly TEXTURE_MAX_ANISOTROPY_EXT: number; } -interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode { +interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { readonly classList: DOMTokenList; className: string; readonly clientHeight: number; @@ -3675,6 +3676,16 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByClassName(classNames: string): NodeListOf; matches(selector: string): boolean; closest(selector: string): Element | null; + scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void; + scroll(options?: ScrollToOptions): void; + scroll(x: number, y: number): void; + scrollTo(options?: ScrollToOptions): void; + scrollTo(x: number, y: number): void; + scrollBy(options?: ScrollToOptions): void; + scrollBy(x: number, y: number): void; + insertAdjacentElement(position: string, insertedElement: Element): Element | null; + insertAdjacentHTML(where: string, html: string): void; + insertAdjacentText(where: string, text: string): void; addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -4446,7 +4457,7 @@ interface HTMLCanvasElement extends HTMLElement { * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. */ toDataURL(type?: string, ...args: any[]): string; - toBlob(callback: (result: Blob | null) => void, ... arguments: any[]): void; + toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; } declare var HTMLCanvasElement: { @@ -4621,11 +4632,7 @@ interface HTMLElement extends Element { click(): void; dragDrop(): boolean; focus(): void; - insertAdjacentElement(position: string, insertedElement: Element): Element; - insertAdjacentHTML(where: string, html: string): void; - insertAdjacentText(where: string, text: string): void; msGetInputContext(): MSInputMethodContext; - scrollIntoView(top?: boolean): void; setActive(): void; addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -5890,6 +5897,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { */ type: string; import?: Document; + integrity: string; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6178,7 +6186,7 @@ interface HTMLMediaElement extends HTMLElement { */ canPlayType(type: string): string; /** - * Fires immediately after the client loads the object. + * Resets the audio or video object and loads a new media resource. */ load(): void; /** @@ -6751,6 +6759,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the MIME type for the associated scripting engine. */ type: string; + integrity: string; } declare var HTMLScriptElement: { @@ -7756,6 +7765,7 @@ interface KeyboardEvent extends UIEvent { readonly repeat: boolean; readonly shiftKey: boolean; readonly which: number; + readonly code: string; getModifierState(keyArg: string): boolean; initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; readonly DOM_KEY_LOCATION_JOYSTICK: number; @@ -9128,6 +9138,7 @@ interface PerformanceTiming { readonly responseStart: number; readonly unloadEventEnd: number; readonly unloadEventStart: number; + readonly secureConnectionStart: number; toJSON(): any; } @@ -11405,8 +11416,8 @@ declare var StereoPannerNode: { interface Storage { readonly length: number; clear(): void; - getItem(key: string): string; - key(index: number): string; + getItem(key: string): string | null; + key(index: number): string | null; removeItem(key: string): void; setItem(key: string, data: string): void; [key: string]: any; @@ -12947,7 +12958,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onunload: (this: this, ev: Event) => any; onvolumechange: (this: this, ev: Event) => any; onwaiting: (this: this, ev: Event) => any; - readonly opener: Window; + opener: any; orientation: string | number; readonly outerHeight: number; readonly outerWidth: number; @@ -13002,6 +13013,9 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + scroll(options?: ScrollToOptions): void; + scrollTo(options?: ScrollToOptions): void; + scrollBy(options?: ScrollToOptions): void; addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -14029,6 +14043,20 @@ interface ProgressEventInit extends EventInit { total?: number; } +interface ScrollOptions { + behavior?: ScrollBehavior; +} + +interface ScrollToOptions extends ScrollOptions { + left?: number; + top?: number; +} + +interface ScrollIntoViewOptions extends ScrollOptions { + block?: ScrollLogicalPosition; + inline?: ScrollLogicalPosition; +} + interface ClipboardEventInit extends EventInit { data?: string; dataType?: string; @@ -14072,7 +14100,7 @@ interface EcdsaParams extends Algorithm { } interface EcKeyGenParams extends Algorithm { - typedCurve: string; + namedCurve: string; } interface EcKeyAlgorithm extends KeyAlgorithm { @@ -14208,6 +14236,13 @@ interface JsonWebKey { k?: string; } +interface ParentNode { + readonly children: HTMLCollection; + readonly firstElementChild: Element; + readonly lastElementChild: Element; + readonly childElementCount: number; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -14278,7 +14313,7 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msCredentials: MSCredentials; -declare var name: string; +declare const name: never; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; declare var onabort: (this: Window, ev: UIEvent) => any; @@ -14372,7 +14407,7 @@ declare var ontouchstart: (ev: TouchEvent) => any; declare var onunload: (this: Window, ev: Event) => any; declare var onvolumechange: (this: Window, ev: Event) => any; declare var onwaiting: (this: Window, ev: Event) => any; -declare var opener: Window; +declare var opener: any; declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; @@ -14425,6 +14460,9 @@ declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function scroll(options?: ScrollToOptions): void; +declare function scrollTo(options?: ScrollToOptions): void; +declare function scrollBy(options?: ScrollToOptions): void; declare function toString(): string; declare function addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare function dispatchEvent(evt: Event): boolean; @@ -14580,6 +14618,8 @@ type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; type payloadtype = number; +type ScrollBehavior = "auto" | "instant" | "smooth"; +type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; \ No newline at end of file diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index c61a1a8b8a6..483348f3f75 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -1000,7 +1000,7 @@ interface EcdsaParams extends Algorithm { } interface EcKeyGenParams extends Algorithm { - typedCurve: string; + namedCurve: string; } interface EcKeyAlgorithm extends KeyAlgorithm { From e445e012c4fe9a3673204988491266a41d56fd7a Mon Sep 17 00:00:00 2001 From: zhengbli Date: Sat, 20 Aug 2016 20:41:33 -0700 Subject: [PATCH 222/508] Add test for jsdoc syntactic classification for function declaration --- .../syntacticClassificationsDocComment4.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/cases/fourslash/syntacticClassificationsDocComment4.ts diff --git a/tests/cases/fourslash/syntacticClassificationsDocComment4.ts b/tests/cases/fourslash/syntacticClassificationsDocComment4.ts new file mode 100644 index 00000000000..d8ac2f12d8b --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsDocComment4.ts @@ -0,0 +1,24 @@ +/// + +//// /** @param {number} p1 */ +//// function foo(p1) {} + +var c = classification; +verify.syntacticClassificationsAre( + c.comment("/** "), + c.punctuation("@"), + c.docCommentTagName("param"), + c.comment(" "), + c.punctuation("{"), + c.keyword("number"), + c.punctuation("}"), + c.comment(" "), + c.parameterName("p1"), + c.comment(" */"), + c.keyword("function"), + c.identifier("foo"), + c.punctuation("("), + c.parameterName("p1"), + c.punctuation(")"), + c.punctuation("{"), + c.punctuation("}")); From 6d2323b0d81bc85e33bb0bce8b292938d8a0de27 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Sat, 20 Aug 2016 20:41:47 -0700 Subject: [PATCH 223/508] Simplify implementation --- src/compiler/utilities.ts | 4 ++++ src/services/services.ts | 37 ++++++++++++------------------------- 2 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0a1f43203ce..f1573f9b58a 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -301,6 +301,10 @@ namespace ts { return node.kind >= SyntaxKind.FirstJSDocNode && node.kind <= SyntaxKind.LastJSDocNode; } + export function isJSDocTag(node: Node) { + return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; + } + export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number { if (nodeIsMissing(node) || !node.decorators) { return getTokenPosOfNode(node, sourceFile); diff --git a/src/services/services.ts b/src/services/services.ts index c4b42f94226..22f5a74eb50 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -21,7 +21,6 @@ namespace ts { getChildCount(sourceFile?: SourceFile): number; getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; - getNonJsDocCommentChildren?(sourceFile?: SourceFile): Node[]; getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; @@ -197,7 +196,6 @@ namespace ts { public parent: Node; public jsDocComments: JSDocComment[]; private _children: Node[]; - private _nonJsDocCommentChildren: Node[]; constructor(kind: SyntaxKind, pos: number, end: number) { this.pos = pos; @@ -275,22 +273,20 @@ namespace ts { } private createChildren(sourceFile?: SourceFile) { - let jsDocCommentChildren: Node[]; - let nonJsDocCommentChildren: Node[]; + let children: Node[]; if (this.kind >= SyntaxKind.FirstNode) { scanner.setText((sourceFile || this.getSourceFile()).text); - jsDocCommentChildren = []; - nonJsDocCommentChildren = []; + children = []; let pos = this.pos; const useJSDocScanner = this.kind >= SyntaxKind.FirstJSDocTagNode && this.kind <= SyntaxKind.LastJSDocTagNode; - const processNode = (node: Node, children = nonJsDocCommentChildren) => { + const processNode = (node: Node) => { if (pos < node.pos) { pos = this.addSyntheticNodes(children, pos, node.pos, useJSDocScanner); } children.push(node); pos = node.end; }; - const processNodes = (nodes: NodeArray, children = nonJsDocCommentChildren) => { + const processNodes = (nodes: NodeArray) => { if (pos < nodes.pos) { pos = this.addSyntheticNodes(children, pos, nodes.pos, useJSDocScanner); } @@ -300,7 +296,7 @@ namespace ts { // jsDocComments need to be the first children if (this.jsDocComments) { for (const jsDocComment of this.jsDocComments) { - processNode(jsDocComment, jsDocCommentChildren); + processNode(jsDocComment); } } // For syntactic classifications, all trivia are classcified together, including jsdoc comments. @@ -309,12 +305,11 @@ namespace ts { pos = this.pos; forEachChild(this, processNode, processNodes); if (pos < this.end) { - this.addSyntheticNodes(nonJsDocCommentChildren, pos, this.end); + this.addSyntheticNodes(children, pos, this.end); } scanner.setText(undefined); } - this._nonJsDocCommentChildren = nonJsDocCommentChildren || emptyArray; - this._children = concatenate(jsDocCommentChildren, this._nonJsDocCommentChildren); + this._children = children || emptyArray; } public getChildCount(sourceFile?: SourceFile): number { @@ -332,18 +327,6 @@ namespace ts { return this._children; } - public getNonJsDocCommentChildren(sourceFile?: SourceFile): Node[] { - // If the cached children were cleared, that means some node before the current node has changed. - // so even if we have a cached nonJsDocCommentChildren, it would be outdated as well. - if (!this._children) { - this.createChildren(sourceFile); - } - // If the node has cached children but not nonJsDocCommentChildren, it means the children is not created - // via calling the "createChildren" method, so it can only be a SyntaxList. As SyntaxList cannot have jsDocCommentChildren - // anyways, we can just return its children. - return this._nonJsDocCommentChildren ? this._nonJsDocCommentChildren : this._children; - } - public getFirstToken(sourceFile?: SourceFile): Node { const children = this.getChildren(sourceFile); if (!children.length) { @@ -7591,6 +7574,10 @@ namespace ts { * False will mean that node is not classified and traverse routine should recurse into node contents. */ function tryClassifyNode(node: Node): boolean { + if (isJSDocTag(node)) { + return true; + } + if (nodeIsMissing(node)) { return true; } @@ -7746,7 +7733,7 @@ namespace ts { if (decodedTextSpanIntersectsWith(spanStart, spanLength, element.pos, element.getFullWidth())) { checkForClassificationCancellation(element.kind); - const children = element.getNonJsDocCommentChildren ? element.getNonJsDocCommentChildren(sourceFile) : element.getChildren(sourceFile); + const children = element.getChildren(sourceFile); for (let i = 0, n = children.length; i < n; i++) { const child = children[i]; if (!tryClassifyNode(child)) { From 84386f9d3b4ac8309ab5f3ce936613f14cad9106 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Sat, 20 Aug 2016 20:46:56 -0700 Subject: [PATCH 224/508] Tolerate certain errors in tsconfig.json --- src/server/editorServices.ts | 50 +++++++++++++++++++++--------------- src/server/session.ts | 20 ++++++++++----- 2 files changed, 42 insertions(+), 28 deletions(-) diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index db9bdd5043b..0d84fa54a4a 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -603,8 +603,11 @@ namespace ts.server { return projects.length > 1 ? deduplicate(result, areEqual) : result; } + export type ProjectServiceEvent = + { eventName: "context", data: { project: Project, fileName: string } } | { eventName: "configFileDiag", data: { triggerFile?: string, configFileName: string, diagnostics: Diagnostic[] } } + export interface ProjectServiceEventHandler { - (eventName: string, project: Project, fileName: string): void; + (event: ProjectServiceEvent): void; } export interface HostConfiguration { @@ -748,10 +751,13 @@ namespace ts.server { return ts.normalizePath(name); } - watchedProjectConfigFileChanged(project: Project) { + watchedProjectConfigFileChanged(project: Project): void { this.log("Config file changed: " + project.projectFilename); - this.updateConfiguredProject(project); + const configFileErrors = this.updateConfiguredProject(project); this.updateProjectStructure(); + if (configFileErrors && configFileErrors.length > 0) { + this.eventHandler({ eventName: "configFileDiag", data: { triggerFile: project.projectFilename, configFileName: project.projectFilename, diagnostics: configFileErrors } }); + } } log(msg: string, type = "Err") { @@ -828,13 +834,13 @@ namespace ts.server { for (let j = 0, flen = this.openFileRoots.length; j < flen; j++) { const openFile = this.openFileRoots[j]; if (this.eventHandler) { - this.eventHandler("context", openFile.defaultProject, openFile.fileName); + this.eventHandler({ eventName: "context", data: { project: openFile.defaultProject, fileName: openFile.fileName } }); } } for (let j = 0, flen = this.openFilesReferenced.length; j < flen; j++) { const openFile = this.openFilesReferenced[j]; if (this.eventHandler) { - this.eventHandler("context", openFile.defaultProject, openFile.fileName); + this.eventHandler({ eventName: "context", data: { project: openFile.defaultProject, fileName: openFile.fileName } }); } } } @@ -1234,11 +1240,12 @@ namespace ts.server { else { this.updateConfiguredProject(project); } + return { configFileName }; } else { this.log("No config files found."); } - return configFileName ? { configFileName } : {}; + return {}; } /** @@ -1328,7 +1335,7 @@ namespace ts.server { return undefined; } - configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, errors?: Diagnostic[] } { + configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, errors: Diagnostic[] } { configFilename = ts.normalizePath(configFilename); // file references will be relative to dirPath (or absolute) const dirPath = ts.getDirectoryPath(configFilename); @@ -1341,20 +1348,19 @@ namespace ts.server { const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath, /*existingOptions*/ {}, configFilename); Debug.assert(!!parsedCommandLine.fileNames); - if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { - return { succeeded: false, errors: parsedCommandLine.errors }; - } - else if (parsedCommandLine.fileNames.length === 0) { + if (parsedCommandLine.fileNames.length === 0) { const error = createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename); - return { succeeded: false, errors: [error] }; + return { succeeded: false, errors: concatenate(parsedCommandLine.errors, [error]) }; } else { + // if the project has some files, we can continue with the parsed options and tolerate + // errors in the parsedCommandLine const projectOptions: ProjectOptions = { files: parsedCommandLine.fileNames, wildcardDirectories: parsedCommandLine.wildcardDirectories, compilerOptions: parsedCommandLine.options, }; - return { succeeded: true, projectOptions }; + return { succeeded: true, projectOptions, errors: parsedCommandLine.errors }; } } } @@ -1377,10 +1383,11 @@ namespace ts.server { return false; } - openConfigFile(configFilename: string, clientFileName?: string): { success: boolean, project?: Project, errors?: Diagnostic[] } { - const { succeeded, projectOptions, errors } = this.configFileToProjectOptions(configFilename); + openConfigFile(configFilename: string, clientFileName?: string): { success: boolean, project?: Project, errors: Diagnostic[] } { + const { succeeded, projectOptions, errors: errorsFromConfigFile } = this.configFileToProjectOptions(configFilename); + // Note: even if "succeeded"" is true, "errors" may still exist, as they are just tolerated if (!succeeded) { - return { success: false, errors }; + return { success: false, errors: errorsFromConfigFile }; } else { if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) { @@ -1392,7 +1399,7 @@ namespace ts.server { project.projectFileWatcher = this.host.watchFile( toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), _ => this.watchedProjectConfigFileChanged(project)); - return { success: true, project }; + return { success: true, project, errors: errorsFromConfigFile }; } } @@ -1433,7 +1440,7 @@ namespace ts.server { return watchers; }, >{}); - return { success: true, project: project, errors }; + return { success: true, project: project, errors: concatenate(errors, errorsFromConfigFile) }; } } @@ -1451,7 +1458,7 @@ namespace ts.server { if (projectOptions.compilerOptions && !projectOptions.compilerOptions.disableSizeLimit && this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { project.setProjectOptions(projectOptions); if (project.languageServiceDiabled) { - return; + return errors; } project.disableLanguageService(); @@ -1459,7 +1466,7 @@ namespace ts.server { project.directoryWatcher.close(); project.directoryWatcher = undefined; } - return; + return errors; } if (project.languageServiceDiabled) { @@ -1478,7 +1485,7 @@ namespace ts.server { } } project.finishGraph(); - return; + return errors; } // if the project is too large, the root files might not have been all loaded if the total @@ -1524,6 +1531,7 @@ namespace ts.server { project.setProjectOptions(projectOptions); project.finishGraph(); } + return errors; } } diff --git a/src/server/session.ts b/src/server/session.ts index 9383a54bd48..00468330ffb 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -153,16 +153,22 @@ namespace ts.server { private logger: Logger ) { this.projectService = - new ProjectService(host, logger, (eventName, project, fileName) => { - this.handleEvent(eventName, project, fileName); + new ProjectService(host, logger, event => { + this.handleEvent(event); }); } - private handleEvent(eventName: string, project: Project, fileName: string) { - if (eventName == "context") { - this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); - this.updateErrorCheck([{ fileName, project }], this.changeSeq, - (n) => n === this.changeSeq, 100); + private handleEvent(event: ProjectServiceEvent) { + switch (event.eventName) { + case "context": + const { project, fileName } = event.data; + this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); + this.updateErrorCheck([{ fileName, project }], this.changeSeq, + (n) => n === this.changeSeq, 100); + break; + case "configFileDiag": + const { triggerFile, configFileName, diagnostics } = event.data; + this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); } } From b2074172e1ef7b6f389d398e737268c16dc2cd93 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Sat, 20 Aug 2016 20:47:30 -0700 Subject: [PATCH 225/508] Add test for configFile error tolerance --- src/harness/unittests/tsserverProjectSystem.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 49f033b9def..d4ed84191b4 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -623,5 +623,23 @@ namespace ts { checkNumberOfConfiguredProjects(projectService, 1); checkNumberOfInferredProjects(projectService, 0); }); + + it("should tolerate config file errors and still try to build a project", () => { + const configFile: FileOrFolder = { + path: "/a/b/tsconfig.json", + content: `{ + "compilerOptions": { + "target": "es6", + "allowAnything": true + }, + "someOtherProperty": {} + }` + }; + const host = new TestServerHost(/*useCaseSensitiveFileNames*/ false, getExecutingFilePathFromLibFile(libFile), "/", [commonFile1, commonFile2, libFile, configFile]); + const projectService = new server.ProjectService(host, nullLogger); + projectService.openClientFile(commonFile1.path); + checkNumberOfConfiguredProjects(projectService, 1); + checkConfiguredProjectRootFiles(projectService.configuredProjects[0], [commonFile1.path, commonFile2.path]); + }); }); } \ No newline at end of file From a8ab52fd573dd28e1ee8a19f6271e6e98b35dd64 Mon Sep 17 00:00:00 2001 From: zhengbli Date: Sat, 20 Aug 2016 20:47:35 -0700 Subject: [PATCH 226/508] Use TS parser to tolerate more errors in tsconfig.json --- src/harness/unittests/tsconfigParsing.ts | 20 +++ src/server/editorServices.ts | 173 ++++++++++++----------- src/services/utilities.ts | 20 +++ 3 files changed, 132 insertions(+), 81 deletions(-) diff --git a/src/harness/unittests/tsconfigParsing.ts b/src/harness/unittests/tsconfigParsing.ts index 557379dff3b..2c9bcdb8423 100644 --- a/src/harness/unittests/tsconfigParsing.ts +++ b/src/harness/unittests/tsconfigParsing.ts @@ -181,5 +181,25 @@ namespace ts { ["/d.ts", "/folder/e.ts"] ); }); + + it("parse and re-emit tsconfig.json file with diagnostics", () => { + const content = `{ + "compilerOptions": { + "allowJs": true + "outDir": "bin" + } + "files": ["file1.ts"] + }`; + const { configJsonObject, diagnostics } = parseAndReEmitConfigJSONFile(content); + const expectedResult = { + compilerOptions: { + allowJs: true, + outDir: "bin" + }, + files: ["file1.ts"] + }; + assert.isTrue(diagnostics.length === 2); + assert.equal(JSON.stringify(configJsonObject), JSON.stringify(expectedResult)); + }); }); } diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 0d84fa54a4a..255ad8547ea 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -702,7 +702,8 @@ namespace ts.server { } handleProjectFileListChanges(project: Project) { - const { projectOptions } = this.configFileToProjectOptions(project.projectFilename); + const { projectOptions, errors } = this.configFileToProjectOptions(project.projectFilename); + this.reportConfigFileDiagnostics(project.projectFilename, errors); const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f))); const currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f))); @@ -720,18 +721,32 @@ namespace ts.server { } } + reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile?: string) { + if (diagnostics && diagnostics.length > 0) { + this.eventHandler({ + eventName: "configFileDiag", + data: { configFileName, diagnostics, triggerFile } + }); + } + } + /** * This is the callback function when a watched directory has an added tsconfig file. */ directoryWatchedForTsconfigChanged(fileName: string) { - if (ts.getBaseFileName(fileName) != "tsconfig.json") { + if (ts.getBaseFileName(fileName) !== "tsconfig.json") { this.log(fileName + " is not tsconfig.json"); return; } this.log("Detected newly added tsconfig file: " + fileName); - const { projectOptions } = this.configFileToProjectOptions(fileName); + const { projectOptions, errors } = this.configFileToProjectOptions(fileName); + this.reportConfigFileDiagnostics(fileName, errors); + + if (!projectOptions) { + return; + } const rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f)); const openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName)); @@ -1224,7 +1239,7 @@ namespace ts.server { const project = this.findConfiguredProjectByConfigFile(configFileName); if (!project) { const configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.success) { + if (!configResult.project) { return { configFileName, configFileErrors: configResult.errors }; } else { @@ -1335,33 +1350,31 @@ namespace ts.server { return undefined; } - configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, errors: Diagnostic[] } { + configFileToProjectOptions(configFilename: string): { projectOptions?: ProjectOptions, errors: Diagnostic[] } { configFilename = ts.normalizePath(configFilename); + let errors: Diagnostic[] = []; // file references will be relative to dirPath (or absolute) const dirPath = ts.getDirectoryPath(configFilename); const contents = this.host.readFile(configFilename); - const rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileTextToJson(configFilename, contents); - if (rawConfig.error) { - return { succeeded: false, errors: [rawConfig.error] }; + const { configJsonObject, diagnostics } = ts.parseAndReEmitConfigJSONFile(contents); + errors = concatenate(errors, diagnostics); + const parsedCommandLine = ts.parseJsonConfigFileContent(configJsonObject, this.host, dirPath, /*existingOptions*/ {}, configFilename); + errors = concatenate(errors, parsedCommandLine.errors); + Debug.assert(!!parsedCommandLine.fileNames); + + if (parsedCommandLine.fileNames.length === 0) { + errors.push(createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + return { errors }; } else { - const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath, /*existingOptions*/ {}, configFilename); - Debug.assert(!!parsedCommandLine.fileNames); - - if (parsedCommandLine.fileNames.length === 0) { - const error = createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename); - return { succeeded: false, errors: concatenate(parsedCommandLine.errors, [error]) }; - } - else { - // if the project has some files, we can continue with the parsed options and tolerate - // errors in the parsedCommandLine - const projectOptions: ProjectOptions = { - files: parsedCommandLine.fileNames, - wildcardDirectories: parsedCommandLine.wildcardDirectories, - compilerOptions: parsedCommandLine.options, - }; - return { succeeded: true, projectOptions, errors: parsedCommandLine.errors }; - } + // if the project has some files, we can continue with the parsed options and tolerate + // errors in the parsedCommandLine + const projectOptions: ProjectOptions = { + files: parsedCommandLine.fileNames, + wildcardDirectories: parsedCommandLine.wildcardDirectories, + compilerOptions: parsedCommandLine.options, + }; + return { projectOptions, errors }; } } @@ -1383,65 +1396,63 @@ namespace ts.server { return false; } - openConfigFile(configFilename: string, clientFileName?: string): { success: boolean, project?: Project, errors: Diagnostic[] } { - const { succeeded, projectOptions, errors: errorsFromConfigFile } = this.configFileToProjectOptions(configFilename); - // Note: even if "succeeded"" is true, "errors" may still exist, as they are just tolerated - if (!succeeded) { - return { success: false, errors: errorsFromConfigFile }; + openConfigFile(configFilename: string, clientFileName?: string): { project?: Project, errors: Diagnostic[] } { + const parseConfigFileResult = this.configFileToProjectOptions(configFilename); + let errors = parseConfigFileResult.errors; + if (!parseConfigFileResult.projectOptions) { + return { errors }; } - else { - if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) { - if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { - const project = this.createProject(configFilename, projectOptions, /*languageServiceDisabled*/ true); + const projectOptions = parseConfigFileResult.projectOptions; + if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) { + if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { + const project = this.createProject(configFilename, projectOptions, /*languageServiceDisabled*/ true); - // for configured projects with languageService disabled, we only watch its config file, - // do not care about the directory changes in the folder. - project.projectFileWatcher = this.host.watchFile( - toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), - _ => this.watchedProjectConfigFileChanged(project)); - return { success: true, project, errors: errorsFromConfigFile }; - } + // for configured projects with languageService disabled, we only watch its config file, + // do not care about the directory changes in the folder. + project.projectFileWatcher = this.host.watchFile( + toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), + _ => this.watchedProjectConfigFileChanged(project)); + return { project, errors }; + } + } + + const project = this.createProject(configFilename, projectOptions); + for (const rootFilename of projectOptions.files) { + if (this.host.fileExists(rootFilename)) { + const info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename); + project.addRoot(info); + } + else { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.File_0_not_found, rootFilename)); + } + } + project.finishGraph(); + project.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(project)); + + const configDirectoryPath = ts.getDirectoryPath(configFilename); + + this.log("Add recursive watcher for: " + configDirectoryPath); + project.directoryWatcher = this.host.watchDirectory( + configDirectoryPath, + path => this.directoryWatchedForSourceFilesChanged(project, path), + /*recursive*/ true + ); + + project.directoriesWatchedForWildcards = reduceProperties(createMap(projectOptions.wildcardDirectories), (watchers, flag, directory) => { + if (comparePaths(configDirectoryPath, directory, ".", !this.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { + const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; + this.log(`Add ${ recursive ? "recursive " : ""}watcher for: ${directory}`); + watchers[directory] = this.host.watchDirectory( + directory, + path => this.directoryWatchedForSourceFilesChanged(project, path), + recursive + ); } - const project = this.createProject(configFilename, projectOptions); - let errors: Diagnostic[]; - for (const rootFilename of projectOptions.files) { - if (this.host.fileExists(rootFilename)) { - const info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename); - project.addRoot(info); - } - else { - (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.File_0_not_found, rootFilename)); - } - } - project.finishGraph(); - project.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(project)); + return watchers; + }, >{}); - const configDirectoryPath = ts.getDirectoryPath(configFilename); - - this.log("Add recursive watcher for: " + configDirectoryPath); - project.directoryWatcher = this.host.watchDirectory( - configDirectoryPath, - path => this.directoryWatchedForSourceFilesChanged(project, path), - /*recursive*/ true - ); - - project.directoriesWatchedForWildcards = reduceProperties(createMap(projectOptions.wildcardDirectories), (watchers, flag, directory) => { - if (comparePaths(configDirectoryPath, directory, ".", !this.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { - const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; - this.log(`Add ${ recursive ? "recursive " : ""}watcher for: ${directory}`); - watchers[directory] = this.host.watchDirectory( - directory, - path => this.directoryWatchedForSourceFilesChanged(project, path), - recursive - ); - } - - return watchers; - }, >{}); - - return { success: true, project: project, errors: concatenate(errors, errorsFromConfigFile) }; - } + return { project: project, errors }; } updateConfiguredProject(project: Project): Diagnostic[] { @@ -1450,8 +1461,8 @@ namespace ts.server { this.removeProject(project); } else { - const { succeeded, projectOptions, errors } = this.configFileToProjectOptions(project.projectFilename); - if (!succeeded) { + const { projectOptions, errors } = this.configFileToProjectOptions(project.projectFilename); + if (!projectOptions) { return errors; } else { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 7f41cdbb3a4..858f889bc6c 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -925,4 +925,24 @@ namespace ts { } return ensureScriptKind(fileName, scriptKind); } + + export function parseAndReEmitConfigJSONFile(content: string) { + const options: TranspileOptions = { + fileName: "config.js", + compilerOptions: { + target: ScriptTarget.ES6 + }, + reportDiagnostics: true + }; + const { outputText, diagnostics } = ts.transpileModule("(" + content + ")", options); + // Becasue the content was wrapped in "()", the start position of diagnostics needs to be subtract by 1 + // also, the emitted result will have "(" in the beginning and ");" in the end. We need to strip these + // as well + const trimmedOutput = outputText.trim(); + const configJsonObject = JSON.parse(trimmedOutput.substring(1, trimmedOutput.length - 2)); + for (const diagnostic of diagnostics) { + diagnostic.start = diagnostic.start - 1; + } + return { configJsonObject, diagnostics }; + } } \ No newline at end of file From 582d8b8fc8047fcda47024a37bf5258d2050fe3b Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 21 Aug 2016 16:18:45 -0700 Subject: [PATCH 227/508] Implement tuple types as type references to synthesized generic types --- src/compiler/checker.ts | 177 +++++++++++++++++++--------------------- src/compiler/types.ts | 5 +- 2 files changed, 87 insertions(+), 95 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8568cd5feed..d87dbd1696c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -106,7 +106,7 @@ namespace ts { isOptionalParameter }; - const tupleTypes = createMap(); + const tupleTypes: TupleType[] = []; const unionTypes = createMap(); const intersectionTypes = createMap(); const stringLiteralTypes = createMap(); @@ -2145,9 +2145,6 @@ namespace ts { // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); } - else if (type.flags & TypeFlags.Tuple) { - writeTupleType(type); - } else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol) { const typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); @@ -2214,6 +2211,11 @@ namespace ts { writePunctuation(writer, SyntaxKind.OpenBracketToken); writePunctuation(writer, SyntaxKind.CloseBracketToken); } + else if (type.target.flags & TypeFlags.Tuple) { + writePunctuation(writer, SyntaxKind.OpenBracketToken); + writeTypeList(type.typeArguments.slice(0, type.target.typeParameters.length), SyntaxKind.CommaToken); + writePunctuation(writer, SyntaxKind.CloseBracketToken); + } else { // Write the type reference in the format f.g.C where A and B are type arguments // for outer type parameters, and f and g are the respective declaring containers of those @@ -2242,12 +2244,6 @@ namespace ts { } } - function writeTupleType(type: TupleType) { - writePunctuation(writer, SyntaxKind.OpenBracketToken); - writeTypeList(type.elementTypes, SyntaxKind.CommaToken); - writePunctuation(writer, SyntaxKind.CloseBracketToken); - } - function writeUnionOrIntersectionType(type: UnionOrIntersectionType, flags: TypeFormatFlags) { if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.OpenParenToken); @@ -2958,7 +2954,7 @@ namespace ts { : elementType; if (!type) { if (isTupleType(parentType)) { - error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), (parentType).elementTypes.length, pattern.elements.length); + error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { error(declaration, Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); @@ -3150,12 +3146,12 @@ namespace ts { } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. const elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors)); + let result = createTupleType(elementTypes); if (includePatternInType) { - const result = createNewTupleType(elementTypes); + result = cloneTypeReference(result); result.pattern = pattern; - return result; } - return createTupleType(elementTypes); + return result; } // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself @@ -3564,18 +3560,19 @@ namespace ts { } function getBaseTypes(type: InterfaceType): ObjectType[] { - const isClass = type.symbol.flags & SymbolFlags.Class; - const isInterface = type.symbol.flags & SymbolFlags.Interface; if (!type.resolvedBaseTypes) { - if (!isClass && !isInterface) { - Debug.fail("type must be class or interface"); + if (type.flags & TypeFlags.Tuple) { + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; } - if (isClass) { + else if (type.symbol.flags & SymbolFlags.Class) { resolveBaseTypesOfClass(type); } - if (isInterface) { + else if (type.symbol.flags & SymbolFlags.Interface) { resolveBaseTypesOfInterface(type); } + else { + Debug.fail("type must be class or interface"); + } } return type.resolvedBaseTypes; } @@ -4001,20 +3998,25 @@ namespace ts { return createTypeReference((type).target, concatenate((type).typeArguments, [thisArgument || (type).target.thisType])); } - if (type.flags & TypeFlags.Tuple) { - return createTupleType((type as TupleType).elementTypes, thisArgument); - } return type; } function resolveObjectTypeMembers(type: ObjectType, source: InterfaceTypeWithDeclaredMembers, typeParameters: TypeParameter[], typeArguments: Type[]) { - let mapper = identityMapper; - let members = source.symbol.members; - let callSignatures = source.declaredCallSignatures; - let constructSignatures = source.declaredConstructSignatures; - let stringIndexInfo = source.declaredStringIndexInfo; - let numberIndexInfo = source.declaredNumberIndexInfo; - if (!rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + let mapper: TypeMapper; + let members: SymbolTable; + let callSignatures: Signature[]; + let constructSignatures: Signature[]; + let stringIndexInfo: IndexInfo; + let numberIndexInfo: IndexInfo; + if (rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = identityMapper; + members = source.symbol ? source.symbol.members : createSymbolTable(source.declaredProperties); + callSignatures = source.declaredCallSignatures; + constructSignatures = source.declaredConstructSignatures; + stringIndexInfo = source.declaredStringIndexInfo; + numberIndexInfo = source.declaredNumberIndexInfo; + } + else { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); @@ -4024,7 +4026,7 @@ namespace ts { } const baseTypes = getBaseTypes(source); if (baseTypes.length) { - if (members === source.symbol.members) { + if (source.symbol && members === source.symbol.members) { members = createSymbolTable(source.declaredProperties); } const thisArgument = lastOrUndefined(typeArguments); @@ -4094,26 +4096,6 @@ namespace ts { return result; } - function createTupleTypeMemberSymbols(memberTypes: Type[]): SymbolTable { - const members = createMap(); - for (let i = 0; i < memberTypes.length; i++) { - const symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "" + i); - symbol.type = memberTypes[i]; - members[i] = symbol; - } - return members; - } - - function resolveTupleTypeMembers(type: TupleType) { - const arrayElementType = getUnionType(type.elementTypes); - // Make the tuple type itself the 'this' type by including an extra type argument - // (Unless it's provided in the case that the tuple is a type parameter constraint) - const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type.thisType || type])); - const members = createTupleTypeMemberSymbols(type.elementTypes); - addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); - } - function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreThisTypes: boolean, ignoreReturnTypes: boolean): Signature { for (const s of signatureList) { if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { @@ -4292,9 +4274,6 @@ namespace ts { else if (type.flags & TypeFlags.Anonymous) { resolveAnonymousTypeMembers(type); } - else if (type.flags & TypeFlags.Tuple) { - resolveTupleTypeMembers(type); - } else if (type.flags & TypeFlags.Union) { resolveUnionTypeMembers(type); } @@ -4992,6 +4971,13 @@ namespace ts { return type; } + function cloneTypeReference(source: TypeReference): TypeReference { + let type = createObjectType(source.flags, source.symbol); + type.target = source.target; + type.typeArguments = source.typeArguments; + return type; + } + // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type { const type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); @@ -5234,17 +5220,44 @@ namespace ts { return links.resolvedType; } - function createTupleType(elementTypes: Type[], thisType?: Type) { - const id = getTypeListId(elementTypes) + "," + (thisType ? thisType.id : 0); - return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes, thisType)); + function createTupleTypeOfArity(arity: number): TupleType { + const typeParameters: TypeParameter[] = []; + const properties: Symbol[] = []; + for (let i = 0; i < arity; i++) { + const typeParameter = createType(TypeFlags.TypeParameter); + typeParameters.push(typeParameter); + const property = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "" + i); + property.type = typeParameter; + properties.push(property); + } + const type = createObjectType(TypeFlags.Tuple | TypeFlags.Reference); + type.typeParameters = typeParameters; + type.outerTypeParameters = undefined; + type.localTypeParameters = typeParameters; + type.instantiations = createMap(); + type.instantiations[getTypeListId(type.typeParameters)] = type; + type.target = type; + type.typeArguments = type.typeParameters; + type.thisType = createType(TypeFlags.TypeParameter | TypeFlags.ThisType); + type.thisType.constraint = type; + type.declaredProperties = properties; + type.declaredCallSignatures = emptyArray; + type.declaredConstructSignatures = emptyArray; + type.declaredStringIndexInfo = undefined; + type.declaredNumberIndexInfo = undefined; + return type; } - function createNewTupleType(elementTypes: Type[], thisType?: Type) { - const propagatedFlags = getPropagatingFlagsOfTypes(elementTypes, /*excludeKinds*/ 0); - const type = createObjectType(TypeFlags.Tuple | propagatedFlags); - type.elementTypes = elementTypes; - type.thisType = thisType; - return type; + function getTupleTypeOfArity(arity: number): TupleType { + return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + } + + function getTypeReferenceArity(type: TypeReference): number { + return type.target.typeParameters.length; + } + + function createTupleType(elementTypes: Type[]) { + return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); } function getTypeFromTupleTypeNode(node: TupleTypeNode): Type { @@ -5845,9 +5858,6 @@ namespace ts { if (type.flags & TypeFlags.Reference) { return createTypeReference((type).target, instantiateList((type).typeArguments, mapper, instantiateType)); } - if (type.flags & TypeFlags.Tuple) { - return createTupleType(instantiateList((type).elementTypes, mapper, instantiateType)); - } if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) { return getUnionType(instantiateList((type).types, mapper, instantiateType), /*subtypeReduction*/ false, type.aliasSymbol, mapper.targetTypes); } @@ -7168,8 +7178,8 @@ namespace ts { * Check if a Type was written as a tuple type literal. * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ - function isTupleType(type: Type): type is TupleType { - return !!(type.flags & TypeFlags.Tuple); + function isTupleType(type: Type): boolean { + return !!(type.flags & TypeFlags.Reference && (type).target.flags & TypeFlags.Tuple); } function getFalsyFlagsOfTypes(types: Type[]): TypeFlags { @@ -7301,11 +7311,8 @@ namespace ts { if (type.flags & TypeFlags.Union) { return getUnionType(map((type).types, getWidenedConstituentType)); } - if (isArrayType(type)) { - return createArrayType(getWidenedType((type).typeArguments[0])); - } - if (isTupleType(type)) { - return createTupleType(map(type.elementTypes, getWidenedType)); + if (isArrayType(type) || isTupleType(type)) { + return createTypeReference((type).target, map((type).typeArguments, getWidenedType)); } } return type; @@ -7331,11 +7338,8 @@ namespace ts { } } } - if (isArrayType(type)) { - return reportWideningErrorsInType((type).typeArguments[0]); - } - if (isTupleType(type)) { - for (const t of type.elementTypes) { + if (isArrayType(type) || isTupleType(type)) { + for (const t of (type).typeArguments) { if (reportWideningErrorsInType(t)) { errorReported = true; } @@ -7445,7 +7449,6 @@ namespace ts { function couldContainTypeParameters(type: Type): boolean { return !!(type.flags & TypeFlags.TypeParameter || type.flags & TypeFlags.Reference && forEach((type).typeArguments, couldContainTypeParameters) || - type.flags & TypeFlags.Tuple && forEach((type).elementTypes, couldContainTypeParameters) || type.flags & TypeFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) || type.flags & TypeFlags.UnionOrIntersection && couldUnionOrIntersectionContainTypeParameters(type)); } @@ -7548,14 +7551,6 @@ namespace ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (source.flags & TypeFlags.Tuple && target.flags & TypeFlags.Tuple && (source).elementTypes.length === (target).elementTypes.length) { - // If source and target are tuples of the same size, infer from element types - const sourceTypes = (source).elementTypes; - const targetTypes = (target).elementTypes; - for (let i = 0; i < sourceTypes.length; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } else if (target.flags & TypeFlags.UnionOrIntersection) { const targetTypes = (target).types; let typeParameterCount = 0; @@ -9913,7 +9908,7 @@ namespace ts { // 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] = []". if (inDestructuringPattern && elementTypes.length) { - const type = createNewTupleType(elementTypes); + const type = cloneTypeReference(createTupleType(elementTypes)); type.pattern = node; return type; } @@ -9927,7 +9922,7 @@ namespace ts { for (let i = elementTypes.length; i < patternElements.length; i++) { const patternElement = patternElements[i]; if (hasDefaultValue(patternElement)) { - elementTypes.push((contextualType).elementTypes[i]); + elementTypes.push((contextualType).typeArguments[i]); } else { if (patternElement.kind !== SyntaxKind.OmittedExpression) { @@ -13038,7 +13033,7 @@ namespace ts { // such as NodeCheckFlags.LexicalThis on "this"expression. checkExpression(element); if (isTupleType(sourceType)) { - error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), (sourceType).elementTypes.length, elements.length); + error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); } else { error(element, Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); @@ -18515,7 +18510,7 @@ namespace ts { else if (isTypeOfKind(type, TypeFlags.StringLike)) { return TypeReferenceSerializationKind.StringLikeType; } - else if (isTypeOfKind(type, TypeFlags.Tuple)) { + else if (isTupleType(type)) { return TypeReferenceSerializationKind.ArrayLikeType; } else if (isTypeOfKind(type, TypeFlags.ESSymbol)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 7594d2c3fb8..f5d71d0935b 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2385,10 +2385,7 @@ namespace ts { instantiations: Map; // Generic instantiation cache } - export interface TupleType extends ObjectType { - elementTypes: Type[]; // Element types - thisType?: Type; // This-type of tuple (only needed for tuples that are constraints of type parameters) - } + export interface TupleType extends GenericType { } export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types From 7d82c22bc376d230e5c896aeeadf2ac922c058ca Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 21 Aug 2016 16:53:34 -0700 Subject: [PATCH 228/508] Add comments + minor changes --- src/compiler/checker.ts | 25 ++++++++++++++++--------- src/compiler/types.ts | 4 +--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index d87dbd1696c..9efaf72c03a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -106,7 +106,7 @@ namespace ts { isOptionalParameter }; - const tupleTypes: TupleType[] = []; + const tupleTypes: GenericType[] = []; const unionTypes = createMap(); const intersectionTypes = createMap(); const stringLiteralTypes = createMap(); @@ -2213,7 +2213,7 @@ namespace ts { } else if (type.target.flags & TypeFlags.Tuple) { writePunctuation(writer, SyntaxKind.OpenBracketToken); - writeTypeList(type.typeArguments.slice(0, type.target.typeParameters.length), SyntaxKind.CommaToken); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), SyntaxKind.CommaToken); writePunctuation(writer, SyntaxKind.CloseBracketToken); } else { @@ -4978,6 +4978,10 @@ namespace ts { return type; } + function getTypeReferenceArity(type: TypeReference): number { + return type.target.typeParameters.length; + } + // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type { const type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); @@ -5220,7 +5224,14 @@ namespace ts { return links.resolvedType; } - function createTupleTypeOfArity(arity: number): TupleType { + // We represent tuple types as type references to synthesized generic interface types created by + // this function. The types are of the form: + // + // interface Tuple extends Array { 0: T0, 1: T1, 2: T2, ... } + // + // Note that the generic type created by this function has no symbol associated with it. The same + // is true for each of the synthesized type parameters. + function createTupleTypeOfArity(arity: number): GenericType { const typeParameters: TypeParameter[] = []; const properties: Symbol[] = []; for (let i = 0; i < arity; i++) { @@ -5230,7 +5241,7 @@ namespace ts { property.type = typeParameter; properties.push(property); } - const type = createObjectType(TypeFlags.Tuple | TypeFlags.Reference); + const type = createObjectType(TypeFlags.Tuple | TypeFlags.Reference); type.typeParameters = typeParameters; type.outerTypeParameters = undefined; type.localTypeParameters = typeParameters; @@ -5248,14 +5259,10 @@ namespace ts { return type; } - function getTupleTypeOfArity(arity: number): TupleType { + function getTupleTypeOfArity(arity: number): GenericType { return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); } - function getTypeReferenceArity(type: TypeReference): number { - return type.target.typeParameters.length; - } - function createTupleType(elementTypes: Type[]) { return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f5d71d0935b..656f155784a 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2263,7 +2263,7 @@ namespace ts { Class = 1 << 15, // Class Interface = 1 << 16, // Interface Reference = 1 << 17, // Generic type reference - Tuple = 1 << 18, // Tuple + Tuple = 1 << 18, // Synthesized generic tuple type Union = 1 << 19, // Union (T | U) Intersection = 1 << 20, // Intersection (T & U) Anonymous = 1 << 21, // Anonymous @@ -2385,8 +2385,6 @@ namespace ts { instantiations: Map; // Generic instantiation cache } - export interface TupleType extends GenericType { } - export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types /* @internal */ From 2e8d11e9c09e8ffb20ff8d8a69399f652fddc510 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sun, 21 Aug 2016 17:01:07 -0700 Subject: [PATCH 229/508] Accept new baselines --- .../arityAndOrderCompatibility01.errors.txt | 6 ++--- .../reference/arrayLiterals3.errors.txt | 6 ++--- .../reference/castingTuple.errors.txt | 16 +++++-------- .../contextualTypeWithTuple.errors.txt | 20 +++++++--------- ...TypedBindingInitializerNegative.errors.txt | 6 ++--- .../declarationsAndAssignments.errors.txt | 16 +++++-------- ...rayBindingPatternAndAssignment2.errors.txt | 6 ++--- ...tructuringParameterDeclaration2.errors.txt | 24 +++++++------------ ...structuringParameterProperties2.errors.txt | 6 ++--- ...structuringParameterProperties5.errors.txt | 10 ++++---- ...structuringVariableDeclaration2.errors.txt | 18 +++++--------- .../genericCallWithTupleType.errors.txt | 12 ++++------ .../iterableArrayPattern29.errors.txt | 6 ++--- .../optionalBindingParameters1.errors.txt | 6 ++--- ...alBindingParametersInOverloads1.errors.txt | 6 ++--- .../baselines/reference/tupleTypes.errors.txt | 18 +++++--------- 16 files changed, 64 insertions(+), 118 deletions(-) diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt index d60f0b7d03c..a6a685069d6 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt +++ b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt @@ -39,8 +39,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'. Property 'length' is missing in type '{ 0: string; 1: number; }'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(29,5): error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. Types of property '0' are incompatible. Type 'string' is not assignable to type 'number'. @@ -136,8 +135,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error var n1: [number, string] = x; ~~ !!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. var n2: [number, string] = y; ~~ !!! error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index 8e6c7eccf81..f221fd96fab 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -1,8 +1,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(10,5): error TS2322: Type 'undefined[]' is not assignable to type '[any, any, any]'. Property '0' is missing in type 'undefined[]'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'boolean'. + Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'. Types of property 'pop' are incompatible. Type '() => string | number | boolean' is not assignable to type '() => number'. @@ -37,8 +36,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error var a1: [boolean, string, number] = ["string", 1, true]; // Error ~~ !!! error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), diff --git a/tests/baselines/reference/castingTuple.errors.txt b/tests/baselines/reference/castingTuple.errors.txt index 6d5549c6bf2..2f9eeedf9ef 100644 --- a/tests/baselines/reference/castingTuple.errors.txt +++ b/tests/baselines/reference/castingTuple.errors.txt @@ -1,10 +1,8 @@ tests/cases/conformance/types/tuple/castingTuple.ts(28,10): error TS2352: Type '[number, string]' cannot be converted to type '[number, number]'. - Types of property '1' are incompatible. - Type 'string' is not comparable to type 'number'. + Type 'string' is not comparable to type 'number'. tests/cases/conformance/types/tuple/castingTuple.ts(29,10): error TS2352: Type '[C, D]' cannot be converted to type '[A, I]'. - Types of property '0' are incompatible. - Type 'C' is not comparable to type 'A'. - Property 'a' is missing in type 'C'. + Type 'C' is not comparable to type 'A'. + Property 'a' is missing in type 'C'. tests/cases/conformance/types/tuple/castingTuple.ts(30,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'. tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot find name 't4'. @@ -40,14 +38,12 @@ tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot var t3 = <[number, number]>numStrTuple; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2352: Type '[number, string]' cannot be converted to type '[number, number]'. -!!! error TS2352: Types of property '1' are incompatible. -!!! error TS2352: Type 'string' is not comparable to type 'number'. +!!! error TS2352: Type 'string' is not comparable to type 'number'. var t9 = <[A, I]>classCDTuple; ~~~~~~~~~~~~~~~~~~~~ !!! error TS2352: Type '[C, D]' cannot be converted to type '[A, I]'. -!!! error TS2352: Types of property '0' are incompatible. -!!! error TS2352: Type 'C' is not comparable to type 'A'. -!!! error TS2352: Property 'a' is missing in type 'C'. +!!! error TS2352: Type 'C' is not comparable to type 'A'. +!!! error TS2352: Property 'a' is missing in type 'C'. var array1 = numStrTuple; ~~~~~~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'. diff --git a/tests/baselines/reference/contextualTypeWithTuple.errors.txt b/tests/baselines/reference/contextualTypeWithTuple.errors.txt index e0580ca2379..a488d8c7648 100644 --- a/tests/baselines/reference/contextualTypeWithTuple.errors.txt +++ b/tests/baselines/reference/contextualTypeWithTuple.errors.txt @@ -5,9 +5,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS232 Type 'true' is not assignable to type 'string | number'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'. - Types of property '0' are incompatible. - Type '{}' is not assignable to type '{ a: string; }'. - Property 'a' is missing in type '{}'. + Type '{}' is not assignable to type '{ a: string; }'. + Property 'a' is missing in type '{}'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(19,1): error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'. Property '2' is missing in type '[number, string]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(20,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]'. @@ -18,9 +17,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(20,5): error TS23 tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(24,1): error TS2322: Type '[C, string | number]' is not assignable to type '[C, string | number, D]'. Property '2' is missing in type '[C, string | number]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS2322: Type '[number, string | number]' is not assignable to type '[number, string]'. - Types of property '1' are incompatible. - Type 'string | number' is not assignable to type 'string'. - Type 'number' is not assignable to type 'string'. + Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts (7 errors) ==== @@ -52,9 +50,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23 objNumTuple = [ {}, 5]; ~~~~~~~~~~~ !!! error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type '{ a: string; }'. -!!! error TS2322: Property 'a' is missing in type '{}'. +!!! error TS2322: Type '{}' is not assignable to type '{ a: string; }'. +!!! error TS2322: Property 'a' is missing in type '{}'. numStrBoolTuple = numStrTuple; ~~~~~~~~~~~~~~~ !!! error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'. @@ -76,6 +73,5 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23 numStrTuple = unionTuple3; ~~~~~~~~~~~ !!! error TS2322: Type '[number, string | number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt index 42d617887e0..447ccec5ddf 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt @@ -11,8 +11,7 @@ tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTyp tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(16,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(21,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. - Types of property '0' are incompatible. - Type 'number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(26,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. @@ -57,8 +56,7 @@ tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTyp function g({ prop = [101, 1234] }: Tuples) {} ~~~~ !!! error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. interface StringUnion { prop: "foo" | "bar"; diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 517eaafe4ab..3ed9e241c39 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -18,11 +18,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. - Types of property '1' are incompatible. - Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. - Types of property '1' are incompatible. - Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. - Property 'x' is missing in type '{ y: boolean; }'. + Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. + Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. + Property 'x' is missing in type '{ y: boolean; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. @@ -174,11 +172,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): f14([2, ["abc", { y: false }]]); // Error, no x ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. -!!! error TS2345: Types of property '1' are incompatible. -!!! error TS2345: Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. -!!! error TS2345: Types of property '1' are incompatible. -!!! error TS2345: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. -!!! error TS2345: Property 'x' is missing in type '{ y: boolean; }'. +!!! error TS2345: Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. +!!! error TS2345: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. +!!! error TS2345: Property 'x' is missing in type '{ y: boolean; }'. module M { export var [a, b] = [1, 2]; diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index 3348effe822..e22b23122d3 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -2,8 +2,7 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. - Types of property '1' are incompatible. - Type 'number' is not assignable to type 'boolean'. + Type 'number' is not assignable to type 'boolean'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'. Property '0' is missing in type 'number[]'. @@ -30,8 +29,7 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"]; // Error ~~~~~~~~~~~~ !!! error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. interface J extends Array { 2: number; } diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 878bb38abf0..d76a4efe5f1 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -1,6 +1,5 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,4): error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. - Types of property '1' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,29): error TS1005: ',' expected. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(8,4): error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. Types of property 'pop' are incompatible. @@ -32,12 +31,9 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( Types of property '2' are incompatible. Type 'boolean' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,4): error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'. - Types of property '2' are incompatible. - Type '[[string]]' is not assignable to type '[[number]]'. - Types of property '0' are incompatible. - Type '[string]' is not assignable to type '[number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Type '[[string]]' is not assignable to type '[[number]]'. + Type '[string]' is not assignable to type '[number]'. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(46,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(47,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(55,7): error TS2420: Class 'C4' incorrectly implements interface 'F2'. @@ -62,8 +58,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( a0([1, "string", [["world"]]); // Error ~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. -!!! error TS2345: Types of property '1' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. ~ !!! error TS1005: ',' expected. a0([1, 2, [["world"]], "string"]); // Error @@ -142,12 +137,9 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer ~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type '[[string]]' is not assignable to type '[[number]]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type '[string]' is not assignable to type '[number]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2345: Type '[[string]]' is not assignable to type '[[number]]'. +!!! error TS2345: Type '[string]' is not assignable to type '[number]'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. // A parameter can be marked optional by following its name or binding pattern with a question mark (?) // or by including an initializer. Initializers (including binding property or element initializers) are diff --git a/tests/baselines/reference/destructuringParameterProperties2.errors.txt b/tests/baselines/reference/destructuringParameterProperties2.errors.txt index ec0f400631f..deb039aa67d 100644 --- a/tests/baselines/reference/destructuringParameterProperties2.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties2.errors.txt @@ -6,8 +6,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9 tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. - Types of property '2' are incompatible. - Type 'string' is not assignable to type 'boolean'. + Type 'string' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ==== @@ -48,8 +47,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2 var x = new C1(undefined, [0, undefined, ""]); ~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. +!!! error TS2345: Type 'string' is not assignable to type 'boolean'. var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; var y = new C1(10, [0, "", true]); diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index 6f5801b7898..8eff6ad0feb 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -8,9 +8,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7 tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. - Types of property '0' are incompatible. - Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. - Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. + Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. + Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ==== @@ -45,7 +44,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); ~~~~~~ !!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. -!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. +!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. +!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt index 1a655837743..bdbda6f9a96 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt @@ -2,12 +2,9 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3 Types of property 'a1' are incompatible. Type 'boolean' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,5): error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'. - Types of property '1' are incompatible. - Type '[[boolean]]' is not assignable to type '[[string]]'. - Types of property '0' are incompatible. - Type '[boolean]' is not assignable to type '[string]'. - Types of property '0' are incompatible. - Type 'boolean' is not assignable to type 'string'. + Type '[[boolean]]' is not assignable to type '[[string]]'. + Type '[boolean]' is not assignable to type '[string]'. + Type 'boolean' is not assignable to type 'string'. tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(9,25): error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'. Types of property 't2' are incompatible. Type 'string' is not assignable to type 'number'. @@ -28,12 +25,9 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(1 var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error ~~~~~~~~~~~~~~~~ !!! error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type '[[boolean]]' is not assignable to type '[[string]]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '[boolean]' is not assignable to type '[string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. +!!! error TS2322: Type '[[boolean]]' is not assignable to type '[[string]]'. +!!! error TS2322: Type '[boolean]' is not assignable to type '[string]'. +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index 0194dc61311..617c4f7159b 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -6,11 +6,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,1): error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'. Type '{ a: string; }' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. - Types of property '0' are incompatible. - Type 'number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. - Types of property '0' are incompatible. - Type '{}' is not assignable to type 'string'. + Type '{}' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(24,1): error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. Property '1' is missing in type '[{}]'. @@ -49,13 +47,11 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup i1.tuple1 = [5, "foo"]; ~~~~~~~~~ !!! error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. i1.tuple1 = [{}, {}]; ~~~~~~~~~ !!! error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type '{}' is not assignable to type 'string'. i2.tuple1 = [{}]; ~~~~~~~~~ !!! error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. diff --git a/tests/baselines/reference/iterableArrayPattern29.errors.txt b/tests/baselines/reference/iterableArrayPattern29.errors.txt index b34d0317d57..29e5d0d2a3f 100644 --- a/tests/baselines/reference/iterableArrayPattern29.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern29.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(2,21): error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'. - Types of property '1' are incompatible. - Type 'boolean' is not assignable to type 'number'. + Type 'boolean' is not assignable to type 'number'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts (2 errors) ==== @@ -11,5 +10,4 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(2,21): error takeFirstTwoEntries(...new Map([["", true], ["hello", true]])); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'. -!!! error TS2345: Types of property '1' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2345: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParameters1.errors.txt b/tests/baselines/reference/optionalBindingParameters1.errors.txt index 78fc1cbddf1..0780c626baf 100644 --- a/tests/baselines/reference/optionalBindingParameters1.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters1.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(2,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. - Types of property '0' are incompatible. - Type 'boolean' is not assignable to type 'string'. + Type 'boolean' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (2 errors) ==== @@ -17,5 +16,4 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): er foo([false, 0, ""]); ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt index 312603d2c2e..30ec4037c88 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt +++ b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt @@ -1,6 +1,5 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(9,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. - Types of property '0' are incompatible. - Type 'boolean' is not assignable to type 'string'. + Type 'boolean' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (1 errors) ==== @@ -15,5 +14,4 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1. foo([false, 0, ""]); ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/tupleTypes.errors.txt b/tests/baselines/reference/tupleTypes.errors.txt index 75f413eb170..3b55476e4b1 100644 --- a/tests/baselines/reference/tupleTypes.errors.txt +++ b/tests/baselines/reference/tupleTypes.errors.txt @@ -4,8 +4,7 @@ tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type 'undefined[]' is no tests/cases/compiler/tupleTypes.ts(15,1): error TS2322: Type '[number]' is not assignable to type '[number, string]'. Property '1' is missing in type '[number]'. tests/cases/compiler/tupleTypes.ts(17,1): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(41,1): error TS2322: Type 'undefined[]' is not assignable to type '[number, string]'. tests/cases/compiler/tupleTypes.ts(47,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'. Types of property 'pop' are incompatible. @@ -18,11 +17,9 @@ tests/cases/compiler/tupleTypes.ts(49,1): error TS2322: Type '[number, {}]' is n Type 'number | {}' is not assignable to type 'number'. Type '{}' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(50,1): error TS2322: Type '[number, number]' is not assignable to type '[number, string]'. - Types of property '1' are incompatible. - Type 'number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is not assignable to type '[number, string]'. - Types of property '1' are incompatible. - Type '{}' is not assignable to type 'string'. + Type '{}' is not assignable to type 'string'. ==== tests/cases/compiler/tupleTypes.ts (9 errors) ==== @@ -53,8 +50,7 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n t = ["hello", 1]; // Error ~ !!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. t = [1, "hello", 2]; // Ok var tf: [string, (x: string) => number] = ["hello", x => x.length]; @@ -104,13 +100,11 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n a1 = a2; // Error ~~ !!! error TS2322: Type '[number, number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. a1 = a3; // Error ~~ !!! error TS2322: Type '[number, {}]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type '{}' is not assignable to type 'string'. a3 = a1; a3 = a2; \ No newline at end of file From d6aa65daf10c1cf317591301bb24156ca079f3fd Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 22 Aug 2016 06:16:18 -0700 Subject: [PATCH 230/508] Use unordered removal where possible --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 20 ++++++++++++------- src/compiler/sys.ts | 2 +- src/compiler/tsc.ts | 2 +- src/harness/harness.ts | 2 +- .../unittests/tsserverProjectSystem.ts | 6 +++--- src/server/editorServices.ts | 12 +++++------ 7 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index abae979a25d..e18ce2efeeb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5336,7 +5336,7 @@ namespace ts { while (i > 0) { i--; if (isSubtypeOfAny(types[i], types)) { - removeItemAt(types, i); + removeItemAtPreservingOrder(types, i); } } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index dd4ba822243..73c92eff547 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1395,7 +1395,7 @@ namespace ts { } /** Remove an item from an array, moving everything to its right one space left. */ - export function removeItemAt(array: T[], index: number): void { + export function removeItemAtPreservingOrder(array: T[], index: number): void { // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. for (let i = index; i < array.length - 1; i++) { array[i] = array[i + 1]; @@ -1403,23 +1403,29 @@ namespace ts { array.pop(); } + export function unorderedRemoveItemAt(array: T[], index: number): void { + // Fill in the "hole" left at `index`. + array[index] = array[array.length - 1]; + array.pop(); + } + /** Remove the *first* occurrence of `item` from the array. */ - export function removeItem(item: T, array: T[]): void { - removeFirstItemWhere(array, element => element === item); + export function unorderedRemoveItem(item: T, array: T[]): void { + unorderedRemoveFirstItemWhere(array, element => element === item); } /** Remove the *first* element satisfying `predicate`. */ - export function removeFirstItemWhere(array: T[], predicate: (element: T) => boolean): void { + export function unorderedRemoveFirstItemWhere(array: T[], predicate: (element: T) => boolean): void { for (let i = 0; i < array.length; i++) { if (predicate(array[i])) { - removeItemAt(array, i); + unorderedRemoveItemAt(array, i); break; } } } - export function createGetCanonicalFileName(useCaseSensitivefileNames: boolean): (fileName: string) => string { - return useCaseSensitivefileNames + export function createGetCanonicalFileName(useCaseSensitiveFileNames: boolean): (fileName: string) => string { + return useCaseSensitiveFileNames ? ((fileName) => fileName) : ((fileName) => fileName.toLowerCase()); } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 7953a2f42e8..966a282ae62 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -285,7 +285,7 @@ namespace ts { function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) { const callbacks = fileWatcherCallbacks[filePath]; if (callbacks) { - removeItem(callback, callbacks); + unorderedRemoveItem(callback, callbacks); if (callbacks.length === 0) { delete fileWatcherCallbacks[filePath]; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 02a97c01132..bd3f88676bc 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -490,7 +490,7 @@ namespace ts { sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; if (removed) { - removeItem(sourceFile.fileName, rootFileNames); + unorderedRemoveItem(sourceFile.fileName, rootFileNames); } startTimerForRecompilation(); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 3b36381146f..634c159dbb8 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1558,7 +1558,7 @@ namespace Harness { tsConfig.options.configFilePath = data.name; // delete entry from the list - ts.removeItemAt(testUnitData, i); + ts.removeItemAtPreservingOrder(testUnitData, i); break; } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index cd87164245a..b02e4d81cd3 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -214,7 +214,7 @@ namespace ts { referenceCount: 0, directoryName, close: () => { - removeFirstItemWhere(callbacks, cb => cb.cb === callback); + unorderedRemoveFirstItemWhere(callbacks, cb => cb.cb === callback); if (!callbacks.length) { delete this.watchedDirectories[path]; } @@ -248,7 +248,7 @@ namespace ts { callbacks.push(callback); return { close: () => { - removeItem(callback, callbacks); + unorderedRemoveItem(callback, callbacks); if (!callbacks.length) { delete this.watchedFiles[path]; } @@ -263,7 +263,7 @@ namespace ts { }; readonly clearTimeout = (timeoutId: any): void => { if (typeof timeoutId === "number") { - removeItemAt(this.callbackQueue, timeoutId); + unorderedRemoveItemAt(this.callbackQueue, timeoutId); } }; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 0a12bf68d79..0aa10819c49 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -275,7 +275,7 @@ namespace ts.server { removeRoot(info: ScriptInfo) { if (this.filenameToScript.contains(info.path)) { this.filenameToScript.remove(info.path); - removeItem(info, this.roots); + unorderedRemoveItem(info, this.roots); this.resolvedModuleNames.remove(info.path); this.resolvedTypeReferenceDirectives.remove(info.path); } @@ -849,7 +849,7 @@ namespace ts.server { project.directoryWatcher.close(); forEachValue(project.directoriesWatchedForWildcards, watcher => { watcher.close(); }); delete project.directoriesWatchedForWildcards; - removeItem(project, this.configuredProjects); + unorderedRemoveItem(project, this.configuredProjects); } else { for (const directory of project.directoriesWatchedForTsconfig) { @@ -861,7 +861,7 @@ namespace ts.server { delete project.projectService.directoryWatchersForTsconfig[directory]; } } - removeItem(project, this.inferredProjects); + unorderedRemoveItem(project, this.inferredProjects); } const fileNames = project.getFileNames(); @@ -986,7 +986,7 @@ namespace ts.server { } } else { - removeItem(info, this.openFilesReferenced); + unorderedRemoveItem(info, this.openFilesReferenced); } info.close(); } @@ -1496,13 +1496,13 @@ namespace ts.server { // openFileRoots or openFileReferenced. if (info.isOpen) { if (this.openFileRoots.indexOf(info) >= 0) { - removeItem(info, this.openFileRoots); + unorderedRemoveItem(info, this.openFileRoots); if (info.defaultProject && !info.defaultProject.isConfiguredProject()) { this.removeProject(info.defaultProject); } } if (this.openFilesReferenced.indexOf(info) >= 0) { - removeItem(info, this.openFilesReferenced); + unorderedRemoveItem(info, this.openFilesReferenced); } this.openFileRootsConfigured.push(info); info.defaultProject = project; From e3a1a981136df47e0fea12aebc36d1ba409d7a9a Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 22 Aug 2016 06:30:41 -0700 Subject: [PATCH 231/508] Remove last external use of `unorderedRemoveFirstItemWhere` --- src/compiler/core.ts | 2 +- src/harness/unittests/tsserverProjectSystem.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 73c92eff547..834f451df80 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1415,7 +1415,7 @@ namespace ts { } /** Remove the *first* element satisfying `predicate`. */ - export function unorderedRemoveFirstItemWhere(array: T[], predicate: (element: T) => boolean): void { + function unorderedRemoveFirstItemWhere(array: T[], predicate: (element: T) => boolean): void { for (let i = 0; i < array.length; i++) { if (predicate(array[i])) { unorderedRemoveItemAt(array, i); diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index b02e4d81cd3..0c491ad349e 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -209,12 +209,13 @@ namespace ts { watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher { const path = this.toPath(directoryName); const callbacks = lookUp(this.watchedDirectories, path) || (this.watchedDirectories[path] = []); - callbacks.push({ cb: callback, recursive }); + const cbWithRecursive = { cb: callback, recursive }; + callbacks.push(cbWithRecursive); return { referenceCount: 0, directoryName, close: () => { - unorderedRemoveFirstItemWhere(callbacks, cb => cb.cb === callback); + unorderedRemoveItem(cbWithRecursive, callbacks); if (!callbacks.length) { delete this.watchedDirectories[path]; } From 05fef61e75a1d35c228b40e3096209118819dd66 Mon Sep 17 00:00:00 2001 From: Kanchalai Tanglertsampan Date: Mon, 22 Aug 2016 09:15:05 -0700 Subject: [PATCH 232/508] Add .types extension --- src/harness/rwcRunner.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index d56e8d6d35f..ba1ab71ec19 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -158,13 +158,13 @@ namespace RWC { it("has the expected emitted code", () => { - Harness.Baseline.runBaseline(baseName + ".output.js", () => { + Harness.Baseline.runBaseline(`${baseName}.output.js`, () => { return Harness.Compiler.collateOutputs(compilerResult.files); }, baselineOpts); }); it("has the expected declaration file content", () => { - Harness.Baseline.runBaseline(baseName + ".d.ts", () => { + Harness.Baseline.runBaseline(`${baseName}.d.ts`, () => { if (!compilerResult.declFilesCode.length) { return null; } @@ -174,7 +174,7 @@ namespace RWC { }); it("has the expected source maps", () => { - Harness.Baseline.runBaseline(baseName + ".map", () => { + Harness.Baseline.runBaseline(`${baseName}.map`, () => { if (!compilerResult.sourceMaps.length) { return null; } @@ -192,7 +192,7 @@ namespace RWC { });*/ it("has the expected errors", () => { - Harness.Baseline.runBaseline(baseName + ".errors.txt", () => { + Harness.Baseline.runBaseline(`${baseName}.errors.txt`, () => { if (compilerResult.errors.length === 0) { return null; } @@ -207,7 +207,7 @@ namespace RWC { // declaration file errors as part of the baseline. it("has the expected errors in generated declaration files", () => { if (compilerOptions.declaration && !compilerResult.errors.length) { - Harness.Baseline.runBaseline(baseName + ".dts.errors.txt", () => { + Harness.Baseline.runBaseline(`${baseName}.dts.errors.txt`, () => { const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles( inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory); @@ -223,7 +223,7 @@ namespace RWC { }); it("has the expected types", () => { - Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles + Harness.Compiler.doTypeAndSymbolBaseline(`${baseName}.types`, compilerResult, inputFiles .concat(otherFiles) .filter(file => !!compilerResult.program.getSourceFile(file.unitName)) .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts); From 4e56fc0d272e39706ea98bdff0ded79dc70ca1d6 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 22 Aug 2016 09:49:26 -0700 Subject: [PATCH 233/508] Properly guard for undefined in getTypeReferenceArity --- 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 9efaf72c03a..3abf271a57b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4979,7 +4979,7 @@ namespace ts { } function getTypeReferenceArity(type: TypeReference): number { - return type.target.typeParameters.length; + return type.target.typeParameters ? type.target.typeParameters.length : 0; } // Get type from reference to class or interface From 2c814f4413cbc83a88c711823b0aea5125e8d343 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 22 Aug 2016 10:08:57 -0700 Subject: [PATCH 234/508] Add jsdoc nullable union test case to fourslash --- tests/cases/fourslash/jsdocNullableUnion.ts | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/cases/fourslash/jsdocNullableUnion.ts diff --git a/tests/cases/fourslash/jsdocNullableUnion.ts b/tests/cases/fourslash/jsdocNullableUnion.ts new file mode 100644 index 00000000000..19dc9818d69 --- /dev/null +++ b/tests/cases/fourslash/jsdocNullableUnion.ts @@ -0,0 +1,23 @@ +/// +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// +//// * @param {never | {x: string}} p1 +//// * @param {undefined | {y: number}} p2 +//// * @param {null | {z: boolean}} p3 +//// * @returns {void} nothing +//// */ +////function f(p1, p2, p3) { +//// p1./*1*/ +//// p2./*2*/ +//// p3./*3*/ +////} + +goTo.marker('1'); +verify.memberListContains("x"); + +goTo.marker('2'); +verify.memberListContains("y"); + +goTo.marker('3'); +verify.memberListContains("z"); From 201305859f9a9a9fc7e93de59238e647c49ced51 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Mon, 22 Aug 2016 11:21:06 -0700 Subject: [PATCH 235/508] Fix class/interface merging issue + lint error --- src/compiler/checker.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3abf271a57b..418f5e40a89 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3564,11 +3564,13 @@ namespace ts { if (type.flags & TypeFlags.Tuple) { type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; } - else if (type.symbol.flags & SymbolFlags.Class) { - resolveBaseTypesOfClass(type); - } - else if (type.symbol.flags & SymbolFlags.Interface) { - resolveBaseTypesOfInterface(type); + else if (type.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + if (type.symbol.flags & SymbolFlags.Class) { + resolveBaseTypesOfClass(type); + } + if (type.symbol.flags & SymbolFlags.Interface) { + resolveBaseTypesOfInterface(type); + } } else { Debug.fail("type must be class or interface"); @@ -4972,7 +4974,7 @@ namespace ts { } function cloneTypeReference(source: TypeReference): TypeReference { - let type = createObjectType(source.flags, source.symbol); + const type = createObjectType(source.flags, source.symbol); type.target = source.target; type.typeArguments = source.typeArguments; return type; From 92eb8df68cd264cce733d6ad43ef2680f3f6ffcc Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 22 Aug 2016 13:03:49 -0700 Subject: [PATCH 236/508] Allow "typings" in a package.json to be missing its extension (but also allow it to have an extension) --- src/compiler/program.ts | 5 +- tests/baselines/reference/typingsLookup4.js | 36 +++++++ .../reference/typingsLookup4.symbols | 27 ++++++ .../reference/typingsLookup4.trace.json | 93 +++++++++++++++++++ .../baselines/reference/typingsLookup4.types | 30 ++++++ .../conformance/typings/typingsLookup4.ts | 31 +++++++ 6 files changed, 220 insertions(+), 2 deletions(-) create mode 100644 tests/baselines/reference/typingsLookup4.js create mode 100644 tests/baselines/reference/typingsLookup4.symbols create mode 100644 tests/baselines/reference/typingsLookup4.trace.json create mode 100644 tests/baselines/reference/typingsLookup4.types create mode 100644 tests/cases/conformance/typings/typingsLookup4.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index afd2ddad9e1..f099d858119 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -720,8 +720,9 @@ namespace ts { const typesFile = tryReadTypesSection(packageJsonPath, candidate, state); if (typesFile) { const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(typesFile), state.host); - // The package.json "typings" property must specify the file with extension, so just try that exact filename. - const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state); + // A package.json "typings" may specify an exact filename, or may choose to omit an extension. + const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures, state); if (result) { return result; } diff --git a/tests/baselines/reference/typingsLookup4.js b/tests/baselines/reference/typingsLookup4.js new file mode 100644 index 00000000000..c11bc13c613 --- /dev/null +++ b/tests/baselines/reference/typingsLookup4.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/typings/typingsLookup4.ts] //// + +//// [package.json] +{ "typings": "jquery.d.ts" } + +//// [jquery.d.ts] +export const j: number; + +//// [package.json] +{ "typings": "kquery" } + +//// [kquery.d.ts] +export const k: number; + +//// [package.json] +{ "typings": "lquery" } + +//// [lquery.ts] +export const l = 2; + +//// [a.ts] +import { j } from "jquery"; +import { k } from "kquery"; +import { l } from "lquery"; +j + k + l; + + +//// [lquery.js] +"use strict"; +exports.l = 2; +//// [a.js] +"use strict"; +var jquery_1 = require("jquery"); +var kquery_1 = require("kquery"); +var lquery_1 = require("lquery"); +jquery_1.j + kquery_1.k + lquery_1.l; diff --git a/tests/baselines/reference/typingsLookup4.symbols b/tests/baselines/reference/typingsLookup4.symbols new file mode 100644 index 00000000000..144548c6452 --- /dev/null +++ b/tests/baselines/reference/typingsLookup4.symbols @@ -0,0 +1,27 @@ +=== /a.ts === +import { j } from "jquery"; +>j : Symbol(j, Decl(a.ts, 0, 8)) + +import { k } from "kquery"; +>k : Symbol(k, Decl(a.ts, 1, 8)) + +import { l } from "lquery"; +>l : Symbol(l, Decl(a.ts, 2, 8)) + +j + k + l; +>j : Symbol(j, Decl(a.ts, 0, 8)) +>k : Symbol(k, Decl(a.ts, 1, 8)) +>l : Symbol(l, Decl(a.ts, 2, 8)) + +=== /node_modules/@types/jquery/jquery.d.ts === +export const j: number; +>j : Symbol(j, Decl(jquery.d.ts, 0, 12)) + +=== /node_modules/@types/kquery/kquery.d.ts === +export const k: number; +>k : Symbol(k, Decl(kquery.d.ts, 0, 12)) + +=== /node_modules/@types/lquery/lquery.ts === +export const l = 2; +>l : Symbol(l, Decl(lquery.ts, 0, 12)) + diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json new file mode 100644 index 00000000000..4bca8456f58 --- /dev/null +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -0,0 +1,93 @@ +[ + "======== Resolving module 'jquery' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'jquery' from 'node_modules' folder.", + "File '/node_modules/jquery.ts' does not exist.", + "File '/node_modules/jquery.tsx' does not exist.", + "File '/node_modules/jquery.d.ts' does not exist.", + "File '/node_modules/jquery/package.json' does not exist.", + "File '/node_modules/jquery/index.ts' does not exist.", + "File '/node_modules/jquery/index.tsx' does not exist.", + "File '/node_modules/jquery/index.d.ts' does not exist.", + "File '/node_modules/@types/jquery.ts' does not exist.", + "File '/node_modules/@types/jquery.tsx' does not exist.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", + "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", + "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'", + "======== Module name 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts'. ========", + "======== Resolving module 'kquery' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'kquery' from 'node_modules' folder.", + "File '/node_modules/kquery.ts' does not exist.", + "File '/node_modules/kquery.tsx' does not exist.", + "File '/node_modules/kquery.d.ts' does not exist.", + "File '/node_modules/kquery/package.json' does not exist.", + "File '/node_modules/kquery/index.ts' does not exist.", + "File '/node_modules/kquery/index.tsx' does not exist.", + "File '/node_modules/kquery/index.d.ts' does not exist.", + "File '/node_modules/@types/kquery.ts' does not exist.", + "File '/node_modules/@types/kquery.tsx' does not exist.", + "File '/node_modules/@types/kquery.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", + "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", + "File '/node_modules/@types/kquery/kquery' does not exist.", + "File '/node_modules/@types/kquery/kquery.ts' does not exist.", + "File '/node_modules/@types/kquery/kquery.tsx' does not exist.", + "File '/node_modules/@types/kquery/kquery.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/kquery/kquery.d.ts', result '/node_modules/@types/kquery/kquery.d.ts'", + "======== Module name 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts'. ========", + "======== Resolving module 'lquery' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'lquery' from 'node_modules' folder.", + "File '/node_modules/lquery.ts' does not exist.", + "File '/node_modules/lquery.tsx' does not exist.", + "File '/node_modules/lquery.d.ts' does not exist.", + "File '/node_modules/lquery/package.json' does not exist.", + "File '/node_modules/lquery/index.ts' does not exist.", + "File '/node_modules/lquery/index.tsx' does not exist.", + "File '/node_modules/lquery/index.d.ts' does not exist.", + "File '/node_modules/@types/lquery.ts' does not exist.", + "File '/node_modules/@types/lquery.tsx' does not exist.", + "File '/node_modules/@types/lquery.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", + "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", + "File '/node_modules/@types/lquery/lquery' does not exist.", + "File '/node_modules/@types/lquery/lquery.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/lquery/lquery.ts', result '/node_modules/@types/lquery/lquery.ts'", + "======== Module name 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts'. ========", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", + "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", + "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts', primary: true. ========", + "======== Resolving type reference directive 'kquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", + "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", + "File '/node_modules/@types/kquery/kquery' does not exist.", + "File '/node_modules/@types/kquery/kquery.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts', primary: true. ========", + "======== Resolving type reference directive 'lquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", + "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", + "File '/node_modules/@types/lquery/lquery' does not exist.", + "File '/node_modules/@types/lquery/lquery.d.ts' does not exist.", + "File '/node_modules/@types/lquery/index.d.ts' does not exist.", + "Looking up in 'node_modules' folder, initial location '/'", + "File '/node_modules/lquery.ts' does not exist.", + "File '/node_modules/lquery.d.ts' does not exist.", + "File '/node_modules/lquery/package.json' does not exist.", + "File '/node_modules/lquery/index.ts' does not exist.", + "File '/node_modules/lquery/index.d.ts' does not exist.", + "File '/node_modules/@types/lquery.ts' does not exist.", + "File '/node_modules/@types/lquery.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", + "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", + "File '/node_modules/@types/lquery/lquery' does not exist.", + "File '/node_modules/@types/lquery/lquery.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts', primary: false. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup4.types b/tests/baselines/reference/typingsLookup4.types new file mode 100644 index 00000000000..d922c7b1dfa --- /dev/null +++ b/tests/baselines/reference/typingsLookup4.types @@ -0,0 +1,30 @@ +=== /a.ts === +import { j } from "jquery"; +>j : number + +import { k } from "kquery"; +>k : number + +import { l } from "lquery"; +>l : number + +j + k + l; +>j + k + l : number +>j + k : number +>j : number +>k : number +>l : number + +=== /node_modules/@types/jquery/jquery.d.ts === +export const j: number; +>j : number + +=== /node_modules/@types/kquery/kquery.d.ts === +export const k: number; +>k : number + +=== /node_modules/@types/lquery/lquery.ts === +export const l = 2; +>l : number +>2 : number + diff --git a/tests/cases/conformance/typings/typingsLookup4.ts b/tests/cases/conformance/typings/typingsLookup4.ts new file mode 100644 index 00000000000..234090aebad --- /dev/null +++ b/tests/cases/conformance/typings/typingsLookup4.ts @@ -0,0 +1,31 @@ +// @traceResolution: true +// @noImplicitReferences: true +// @currentDirectory: / +// A file extension is optional in typings entries. + +// @filename: /tsconfig.json +{} + +// @filename: /node_modules/@types/jquery/package.json +{ "typings": "jquery.d.ts" } + +// @filename: /node_modules/@types/jquery/jquery.d.ts +export const j: number; + +// @filename: /node_modules/@types/kquery/package.json +{ "typings": "kquery" } + +// @filename: /node_modules/@types/kquery/kquery.d.ts +export const k: number; + +// @filename: /node_modules/@types/lquery/package.json +{ "typings": "lquery" } + +// @filename: /node_modules/@types/lquery/lquery.ts +export const l = 2; + +// @filename: /a.ts +import { j } from "jquery"; +import { k } from "kquery"; +import { l } from "lquery"; +j + k + l; From 111e50921c20c120bb123945f84949365e020eb3 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 22 Aug 2016 13:57:40 -0700 Subject: [PATCH 237/508] Go to Implementation --- src/compiler/checker.ts | 3 +- src/compiler/types.ts | 1 + src/compiler/utilities.ts | 5 + src/harness/fourslash.ts | 62 +++ src/harness/harnessLanguageService.ts | 3 + src/server/client.ts | 22 + src/server/protocol.d.ts | 15 + src/server/session.ts | 27 + src/services/services.ts | 486 ++++++++++++++++-- src/services/shims.ts | 19 + tests/cases/fourslash/fourslash.ts | 3 + .../goToImplementationClassMethod_00.ts | 12 + .../goToImplementationClassMethod_01.ts | 21 + .../fourslash/goToImplementationEnum_00.ts | 13 + .../fourslash/goToImplementationEnum_01.ts | 13 + .../goToImplementationInterfaceMethod_00.ts | 27 + .../goToImplementationInterfaceMethod_01.ts | 25 + .../goToImplementationInterfaceMethod_02.ts | 25 + .../goToImplementationInterfaceMethod_03.ts | 25 + .../goToImplementationInterfaceMethod_04.ts | 26 + .../goToImplementationInterfaceMethod_05.ts | 38 ++ .../goToImplementationInterfaceMethod_06.ts | 49 ++ .../goToImplementationInterfaceMethod_08.ts | 23 + .../goToImplementationInterfaceMethod_09.ts | 30 ++ .../goToImplementationInterfaceMethod_10.ts | 36 ++ .../goToImplementationInterfaceMethod_11.ts | 36 ++ .../goToImplementationInterfaceMethod_12.ts | 12 + .../goToImplementationInterfaceProperty_00.ts | 23 + .../goToImplementationInterfaceProperty_01.ts | 16 + .../goToImplementationInterface_00.ts | 26 + .../goToImplementationInterface_01.ts | 25 + .../goToImplementationInterface_02.ts | 20 + .../goToImplementationInterface_03.ts | 10 + .../goToImplementationInterface_04.ts | 22 + .../goToImplementationInterface_05.ts | 14 + .../goToImplementationInterface_06.ts | 16 + .../fourslash/goToImplementationInvalid.ts | 12 + .../fourslash/goToImplementationLocal_00.ts | 9 + .../fourslash/goToImplementationLocal_01.ts | 9 + .../fourslash/goToImplementationLocal_02.ts | 8 + .../fourslash/goToImplementationLocal_03.ts | 12 + .../fourslash/goToImplementationLocal_04.ts | 10 + .../fourslash/goToImplementationLocal_05.ts | 12 + .../goToImplementationNamespace_00.ts | 12 + .../goToImplementationNamespace_01.ts | 12 + .../goToImplementationNamespace_02.ts | 12 + .../goToImplementationNamespace_03.ts | 12 + .../goToImplementationNamespace_04.ts | 26 + .../goToImplementationNamespace_05.ts | 26 + .../goToImplementationNamespace_06.ts | 28 + .../goToImplementationNamespace_07.ts | 28 + ...mentationShorthandPropertyAssignment_00.ts | 43 ++ ...mentationShorthandPropertyAssignment_01.ts | 48 ++ ...mentationShorthandPropertyAssignment_02.ts | 22 + .../fourslash/goToImplementationSuper_00.ts | 16 + .../fourslash/goToImplementationSuper_01.ts | 16 + .../fourslash/goToImplementationThis_00.ts | 14 + .../fourslash/goToImplementationThis_01.ts | 12 + .../fourslash/server/implementation01.ts | 9 + .../shims-pp/getImplementationAtPosition.ts | 35 ++ .../shims/getImplementationAtPosition.ts | 35 ++ 61 files changed, 1674 insertions(+), 33 deletions(-) create mode 100644 tests/cases/fourslash/goToImplementationClassMethod_00.ts create mode 100644 tests/cases/fourslash/goToImplementationClassMethod_01.ts create mode 100644 tests/cases/fourslash/goToImplementationEnum_00.ts create mode 100644 tests/cases/fourslash/goToImplementationEnum_01.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_00.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_01.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_03.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_12.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceProperty_00.ts create mode 100644 tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts create mode 100644 tests/cases/fourslash/goToImplementationInterface_00.ts create mode 100644 tests/cases/fourslash/goToImplementationInterface_01.ts create mode 100644 tests/cases/fourslash/goToImplementationInterface_02.ts create mode 100644 tests/cases/fourslash/goToImplementationInterface_03.ts create mode 100644 tests/cases/fourslash/goToImplementationInterface_04.ts create mode 100644 tests/cases/fourslash/goToImplementationInterface_05.ts create mode 100644 tests/cases/fourslash/goToImplementationInterface_06.ts create mode 100644 tests/cases/fourslash/goToImplementationInvalid.ts create mode 100644 tests/cases/fourslash/goToImplementationLocal_00.ts create mode 100644 tests/cases/fourslash/goToImplementationLocal_01.ts create mode 100644 tests/cases/fourslash/goToImplementationLocal_02.ts create mode 100644 tests/cases/fourslash/goToImplementationLocal_03.ts create mode 100644 tests/cases/fourslash/goToImplementationLocal_04.ts create mode 100644 tests/cases/fourslash/goToImplementationLocal_05.ts create mode 100644 tests/cases/fourslash/goToImplementationNamespace_00.ts create mode 100644 tests/cases/fourslash/goToImplementationNamespace_01.ts create mode 100644 tests/cases/fourslash/goToImplementationNamespace_02.ts create mode 100644 tests/cases/fourslash/goToImplementationNamespace_03.ts create mode 100644 tests/cases/fourslash/goToImplementationNamespace_04.ts create mode 100644 tests/cases/fourslash/goToImplementationNamespace_05.ts create mode 100644 tests/cases/fourslash/goToImplementationNamespace_06.ts create mode 100644 tests/cases/fourslash/goToImplementationNamespace_07.ts create mode 100644 tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_00.ts create mode 100644 tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts create mode 100644 tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts create mode 100644 tests/cases/fourslash/goToImplementationSuper_00.ts create mode 100644 tests/cases/fourslash/goToImplementationSuper_01.ts create mode 100644 tests/cases/fourslash/goToImplementationThis_00.ts create mode 100644 tests/cases/fourslash/goToImplementationThis_01.ts create mode 100644 tests/cases/fourslash/server/implementation01.ts create mode 100644 tests/cases/fourslash/shims-pp/getImplementationAtPosition.ts create mode 100644 tests/cases/fourslash/shims/getImplementationAtPosition.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 193deded4c5..f7ce30fe4f3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -103,7 +103,8 @@ namespace ts { getJsxElementAttributesType, getJsxIntrinsicTagNames, - isOptionalParameter + isOptionalParameter, + isTypeAssignableTo }; const tupleTypes = createMap(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a61d4a360b3..adfde2d0605 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1889,6 +1889,7 @@ namespace ts { getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; + isTypeAssignableTo(source: Type, target: Type): boolean; // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 870df4a54af..35dea56cf0b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1669,6 +1669,11 @@ namespace ts { return false; } + export function isFunctionDeclarationIdentifierName(node: Identifier): boolean { + return node.parent.kind === SyntaxKind.FunctionDeclaration && + (node.parent).name === node; + } + // An alias symbol is created by one of the following declarations: // import = ... // import from ... diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 63731417f48..27baabf652a 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1604,6 +1604,15 @@ namespace FourSlash { assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Type definitions Count")); } + public verifyImplementationsCount(negative: boolean, expectedCount: number) { + const assertFn = negative ? assert.notEqual : assert.equal; + + const implementations = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition); + const actualCount = implementations && implementations.length || 0; + + assertFn(actualCount, expectedCount, this.messageAtLastKnownMarker("Implementations Count")); + } + public verifyDefinitionsName(negative: boolean, expectedName: string, expectedContainerName: string) { const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); const actualDefinitionName = definitions && definitions.length ? definitions[0].name : ""; @@ -1618,6 +1627,47 @@ namespace FourSlash { } } + public goToImplementation(implIndex: number) { + const implementations = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition); + if (!implementations || !implementations.length) { + this.raiseError("goToImplementation failed - expected to at least one implementation location but got 0"); + } + + if (implIndex >= implementations.length) { + this.raiseError(`goToImplementation failed - implIndex value (${implIndex}) exceeds implementation list size (${implementations.length})`); + } + + const implementation = implementations[implIndex]; + this.openFile(implementation.fileName); + this.currentCaretPosition = implementation.textSpan.start; + } + + public verifyRangesInImplementationList() { + const implementations = this.languageService.getImplementationAtPosition(this.activeFile.fileName, this.currentCaretPosition); + if (!implementations || !implementations.length) { + this.raiseError("verifyRangesInImplementationList failed - expected to at least one implementation location but got 0"); + } + + const ranges = this.getRanges(); + + if (!ranges || !ranges.length) { + this.raiseError("verifyRangesInImplementationList failed - expected to at least one range in test source"); + } + + for (const range of ranges) { + let rangeIsPresent = false; + const length = range.end - range.start; + for (const impl of implementations) { + if (range.fileName === impl.fileName && range.start === impl.textSpan.start && length === impl.textSpan.length) { + rangeIsPresent = true; + break; + } + } + assert.isTrue(rangeIsPresent, `No implementation found for range ${range.start}, ${range.end} in ${range.fileName}: ${this.rangeText(range)}`); + } + assert.equal(implementations.length, ranges.length, `Different number of implementations (${implementations.length}) and ranges (${ranges.length})`); + } + public getMarkers(): Marker[] { // Return a copy of the list return this.testData.markers.slice(0); @@ -2768,6 +2818,10 @@ namespace FourSlashInterface { this.state.goToTypeDefinition(definitionIndex); } + public implementation(implementationIndex = 0) { + this.state.goToImplementation(implementationIndex); + } + public position(position: number, fileIndex?: number): void; public position(position: number, fileName?: string): void; public position(position: number, fileNameOrIndex?: any): void { @@ -2876,6 +2930,10 @@ namespace FourSlashInterface { this.state.verifyTypeDefinitionsCount(this.negative, expectedCount); } + public implementationCountIs(expectedCount: number) { + this.state.verifyImplementationsCount(this.negative, expectedCount); + } + public definitionLocationExists() { this.state.verifyDefinitionLocationExists(this.negative); } @@ -3113,6 +3171,10 @@ namespace FourSlashInterface { public ProjectInfo(expected: string[]) { this.state.verifyProjectInfo(expected); } + + public allRangesAppearInImplementationList() { + this.state.verifyRangesInImplementationList(); + } } export class Edit { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 94124432780..5209c6d7398 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -408,6 +408,9 @@ namespace Harness.LanguageService { getTypeDefinitionAtPosition(fileName: string, position: number): ts.DefinitionInfo[] { return unwrapJSONCallResult(this.shim.getTypeDefinitionAtPosition(fileName, position)); } + getImplementationAtPosition(fileName: string, position: number): ts.ImplementationLocation[] { + return unwrapJSONCallResult(this.shim.getImplementationAtPosition(fileName, position)); + } getReferencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] { return unwrapJSONCallResult(this.shim.getReferencesAtPosition(fileName, position)); } diff --git a/src/server/client.ts b/src/server/client.ts index 88177e91fad..a9938ca85ec 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -353,6 +353,28 @@ namespace ts.server { }); } + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] { + const lineOffset = this.positionToOneBasedLineOffset(fileName, position); + const args: protocol.FileLocationRequestArgs = { + file: fileName, + line: lineOffset.line, + offset: lineOffset.offset, + }; + + const request = this.processRequest(CommandNames.Implementation, args); + const response = this.processResponse(request); + + return response.body.map(entry => { + const fileName = entry.file; + const start = this.lineOffsetToPosition(fileName, entry.start); + const end = this.lineOffsetToPosition(fileName, entry.end); + return { + fileName, + textSpan: ts.createTextSpanFromBounds(start, end) + }; + }); + } + findReferences(fileName: string, position: number): ReferencedSymbol[] { // Not yet implemented. return []; diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 6442848abbe..5263b86e2a3 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -193,6 +193,14 @@ declare namespace ts.server.protocol { export interface TypeDefinitionRequest extends FileLocationRequest { } + /** + * Go to implementation request; value of command field is + * "implementation". Return response giving the file locations that + * implement the symbol found in file at location line, col. + */ + export interface ImplementationRequest extends FileLocationRequest { + } + /** * Location in source code expressed as (one-based) line and character offset. */ @@ -240,6 +248,13 @@ declare namespace ts.server.protocol { body?: FileSpan[]; } + /** + * Implementation response message. Gives text range for implementations. + */ + export interface ImplementationResponse extends Response { + body?: FileSpan[]; + } + /** * Get occurrences request; value of command field is * "occurrences". Return response giving spans that are relevant diff --git a/src/server/session.ts b/src/server/session.ts index 9383a54bd48..783451e02c6 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -111,6 +111,7 @@ namespace ts.server { export const Formatonkey = "formatonkey"; export const Geterr = "geterr"; export const GeterrForProject = "geterrForProject"; + export const Implementation = "implementation"; export const SemanticDiagnosticsSync = "semanticDiagnosticsSync"; export const SyntacticDiagnosticsSync = "syntacticDiagnosticsSync"; export const NavBar = "navbar"; @@ -357,6 +358,28 @@ namespace ts.server { })); } + private getImplementation(line: number, offset: number, fileName: string): protocol.FileSpan[] { + const file = ts.normalizePath(fileName); + const project = this.projectService.getProjectForFile(file); + if (!project || project.languageServiceDiabled) { + throw Errors.NoProject; + } + + const compilerService = project.compilerService; + const position = compilerService.host.lineOffsetToPosition(file, line, offset); + + const implementations = compilerService.languageService.getImplementationAtPosition(file, position); + if (!implementations) { + return undefined; + } + + return implementations.map(impl => ({ + file: impl.fileName, + start: compilerService.host.positionToLineOffset(impl.fileName, impl.textSpan.start), + end: compilerService.host.positionToLineOffset(impl.fileName, ts.textSpanEnd(impl.textSpan)) + })); + } + private getOccurrences(line: number, offset: number, fileName: string): protocol.OccurrencesResponseItem[] { fileName = ts.normalizePath(fileName); const project = this.projectService.getProjectForFile(fileName); @@ -1074,6 +1097,10 @@ namespace ts.server { const defArgs = request.arguments; return { response: this.getTypeDefinition(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; }, + [CommandNames.Implementation]: (request: protocol.Request) => { + const implArgs = request.arguments; + return { response: this.getImplementation(implArgs.line, implArgs.offset, implArgs.file), responseRequired: true }; + }, [CommandNames.References]: (request: protocol.Request) => { const defArgs = request.arguments; return { response: this.getReferences(defArgs.line, defArgs.offset, defArgs.file), responseRequired: true }; diff --git a/src/services/services.ts b/src/services/services.ts index d200e081c5a..bb63f30c603 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1213,6 +1213,7 @@ namespace ts { getDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; getTypeDefinitionAtPosition(fileName: string, position: number): DefinitionInfo[]; + getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[]; getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[]; findReferences(fileName: string, position: number): ReferencedSymbol[]; @@ -1301,6 +1302,11 @@ namespace ts { isDefinition: boolean; } + export interface ImplementationLocation { + textSpan: TextSpan; + fileName: string; + } + export interface DocumentHighlights { fileName: string; highlightSpans: HighlightSpan[]; @@ -5288,6 +5294,149 @@ namespace ts { return getDefinitionFromSymbol(type.symbol, node); } + /// Goto implementation + function getImplementationAtPosition(fileName: string, position: number): ImplementationLocation[] { + synchronizeHostData(); + + const entries: ImplementationLocation[] = []; + const node = getTouchingPropertyName(getValidSourceFile(fileName), position); + const typeChecker = program.getTypeChecker(); + + if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + const entry = getReferenceEntryForShorthandPropertyAssignment(node, typeChecker); + entries.push({ + textSpan: entry.textSpan, + fileName: entry.fileName + }); + } + else if (definitionIsImplementation(node, typeChecker)) { + const definitions = getDefinitionAtPosition(fileName, position); + forEach(definitions, (definition: DefinitionInfo) => { + entries.push({ + textSpan: definition.textSpan, + fileName: definition.fileName + }); + }); + } + else { + // Do a search for all references and filter them down to implementations only + const result = getReferencedSymbolsForNode(node, program.getSourceFiles(), /*findInStrings*/false, /*findInComments*/false, /*implementations*/true); + + forEach(result, referencedSymbol => { + if (referencedSymbol.references) { + forEach(referencedSymbol.references, entry => { + entries.push({ + textSpan: entry.textSpan, + fileName: entry.fileName + }); + }); + } + }); + } + + return entries; + } + + /** + * Returns true if the implementation for this node is the same as its definition + */ + function definitionIsImplementation(node: Node, typeChecker: TypeChecker) { + if (node.kind === SyntaxKind.SuperKeyword || node.kind === SyntaxKind.ThisKeyword) { + return true; + } + + if (node.parent.kind === SyntaxKind.PropertyAccessExpression || node.parent.kind === SyntaxKind.ElementAccessExpression) { + const expression = (node.parent).expression; + + // Members of "this" and "super" only have one possible implementation, so no need to find + // all references. Similarly, for the left hand side of the expression it only really + // makes sense to return the definition + if (node === expression || expression.kind === SyntaxKind.SuperKeyword || expression.kind === SyntaxKind.ThisKeyword) { + return true; + } + + // Check to see if this is a property that can have multiple implementations by determining + // if the parent is an interface (or class, or union/intersection) + const expressionType = typeChecker.getTypeAtLocation(expression); + if (expressionType && expressionType.getFlags() & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.UnionOrIntersection)) { + return false; + } + + // Also check the right hand side to see if this is a type being accessed on a namespace/module + const rightHandType = typeChecker.getTypeAtLocation(node); + return rightHandType && !(rightHandType.getFlags() & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.UnionOrIntersection)); + } + + const symbol = typeChecker.getSymbolAtLocation(node); + return symbol && !isClassOrInterfaceReference(symbol) && !(symbol.parent && isClassOrInterfaceReference(symbol.parent)); + } + + function getReferenceEntryForShorthandPropertyAssignment(node: Node, typeChecker: TypeChecker) { + const refSymbol = typeChecker.getSymbolAtLocation(node); + const shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); + + if (shorthandSymbol) { + const shorthandDeclarations = shorthandSymbol.getDeclarations(); + if (shorthandDeclarations.length === 1) { + return getReferenceEntryFromNode(shorthandDeclarations[0]); + } + else if (shorthandDeclarations.length > 1) { + // This can happen when the property being assigned is a constructor for a + // class that also has interface declarations with the same name. We just want + // the class itself + + return forEach(shorthandDeclarations, declaration => { + if (declaration.kind === SyntaxKind.ClassDeclaration) { + return getReferenceEntryFromNode(declaration); + } + }); + } + } + } + + function isClassOrInterfaceReference(toCheck: Symbol) { + return toCheck.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface); + } + + function isIdentifierOfImplementation(node: Identifier): boolean { + const parent = node.parent; + + if (isIdentifierName(node) || isFunctionDeclarationIdentifierName(node)) { + // PropertyAccessExpression? + switch (parent.kind) { + case SyntaxKind.FunctionDeclaration: + case SyntaxKind.FunctionExpression: + case SyntaxKind.MethodDeclaration: + case SyntaxKind.Constructor: + case SyntaxKind.GetAccessor: + case SyntaxKind.SetAccessor: + return !!(parent).body; + case SyntaxKind.PropertyDeclaration: + return !!(parent).initializer; + case SyntaxKind.PropertyAssignment: + return true; + } + } + else if (isVariableLike(parent) && parent.name === node) { + return !!parent.initializer; + } + + return isIdentifierOfClass(node) || isIdentifierOfEnumDeclaration(node); + } + + function isIdentifierOfClass(node: Identifier) { + return (node.parent.kind === SyntaxKind.ClassDeclaration || node.parent.kind === SyntaxKind.ClassExpression) && + (node.parent).name === node; + } + + function isIdentifierOfEnumDeclaration(node: Identifier) { + return node.parent.kind === SyntaxKind.EnumDeclaration && (node.parent).name === node; + } + + function isTypeAssertionExpression(node: Node): node is TypeAssertion { + return node.kind === SyntaxKind.TypeAssertionExpression; + } + function getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] { let results = getOccurrencesAtPositionCore(fileName, position); @@ -5334,7 +5483,7 @@ namespace ts { node.kind === SyntaxKind.StringLiteral || isLiteralNameOfPropertyDeclarationOrIndexAccess(node)) { - const referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false); + const referencedSymbols = getReferencedSymbolsForNode(node, sourceFilesToSearch, /*findInStrings*/ false, /*findInComments*/ false, /*implementations*/false); return convertReferencedSymbols(referencedSymbols); } @@ -6006,7 +6155,7 @@ namespace ts { case SyntaxKind.ThisKeyword: // case SyntaxKind.SuperKeyword: TODO:GH#9268 case SyntaxKind.StringLiteral: - return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); + return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments, /*implementations*/false); } return undefined; } @@ -6024,37 +6173,40 @@ namespace ts { } } - function getReferencedSymbolsForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean): ReferencedSymbol[] { + function getReferencedSymbolsForNode(node: Node, sourceFiles: SourceFile[], findInStrings: boolean, findInComments: boolean, implementations: boolean): ReferencedSymbol[] { const typeChecker = program.getTypeChecker(); - - // Labels - if (isLabelName(node)) { - if (isJumpStatementTarget(node)) { - const labelDefinition = getTargetLabel((node.parent), (node).text); - // if we have a label definition, look within its statement for references, if not, then - // the label is undefined and we have no results.. - return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; - } - else { - // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node); - } - } - - if (isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles); - } - - if (node.kind === SyntaxKind.SuperKeyword) { - return getReferencesForSuperKeyword(node); - } - const symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol && node.kind === SyntaxKind.StringLiteral) { - return getReferencesForStringLiteral(node, sourceFiles); + if (!implementations) { + // Labels + if (isLabelName(node)) { + if (isJumpStatementTarget(node)) { + const labelDefinition = getTargetLabel((node.parent), (node).text); + // if we have a label definition, look within its statement for references, if not, then + // the label is undefined and we have no results.. + return labelDefinition ? getLabelReferencesInNode(labelDefinition.parent, labelDefinition) : undefined; + } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node); + } + } + + if (isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles); + } + + if (node.kind === SyntaxKind.SuperKeyword) { + return getReferencesForSuperKeyword(node); + } + + + if (!symbol && node.kind === SyntaxKind.StringLiteral) { + return getReferencesForStringLiteral(node, sourceFiles); + } } + // Could not find a symbol e.g. unknown identifier if (!symbol) { // Can't have references to something that we have no symbol for. @@ -6084,9 +6236,11 @@ namespace ts { // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. const symbolToIndex: number[] = []; + const indexToSymbol: {[index: number]: Symbol} = {}; + if (scope) { result = []; - getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, indexToSymbol); } else { const internedName = getInternedName(symbol, node, declarations); @@ -6097,11 +6251,15 @@ namespace ts { if (nameTable[internedName] !== undefined) { result = result || []; - getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); + getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, indexToSymbol); } } } + if (implementations) { + return filterToImplementations(node, symbol, result, indexToSymbol); + } + return result; function getDefinition(symbol: Symbol): DefinitionInfo { @@ -6363,7 +6521,8 @@ namespace ts { findInStrings: boolean, findInComments: boolean, result: ReferencedSymbol[], - symbolToIndex: number[]): void { + symbolToIndex: number[], + indexToSymbol: {[index: number]: Symbol}): void { const sourceFile = container.getSourceFile(); const tripleSlashDirectivePrefixRegex = /^\/\/\/\s* { + const impl = getImplementationFromEntry(entry); + if (impl) { + const entryNode = getTokenAtPosition(getValidSourceFile(entry.fileName), entry.textSpan.start); + const element = getContainingObjectLiteralElement(entryNode); + if (element && element.parent && element.parent.kind === SyntaxKind.ObjectLiteralExpression) { + const objType = getDeclaredTypeOfObjectLiteralExpression(element.parent); + + if (objType && typeChecker.isTypeAssignableTo(objType, type)) { + return impl; + } + } + else { + const defClass = getContainingClass(entryNode); + if (defClass) { + const classType = typeChecker.getTypeAtLocation(defClass); + if (typeChecker.isTypeAssignableTo(classType, type)) { + return impl; + } + } + } + } + }); + } + } + + return filterReferenceEntries(refs, getImplementationFromEntry); + } + + function getDeclaredTypeOfObjectLiteralExpression(node: Node): Type { + if (node && node.parent) { + if (node.parent.kind === SyntaxKind.ParenthesizedExpression) { + return getDeclaredTypeOfObjectLiteralExpression(node.parent); + } + + if (isVariableLike(node.parent) && node.parent.type) { + return typeChecker.getTypeAtLocation(node.parent.type); + } + else if (node.parent.kind === SyntaxKind.ReturnStatement) { + const containerSig = typeChecker.getSignatureFromDeclaration(getContainingFunction(node)); + return typeChecker.getReturnTypeOfSignature(containerSig); + } + else if (node.parent.kind === SyntaxKind.TypeAssertionExpression) { + return typeChecker.getTypeAtLocation((node.parent).type); + } + } + return undefined; + } + + function filterReferenceEntries(refs: ReferencedSymbol[], filterer: (x: ReferenceEntry) => ReferenceEntry): ReferencedSymbol[] { + const result: ReferencedSymbol[] = []; + forEach(refs, (ref) => { + const filtered: ReferenceEntry[] = []; + forEach(ref.references, (entry) => { + const filteredEntry = filterer(entry); + if (filteredEntry) { + filtered.push(filteredEntry); + } + }); + if (filtered.length) { + result.push({ definition: ref.definition, references: filtered }); + } + }); + return result; + } + + function filterToClassMemberImplementations(parent: PropertyAccessExpression, searchSymbol: Symbol, refs: ReferencedSymbol[], indexToSymbol: {[index: number]: Symbol}): ReferencedSymbol[] { + // Need to find out what class this member is being accessed on + const type = typeChecker.getTypeAtLocation(parent.expression); + const classHierarchy: Symbol[] = getClassHierarchy(searchSymbol.parent); + + let lowest: ReferencedSymbol[]; + let lowestRank: number; + + // Filter down the references to those that refer to implementations of the symbol. That is, implementations + // from subclasses of the parent class and the lowest implementation in the parent class' class hierarchy + forEach(refs, (refSymbol, index) => { + const actual = indexToSymbol[index]; + + // We only care about implementations in classes in the hierarchy + if (actual.parent.getFlags() & SymbolFlags.Interface) { + return; + } + const rank = classHierarchy.indexOf(actual.parent); + + // No need to check anything past the lowest we have found so far + if (lowest && rank > lowestRank) { + return; + } + + const implementations: ReferenceEntry[] = []; + forEach(refSymbol.references, (entry) => { + const impl = getImplementationFromEntry(entry, type, classHierarchy); + if (impl) { + implementations.push(impl); + } + }); + if (implementations.length) { + if (!lowest || rank < lowestRank) { + lowest = [{ definition: refSymbol.definition, references: implementations }]; + lowestRank = rank; + } + else if (rank === lowestRank) { + lowest.push({ definition: refSymbol.definition, references: implementations }); + } + } + }); + + return lowest; + } + + function getImplementationFromEntry(entry: ReferenceEntry, base?: Type, hierarchy?: Symbol[]): ReferenceEntry { + const sourceFile = getValidSourceFile(entry.fileName); + const refNode = getTouchingPropertyName(sourceFile, entry.textSpan.start); + + // Check to make sure this reference is either part of a sub class or a class that we explicitly + // inherit from in the class hierarchy + if (isMemberOfSubOrParentClass(refNode, base, hierarchy) && refNode.kind === SyntaxKind.Identifier) { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (isIdentifierOfImplementation(refNode)) { + return getReferenceEntryFromNode(refNode.parent); + } + else if (refNode.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { + // Go ahead and dereference the shorthand assignment by going to its definition + return getReferenceEntryForShorthandPropertyAssignment(refNode, typeChecker); + } + + // Check if the node is within an extends or implements clause + const containingHeritageClause = getContainingClassHeritageClause(refNode); + if (containingHeritageClause) { + return getReferenceEntryFromNode(containingHeritageClause.parent); + } + + // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface + const containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference) { + const parent = containingTypeReference.parent; + if (isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + return getReferenceEntryFromNode(parent.initializer); + } + else if (isFunctionLike(parent) && parent.type === containingTypeReference && parent.body && parent.body.kind === SyntaxKind.Block) { + return forEachReturnStatement(parent.body, (returnStatement) => { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + return getReferenceEntryFromNode(returnStatement.expression); + } + }); + } + else if (isTypeAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + return getReferenceEntryFromNode(parent.expression); + } + } + } + } + + function isMemberOfSubOrParentClass(reference: Node, base: Type, hierarchy: Symbol[]) { + if (!base || !hierarchy) { + return true; + } + const referenceSymbol = typeChecker.getSymbolAtLocation(reference); + if (referenceSymbol && referenceSymbol.parent) { + if (hierarchy.indexOf(referenceSymbol.parent) !== -1) { + return true; + } + + const referenceParentDeclarations = referenceSymbol.parent.getDeclarations(); + if (referenceParentDeclarations.length) { + const referenceParentType = typeChecker.getTypeAtLocation(referenceParentDeclarations[0]); + return typeChecker.isTypeAssignableTo(referenceParentType, base); + } + } + return false; + } + + function getContainingTypeReference(node: Node): Node { + if (node) { + if (node.kind === SyntaxKind.TypeReference) { + return node; + } + + if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName) { + return getContainingTypeReference(node.parent); + } + } + return undefined; + } + + function getContainingClassHeritageClause(node: Node): HeritageClause { + if (node) { + if (node.kind === SyntaxKind.ExpressionWithTypeArguments + && node.parent.kind === SyntaxKind.HeritageClause + && isClassLike(node.parent.parent)) { + return node.parent; + } + + else if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.PropertyAccessExpression) { + return getContainingClassHeritageClause(node.parent); + } + } + return undefined; + } + + /** + * Returns true if this is an expression that could be used to implement an interface. + */ + function isImplementationExpression(node: Expression): boolean { + // Unwrap parentheses + if (node.kind === SyntaxKind.ParenthesizedExpression) { + return isImplementationExpression((node).expression); + } + + return node.kind === SyntaxKind.ArrowFunction || + node.kind === SyntaxKind.FunctionExpression || + node.kind === SyntaxKind.ObjectLiteralExpression || + node.kind === SyntaxKind.ClassExpression; + } + + function getClassHierarchy(symbol: Symbol) { + const classes: Symbol[] = []; + getClassHierarchyRecursive(symbol, classes, createMap()); + return classes; + + function getClassHierarchyRecursive(symbol: Symbol, result: Symbol[], previousIterationSymbolsCache: SymbolTable) { + if (hasProperty(previousIterationSymbolsCache, symbol.name)) { + return; + } + previousIterationSymbolsCache[symbol.name] = symbol; + + if (result.indexOf(symbol) !== -1) { + return; + } + result.push(symbol); + forEach(symbol.getDeclarations(), (decl) => { + if (isClassLike(decl)) { + const heritage = getClassExtendsHeritageClauseElement(decl); + if (heritage) { + const type = typeChecker.getTypeAtLocation(heritage); + if (type && type.symbol) { + getClassHierarchyRecursive(type.symbol, result, previousIterationSymbolsCache); + } + } + } + }); + } + } + function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] { let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); if (!searchSpaceNode) { @@ -8310,6 +8731,7 @@ namespace ts { getQuickInfoAtPosition, getDefinitionAtPosition, getTypeDefinitionAtPosition, + getImplementationAtPosition, getReferencesAtPosition, findReferences, getOccurrencesAtPosition, diff --git a/src/services/shims.ts b/src/services/shims.ts index 9a581ed6be1..612ed955ed4 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -173,6 +173,12 @@ namespace ts { */ getTypeDefinitionAtPosition(fileName: string, position: number): string; + /** + * Returns a JSON-encoded value of the type: + * { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean, isDefinition?: boolean }[] + */ + getImplementationAtPosition(fileName: string, position: number): string; + /** * Returns a JSON-encoded value of the type: * { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean, isDefinition?: boolean }[] @@ -772,6 +778,19 @@ namespace ts { ); } + /// GOTO Implementation + + /** + * Computes the implementation location of the symbol + * at the requested position. + */ + public getImplementationAtPosition(fileName: string, position: number): string { + return this.forwardJSONCall( + `getImplementationAtPosition('${fileName}', ${position})`, + () => this.languageService.getImplementationAtPosition(fileName, position) + ); + } + public getRenameInfo(fileName: string, position: number): string { return this.forwardJSONCall( `getRenameInfo('${fileName}', ${position})`, diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 9ce3197a46f..f35e4fc3e0e 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -110,6 +110,7 @@ declare namespace FourSlashInterface { eof(): void; definition(definitionIndex?: number): void; type(definitionIndex?: number): void; + implementation(implementationIndex?: number): void; position(position: number, fileIndex?: number): any; position(position: number, fileName?: string): any; file(index: number, content?: string, scriptKindName?: string): any; @@ -134,6 +135,7 @@ declare namespace FourSlashInterface { quickInfoExists(): void; definitionCountIs(expectedCount: number): void; typeDefinitionCountIs(expectedCount: number): void; + implementationCountIs(expectedCount: number): void; definitionLocationExists(): void; verifyDefinitionsName(name: string, containerName: string): void; isValidBraceCompletionAtPosition(openingBrace?: string): void; @@ -226,6 +228,7 @@ declare namespace FourSlashInterface { getSyntacticDiagnostics(expected: string): void; getSemanticDiagnostics(expected: string): void; ProjectInfo(expected: string[]): void; + allRangesAppearInImplementationList(): void; } class edit { backspace(count?: number): void; diff --git a/tests/cases/fourslash/goToImplementationClassMethod_00.ts b/tests/cases/fourslash/goToImplementationClassMethod_00.ts new file mode 100644 index 00000000000..465db091d32 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationClassMethod_00.ts @@ -0,0 +1,12 @@ +/// + +// Should handle calls made on members declared in a class + +//// class Bar { +//// [|hello() {}|] +//// } +//// +//// new Bar().hel/*reference*/lo; + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationClassMethod_01.ts b/tests/cases/fourslash/goToImplementationClassMethod_01.ts new file mode 100644 index 00000000000..8b1cb3e762d --- /dev/null +++ b/tests/cases/fourslash/goToImplementationClassMethod_01.ts @@ -0,0 +1,21 @@ +/// + +// Should handle calls made on member declared in an abstract class + +//// abstract class AbstractBar { +//// abstract he/*declaration*/llo(): void; +//// } +//// +//// class Bar extends AbstractBar{ +//// [|hello() {}|] +//// } +//// +//// function whatever(x: AbstractBar) { +//// x.he/*reference*/llo(); +//// } + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); + +goTo.marker("declaration"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationEnum_00.ts b/tests/cases/fourslash/goToImplementationEnum_00.ts new file mode 100644 index 00000000000..3a93542f806 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationEnum_00.ts @@ -0,0 +1,13 @@ +/// + +// Should handle calls made on members of an enum + +//// enum Foo { +//// [|Foo1 = function initializer() { return 5 } ()|], +//// Foo2 = 6 +//// } +//// +//// Foo.Fo/*reference*/o1; + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationEnum_01.ts b/tests/cases/fourslash/goToImplementationEnum_01.ts new file mode 100644 index 00000000000..2e7203f3c8f --- /dev/null +++ b/tests/cases/fourslash/goToImplementationEnum_01.ts @@ -0,0 +1,13 @@ +/// + +// Should handle calls made on enum name + +//// [|enum Foo { +//// Foo1 = function initializer() { return 5 } (), +//// Foo2 = 6 +//// }|] +//// +//// Fo/*reference*/o; + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_00.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_00.ts new file mode 100644 index 00000000000..71e6266aa20 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_00.ts @@ -0,0 +1,27 @@ +/// + +// Should return method implementations in object literals within variable-like declarations + +//// interface Foo { +//// he/*declaration*/llo: () => void +//// } +//// +//// var bar: Foo = { [|hello: helloImpl|] }; +//// +//// function helloImpl () {} +//// +//// function whatever(x: Foo = { [|hello() {/**1*/}|] }) { +//// x.he/*function_call*/llo() +//// } +//// +//// class Bar { +//// x: Foo = { [|hello() {/*2*/}|] } +//// +//// constructor(public f: Foo = { [|hello() {/**3*/}|] } ) {} +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); + +goTo.marker("declaration"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_01.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_01.ts new file mode 100644 index 00000000000..5f5ba64338b --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_01.ts @@ -0,0 +1,25 @@ +/// + +// Should return implementations in a simple class + +//// interface Foo { +//// hel/*declaration*/lo(): void; +//// okay?: number; +//// } +//// +//// class Bar implements Foo { +//// [|hello() {}|] +//// public sure() {} +//// } +//// +//// function whatever(a: Foo) { +//// a.he/*function_call*/llo(); +//// } +//// +//// whatever(new Bar()); + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); + +goTo.marker("declaration"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts new file mode 100644 index 00000000000..f5b1f1eea93 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_02.ts @@ -0,0 +1,25 @@ +/// + +// Should return implementations when left hand side of function call is an abstract class + +//// interface Foo { +//// he/*declaration*/llo(): void +//// } +//// +//// abstract class AbstractBar implements Foo { +//// abstract hello(): void; +//// } +//// +//// class Bar extends AbstractBar { +//// [|hello() {}|] +//// } +//// +//// function whatever(a: AbstractBar) { +//// a.he/*function_call*/llo(); +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); + +goTo.marker("declaration"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_03.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_03.ts new file mode 100644 index 00000000000..cc22956bb05 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_03.ts @@ -0,0 +1,25 @@ +/// + +// Should not return super implementations when method is implemented in class + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class Bar extends SuperBar { +//// [|hello() {}|] +//// } +//// +//// class SuperBar implements Foo { +//// hello() {} // should not show up +//// } +//// +//// class OtherBar implements Foo { +//// hello() {} // should not show up +//// } +//// +//// new Bar().hel/*function_call*/lo(); +//// new Bar()["hello"](); + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts new file mode 100644 index 00000000000..32f5ff41484 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_04.ts @@ -0,0 +1,26 @@ +/// + +// Should return implementation in class and all sub-classes of target + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class Bar extends SuperBar { +//// [|hello() {}|] +//// } +//// +//// class SuperBar implements Foo { +//// [|hello() {}|] +//// } +//// +//// class OtherBar implements Foo { +//// hello() {} // should not show up +//// } +//// +//// function (x: SuperBar) { +//// x.he/*function_call*/llo() +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts new file mode 100644 index 00000000000..43079b20dcc --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts @@ -0,0 +1,38 @@ +/// + +// Should not return implementations in classes with a shared parent that implements the interface + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class SuperBar implements Foo { +//// [|hello() {}|] +//// } +//// +//// class Bar extends SuperBar { +//// hello2() {} +//// } +//// +//// class OtherBar extends SuperBar { +//// [|hello() {}|] // This could be considered a false positive because it does not extend Bar. Returned because it shares a common ancestor and is structurally equivalent +//// hello2() {} +//// hello3() {} +//// } +//// +//// class NotRelatedToBar { +//// hello() {} // Equivalent to last case, but shares no common ancestors with Bar and so is not returned +//// hello2() {} +//// hello3() {} +//// } +//// +//// class NotBar extends SuperBar { +//// hello() {} // Should not be returned because it is not structurally equivalent to Bar +//// } +//// +//// function whatever(x: Bar) { +//// x.he/*function_call*/llo() +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts new file mode 100644 index 00000000000..175b5bd50fc --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts @@ -0,0 +1,49 @@ +/// + +// Should not return references to parent interfaces even if the method is declared there + +//// interface SuperFoo { +//// hello (): void; +//// } +//// +//// interface Foo extends SuperFoo { +//// someOtherFunction(): void; +//// } +//// +//// class Bar implements Foo { +//// [|hello() {}|] +//// someOtherFunction() {} +//// } +//// +//// function createFoo(): Foo { +//// return { +//// [|hello() {}|], +//// someOtherFunction() {} +//// }; +//// } +//// +//// var y: Foo = { +//// [|hello() {}|], +//// someOtherFunction() {} +//// }; +//// +//// class FooLike implements SuperFoo { +//// [|hello() {}|] // This case could be considered a false positive. It does not explicitly implement Foo but does implement it structurally and it shares a common ancestor +//// someOtherFunction() {} +//// } +//// +//// class NotRelatedToFoo { +//// hello() {} // This case is equivalent to the last case, but is not returned because it does not share a common ancestor with Foo +//// someOtherFunction() {} +//// } +//// +//// class NotFoo implements SuperFoo { +//// hello() {} // We only want implementations of Foo, even though the function is declared in SuperFoo +//// } +//// +//// function (x: Foo) { +//// x.he/*function_call*/llo() +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts new file mode 100644 index 00000000000..7d0be4a38a6 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_08.ts @@ -0,0 +1,23 @@ +/// + +// Should handle calls made on this + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class SuperBar implements Foo { +//// [|hello() {}|] +//// } +//// +//// class Bar extends SuperBar { +//// whatever() { this.he/*function_call*/llo(); } +//// } +//// +//// class SubBar extends Bar { +//// hello() {} +//// } + + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts new file mode 100644 index 00000000000..cb32f0203d0 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_09.ts @@ -0,0 +1,30 @@ +/// + +// Should handle calls made on super + +//// interface Foo { +//// hello (): void; +//// } +//// +//// class SubBar extends Bar { +//// hello() {} +//// } +//// +//// class Bar extends SuperBar { +//// hello() {} +//// +//// whatever() { +//// super.he/*function_call*/llo(); +//// } +//// } +//// +//// class SuperBar extends MegaBar { +//// [|hello() {}|] +//// } +//// +//// class MegaBar implements Foo { +//// hello() {} +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts new file mode 100644 index 00000000000..eed8c418043 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts @@ -0,0 +1,36 @@ +/// + +// Should handle intersection types + +//// interface Foo { +//// hello(): void; +//// aloha(): void; +//// } +//// +//// interface Bar { +//// hello(): void; +//// goodbye(): void; +//// } +//// +//// class FooImpl implements Foo { +//// hello() {/**FooImpl*/} +//// aloha() {} +//// } +//// +//// class BarImpl implements Bar { +//// hello() {/**BarImpl*/} +//// goodbye() {} +//// } +//// +//// class FooAndBarImpl implements Foo, Bar { +//// [|hello() {/**FooAndBarImpl*/}|] +//// aloha() {} +//// goodbye() {} +//// } +//// +//// function someFunction(x: Foo & Bar) { +//// x.he/*function_call*/llo(); +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts new file mode 100644 index 00000000000..7cf0533de5f --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts @@ -0,0 +1,36 @@ +/// + +// Should handle union types + +//// interface Foo { +//// hello(): void; +//// aloha(): void; +//// } +//// +//// interface Bar { +//// hello(): void; +//// goodbye(): void; +//// } +//// +//// class FooImpl implements Foo { +//// [|hello() {/**FooImpl*/}|] +//// aloha() {} +//// } +//// +//// class BarImpl implements Bar { +//// [|hello() {/**BarImpl*/}|] +//// goodbye() {} +//// } +//// +//// class FooAndBarImpl implements Foo, Bar { +//// [|hello() {/**FooAndBarImpl*/}|] +//// aloha() {} +//// goodbye() {} +//// } +//// +//// function someFunction(x: Foo | Bar) { +//// x.he/*function_call*/llo(); +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_12.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_12.ts new file mode 100644 index 00000000000..7d948006fb3 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_12.ts @@ -0,0 +1,12 @@ +/// + +// Should handle members of object literals in type assertion expressions + +//// interface Foo { +//// hel/*reference*/lo(): void; +//// } +//// +//// var x = { [|hello: () => {}|] }; +//// var y = (((({ [|hello: () => {}|] })))); +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceProperty_00.ts b/tests/cases/fourslash/goToImplementationInterfaceProperty_00.ts new file mode 100644 index 00000000000..43b59d021d3 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceProperty_00.ts @@ -0,0 +1,23 @@ +/// + +// Should handle property assignments in object literals within variable like declarations + +//// interface Foo { +//// hello: number +//// } +//// +//// var bar: Foo = { [|hello: 5|] }; +//// +//// +//// function whatever(x: Foo = { [|hello: 5 * 9|] }) { +//// x.he/*reference*/llo +//// } +//// +//// class Bar { +//// x: Foo = { [|hello: 6|] } +//// +//// constructor(public f: Foo = { [|hello: 7|] } ) {} +//// } + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts b/tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts new file mode 100644 index 00000000000..2725a5ab9d4 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterfaceProperty_01.ts @@ -0,0 +1,16 @@ +/// + +// Should handle property assignments within class declarations + +//// interface Foo { hello: number } +//// +//// class Bar implements Foo { +//// [|hello = 5 * 9;|] +//// } +//// +//// function whatever(foo: Foo) { +//// foo.he/*reference*/llo; +//// } + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_00.ts b/tests/cases/fourslash/goToImplementationInterface_00.ts new file mode 100644 index 00000000000..6e8ca5f3179 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_00.ts @@ -0,0 +1,26 @@ +/// + +// Should go to definitions in object literals in variable like declarations when invoked on interface + +//// interface Fo/*interface_definition*/o { +//// hello: () => void +//// } +//// +//// interface Baz extends Foo {} +//// +//// var bar: Foo = [|{ hello: helloImpl /**0*/ }|]; +//// +//// function helloImpl () {} +//// +//// function whatever(x: Foo = [|{ hello() {/**1*/} }|] ) { +//// } +//// +//// class Bar { +//// x: Foo = [|{ hello() {/*2*/} }|] +//// +//// constructor(public f: Foo = [|{ hello() {/**3*/} }|] ) {} +//// } + + +goTo.marker("interface_definition"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_01.ts b/tests/cases/fourslash/goToImplementationInterface_01.ts new file mode 100644 index 00000000000..6d9d5c97507 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_01.ts @@ -0,0 +1,25 @@ +/// + +//// interface Fo/*interface_definition*/o { hello(): void } +//// +//// [|class SuperBar implements Foo { +//// hello () {} +//// }|] +//// +//// [|abstract class AbstractBar implements Foo { +//// abstract hello (): void; +//// }|] +//// +//// class Bar extends SuperBar { +//// } +//// +//// class NotAbstractBar extends AbstractBar { +//// hello () {} +//// } +//// +//// var x = new SuperBar(); +//// var y: SuperBar = new SuperBar(); +//// var z: AbstractBar = new NotAbstractBar(); + +goTo.marker("interface_definition"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_02.ts b/tests/cases/fourslash/goToImplementationInterface_02.ts new file mode 100644 index 00000000000..b22de0e266e --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_02.ts @@ -0,0 +1,20 @@ +/// + +// Should go to definitions in object literals in return statements of functions with the type of the interface + +//// interface Fo/*interface_definition*/o { hello: () => void } +//// +//// function createFoo(): Foo { +//// return [|{ +//// hello() {} +//// }|]; +//// } +//// +//// function createFooLike() { +//// return { +//// hello() {} +//// }; +//// } + +goTo.marker("interface_definition"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_03.ts b/tests/cases/fourslash/goToImplementationInterface_03.ts new file mode 100644 index 00000000000..b198269d498 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_03.ts @@ -0,0 +1,10 @@ +/// + +// Should go to object literals within cast expressions when invoked on interface + +//// interface Fo/*interface_definition*/o { hello: () => void } +//// +//// var x = [|{ hello: () => {} }|]; + +goTo.marker("interface_definition"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_04.ts b/tests/cases/fourslash/goToImplementationInterface_04.ts new file mode 100644 index 00000000000..3989c194363 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_04.ts @@ -0,0 +1,22 @@ +/// + +// Should go to function literals that implement the interface within variable like declarations when invoked on an interface + +//// interface Fo/*interface_definition*/o { +//// (a: number): void +//// } +//// +//// var bar: Foo = [|(a) => {/**0*/}|]; +//// +//// function whatever(x: Foo = [|(a) => {/**1*/}|] ) { +//// } +//// +//// class Bar { +//// x: Foo = [|(a) => {/**2*/}|] +//// +//// constructor(public f: Foo = [|function(a) {}|] ) {} +//// } + + +goTo.marker("interface_definition"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_05.ts b/tests/cases/fourslash/goToImplementationInterface_05.ts new file mode 100644 index 00000000000..d0f87c6d6d4 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_05.ts @@ -0,0 +1,14 @@ +/// + +// Should go to function literals that implement the interface within type assertions when invoked on an interface + +//// interface Fo/*interface_definition*/o { +//// (a: number): void +//// } +//// +//// let bar2 = [|function(a) {}|]; +//// + + +goTo.marker("interface_definition"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterface_06.ts b/tests/cases/fourslash/goToImplementationInterface_06.ts new file mode 100644 index 00000000000..7ba2ebfc023 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInterface_06.ts @@ -0,0 +1,16 @@ +/// + +// Should go to class expressions that implement a constructor type + +//// interface Fo/*interface_definition*/o { +//// new (a: number): SomeOtherType; +//// } +//// +//// interface SomeOtherType {} +//// +//// let x: Foo = [|class { constructor (a: number) {} }|]; +//// let y = [|class { constructor (a: number) {} }|]; + + +goTo.marker("interface_definition"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInvalid.ts b/tests/cases/fourslash/goToImplementationInvalid.ts new file mode 100644 index 00000000000..a9739c9fe12 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationInvalid.ts @@ -0,0 +1,12 @@ +/// + +// Should not crash when invoked on an invalid location + +//// var x1 = 50/*0*/0; +//// var x2 = "hel/*1*/lo"; +//// /*2*/ + +for(var i = 0; i < 3; i++) { + goTo.marker("" + i); + verify.implementationCountIs(0); +} \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_00.ts b/tests/cases/fourslash/goToImplementationLocal_00.ts new file mode 100644 index 00000000000..0d0ba9001b7 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_00.ts @@ -0,0 +1,9 @@ +/// + +// Should return definition of locally declared functions + +//// he/*function_call*/llo(); +//// [|function hello() {}|] + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_01.ts b/tests/cases/fourslash/goToImplementationLocal_01.ts new file mode 100644 index 00000000000..d2ccb976e95 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_01.ts @@ -0,0 +1,9 @@ +/// + +// Should return the defintion of locally defined variables + +//// const [|hello = function() {}|]; +//// he/*function_call*/llo(); + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_02.ts b/tests/cases/fourslash/goToImplementationLocal_02.ts new file mode 100644 index 00000000000..47097652d81 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_02.ts @@ -0,0 +1,8 @@ +/// + +//// const x = { [|hello: () => {}|] }; +//// +//// x.he/*function_call*/llo(); +//// +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_03.ts b/tests/cases/fourslash/goToImplementationLocal_03.ts new file mode 100644 index 00000000000..46ad28a3e1d --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_03.ts @@ -0,0 +1,12 @@ +/// + +// Should return the definition when invoked on variable assignment + +//// let [|he/*local_var*/llo = {}|]; +//// +//// x.hello(); +//// +//// hello = {}; +//// +goTo.marker("local_var"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_04.ts b/tests/cases/fourslash/goToImplementationLocal_04.ts new file mode 100644 index 00000000000..3452749bdcf --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_04.ts @@ -0,0 +1,10 @@ +/// + +// Should return definition of function when invoked on the declaration + +//// [|function he/*local_var*/llo() {}|] +//// +//// hello(); +//// +goTo.marker("local_var"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationLocal_05.ts b/tests/cases/fourslash/goToImplementationLocal_05.ts new file mode 100644 index 00000000000..e58343d2505 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationLocal_05.ts @@ -0,0 +1,12 @@ +/// + +// Should handle calls made the left hand side of a property access expression + +//// class Bar { +//// public hello() {} +//// } +//// +//// var [|someVar = new Bar()|]; +//// someVa/*reference*/r.hello(); +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_00.ts b/tests/cases/fourslash/goToImplementationNamespace_00.ts new file mode 100644 index 00000000000..edae50425bd --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_00.ts @@ -0,0 +1,12 @@ +/// + +// Should handle calls on namespaces + +//// [|namespace Foo { +//// export function hello() {} +//// }|] +//// +//// let x = Fo/*reference*/o; + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_01.ts b/tests/cases/fourslash/goToImplementationNamespace_01.ts new file mode 100644 index 00000000000..4d5b30efa0c --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_01.ts @@ -0,0 +1,12 @@ +/// + +// Should handle calls on modules + +//// [|module Foo { +//// export function hello() {} +//// }|] +//// +//// let x = Fo/*reference*/o; + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_02.ts b/tests/cases/fourslash/goToImplementationNamespace_02.ts new file mode 100644 index 00000000000..ea24336be7e --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_02.ts @@ -0,0 +1,12 @@ +/// + +// Should handle property access expressions on namespaces + +//// namespace Foo { +//// [|export function hello() {}|] +//// } +//// +//// Foo.hell/*reference*/o(); + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_03.ts b/tests/cases/fourslash/goToImplementationNamespace_03.ts new file mode 100644 index 00000000000..c4388df7e8a --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_03.ts @@ -0,0 +1,12 @@ +/// + +// Should handle property access expressions on namespaces + +//// module Foo { +//// [|export function hello() {}|] +//// } +//// +//// Foo.hell/*reference*/o(); + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_04.ts b/tests/cases/fourslash/goToImplementationNamespace_04.ts new file mode 100644 index 00000000000..5f4267da530 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_04.ts @@ -0,0 +1,26 @@ +/// + +// Should handle sub-namespaces + +//// /*parentNamespace*/namespace Foo { +//// export function hello() {} +//// } +//// +//// /*parentNamespace2*/namespace Foo./*childNamespace*/Bar { +//// export function okay() {} +//// } +//// +//// Fo/*parentReference*/o.hello(); +//// Foo.Ba/*childReference*/r.okay(); + +goTo.marker("parentReference"); +goTo.implementation(0); +verify.caretAtMarker("parentNamespace"); + +goTo.marker("parentReference"); +goTo.implementation(1); +verify.caretAtMarker("parentNamespace2"); + +goTo.marker("childReference"); +goTo.implementation(); +verify.caretAtMarker("childNamespace") \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_05.ts b/tests/cases/fourslash/goToImplementationNamespace_05.ts new file mode 100644 index 00000000000..3dfb1fcca49 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_05.ts @@ -0,0 +1,26 @@ +/// + +// Should handle sub-modules + +//// /*parentModule*/module Foo { +//// export function hello() {} +//// } +//// +//// /*parentModule2*/module Foo./*childModule*/Bar { +//// export function okay() {} +//// } +//// +//// Fo/*parentReference*/o.hello(); +//// Foo.Ba/*childReference*/r.okay(); + +goTo.marker("parentReference"); +goTo.implementation(0); +verify.caretAtMarker("parentModule"); + +goTo.marker("parentReference"); +goTo.implementation(1); +verify.caretAtMarker("parentModule2"); + +goTo.marker("childReference"); +goTo.implementation(); +verify.caretAtMarker("childModule") \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationNamespace_06.ts b/tests/cases/fourslash/goToImplementationNamespace_06.ts new file mode 100644 index 00000000000..38aeb47feae --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_06.ts @@ -0,0 +1,28 @@ +/// + +// Should handle types that are members of a namespace in type references and heritage clauses + +//// namespace Foo { +//// export interface Bar { +//// hello(): void; +//// } +//// +//// [|class BarImpl implements Bar { +//// hello() {} +//// }|] +//// } +//// +//// [|class Baz implements Foo.Bar { +//// hello() {} +//// }|] +//// +//// var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|]; +//// +//// var someVar2 = [|{ hello: () => {/**2*/} }|]; +//// +//// function whatever(x: Foo.Ba/*reference*/r) { +//// +//// } + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); diff --git a/tests/cases/fourslash/goToImplementationNamespace_07.ts b/tests/cases/fourslash/goToImplementationNamespace_07.ts new file mode 100644 index 00000000000..fc64275d906 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationNamespace_07.ts @@ -0,0 +1,28 @@ +/// + +// Should handle types that are members of a module in type references and heritage clauses + +//// module Foo { +//// export interface Bar { +//// hello(): void; +//// } +//// +//// [|class BarImpl implements Bar { +//// hello() {} +//// }|] +//// } +//// +//// [|class Baz implements Foo.Bar { +//// hello() {} +//// }|] +//// +//// var someVar1 : Foo.Bar = [|{ hello: () => {/**1*/} }|]; +//// +//// var someVar2 = [|{ hello: () => {/**2*/} }|]; +//// +//// function whatever(x: Foo.Ba/*reference*/r) { +//// +//// } + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); diff --git a/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_00.ts b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_00.ts new file mode 100644 index 00000000000..ad4a0cd6b51 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_00.ts @@ -0,0 +1,43 @@ +/// + +// Should handle shorthand property assignments of class constructors + +//// interface Foo { +//// someFunction(): void; +//// } +//// +//// interface FooConstructor { +//// new (): Foo +//// } +//// +//// interface Bar { +//// Foo: FooConstructor; +//// } +//// +//// var x = /*classExpression*/class Foo { +//// createBarInClassExpression(): Bar { +//// return { +//// Fo/*classExpressionRef*/o +//// }; +//// } +//// +//// someFunction() {} +//// } +//// +//// /*declaredClass*/class Foo { +//// +//// } +//// +//// function createBarUsingClassDeclaration(): Bar { +//// return { +//// Fo/*declaredClassRef*/o +//// }; +//// } + +goTo.marker("classExpressionRef"); +goTo.implementation(); +verify.caretAtMarker("classExpression"); + +goTo.marker("declaredClassRef"); +goTo.implementation(); +verify.caretAtMarker("declaredClass"); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts new file mode 100644 index 00000000000..abb0aad0602 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_01.ts @@ -0,0 +1,48 @@ +/// + +// Should handle shorthand property assignments of class constructors when invoked on member of interface + +//// interface Foo { +//// someFunction(): void; +//// } +//// +//// interface FooConstructor { +//// new (): Foo +//// } +//// +//// interface Bar { +//// Foo: FooConstructor; +//// } +//// +//// // Class expression that gets used in a bar implementation +//// var x = [|class Foo { +//// createBarInClassExpression(): Bar { +//// return { +//// Foo +//// }; +//// } +//// +//// someFunction() {} +//// }|]; +//// +//// // Class declaration that gets used in a bar implementation. This class has multiple definitions +//// // (the class declaration and the interface above), but we only want the class returned +//// [|class Foo { +//// +//// }|] +//// +//// function createBarUsingClassDeclaration(): Bar { +//// return { +//// Foo +//// }; +//// } +//// +//// // Class expression that does not get used in a bar implementation +//// var y = class Foo { +//// someFunction() {} +//// }; +//// +//// createBarUsingClassDeclaration().Fo/*reference*/o; + +goTo.marker("reference"); +verify.allRangesAppearInImplementationList();; \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts new file mode 100644 index 00000000000..8db6cbce5de --- /dev/null +++ b/tests/cases/fourslash/goToImplementationShorthandPropertyAssignment_02.ts @@ -0,0 +1,22 @@ +/// + +// Should go to implementation of properties that are assigned to implementations of an interface using shorthand notation + +//// interface Foo { +//// hello(): void; +//// } +//// +//// function createFoo(): Foo { +//// return { +//// hello +//// }; +//// +//// [|function hello() {}|] +//// } +//// +//// function whatever(x: Foo) { +//// x.h/*function_call*/ello(); +//// } + +goTo.marker("function_call"); +verify.allRangesAppearInImplementationList(); diff --git a/tests/cases/fourslash/goToImplementationSuper_00.ts b/tests/cases/fourslash/goToImplementationSuper_00.ts new file mode 100644 index 00000000000..b7def58ca59 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationSuper_00.ts @@ -0,0 +1,16 @@ +/// + +// Should go to super class declaration when invoked on a super call expression + +//// [|class Foo { +//// constructor() {} +//// }|] +//// +//// class Bar extends Foo { +//// constructor() { +//// su/*super_call*/per(); +//// } +//// } + +goTo.marker("super_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationSuper_01.ts b/tests/cases/fourslash/goToImplementationSuper_01.ts new file mode 100644 index 00000000000..11ba0719e5d --- /dev/null +++ b/tests/cases/fourslash/goToImplementationSuper_01.ts @@ -0,0 +1,16 @@ +/// + +// Should go to the super class declaration when invoked on the super keyword in a property access expression + +//// [|class Foo { +//// hello() {} +//// }|] +//// +//// class Bar extends Foo { +//// hello() { +//// sup/*super_call*/er.hello(); +//// } +//// } + +goTo.marker("super_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationThis_00.ts b/tests/cases/fourslash/goToImplementationThis_00.ts new file mode 100644 index 00000000000..0e4a0ff9849 --- /dev/null +++ b/tests/cases/fourslash/goToImplementationThis_00.ts @@ -0,0 +1,14 @@ +/// + +// Should go to class declaration when invoked on this keyword in property access expression + +//// [|class Bar extends Foo { +//// hello() { +//// thi/*this_call*/s.whatever(); +//// } +//// +//// whatever() {} +//// }|] + +goTo.marker("this_call"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationThis_01.ts b/tests/cases/fourslash/goToImplementationThis_01.ts new file mode 100644 index 00000000000..001ebc08b9f --- /dev/null +++ b/tests/cases/fourslash/goToImplementationThis_01.ts @@ -0,0 +1,12 @@ +/// + +// Should go to class declaration when invoked on a this type reference + +//// [|class Bar extends Foo { +//// hello(): th/*this_type*/is { +//// return this; +//// } +//// }|] + +goTo.marker("this_type"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/server/implementation01.ts b/tests/cases/fourslash/server/implementation01.ts new file mode 100644 index 00000000000..24d5f935bda --- /dev/null +++ b/tests/cases/fourslash/server/implementation01.ts @@ -0,0 +1,9 @@ +/// + +// @Filename: a.ts +//// interface Fo/*1*/o {} +//// /*2*/class Bar implements Foo {} + +goTo.marker('1'); +goTo.implementation(); +verify.caretAtMarker('2'); \ No newline at end of file diff --git a/tests/cases/fourslash/shims-pp/getImplementationAtPosition.ts b/tests/cases/fourslash/shims-pp/getImplementationAtPosition.ts new file mode 100644 index 00000000000..a509922f919 --- /dev/null +++ b/tests/cases/fourslash/shims-pp/getImplementationAtPosition.ts @@ -0,0 +1,35 @@ +/// + +// @Filename: goToImplementationDifferentFile_Implementation.ts +//// /*fooClassImplementation*/class FooImpl implements Foo {} +//// +//// /*barClassImplementation*/class Bar { +//// /*barHelloFunctionImplementation*/hello() {} +//// } +//// + +// @Filename: goToImplementationDifferentFile_Consumption.ts +//// interface Fo/*fooClassReference*/o {} +//// +//// var x = new B/*barClassReference*/ar(); +//// +//// x.hel/*barHelloFunctionReference*/lo(); +//// +//// /*thisImplementation*/class SomeClass { +//// someMethod() { +//// thi/*thisReference*/s.someMethod(); +//// } +//// } + +var markerList = [ + "fooClass", + "barClass", + "barHelloFunction", + "this" +]; + +markerList.forEach((marker) => { + goTo.marker(marker + 'Reference'); + goTo.implementation(); + verify.caretAtMarker(marker + 'Implementation'); +}); diff --git a/tests/cases/fourslash/shims/getImplementationAtPosition.ts b/tests/cases/fourslash/shims/getImplementationAtPosition.ts new file mode 100644 index 00000000000..a509922f919 --- /dev/null +++ b/tests/cases/fourslash/shims/getImplementationAtPosition.ts @@ -0,0 +1,35 @@ +/// + +// @Filename: goToImplementationDifferentFile_Implementation.ts +//// /*fooClassImplementation*/class FooImpl implements Foo {} +//// +//// /*barClassImplementation*/class Bar { +//// /*barHelloFunctionImplementation*/hello() {} +//// } +//// + +// @Filename: goToImplementationDifferentFile_Consumption.ts +//// interface Fo/*fooClassReference*/o {} +//// +//// var x = new B/*barClassReference*/ar(); +//// +//// x.hel/*barHelloFunctionReference*/lo(); +//// +//// /*thisImplementation*/class SomeClass { +//// someMethod() { +//// thi/*thisReference*/s.someMethod(); +//// } +//// } + +var markerList = [ + "fooClass", + "barClass", + "barHelloFunction", + "this" +]; + +markerList.forEach((marker) => { + goTo.marker(marker + 'Reference'); + goTo.implementation(); + verify.caretAtMarker(marker + 'Implementation'); +}); From 5aafc2c848ec209ec395428b76eb8a51341305d9 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 22 Aug 2016 14:08:34 -0700 Subject: [PATCH 238/508] Contextually type this in getDeclFromSig, not checkThisExpr --- src/compiler/checker.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 17cfdf8976f..81a9c639feb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3063,9 +3063,14 @@ namespace ts { } } // Use contextual parameter type if one is available - const type = declaration.symbol.name === "this" - ? getContextuallyTypedThisType(func) - : getContextuallyTypedParameterType(declaration); + let type: Type; + if (declaration.symbol.name === "this") { + const thisParameter = getContextuallyTypedThisParameter(func); + type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + } + else { + type = getContextuallyTypedParameterType(declaration); + } if (type) { return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } @@ -4689,6 +4694,9 @@ namespace ts { if (isJSConstructSignature) { minArgumentCount--; } + if (!thisParameter && isObjectLiteralMethod(declaration)) { + thisParameter = getContextuallyTypedThisParameter(declaration); + } const classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent).symbol)) @@ -9087,10 +9095,6 @@ namespace ts { if (thisType) { return thisType; } - const type = getContextuallyTypedThisType(container); - if (type) { - return type; - } } if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); @@ -9326,11 +9330,11 @@ namespace ts { } } - function getContextuallyTypedThisType(func: FunctionLikeDeclaration): Type { + function getContextuallyTypedThisParameter(func: FunctionLikeDeclaration): Symbol { if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) { const contextualSignature = getContextualSignature(func); if (contextualSignature) { - return getThisTypeOfSignature(contextualSignature); + return contextualSignature.thisParameter; } } From 4a58e68d0040fb98e1be51ec9480d52a06bb8694 Mon Sep 17 00:00:00 2001 From: Yui Date: Mon, 22 Aug 2016 14:38:07 -0700 Subject: [PATCH 239/508] Update parser comment with es7 grammar (#10459) * Use ES7 term of ExponentiationExpression * Update timeout for mac OS * Address PR: add space --- Gulpfile.ts | 2 +- src/compiler/parser.ts | 42 +++++++++++++++++++++++++++++++----------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/Gulpfile.ts b/Gulpfile.ts index 1b902562832..295a7ce03d9 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -551,7 +551,7 @@ function restoreSavedNodeEnv() { process.env.NODE_ENV = savedNodeEnv; } -let testTimeout = 20000; +let testTimeout = 40000; function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) { const lintFlag = cmdLineOptions["lint"]; cleanTestDirs((err) => { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d6a2cf88ed8..f373d339553 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -912,7 +912,7 @@ namespace ts { // Note: it is not actually necessary to save/restore the context flags here. That's // because the saving/restoring of these flags happens naturally through the recursive // descent nature of our parser. However, we still store this here just so we can - // assert that that invariant holds. + // assert that invariant holds. const saveContextFlags = contextFlags; // If we're only looking ahead, then tell the scanner to only lookahead as well. @@ -2765,7 +2765,7 @@ namespace ts { // Note: for ease of implementation we treat productions '2' and '3' as the same thing. // (i.e. they're both BinaryExpressions with an assignment operator in it). - // First, do the simple check if we have a YieldExpression (production '5'). + // First, do the simple check if we have a YieldExpression (production '6'). if (isYieldExpression()) { return parseYieldExpression(); } @@ -3373,24 +3373,44 @@ namespace ts { } /** - * Parse ES7 unary expression and await expression + * Parse ES7 exponential expression and await expression + * + * ES7 ExponentiationExpression: + * 1) UnaryExpression[?Yield] + * 2) UpdateExpression[?Yield] ** ExponentiationExpression[?Yield] * - * ES7 UnaryExpression: - * 1) SimpleUnaryExpression[?yield] - * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] */ function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression { if (isAwaitExpression()) { return parseAwaitExpression(); } - if (isIncrementExpression()) { + /** + * ES7 UpdateExpression: + * 1) LeftHandSideExpression[?Yield] + * 2) LeftHandSideExpression[?Yield][no LineTerminator here]++ + * 3) LeftHandSideExpression[?Yield][no LineTerminator here]-- + * 4) ++UnaryExpression[?Yield] + * 5) --UnaryExpression[?Yield] + */ + if (isUpdateExpression()) { const incrementExpression = parseIncrementExpression(); return token() === SyntaxKind.AsteriskAsteriskToken ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } + /** + * ES7 UnaryExpression: + * 1) UpdateExpression[?yield] + * 2) delete UpdateExpression[?yield] + * 3) void UpdateExpression[?yield] + * 4) typeof UpdateExpression[?yield] + * 5) + UpdateExpression[?yield] + * 6) - UpdateExpression[?yield] + * 7) ~ UpdateExpression[?yield] + * 8) ! UpdateExpression[?yield] + */ const unaryOperator = token(); const simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === SyntaxKind.AsteriskAsteriskToken) { @@ -3408,8 +3428,8 @@ namespace ts { /** * Parse ES7 simple-unary expression or higher: * - * ES7 SimpleUnaryExpression: - * 1) IncrementExpression[?yield] + * ES7 UnaryExpression: + * 1) UpdateExpression[?yield] * 2) delete UnaryExpression[?yield] * 3) void UnaryExpression[?yield] * 4) typeof UnaryExpression[?yield] @@ -3447,14 +3467,14 @@ namespace ts { /** * Check if the current token can possibly be an ES7 increment expression. * - * ES7 IncrementExpression: + * ES7 UpdateExpression: * LeftHandSideExpression[?Yield] * LeftHandSideExpression[?Yield][no LineTerminator here]++ * LeftHandSideExpression[?Yield][no LineTerminator here]-- * ++LeftHandSideExpression[?Yield] * --LeftHandSideExpression[?Yield] */ - function isIncrementExpression(): boolean { + function isUpdateExpression(): boolean { // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token()) { From 046b55e9f152917e801f4279ded73d467c93ae8b Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 22 Aug 2016 16:27:44 -0700 Subject: [PATCH 240/508] allowSyntheticDefaultImports resolves to modules instead of variables Fixes #10429 by improving the fix in #10096 --- src/compiler/checker.ts | 10 +++--- .../baselines/reference/tsxDefaultImports.js | 34 +++++++++++++++++++ .../reference/tsxDefaultImports.symbols | 29 ++++++++++++++++ .../reference/tsxDefaultImports.types | 29 ++++++++++++++++ tests/cases/compiler/tsxDefaultImports.ts | 12 +++++++ 5 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 tests/baselines/reference/tsxDefaultImports.js create mode 100644 tests/baselines/reference/tsxDefaultImports.symbols create mode 100644 tests/baselines/reference/tsxDefaultImports.types create mode 100644 tests/cases/compiler/tsxDefaultImports.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 193deded4c5..aab284b0ceb 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1126,13 +1126,13 @@ namespace ts { else { symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } - // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default - if (!symbolFromVariable && allowSyntheticDefaultImports && name.text === "default") { - symbolFromVariable = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); - } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); - const symbolFromModule = getExportOfModule(targetSymbol, name.text); + let symbolFromModule = getExportOfModule(targetSymbol, name.text); + // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { + symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + } const symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; diff --git a/tests/baselines/reference/tsxDefaultImports.js b/tests/baselines/reference/tsxDefaultImports.js new file mode 100644 index 00000000000..79f5d2b8fa1 --- /dev/null +++ b/tests/baselines/reference/tsxDefaultImports.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/tsxDefaultImports.ts] //// + +//// [a.ts] + +enum SomeEnum { + one, +} +export default class SomeClass { + public static E = SomeEnum; +} + +//// [b.ts] +import {default as Def} from "./a" +let a = Def.E.one; + + +//// [a.js] +"use strict"; +var SomeEnum; +(function (SomeEnum) { + SomeEnum[SomeEnum["one"] = 0] = "one"; +})(SomeEnum || (SomeEnum = {})); +var SomeClass = (function () { + function SomeClass() { + } + SomeClass.E = SomeEnum; + return SomeClass; +}()); +exports.__esModule = true; +exports["default"] = SomeClass; +//// [b.js] +"use strict"; +var a_1 = require("./a"); +var a = a_1["default"].E.one; diff --git a/tests/baselines/reference/tsxDefaultImports.symbols b/tests/baselines/reference/tsxDefaultImports.symbols new file mode 100644 index 00000000000..e42392e24aa --- /dev/null +++ b/tests/baselines/reference/tsxDefaultImports.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/a.ts === + +enum SomeEnum { +>SomeEnum : Symbol(SomeEnum, Decl(a.ts, 0, 0)) + + one, +>one : Symbol(SomeEnum.one, Decl(a.ts, 1, 15)) +} +export default class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(a.ts, 3, 1)) + + public static E = SomeEnum; +>E : Symbol(SomeClass.E, Decl(a.ts, 4, 32)) +>SomeEnum : Symbol(SomeEnum, Decl(a.ts, 0, 0)) +} + +=== tests/cases/compiler/b.ts === +import {default as Def} from "./a" +>default : Symbol(Def, Decl(b.ts, 0, 8)) +>Def : Symbol(Def, Decl(b.ts, 0, 8)) + +let a = Def.E.one; +>a : Symbol(a, Decl(b.ts, 1, 3)) +>Def.E.one : Symbol(SomeEnum.one, Decl(a.ts, 1, 15)) +>Def.E : Symbol(Def.E, Decl(a.ts, 4, 32)) +>Def : Symbol(Def, Decl(b.ts, 0, 8)) +>E : Symbol(Def.E, Decl(a.ts, 4, 32)) +>one : Symbol(SomeEnum.one, Decl(a.ts, 1, 15)) + diff --git a/tests/baselines/reference/tsxDefaultImports.types b/tests/baselines/reference/tsxDefaultImports.types new file mode 100644 index 00000000000..a9bdedf3efd --- /dev/null +++ b/tests/baselines/reference/tsxDefaultImports.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/a.ts === + +enum SomeEnum { +>SomeEnum : SomeEnum + + one, +>one : SomeEnum +} +export default class SomeClass { +>SomeClass : SomeClass + + public static E = SomeEnum; +>E : typeof SomeEnum +>SomeEnum : typeof SomeEnum +} + +=== tests/cases/compiler/b.ts === +import {default as Def} from "./a" +>default : typeof Def +>Def : typeof Def + +let a = Def.E.one; +>a : SomeEnum +>Def.E.one : SomeEnum +>Def.E : typeof SomeEnum +>Def : typeof Def +>E : typeof SomeEnum +>one : SomeEnum + diff --git a/tests/cases/compiler/tsxDefaultImports.ts b/tests/cases/compiler/tsxDefaultImports.ts new file mode 100644 index 00000000000..4e313b33eac --- /dev/null +++ b/tests/cases/compiler/tsxDefaultImports.ts @@ -0,0 +1,12 @@ +// @Filename: a.ts + +enum SomeEnum { + one, +} +export default class SomeClass { + public static E = SomeEnum; +} + +// @Filename: b.ts +import {default as Def} from "./a" +let a = Def.E.one; From fc1d6a8437439b4caf232503baf07d1f5a4bf794 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Mon, 22 Aug 2016 16:36:38 -0700 Subject: [PATCH 241/508] Rename getContextuallyTypedThisParameter to getContextualThisParameter --- src/compiler/checker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 81a9c639feb..2f2c3002299 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3065,7 +3065,7 @@ namespace ts { // Use contextual parameter type if one is available let type: Type; if (declaration.symbol.name === "this") { - const thisParameter = getContextuallyTypedThisParameter(func); + const thisParameter = getContextualThisParameter(func); type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; } else { @@ -4695,7 +4695,7 @@ namespace ts { minArgumentCount--; } if (!thisParameter && isObjectLiteralMethod(declaration)) { - thisParameter = getContextuallyTypedThisParameter(declaration); + thisParameter = getContextualThisParameter(declaration); } const classType = declaration.kind === SyntaxKind.Constructor ? @@ -9330,7 +9330,7 @@ namespace ts { } } - function getContextuallyTypedThisParameter(func: FunctionLikeDeclaration): Symbol { + function getContextualThisParameter(func: FunctionLikeDeclaration): Symbol { if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) { const contextualSignature = getContextualSignature(func); if (contextualSignature) { From 36130ffa64ea95c6d924951ff2a2090504a0e94c Mon Sep 17 00:00:00 2001 From: Yui Date: Mon, 22 Aug 2016 16:37:04 -0700 Subject: [PATCH 242/508] Fix 10472: Invalid emitted code for await expression (#10483) * Properly emit await expression with yield expression * Add tests and update baselines * Move parsing await expression into parse unary-expression * Update incorrect comment --- src/compiler/emitter.ts | 4 ++ src/compiler/parser.ts | 11 ++-- .../reference/await_unaryExpression_es6.js | 47 ++++++++++++++++ .../await_unaryExpression_es6.symbols | 25 +++++++++ .../reference/await_unaryExpression_es6.types | 37 ++++++++++++ .../reference/await_unaryExpression_es6_1.js | 56 +++++++++++++++++++ .../await_unaryExpression_es6_1.symbols | 31 ++++++++++ .../await_unaryExpression_es6_1.types | 46 +++++++++++++++ .../reference/await_unaryExpression_es6_2.js | 38 +++++++++++++ .../await_unaryExpression_es6_2.symbols | 19 +++++++ .../await_unaryExpression_es6_2.types | 28 ++++++++++ .../await_unaryExpression_es6_3.errors.txt | 27 +++++++++ .../reference/await_unaryExpression_es6_3.js | 53 ++++++++++++++++++ tests/baselines/reference/castOfAwait.js | 6 +- .../async/es6/await_unaryExpression_es6.ts | 17 ++++++ .../async/es6/await_unaryExpression_es6_1.ts | 21 +++++++ .../async/es6/await_unaryExpression_es6_2.ts | 13 +++++ .../async/es6/await_unaryExpression_es6_3.ts | 19 +++++++ 18 files changed, 489 insertions(+), 9 deletions(-) create mode 100644 tests/baselines/reference/await_unaryExpression_es6.js create mode 100644 tests/baselines/reference/await_unaryExpression_es6.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es6.types create mode 100644 tests/baselines/reference/await_unaryExpression_es6_1.js create mode 100644 tests/baselines/reference/await_unaryExpression_es6_1.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es6_1.types create mode 100644 tests/baselines/reference/await_unaryExpression_es6_2.js create mode 100644 tests/baselines/reference/await_unaryExpression_es6_2.symbols create mode 100644 tests/baselines/reference/await_unaryExpression_es6_2.types create mode 100644 tests/baselines/reference/await_unaryExpression_es6_3.errors.txt create mode 100644 tests/baselines/reference/await_unaryExpression_es6_3.js create mode 100644 tests/cases/conformance/async/es6/await_unaryExpression_es6.ts create mode 100644 tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts create mode 100644 tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts create mode 100644 tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 357a15507a4..d0f7918dc89 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -1817,6 +1817,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge else if (node.parent.kind === SyntaxKind.ConditionalExpression && (node.parent).condition === node) { return true; } + else if (node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.DeleteExpression || + node.parent.kind === SyntaxKind.TypeOfExpression || node.parent.kind === SyntaxKind.VoidExpression) { + return true; + } return false; } diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f373d339553..b5ba89887a2 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -3381,10 +3381,6 @@ namespace ts { * */ function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression { - if (isAwaitExpression()) { - return parseAwaitExpression(); - } - /** * ES7 UpdateExpression: * 1) LeftHandSideExpression[?Yield] @@ -3452,13 +3448,15 @@ namespace ts { return parseTypeOfExpression(); case SyntaxKind.VoidKeyword: return parseVoidExpression(); - case SyntaxKind.AwaitKeyword: - return parseAwaitExpression(); case SyntaxKind.LessThanToken: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); + case SyntaxKind.AwaitKeyword: + if (isAwaitExpression()) { + return parseAwaitExpression(); + } default: return parseIncrementExpression(); } @@ -3485,6 +3483,7 @@ namespace ts { case SyntaxKind.DeleteKeyword: case SyntaxKind.TypeOfKeyword: case SyntaxKind.VoidKeyword: + case SyntaxKind.AwaitKeyword: return false; case SyntaxKind.LessThanToken: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression diff --git a/tests/baselines/reference/await_unaryExpression_es6.js b/tests/baselines/reference/await_unaryExpression_es6.js new file mode 100644 index 00000000000..46065bdada9 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6.js @@ -0,0 +1,47 @@ +//// [await_unaryExpression_es6.ts] + +async function bar() { + !await 42; // OK +} + +async function bar1() { + +await 42; // OK +} + +async function bar3() { + -await 42; // OK +} + +async function bar4() { + ~await 42; // OK +} + +//// [await_unaryExpression_es6.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function bar() { + return __awaiter(this, void 0, void 0, function* () { + !(yield 42); // OK + }); +} +function bar1() { + return __awaiter(this, void 0, void 0, function* () { + +(yield 42); // OK + }); +} +function bar3() { + return __awaiter(this, void 0, void 0, function* () { + -(yield 42); // OK + }); +} +function bar4() { + return __awaiter(this, void 0, void 0, function* () { + ~(yield 42); // OK + }); +} diff --git a/tests/baselines/reference/await_unaryExpression_es6.symbols b/tests/baselines/reference/await_unaryExpression_es6.symbols new file mode 100644 index 00000000000..81edd4b981b --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6.ts === + +async function bar() { +>bar : Symbol(bar, Decl(await_unaryExpression_es6.ts, 0, 0)) + + !await 42; // OK +} + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es6.ts, 3, 1)) + + +await 42; // OK +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6.ts, 7, 1)) + + -await 42; // OK +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es6.ts, 11, 1)) + + ~await 42; // OK +} diff --git a/tests/baselines/reference/await_unaryExpression_es6.types b/tests/baselines/reference/await_unaryExpression_es6.types new file mode 100644 index 00000000000..2a4b7354d3e --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6.ts === + +async function bar() { +>bar : () => Promise + + !await 42; // OK +>!await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar1() { +>bar1 : () => Promise + + +await 42; // OK +>+await 42 : number +>await 42 : number +>42 : number +} + +async function bar3() { +>bar3 : () => Promise + + -await 42; // OK +>-await 42 : number +>await 42 : number +>42 : number +} + +async function bar4() { +>bar4 : () => Promise + + ~await 42; // OK +>~await 42 : number +>await 42 : number +>42 : number +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.js b/tests/baselines/reference/await_unaryExpression_es6_1.js new file mode 100644 index 00000000000..c6f5f1142c0 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_1.js @@ -0,0 +1,56 @@ +//// [await_unaryExpression_es6_1.ts] + +async function bar() { + !await 42; // OK +} + +async function bar1() { + delete await 42; // OK +} + +async function bar2() { + delete await 42; // OK +} + +async function bar3() { + void await 42; +} + +async function bar4() { + +await 42; +} + +//// [await_unaryExpression_es6_1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function bar() { + return __awaiter(this, void 0, void 0, function* () { + !(yield 42); // OK + }); +} +function bar1() { + return __awaiter(this, void 0, void 0, function* () { + delete (yield 42); // OK + }); +} +function bar2() { + return __awaiter(this, void 0, void 0, function* () { + delete (yield 42); // OK + }); +} +function bar3() { + return __awaiter(this, void 0, void 0, function* () { + void (yield 42); + }); +} +function bar4() { + return __awaiter(this, void 0, void 0, function* () { + +(yield 42); + }); +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.symbols b/tests/baselines/reference/await_unaryExpression_es6_1.symbols new file mode 100644 index 00000000000..ed7d7e4ed02 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_1.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts === + +async function bar() { +>bar : Symbol(bar, Decl(await_unaryExpression_es6_1.ts, 0, 0)) + + !await 42; // OK +} + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es6_1.ts, 3, 1)) + + delete await 42; // OK +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_1.ts, 7, 1)) + + delete await 42; // OK +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_1.ts, 11, 1)) + + void await 42; +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es6_1.ts, 15, 1)) + + +await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.types b/tests/baselines/reference/await_unaryExpression_es6_1.types new file mode 100644 index 00000000000..a5c3740b677 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_1.types @@ -0,0 +1,46 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts === + +async function bar() { +>bar : () => Promise + + !await 42; // OK +>!await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar1() { +>bar1 : () => Promise + + delete await 42; // OK +>delete await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar2() { +>bar2 : () => Promise + + delete await 42; // OK +>delete await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar3() { +>bar3 : () => Promise + + void await 42; +>void await 42 : undefined +>await 42 : number +>42 : number +} + +async function bar4() { +>bar4 : () => Promise + + +await 42; +>+await 42 : number +>await 42 : number +>42 : number +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.js b/tests/baselines/reference/await_unaryExpression_es6_2.js new file mode 100644 index 00000000000..3c341018ed1 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_2.js @@ -0,0 +1,38 @@ +//// [await_unaryExpression_es6_2.ts] + +async function bar1() { + delete await 42; +} + +async function bar2() { + delete await 42; +} + +async function bar3() { + void await 42; +} + +//// [await_unaryExpression_es6_2.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function bar1() { + return __awaiter(this, void 0, void 0, function* () { + delete (yield 42); + }); +} +function bar2() { + return __awaiter(this, void 0, void 0, function* () { + delete (yield 42); + }); +} +function bar3() { + return __awaiter(this, void 0, void 0, function* () { + void (yield 42); + }); +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.symbols b/tests/baselines/reference/await_unaryExpression_es6_2.symbols new file mode 100644 index 00000000000..574ea4d433a --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts === + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es6_2.ts, 0, 0)) + + delete await 42; +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_2.ts, 3, 1)) + + delete await 42; +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_2.ts, 7, 1)) + + void await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.types b/tests/baselines/reference/await_unaryExpression_es6_2.types new file mode 100644 index 00000000000..b438f063add --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_2.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts === + +async function bar1() { +>bar1 : () => Promise + + delete await 42; +>delete await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar2() { +>bar2 : () => Promise + + delete await 42; +>delete await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar3() { +>bar3 : () => Promise + + void await 42; +>void await 42 : undefined +>await 42 : number +>42 : number +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_3.errors.txt b/tests/baselines/reference/await_unaryExpression_es6_3.errors.txt new file mode 100644 index 00000000000..5518f84983f --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_3.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts(3,7): error TS1109: Expression expected. +tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts(7,7): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts (2 errors) ==== + + async function bar1() { + ++await 42; // Error + ~~~~~ +!!! error TS1109: Expression expected. + } + + async function bar2() { + --await 42; // Error + ~~~~~ +!!! error TS1109: Expression expected. + } + + async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis + } + + async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es6_3.js b/tests/baselines/reference/await_unaryExpression_es6_3.js new file mode 100644 index 00000000000..077e264c450 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_3.js @@ -0,0 +1,53 @@ +//// [await_unaryExpression_es6_3.ts] + +async function bar1() { + ++await 42; // Error +} + +async function bar2() { + --await 42; // Error +} + +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} + +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} + +//// [await_unaryExpression_es6_3.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function bar1() { + return __awaiter(this, void 0, void 0, function* () { + ++; + yield 42; // Error + }); +} +function bar2() { + return __awaiter(this, void 0, void 0, function* () { + --; + yield 42; // Error + }); +} +function bar3() { + return __awaiter(this, void 0, void 0, function* () { + var x = 42; + yield x++; // OK but shouldn't need parenthesis + }); +} +function bar4() { + return __awaiter(this, void 0, void 0, function* () { + var x = 42; + yield x--; // OK but shouldn't need parenthesis + }); +} diff --git a/tests/baselines/reference/castOfAwait.js b/tests/baselines/reference/castOfAwait.js index 95817b7f0e6..26e9812bf43 100644 --- a/tests/baselines/reference/castOfAwait.js +++ b/tests/baselines/reference/castOfAwait.js @@ -20,9 +20,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function f() { return __awaiter(this, void 0, void 0, function* () { yield 0; - typeof yield 0; - void yield 0; - yield void typeof void yield 0; + typeof (yield 0); + void (yield 0); + yield void typeof void (yield 0); yield yield 0; }); } diff --git a/tests/cases/conformance/async/es6/await_unaryExpression_es6.ts b/tests/cases/conformance/async/es6/await_unaryExpression_es6.ts new file mode 100644 index 00000000000..09cf0a87a5a --- /dev/null +++ b/tests/cases/conformance/async/es6/await_unaryExpression_es6.ts @@ -0,0 +1,17 @@ +// @target: es6 + +async function bar() { + !await 42; // OK +} + +async function bar1() { + +await 42; // OK +} + +async function bar3() { + -await 42; // OK +} + +async function bar4() { + ~await 42; // OK +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts b/tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts new file mode 100644 index 00000000000..5ccf1a1c35a --- /dev/null +++ b/tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts @@ -0,0 +1,21 @@ +// @target: es6 + +async function bar() { + !await 42; // OK +} + +async function bar1() { + delete await 42; // OK +} + +async function bar2() { + delete await 42; // OK +} + +async function bar3() { + void await 42; +} + +async function bar4() { + +await 42; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts b/tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts new file mode 100644 index 00000000000..24683765d19 --- /dev/null +++ b/tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts @@ -0,0 +1,13 @@ +// @target: es6 + +async function bar1() { + delete await 42; +} + +async function bar2() { + delete await 42; +} + +async function bar3() { + void await 42; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts b/tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts new file mode 100644 index 00000000000..b595ab5e748 --- /dev/null +++ b/tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts @@ -0,0 +1,19 @@ +// @target: es6 + +async function bar1() { + ++await 42; // Error +} + +async function bar2() { + --await 42; // Error +} + +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} + +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} \ No newline at end of file From 0f83fc130e2e4376cc64c7af48e8401c7eb2c68b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 22 Aug 2016 23:10:05 -0700 Subject: [PATCH 243/508] Added tests. --- .../es6/templates/taggedTemplateWithConstructableTag01.ts | 3 +++ .../es6/templates/taggedTemplateWithConstructableTag02.ts | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts create mode 100644 tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts diff --git a/tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts b/tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts new file mode 100644 index 00000000000..996f5b80298 --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts @@ -0,0 +1,3 @@ +class CtorTag { } + +CtorTag `Hello world!`; \ No newline at end of file diff --git a/tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts b/tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts new file mode 100644 index 00000000000..7c6f009bf23 --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts @@ -0,0 +1,6 @@ +interface I { + new (...args: any[]): string; + new (): number; +} +var tag: I; +tag `Hello world!`; \ No newline at end of file From e7798c002ef4bb86d29bf7262aadb03b398aadba Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 22 Aug 2016 23:10:16 -0700 Subject: [PATCH 244/508] Accepted baselines. --- .../taggedTemplateWithConstructableTag01.js | 13 +++++++++++++ ...aggedTemplateWithConstructableTag01.symbols | 7 +++++++ .../taggedTemplateWithConstructableTag01.types | 9 +++++++++ .../taggedTemplateWithConstructableTag02.js | 12 ++++++++++++ ...aggedTemplateWithConstructableTag02.symbols | 16 ++++++++++++++++ .../taggedTemplateWithConstructableTag02.types | 18 ++++++++++++++++++ 6 files changed, 75 insertions(+) create mode 100644 tests/baselines/reference/taggedTemplateWithConstructableTag01.js create mode 100644 tests/baselines/reference/taggedTemplateWithConstructableTag01.symbols create mode 100644 tests/baselines/reference/taggedTemplateWithConstructableTag01.types create mode 100644 tests/baselines/reference/taggedTemplateWithConstructableTag02.js create mode 100644 tests/baselines/reference/taggedTemplateWithConstructableTag02.symbols create mode 100644 tests/baselines/reference/taggedTemplateWithConstructableTag02.types diff --git a/tests/baselines/reference/taggedTemplateWithConstructableTag01.js b/tests/baselines/reference/taggedTemplateWithConstructableTag01.js new file mode 100644 index 00000000000..dbcb70edf00 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateWithConstructableTag01.js @@ -0,0 +1,13 @@ +//// [taggedTemplateWithConstructableTag01.ts] +class CtorTag { } + +CtorTag `Hello world!`; + +//// [taggedTemplateWithConstructableTag01.js] +var CtorTag = (function () { + function CtorTag() { + } + return CtorTag; +}()); +(_a = ["Hello world!"], _a.raw = ["Hello world!"], CtorTag(_a)); +var _a; diff --git a/tests/baselines/reference/taggedTemplateWithConstructableTag01.symbols b/tests/baselines/reference/taggedTemplateWithConstructableTag01.symbols new file mode 100644 index 00000000000..340d5887808 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateWithConstructableTag01.symbols @@ -0,0 +1,7 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts === +class CtorTag { } +>CtorTag : Symbol(CtorTag, Decl(taggedTemplateWithConstructableTag01.ts, 0, 0)) + +CtorTag `Hello world!`; +>CtorTag : Symbol(CtorTag, Decl(taggedTemplateWithConstructableTag01.ts, 0, 0)) + diff --git a/tests/baselines/reference/taggedTemplateWithConstructableTag01.types b/tests/baselines/reference/taggedTemplateWithConstructableTag01.types new file mode 100644 index 00000000000..05e5aba7cde --- /dev/null +++ b/tests/baselines/reference/taggedTemplateWithConstructableTag01.types @@ -0,0 +1,9 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts === +class CtorTag { } +>CtorTag : CtorTag + +CtorTag `Hello world!`; +>CtorTag `Hello world!` : any +>CtorTag : typeof CtorTag +>`Hello world!` : string + diff --git a/tests/baselines/reference/taggedTemplateWithConstructableTag02.js b/tests/baselines/reference/taggedTemplateWithConstructableTag02.js new file mode 100644 index 00000000000..6c38d508bd2 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateWithConstructableTag02.js @@ -0,0 +1,12 @@ +//// [taggedTemplateWithConstructableTag02.ts] +interface I { + new (...args: any[]): string; + new (): number; +} +var tag: I; +tag `Hello world!`; + +//// [taggedTemplateWithConstructableTag02.js] +var tag; +(_a = ["Hello world!"], _a.raw = ["Hello world!"], tag(_a)); +var _a; diff --git a/tests/baselines/reference/taggedTemplateWithConstructableTag02.symbols b/tests/baselines/reference/taggedTemplateWithConstructableTag02.symbols new file mode 100644 index 00000000000..2b2ccdbcbcf --- /dev/null +++ b/tests/baselines/reference/taggedTemplateWithConstructableTag02.symbols @@ -0,0 +1,16 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts === +interface I { +>I : Symbol(I, Decl(taggedTemplateWithConstructableTag02.ts, 0, 0)) + + new (...args: any[]): string; +>args : Symbol(args, Decl(taggedTemplateWithConstructableTag02.ts, 1, 9)) + + new (): number; +} +var tag: I; +>tag : Symbol(tag, Decl(taggedTemplateWithConstructableTag02.ts, 4, 3)) +>I : Symbol(I, Decl(taggedTemplateWithConstructableTag02.ts, 0, 0)) + +tag `Hello world!`; +>tag : Symbol(tag, Decl(taggedTemplateWithConstructableTag02.ts, 4, 3)) + diff --git a/tests/baselines/reference/taggedTemplateWithConstructableTag02.types b/tests/baselines/reference/taggedTemplateWithConstructableTag02.types new file mode 100644 index 00000000000..1b96c3324dd --- /dev/null +++ b/tests/baselines/reference/taggedTemplateWithConstructableTag02.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts === +interface I { +>I : I + + new (...args: any[]): string; +>args : any[] + + new (): number; +} +var tag: I; +>tag : I +>I : I + +tag `Hello world!`; +>tag `Hello world!` : any +>tag : I +>`Hello world!` : string + From 3292631b421fd85a870e65aaf82fab8aabf27dfe Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 22 Aug 2016 23:24:13 -0700 Subject: [PATCH 245/508] Added test for untyped tag. --- .../conformance/es6/templates/taggedTemplateUntypedTagCall01.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/cases/conformance/es6/templates/taggedTemplateUntypedTagCall01.ts diff --git a/tests/cases/conformance/es6/templates/taggedTemplateUntypedTagCall01.ts b/tests/cases/conformance/es6/templates/taggedTemplateUntypedTagCall01.ts new file mode 100644 index 00000000000..b77e04b3095 --- /dev/null +++ b/tests/cases/conformance/es6/templates/taggedTemplateUntypedTagCall01.ts @@ -0,0 +1,2 @@ +var tag: Function; +tag `Hello world!`; \ No newline at end of file From 310e9c3a5110fb07bd987f7fcce1b87d7d591180 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 22 Aug 2016 23:25:37 -0700 Subject: [PATCH 246/508] Accepted baselines. --- .../reference/taggedTemplateUntypedTagCall01.js | 8 ++++++++ .../reference/taggedTemplateUntypedTagCall01.symbols | 8 ++++++++ .../reference/taggedTemplateUntypedTagCall01.types | 10 ++++++++++ 3 files changed, 26 insertions(+) create mode 100644 tests/baselines/reference/taggedTemplateUntypedTagCall01.js create mode 100644 tests/baselines/reference/taggedTemplateUntypedTagCall01.symbols create mode 100644 tests/baselines/reference/taggedTemplateUntypedTagCall01.types diff --git a/tests/baselines/reference/taggedTemplateUntypedTagCall01.js b/tests/baselines/reference/taggedTemplateUntypedTagCall01.js new file mode 100644 index 00000000000..e0d16eec39d --- /dev/null +++ b/tests/baselines/reference/taggedTemplateUntypedTagCall01.js @@ -0,0 +1,8 @@ +//// [taggedTemplateUntypedTagCall01.ts] +var tag: Function; +tag `Hello world!`; + +//// [taggedTemplateUntypedTagCall01.js] +var tag; +(_a = ["Hello world!"], _a.raw = ["Hello world!"], tag(_a)); +var _a; diff --git a/tests/baselines/reference/taggedTemplateUntypedTagCall01.symbols b/tests/baselines/reference/taggedTemplateUntypedTagCall01.symbols new file mode 100644 index 00000000000..07af0a996e5 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateUntypedTagCall01.symbols @@ -0,0 +1,8 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateUntypedTagCall01.ts === +var tag: Function; +>tag : Symbol(tag, Decl(taggedTemplateUntypedTagCall01.ts, 0, 3)) +>Function : Symbol(Function, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + +tag `Hello world!`; +>tag : Symbol(tag, Decl(taggedTemplateUntypedTagCall01.ts, 0, 3)) + diff --git a/tests/baselines/reference/taggedTemplateUntypedTagCall01.types b/tests/baselines/reference/taggedTemplateUntypedTagCall01.types new file mode 100644 index 00000000000..3949869550c --- /dev/null +++ b/tests/baselines/reference/taggedTemplateUntypedTagCall01.types @@ -0,0 +1,10 @@ +=== tests/cases/conformance/es6/templates/taggedTemplateUntypedTagCall01.ts === +var tag: Function; +>tag : Function +>Function : Function + +tag `Hello world!`; +>tag `Hello world!` : any +>tag : Function +>`Hello world!` : string + From 590755b8a0c2396969b0a7de17d6fe745a220694 Mon Sep 17 00:00:00 2001 From: Yuichi Nukiyama Date: Tue, 23 Aug 2016 21:54:01 +0900 Subject: [PATCH 247/508] change error message --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 2 +- .../reference/apparentTypeSubtyping.errors.txt | 4 ++-- .../reference/apparentTypeSupertype.errors.txt | 4 ++-- tests/baselines/reference/arrayLiterals3.errors.txt | 4 ++-- .../reference/assignFromBooleanInterface.errors.txt | 4 ++-- .../reference/assignFromBooleanInterface2.errors.txt | 4 ++-- .../reference/assignFromNumberInterface.errors.txt | 4 ++-- .../reference/assignFromNumberInterface2.errors.txt | 4 ++-- .../reference/assignFromStringInterface.errors.txt | 4 ++-- .../reference/assignFromStringInterface2.errors.txt | 4 ++-- .../reference/nativeToBoxedTypes.errors.txt | 12 ++++++------ .../baselines/reference/primitiveMembers.errors.txt | 4 ++-- tests/baselines/reference/symbolType15.errors.txt | 4 ++-- 14 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3a6608c71d1..a6cb6fbde44 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -6275,7 +6275,7 @@ namespace ts { (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || (getGlobalESSymbolType() === source && esSymbolType === target)) { - reportError(Diagnostics._0_is_a_primitive_type_while_1_is_a_boxed_object_Prefer_using_0_when_possible, targetType, sourceType); + reportError(Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); } } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index fb8bc21ec95..b8978b32571 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1955,7 +1955,7 @@ "category": "Error", "code": 2691 }, - "'{0}' is a primitive type while '{1}' is a boxed object. Prefer using '{0}' when possible.": { + "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible.": { "category": "Error", "code": 2692 }, diff --git a/tests/baselines/reference/apparentTypeSubtyping.errors.txt b/tests/baselines/reference/apparentTypeSubtyping.errors.txt index c19cfa44360..01fffeb3824 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.errors.txt +++ b/tests/baselines/reference/apparentTypeSubtyping.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(9,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. Types of property 'x' are incompatible. Type 'String' is not assignable to type 'string'. - 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (1 errors) ==== @@ -18,7 +18,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi !!! error TS2415: Class 'Derived' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'x' are incompatible. !!! error TS2415: Type 'String' is not assignable to type 'string'. -!!! error TS2415: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. +!!! error TS2415: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. x: String; } diff --git a/tests/baselines/reference/apparentTypeSupertype.errors.txt b/tests/baselines/reference/apparentTypeSupertype.errors.txt index b7195557e8d..c7610a80f2f 100644 --- a/tests/baselines/reference/apparentTypeSupertype.errors.txt +++ b/tests/baselines/reference/apparentTypeSupertype.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty Types of property 'x' are incompatible. Type 'U' is not assignable to type 'string'. Type 'String' is not assignable to type 'string'. - 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (1 errors) ==== @@ -20,6 +20,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty !!! error TS2415: Types of property 'x' are incompatible. !!! error TS2415: Type 'U' is not assignable to type 'string'. !!! error TS2415: Type 'String' is not assignable to type 'string'. -!!! error TS2415: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. +!!! error TS2415: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. x: U; } \ No newline at end of file diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index eb0c6dc51b7..7ced9e3933e 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -18,7 +18,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error Types of parameters 'items' and 'items' are incompatible. Type 'Number' is not assignable to type 'string | number'. Type 'Number' is not assignable to type 'number'. - 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. ==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ==== @@ -82,5 +82,5 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error !!! error TS2322: Types of parameters 'items' and 'items' are incompatible. !!! error TS2322: Type 'Number' is not assignable to type 'string | number'. !!! error TS2322: Type 'Number' is not assignable to type 'number'. -!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. \ No newline at end of file diff --git a/tests/baselines/reference/assignFromBooleanInterface.errors.txt b/tests/baselines/reference/assignFromBooleanInterface.errors.txt index f5c92a47569..555b645cd7d 100644 --- a/tests/baselines/reference/assignFromBooleanInterface.errors.txt +++ b/tests/baselines/reference/assignFromBooleanInterface.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts(3,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. - 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. + 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. ==== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts (1 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts(3 x = a; ~ !!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. -!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. +!!! error TS2322: 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromBooleanInterface2.errors.txt b/tests/baselines/reference/assignFromBooleanInterface2.errors.txt index bfbf56eec5a..6c7ebbe5ee8 100644 --- a/tests/baselines/reference/assignFromBooleanInterface2.errors.txt +++ b/tests/baselines/reference/assignFromBooleanInterface2.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts( Type '() => Object' is not assignable to type '() => boolean'. Type 'Object' is not assignable to type 'boolean'. tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(19,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. - 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. + 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(20,1): error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'. @@ -34,7 +34,7 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts( x = a; // expected error ~ !!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. -!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. +!!! error TS2322: 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/assignFromNumberInterface.errors.txt b/tests/baselines/reference/assignFromNumberInterface.errors.txt index e68ec76f68f..1a70ef342d2 100644 --- a/tests/baselines/reference/assignFromNumberInterface.errors.txt +++ b/tests/baselines/reference/assignFromNumberInterface.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts(3,1): error TS2322: Type 'Number' is not assignable to type 'number'. - 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. ==== tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts (1 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts(3,1 x = a; ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. -!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromNumberInterface2.errors.txt b/tests/baselines/reference/assignFromNumberInterface2.errors.txt index 5cae4654760..3297501d612 100644 --- a/tests/baselines/reference/assignFromNumberInterface2.errors.txt +++ b/tests/baselines/reference/assignFromNumberInterface2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(24,1): error TS2322: Type 'Number' is not assignable to type 'number'. - 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(25,1): error TS2322: Type 'NotNumber' is not assignable to type 'number'. @@ -30,7 +30,7 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(25 x = a; // expected error ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. -!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotNumber' is not assignable to type 'number'. diff --git a/tests/baselines/reference/assignFromStringInterface.errors.txt b/tests/baselines/reference/assignFromStringInterface.errors.txt index 80268f4b06a..7e7af4d1b9d 100644 --- a/tests/baselines/reference/assignFromStringInterface.errors.txt +++ b/tests/baselines/reference/assignFromStringInterface.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts(3,1): error TS2322: Type 'String' is not assignable to type 'string'. - 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts (1 errors) ==== @@ -8,5 +8,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts(3,1 x = a; ~ !!! error TS2322: Type 'String' is not assignable to type 'string'. -!!! error TS2322: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. +!!! error TS2322: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromStringInterface2.errors.txt b/tests/baselines/reference/assignFromStringInterface2.errors.txt index d20bdaaba32..0fc3284bf00 100644 --- a/tests/baselines/reference/assignFromStringInterface2.errors.txt +++ b/tests/baselines/reference/assignFromStringInterface2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(47,1): error TS2322: Type 'String' is not assignable to type 'string'. - 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(48,1): error TS2322: Type 'NotString' is not assignable to type 'string'. @@ -53,7 +53,7 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(48 x = a; // expected error ~ !!! error TS2322: Type 'String' is not assignable to type 'string'. -!!! error TS2322: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. +!!! error TS2322: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotString' is not assignable to type 'string'. diff --git a/tests/baselines/reference/nativeToBoxedTypes.errors.txt b/tests/baselines/reference/nativeToBoxedTypes.errors.txt index 255e0414fd9..03186a6d7e3 100644 --- a/tests/baselines/reference/nativeToBoxedTypes.errors.txt +++ b/tests/baselines/reference/nativeToBoxedTypes.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/nativeToBoxedTypes.ts(3,1): error TS2322: Type 'Number' is not assignable to type 'number'. - 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. tests/cases/compiler/nativeToBoxedTypes.ts(7,1): error TS2322: Type 'String' is not assignable to type 'string'. - 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. tests/cases/compiler/nativeToBoxedTypes.ts(11,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. - 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. + 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. tests/cases/compiler/nativeToBoxedTypes.ts(14,10): error TS2304: Cannot find name 'Symbol'. @@ -13,21 +13,21 @@ tests/cases/compiler/nativeToBoxedTypes.ts(14,10): error TS2304: Cannot find nam n = N; ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. -!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. var S = new String(); var s = "foge"; s = S; ~ !!! error TS2322: Type 'String' is not assignable to type 'string'. -!!! error TS2322: 'string' is a primitive type while 'String' is a boxed object. Prefer using 'string' when possible. +!!! error TS2322: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. var B = new Boolean(); var b = true; b = B; ~ !!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. -!!! error TS2322: 'boolean' is a primitive type while 'Boolean' is a boxed object. Prefer using 'boolean' when possible. +!!! error TS2322: 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. var sym: symbol; var Sym: Symbol; diff --git a/tests/baselines/reference/primitiveMembers.errors.txt b/tests/baselines/reference/primitiveMembers.errors.txt index 24f02486d00..49ef8c4e3cf 100644 --- a/tests/baselines/reference/primitiveMembers.errors.txt +++ b/tests/baselines/reference/primitiveMembers.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/primitiveMembers.ts(5,3): error TS2339: Property 'toBAZ' does not exist on type 'number'. tests/cases/compiler/primitiveMembers.ts(11,1): error TS2322: Type 'Number' is not assignable to type 'number'. - 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. ==== tests/cases/compiler/primitiveMembers.ts (2 errors) ==== @@ -19,7 +19,7 @@ tests/cases/compiler/primitiveMembers.ts(11,1): error TS2322: Type 'Number' is n n = N; // should not work, as 'number' has a different brand ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. -!!! error TS2322: 'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. N = n; // should work var o: Object = {} diff --git a/tests/baselines/reference/symbolType15.errors.txt b/tests/baselines/reference/symbolType15.errors.txt index 4a27ea24c59..205a2a999d0 100644 --- a/tests/baselines/reference/symbolType15.errors.txt +++ b/tests/baselines/reference/symbolType15.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/Symbols/symbolType15.ts(5,1): error TS2322: Type 'Symbol' is not assignable to type 'symbol'. - 'symbol' is a primitive type while 'Symbol' is a boxed object. Prefer using 'symbol' when possible. + 'symbol' is a primitive, but 'Symbol' is a wrapper object. Prefer using 'symbol' when possible. ==== tests/cases/conformance/es6/Symbols/symbolType15.ts (1 errors) ==== @@ -10,4 +10,4 @@ tests/cases/conformance/es6/Symbols/symbolType15.ts(5,1): error TS2322: Type 'Sy sym = symObj; ~~~ !!! error TS2322: Type 'Symbol' is not assignable to type 'symbol'. -!!! error TS2322: 'symbol' is a primitive type while 'Symbol' is a boxed object. Prefer using 'symbol' when possible. \ No newline at end of file +!!! error TS2322: 'symbol' is a primitive, but 'Symbol' is a wrapper object. Prefer using 'symbol' when possible. \ No newline at end of file From 457b67f67a141097c56807db165f1510d94db47f Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 23 Aug 2016 11:12:01 -0700 Subject: [PATCH 248/508] PR Feedback --- src/compiler/utilities.ts | 5 ----- src/server/session.ts | 4 ++-- src/services/services.ts | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 35dea56cf0b..870df4a54af 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1669,11 +1669,6 @@ namespace ts { return false; } - export function isFunctionDeclarationIdentifierName(node: Identifier): boolean { - return node.parent.kind === SyntaxKind.FunctionDeclaration && - (node.parent).name === node; - } - // An alias symbol is created by one of the following declarations: // import = ... // import from ... diff --git a/src/server/session.ts b/src/server/session.ts index 783451e02c6..2eb994519b1 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -366,9 +366,9 @@ namespace ts.server { } const compilerService = project.compilerService; - const position = compilerService.host.lineOffsetToPosition(file, line, offset); + const implementations = compilerService.languageService.getImplementationAtPosition(file, + compilerService.host.lineOffsetToPosition(file, line, offset)); - const implementations = compilerService.languageService.getImplementationAtPosition(file, position); if (!implementations) { return undefined; } diff --git a/src/services/services.ts b/src/services/services.ts index bb63f30c603..6f682822bba 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -5302,6 +5302,8 @@ namespace ts { const node = getTouchingPropertyName(getValidSourceFile(fileName), position); const typeChecker = program.getTypeChecker(); + // If invoked directly on a shorthand property assignment, then return + // the declaration of the symbol being assigned (not the symbol being assigned to). if (node.parent.kind === SyntaxKind.ShorthandPropertyAssignment) { const entry = getReferenceEntryForShorthandPropertyAssignment(node, typeChecker); entries.push({ @@ -5309,6 +5311,10 @@ namespace ts { fileName: entry.fileName }); } + + // For most symbols, the definition is the same as the implementation so we can just + // call "Go to Definition". This case should handle anything that is not a type + // reference to or member of an interface, class, or union/intersection type. else if (definitionIsImplementation(node, typeChecker)) { const definitions = getDefinitionAtPosition(fileName, position); forEach(definitions, (definition: DefinitionInfo) => { @@ -5318,8 +5324,12 @@ namespace ts { }); }); } + + // Interfaces, classes, and unions/intersection types separate the implementation and + // definition so "Go to Definition" is not sufficient. This case handles invocations + // on type references and members of those types. else { - // Do a search for all references and filter them down to implementations only + // Perform "Find all References" and filter them down to implementations only const result = getReferencedSymbolsForNode(node, program.getSourceFiles(), /*findInStrings*/false, /*findInComments*/false, /*implementations*/true); forEach(result, referencedSymbol => { @@ -5362,7 +5372,8 @@ namespace ts { return false; } - // Also check the right hand side to see if this is a type being accessed on a namespace/module + // Also check the right hand side to see if this is a type being accessed on a namespace/module. + // For example, SomeModule.SomeType const rightHandType = typeChecker.getTypeAtLocation(node); return rightHandType && !(rightHandType.getFlags() & (TypeFlags.Class | TypeFlags.Interface | TypeFlags.UnionOrIntersection)); } @@ -5424,6 +5435,11 @@ namespace ts { return isIdentifierOfClass(node) || isIdentifierOfEnumDeclaration(node); } + function isFunctionDeclarationIdentifierName(node: Identifier): boolean { + return node.parent.kind === SyntaxKind.FunctionDeclaration && + (node.parent).name === node; + } + function isIdentifierOfClass(node: Identifier) { return (node.parent.kind === SyntaxKind.ClassDeclaration || node.parent.kind === SyntaxKind.ClassExpression) && (node.parent).name === node; From c21d16a3bbb58b9beac271b1735fa782243d447a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 23 Aug 2016 11:14:05 -0700 Subject: [PATCH 249/508] Added test for decorators. --- .../decorators/class/constructableDecoratorOnClass01.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts diff --git a/tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts b/tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts new file mode 100644 index 00000000000..a9f9fa1699d --- /dev/null +++ b/tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts @@ -0,0 +1,8 @@ +// @experimentalDecorators: true + +class CtorDtor {} + +@CtorDtor +class C { + +} From d6ec5f29796ff094267df0e11b3b17bc6b95a28a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 23 Aug 2016 11:14:33 -0700 Subject: [PATCH 250/508] Accepted baselines. --- .../constructableDecoratorOnClass01.js | 30 +++++++++++++++++++ .../constructableDecoratorOnClass01.symbols | 13 ++++++++ .../constructableDecoratorOnClass01.types | 13 ++++++++ 3 files changed, 56 insertions(+) create mode 100644 tests/baselines/reference/constructableDecoratorOnClass01.js create mode 100644 tests/baselines/reference/constructableDecoratorOnClass01.symbols create mode 100644 tests/baselines/reference/constructableDecoratorOnClass01.types diff --git a/tests/baselines/reference/constructableDecoratorOnClass01.js b/tests/baselines/reference/constructableDecoratorOnClass01.js new file mode 100644 index 00000000000..26c5bf4a1c4 --- /dev/null +++ b/tests/baselines/reference/constructableDecoratorOnClass01.js @@ -0,0 +1,30 @@ +//// [constructableDecoratorOnClass01.ts] + +class CtorDtor {} + +@CtorDtor +class C { + +} + + +//// [constructableDecoratorOnClass01.js] +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var CtorDtor = (function () { + function CtorDtor() { + } + return CtorDtor; +}()); +var C = (function () { + function C() { + } + C = __decorate([ + CtorDtor + ], C); + return C; +}()); diff --git a/tests/baselines/reference/constructableDecoratorOnClass01.symbols b/tests/baselines/reference/constructableDecoratorOnClass01.symbols new file mode 100644 index 00000000000..46de420b826 --- /dev/null +++ b/tests/baselines/reference/constructableDecoratorOnClass01.symbols @@ -0,0 +1,13 @@ +=== tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts === + +class CtorDtor {} +>CtorDtor : Symbol(CtorDtor, Decl(constructableDecoratorOnClass01.ts, 0, 0)) + +@CtorDtor +>CtorDtor : Symbol(CtorDtor, Decl(constructableDecoratorOnClass01.ts, 0, 0)) + +class C { +>C : Symbol(C, Decl(constructableDecoratorOnClass01.ts, 1, 17)) + +} + diff --git a/tests/baselines/reference/constructableDecoratorOnClass01.types b/tests/baselines/reference/constructableDecoratorOnClass01.types new file mode 100644 index 00000000000..d66778a27e6 --- /dev/null +++ b/tests/baselines/reference/constructableDecoratorOnClass01.types @@ -0,0 +1,13 @@ +=== tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts === + +class CtorDtor {} +>CtorDtor : CtorDtor + +@CtorDtor +>CtorDtor : typeof CtorDtor + +class C { +>C : C + +} + From 7ecbfb21481fd81464404802bd7a5d713cdf8a09 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 23 Aug 2016 11:30:44 -0700 Subject: [PATCH 251/508] Unify untyped call checking between decorators and template tags. --- src/compiler/checker.ts | 43 +++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 370802478bc..bde11422b95 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -11943,18 +11943,12 @@ namespace ts { // Function interface, since they have none by default. This is a bit of a leap of faith // that the user will not add any. const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); - const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct); - // TS 1.0 spec: 4.12 - // If FuncExpr is of type Any, or of an object type that has no call or construct signatures - // but is a subtype of the Function interface, the call is an untyped function call. In an - // untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual + + // TS 1.0 Spec: 4.12 + // In an untyped function call no TypeArgs are permitted, Args can be any argument list, no contextual // types are provided for the argument expressions, and the result is always of type Any. - // We exclude union types because we may have a union of function types that happen to have - // no common signatures. - if (isTypeAny(funcType) || - (isTypeAny(apparentType) && funcType.flags & TypeFlags.TypeParameter) || - (!callSignatures.length && !constructSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { + if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) { // The unknownType indicates that an error already occurred (and was reported). No // need to report another error in this case. if (funcType !== unknownType && node.typeArguments) { @@ -11977,6 +11971,29 @@ namespace ts { return resolveCall(node, callSignatures, candidatesOutArray); } + /** + * TS 1.0 spec: 4.12 + * If FuncExpr is of type Any, or of an object type that has no call or construct signatures + * but is a subtype of the Function interface, the call is an untyped function call. + */ + function isUntypedFunctionCall(funcType: Type, apparentFuncType: Type, numCallSignatures: number, numConstructSignatures: number) { + if (isTypeAny(funcType)) { + return true; + } + if (isTypeAny(apparentFuncType) && funcType.flags & TypeFlags.TypeParameter) { + return true; + } + if (!numCallSignatures && !numConstructSignatures) { + // We exclude union types because we may have a union of function types that happen to have + // no common signatures. + if (funcType.flags & TypeFlags.Union) { + return false; + } + return isTypeAssignableTo(funcType, globalFunctionType); + } + return false; + } + function resolveNewExpression(node: NewExpression, candidatesOutArray: Signature[]): Signature { if (node.arguments && languageVersion < ScriptTarget.ES5) { const spreadIndex = getSpreadArgumentIndex(node.arguments); @@ -12102,8 +12119,9 @@ namespace ts { } const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); + const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct); - if (isTypeAny(tagType) || (!callSignatures.length && !(tagType.flags & TypeFlags.Union) && isTypeAssignableTo(tagType, globalFunctionType))) { + if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, constructSignatures.length)) { return resolveUntypedCall(node); } @@ -12148,7 +12166,8 @@ namespace ts { } const callSignatures = getSignaturesOfType(apparentType, SignatureKind.Call); - if (funcType === anyType || (!callSignatures.length && !(funcType.flags & TypeFlags.Union) && isTypeAssignableTo(funcType, globalFunctionType))) { + const constructSignatures = getSignaturesOfType(apparentType, SignatureKind.Construct); + if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, constructSignatures.length)) { return resolveUntypedCall(node); } From 5ce285c367c8baf70576ce6b1562015328aa118a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 23 Aug 2016 11:30:57 -0700 Subject: [PATCH 252/508] Accepted baselines. --- .../constructableDecoratorOnClass01.errors.txt | 16 ++++++++++++++++ ...ggedTemplateWithConstructableTag01.errors.txt | 9 +++++++++ ...ggedTemplateWithConstructableTag02.errors.txt | 12 ++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/baselines/reference/constructableDecoratorOnClass01.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateWithConstructableTag01.errors.txt create mode 100644 tests/baselines/reference/taggedTemplateWithConstructableTag02.errors.txt diff --git a/tests/baselines/reference/constructableDecoratorOnClass01.errors.txt b/tests/baselines/reference/constructableDecoratorOnClass01.errors.txt new file mode 100644 index 00000000000..f390aaf8550 --- /dev/null +++ b/tests/baselines/reference/constructableDecoratorOnClass01.errors.txt @@ -0,0 +1,16 @@ +tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts(4,1): error TS1238: Unable to resolve signature of class decorator when called as an expression. + Cannot invoke an expression whose type lacks a call signature. + + +==== tests/cases/conformance/decorators/class/constructableDecoratorOnClass01.ts (1 errors) ==== + + class CtorDtor {} + + @CtorDtor + ~~~~~~~~~ +!!! error TS1238: Unable to resolve signature of class decorator when called as an expression. +!!! error TS1238: Cannot invoke an expression whose type lacks a call signature. + class C { + + } + \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateWithConstructableTag01.errors.txt b/tests/baselines/reference/taggedTemplateWithConstructableTag01.errors.txt new file mode 100644 index 00000000000..b114acc5277 --- /dev/null +++ b/tests/baselines/reference/taggedTemplateWithConstructableTag01.errors.txt @@ -0,0 +1,9 @@ +tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts(3,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. + + +==== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag01.ts (1 errors) ==== + class CtorTag { } + + CtorTag `Hello world!`; + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateWithConstructableTag02.errors.txt b/tests/baselines/reference/taggedTemplateWithConstructableTag02.errors.txt new file mode 100644 index 00000000000..9bc4414b24f --- /dev/null +++ b/tests/baselines/reference/taggedTemplateWithConstructableTag02.errors.txt @@ -0,0 +1,12 @@ +tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts(6,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. + + +==== tests/cases/conformance/es6/templates/taggedTemplateWithConstructableTag02.ts (1 errors) ==== + interface I { + new (...args: any[]): string; + new (): number; + } + var tag: I; + tag `Hello world!`; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. \ No newline at end of file From e5675a8495c1a3c25f00802ffc14746a59fd0fba Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 23 Aug 2016 12:02:03 -0700 Subject: [PATCH 253/508] Always output something at the end of walkSymbol --- src/compiler/checker.ts | 49 ++++++++++--------- .../reference/augmentExportEquals3.symbols | 4 +- .../reference/augmentExportEquals3.types | 4 +- .../reference/augmentExportEquals3_1.symbols | 4 +- .../reference/augmentExportEquals3_1.types | 4 +- .../reference/augmentExportEquals4.symbols | 4 +- .../reference/augmentExportEquals4.types | 4 +- .../reference/augmentExportEquals4_1.symbols | 4 +- .../reference/augmentExportEquals4_1.types | 4 +- .../reference/augmentExportEquals5.symbols | 4 +- .../reference/augmentExportEquals5.types | 4 +- .../reference/augmentExportEquals6.symbols | 4 +- .../reference/augmentExportEquals6.types | 4 +- .../reference/augmentExportEquals6_1.symbols | 4 +- .../reference/augmentExportEquals6_1.types | 4 +- .../moduleAugmentationGlobal1.symbols | 2 +- .../moduleAugmentationGlobal2.symbols | 2 +- .../moduleAugmentationGlobal3.symbols | 2 +- .../moduleAugmentationGlobal4.symbols | 4 +- .../moduleAugmentationGlobal5.symbols | 4 +- ...moduleAugmentationInAmbientModule5.symbols | 2 +- ...module_augmentUninstantiatedModule.symbols | 4 +- .../baselines/reference/systemModule15.types | 4 +- tests/cases/fourslash/jsRequireQuickInfo.ts | 11 +++++ 24 files changed, 76 insertions(+), 64 deletions(-) create mode 100644 tests/cases/fourslash/jsRequireQuickInfo.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3d74190b14f..00801fce0c0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2058,7 +2058,7 @@ namespace ts { parentSymbol = symbol; } - // const the writer know we just wrote out a symbol. The declaration emitter writer uses + // Let the writer know we just wrote out a symbol. The declaration emitter writer uses // this to determine if an import it has previously seen (and not written out) needs // to be written to the file once the walk of the tree is complete. // @@ -2067,37 +2067,38 @@ namespace ts { // and we could then access that data during declaration emit. writer.trackSymbol(symbol, enclosingDeclaration, meaning); function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void { - if (symbol) { - const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); + function recur(symbol: Symbol, meaning: SymbolFlags, endOfChain?: boolean): void { + if (symbol) { + const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - // Go up and add our parent. - walkSymbol( - getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), - getQualifiedLeftMeaning(meaning)); - } - - if (accessibleSymbolChain) { - for (const accessibleSymbol of accessibleSymbolChain) { - appendParentTypeArgumentsAndSymbolName(accessibleSymbol); - } - } - else { - // If we didn't find accessible symbol chain for this symbol, break if this is external module - if (!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) { - return; + // Go up and add our parent. + recur( + getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), + getQualifiedLeftMeaning(meaning)); } - // if this is anonymous type break - if (symbol.flags & SymbolFlags.TypeLiteral || symbol.flags & SymbolFlags.ObjectLiteral) { - return; + if (accessibleSymbolChain) { + for (const accessibleSymbol of accessibleSymbolChain) { + appendParentTypeArgumentsAndSymbolName(accessibleSymbol); + } } + else if ( + // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. + endOfChain || + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + // If a parent symbol is an anonymous type, don't write it. + !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { - appendParentTypeArgumentsAndSymbolName(symbol); + appendParentTypeArgumentsAndSymbolName(symbol); + } } } + + recur(symbol, meaning, /*endOfChain*/ true); } // Get qualified name if the symbol is not a type parameter diff --git a/tests/baselines/reference/augmentExportEquals3.symbols b/tests/baselines/reference/augmentExportEquals3.symbols index c7338867021..485f977321f 100644 --- a/tests/baselines/reference/augmentExportEquals3.symbols +++ b/tests/baselines/reference/augmentExportEquals3.symbols @@ -1,10 +1,10 @@ === tests/cases/compiler/file1.ts === function foo() {} ->foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 17), Decl(file2.ts, 1, 8)) +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 17), Decl(file2.ts, 1, 8)) namespace foo { ->foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 17), Decl(file2.ts, 1, 8)) +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 17), Decl(file2.ts, 1, 8)) export var v = 1; >v : Symbol(v, Decl(file1.ts, 3, 14)) diff --git a/tests/baselines/reference/augmentExportEquals3.types b/tests/baselines/reference/augmentExportEquals3.types index 4df7bbc60fa..47c92ab343f 100644 --- a/tests/baselines/reference/augmentExportEquals3.types +++ b/tests/baselines/reference/augmentExportEquals3.types @@ -1,10 +1,10 @@ === tests/cases/compiler/file1.ts === function foo() {} ->foo : typeof +>foo : typeof foo namespace foo { ->foo : typeof +>foo : typeof foo export var v = 1; >v : number diff --git a/tests/baselines/reference/augmentExportEquals3_1.symbols b/tests/baselines/reference/augmentExportEquals3_1.symbols index 09827aaa094..ad3505c2835 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.symbols +++ b/tests/baselines/reference/augmentExportEquals3_1.symbols @@ -1,10 +1,10 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { function foo(): void; ->foo : Symbol(, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25), Decl(file2.ts, 2, 8)) +>foo : Symbol(foo, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25), Decl(file2.ts, 2, 8)) namespace foo { ->foo : Symbol(, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25), Decl(file2.ts, 2, 8)) +>foo : Symbol(foo, Decl(file1.d.ts, 0, 24), Decl(file1.d.ts, 1, 25), Decl(file2.ts, 2, 8)) export var v: number; >v : Symbol(v, Decl(file1.d.ts, 3, 18)) diff --git a/tests/baselines/reference/augmentExportEquals3_1.types b/tests/baselines/reference/augmentExportEquals3_1.types index 8a70a6ec0a6..48aa4781676 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.types +++ b/tests/baselines/reference/augmentExportEquals3_1.types @@ -1,10 +1,10 @@ === tests/cases/compiler/file1.d.ts === declare module "file1" { function foo(): void; ->foo : typeof +>foo : typeof foo namespace foo { ->foo : typeof +>foo : typeof foo export var v: number; >v : number diff --git a/tests/baselines/reference/augmentExportEquals4.symbols b/tests/baselines/reference/augmentExportEquals4.symbols index 94941693bae..7394e8c6b28 100644 --- a/tests/baselines/reference/augmentExportEquals4.symbols +++ b/tests/baselines/reference/augmentExportEquals4.symbols @@ -1,10 +1,10 @@ === tests/cases/compiler/file1.ts === class foo {} ->foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 8)) +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 8)) namespace foo { ->foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 8)) +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 8)) export var v = 1; >v : Symbol(v, Decl(file1.ts, 3, 14)) diff --git a/tests/baselines/reference/augmentExportEquals4.types b/tests/baselines/reference/augmentExportEquals4.types index 3d25ae2decb..8d3b6ecc891 100644 --- a/tests/baselines/reference/augmentExportEquals4.types +++ b/tests/baselines/reference/augmentExportEquals4.types @@ -1,10 +1,10 @@ === tests/cases/compiler/file1.ts === class foo {} ->foo : +>foo : foo namespace foo { ->foo : typeof +>foo : typeof foo export var v = 1; >v : number diff --git a/tests/baselines/reference/augmentExportEquals4_1.symbols b/tests/baselines/reference/augmentExportEquals4_1.symbols index 5c4aadbdf83..9954f71bfbc 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.symbols +++ b/tests/baselines/reference/augmentExportEquals4_1.symbols @@ -2,10 +2,10 @@ declare module "file1" { class foo {} ->foo : Symbol(, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 2, 8)) +>foo : Symbol(foo, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 2, 8)) namespace foo { ->foo : Symbol(, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 2, 8)) +>foo : Symbol(foo, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 2, 8)) export var v: number; >v : Symbol(v, Decl(file1.d.ts, 4, 18)) diff --git a/tests/baselines/reference/augmentExportEquals4_1.types b/tests/baselines/reference/augmentExportEquals4_1.types index 9f219286000..a16efb29ce1 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.types +++ b/tests/baselines/reference/augmentExportEquals4_1.types @@ -2,10 +2,10 @@ declare module "file1" { class foo {} ->foo : +>foo : foo namespace foo { ->foo : typeof +>foo : typeof foo export var v: number; >v : number diff --git a/tests/baselines/reference/augmentExportEquals5.symbols b/tests/baselines/reference/augmentExportEquals5.symbols index 37fa00bd8cc..09da5f32d72 100644 --- a/tests/baselines/reference/augmentExportEquals5.symbols +++ b/tests/baselines/reference/augmentExportEquals5.symbols @@ -16,12 +16,12 @@ declare module Express { declare module "express" { function e(): e.Express; ->e : Symbol(, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28), Decl(augmentation.ts, 1, 29)) +>e : Symbol(e, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28), Decl(augmentation.ts, 1, 29)) >e : Symbol(e, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28)) >Express : Symbol(Express, Decl(express.d.ts, 54, 9)) namespace e { ->e : Symbol(, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28), Decl(augmentation.ts, 1, 29)) +>e : Symbol(e, Decl(express.d.ts, 8, 26), Decl(express.d.ts, 9, 28), Decl(augmentation.ts, 1, 29)) interface IRoute { >IRoute : Symbol(IRoute, Decl(express.d.ts, 10, 17)) diff --git a/tests/baselines/reference/augmentExportEquals5.types b/tests/baselines/reference/augmentExportEquals5.types index 42b79674dfd..7d4d765e5ee 100644 --- a/tests/baselines/reference/augmentExportEquals5.types +++ b/tests/baselines/reference/augmentExportEquals5.types @@ -16,12 +16,12 @@ declare module Express { declare module "express" { function e(): e.Express; ->e : typeof +>e : typeof e >e : any >Express : Express namespace e { ->e : typeof +>e : typeof e interface IRoute { >IRoute : IRoute diff --git a/tests/baselines/reference/augmentExportEquals6.symbols b/tests/baselines/reference/augmentExportEquals6.symbols index 4af820f24d7..9ccf8685af7 100644 --- a/tests/baselines/reference/augmentExportEquals6.symbols +++ b/tests/baselines/reference/augmentExportEquals6.symbols @@ -1,10 +1,10 @@ === tests/cases/compiler/file1.ts === class foo {} ->foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 10)) +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 10)) namespace foo { ->foo : Symbol(, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 10)) +>foo : Symbol(foo, Decl(file1.ts, 0, 0), Decl(file1.ts, 1, 12), Decl(file2.ts, 1, 10)) export class A {} >A : Symbol(A, Decl(file1.ts, 2, 15), Decl(file2.ts, 4, 26)) diff --git a/tests/baselines/reference/augmentExportEquals6.types b/tests/baselines/reference/augmentExportEquals6.types index 1a2b2b22ccb..4cb7f3e2b63 100644 --- a/tests/baselines/reference/augmentExportEquals6.types +++ b/tests/baselines/reference/augmentExportEquals6.types @@ -1,10 +1,10 @@ === tests/cases/compiler/file1.ts === class foo {} ->foo : +>foo : foo namespace foo { ->foo : typeof +>foo : typeof foo export class A {} >A : A diff --git a/tests/baselines/reference/augmentExportEquals6_1.symbols b/tests/baselines/reference/augmentExportEquals6_1.symbols index 3db6702448e..c66f01e2d14 100644 --- a/tests/baselines/reference/augmentExportEquals6_1.symbols +++ b/tests/baselines/reference/augmentExportEquals6_1.symbols @@ -2,10 +2,10 @@ declare module "file1" { class foo {} ->foo : Symbol(, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 1, 28)) +>foo : Symbol(foo, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 1, 28)) namespace foo { ->foo : Symbol(, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 1, 28)) +>foo : Symbol(foo, Decl(file1.d.ts, 1, 24), Decl(file1.d.ts, 2, 16), Decl(file2.ts, 1, 28)) class A {} >A : Symbol(A, Decl(file1.d.ts, 3, 19), Decl(file2.ts, 4, 24)) diff --git a/tests/baselines/reference/augmentExportEquals6_1.types b/tests/baselines/reference/augmentExportEquals6_1.types index a9cc78056c8..9d6042ee659 100644 --- a/tests/baselines/reference/augmentExportEquals6_1.types +++ b/tests/baselines/reference/augmentExportEquals6_1.types @@ -2,10 +2,10 @@ declare module "file1" { class foo {} ->foo : +>foo : foo namespace foo { ->foo : typeof +>foo : typeof foo class A {} >A : A diff --git a/tests/baselines/reference/moduleAugmentationGlobal1.symbols b/tests/baselines/reference/moduleAugmentationGlobal1.symbols index 4115379b0f2..53cc4500e07 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal1.symbols +++ b/tests/baselines/reference/moduleAugmentationGlobal1.symbols @@ -10,7 +10,7 @@ import {A} from "./f1"; // change the shape of Array declare global { ->global : Symbol(, Decl(f2.ts, 0, 23)) +>global : Symbol(global, Decl(f2.ts, 0, 23)) interface Array { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(f2.ts, 3, 16)) diff --git a/tests/baselines/reference/moduleAugmentationGlobal2.symbols b/tests/baselines/reference/moduleAugmentationGlobal2.symbols index 48fe93353fb..0e6d8a6024d 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal2.symbols +++ b/tests/baselines/reference/moduleAugmentationGlobal2.symbols @@ -10,7 +10,7 @@ import {A} from "./f1"; >A : Symbol(A, Decl(f2.ts, 2, 8)) declare global { ->global : Symbol(, Decl(f2.ts, 2, 23)) +>global : Symbol(global, Decl(f2.ts, 2, 23)) interface Array { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(f2.ts, 4, 16)) diff --git a/tests/baselines/reference/moduleAugmentationGlobal3.symbols b/tests/baselines/reference/moduleAugmentationGlobal3.symbols index 41c7f25b818..1521fbb6e34 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal3.symbols +++ b/tests/baselines/reference/moduleAugmentationGlobal3.symbols @@ -10,7 +10,7 @@ import {A} from "./f1"; >A : Symbol(A, Decl(f2.ts, 2, 8)) declare global { ->global : Symbol(, Decl(f2.ts, 2, 23)) +>global : Symbol(global, Decl(f2.ts, 2, 23)) interface Array { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(f2.ts, 4, 16)) diff --git a/tests/baselines/reference/moduleAugmentationGlobal4.symbols b/tests/baselines/reference/moduleAugmentationGlobal4.symbols index f9cdac3fc2e..6aaa587234b 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal4.symbols +++ b/tests/baselines/reference/moduleAugmentationGlobal4.symbols @@ -1,7 +1,7 @@ === tests/cases/compiler/f1.ts === declare global { ->global : Symbol(, Decl(f1.ts, 0, 0)) +>global : Symbol(global, Decl(f1.ts, 0, 0)) interface Something {x} >Something : Symbol(Something, Decl(f1.ts, 1, 16), Decl(f2.ts, 1, 16)) @@ -11,7 +11,7 @@ export {}; === tests/cases/compiler/f2.ts === declare global { ->global : Symbol(, Decl(f2.ts, 0, 0)) +>global : Symbol(global, Decl(f2.ts, 0, 0)) interface Something {y} >Something : Symbol(Something, Decl(f1.ts, 1, 16), Decl(f2.ts, 1, 16)) diff --git a/tests/baselines/reference/moduleAugmentationGlobal5.symbols b/tests/baselines/reference/moduleAugmentationGlobal5.symbols index 27548b05ef2..4c4693601e8 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal5.symbols +++ b/tests/baselines/reference/moduleAugmentationGlobal5.symbols @@ -9,7 +9,7 @@ No type information for this code.=== tests/cases/compiler/f1.d.ts === declare module "A" { global { ->global : Symbol(, Decl(f1.d.ts, 1, 20)) +>global : Symbol(global, Decl(f1.d.ts, 1, 20)) interface Something {x} >Something : Symbol(Something, Decl(f1.d.ts, 2, 12), Decl(f2.d.ts, 1, 12)) @@ -19,7 +19,7 @@ declare module "A" { === tests/cases/compiler/f2.d.ts === declare module "B" { global { ->global : Symbol(, Decl(f2.d.ts, 0, 20)) +>global : Symbol(global, Decl(f2.d.ts, 0, 20)) interface Something {y} >Something : Symbol(Something, Decl(f1.d.ts, 2, 12), Decl(f2.d.ts, 1, 12)) diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.symbols b/tests/baselines/reference/moduleAugmentationInAmbientModule5.symbols index 76b135307dd..a8cc1a3412e 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule5.symbols +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.symbols @@ -26,7 +26,7 @@ declare module "array" { >A : Symbol(A, Decl(array.d.ts, 6, 12)) global { ->global : Symbol(, Decl(array.d.ts, 6, 24)) +>global : Symbol(global, Decl(array.d.ts, 6, 24)) interface Array { >Array : Symbol(Array, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --), Decl(array.d.ts, 7, 12)) diff --git a/tests/baselines/reference/module_augmentUninstantiatedModule.symbols b/tests/baselines/reference/module_augmentUninstantiatedModule.symbols index d405f9549ea..4ea073b0254 100644 --- a/tests/baselines/reference/module_augmentUninstantiatedModule.symbols +++ b/tests/baselines/reference/module_augmentUninstantiatedModule.symbols @@ -1,10 +1,10 @@ === tests/cases/compiler/module_augmentUninstantiatedModule.ts === declare module "foo" { namespace M {} ->M : Symbol(, Decl(module_augmentUninstantiatedModule.ts, 0, 22), Decl(module_augmentUninstantiatedModule.ts, 2, 6), Decl(module_augmentUninstantiatedModule.ts, 6, 22)) +>M : Symbol(M, Decl(module_augmentUninstantiatedModule.ts, 0, 22), Decl(module_augmentUninstantiatedModule.ts, 2, 6), Decl(module_augmentUninstantiatedModule.ts, 6, 22)) var M; ->M : Symbol(, Decl(module_augmentUninstantiatedModule.ts, 0, 22), Decl(module_augmentUninstantiatedModule.ts, 2, 6), Decl(module_augmentUninstantiatedModule.ts, 6, 22)) +>M : Symbol(M, Decl(module_augmentUninstantiatedModule.ts, 0, 22), Decl(module_augmentUninstantiatedModule.ts, 2, 6), Decl(module_augmentUninstantiatedModule.ts, 6, 22)) export = M; >M : Symbol(M, Decl(module_augmentUninstantiatedModule.ts, 0, 22), Decl(module_augmentUninstantiatedModule.ts, 2, 6)) diff --git a/tests/baselines/reference/systemModule15.types b/tests/baselines/reference/systemModule15.types index 502638dab93..fa16cc3ce10 100644 --- a/tests/baselines/reference/systemModule15.types +++ b/tests/baselines/reference/systemModule15.types @@ -25,9 +25,9 @@ use(moduleB.moduleC); use(moduleB.moduleCStar); >use(moduleB.moduleCStar) : void >use : (v: any) => void ->moduleB.moduleCStar : typeof +>moduleB.moduleCStar : typeof "tests/cases/compiler/file3" >moduleB : typeof moduleB ->moduleCStar : typeof +>moduleCStar : typeof "tests/cases/compiler/file3" === tests/cases/compiler/file2.ts === diff --git a/tests/cases/fourslash/jsRequireQuickInfo.ts b/tests/cases/fourslash/jsRequireQuickInfo.ts new file mode 100644 index 00000000000..1bf0a3f7f30 --- /dev/null +++ b/tests/cases/fourslash/jsRequireQuickInfo.ts @@ -0,0 +1,11 @@ +/// + +// @allowJs: true +// @Filename: a.js +////const /**/x = require("./b"); + +// @Filename: b.js +////exports.x = 0; + +goTo.marker(); +verify.quickInfoIs('const x: typeof "tests/cases/fourslash/b"'); From 0b71f5f6617f0a421f0c3d2c7fa009c5c0923faa Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 23 Aug 2016 13:38:39 -0700 Subject: [PATCH 254/508] An import ending in "/" is always an import of a directory. --- src/compiler/core.ts | 14 ++++++++++++- src/compiler/program.ts | 2 +- ...gBasedModuleResolution7_classic.trace.json | 6 +++--- ...pingBasedModuleResolution7_node.trace.json | 6 +++--- .../reference/relativeModuleWithoutSlash.js | 8 ++++---- .../relativeModuleWithoutSlash.symbols | 12 +++++------ .../relativeModuleWithoutSlash.trace.json | 18 +++++++++-------- .../relativeModuleWithoutSlash.types | 20 +++++++++---------- .../compiler/relativeModuleWithoutSlash.ts | 4 ++-- 9 files changed, 52 insertions(+), 38 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 27b27bc6532..a0c869e612a 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -829,8 +829,20 @@ namespace ts { export function normalizePath(path: string): string { path = normalizeSlashes(path); const rootLength = getRootLength(path); + const root = path.substr(0, rootLength); const normalized = getNormalizedParts(path, rootLength); - return path.substr(0, rootLength) + normalized.join(directorySeparator); + if (normalized.length) { + const joinedParts = root + normalized.join(directorySeparator); + return isPathToDirectory(path) ? joinedParts + "/" : joinedParts; + } + else { + return root; + } + } + + /** A path ending with '/' refers to a directory only, never a file. */ + export function isPathToDirectory(path: string): boolean { + return path.charCodeAt(path.length - 1) === CharacterCodes.slash; } export function getDirectoryPath(path: Path): Path; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f099d858119..ca756b6f1dd 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -646,7 +646,7 @@ namespace ts { trace(state.host, Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0, candidate); } - const resolvedFileName = loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); + const resolvedFileName = !isPathToDirectory(candidate) && loadModuleFromFile(candidate, supportedExtensions, failedLookupLocations, onlyRecordFailures, state); return resolvedFileName || loadNodeModuleFromDirectory(supportedExtensions, candidate, failedLookupLocations, onlyRecordFailures, state); } diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.trace.json index 2d72108210e..a8cadb8f067 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution7_classic.trace.json @@ -14,7 +14,7 @@ "======== Module name './project/file2' was successfully resolved to 'c:/root/generated/src/project/file2.ts'. ========", "======== Resolving module 'module3' from 'c:/root/src/file1.ts'. ========", "Module resolution kind is not specified, using 'Classic'.", - "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'module3'", + "'baseUrl' option is set to 'c:/root/', using this value to resolve non-relative module name 'module3'", "'paths' option is specified, looking for a pattern to match module name 'module3'.", "Module name 'module3', matched pattern '*'.", "Trying substitution '*', candidate module location: 'module3'.", @@ -32,7 +32,7 @@ "======== Module name 'module3' was successfully resolved to 'c:/module3.d.ts'. ========", "======== Resolving module 'module1' from 'c:/root/generated/src/project/file2.ts'. ========", "Module resolution kind is not specified, using 'Classic'.", - "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'module1'", + "'baseUrl' option is set to 'c:/root/', using this value to resolve non-relative module name 'module1'", "'paths' option is specified, looking for a pattern to match module name 'module1'.", "Module name 'module1', matched pattern '*'.", "Trying substitution '*', candidate module location: 'module1'.", @@ -44,7 +44,7 @@ "======== Module name 'module1' was successfully resolved to 'c:/shared/module1.d.ts'. ========", "======== Resolving module 'templates/module2' from 'c:/root/generated/src/project/file2.ts'. ========", "Module resolution kind is not specified, using 'Classic'.", - "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'templates/module2'", + "'baseUrl' option is set to 'c:/root/', using this value to resolve non-relative module name 'templates/module2'", "'paths' option is specified, looking for a pattern to match module name 'templates/module2'.", "Module name 'templates/module2', matched pattern 'templates/*'.", "Trying substitution 'generated/src/templates/*', candidate module location: 'generated/src/templates/module2'.", diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution7_node.trace.json b/tests/baselines/reference/pathMappingBasedModuleResolution7_node.trace.json index 6be7d349fed..48633c85e3b 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution7_node.trace.json +++ b/tests/baselines/reference/pathMappingBasedModuleResolution7_node.trace.json @@ -22,7 +22,7 @@ "======== Module name './project/file2' was successfully resolved to 'c:/root/generated/src/project/file2.ts'. ========", "======== Resolving module 'module3' from 'c:/root/src/file1.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'module3'", + "'baseUrl' option is set to 'c:/root/', using this value to resolve non-relative module name 'module3'", "'paths' option is specified, looking for a pattern to match module name 'module3'.", "Module name 'module3', matched pattern '*'.", "Trying substitution '*', candidate module location: 'module3'.", @@ -79,7 +79,7 @@ "======== Module name 'module3' was successfully resolved to 'c:/node_modules/module3.d.ts'. ========", "======== Resolving module 'module1' from 'c:/root/generated/src/project/file2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'module1'", + "'baseUrl' option is set to 'c:/root/', using this value to resolve non-relative module name 'module1'", "'paths' option is specified, looking for a pattern to match module name 'module1'.", "Module name 'module1', matched pattern '*'.", "Trying substitution '*', candidate module location: 'module1'.", @@ -104,7 +104,7 @@ "======== Module name 'module1' was successfully resolved to 'c:/shared/module1/index.d.ts'. ========", "======== Resolving module 'templates/module2' from 'c:/root/generated/src/project/file2.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", - "'baseUrl' option is set to 'c:/root', using this value to resolve non-relative module name 'templates/module2'", + "'baseUrl' option is set to 'c:/root/', using this value to resolve non-relative module name 'templates/module2'", "'paths' option is specified, looking for a pattern to match module name 'templates/module2'.", "Module name 'templates/module2', matched pattern 'templates/*'.", "Trying substitution 'generated/src/templates/*', candidate module location: 'generated/src/templates/module2'.", diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.js b/tests/baselines/reference/relativeModuleWithoutSlash.js index f83406499d4..e52d0cd19ed 100644 --- a/tests/baselines/reference/relativeModuleWithoutSlash.js +++ b/tests/baselines/reference/relativeModuleWithoutSlash.js @@ -11,13 +11,13 @@ export default { aIndex: 0 }; import a from "."; import aIndex from "./"; a.a; -aIndex.a; //aIndex.aIndex; See GH#9690 +aIndex.aIndex; //// [test.ts] import a from ".."; import aIndex from "../"; a.a; -aIndex.a; //aIndex.aIndex; +aIndex.aIndex; //// [a.js] @@ -33,10 +33,10 @@ exports["default"] = { aIndex: 0 }; var _1 = require("."); var _2 = require("./"); _1["default"].a; -_2["default"].a; //aIndex.aIndex; See GH#9690 +_2["default"].aIndex; //// [test.js] "use strict"; var __1 = require(".."); var _1 = require("../"); __1["default"].a; -_1["default"].a; //aIndex.aIndex; +_1["default"].aIndex; diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.symbols b/tests/baselines/reference/relativeModuleWithoutSlash.symbols index 8c54a0682c7..4a9f8b41569 100644 --- a/tests/baselines/reference/relativeModuleWithoutSlash.symbols +++ b/tests/baselines/reference/relativeModuleWithoutSlash.symbols @@ -19,10 +19,10 @@ a.a; >a : Symbol(a, Decl(test.ts, 0, 6)) >a : Symbol(a, Decl(a.ts, 1, 16)) -aIndex.a; //aIndex.aIndex; See GH#9690 ->aIndex.a : Symbol(a, Decl(a.ts, 1, 16)) +aIndex.aIndex; +>aIndex.aIndex : Symbol(aIndex, Decl(index.ts, 0, 16)) >aIndex : Symbol(aIndex, Decl(test.ts, 1, 6)) ->a : Symbol(a, Decl(a.ts, 1, 16)) +>aIndex : Symbol(aIndex, Decl(index.ts, 0, 16)) === /a/b/test.ts === import a from ".."; @@ -36,8 +36,8 @@ a.a; >a : Symbol(a, Decl(test.ts, 0, 6)) >a : Symbol(a, Decl(a.ts, 1, 16)) -aIndex.a; //aIndex.aIndex; ->aIndex.a : Symbol(a, Decl(a.ts, 1, 16)) +aIndex.aIndex; +>aIndex.aIndex : Symbol(aIndex, Decl(index.ts, 0, 16)) >aIndex : Symbol(aIndex, Decl(test.ts, 1, 6)) ->a : Symbol(a, Decl(a.ts, 1, 16)) +>aIndex : Symbol(aIndex, Decl(index.ts, 0, 16)) diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.trace.json b/tests/baselines/reference/relativeModuleWithoutSlash.trace.json index cee5b060676..3c99d4eb6a0 100644 --- a/tests/baselines/reference/relativeModuleWithoutSlash.trace.json +++ b/tests/baselines/reference/relativeModuleWithoutSlash.trace.json @@ -7,10 +7,11 @@ "======== Module name '.' was successfully resolved to '/a.ts'. ========", "======== Resolving module './' from '/a/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/a'.", - "File '/a.ts' exist - use it as a name resolution result.", - "Resolving real path for '/a.ts', result '/a.ts'", - "======== Module name './' was successfully resolved to '/a.ts'. ========", + "Loading module as file / folder, candidate module location '/a/'.", + "File '/a/package.json' does not exist.", + "File '/a/index.ts' exist - use it as a name resolution result.", + "Resolving real path for '/a/index.ts', result '/a/index.ts'", + "======== Module name './' was successfully resolved to '/a/index.ts'. ========", "======== Resolving module '..' from '/a/b/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module as file / folder, candidate module location '/a'.", @@ -19,8 +20,9 @@ "======== Module name '..' was successfully resolved to '/a.ts'. ========", "======== Resolving module '../' from '/a/b/test.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", - "Loading module as file / folder, candidate module location '/a'.", - "File '/a.ts' exist - use it as a name resolution result.", - "Resolving real path for '/a.ts', result '/a.ts'", - "======== Module name '../' was successfully resolved to '/a.ts'. ========" + "Loading module as file / folder, candidate module location '/a/'.", + "File '/a/package.json' does not exist.", + "File '/a/index.ts' exist - use it as a name resolution result.", + "Resolving real path for '/a/index.ts', result '/a/index.ts'", + "======== Module name '../' was successfully resolved to '/a/index.ts'. ========" ] \ No newline at end of file diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.types b/tests/baselines/reference/relativeModuleWithoutSlash.types index 796ef714dd9..b84b57814be 100644 --- a/tests/baselines/reference/relativeModuleWithoutSlash.types +++ b/tests/baselines/reference/relativeModuleWithoutSlash.types @@ -16,32 +16,32 @@ import a from "."; >a : { a: number; } import aIndex from "./"; ->aIndex : { a: number; } +>aIndex : { aIndex: number; } a.a; >a.a : number >a : { a: number; } >a : number -aIndex.a; //aIndex.aIndex; See GH#9690 ->aIndex.a : number ->aIndex : { a: number; } ->a : number +aIndex.aIndex; +>aIndex.aIndex : number +>aIndex : { aIndex: number; } +>aIndex : number === /a/b/test.ts === import a from ".."; >a : { a: number; } import aIndex from "../"; ->aIndex : { a: number; } +>aIndex : { aIndex: number; } a.a; >a.a : number >a : { a: number; } >a : number -aIndex.a; //aIndex.aIndex; ->aIndex.a : number ->aIndex : { a: number; } ->a : number +aIndex.aIndex; +>aIndex.aIndex : number +>aIndex : { aIndex: number; } +>aIndex : number diff --git a/tests/cases/compiler/relativeModuleWithoutSlash.ts b/tests/cases/compiler/relativeModuleWithoutSlash.ts index 42b328e1175..a5bceff8b13 100644 --- a/tests/cases/compiler/relativeModuleWithoutSlash.ts +++ b/tests/cases/compiler/relativeModuleWithoutSlash.ts @@ -11,10 +11,10 @@ export default { aIndex: 0 }; import a from "."; import aIndex from "./"; a.a; -aIndex.a; //aIndex.aIndex; See GH#9690 +aIndex.aIndex; // @Filename: /a/b/test.ts import a from ".."; import aIndex from "../"; a.a; -aIndex.a; //aIndex.aIndex; +aIndex.aIndex; From c71c5a876ea357993759ab663a8bc3e098f13afa Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Tue, 23 Aug 2016 16:45:51 -0700 Subject: [PATCH 255/508] Using for..of instead of forEach --- src/harness/harnessLanguageService.ts | 4 +- src/services/services.ts | 74 ++++++++++++++------------- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 5ae6a33463b..880a103a202 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -135,14 +135,14 @@ namespace Harness.LanguageService { public getFilenames(): string[] { const fileNames: string[] = []; - ts.forEach(this.virtualFileSystem.getAllFileEntries(), (virtualEntry) => { + for (const virtualEntry of this.virtualFileSystem.getAllFileEntries()){ const scriptInfo = virtualEntry.content; if (scriptInfo.isRootFile) { // only include root files here // usually it means that we won't include lib.d.ts in the list of root files so it won't mess the computation of compilation root dir. fileNames.push(scriptInfo.fileName); } - }); + } return fileNames; } diff --git a/src/services/services.ts b/src/services/services.ts index 4c199de1869..48cc186f7ec 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4559,12 +4559,12 @@ namespace ts { // Determine the path to the directory containing the script relative to the root directory it is contained within let relativeDirectory: string; - forEach(rootDirs, rootDirectory => { + for (const rootDirectory of rootDirs) { if (containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { relativeDirectory = scriptPath.substr(rootDirectory.length); - return true; + break; } - }); + } // Now find a path for each potential directory that is to be merged with the one containing the script return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); @@ -4600,10 +4600,10 @@ namespace ts { if (directoryProbablyExists(baseDirectory, host)) { // Enumerate the available files const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); - forEach(files, filePath => { + for (let filePath of files) { filePath = normalizePath(filePath); if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { - return false; + continue; } const fileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); @@ -4616,20 +4616,20 @@ namespace ts { sortText: fileName }); } - }); + } // If possible, get folder completion as well if (host.getDirectories) { const directories = host.getDirectories(baseDirectory); - forEach(directories, d => { - const directoryName = getBaseFileName(normalizePath(d)); + for (const directory of directories) { + const directoryName = getBaseFileName(normalizePath(directory)); result.push({ name: directoryName, kind: ScriptElementKind.directory, sortText: directoryName }); - }); + } } } @@ -4660,11 +4660,11 @@ namespace ts { if (paths.hasOwnProperty(path)) { if (path === "*") { if (paths[path]) { - forEach(paths[path], pattern => { - forEach(getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions), match => { + for (const pattern of paths[path]) { + for (const match of getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions)) { result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName)); - }); - }); + } + } } } else if (startsWith(path, fragment)) { @@ -4683,9 +4683,9 @@ namespace ts { getCompletionEntriesFromTypings(host, options, scriptPath, result); - forEach(enumeratePotentialNonRelativeModules(fragment, scriptPath, options), moduleName => { + for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, options)) { result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); - }); + } return result; } @@ -4717,17 +4717,17 @@ namespace ts { const result: string[] = []; // Trim away prefix and suffix - forEach(matches, match => { + for (const match of matches) { const normalizedMatch = normalizePath(match); if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { - return; + continue; } const start = completePrefix.length; const length = normalizedMatch.length - start - normalizedSuffix.length; result.push(removeFileExtension(normalizedMatch.substr(start, length))); - }); + } return result; } @@ -4740,15 +4740,15 @@ namespace ts { const moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(directorySeparator)) : undefined; // Get modules that the type checker picked up - const ambientModules = ts.map(program.getTypeChecker().getAmbientModules(), sym => stripQuotes(sym.name)); - let nonRelativeModules = ts.filter(ambientModules, moduleName => startsWith(moduleName, fragment)); + const ambientModules = map(program.getTypeChecker().getAmbientModules(), sym => stripQuotes(sym.name)); + let nonRelativeModules = filter(ambientModules, moduleName => startsWith(moduleName, fragment)); // Nested modules of the form "module-name/sub" need to be adjusted to only return the string // after the last '/' that appears in the fragment because that's where the replacement span // starts if (isNestedModule) { const moduleNameWithSeperator = ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, moduleName => { + nonRelativeModules = map(nonRelativeModules, moduleName => { if (startsWith(fragment, moduleNameWithSeperator)) { return moduleName.substr(moduleNameWithSeperator.length); } @@ -4758,20 +4758,20 @@ namespace ts { if (!options.moduleResolution || options.moduleResolution === ModuleResolutionKind.NodeJs) { - forEach(enumerateNodeModulesVisibleToScript(host, scriptPath), visibleModule => { + for (const visibleModule of enumerateNodeModulesVisibleToScript(host, scriptPath)) { if (!isNestedModule) { nonRelativeModules.push(visibleModule.moduleName); } else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); - forEach(nestedFiles, (f) => { + for (let f of nestedFiles) { f = normalizePath(f); const nestedModule = removeFileExtension(getBaseFileName(f)); nonRelativeModules.push(nestedModule); - }); + } } - }); + } } return deduplicate(nonRelativeModules); @@ -4827,9 +4827,9 @@ namespace ts { function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { // Check for typings specified in compiler options if (options.types) { - forEach(options.types, moduleName => { + for (const moduleName of options.types){ result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); - }); + } } else if (host.getDirectories && options.typeRoots) { const absoluteRoots = map(options.typeRoots, rootDirectory => { @@ -4840,15 +4840,17 @@ namespace ts { const basePath = options.project || host.getCurrentDirectory(); return normalizePath(combinePaths(basePath, rootDirectory)); }); - forEach(absoluteRoots, absoluteRoot => getCompletionEntriesFromDirectories(host, options, absoluteRoot, result)); + for (const absoluteRoot of absoluteRoots) { + getCompletionEntriesFromDirectories(host, options, absoluteRoot, result); + } } if (host.getDirectories) { // Also get all @types typings installed in visible node_modules directories - forEach(findPackageJsons(scriptPath), package => { + for (const package of findPackageJsons(scriptPath)) { const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); getCompletionEntriesFromDirectories(host, options, typesDir, result); - }); + } } return result; @@ -4856,10 +4858,10 @@ namespace ts { function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: ImportCompletionEntry[]) { if (host.getDirectories && directoryProbablyExists(directory, host)) { - forEach(host.getDirectories(directory), typeDirectory => { + for (let typeDirectory of host.getDirectories(directory)) { typeDirectory = normalizePath(typeDirectory); result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName)); - }); + } } } @@ -4889,7 +4891,7 @@ namespace ts { function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { const result: VisibleModuleInfo[] = []; - findPackageJsons(scriptPath).forEach((packageJson) => { + for (const packageJson of findPackageJsons(scriptPath)) { const package = tryReadingPackageJson(packageJson); if (!package) { return; @@ -4905,14 +4907,14 @@ namespace ts { addPotentialPackageNames(package.devDependencies, foundModuleNames); } - forEach(foundModuleNames, (moduleName) => { + for (const moduleName of foundModuleNames) { const moduleDir = combinePaths(nodeModulesDir, moduleName); result.push({ moduleName, moduleDir }); - }); - }); + } + } return result; From d44385577f7f79dbba95703ad6f5eb126710b433 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 24 Aug 2016 06:47:15 -0700 Subject: [PATCH 256/508] Rename function and clean up code --- src/compiler/checker.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 00801fce0c0..3e566f1b77c 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2067,7 +2067,7 @@ namespace ts { // and we could then access that data during declaration emit. writer.trackSymbol(symbol, enclosingDeclaration, meaning); function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void { - function recur(symbol: Symbol, meaning: SymbolFlags, endOfChain?: boolean): void { + function climbSymbol(symbol: Symbol, meaning: SymbolFlags, endOfChain?: boolean): void { if (symbol) { const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); @@ -2075,7 +2075,7 @@ namespace ts { needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { // Go up and add our parent. - recur( + climbSymbol( getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), getQualifiedLeftMeaning(meaning)); } @@ -2098,7 +2098,7 @@ namespace ts { } } - recur(symbol, meaning, /*endOfChain*/ true); + climbSymbol(symbol, meaning, /*endOfChain*/ true); } // Get qualified name if the symbol is not a type parameter @@ -2108,10 +2108,10 @@ namespace ts { const typeFormatFlag = TypeFormatFlags.UseFullyQualifiedType & typeFlags; if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { walkSymbol(symbol, meaning); - return; } - - return appendParentTypeArgumentsAndSymbolName(symbol); + else { + appendParentTypeArgumentsAndSymbolName(symbol); + } } function buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]) { From 73c3961355322515567875286141c4da723fb8ae Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 24 Aug 2016 18:50:04 -0700 Subject: [PATCH 257/508] Adding display parts to definition items to support FindAllReferences --- src/services/services.ts | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index babb5cf4574..7718be5a3d4 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -300,8 +300,8 @@ namespace ts { } } // For syntactic classifications, all trivia are classcified together, including jsdoc comments. - // For that to work, the jsdoc comments should still be the leading trivia of the first child. - // Restoring the scanner position ensures that. + // For that to work, the jsdoc comments should still be the leading trivia of the first child. + // Restoring the scanner position ensures that. pos = this.pos; forEachChild(this, processNode, processNodes); if (pos < this.end) { @@ -1374,8 +1374,13 @@ namespace ts { containerName: string; } + export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { + // For more complex definitions where kind and name are insufficient to properly colorize the text + displayParts?: SymbolDisplayPart[]; + } + export interface ReferencedSymbol { - definition: DefinitionInfo; + definition: ReferencedSymbolDefinitionInfo; references: ReferenceEntry[]; } @@ -6108,7 +6113,7 @@ namespace ts { return result; - function getDefinition(symbol: Symbol): DefinitionInfo { + function getDefinition(symbol: Symbol): ReferencedSymbolDefinitionInfo { const info = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, node.getSourceFile(), getContainerNode(node), node); const name = map(info.displayParts, p => p.text).join(""); const declarations = symbol.declarations; @@ -6122,7 +6127,8 @@ namespace ts { name, kind: info.symbolKind, fileName: declarations[0].getSourceFile().fileName, - textSpan: createTextSpan(declarations[0].getStart(), 0) + textSpan: createTextSpan(declarations[0].getStart(), 0), + displayParts: info.displayParts }; } @@ -6317,7 +6323,7 @@ namespace ts { } }); - const definition: DefinitionInfo = { + const definition: ReferencedSymbolDefinitionInfo = { containerKind: "", containerName: "", fileName: targetLabel.getSourceFile().fileName, @@ -6634,6 +6640,11 @@ namespace ts { getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); } + const symbol = typeChecker.getSymbolAtLocation(node); + + const displayParts = symbol ? getSymbolDisplayPartsDocumentationAndSymbolKind( + symbol, node.getSourceFile(), getContainerNode(node), node).displayParts : undefined; + return [{ definition: { containerKind: "", @@ -6641,7 +6652,8 @@ namespace ts { fileName: node.getSourceFile().fileName, kind: ScriptElementKind.variableElement, name: type.text, - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()) + textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), + displayParts }, references: references }]; From 03182bfec58d29973df46b0c95074995b14c768d Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Wed, 24 Aug 2016 21:08:50 -0400 Subject: [PATCH 258/508] Update error message + refactor --- src/compiler/checker.ts | 29 +++++------------ src/compiler/diagnosticMessages.json | 4 +++ .../reference/assignments.errors.txt | 4 +-- ...assExtendsInterfaceInExpression.errors.txt | 4 +-- .../errorsOnImportedSymbol.errors.txt | 8 ++--- .../es6ExportEqualsInterop.errors.txt | 4 +-- ...ignmentOfDeclaredExternalModule.errors.txt | 8 ++--- ...onstructInvocationWithNoTypeArg.errors.txt | 4 +-- ...inheritFromGenericTypeParameter.errors.txt | 4 +-- .../reference/intTypeCheck.errors.txt | 32 +++++++++---------- .../interfaceNameAsIdentifier.errors.txt | 4 +-- .../reference/interfaceNaming1.errors.txt | 8 ++--- .../invalidUndefinedAssignments.errors.txt | 4 +-- ...singES6ArrayWithOnlyES6ArrayLib.errors.txt | 4 +-- .../reference/newOperator.errors.txt | 4 +-- .../reservedNamesInAliases.errors.txt | 4 +-- .../reference/returnTypeParameter.errors.txt | 4 +-- .../typeParameterAsBaseClass.errors.txt | 4 +-- .../typeParameterAsBaseType.errors.txt | 8 ++--- .../reference/typeUsedAsValueError.errors.txt | 20 ++++++------ .../typeUsedAsValueError2.errors.txt | 4 +-- .../reference/typeofSimple.errors.txt | 4 +-- .../reference/typeofTypeParameter.errors.txt | 4 +-- .../reference/validNullAssignments.errors.txt | 4 +-- 24 files changed, 86 insertions(+), 95 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 5b89c185822..d5e4f35d60b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -872,7 +872,7 @@ namespace ts { if (!errorLocation || !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation) && - !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning, nameNotFoundMessage, nameArg)) { + !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); } } @@ -982,28 +982,15 @@ namespace ts { } } - function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): boolean { - const strictlyValueMeanings = SymbolFlags.Value & ~SymbolFlags.Type; - const strictlyTypeMeanings = SymbolFlags.Type & ~SymbolFlags.Value; - - if (!(meaning & strictlyValueMeanings) || meaning & SymbolFlags.NamespaceModule) { - return false; - } - - const nameAsType = resolveName(errorLocation, name, strictlyTypeMeanings, nameNotFoundMessage, nameArg); - if (!nameAsType) { - return false; - } - - if (nameAsType.flags & SymbolFlags.Alias) { - const resolvedSymbol = resolveAlias(nameAsType); - if (resolvedSymbol.flags & SymbolFlags.NamespaceModule) { - return false; + function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: string, meaning: SymbolFlags): boolean { + if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) { + const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); + if (symbol && !(symbol.flags & SymbolFlags.NamespaceModule)) { + error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, name); + return true; } } - - error(errorLocation, Diagnostics.Cannot_find_name_0_A_type_exists_with_this_name_but_no_value, name); - return true; + return false; } function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b8978b32571..645728dab4a 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1959,6 +1959,10 @@ "category": "Error", "code": 2692 }, + "'{0}' only refers to a type, but is being used as a value here.": { + "category": "Error", + "code": 2693 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/assignments.errors.txt b/tests/baselines/reference/assignments.errors.txt index 99457ed5837..2e637a6c720 100644 --- a/tests/baselines/reference/assignments.errors.txt +++ b/tests/baselines/reference/assignments.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(14,1): er tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(18,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): error TS2693: 'I' only refers to a type, but is being used as a value here. ==== tests/cases/conformance/expressions/valuesAndReferences/assignments.ts (6 errors) ==== @@ -49,4 +49,4 @@ tests/cases/conformance/expressions/valuesAndReferences/assignments.ts(31,1): er interface I { } I = null; // Error ~ -!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file +!!! error TS2693: 'I' only refers to a type, but is being used as a value here. \ No newline at end of file diff --git a/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt b/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt index 3bfaba31113..754f7a57f6a 100644 --- a/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt +++ b/tests/baselines/reference/classExtendsInterfaceInExpression.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2692: Cannot find name 'A'. A type exists with this name, but no value. +tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2693: 'A' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/classExtendsInterfaceInExpression.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/classExtendsInterfaceInExpression.ts(7,25): error TS2692: C class C extends factory(A) {} ~ -!!! error TS2692: Cannot find name 'A'. A type exists with this name, but no value. +!!! error TS2693: 'A' only refers to a type, but is being used as a value here. \ No newline at end of file diff --git a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt index 960e707cfee..127026a8e2c 100644 --- a/tests/baselines/reference/errorsOnImportedSymbol.errors.txt +++ b/tests/baselines/reference/errorsOnImportedSymbol.errors.txt @@ -1,15 +1,15 @@ -tests/cases/compiler/errorsOnImportedSymbol_1.ts(2,13): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. -tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. +tests/cases/compiler/errorsOnImportedSymbol_1.ts(2,13): error TS2693: 'Sammy' only refers to a type, but is being used as a value here. +tests/cases/compiler/errorsOnImportedSymbol_1.ts(3,9): error TS2693: 'Sammy' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/errorsOnImportedSymbol_1.ts (2 errors) ==== import Sammy = require("./errorsOnImportedSymbol_0"); var x = new Sammy.Sammy(); ~~~~~ -!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. +!!! error TS2693: 'Sammy' only refers to a type, but is being used as a value here. var y = Sammy.Sammy(); ~~~~~ -!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. +!!! error TS2693: 'Sammy' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/errorsOnImportedSymbol_0.ts (0 errors) ==== diff --git a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt index e5ca006133b..be9aaf35fc4 100644 --- a/tests/baselines/reference/es6ExportEqualsInterop.errors.txt +++ b/tests/baselines/reference/es6ExportEqualsInterop.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/main.ts(15,1): error TS2692: Cannot find name 'z1'. A type exists with this name, but no value. +tests/cases/compiler/main.ts(15,1): error TS2693: 'z1' only refers to a type, but is being used as a value here. tests/cases/compiler/main.ts(21,4): error TS2339: Property 'a' does not exist on type '() => any'. tests/cases/compiler/main.ts(23,4): error TS2339: Property 'a' does not exist on type 'typeof Foo'. tests/cases/compiler/main.ts(27,8): error TS1192: Module '"interface"' has no default export. @@ -49,7 +49,7 @@ tests/cases/compiler/main.ts(106,15): error TS2498: Module '"class-module"' uses z1.a; ~~ -!!! error TS2692: Cannot find name 'z1'. A type exists with this name, but no value. +!!! error TS2693: 'z1' only refers to a type, but is being used as a value here. z2.a; z3.a; z4.a; diff --git a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt index 2d54bfd7e6d..a82be89da4e 100644 --- a/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt +++ b/tests/baselines/reference/exportAssignmentOfDeclaredExternalModule.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(3,13): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. -tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. +tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(3,13): error TS2693: 'Sammy' only refers to a type, but is being used as a value here. +tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error TS2693: 'Sammy' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts (2 errors) ==== @@ -7,10 +7,10 @@ tests/cases/compiler/exportAssignmentOfDeclaredExternalModule_1.ts(4,9): error T import Sammy = require('./exportAssignmentOfDeclaredExternalModule_0'); var x = new Sammy(); // error to use as constructor as there is not constructor symbol ~~~~~ -!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. +!!! error TS2693: 'Sammy' only refers to a type, but is being used as a value here. var y = Sammy(); // error to use interface name as call target ~~~~~ -!!! error TS2692: Cannot find name 'Sammy'. A type exists with this name, but no value. +!!! error TS2693: 'Sammy' only refers to a type, but is being used as a value here. var z: Sammy; // no error - z is of type interface Sammy from module 'M' var a = new z(); // constructor - no error var b = z(); // call signature - no error diff --git a/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt b/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt index cef121150fb..5a4f710ed6d 100644 --- a/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt +++ b/tests/baselines/reference/genericConstructInvocationWithNoTypeArg.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2692: Cannot find name 'Foo'. A type exists with this name, but no value. +tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2693: 'Foo' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/genericConstructInvocationWithNoTypeArg.ts(4,27): error TS2 } var f2: Foo = new Foo(3); ~~~ -!!! error TS2692: Cannot find name 'Foo'. A type exists with this name, but no value. +!!! error TS2693: 'Foo' only refers to a type, but is being used as a value here. \ No newline at end of file diff --git a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt index 86cbc3ac1d6..08d138f2e5d 100644 --- a/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt +++ b/tests/baselines/reference/inheritFromGenericTypeParameter.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/compiler/inheritFromGenericTypeParameter.ts(1,20): error TS2693: 'T' only refers to a type, but is being used as a value here. tests/cases/compiler/inheritFromGenericTypeParameter.ts(2,24): error TS2312: An interface may only extend a class or another interface. ==== tests/cases/compiler/inheritFromGenericTypeParameter.ts (2 errors) ==== class C extends T { } ~ -!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +!!! error TS2693: 'T' only refers to a type, but is being used as a value here. interface I extends T { } ~ !!! error TS2312: An interface may only extend a class or another interface. \ No newline at end of file diff --git a/tests/baselines/reference/intTypeCheck.errors.txt b/tests/baselines/reference/intTypeCheck.errors.txt index 3cd1997dc5a..2214c685956 100644 --- a/tests/baselines/reference/intTypeCheck.errors.txt +++ b/tests/baselines/reference/intTypeCheck.errors.txt @@ -10,7 +10,7 @@ tests/cases/compiler/intTypeCheck.ts(103,5): error TS2322: Type '() => void' is Property 'p' is missing in type '() => void'. tests/cases/compiler/intTypeCheck.ts(106,5): error TS2322: Type 'boolean' is not assignable to type 'i1'. tests/cases/compiler/intTypeCheck.ts(106,20): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(106,21): error TS2692: Cannot find name 'i1'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(106,21): error TS2693: 'i1' only refers to a type, but is being used as a value here. tests/cases/compiler/intTypeCheck.ts(107,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(112,5): error TS2322: Type '{}' is not assignable to type 'i2'. Type '{}' provides no match for the signature '(): any' @@ -21,7 +21,7 @@ tests/cases/compiler/intTypeCheck.ts(115,5): error TS2322: Type 'Base' is not as Type 'Base' provides no match for the signature '(): any' tests/cases/compiler/intTypeCheck.ts(120,5): error TS2322: Type 'boolean' is not assignable to type 'i2'. tests/cases/compiler/intTypeCheck.ts(120,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(120,22): error TS2692: Cannot find name 'i2'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(120,22): error TS2693: 'i2' only refers to a type, but is being used as a value here. tests/cases/compiler/intTypeCheck.ts(121,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(126,5): error TS2322: Type '{}' is not assignable to type 'i3'. Type '{}' provides no match for the signature 'new (): any' @@ -33,12 +33,12 @@ tests/cases/compiler/intTypeCheck.ts(131,5): error TS2322: Type '() => void' is Type '() => void' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(134,5): error TS2322: Type 'boolean' is not assignable to type 'i3'. tests/cases/compiler/intTypeCheck.ts(134,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(134,22): error TS2692: Cannot find name 'i3'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(134,22): error TS2693: 'i3' only refers to a type, but is being used as a value here. tests/cases/compiler/intTypeCheck.ts(135,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(142,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(148,5): error TS2322: Type 'boolean' is not assignable to type 'i4'. tests/cases/compiler/intTypeCheck.ts(148,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(148,22): error TS2692: Cannot find name 'i4'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(148,22): error TS2693: 'i4' only refers to a type, but is being used as a value here. tests/cases/compiler/intTypeCheck.ts(149,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(154,5): error TS2322: Type '{}' is not assignable to type 'i5'. Property 'p' is missing in type '{}'. @@ -51,7 +51,7 @@ tests/cases/compiler/intTypeCheck.ts(159,5): error TS2322: Type '() => void' is Property 'p' is missing in type '() => void'. tests/cases/compiler/intTypeCheck.ts(162,5): error TS2322: Type 'boolean' is not assignable to type 'i5'. tests/cases/compiler/intTypeCheck.ts(162,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(162,22): error TS2692: Cannot find name 'i5'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(162,22): error TS2693: 'i5' only refers to a type, but is being used as a value here. tests/cases/compiler/intTypeCheck.ts(163,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(168,5): error TS2322: Type '{}' is not assignable to type 'i6'. Type '{}' provides no match for the signature '(): any' @@ -64,7 +64,7 @@ tests/cases/compiler/intTypeCheck.ts(173,5): error TS2322: Type '() => void' is Type 'void' is not assignable to type 'number'. tests/cases/compiler/intTypeCheck.ts(176,5): error TS2322: Type 'boolean' is not assignable to type 'i6'. tests/cases/compiler/intTypeCheck.ts(176,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(176,22): error TS2692: Cannot find name 'i6'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(176,22): error TS2693: 'i6' only refers to a type, but is being used as a value here. tests/cases/compiler/intTypeCheck.ts(177,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(182,5): error TS2322: Type '{}' is not assignable to type 'i7'. Type '{}' provides no match for the signature 'new (): any' @@ -76,12 +76,12 @@ tests/cases/compiler/intTypeCheck.ts(187,5): error TS2322: Type '() => void' is Type '() => void' provides no match for the signature 'new (): any' tests/cases/compiler/intTypeCheck.ts(190,5): error TS2322: Type 'boolean' is not assignable to type 'i7'. tests/cases/compiler/intTypeCheck.ts(190,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(190,22): error TS2692: Cannot find name 'i7'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(190,22): error TS2693: 'i7' only refers to a type, but is being used as a value here. tests/cases/compiler/intTypeCheck.ts(191,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(198,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/intTypeCheck.ts(204,5): error TS2322: Type 'boolean' is not assignable to type 'i8'. tests/cases/compiler/intTypeCheck.ts(204,21): error TS1109: Expression expected. -tests/cases/compiler/intTypeCheck.ts(204,22): error TS2692: Cannot find name 'i8'. A type exists with this name, but no value. +tests/cases/compiler/intTypeCheck.ts(204,22): error TS2693: 'i8' only refers to a type, but is being used as a value here. tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -214,7 +214,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2692: Cannot find name 'i1'. A type exists with this name, but no value. +!!! error TS2693: 'i1' only refers to a type, but is being used as a value here. var obj10: i1 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -247,7 +247,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2692: Cannot find name 'i2'. A type exists with this name, but no value. +!!! error TS2693: 'i2' only refers to a type, but is being used as a value here. var obj21: i2 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -281,7 +281,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2692: Cannot find name 'i3'. A type exists with this name, but no value. +!!! error TS2693: 'i3' only refers to a type, but is being used as a value here. var obj32: i3 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -305,7 +305,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2692: Cannot find name 'i4'. A type exists with this name, but no value. +!!! error TS2693: 'i4' only refers to a type, but is being used as a value here. var obj43: i4 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -341,7 +341,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2692: Cannot find name 'i5'. A type exists with this name, but no value. +!!! error TS2693: 'i5' only refers to a type, but is being used as a value here. var obj54: i5 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -377,7 +377,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2692: Cannot find name 'i6'. A type exists with this name, but no value. +!!! error TS2693: 'i6' only refers to a type, but is being used as a value here. var obj65: i6 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -411,7 +411,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2692: Cannot find name 'i7'. A type exists with this name, but no value. +!!! error TS2693: 'i7' only refers to a type, but is being used as a value here. var obj76: i7 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. @@ -435,7 +435,7 @@ tests/cases/compiler/intTypeCheck.ts(205,17): error TS2351: Cannot use 'new' wit ~ !!! error TS1109: Expression expected. ~~ -!!! error TS2692: Cannot find name 'i8'. A type exists with this name, but no value. +!!! error TS2693: 'i8' only refers to a type, but is being used as a value here. var obj87: i8 = new {}; ~~~~~~ !!! error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. \ No newline at end of file diff --git a/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt b/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt index f3ee47573f7..5be40b5b7b6 100644 --- a/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt +++ b/tests/baselines/reference/interfaceNameAsIdentifier.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/interfaceNameAsIdentifier.ts(4,1): error TS2692: Cannot find name 'C'. A type exists with this name, but no value. +tests/cases/compiler/interfaceNameAsIdentifier.ts(4,1): error TS2693: 'C' only refers to a type, but is being used as a value here. tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2304: Cannot find name 'm2'. @@ -8,7 +8,7 @@ tests/cases/compiler/interfaceNameAsIdentifier.ts(12,1): error TS2304: Cannot fi } C(); ~ -!!! error TS2692: Cannot find name 'C'. A type exists with this name, but no value. +!!! error TS2693: 'C' only refers to a type, but is being used as a value here. module m2 { export interface C { diff --git a/tests/baselines/reference/interfaceNaming1.errors.txt b/tests/baselines/reference/interfaceNaming1.errors.txt index bdd3ca6c1f8..5efeea8c5e9 100644 --- a/tests/baselines/reference/interfaceNaming1.errors.txt +++ b/tests/baselines/reference/interfaceNaming1.errors.txt @@ -1,19 +1,19 @@ -tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2692: Cannot find name 'interface'. A type exists with this name, but no value. +tests/cases/compiler/interfaceNaming1.ts(1,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. tests/cases/compiler/interfaceNaming1.ts(1,11): error TS1005: ';' expected. -tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2692: Cannot find name 'interface'. A type exists with this name, but no value. +tests/cases/compiler/interfaceNaming1.ts(3,1): error TS2693: 'interface' only refers to a type, but is being used as a value here. tests/cases/compiler/interfaceNaming1.ts(3,13): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. ==== tests/cases/compiler/interfaceNaming1.ts (4 errors) ==== interface { } ~~~~~~~~~ -!!! error TS2692: Cannot find name 'interface'. A type exists with this name, but no value. +!!! error TS2693: 'interface' only refers to a type, but is being used as a value here. ~ !!! error TS1005: ';' expected. interface interface{ } interface & { } ~~~~~~~~~ -!!! error TS2692: Cannot find name 'interface'. A type exists with this name, but no value. +!!! error TS2693: 'interface' only refers to a type, but is being used as a value here. ~~~ !!! error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. \ No newline at end of file diff --git a/tests/baselines/reference/invalidUndefinedAssignments.errors.txt b/tests/baselines/reference/invalidUndefinedAssignments.errors.txt index 2e9f6efb137..05921e9433f 100644 --- a/tests/baselines/reference/invalidUndefinedAssignments.errors.txt +++ b/tests/baselines/reference/invalidUndefinedAssignments.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(4,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(9,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(14,1): error TS2693: 'I' only refers to a type, but is being used as a value here. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(17,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression. @@ -28,7 +28,7 @@ tests/cases/conformance/types/primitives/undefined/invalidUndefinedAssignments.t g = x; I = x; ~ -!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value. +!!! error TS2693: 'I' only refers to a type, but is being used as a value here. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt index 372d2e797e0..3668e7080fd 100644 --- a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt +++ b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.errors.txt @@ -1,7 +1,7 @@ error TS2318: Cannot find global type 'Boolean'. error TS2318: Cannot find global type 'IArguments'. error TS2318: Cannot find global type 'Number'. -tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2692: Cannot find name 'Array'. A type exists with this name, but no value. +tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib.ts(4,12): error TS2693: 'Array' only refers to a type, but is being used as a value here. !!! error TS2318: Cannot find global type 'Boolean'. @@ -13,7 +13,7 @@ tests/cases/compiler/modularizeLibrary_ErrorFromUsingES6ArrayWithOnlyES6ArrayLib function f(x: number, y: number, z: number) { return Array.from(arguments); ~~~~~ -!!! error TS2692: Cannot find name 'Array'. A type exists with this name, but no value. +!!! error TS2693: 'Array' only refers to a type, but is being used as a value here. } f(1, 2, 3); diff --git a/tests/baselines/reference/newOperator.errors.txt b/tests/baselines/reference/newOperator.errors.txt index e8d834824e5..fc6f22d9eac 100644 --- a/tests/baselines/reference/newOperator.errors.txt +++ b/tests/baselines/reference/newOperator.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/newOperator.ts(3,13): error TS2692: Cannot find name 'ifc'. A type exists with this name, but no value. +tests/cases/compiler/newOperator.ts(3,13): error TS2693: 'ifc' only refers to a type, but is being used as a value here. tests/cases/compiler/newOperator.ts(10,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/newOperator.ts(11,10): error TS2351: Cannot use 'new' with an expression whose type lacks a call or construct signature. tests/cases/compiler/newOperator.ts(12,5): error TS2304: Cannot find name 'string'. @@ -17,7 +17,7 @@ tests/cases/compiler/newOperator.ts(45,23): error TS1150: 'new T[]' cannot be us // Attempting to 'new' an interface yields poor error var i = new ifc(); ~~~ -!!! error TS2692: Cannot find name 'ifc'. A type exists with this name, but no value. +!!! error TS2693: 'ifc' only refers to a type, but is being used as a value here. // Parens are optional var x = new Date; diff --git a/tests/baselines/reference/reservedNamesInAliases.errors.txt b/tests/baselines/reference/reservedNamesInAliases.errors.txt index 99dc5137714..b6565427395 100644 --- a/tests/baselines/reference/reservedNamesInAliases.errors.txt +++ b/tests/baselines/reference/reservedNamesInAliases.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(5,6): error tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,1): error TS2304: Cannot find name 'type'. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,6): error TS1005: ';' expected. tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,11): error TS1109: Expression expected. -tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2692: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error TS2693: 'I' only refers to a type, but is being used as a value here. ==== tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts (8 errors) ==== @@ -30,4 +30,4 @@ tests/cases/conformance/types/typeAliases/reservedNamesInAliases.ts(6,13): error ~ !!! error TS1109: Expression expected. ~ -!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value. \ No newline at end of file +!!! error TS2693: 'I' only refers to a type, but is being used as a value here. \ No newline at end of file diff --git a/tests/baselines/reference/returnTypeParameter.errors.txt b/tests/baselines/reference/returnTypeParameter.errors.txt index 7b762f0938a..24b9e725de8 100644 --- a/tests/baselines/reference/returnTypeParameter.errors.txt +++ b/tests/baselines/reference/returnTypeParameter.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/returnTypeParameter.ts(1,22): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. -tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2693: 'T' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/returnTypeParameter.ts (2 errors) ==== @@ -8,4 +8,4 @@ tests/cases/compiler/returnTypeParameter.ts(2,34): error TS2692: Cannot find nam !!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. function f2(a: T): T { return T; } // bug was that this satisfied the return statement requirement ~ -!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. \ No newline at end of file +!!! error TS2693: 'T' only refers to a type, but is being used as a value here. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt index 8254f12cb1c..e633a6dd396 100644 --- a/tests/baselines/reference/typeParameterAsBaseClass.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseClass.errors.txt @@ -1,11 +1,11 @@ -tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/compiler/typeParameterAsBaseClass.ts(1,20): error TS2693: 'T' only refers to a type, but is being used as a value here. tests/cases/compiler/typeParameterAsBaseClass.ts(2,24): error TS2422: A class may only implement another class or interface. ==== tests/cases/compiler/typeParameterAsBaseClass.ts (2 errors) ==== class C extends T {} ~ -!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +!!! error TS2693: 'T' only refers to a type, but is being used as a value here. class C2 implements T {} ~ !!! error TS2422: A class may only implement another class or interface. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterAsBaseType.errors.txt b/tests/baselines/reference/typeParameterAsBaseType.errors.txt index f6b82a85681..c16b16d0b1a 100644 --- a/tests/baselines/reference/typeParameterAsBaseType.errors.txt +++ b/tests/baselines/reference/typeParameterAsBaseType.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. -tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2692: Cannot find name 'U'. A type exists with this name, but no value. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(4,20): error TS2693: 'T' only refers to a type, but is being used as a value here. +tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(5,24): error TS2693: 'U' only refers to a type, but is being used as a value here. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(7,24): error TS2312: An interface may only extend a class or another interface. tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): error TS2312: An interface may only extend a class or another interface. @@ -10,10 +10,10 @@ tests/cases/conformance/types/typeParameters/typeParameterAsBaseType.ts(8,28): e class C extends T { } ~ -!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +!!! error TS2693: 'T' only refers to a type, but is being used as a value here. class C2 extends U { } ~ -!!! error TS2692: Cannot find name 'U'. A type exists with this name, but no value. +!!! error TS2693: 'U' only refers to a type, but is being used as a value here. interface I extends T { } ~ diff --git a/tests/baselines/reference/typeUsedAsValueError.errors.txt b/tests/baselines/reference/typeUsedAsValueError.errors.txt index 75a83134162..89459235c53 100644 --- a/tests/baselines/reference/typeUsedAsValueError.errors.txt +++ b/tests/baselines/reference/typeUsedAsValueError.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/typeUsedAsValueError.ts(16,11): error TS2692: Cannot find name 'Interface'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(16,11): error TS2693: 'Interface' only refers to a type, but is being used as a value here. tests/cases/compiler/typeUsedAsValueError.ts(17,11): error TS2304: Cannot find name 'InterfaceNotFound'. -tests/cases/compiler/typeUsedAsValueError.ts(18,13): error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. -tests/cases/compiler/typeUsedAsValueError.ts(19,16): error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(18,13): error TS2693: 'TypeAliasForSomeClass' only refers to a type, but is being used as a value here. +tests/cases/compiler/typeUsedAsValueError.ts(19,16): error TS2693: 'TypeAliasForSomeClass' only refers to a type, but is being used as a value here. tests/cases/compiler/typeUsedAsValueError.ts(20,16): error TS2304: Cannot find name 'TypeAliasForSomeClassNotFound'. -tests/cases/compiler/typeUsedAsValueError.ts(21,11): error TS2692: Cannot find name 'someType'. A type exists with this name, but no value. -tests/cases/compiler/typeUsedAsValueError.ts(22,17): error TS2692: Cannot find name 'someType'. A type exists with this name, but no value. +tests/cases/compiler/typeUsedAsValueError.ts(21,11): error TS2693: 'someType' only refers to a type, but is being used as a value here. +tests/cases/compiler/typeUsedAsValueError.ts(22,17): error TS2693: 'someType' only refers to a type, but is being used as a value here. tests/cases/compiler/typeUsedAsValueError.ts(23,17): error TS2304: Cannot find name 'someTypeNotFound'. @@ -26,25 +26,25 @@ tests/cases/compiler/typeUsedAsValueError.ts(23,17): error TS2304: Cannot find n let one = Interface; ~~~~~~~~~ -!!! error TS2692: Cannot find name 'Interface'. A type exists with this name, but no value. +!!! error TS2693: 'Interface' only refers to a type, but is being used as a value here. let two = InterfaceNotFound; ~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'InterfaceNotFound'. let three = TypeAliasForSomeClass; ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +!!! error TS2693: 'TypeAliasForSomeClass' only refers to a type, but is being used as a value here. let four = new TypeAliasForSomeClass(); ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2692: Cannot find name 'TypeAliasForSomeClass'. A type exists with this name, but no value. +!!! error TS2693: 'TypeAliasForSomeClass' only refers to a type, but is being used as a value here. let five = new TypeAliasForSomeClassNotFound(); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'TypeAliasForSomeClassNotFound'. let six = someType; ~~~~~~~~ -!!! error TS2692: Cannot find name 'someType'. A type exists with this name, but no value. +!!! error TS2693: 'someType' only refers to a type, but is being used as a value here. acceptsSomeType(someType); ~~~~~~~~ -!!! error TS2692: Cannot find name 'someType'. A type exists with this name, but no value. +!!! error TS2693: 'someType' only refers to a type, but is being used as a value here. acceptsSomeType(someTypeNotFound); ~~~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'someTypeNotFound'. \ No newline at end of file diff --git a/tests/baselines/reference/typeUsedAsValueError2.errors.txt b/tests/baselines/reference/typeUsedAsValueError2.errors.txt index 8707ffaaafb..3027abb0e6b 100644 --- a/tests/baselines/reference/typeUsedAsValueError2.errors.txt +++ b/tests/baselines/reference/typeUsedAsValueError2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/world.ts(4,1): error TS2692: Cannot find name 'HelloInterface'. A type exists with this name, but no value. +tests/cases/compiler/world.ts(4,1): error TS2693: 'HelloInterface' only refers to a type, but is being used as a value here. tests/cases/compiler/world.ts(5,1): error TS2304: Cannot find name 'HelloNamespace'. @@ -8,7 +8,7 @@ tests/cases/compiler/world.ts(5,1): error TS2304: Cannot find name 'HelloNamespa HelloInterface.world; ~~~~~~~~~~~~~~ -!!! error TS2692: Cannot find name 'HelloInterface'. A type exists with this name, but no value. +!!! error TS2693: 'HelloInterface' only refers to a type, but is being used as a value here. HelloNamespace.world; ~~~~~~~~~~~~~~ !!! error TS2304: Cannot find name 'HelloNamespace'. diff --git a/tests/baselines/reference/typeofSimple.errors.txt b/tests/baselines/reference/typeofSimple.errors.txt index 977a8b34d45..ad498563c57 100644 --- a/tests/baselines/reference/typeofSimple.errors.txt +++ b/tests/baselines/reference/typeofSimple.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeofSimple.ts(3,5): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/typeofSimple.ts(8,21): error TS2692: Cannot find name 'J'. A type exists with this name, but no value. +tests/cases/compiler/typeofSimple.ts(8,21): error TS2693: 'J' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/typeofSimple.ts (2 errors) ==== @@ -14,7 +14,7 @@ tests/cases/compiler/typeofSimple.ts(8,21): error TS2692: Cannot find name 'J'. var numberJ: typeof J; //Error, cannot reference type in typeof ~ -!!! error TS2692: Cannot find name 'J'. A type exists with this name, but no value. +!!! error TS2693: 'J' only refers to a type, but is being used as a value here. var numberI: I; var fun: () => I; diff --git a/tests/baselines/reference/typeofTypeParameter.errors.txt b/tests/baselines/reference/typeofTypeParameter.errors.txt index a4fc868197d..cdaeecaafb6 100644 --- a/tests/baselines/reference/typeofTypeParameter.errors.txt +++ b/tests/baselines/reference/typeofTypeParameter.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts(3,19): error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts(3,19): error TS2693: 'T' only refers to a type, but is being used as a value here. ==== tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts (1 errors) ==== @@ -6,6 +6,6 @@ tests/cases/conformance/types/specifyingTypes/typeQueries/typeofTypeParameter.ts var a: typeof x; var y: typeof T; ~ -!!! error TS2692: Cannot find name 'T'. A type exists with this name, but no value. +!!! error TS2693: 'T' only refers to a type, but is being used as a value here. return a; } \ No newline at end of file diff --git a/tests/baselines/reference/validNullAssignments.errors.txt b/tests/baselines/reference/validNullAssignments.errors.txt index d3c403b4ae4..1fcebdcbaa9 100644 --- a/tests/baselines/reference/validNullAssignments.errors.txt +++ b/tests/baselines/reference/validNullAssignments.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/primitives/null/validNullAssignments.ts(10,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(15,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/types/primitives/null/validNullAssignments.ts(20,1): error TS2692: Cannot find name 'I'. A type exists with this name, but no value. +tests/cases/conformance/types/primitives/null/validNullAssignments.ts(20,1): error TS2693: 'I' only refers to a type, but is being used as a value here. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/null/validNullAssignments.ts(30,1): error TS2364: Invalid left-hand side of assignment expression. @@ -31,7 +31,7 @@ tests/cases/conformance/types/primitives/null/validNullAssignments.ts(30,1): err g = null; // ok I = null; // error ~ -!!! error TS2692: Cannot find name 'I'. A type exists with this name, but no value. +!!! error TS2693: 'I' only refers to a type, but is being used as a value here. module M { export var x = 1; } M = null; // error From 03308777cab4b0e1ac5d14abbfafa996db63a459 Mon Sep 17 00:00:00 2001 From: Justin Bay Date: Wed, 24 Aug 2016 23:47:52 -0400 Subject: [PATCH 259/508] Accept new baselines per refactor --- .../reference/invalidImportAliasIdentifiers.errors.txt | 4 ++-- .../strictModeReservedWordInClassDeclaration.errors.txt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt b/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt index afe7472570d..bf5cf5c0f12 100644 --- a/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt +++ b/tests/baselines/reference/invalidImportAliasIdentifiers.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(5,12): error TS2503: Cannot find namespace 'V'. tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(11,12): error TS2503: Cannot find namespace 'C'. -tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(23,12): error TS2503: Cannot find namespace 'I'. +tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts(23,12): error TS2693: 'I' only refers to a type, but is being used as a value here. ==== tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIdentifiers.ts (3 errors) ==== @@ -32,5 +32,5 @@ tests/cases/conformance/internalModules/importDeclarations/invalidImportAliasIde import i = I; ~ -!!! error TS2503: Cannot find namespace 'I'. +!!! error TS2693: 'I' only refers to a type, but is being used as a value here. \ No newline at end of file diff --git a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt index 0b868960bed..0dff64c9a31 100644 --- a/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt +++ b/tests/baselines/reference/strictModeReservedWordInClassDeclaration.errors.txt @@ -16,9 +16,9 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,9): error TS tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(21,17): error TS1213: Identifier expected. 'private' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(23,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2503: Cannot find namespace 'public'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(25,20): error TS2693: 'public' only refers to a type, but is being used as a value here. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. -tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2503: Cannot find namespace 'public'. +tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(26,21): error TS2693: 'public' only refers to a type, but is being used as a value here. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(27,17): error TS2304: Cannot find name 'package'. tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. @@ -88,12 +88,12 @@ tests/cases/compiler/strictModeReservedWordInClassDeclaration.ts(28,17): error T ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ -!!! error TS2503: Cannot find namespace 'public'. +!!! error TS2693: 'public' only refers to a type, but is being used as a value here. class F1 implements public.private.implements { } ~~~~~~ !!! error TS1213: Identifier expected. 'public' is a reserved word in strict mode. Class definitions are automatically in strict mode. ~~~~~~ -!!! error TS2503: Cannot find namespace 'public'. +!!! error TS2693: 'public' only refers to a type, but is being used as a value here. class G extends package { } ~~~~~~~ !!! error TS1213: Identifier expected. 'package' is a reserved word in strict mode. Class definitions are automatically in strict mode. From a9602facdb54f8b2c5d5ec3dcdbcfd60f302bae0 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 25 Aug 2016 06:18:50 -0700 Subject: [PATCH 260/508] Reduce nesting --- src/compiler/checker.ts | 53 +++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 3e566f1b77c..5020fd48353 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2066,39 +2066,34 @@ namespace ts { // up front (for example, during checking) could determine if we need to emit the imports // and we could then access that data during declaration emit. writer.trackSymbol(symbol, enclosingDeclaration, meaning); - function walkSymbol(symbol: Symbol, meaning: SymbolFlags): void { - function climbSymbol(symbol: Symbol, meaning: SymbolFlags, endOfChain?: boolean): void { - if (symbol) { - const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); + function walkSymbol(symbol: Symbol, meaning: SymbolFlags, endOfChain: boolean): void { + const accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, !!(flags & SymbolFormatFlags.UseOnlyExternalAliasing)); - if (!accessibleSymbolChain || - needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { - // Go up and add our parent. - climbSymbol( - getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol), - getQualifiedLeftMeaning(meaning)); - } - - if (accessibleSymbolChain) { - for (const accessibleSymbol of accessibleSymbolChain) { - appendParentTypeArgumentsAndSymbolName(accessibleSymbol); - } - } - else if ( - // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. - endOfChain || - // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) - !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && - // If a parent symbol is an anonymous type, don't write it. - !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { - - appendParentTypeArgumentsAndSymbolName(symbol); - } + // Go up and add our parent. + const parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + walkSymbol(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); } } - climbSymbol(symbol, meaning, /*endOfChain*/ true); + if (accessibleSymbolChain) { + for (const accessibleSymbol of accessibleSymbolChain) { + appendParentTypeArgumentsAndSymbolName(accessibleSymbol); + } + } + else if ( + // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. + endOfChain || + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + // If a parent symbol is an anonymous type, don't write it. + !(symbol.flags & (SymbolFlags.TypeLiteral | SymbolFlags.ObjectLiteral))) { + + appendParentTypeArgumentsAndSymbolName(symbol); + } } // Get qualified name if the symbol is not a type parameter @@ -2107,7 +2102,7 @@ namespace ts { const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; const typeFormatFlag = TypeFormatFlags.UseFullyQualifiedType & typeFlags; if (!isTypeParameter && (enclosingDeclaration || typeFormatFlag)) { - walkSymbol(symbol, meaning); + walkSymbol(symbol, meaning, /*endOfChain*/ true); } else { appendParentTypeArgumentsAndSymbolName(symbol); From bab4a529834d94ddf8a7b84852d77140593a02fe Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 25 Aug 2016 06:21:02 -0700 Subject: [PATCH 261/508] strip comments when re-emitting tsconfig.json (#10529) --- src/harness/unittests/tsconfigParsing.ts | 1 + src/services/utilities.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/harness/unittests/tsconfigParsing.ts b/src/harness/unittests/tsconfigParsing.ts index 2c9bcdb8423..eccf3537643 100644 --- a/src/harness/unittests/tsconfigParsing.ts +++ b/src/harness/unittests/tsconfigParsing.ts @@ -186,6 +186,7 @@ namespace ts { const content = `{ "compilerOptions": { "allowJs": true + // Some comments "outDir": "bin" } "files": ["file1.ts"] diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 858f889bc6c..9b3469643ba 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -930,7 +930,8 @@ namespace ts { const options: TranspileOptions = { fileName: "config.js", compilerOptions: { - target: ScriptTarget.ES6 + target: ScriptTarget.ES6, + removeComments: true }, reportDiagnostics: true }; From c0309fa78e5dbf7dd699cf21ea59ed9cb24268ad Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 25 Aug 2016 09:21:31 -0700 Subject: [PATCH 262/508] Fix crash when checking module exports for export= Also make maxNodeModuleJsDepth default to 0 so that incorrect tsconfigs now let the compiler spend less time compiling JS that is found in node_modules (especially since most people will already have the d.ts and want ignore the JS anyway). jsconfig still defaults to 2. --- src/compiler/checker.ts | 6 ++-- src/compiler/commandLineParser.ts | 2 +- src/compiler/program.ts | 2 +- .../convertCompilerOptionsFromJson.ts | 8 +++-- ...ForConflictingExportEqualsValue.errors.txt | 9 +++++ .../errorForConflictingExportEqualsValue.js | 8 +++++ ...NodeModuleJsDepthDefaultsToZero.errors.txt | 26 ++++++++++++++ ...NodeModuleJsDepthDefaultsToZero.trace.json | 28 +++++++++++++++ .../errorForConflictingExportEqualsValue.ts | 2 ++ .../maxNodeModuleJsDepthDefaultsToZero.ts | 36 +++++++++++++++++++ .../importHigher/tsconfig.json | 3 +- 11 files changed, 123 insertions(+), 7 deletions(-) create mode 100644 tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt create mode 100644 tests/baselines/reference/errorForConflictingExportEqualsValue.js create mode 100644 tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt create mode 100644 tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json create mode 100644 tests/cases/compiler/errorForConflictingExportEqualsValue.ts create mode 100644 tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 370802478bc..9e8bcf40be7 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1023,8 +1023,8 @@ namespace ts { } } - function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration { - return findMap(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); + function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration | undefined { + return forEach(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); } function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration): Symbol { @@ -1191,6 +1191,7 @@ namespace ts { if (!links.target) { links.target = resolvingSymbol; const node = getDeclarationOfAliasSymbol(symbol); + Debug.assert(!!node); const target = getTargetOfAliasDeclaration(node); if (links.target === resolvingSymbol) { links.target = target || unknownSymbol; @@ -1226,6 +1227,7 @@ namespace ts { if (!links.referenced) { links.referenced = true; const node = getDeclarationOfAliasSymbol(symbol); + Debug.assert(!!node); if (node.kind === SyntaxKind.ExportAssignment) { // export default checkExpressionCached((node).expression); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6406455d713..e1175c42438 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -885,7 +885,7 @@ namespace ts { function convertCompilerOptionsFromJsonWorker(jsonOptions: any, basePath: string, errors: Diagnostic[], configFileName?: string): CompilerOptions { - const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true } : {}; + const options: CompilerOptions = getBaseFileName(configFileName) === "jsconfig.json" ? { allowJs: true, maxNodeModuleJsDepth: 2 } : {}; convertOptionsFromJson(optionDeclarations, jsonOptions, basePath, options, Diagnostics.Unknown_compiler_option_0, errors); return options; } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f099d858119..49f61981d72 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1101,7 +1101,7 @@ namespace ts { // - This calls resolveModuleNames, and then calls findSourceFile for each resolved module. // As all these operations happen - and are nested - within the createProgram call, they close over the below variables. // The current resolution depth is tracked by incrementing/decrementing as the depth first search progresses. - const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 2; + const maxNodeModulesJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; let currentNodeModulesDepth = 0; // If a module has some of its imports skipped due to being at the depth limit under node_modules, then track diff --git a/src/harness/unittests/convertCompilerOptionsFromJson.ts b/src/harness/unittests/convertCompilerOptionsFromJson.ts index d308bb2a6e6..9de18850477 100644 --- a/src/harness/unittests/convertCompilerOptionsFromJson.ts +++ b/src/harness/unittests/convertCompilerOptionsFromJson.ts @@ -403,6 +403,7 @@ namespace ts { { compilerOptions: { allowJs: true, + maxNodeModuleJsDepth: 2, module: ModuleKind.CommonJS, target: ScriptTarget.ES5, noImplicitAny: false, @@ -429,6 +430,7 @@ namespace ts { { compilerOptions: { allowJs: false, + maxNodeModuleJsDepth: 2, module: ModuleKind.CommonJS, target: ScriptTarget.ES5, noImplicitAny: false, @@ -450,7 +452,8 @@ namespace ts { { compilerOptions: { - allowJs: true + allowJs: true, + maxNodeModuleJsDepth: 2 }, errors: [{ file: undefined, @@ -469,7 +472,8 @@ namespace ts { { compilerOptions: { - allowJs: true + allowJs: true, + maxNodeModuleJsDepth: 2 }, errors: [] } diff --git a/tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt b/tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt new file mode 100644 index 00000000000..9a5858f46ab --- /dev/null +++ b/tests/baselines/reference/errorForConflictingExportEqualsValue.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/errorForConflictingExportEqualsValue.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + +==== tests/cases/compiler/errorForConflictingExportEqualsValue.ts (1 errors) ==== + export var x; + export = {}; + ~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + \ No newline at end of file diff --git a/tests/baselines/reference/errorForConflictingExportEqualsValue.js b/tests/baselines/reference/errorForConflictingExportEqualsValue.js new file mode 100644 index 00000000000..88762e7e846 --- /dev/null +++ b/tests/baselines/reference/errorForConflictingExportEqualsValue.js @@ -0,0 +1,8 @@ +//// [errorForConflictingExportEqualsValue.ts] +export var x; +export = {}; + + +//// [errorForConflictingExportEqualsValue.js] +"use strict"; +module.exports = {}; diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt new file mode 100644 index 00000000000..4859ca45b7c --- /dev/null +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt @@ -0,0 +1,26 @@ +c:/root/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. + + +==== c:/root/index.ts (1 errors) ==== + /// + import * as foo from "shortid"; + foo.x // found in index.d.ts + foo.y // ignored from shortid/index.ts + ~ +!!! error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. + + +==== c:/root/node_modules/shortid/node_modules/z/index.js (0 errors) ==== + // z will not be found because maxNodeModulesJsDepth: 0 + module.exports = { z: 'no' }; + +==== c:/root/node_modules/shortid/index.js (0 errors) ==== + var z = require('z'); + var y = { y: 'foo' }; + module.exports = y; + +==== c:/root/typings/index.d.ts (0 errors) ==== + declare module "shortid" { + export var x: number; + } + \ No newline at end of file diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json new file mode 100644 index 00000000000..d9fabbfa5df --- /dev/null +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json @@ -0,0 +1,28 @@ +[ + "======== Resolving module 'shortid' from 'c:/root/index.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module 'shortid' from 'node_modules' folder.", + "File 'c:/root/node_modules/shortid.ts' does not exist.", + "File 'c:/root/node_modules/shortid.tsx' does not exist.", + "File 'c:/root/node_modules/shortid.d.ts' does not exist.", + "File 'c:/root/node_modules/shortid.js' does not exist.", + "File 'c:/root/node_modules/shortid.jsx' does not exist.", + "File 'c:/root/node_modules/shortid/package.json' does not exist.", + "File 'c:/root/node_modules/shortid/index.ts' does not exist.", + "File 'c:/root/node_modules/shortid/index.tsx' does not exist.", + "File 'c:/root/node_modules/shortid/index.d.ts' does not exist.", + "File 'c:/root/node_modules/shortid/index.js' exist - use it as a name resolution result.", + "File 'c:/root/node_modules/@types/shortid.ts' does not exist.", + "File 'c:/root/node_modules/@types/shortid.tsx' does not exist.", + "File 'c:/root/node_modules/@types/shortid.d.ts' does not exist.", + "File 'c:/root/node_modules/@types/shortid.js' does not exist.", + "File 'c:/root/node_modules/@types/shortid.jsx' does not exist.", + "File 'c:/root/node_modules/@types/shortid/package.json' does not exist.", + "File 'c:/root/node_modules/@types/shortid/index.ts' does not exist.", + "File 'c:/root/node_modules/@types/shortid/index.tsx' does not exist.", + "File 'c:/root/node_modules/@types/shortid/index.d.ts' does not exist.", + "File 'c:/root/node_modules/@types/shortid/index.js' does not exist.", + "File 'c:/root/node_modules/@types/shortid/index.jsx' does not exist.", + "Resolving real path for 'c:/root/node_modules/shortid/index.js', result 'c:/root/node_modules/shortid/index.js'", + "======== Module name 'shortid' was successfully resolved to 'c:/root/node_modules/shortid/index.js'. ========" +] \ No newline at end of file diff --git a/tests/cases/compiler/errorForConflictingExportEqualsValue.ts b/tests/cases/compiler/errorForConflictingExportEqualsValue.ts new file mode 100644 index 00000000000..59af1f46690 --- /dev/null +++ b/tests/cases/compiler/errorForConflictingExportEqualsValue.ts @@ -0,0 +1,2 @@ +export var x; +export = {}; diff --git a/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts b/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts new file mode 100644 index 00000000000..119f8277bf2 --- /dev/null +++ b/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts @@ -0,0 +1,36 @@ +// @module: commonjs +// @moduleResolution: node +// @allowJs: true +// @traceResolution: true +// @noEmit: true + +// @filename: c:/root/tsconfig.json +{ + "compileOnSave": true, + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "node", + "outDir": "bin" + }, + "exclude": [ "node_modules" ] +} +// @filename: c:/root/node_modules/shortid/node_modules/z/index.js +// z will not be found because maxNodeModulesJsDepth: 0 +module.exports = { z: 'no' }; + +// @filename: c:/root/node_modules/shortid/index.js +var z = require('z'); +var y = { y: 'foo' }; +module.exports = y; + +// @filename: c:/root/typings/index.d.ts +declare module "shortid" { + export var x: number; +} + +// @filename: c:/root/index.ts +/// +import * as foo from "shortid"; +foo.x // found in index.d.ts +foo.y // ignored from shortid/index.ts + diff --git a/tests/cases/projects/NodeModulesSearch/importHigher/tsconfig.json b/tests/cases/projects/NodeModulesSearch/importHigher/tsconfig.json index c7b95984b42..301db9c870a 100644 --- a/tests/cases/projects/NodeModulesSearch/importHigher/tsconfig.json +++ b/tests/cases/projects/NodeModulesSearch/importHigher/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "allowJs": true, "declaration": false, - "moduleResolution": "node" + "moduleResolution": "node", + "maxNodeModuleJsDepth": 2 } } From 751b0a65dec5ddecf8a4d53942776e32b88115bc Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 25 Aug 2016 10:25:17 -0700 Subject: [PATCH 263/508] Clean up maxNodeModuleJsDepth test --- ...NodeModuleJsDepthDefaultsToZero.errors.txt | 14 +++--- ...NodeModuleJsDepthDefaultsToZero.trace.json | 48 +++++++++---------- .../maxNodeModuleJsDepthDefaultsToZero.ts | 14 +++--- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt index 4859ca45b7c..4fa15a71fa8 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt @@ -1,25 +1,25 @@ -c:/root/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. +tests/cases/compiler/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. -==== c:/root/index.ts (1 errors) ==== - /// +==== tests/cases/compiler/index.ts (1 errors) ==== + /// import * as foo from "shortid"; foo.x // found in index.d.ts - foo.y // ignored from shortid/index.ts + foo.y // ignored from shortid/index.js ~ !!! error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. -==== c:/root/node_modules/shortid/node_modules/z/index.js (0 errors) ==== +==== tests/cases/compiler/node_modules/shortid/node_modules/z/index.js (0 errors) ==== // z will not be found because maxNodeModulesJsDepth: 0 module.exports = { z: 'no' }; -==== c:/root/node_modules/shortid/index.js (0 errors) ==== +==== tests/cases/compiler/node_modules/shortid/index.js (0 errors) ==== var z = require('z'); var y = { y: 'foo' }; module.exports = y; -==== c:/root/typings/index.d.ts (0 errors) ==== +==== tests/cases/compiler/typings/index.d.ts (0 errors) ==== declare module "shortid" { export var x: number; } diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json index d9fabbfa5df..f3db007a2ba 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json @@ -1,28 +1,28 @@ [ - "======== Resolving module 'shortid' from 'c:/root/index.ts'. ========", + "======== Resolving module 'shortid' from '/media/nathansa/src2/ts/tests/cases/compiler/index.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'shortid' from 'node_modules' folder.", - "File 'c:/root/node_modules/shortid.ts' does not exist.", - "File 'c:/root/node_modules/shortid.tsx' does not exist.", - "File 'c:/root/node_modules/shortid.d.ts' does not exist.", - "File 'c:/root/node_modules/shortid.js' does not exist.", - "File 'c:/root/node_modules/shortid.jsx' does not exist.", - "File 'c:/root/node_modules/shortid/package.json' does not exist.", - "File 'c:/root/node_modules/shortid/index.ts' does not exist.", - "File 'c:/root/node_modules/shortid/index.tsx' does not exist.", - "File 'c:/root/node_modules/shortid/index.d.ts' does not exist.", - "File 'c:/root/node_modules/shortid/index.js' exist - use it as a name resolution result.", - "File 'c:/root/node_modules/@types/shortid.ts' does not exist.", - "File 'c:/root/node_modules/@types/shortid.tsx' does not exist.", - "File 'c:/root/node_modules/@types/shortid.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/shortid.js' does not exist.", - "File 'c:/root/node_modules/@types/shortid.jsx' does not exist.", - "File 'c:/root/node_modules/@types/shortid/package.json' does not exist.", - "File 'c:/root/node_modules/@types/shortid/index.ts' does not exist.", - "File 'c:/root/node_modules/@types/shortid/index.tsx' does not exist.", - "File 'c:/root/node_modules/@types/shortid/index.d.ts' does not exist.", - "File 'c:/root/node_modules/@types/shortid/index.js' does not exist.", - "File 'c:/root/node_modules/@types/shortid/index.jsx' does not exist.", - "Resolving real path for 'c:/root/node_modules/shortid/index.js', result 'c:/root/node_modules/shortid/index.js'", - "======== Module name 'shortid' was successfully resolved to 'c:/root/node_modules/shortid/index.js'. ========" + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.ts' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.tsx' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.d.ts' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.js' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.jsx' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/package.json' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.ts' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.tsx' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.d.ts' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.js' exist - use it as a name resolution result.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.ts' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.tsx' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.d.ts' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.js' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.jsx' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/package.json' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.ts' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.tsx' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.d.ts' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.js' does not exist.", + "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.jsx' does not exist.", + "Resolving real path for '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.js', result '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.js'", + "======== Module name 'shortid' was successfully resolved to '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.js'. ========" ] \ No newline at end of file diff --git a/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts b/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts index 119f8277bf2..0c8ac7c5fa6 100644 --- a/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts +++ b/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts @@ -4,7 +4,7 @@ // @traceResolution: true // @noEmit: true -// @filename: c:/root/tsconfig.json +// @filename: tsconfig.json { "compileOnSave": true, "compilerOptions": { @@ -14,23 +14,23 @@ }, "exclude": [ "node_modules" ] } -// @filename: c:/root/node_modules/shortid/node_modules/z/index.js +// @filename: node_modules/shortid/node_modules/z/index.js // z will not be found because maxNodeModulesJsDepth: 0 module.exports = { z: 'no' }; -// @filename: c:/root/node_modules/shortid/index.js +// @filename: node_modules/shortid/index.js var z = require('z'); var y = { y: 'foo' }; module.exports = y; -// @filename: c:/root/typings/index.d.ts +// @filename: typings/index.d.ts declare module "shortid" { export var x: number; } -// @filename: c:/root/index.ts -/// +// @filename: index.ts +/// import * as foo from "shortid"; foo.x // found in index.d.ts -foo.y // ignored from shortid/index.ts +foo.y // ignored from shortid/index.js From 6ee749f8b33bfdcaee2b1e41eeed618f49a1e25a Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 25 Aug 2016 11:02:26 -0700 Subject: [PATCH 264/508] Get rid of absolute paths --- ...NodeModuleJsDepthDefaultsToZero.errors.txt | 12 ++--- ...NodeModuleJsDepthDefaultsToZero.trace.json | 48 +++++++++---------- .../maxNodeModuleJsDepthDefaultsToZero.ts | 12 ++--- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt index 4fa15a71fa8..2218e7910ae 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. +/index.ts(4,5): error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. -==== tests/cases/compiler/index.ts (1 errors) ==== - /// +==== /index.ts (1 errors) ==== + /// import * as foo from "shortid"; foo.x // found in index.d.ts foo.y // ignored from shortid/index.js @@ -10,16 +10,16 @@ tests/cases/compiler/index.ts(4,5): error TS2339: Property 'y' does not exist on !!! error TS2339: Property 'y' does not exist on type 'typeof "shortid"'. -==== tests/cases/compiler/node_modules/shortid/node_modules/z/index.js (0 errors) ==== +==== /node_modules/shortid/node_modules/z/index.js (0 errors) ==== // z will not be found because maxNodeModulesJsDepth: 0 module.exports = { z: 'no' }; -==== tests/cases/compiler/node_modules/shortid/index.js (0 errors) ==== +==== /node_modules/shortid/index.js (0 errors) ==== var z = require('z'); var y = { y: 'foo' }; module.exports = y; -==== tests/cases/compiler/typings/index.d.ts (0 errors) ==== +==== /typings/index.d.ts (0 errors) ==== declare module "shortid" { export var x: number; } diff --git a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json index f3db007a2ba..e53b2a0934f 100644 --- a/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json +++ b/tests/baselines/reference/maxNodeModuleJsDepthDefaultsToZero.trace.json @@ -1,28 +1,28 @@ [ - "======== Resolving module 'shortid' from '/media/nathansa/src2/ts/tests/cases/compiler/index.ts'. ========", + "======== Resolving module 'shortid' from '/index.ts'. ========", "Explicitly specified module resolution kind: 'NodeJs'.", "Loading module 'shortid' from 'node_modules' folder.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.ts' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.tsx' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.d.ts' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.js' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid.jsx' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/package.json' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.ts' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.tsx' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.d.ts' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.js' exist - use it as a name resolution result.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.ts' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.tsx' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.d.ts' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.js' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid.jsx' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/package.json' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.ts' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.tsx' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.d.ts' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.js' does not exist.", - "File '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/@types/shortid/index.jsx' does not exist.", - "Resolving real path for '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.js', result '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.js'", - "======== Module name 'shortid' was successfully resolved to '/media/nathansa/src2/ts/tests/cases/compiler/node_modules/shortid/index.js'. ========" + "File '/node_modules/shortid.ts' does not exist.", + "File '/node_modules/shortid.tsx' does not exist.", + "File '/node_modules/shortid.d.ts' does not exist.", + "File '/node_modules/shortid.js' does not exist.", + "File '/node_modules/shortid.jsx' does not exist.", + "File '/node_modules/shortid/package.json' does not exist.", + "File '/node_modules/shortid/index.ts' does not exist.", + "File '/node_modules/shortid/index.tsx' does not exist.", + "File '/node_modules/shortid/index.d.ts' does not exist.", + "File '/node_modules/shortid/index.js' exist - use it as a name resolution result.", + "File '/node_modules/@types/shortid.ts' does not exist.", + "File '/node_modules/@types/shortid.tsx' does not exist.", + "File '/node_modules/@types/shortid.d.ts' does not exist.", + "File '/node_modules/@types/shortid.js' does not exist.", + "File '/node_modules/@types/shortid.jsx' does not exist.", + "File '/node_modules/@types/shortid/package.json' does not exist.", + "File '/node_modules/@types/shortid/index.ts' does not exist.", + "File '/node_modules/@types/shortid/index.tsx' does not exist.", + "File '/node_modules/@types/shortid/index.d.ts' does not exist.", + "File '/node_modules/@types/shortid/index.js' does not exist.", + "File '/node_modules/@types/shortid/index.jsx' does not exist.", + "Resolving real path for '/node_modules/shortid/index.js', result '/node_modules/shortid/index.js'", + "======== Module name 'shortid' was successfully resolved to '/node_modules/shortid/index.js'. ========" ] \ No newline at end of file diff --git a/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts b/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts index 0c8ac7c5fa6..9d154ec1e59 100644 --- a/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts +++ b/tests/cases/compiler/maxNodeModuleJsDepthDefaultsToZero.ts @@ -4,7 +4,7 @@ // @traceResolution: true // @noEmit: true -// @filename: tsconfig.json +// @filename: /tsconfig.json { "compileOnSave": true, "compilerOptions": { @@ -14,22 +14,22 @@ }, "exclude": [ "node_modules" ] } -// @filename: node_modules/shortid/node_modules/z/index.js +// @filename: /node_modules/shortid/node_modules/z/index.js // z will not be found because maxNodeModulesJsDepth: 0 module.exports = { z: 'no' }; -// @filename: node_modules/shortid/index.js +// @filename: /node_modules/shortid/index.js var z = require('z'); var y = { y: 'foo' }; module.exports = y; -// @filename: typings/index.d.ts +// @filename: /typings/index.d.ts declare module "shortid" { export var x: number; } -// @filename: index.ts -/// +// @filename: /index.ts +/// import * as foo from "shortid"; foo.x // found in index.d.ts foo.y // ignored from shortid/index.js From e0a36840c058210d7d29cea9e9bd039e4cf4210a Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 25 Aug 2016 11:53:44 -0700 Subject: [PATCH 265/508] PR feedback --- src/services/services.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 7718be5a3d4..6da12696937 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1375,8 +1375,7 @@ namespace ts { } export interface ReferencedSymbolDefinitionInfo extends DefinitionInfo { - // For more complex definitions where kind and name are insufficient to properly colorize the text - displayParts?: SymbolDisplayPart[]; + displayParts: SymbolDisplayPart[]; } export interface ReferencedSymbol { @@ -6640,11 +6639,6 @@ namespace ts { getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); } - const symbol = typeChecker.getSymbolAtLocation(node); - - const displayParts = symbol ? getSymbolDisplayPartsDocumentationAndSymbolKind( - symbol, node.getSourceFile(), getContainerNode(node), node).displayParts : undefined; - return [{ definition: { containerKind: "", @@ -6653,7 +6647,7 @@ namespace ts { kind: ScriptElementKind.variableElement, name: type.text, textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), - displayParts + displayParts: [displayPart(getTextOfNode(node), SymbolDisplayPartKind.stringLiteral)] }, references: references }]; From 15ff0f79568f6e2dd7f1c685ee11b537ca27b951 Mon Sep 17 00:00:00 2001 From: Yui Date: Mon, 8 Aug 2016 14:45:01 -0700 Subject: [PATCH 266/508] [Release 2.0] fix10179: 2.0 emits optional class properties defined in constructors, which breaks compatibility (#10212) * Do not emit "?" for in property declaration in .d.ts when the property is declared as optional parameter property declaration * Update baselines --- src/compiler/declarationEmitter.ts | 6 ++++-- tests/baselines/reference/declFileConstructors.js | 4 ++-- tests/baselines/reference/optionalMethods.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 3642ee7f10a..ab1ca518256 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -1132,8 +1132,10 @@ namespace ts { // it if it's not a well known symbol. In that case, the text of the name will be exactly // what we want, namely the name expression enclosed in brackets. writeTextOfNode(currentText, node.name); - // If optional property emit ? - if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || node.kind === SyntaxKind.Parameter) && hasQuestionToken(node)) { + // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor + // we don't want to emit property declaration with "?" + if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || + (node.kind === SyntaxKind.Parameter && !isParameterPropertyDeclaration(node))) && hasQuestionToken(node)) { write("?"); } if ((node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) && node.parent.kind === SyntaxKind.TypeLiteral) { diff --git a/tests/baselines/reference/declFileConstructors.js b/tests/baselines/reference/declFileConstructors.js index 8e92b1a36ae..44e816712fb 100644 --- a/tests/baselines/reference/declFileConstructors.js +++ b/tests/baselines/reference/declFileConstructors.js @@ -247,7 +247,7 @@ export declare class ConstructorWithPrivateParameterProperty { constructor(x: string); } export declare class ConstructorWithOptionalParameterProperty { - x?: string; + x: string; constructor(x?: string); } export declare class ConstructorWithParameterInitializer { @@ -281,7 +281,7 @@ declare class GlobalConstructorWithPrivateParameterProperty { constructor(x: string); } declare class GlobalConstructorWithOptionalParameterProperty { - x?: string; + x: string; constructor(x?: string); } declare class GlobalConstructorWithParameterInitializer { diff --git a/tests/baselines/reference/optionalMethods.js b/tests/baselines/reference/optionalMethods.js index 42decf512e4..98629f5718b 100644 --- a/tests/baselines/reference/optionalMethods.js +++ b/tests/baselines/reference/optionalMethods.js @@ -126,7 +126,7 @@ interface Foo { } declare function test1(x: Foo): void; declare class Bar { - d?: number; + d: number; e: number; a: number; b?: number; From 34847f0ce05de1c8daccbec99c5181b0988b3b04 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 25 Aug 2016 14:08:37 -0700 Subject: [PATCH 267/508] Making language service host changes optional --- src/services/services.ts | 150 +++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 69 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 48cc186f7ec..fde5b300c2f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1158,9 +1158,13 @@ namespace ts { error?(s: string): void; useCaseSensitiveFileNames?(): boolean; - readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; - readFile(path: string, encoding?: string): string; - fileExists(path: string): boolean; + /* + * LS host can optionally implement these methods to support getImportModuleCompletionsAtPosition. + * Without these methods, only completions for ambient modules will be provided. + */ + readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; + readFile?(path: string, encoding?: string): string; + fileExists?(path: string): boolean; /* * LS host can optionally implement this method if it wants to be completely in charge of module name resolution. @@ -3155,7 +3159,8 @@ namespace ts { writeFile: (fileName, data, writeByteOrderMark) => { }, getCurrentDirectory: () => currentDirectory, fileExists: (fileName): boolean => { - return host.fileExists(fileName); + // stub missing host functionality + return hostCache.getOrCreateEntry(fileName) !== undefined; }, readFile: (fileName): string => { // stub missing host functionality @@ -4598,23 +4603,25 @@ namespace ts { const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); if (directoryProbablyExists(baseDirectory, host)) { - // Enumerate the available files - const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); - for (let filePath of files) { - filePath = normalizePath(filePath); - if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { - continue; - } + if (host.readDirectory) { + // Enumerate the available files if possible + const files = host.readDirectory(baseDirectory, extensions, /*exclude*/undefined, /*include*/["./*"]); + for (let filePath of files) { + filePath = normalizePath(filePath); + if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { + continue; + } - const fileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); - const duplicate = !includeExtensions && forEach(result, entry => entry.name === fileName); + const fileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); + const duplicate = !includeExtensions && forEach(result, entry => entry.name === fileName); - if (!duplicate) { - result.push({ - name: fileName, - kind: ScriptElementKind.scriptElement, - sortText: fileName - }); + if (!duplicate) { + result.push({ + name: fileName, + kind: ScriptElementKind.scriptElement, + sortText: fileName + }); + } } } @@ -4691,44 +4698,46 @@ namespace ts { } function getModulesForPathsPattern(fragment: string, baseUrl: string, pattern: string, fileExtensions: string[]): string[] { - const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); - const normalizedPrefixBase = getBaseFileName(normalizedPrefix); + if (host.readDirectory) { + const parsed = hasZeroOrOneAsteriskCharacter(pattern) ? tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + const normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + const normalizedPrefixDirectory = getDirectoryPath(normalizedPrefix); + const normalizedPrefixBase = getBaseFileName(normalizedPrefix); - const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; + const fragmentHasPath = fragment.indexOf(directorySeparator) !== -1; - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + const expandedPrefixDirectory = fragmentHasPath ? combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + getDirectoryPath(fragment)) : normalizedPrefixDirectory; - const normalizedSuffix = normalizePath(parsed.suffix); - const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); - const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + const normalizedSuffix = normalizePath(parsed.suffix); + const baseDirectory = combinePaths(baseUrl, expandedPrefixDirectory); + const completePrefix = fragmentHasPath ? baseDirectory : ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - const includeGlob = normalizedSuffix ? "**/*" : "./*"; + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + const includeGlob = normalizedSuffix ? "**/*" : "./*"; - const matches = host.readDirectory(baseDirectory, fileExtensions, undefined, [includeGlob]); - const result: string[] = []; + const matches = host.readDirectory(baseDirectory, fileExtensions, undefined, [includeGlob]); + const result: string[] = []; - // Trim away prefix and suffix - for (const match of matches) { - const normalizedMatch = normalizePath(match); - if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { - continue; + // Trim away prefix and suffix + for (const match of matches) { + const normalizedMatch = normalizePath(match); + if (!endsWith(normalizedMatch, normalizedSuffix) || !startsWith(normalizedMatch, completePrefix)) { + continue; + } + + const start = completePrefix.length; + const length = normalizedMatch.length - start - normalizedSuffix.length; + + result.push(removeFileExtension(normalizedMatch.substr(start, length))); } - - const start = completePrefix.length; - const length = normalizedMatch.length - start - normalizedSuffix.length; - - result.push(removeFileExtension(normalizedMatch.substr(start, length))); + return result; } - return result; } return undefined; @@ -4762,7 +4771,7 @@ namespace ts { if (!isNestedModule) { nonRelativeModules.push(visibleModule.moduleName); } - else if (startsWith(visibleModule.moduleName, moduleNameFragment)) { + else if (host.readDirectory && startsWith(visibleModule.moduleName, moduleNameFragment)) { const nestedFiles = host.readDirectory(visibleModule.moduleDir, supportedTypeScriptExtensions, /*exclude*/undefined, /*include*/["./*"]); for (let f of nestedFiles) { @@ -4891,28 +4900,31 @@ namespace ts { function enumerateNodeModulesVisibleToScript(host: LanguageServiceHost, scriptPath: string) { const result: VisibleModuleInfo[] = []; - for (const packageJson of findPackageJsons(scriptPath)) { - const package = tryReadingPackageJson(packageJson); - if (!package) { - return; - } - const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); - const foundModuleNames: string[] = []; + if (host.readFile && host.fileExists) { + for (const packageJson of findPackageJsons(scriptPath)) { + const package = tryReadingPackageJson(packageJson); + if (!package) { + return; + } - if (package.dependencies) { - addPotentialPackageNames(package.dependencies, foundModuleNames); - } - if (package.devDependencies) { - addPotentialPackageNames(package.devDependencies, foundModuleNames); - } + const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); + const foundModuleNames: string[] = []; - for (const moduleName of foundModuleNames) { - const moduleDir = combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName, - moduleDir - }); + if (package.dependencies) { + addPotentialPackageNames(package.dependencies, foundModuleNames); + } + if (package.devDependencies) { + addPotentialPackageNames(package.devDependencies, foundModuleNames); + } + + for (const moduleName of foundModuleNames) { + const moduleDir = combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName, + moduleDir + }); + } } } From 8d5aaf8eda96e9305fa172f600dac9fe39e54dc2 Mon Sep 17 00:00:00 2001 From: Zhengbo Li Date: Thu, 25 Aug 2016 14:26:58 -0700 Subject: [PATCH 268/508] avoid creating syntax nodes for jsdoc comment tags (#10526) --- src/services/services.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index babb5cf4574..a55f2cf61b0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -280,11 +280,14 @@ namespace ts { let pos = this.pos; const useJSDocScanner = this.kind >= SyntaxKind.FirstJSDocTagNode && this.kind <= SyntaxKind.LastJSDocTagNode; const processNode = (node: Node) => { - if (pos < node.pos) { + const isJSDocTagNode = isJSDocTag(node); + if (!isJSDocTagNode && pos < node.pos) { pos = this.addSyntheticNodes(children, pos, node.pos, useJSDocScanner); } children.push(node); - pos = node.end; + if (!isJSDocTagNode) { + pos = node.end; + } }; const processNodes = (nodes: NodeArray) => { if (pos < nodes.pos) { @@ -299,10 +302,6 @@ namespace ts { processNode(jsDocComment); } } - // For syntactic classifications, all trivia are classcified together, including jsdoc comments. - // For that to work, the jsdoc comments should still be the leading trivia of the first child. - // Restoring the scanner position ensures that. - pos = this.pos; forEachChild(this, processNode, processNodes); if (pos < this.end) { this.addSyntheticNodes(children, pos, this.end); From d7376aa8f13c7805c1bc6eae486370a29e01a146 Mon Sep 17 00:00:00 2001 From: Ben Mosher Date: Thu, 25 Aug 2016 20:30:17 -0400 Subject: [PATCH 269/508] Allow undefined from ProxyHandler.getOwnPropertyDescriptor https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/getOwnPropertyDescriptor --- lib/lib.es2015.proxy.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index 3908e97c17c..fa7527ef1c4 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -19,7 +19,7 @@ interface ProxyHandler { setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; - getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined; has? (target: T, p: PropertyKey): boolean; get? (target: T, p: PropertyKey, receiver: any): any; set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; @@ -35,4 +35,4 @@ interface ProxyConstructor { revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; new (target: T, handler: ProxyHandler): T } -declare var Proxy: ProxyConstructor; \ No newline at end of file +declare var Proxy: ProxyConstructor; From 276b56dfb03ef5f9a035aa0b0509ef46a469c476 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 25 Aug 2016 17:39:55 -0700 Subject: [PATCH 270/508] More PR feedback --- src/services/services.ts | 42 ++++++++++--------- ...tionForStringLiteralNonrelativeImport12.ts | 28 +++++++++++++ 2 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts diff --git a/src/services/services.ts b/src/services/services.ts index fde5b300c2f..8bb378e090a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2076,6 +2076,8 @@ namespace ts { */ const tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*(); for (let filePath of files) { filePath = normalizePath(filePath); if (exclude && comparePaths(filePath, exclude, scriptPath, ignoreCase) === Comparison.EqualTo) { continue; } - const fileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); - const duplicate = !includeExtensions && forEach(result, entry => entry.name === fileName); + const foundFileName = includeExtensions ? getBaseFileName(filePath) : removeFileExtension(getBaseFileName(filePath)); - if (!duplicate) { - result.push({ - name: fileName, - kind: ScriptElementKind.scriptElement, - sortText: fileName - }); + if (!foundFiles[foundFileName]) { + foundFiles[foundFileName] = true; } } + + for (const foundFile in foundFiles) { + result.push({ + name: foundFile, + kind: ScriptElementKind.scriptElement, + sortText: foundFile + }); + } } // If possible, get folder completion as well @@ -4836,7 +4842,7 @@ namespace ts { function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { // Check for typings specified in compiler options if (options.types) { - for (const moduleName of options.types){ + for (const moduleName of options.types) { result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); } } @@ -4911,11 +4917,9 @@ namespace ts { const nodeModulesDir = combinePaths(getDirectoryPath(packageJson), "node_modules"); const foundModuleNames: string[] = []; - if (package.dependencies) { - addPotentialPackageNames(package.dependencies, foundModuleNames); - } - if (package.devDependencies) { - addPotentialPackageNames(package.devDependencies, foundModuleNames); + // Provide completions for all non @types dependencies + for (const key of nodeModulesDependencyKeys) { + addPotentialPackageNames(package[key], foundModuleNames); } for (const moduleName of foundModuleNames) { @@ -4940,11 +4944,12 @@ namespace ts { } } - // Add all the package names that are not in the @types scope function addPotentialPackageNames(dependencies: any, result: string[]) { - for (const dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { - result.push(dep); + if (dependencies) { + for (const dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !startsWith(dep, "@types/")) { + result.push(dep); + } } } } @@ -4955,7 +4960,6 @@ namespace ts { } // Replace everything after the last directory seperator that appears - // FIXME: do we care about the other seperator? function getDirectoryFragmentTextSpan(text: string, textStart: number): TextSpan { const index = text.lastIndexOf(directorySeparator); const offset = index !== -1 ? index + 1 : 0; diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts new file mode 100644 index 00000000000..92db8d5a50e --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts @@ -0,0 +1,28 @@ +/// + +// Should give completions for all dependencies in package.json + +// @Filename: tests/test0.ts +//// import * as foo1 from "m/*import_as0*/ +//// import foo2 = require("m/*import_equals0*/ +//// var foo3 = require("m/*require0*/ + +// @Filename: package.json +//// { +//// "dependencies": { "module": "latest" }, +//// "devDependencies": { "dev-module": "latest" }, +//// "optionalDependencies": { "optional-module": "latest" }, +//// "peerDependencies": { "peer-module": "latest" } +//// } + +const kinds = ["import_as", "import_equals", "require"]; + +for (const kind of kinds) { + goTo.marker(kind + "0"); + + verify.importModuleCompletionListContains("module"); + verify.importModuleCompletionListContains("dev-module"); + verify.importModuleCompletionListContains("optional-module"); + verify.importModuleCompletionListContains("peer-module"); + verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); +} From 0116abdcf2cc57174a839deb29e6c4419c576dfd Mon Sep 17 00:00:00 2001 From: Ryan Cavanaugh Date: Fri, 26 Aug 2016 08:49:43 -0700 Subject: [PATCH 271/508] First in UMD global wins Fixes #9771 --- src/compiler/checker.ts | 8 ++++- .../baselines/reference/umdGlobalConflict.js | 23 +++++++++++++++ .../reference/umdGlobalConflict.symbols | 29 +++++++++++++++++++ .../reference/umdGlobalConflict.types | 29 +++++++++++++++++++ tests/cases/compiler/umdGlobalConflict.ts | 15 ++++++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 tests/baselines/reference/umdGlobalConflict.js create mode 100644 tests/baselines/reference/umdGlobalConflict.symbols create mode 100644 tests/baselines/reference/umdGlobalConflict.types create mode 100644 tests/cases/compiler/umdGlobalConflict.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2341a0f7dfd..8c1e401912d 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -18763,7 +18763,13 @@ namespace ts { (augmentations || (augmentations = [])).push(file.moduleAugmentations); } if (file.symbol && file.symbol.globalExports) { - mergeSymbolTable(globals, file.symbol.globalExports); + // Merge in UMD exports with first-in-wins semantics (see #9771) + const source = file.symbol.globalExports; + for (const id in source) { + if (!(id in globals)) { + globals[id] = source[id]; + } + } } }); diff --git a/tests/baselines/reference/umdGlobalConflict.js b/tests/baselines/reference/umdGlobalConflict.js new file mode 100644 index 00000000000..e8a820e2333 --- /dev/null +++ b/tests/baselines/reference/umdGlobalConflict.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/umdGlobalConflict.ts] //// + +//// [index.d.ts] +export as namespace Alpha; +export var x: string; + +//// [index.d.ts] +export as namespace Alpha; +export var y: number; + +//// [consumer.ts] +import * as v1 from './v1'; +import * as v2 from './v2'; + +//// [global.ts] +// Should be OK, first in wins +const p: string = Alpha.x; + +//// [consumer.js] +"use strict"; +//// [global.js] +// Should be OK, first in wins +var p = Alpha.x; diff --git a/tests/baselines/reference/umdGlobalConflict.symbols b/tests/baselines/reference/umdGlobalConflict.symbols new file mode 100644 index 00000000000..b13fb0f25b1 --- /dev/null +++ b/tests/baselines/reference/umdGlobalConflict.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/v1/index.d.ts === +export as namespace Alpha; +>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0)) + +export var x: string; +>x : Symbol(x, Decl(index.d.ts, 1, 10)) + +=== tests/cases/compiler/v2/index.d.ts === +export as namespace Alpha; +>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0)) + +export var y: number; +>y : Symbol(y, Decl(index.d.ts, 1, 10)) + +=== tests/cases/compiler/consumer.ts === +import * as v1 from './v1'; +>v1 : Symbol(v1, Decl(consumer.ts, 0, 6)) + +import * as v2 from './v2'; +>v2 : Symbol(v2, Decl(consumer.ts, 1, 6)) + +=== tests/cases/compiler/global.ts === +// Should be OK, first in wins +const p: string = Alpha.x; +>p : Symbol(p, Decl(global.ts, 1, 5)) +>Alpha.x : Symbol(Alpha.x, Decl(index.d.ts, 1, 10)) +>Alpha : Symbol(Alpha, Decl(index.d.ts, 0, 0)) +>x : Symbol(Alpha.x, Decl(index.d.ts, 1, 10)) + diff --git a/tests/baselines/reference/umdGlobalConflict.types b/tests/baselines/reference/umdGlobalConflict.types new file mode 100644 index 00000000000..fa74e26874f --- /dev/null +++ b/tests/baselines/reference/umdGlobalConflict.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/v1/index.d.ts === +export as namespace Alpha; +>Alpha : typeof Alpha + +export var x: string; +>x : string + +=== tests/cases/compiler/v2/index.d.ts === +export as namespace Alpha; +>Alpha : typeof + +export var y: number; +>y : number + +=== tests/cases/compiler/consumer.ts === +import * as v1 from './v1'; +>v1 : typeof v1 + +import * as v2 from './v2'; +>v2 : typeof v2 + +=== tests/cases/compiler/global.ts === +// Should be OK, first in wins +const p: string = Alpha.x; +>p : string +>Alpha.x : string +>Alpha : typeof Alpha +>x : string + diff --git a/tests/cases/compiler/umdGlobalConflict.ts b/tests/cases/compiler/umdGlobalConflict.ts new file mode 100644 index 00000000000..58b4ea6be02 --- /dev/null +++ b/tests/cases/compiler/umdGlobalConflict.ts @@ -0,0 +1,15 @@ +//@filename: v1/index.d.ts +export as namespace Alpha; +export var x: string; + +//@filename: v2/index.d.ts +export as namespace Alpha; +export var y: number; + +//@filename: consumer.ts +import * as v1 from './v1'; +import * as v2 from './v2'; + +//@filename: global.ts +// Should be OK, first in wins +const p: string = Alpha.x; \ No newline at end of file From 3f126a52f9b9f598acbfa01305424f47c5b0aeb1 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Wed, 24 Aug 2016 09:26:38 -0700 Subject: [PATCH 272/508] Allow to find all references for constructors --- src/compiler/checker.ts | 2 +- src/services/services.ts | 157 ++++++++++++++++-- .../findAllReferencesOfConstructor.ts | 43 +++++ 3 files changed, 188 insertions(+), 14 deletions(-) create mode 100644 tests/cases/fourslash/findAllReferencesOfConstructor.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 2341a0f7dfd..46863997193 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8752,7 +8752,7 @@ namespace ts { // The location isn't a reference to the given symbol, meaning we're being asked // a hypothetical question of what type the symbol would have if there was a reference // to it at the given location. Since we have no control flow information for the - // hypotherical reference (control flow information is created and attached by the + // hypothetical reference (control flow information is created and attached by the // binder), we simply return the declared type of the symbol. return getTypeOfSymbol(symbol); } diff --git a/src/services/services.ts b/src/services/services.ts index a55f2cf61b0..c9ba2cd6056 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2788,18 +2788,41 @@ namespace ts { return node && node.parent && node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node; } + function climbPastPropertyAccess(node: Node) { + return isRightSideOfPropertyAccess(node) ? node.parent : node; + } + function isCallExpressionTarget(node: Node): boolean { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; - } - return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; + return isCallOrNewExpressionTarget(node, SyntaxKind.CallExpression); } function isNewExpressionTarget(node: Node): boolean { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; + return isCallOrNewExpressionTarget(node, SyntaxKind.NewExpression); + } + + function isCallOrNewExpressionTarget(node: Node, kind: SyntaxKind) { + const target = climbPastPropertyAccess(node); + return target && target.parent && target.parent.kind === kind && (target.parent).expression === target; + } + + /** Get `C` given `N` if `N` is in the position `class C extends N` */ + function tryGetClassExtendingNode(node: Node): ClassLikeDeclaration | undefined { + const target = climbPastPropertyAccess(node); + + const expr = target.parent; + if (expr.kind !== SyntaxKind.ExpressionWithTypeArguments) { + return; + } + + const heritageClause = expr.parent; + if (heritageClause.kind !== SyntaxKind.HeritageClause) { + return; + } + + const classNode = heritageClause.parent; + if (getHeritageClause(classNode.heritageClauses, SyntaxKind.ExtendsKeyword) === heritageClause) { + return classNode; } - return node && node.parent && node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node; } function isNameOfModuleDeclaration(node: Node) { @@ -4714,7 +4737,9 @@ namespace ts { if (functionDeclaration.kind === SyntaxKind.Constructor) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + // For a constructor, `type` will be unknown. + const showSymbol = symbol.declarations[0].kind === SyntaxKind.Constructor ? symbol.parent : type.symbol; + addPrefixForAnyFunctionOrVar(showSymbol, symbolKind); } else { // (function/method) symbol(..signature) @@ -6008,6 +6033,7 @@ namespace ts { case SyntaxKind.Identifier: case SyntaxKind.ThisKeyword: // case SyntaxKind.SuperKeyword: TODO:GH#9268 + case SyntaxKind.ConstructorKeyword: case SyntaxKind.StringLiteral: return getReferencedSymbolsForNode(node, program.getSourceFiles(), findInStrings, findInComments); } @@ -6052,7 +6078,11 @@ namespace ts { return getReferencesForSuperKeyword(node); } - const symbol = typeChecker.getSymbolAtLocation(node); + const isConstructor = node.kind === SyntaxKind.ConstructorKeyword; + + // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, + // so we have to specify that we want the constructor symbol. + let symbol = isConstructor ? node.parent.symbol : typeChecker.getSymbolAtLocation(node); if (!symbol && node.kind === SyntaxKind.StringLiteral) { return getReferencesForStringLiteral(node, sourceFiles); @@ -6078,7 +6108,8 @@ namespace ts { // Get the text to search for. // Note: if this is an external module symbol, the name doesn't include quotes. - const declaredName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); + const nameSymbol = isConstructor ? symbol.parent : symbol; // A constructor is referenced using the name of its class. + const declaredName = stripQuotes(getDeclaredName(typeChecker, nameSymbol, node)); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). @@ -6092,7 +6123,7 @@ namespace ts { getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - const internedName = getInternedName(symbol, node, declarations); + const internedName = isConstructor ? declaredName : getInternedName(symbol, node, declarations); for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -6430,12 +6461,98 @@ namespace ts { const referencedSymbol = getReferencedSymbol(shorthandValueSymbol); referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); } + else if (searchLocation.kind === SyntaxKind.ConstructorKeyword) { + findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } } }); } return; + /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ + function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { + const searchClassSymbol = searchSymbol.parent; + Debug.assert(isClassLike(searchClassSymbol.valueDeclaration)); + + const referenceClass = referenceLocation.parent; + if (referenceSymbol === searchClassSymbol && isClassLike(referenceClass)) { + // This is the class declaration containing the constructor. + const calls = findOwnConstructorCalls(referenceSymbol, referenceClass); + addReferences(calls); + } + else { + // If this class appears in `extends C`, then the extending class' "super" calls are references. + const classExtending = tryGetClassExtendingNode(referenceLocation); + if (classExtending && isClassLike(classExtending)) { + if (getRelatedSymbol([searchClassSymbol], referenceSymbol, referenceLocation)) { + const supers = superConstructorAccesses(classExtending); + addReferences(supers); + } + } + } + } + + function addReferences(references: Node[]): void { + if (references.length) { + const referencedSymbol = getReferencedSymbol(searchSymbol); + addRange(referencedSymbol.references, map(references, getReferenceEntryFromNode)); + } + } + + /** `referenceLocation` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorCalls(referenceSymbol: Symbol, referenceLocation: ClassLikeDeclaration): Node[] { + const result: Node[] = []; + + for (const decl of referenceSymbol.members["__constructor"].declarations) { + Debug.assert(decl.kind === SyntaxKind.Constructor); + const ctrKeyword = decl.getChildAt(0); + Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword); + result.push(ctrKeyword); + } + + forEachProperty(referenceSymbol.exports, member => { + const decl = member.valueDeclaration; + if (decl && decl.kind === SyntaxKind.MethodDeclaration) { + const body = (decl).body; + if (body) { + forEachDescendant(body, SyntaxKind.ThisKeyword, thisKeyword => { + if (isNewExpressionTarget(thisKeyword)) { + result.push(thisKeyword); + } + }); + } + } + }); + + return result; + } + + /** Find references to `super` in the constructor of an extending class. */ + function superConstructorAccesses(cls: ClassLikeDeclaration): Node[] { + const symbol = cls.symbol; + const ctr = symbol.members["__constructor"]; + if (!ctr) { + return []; + } + + const result: Node[] = []; + for (const decl of ctr.declarations) { + Debug.assert(decl.kind === SyntaxKind.Constructor); + const body = (decl).body; + if (body) { + forEachDescendant(body, SyntaxKind.SuperKeyword, node => { + if (isCallExpressionTarget(node)) { + result.push(node); + } + }); + } + }; + return result; + } + function getReferencedSymbol(symbol: Symbol): ReferencedSymbol { const symbolId = getSymbolId(symbol); let index = symbolToIndex[symbolId]; @@ -6809,8 +6926,8 @@ namespace ts { } } - function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node): Symbol { - if (searchSymbols.indexOf(referenceSymbol) >= 0) { + function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node): Symbol | undefined { + if (contains(searchSymbols, referenceSymbol)) { return referenceSymbol; } @@ -6821,6 +6938,11 @@ namespace ts { return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation); } + // If we are in a constructor and we didn't find the symbol yet, we should try looking for the constructor instead. + if (isNewExpressionTarget(referenceLocation) && referenceSymbol.members && referenceSymbol.members["__constructor"]) { + return getRelatedSymbol(searchSymbols, referenceSymbol.members["__constructor"], referenceLocation.parent); + } + // If the reference location is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this symbol to // compare to our searchSymbol @@ -8342,6 +8464,15 @@ namespace ts { }; } + function forEachDescendant(node: Node, kind: SyntaxKind, action: (node: Node) => void) { + forEachChild(node, child => { + if (child.kind === kind) { + action(child); + } + forEachDescendant(child, kind, action); + }); + } + /* @internal */ export function getNameTable(sourceFile: SourceFile): Map { if (!sourceFile.nameTable) { diff --git a/tests/cases/fourslash/findAllReferencesOfConstructor.ts b/tests/cases/fourslash/findAllReferencesOfConstructor.ts new file mode 100644 index 00000000000..15d002862a1 --- /dev/null +++ b/tests/cases/fourslash/findAllReferencesOfConstructor.ts @@ -0,0 +1,43 @@ +/// + +// @Filename: a.ts +////export class C { +//// [|constructor|](n: number); +//// [|constructor|](); +//// [|constructor|](n?: number){} +//// static f() { +//// this.f(); +//// new [|this|](); +//// } +////} +////new [|C|](); +// Does not handle alias. +////const D = C; +////new D(); + +// @Filename: b.ts +////import { C } from "./a"; +////new [|C|](); + +// @Filename: c.ts +////import { C } from "./a"; +////class D extends C { +//// constructor() { +//// [|super|](); +//// super.method(); +//// } +//// method() { super(); } +////} +////class E implements C { +//// constructor() { super(); } +////} + +// Works with qualified names too +// @Filename: d.ts +////import * as a from "./a"; +////new a.[|C|](); +////class d extends a.C { constructor() { [|super|](); } + +const ranges = test.ranges(); +verify.referencesOf(ranges[0], ranges); +verify.referencesOf(ranges[1], ranges); From c1a291dffe8552f90ad372550ab52aa78f9b66ca Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 26 Aug 2016 10:06:27 -0700 Subject: [PATCH 273/508] Get the type of a constructor as the type of the class Fixes a bug when constructor overloads are improper and no signatures can be found. --- src/services/services.ts | 14 +++++++++----- .../fourslash/findAllReferencesOfConstructor.ts | 5 +++-- .../findAllReferencesOfConstructor_badOverload.ts | 8 ++++++++ 3 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts diff --git a/src/services/services.ts b/src/services/services.ts index c9ba2cd6056..e58579e27f9 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4628,7 +4628,8 @@ namespace ts { const symbolFlags = symbol.flags; let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); let hasAddedSymbolInfo: boolean; - const isThisExpression: boolean = location.kind === SyntaxKind.ThisKeyword && isExpression(location); + const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isExpression(location); + const isConstructor = location.kind === SyntaxKind.ConstructorKeyword; let type: Type; // Class at constructor site need to be shown as constructor apart from property,method, vars @@ -4639,7 +4640,12 @@ namespace ts { } let signature: Signature; - type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); + type = isThisExpression + ? typeChecker.getTypeAtLocation(location) + : isConstructor + // For constructor, get type of the class. + ? typeChecker.getTypeOfSymbolAtLocation(symbol.parent, location) + : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) { const right = (location.parent).name; @@ -4737,9 +4743,7 @@ namespace ts { if (functionDeclaration.kind === SyntaxKind.Constructor) { // show (constructor) Type(...) signature symbolKind = ScriptElementKind.constructorImplementationElement; - // For a constructor, `type` will be unknown. - const showSymbol = symbol.declarations[0].kind === SyntaxKind.Constructor ? symbol.parent : type.symbol; - addPrefixForAnyFunctionOrVar(showSymbol, symbolKind); + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) diff --git a/tests/cases/fourslash/findAllReferencesOfConstructor.ts b/tests/cases/fourslash/findAllReferencesOfConstructor.ts index 15d002862a1..27c253b1356 100644 --- a/tests/cases/fourslash/findAllReferencesOfConstructor.ts +++ b/tests/cases/fourslash/findAllReferencesOfConstructor.ts @@ -39,5 +39,6 @@ ////class d extends a.C { constructor() { [|super|](); } const ranges = test.ranges(); -verify.referencesOf(ranges[0], ranges); -verify.referencesOf(ranges[1], ranges); +for (const ctr of ranges.slice(0, 3)) { + verify.referencesOf(ctr, ranges); +} diff --git a/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts b/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts new file mode 100644 index 00000000000..77479bad113 --- /dev/null +++ b/tests/cases/fourslash/findAllReferencesOfConstructor_badOverload.ts @@ -0,0 +1,8 @@ +/// + +////class C { +//// [|constructor|](n: number); +//// [|constructor|](){} +////} + +verify.rangesReferenceEachOther(); From f90d8ddca53e011bc9d544d9436482bd0bb583a4 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 26 Aug 2016 10:40:10 -0700 Subject: [PATCH 274/508] Reuse code for tryGetClassExtendingIdentifier --- src/compiler/utilities.ts | 13 ++++++++++--- src/services/services.ts | 23 ++++------------------- 2 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0c026fc6b6d..4d27730ab33 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2659,10 +2659,17 @@ namespace ts { return token >= SyntaxKind.FirstAssignment && token <= SyntaxKind.LastAssignment; } - export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean { - return node.kind === SyntaxKind.ExpressionWithTypeArguments && + /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ + export function tryGetClassExtendingExpressionWithTypeArguments(node: Node): ClassLikeDeclaration | undefined { + if (node.kind === SyntaxKind.ExpressionWithTypeArguments && (node.parent).token === SyntaxKind.ExtendsKeyword && - isClassLike(node.parent.parent); + isClassLike(node.parent.parent)) { + return node.parent.parent; + } + } + + export function isExpressionWithTypeArgumentsInClassExtendsClause(node: Node): boolean { + return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } export function isEntityNameExpression(node: Expression): node is EntityNameExpression { diff --git a/src/services/services.ts b/src/services/services.ts index e58579e27f9..0b86fdb0d09 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2805,24 +2805,9 @@ namespace ts { return target && target.parent && target.parent.kind === kind && (target.parent).expression === target; } - /** Get `C` given `N` if `N` is in the position `class C extends N` */ - function tryGetClassExtendingNode(node: Node): ClassLikeDeclaration | undefined { - const target = climbPastPropertyAccess(node); - - const expr = target.parent; - if (expr.kind !== SyntaxKind.ExpressionWithTypeArguments) { - return; - } - - const heritageClause = expr.parent; - if (heritageClause.kind !== SyntaxKind.HeritageClause) { - return; - } - - const classNode = heritageClause.parent; - if (getHeritageClause(classNode.heritageClauses, SyntaxKind.ExtendsKeyword) === heritageClause) { - return classNode; - } + /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ + function tryGetClassExtendingIdentifier(node: Node): ClassLikeDeclaration | undefined { + return tryGetClassExtendingExpressionWithTypeArguments(climbPastPropertyAccess(node).parent); } function isNameOfModuleDeclaration(node: Node) { @@ -6487,7 +6472,7 @@ namespace ts { } else { // If this class appears in `extends C`, then the extending class' "super" calls are references. - const classExtending = tryGetClassExtendingNode(referenceLocation); + const classExtending = tryGetClassExtendingIdentifier(referenceLocation); if (classExtending && isClassLike(classExtending)) { if (getRelatedSymbol([searchClassSymbol], referenceSymbol, referenceLocation)) { const supers = superConstructorAccesses(classExtending); From 0a985ee28771c1aee386c7a2cb74c36ce8721e81 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 26 Aug 2016 13:25:19 -0700 Subject: [PATCH 275/508] Parse untyped object type members separated by ',' Previously if the first member was untyped and the separator was ',', then parsing would fail. --- src/compiler/parser.ts | 1 + .../reference/parseObjectLiteralsWithoutTypes.js | 10 ++++++++++ .../parseObjectLiteralsWithoutTypes.symbols | 16 ++++++++++++++++ .../parseObjectLiteralsWithoutTypes.types | 16 ++++++++++++++++ .../compiler/parseObjectLiteralsWithoutTypes.ts | 3 +++ 5 files changed, 46 insertions(+) create mode 100644 tests/baselines/reference/parseObjectLiteralsWithoutTypes.js create mode 100644 tests/baselines/reference/parseObjectLiteralsWithoutTypes.symbols create mode 100644 tests/baselines/reference/parseObjectLiteralsWithoutTypes.types create mode 100644 tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b5ba89887a2..b28f13e438f 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -2339,6 +2339,7 @@ namespace ts { token() === SyntaxKind.LessThanToken || token() === SyntaxKind.QuestionToken || token() === SyntaxKind.ColonToken || + token() === SyntaxKind.CommaToken || canParseSemicolon(); } return false; diff --git a/tests/baselines/reference/parseObjectLiteralsWithoutTypes.js b/tests/baselines/reference/parseObjectLiteralsWithoutTypes.js new file mode 100644 index 00000000000..4872cb8773b --- /dev/null +++ b/tests/baselines/reference/parseObjectLiteralsWithoutTypes.js @@ -0,0 +1,10 @@ +//// [parseObjectLiteralsWithoutTypes.ts] +let x: { foo, bar } +let y: { foo: number, bar } +let z: { foo, bar: number } + + +//// [parseObjectLiteralsWithoutTypes.js] +var x; +var y; +var z; diff --git a/tests/baselines/reference/parseObjectLiteralsWithoutTypes.symbols b/tests/baselines/reference/parseObjectLiteralsWithoutTypes.symbols new file mode 100644 index 00000000000..1e0bd775d10 --- /dev/null +++ b/tests/baselines/reference/parseObjectLiteralsWithoutTypes.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts === +let x: { foo, bar } +>x : Symbol(x, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 3)) +>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 8)) +>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 0, 13)) + +let y: { foo: number, bar } +>y : Symbol(y, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 3)) +>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 8)) +>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 1, 21)) + +let z: { foo, bar: number } +>z : Symbol(z, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 3)) +>foo : Symbol(foo, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 8)) +>bar : Symbol(bar, Decl(parseObjectLiteralsWithoutTypes.ts, 2, 13)) + diff --git a/tests/baselines/reference/parseObjectLiteralsWithoutTypes.types b/tests/baselines/reference/parseObjectLiteralsWithoutTypes.types new file mode 100644 index 00000000000..dcd9cb79d19 --- /dev/null +++ b/tests/baselines/reference/parseObjectLiteralsWithoutTypes.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts === +let x: { foo, bar } +>x : { foo: any; bar: any; } +>foo : any +>bar : any + +let y: { foo: number, bar } +>y : { foo: number; bar: any; } +>foo : number +>bar : any + +let z: { foo, bar: number } +>z : { foo: any; bar: number; } +>foo : any +>bar : number + diff --git a/tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts b/tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts new file mode 100644 index 00000000000..7f00e4b15e7 --- /dev/null +++ b/tests/cases/compiler/parseObjectLiteralsWithoutTypes.ts @@ -0,0 +1,3 @@ +let x: { foo, bar } +let y: { foo: number, bar } +let z: { foo, bar: number } From 3f8cd8230163b9b33f5b511bc639398a101b8bc0 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Fri, 26 Aug 2016 13:30:59 -0700 Subject: [PATCH 276/508] Update other tests and baselines --- ...ShorthandPropertiesAssignmentError.errors.txt | 13 ++----------- ...tLiteralShorthandPropertiesAssignmentError.js | 5 ++--- ...signmentErrorFromMissingIdentifier.errors.txt | 16 ++++------------ ...ertiesAssignmentErrorFromMissingIdentifier.js | 8 ++++---- ...tLiteralShorthandPropertiesAssignmentError.ts | 2 +- ...ertiesAssignmentErrorFromMissingIdentifier.ts | 4 ++-- 6 files changed, 15 insertions(+), 33 deletions(-) diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt index 50839d5e56b..6f405facceb 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.errors.txt @@ -1,8 +1,5 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(4,43): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,16): error TS1131: Property or signature expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(5,25): error TS1128: Declaration or statement expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts(6,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. Types of property 'id' are incompatible. Type 'number' is not assignable to type 'string'. @@ -11,7 +8,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr Type 'number' is not assignable to type 'boolean'. -==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (6 errors) ==== +==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts (3 errors) ==== var id: number = 10000; var name: string = "my name"; @@ -19,13 +16,7 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr ~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ b: string; id: number; }'. !!! error TS2322: Object literal may only specify known properties, and 'name' does not exist in type '{ b: string; id: number; }'. - var person1: { name, id }; // error: can't use short-hand property assignment in type position - ~~~~ -!!! error TS1131: Property or signature expected. - ~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'. - ~ -!!! error TS1128: Declaration or statement expected. + var person1: { name, id }; // ok function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error ~~~~~~~~~~~~ !!! error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ id: string; name: number; }'. diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.js b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.js index 8e2d7f80356..4d01f799348 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.js +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentError.js @@ -3,7 +3,7 @@ var id: number = 10000; var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error -var person1: { name, id }; // error: can't use short-hand property assignment in type position +var person1: { name, id }; // ok function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error function bar(obj: { name: string; id: boolean }) { } bar({ name, id }); // error @@ -14,8 +14,7 @@ bar({ name, id }); // error var id = 10000; var name = "my name"; var person = { name: name, id: id }; // error -var person1 = name, id; -; // error: can't use short-hand property assignment in type position +var person1; // ok function foo(name, id) { return { name: name, id: id }; } // error function bar(obj) { } bar({ name: name, id: id }); // error diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt index b4f695c835d..92750fd29a0 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.errors.txt @@ -3,15 +3,12 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(5,79): error TS2322: Type '{ name: string; id: number; }' is not assignable to type '{ name: number; id: string; }'. Types of property 'name' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,16): error TS1131: Property or signature expected. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'. -tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(7,25): error TS1128: Declaration or statement expected. tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts(8,5): error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'. Types of property 'name' are incompatible. Type 'number' is not assignable to type 'string'. -==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts (6 errors) ==== +==== tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts (3 errors) ==== var id: number = 10000; var name: string = "my name"; @@ -25,15 +22,10 @@ tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPr !!! error TS2322: Types of property 'name' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error - var person1: { name, id }; // error : Can't use shorthand in the type position - ~~~~ -!!! error TS1131: Property or signature expected. - ~~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'id' must be of type 'number', but here has type 'any'. - ~ -!!! error TS1128: Declaration or statement expected. + var person1: { name, id }; // ok var person2: { name: string, id: number } = bar("hello", 5); ~~~~~~~ !!! error TS2322: Type '{ name: number; id: string; }' is not assignable to type '{ name: string; id: number; }'. !!! error TS2322: Types of property 'name' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type 'number' is not assignable to type 'string'. + \ No newline at end of file diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.js b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.js index 71449746add..7800cbff53e 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.js +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.js @@ -5,8 +5,9 @@ var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error -var person1: { name, id }; // error : Can't use shorthand in the type position -var person2: { name: string, id: number } = bar("hello", 5); +var person1: { name, id }; // ok +var person2: { name: string, id: number } = bar("hello", 5); + //// [objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.js] var id = 10000; @@ -14,6 +15,5 @@ var name = "my name"; var person = { name: name, id: id }; // error function bar(name, id) { return { name: name, id: id }; } // error function foo(name, id) { return { name: name, id: id }; } // error -var person1 = name, id; -; // error : Can't use shorthand in the type position +var person1; // ok var person2 = bar("hello", 5); diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts index b745b93b3ca..55f10aec932 100644 --- a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentError.ts @@ -2,7 +2,7 @@ var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error -var person1: { name, id }; // error: can't use short-hand property assignment in type position +var person1: { name, id }; // ok function foo(name: string, id: number): { id: string, name: number } { return { name, id }; } // error function bar(obj: { name: string; id: boolean }) { } bar({ name, id }); // error diff --git a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts index 6b0943a8d77..104be41a839 100644 --- a/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts +++ b/tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentErrorFromMissingIdentifier.ts @@ -4,5 +4,5 @@ var name: string = "my name"; var person: { b: string; id: number } = { name, id }; // error function bar(name: string, id: number): { name: number, id: string } { return { name, id }; } // error function foo(name: string, id: number): { name: string, id: number } { return { name, id }; } // error -var person1: { name, id }; // error : Can't use shorthand in the type position -var person2: { name: string, id: number } = bar("hello", 5); \ No newline at end of file +var person1: { name, id }; // ok +var person2: { name: string, id: number } = bar("hello", 5); From 7e6f18d7654e889b0c5005572cd5fe1e92811e5c Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 26 Aug 2016 13:46:12 -0700 Subject: [PATCH 277/508] Don't use constructor symbol for search -- use class symbol and filter out only 'new C()' uses. --- src/compiler/core.ts | 1 - src/services/services.ts | 54 ++++++++----------- .../findAllReferencesOfConstructor.ts | 2 + 3 files changed, 23 insertions(+), 34 deletions(-) diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 27b27bc6532..636a89105fc 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1515,5 +1515,4 @@ namespace ts { ? ((fileName) => fileName) : ((fileName) => fileName.toLowerCase()); } - } diff --git a/src/services/services.ts b/src/services/services.ts index 0b86fdb0d09..47391d609b2 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4614,7 +4614,6 @@ namespace ts { let symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(symbol, symbolFlags, location); let hasAddedSymbolInfo: boolean; const isThisExpression = location.kind === SyntaxKind.ThisKeyword && isExpression(location); - const isConstructor = location.kind === SyntaxKind.ConstructorKeyword; let type: Type; // Class at constructor site need to be shown as constructor apart from property,method, vars @@ -4625,12 +4624,7 @@ namespace ts { } let signature: Signature; - type = isThisExpression - ? typeChecker.getTypeAtLocation(location) - : isConstructor - // For constructor, get type of the class. - ? typeChecker.getTypeOfSymbolAtLocation(symbol.parent, location) - : typeChecker.getTypeOfSymbolAtLocation(symbol, location); + type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { if (location.parent && location.parent.kind === SyntaxKind.PropertyAccessExpression) { const right = (location.parent).name; @@ -6067,11 +6061,9 @@ namespace ts { return getReferencesForSuperKeyword(node); } - const isConstructor = node.kind === SyntaxKind.ConstructorKeyword; - // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, // so we have to specify that we want the constructor symbol. - let symbol = isConstructor ? node.parent.symbol : typeChecker.getSymbolAtLocation(node); + const symbol = typeChecker.getSymbolAtLocation(node); if (!symbol && node.kind === SyntaxKind.StringLiteral) { return getReferencesForStringLiteral(node, sourceFiles); @@ -6097,8 +6089,7 @@ namespace ts { // Get the text to search for. // Note: if this is an external module symbol, the name doesn't include quotes. - const nameSymbol = isConstructor ? symbol.parent : symbol; // A constructor is referenced using the name of its class. - const declaredName = stripQuotes(getDeclaredName(typeChecker, nameSymbol, node)); + const declaredName = stripQuotes(getDeclaredName(typeChecker, symbol, node)); // Try to get the smallest valid scope that we can limit our search to; // otherwise we'll need to search globally (i.e. include each file). @@ -6112,7 +6103,7 @@ namespace ts { getReferencesInNode(scope, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } else { - const internedName = isConstructor ? declaredName : getInternedName(symbol, node, declarations); + const internedName = getInternedName(symbol, node, declarations); for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); @@ -6145,7 +6136,7 @@ namespace ts { }; } - function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol { + function getAliasSymbolForPropertyNameSymbol(symbol: Symbol, location: Node): Symbol | undefined { if (symbol.flags & SymbolFlags.Alias) { // Default import get alias const defaultImport = getDeclarationOfKind(symbol, SyntaxKind.ImportClause); @@ -6171,6 +6162,10 @@ namespace ts { return undefined; } + function followAliasIfNecessary(symbol: Symbol, location: Node): Symbol { + return getAliasSymbolForPropertyNameSymbol(symbol, location) || symbol; + } + function getPropertySymbolOfDestructuringAssignment(location: Node) { return isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && typeChecker.getPropertySymbolOfDestructuringAssignment(location); @@ -6434,7 +6429,8 @@ namespace ts { if (referenceSymbol) { const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); + const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, + /*searchLocationIsConstructor*/ searchLocation.kind === SyntaxKind.ConstructorKeyword); if (relatedSymbol) { const referencedSymbol = getReferencedSymbol(relatedSymbol); @@ -6461,23 +6457,19 @@ namespace ts { /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ function findAdditionalConstructorReferences(referenceSymbol: Symbol, referenceLocation: Node): void { - const searchClassSymbol = searchSymbol.parent; - Debug.assert(isClassLike(searchClassSymbol.valueDeclaration)); + Debug.assert(isClassLike(searchSymbol.valueDeclaration)); const referenceClass = referenceLocation.parent; - if (referenceSymbol === searchClassSymbol && isClassLike(referenceClass)) { + if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) { + Debug.assert(referenceClass.name === referenceLocation); // This is the class declaration containing the constructor. - const calls = findOwnConstructorCalls(referenceSymbol, referenceClass); - addReferences(calls); + addReferences(findOwnConstructorCalls(referenceSymbol, referenceClass)); } else { // If this class appears in `extends C`, then the extending class' "super" calls are references. const classExtending = tryGetClassExtendingIdentifier(referenceLocation); - if (classExtending && isClassLike(classExtending)) { - if (getRelatedSymbol([searchClassSymbol], referenceSymbol, referenceLocation)) { - const supers = superConstructorAccesses(classExtending); - addReferences(supers); - } + if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { + addReferences(superConstructorAccesses(classExtending)); } } } @@ -6915,21 +6907,17 @@ namespace ts { } } - function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node): Symbol | undefined { + function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean): Symbol | undefined { if (contains(searchSymbols, referenceSymbol)) { - return referenceSymbol; + // If we are searching for constructor uses, they must be 'new' expressions. + return !(searchLocationIsConstructor && !isNewExpressionTarget(referenceLocation)) && referenceSymbol; } // If the reference symbol is an alias, check if what it is aliasing is one of the search // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation); - } - - // If we are in a constructor and we didn't find the symbol yet, we should try looking for the constructor instead. - if (isNewExpressionTarget(referenceLocation) && referenceSymbol.members && referenceSymbol.members["__constructor"]) { - return getRelatedSymbol(searchSymbols, referenceSymbol.members["__constructor"], referenceLocation.parent); + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor); } // If the reference location is in an object literal, try to get the contextual type for the diff --git a/tests/cases/fourslash/findAllReferencesOfConstructor.ts b/tests/cases/fourslash/findAllReferencesOfConstructor.ts index 27c253b1356..b25508a60db 100644 --- a/tests/cases/fourslash/findAllReferencesOfConstructor.ts +++ b/tests/cases/fourslash/findAllReferencesOfConstructor.ts @@ -28,6 +28,8 @@ //// } //// method() { super(); } ////} +// Does not find 'super()' calls for a class that merely implements 'C', +// since those must be calling a different constructor. ////class E implements C { //// constructor() { super(); } ////} From 0dc976df1ebaebbf9a26457d1038589cecad08ca Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Fri, 26 Aug 2016 13:50:48 -0700 Subject: [PATCH 278/508] Remove unused parameter --- src/services/services.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 47391d609b2..b95feb92079 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6463,7 +6463,7 @@ namespace ts { if (referenceSymbol === searchSymbol && isClassLike(referenceClass)) { Debug.assert(referenceClass.name === referenceLocation); // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(referenceSymbol, referenceClass)); + addReferences(findOwnConstructorCalls(searchSymbol)); } else { // If this class appears in `extends C`, then the extending class' "super" calls are references. @@ -6481,20 +6481,20 @@ namespace ts { } } - /** `referenceLocation` is the class where the constructor was defined. + /** `classSymbol` is the class where the constructor was defined. * Reference the constructor and all calls to `new this()`. */ - function findOwnConstructorCalls(referenceSymbol: Symbol, referenceLocation: ClassLikeDeclaration): Node[] { + function findOwnConstructorCalls(classSymbol: Symbol): Node[] { const result: Node[] = []; - for (const decl of referenceSymbol.members["__constructor"].declarations) { + for (const decl of classSymbol.members["__constructor"].declarations) { Debug.assert(decl.kind === SyntaxKind.Constructor); const ctrKeyword = decl.getChildAt(0); Debug.assert(ctrKeyword.kind === SyntaxKind.ConstructorKeyword); result.push(ctrKeyword); } - forEachProperty(referenceSymbol.exports, member => { + forEachProperty(classSymbol.exports, member => { const decl = member.valueDeclaration; if (decl && decl.kind === SyntaxKind.MethodDeclaration) { const body = (decl).body; From 4c847eb257434ac129a8a7b62bdb9a17a272028e Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 26 Aug 2016 15:04:08 -0700 Subject: [PATCH 279/508] Fixing errors and adding a fourslash test --- src/harness/fourslash.ts | 62 +++++++++++++------ src/services/services.ts | 11 +++- .../findReferencesDefinitionDisplayParts.ts | 23 +++++++ tests/cases/fourslash/fourslash.ts | 1 + 4 files changed, 75 insertions(+), 22 deletions(-) create mode 100644 tests/cases/fourslash/findReferencesDefinitionDisplayParts.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 63731417f48..694dcf6394e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -206,6 +206,24 @@ namespace FourSlash { private inputFiles = ts.createMap(); // Map between inputFile's fileName and its content for easily looking up when resolving references + private static getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[]) { + let result = ""; + ts.forEach(displayParts, part => { + if (result) { + result += ",\n "; + } + else { + result = "[\n "; + } + result += JSON.stringify(part); + }); + if (result) { + result += "\n]"; + } + + return result; + } + // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified private addMatchedInputFile(referenceFilePath: string, extensions: string[]) { @@ -777,6 +795,20 @@ namespace FourSlash { ts.forEachProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); } + public verifyDisplayPartsOfReferencedSymbol(expected: ts.SymbolDisplayPart[]) { + const referencedSymbols = this.findReferencesAtCaret(); + + if (referencedSymbols.length === 0) { + this.raiseError("No referenced symbols found at current caret position"); + } + else if (referencedSymbols.length > 1) { + this.raiseError("More than one referenced symbol found"); + } + + assert.equal(TestState.getDisplayPartsJson(referencedSymbols[0].definition.displayParts), + TestState.getDisplayPartsJson(expected), this.messageAtLastKnownMarker("referenced symbol definition display parts")); + } + private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) { for (let i = 0; i < references.length; i++) { const reference = references[i]; @@ -811,6 +843,10 @@ namespace FourSlash { return this.languageService.getReferencesAtPosition(this.activeFile.fileName, this.currentCaretPosition); } + private findReferencesAtCaret() { + return this.languageService.findReferences(this.activeFile.fileName, this.currentCaretPosition); + } + public getSyntacticDiagnostics(expected: string) { const diagnostics = this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); this.testDiagnostics(expected, diagnostics); @@ -856,30 +892,12 @@ namespace FourSlash { displayParts: ts.SymbolDisplayPart[], documentation: ts.SymbolDisplayPart[]) { - function getDisplayPartsJson(displayParts: ts.SymbolDisplayPart[]) { - let result = ""; - ts.forEach(displayParts, part => { - if (result) { - result += ",\n "; - } - else { - result = "[\n "; - } - result += JSON.stringify(part); - }); - if (result) { - result += "\n]"; - } - - return result; - } - const actualQuickInfo = this.languageService.getQuickInfoAtPosition(this.activeFile.fileName, this.currentCaretPosition); assert.equal(actualQuickInfo.kind, kind, this.messageAtLastKnownMarker("QuickInfo kind")); assert.equal(actualQuickInfo.kindModifiers, kindModifiers, this.messageAtLastKnownMarker("QuickInfo kindModifiers")); assert.equal(JSON.stringify(actualQuickInfo.textSpan), JSON.stringify(textSpan), this.messageAtLastKnownMarker("QuickInfo textSpan")); - assert.equal(getDisplayPartsJson(actualQuickInfo.displayParts), getDisplayPartsJson(displayParts), this.messageAtLastKnownMarker("QuickInfo displayParts")); - assert.equal(getDisplayPartsJson(actualQuickInfo.documentation), getDisplayPartsJson(documentation), this.messageAtLastKnownMarker("QuickInfo documentation")); + assert.equal(TestState.getDisplayPartsJson(actualQuickInfo.displayParts), TestState.getDisplayPartsJson(displayParts), this.messageAtLastKnownMarker("QuickInfo displayParts")); + assert.equal(TestState.getDisplayPartsJson(actualQuickInfo.documentation), TestState.getDisplayPartsJson(documentation), this.messageAtLastKnownMarker("QuickInfo documentation")); } public verifyRenameLocations(findInStrings: boolean, findInComments: boolean, ranges?: Range[]) { @@ -2947,6 +2965,10 @@ namespace FourSlashInterface { this.state.verifyRangesReferenceEachOther(ranges); } + public findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]) { + this.state.verifyDisplayPartsOfReferencedSymbol(expected); + } + public rangesWithSameTextReferenceEachOther() { this.state.verifyRangesWithSameTextReferenceEachOther(); } diff --git a/src/services/services.ts b/src/services/services.ts index 6da12696937..8794446e83e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6328,7 +6328,8 @@ namespace ts { fileName: targetLabel.getSourceFile().fileName, kind: ScriptElementKind.label, name: labelName, - textSpan: createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()) + textSpan: createTextSpanFromBounds(targetLabel.getStart(), targetLabel.getEnd()), + displayParts: [displayPart(labelName, SymbolDisplayPartKind.text)] }; return [{ definition, references }]; @@ -6568,6 +6569,11 @@ namespace ts { getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); } + const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); + + const { displayParts } = getSymbolDisplayPartsDocumentationAndSymbolKind( + thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword); + return [{ definition: { containerKind: "", @@ -6575,7 +6581,8 @@ namespace ts { fileName: node.getSourceFile().fileName, kind: ScriptElementKind.variableElement, name: "this", - textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()) + textSpan: createTextSpanFromBounds(node.getStart(), node.getEnd()), + displayParts }, references: references }]; diff --git a/tests/cases/fourslash/findReferencesDefinitionDisplayParts.ts b/tests/cases/fourslash/findReferencesDefinitionDisplayParts.ts new file mode 100644 index 00000000000..d424bd0c500 --- /dev/null +++ b/tests/cases/fourslash/findReferencesDefinitionDisplayParts.ts @@ -0,0 +1,23 @@ +/// + +//// class Gre/*1*/eter { +//// someFunction() { th/*2*/is; } +//// } +//// +//// type Options = "opt/*3*/ion 1" | "option 2"; +//// let myOption: Options = "option 1"; +//// +//// some/*4*/Label: +//// break someLabel; + +goTo.marker("1"); +verify.findReferencesDefinitionDisplayPartsAtCaretAre([{ text: "class", kind: "keyword" }, { text: " ", kind: "space" }, { text: "Greeter", kind: "className" }]); + +goTo.marker("2"); +verify.findReferencesDefinitionDisplayPartsAtCaretAre([{ text: "this", kind: "keyword" }, { text: ":", kind: "punctuation" }, { text: " ", kind: "space" }, { text: "this", kind: "keyword" }]); + +goTo.marker("3"); +verify.findReferencesDefinitionDisplayPartsAtCaretAre([{ text: "\"option 1\"", kind: "stringLiteral" }]); + +goTo.marker("4"); +verify.findReferencesDefinitionDisplayPartsAtCaretAre([{ text: "someLabel", kind: "text" }]); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 9ce3197a46f..59037e0de67 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -171,6 +171,7 @@ declare namespace FourSlashInterface { * If `ranges` is omitted, this is `test.ranges()`. */ rangesReferenceEachOther(ranges?: Range[]): void; + findReferencesDefinitionDisplayPartsAtCaretAre(expected: ts.SymbolDisplayPart[]): void; rangesWithSameTextReferenceEachOther(): void; currentParameterHelpArgumentNameIs(name: string): void; currentParameterSpanIs(parameter: string): void; From a370908421c4aea1cd8bdb7cf2f617da87f6029d Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 26 Aug 2016 15:51:10 -0700 Subject: [PATCH 280/508] [Transforms] Merge master 08/09 (#10263) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Improve error message * Remove `SupportedExpressionWithTypeArguments` type; just check that the expression of each `ExpressionWithTypeArguments` is an `EntityNameExpression`. * Fix bug * Fix #10083 - allowSyntheticDefaultImports alters getExternalModuleMember (#10096) * Use recursion, and fix error for undefined node * Rename function * Fix lint error * Narrowing type parameter intersects w/narrowed types This makes sure that a union type that includes a type parameter is still usable as the actual type that the type guard narrows to. * Don't allow ".d.ts" extension in an import either. * Add a helper function `getOrUpdateProperty` to prevent unprotected access to Maps. * Limit type guards as assertions to incomplete types in loops * Accept new baselines * Fix linting error * Allow JS multiple declarations of ctor properties When a property is declared in the constructor and on the prototype of an ES6 class, the property's symbol is discarded in favour of the method's symbol. That because the usual use for this pattern is to bind an instance function: `this.m = this.m.bind(this)`. In this case the type you want really is the method's type. * Use {} type facts for unconstrained type params Previously it was using TypeFacts.All. But the constraint of an unconstrained type parameter is actually {}. * Fix newline lint * Test that declares conflicting method first * [Release-2.0] Fix 9662: Visual Studio 2015 with TS2.0 gives incorrect @types path resolution errors (#9867) * Change the shape of the shim layer to support getAutomaticTypeDirectives * Change the key for looking up automatic type-directives * Update baselines from change look-up name of type-directives * Add @currentDirectory into the test * Update baselines * Fix linting error * Address PR: fix spelling mistake * Instead of return path of the type directive names just return type directive names * Remove unused reference files: these tests produce erros so they will not produce these files (#9233) * Add string-literal completion test for jsdoc * Support other (new) literal types in jsdoc * Don't allow properties inherited from Object to be automatically included in TSX attributes * Add new test baseline and delete else in binder The extra `else` caused a ton of test failures! * Fix lint * Port PR #10016 to Master (#10100) * Treat namespaceExportDeclaration as declaration * Update baselines * wip - add tests * Add tests * Show "export namespace" for quick-info * Fix more lint * Try using runtests-parallel for CI (#9970) * Try using runtests-parallel for CI * Put worker count setting into .travis.yml * Reduce worker count to 4 - 8 wasnt much different from 4-6 but had contention issues causing timeouts * Fix lssl task (#9967) * Surface noErrorTruncation option * Stricter check for discriminant properties in type guards * Add tests * Emit more efficient/concise "empty" ES6 ctor When there are property assignments in a the class body of an inheriting class, tsc current emit the following compilation: ```ts class Foo extends Bar { public foo = 1; } ``` ```js class Foo extends Bar { constructor(…args) { super(…args); this.foo = 1; } } ``` This introduces an unneeded local variable and might force a reification of the `arguments` object (or otherwise reify the arguments into an array). This is particularly bad when that output is fed into another transpiler like Babel. In Babel, you get something like this today: ```js var Foo = (function (_Bar) { _inherits(Foo, _Bar); function Foo() { _classCallCheck(this, Foo); for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _Bar.call.apply(_Bar, [this].concat(args)); this.foo = 1; } return Foo; })(Bar); ``` This causes a lot of needless work/allocations and some very strange code (`.call.apply` o_0). Admittedly, this is not strictly tsc’s problem; it could have done a deeper analysis of the code and optimized out the extra dance. However, tsc could also have emitted this simpler, more concise and semantically equivalent code in the first place: ```js class Foo extends Bar { constructor() { super(…arguments); this.foo = 1; } } ``` Which compiles into the following in Babel: ```js var Foo = (function (_Bar) { _inherits(Foo, _Bar); function Foo() { _classCallCheck(this, Foo); _Bar.apply(this, arguments); this.foo = 1; } return Foo; })(Bar); ``` Which is well-optimized (today) in most engines and much less confusing to read. As far as I can tell, the proposed compilation has exactly the same semantics as before. Fixes #10175 * Fix instanceof operator narrowing issues * Accept new baselines * Add regression test * Improve naming and documentation from PR * Update comment * Add more tests * Accept new baselines * Reduce worker count to 3 (#10210) Since we saw a starvation issue on one of @sandersn's PRs. * Speed up fourslash tests * Duh * Make baselines faster by not writing out unneeded files * Fix non-strict-compliant test * Fix 10076: Fix Tuple Destructing with "this" (#10208) * Call checkExpression eventhough there is no appropriate type from destructuring of array * Add tests and baselines * use transpileModule * Remove use strict * Improve instanceof for structurally identical types * Introduce isTypeInstanceOf function * Add test * Accept new baselines * Fix loop over array to use for-of instead of for-in * Use correct this in tuple type parameter constraints Instantiate this in tuple types used as type parameter constraints * Add explanatory comment to resolveTupleTypeMembers * Ignore null, undefined, void when checking for discriminant property * Add regression test * Delay tuple type constraint resolution Create a new tuple that stores the this-type. * Always use thisType when generating tuple id * Optimize format of type list id strings used in maps * wip - fix error * Make ReadonlyArray iterable. * Allow OSX to fail while we investigate (#10255) The random test timeouts are an issue. * Fix error from using merging master * avoid using the global name * Fix single-quote lint * Update baselines * Fix linting * Optimize performance of maps * Update API sample * Fix processDiagnosticMessages script * Have travis take shallow clones of the repo (#10275) Just cloning TS on travis takes 23 seconds on linux (68 seconds on mac), hopefully having it do a shallow clone will help. We don't rely on any tagging/artifacts from the travis servers which clone depth could impact, so this shouldn't impact anything other than build speed. * Add folds to travis log (#10269) * Optimize filterType to only call getUnionType if necessary * Add shorthand types declaration for travis-fold (#10293) * Optimize getTypeWithFacts * Filter out nullable and primitive types in isDiscriminantProperty * Fix typo * Add regression tests * Optimize core filter function to only allocate when necessary * Address CR comments + more optimizations * Faster path for creating union types from filterType * Allow an @types direcotry to have a package.json which specifies `"typings": null` to disclude it from automatically included typings. * Lint * Collect timing information for commands running on travis (#10308) * Simplifies performance API * Use 'MapLike' instead of 'Map' in 'preferConstRule.ts'. * narrow from 'any' in most situations instanceof and user-defined typeguards narrow from 'any' unless the narrowed-to type is exactly 'Object' or 'Function'. This is a breaking change. * Update instanceof conformance tests * accept new baselines * add tests * accept new baselines * Use lowercase names for type reference directives * Use proper response codes in web tests * Treat ambient shorthand declarations as explicit uses of the `any` type * Rename 'find' functions * Parallel linting (#10313) * A perilous thing, a parallel lint * Use work queue rather than scheduling work * Dont read files for lint on main thread * Fix style * Fix the style fix (#10344) * Aligned mark names with values used by ts-perf. * Use an enum in checkClassForDuplicateDeclarations to aid readability * Rename to Accessor * Migrated more MapLikes to Maps * Add ES2015 Date constructor signature that accepts another Date (#10353) * Parameters with no assignments implicitly considered const * Add tests * Migrate additional MapLikes to Maps. * Fix 10625: JSX Not validating when index signature is present (#10352) * Check for type of property declaration before using index signature * Add tests and baselines * fix linting error * Adding more comments * Clean up/move some Map helper functions. * Revert some formatting changes. * Improve ReadonlyArray.concat to match Array The Array-based signature was incorrect and also out-of-date. * Fix link to blog * Remove old assertion about when we're allowed to use fileExists * Set isNewIdentifierLocation to true for JavaScript files * Update error message for conflicting type definitions Fixes #10370 * Explain why we lower-case type reference directives * Correctly merge bindThisPropertyAssignment Also simply it considerably after noticing that it's *only* called for Javascript files, so there was a lot of dead code for TS cases that never happened. * Fix comment * Property handle imcomplete control flow types in nested loops * Update due to CR suggestion * Add regression test * Assign and instantiate contextual this type if not present * Fix 10289: correctly generate tsconfig.json with --lib (#10355) * Separate generate tsconfig into its own function and implement init with --lib # Conflicts: # src/compiler/tsc.ts * Add tests and baselines; Update function name Add unittests and baselines Add unittests and baselines for generating tsconfig Move unittest into harness folder Update harness tsconfig.json USe correct function name * Use new MapLike interstead. Update unittest # Conflicts: # src/compiler/commandLineParser.ts * Update JakeFile * Add tests for incorrect cases * Address PR : remove explicity write node_modules * JSDoc supports null, undefined and never types * Update baselines in jsDocParsing unit tests * Restored comments to explain spreading 'arguments' into calls to 'super'. * Added test. * Use the non-nullable type of the contextual type for object completions. * Return non-JsDocComment children ... to make syntactic classification work * Add more tests for `export = foo.bar`. * Output test baselines to tests/baselines/local instead of root * Move supportedTypescriptExtensionsWithDtsFirst next to supportedTypeScriptExtensions and rename * Fix comment * Fix RWC Runner (#10420) * Use /// void = (() => {}), error: (e: any, status: number) => void = (() => {})) { +function exec(cmd: string, args: string[], complete: () => void = (() => { }), error: (e: any, status: number) => void = (() => { })) { console.log(`${cmd} ${args.join(" ")}`); // TODO (weswig): Update child_process types to add windowsVerbatimArguments to the type definition const subshellFlag = isWin ? "/c" : "-c"; @@ -116,12 +116,12 @@ const es2015LibrarySources = [ ]; const es2015LibrarySourceMap = es2015LibrarySources.map(function(source) { - return { target: "lib." + source, sources: ["header.d.ts", source] }; + return { target: "lib." + source, sources: ["header.d.ts", source] }; }); -const es2016LibrarySource = [ "es2016.array.include.d.ts" ]; +const es2016LibrarySource = ["es2016.array.include.d.ts"]; -const es2016LibrarySourceMap = es2016LibrarySource.map(function (source) { +const es2016LibrarySourceMap = es2016LibrarySource.map(function(source) { return { target: "lib." + source, sources: ["header.d.ts", source] }; }); @@ -130,38 +130,38 @@ const es2017LibrarySource = [ "es2017.sharedmemory.d.ts" ]; -const es2017LibrarySourceMap = es2017LibrarySource.map(function (source) { +const es2017LibrarySourceMap = es2017LibrarySource.map(function(source) { return { target: "lib." + source, sources: ["header.d.ts", source] }; }); const hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"]; const librarySourceMap = [ - // Host library - { target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] }, - { target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] }, - { target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] }, - { target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] }, + // Host library + { target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] }, + { target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] }, + { target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] }, + { target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] }, - // JavaScript library - { target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] }, - { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, - { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, - { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, + // JavaScript library + { target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] }, + { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, + { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, + { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, - // JavaScript + all host library - { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, - { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } + // JavaScript + all host library + { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, + { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } ].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap); -const libraryTargets = librarySourceMap.map(function (f) { +const libraryTargets = librarySourceMap.map(function(f) { return path.join(builtLocalDirectory, f.target); }); for (const i in libraryTargets) { const entry = librarySourceMap[i]; const target = libraryTargets[i]; - const sources = [copyright].concat(entry.sources.map(function (s) { + const sources = [copyright].concat(entry.sources.map(function(s) { return path.join(libraryDirectory, s); })); gulp.task(target, false, [], function() { @@ -391,7 +391,7 @@ gulp.task(servicesFile, false, ["lib", "generate-diagnostics"], () => { .pipe(sourcemaps.init()) .pipe(tsc(servicesProject)); const completedJs = js.pipe(prependCopyright()) - .pipe(sourcemaps.write(".")); + .pipe(sourcemaps.write(".")); const completedDts = dts.pipe(prependCopyright(/*outputCopyright*/true)) .pipe(insert.transform((contents, file) => { file.path = standaloneDefinitionsFile; @@ -434,22 +434,22 @@ const tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverli gulp.task(tsserverLibraryFile, false, [servicesFile], (done) => { const serverLibraryProject = tsc.createProject("src/server/tsconfig.library.json", getCompilerSettings({}, /*useBuiltCompiler*/ true)); - const {js, dts}: {js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream} = serverLibraryProject.src() + const {js, dts}: { js: NodeJS.ReadableStream, dts: NodeJS.ReadableStream } = serverLibraryProject.src() .pipe(sourcemaps.init()) .pipe(newer(tsserverLibraryFile)) .pipe(tsc(serverLibraryProject)); return merge2([ js.pipe(prependCopyright()) - .pipe(sourcemaps.write(".")) - .pipe(gulp.dest(builtLocalDirectory)), + .pipe(sourcemaps.write(".")) + .pipe(gulp.dest(builtLocalDirectory)), dts.pipe(prependCopyright()) - .pipe(gulp.dest(builtLocalDirectory)) + .pipe(gulp.dest(builtLocalDirectory)) ]); }); gulp.task("lssl", "Builds language service server library", [tsserverLibraryFile]); -gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON]); +gulp.task("local", "Builds the full compiler and services", [builtLocalCompiler, servicesFile, serverFile, builtGeneratedDiagnosticMessagesJSON, tsserverLibraryFile]); gulp.task("tsc", "Builds only the compiler", [builtLocalCompiler]); @@ -476,7 +476,7 @@ gulp.task(specMd, false, [word2mdJs], (done) => { const specMDFullPath = path.resolve(specMd); const cmd = "cscript //nologo " + word2mdJs + " \"" + specWordFullPath + "\" " + "\"" + specMDFullPath + "\""; console.log(cmd); - cp.exec(cmd, function () { + cp.exec(cmd, function() { done(); }); }); @@ -492,18 +492,18 @@ gulp.task("dontUseDebugMode", false, [], (done) => { useDebugMode = false; done( gulp.task("VerifyLKG", false, [], () => { const expectedFiles = [builtLocalCompiler, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets); - const missingFiles = expectedFiles.filter(function (f) { + const missingFiles = expectedFiles.filter(function(f) { return !fs.existsSync(f); }); if (missingFiles.length > 0) { throw new Error("Cannot replace the LKG unless all built targets are present in directory " + builtLocalDirectory + - ". The following files are missing:\n" + missingFiles.join("\n")); + ". The following files are missing:\n" + missingFiles.join("\n")); } // Copy all the targets into the LKG directory return gulp.src(expectedFiles).pipe(gulp.dest(LKGDirectory)); }); -gulp.task("LKGInternal", false, ["lib", "local", "lssl"]); +gulp.task("LKGInternal", false, ["lib", "local"]); gulp.task("LKG", "Makes a new LKG out of the built js files", ["clean", "dontUseDebugMode"], () => { return runSequence("LKGInternal", "VerifyLKG"); @@ -531,8 +531,6 @@ const localRwcBaseline = path.join(internalTests, "baselines/rwc/local"); const refRwcBaseline = path.join(internalTests, "baselines/rwc/reference"); const localTest262Baseline = path.join(internalTests, "baselines/test262/local"); -const refTest262Baseline = path.join(internalTests, "baselines/test262/reference"); - gulp.task("tests", "Builds the test infrastructure using the built compiler", [run]); gulp.task("tests-debug", "Builds the test sources and automation in debug mode", () => { @@ -553,7 +551,7 @@ function restoreSavedNodeEnv() { process.env.NODE_ENV = savedNodeEnv; } -let testTimeout = 20000; +let testTimeout = 40000; function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: (e?: any) => void) { const lintFlag = cmdLineOptions["lint"]; cleanTestDirs((err) => { @@ -627,7 +625,7 @@ function runConsoleTests(defaultReporter: string, runInParallel: boolean, done: } args.push(run); setNodeEnvToDevelopment(); - runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) { + runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function(err) { // last worker clean everything and runs linter in case if there were no errors del(taskConfigsFolder).then(() => { if (!err) { @@ -679,7 +677,7 @@ gulp.task("runtests", ["build-rules", "tests"], (done) => { runConsoleTests("mocha-fivemat-progress-reporter", /*runInParallel*/ false, done); -}); + }); const nodeServerOutFile = "tests/webTestServer.js"; const nodeServerInFile = "tests/webTestServer.ts"; @@ -811,32 +809,36 @@ gulp.task("diff-rwc", "Diffs the RWC baselines using the diff tool specified by exec(getDiffTool(), [refRwcBaseline, localRwcBaseline], done, done); }); +gulp.task("baseline-accept", "Makes the most recent test results the new baseline, overwriting the old baseline", () => { + return baselineAccept(""); +}); + +function baselineAccept(subfolder = "") { + return merge2(baselineCopy(subfolder), baselineDelete(subfolder)); +} + +function baselineCopy(subfolder = "") { + return gulp.src([`tests/baselines/local/${subfolder}/**`, `!tests/baselines/local/${subfolder}/**/*.delete`]) + .pipe(gulp.dest(refBaseline)); +} + +function baselineDelete(subfolder = "") { + return gulp.src(["tests/baselines/local/**/*.delete"]) + .pipe(insert.transform((content, fileObj) => { + const target = path.join(refBaseline, fileObj.relative.substr(0, fileObj.relative.length - ".delete".length)); + del.sync(target); + del.sync(fileObj.path); + return ""; + })); +} -gulp.task("baseline-accept", "Makes the most recent test results the new baseline, overwriting the old baseline", (done) => { - const softAccept = cmdLineOptions["soft"]; - if (!softAccept) { - del(refBaseline).then(() => { - fs.renameSync(localBaseline, refBaseline); - done(); - }, done); - } - else { - gulp.src(localBaseline) - .pipe(gulp.dest(refBaseline)) - .on("end", () => { - del(path.join(refBaseline, "local")).then(() => done(), done); - }); - } -}); gulp.task("baseline-accept-rwc", "Makes the most recent rwc test results the new baseline, overwriting the old baseline", () => { - return del(refRwcBaseline).then(() => { - fs.renameSync(localRwcBaseline, refRwcBaseline); - }); + return baselineAccept("rwc"); }); + + gulp.task("baseline-accept-test262", "Makes the most recent test262 test results the new baseline, overwriting the old baseline", () => { - return del(refTest262Baseline).then(() => { - fs.renameSync(localTest262Baseline, refTest262Baseline); - }); + return baselineAccept("test262"); }); @@ -928,26 +930,6 @@ gulp.task("build-rules", "Compiles tslint rules to js", () => { .pipe(gulp.dest(dest)); }); -function getLinterOptions() { - return { - configuration: require("./tslint.json"), - formatter: "prose", - formattersDirectory: undefined, - rulesDirectory: "built/local/tslint" - }; -} - -function lintFileContents(options, path, contents) { - const ll = new Linter(path, contents, options); - console.log("Linting '" + path + "'."); - return ll.lint(); -} - -function lintFile(options, path) { - const contents = fs.readFileSync(path, "utf8"); - return lintFileContents(options, path, contents); -} - const lintTargets = [ "Gulpfile.ts", "src/compiler/**/*.ts", @@ -959,27 +941,72 @@ const lintTargets = [ "tests/*.ts", "tests/webhost/*.ts" // Note: does *not* descend recursively ]; +function sendNextFile(files: {path: string}[], child: cp.ChildProcess, callback: (failures: number) => void, failures: number) { + const file = files.pop(); + if (file) { + console.log(`Linting '${file.path}'.`); + child.send({ kind: "file", name: file.path }); + } + else { + child.send({ kind: "close" }); + callback(failures); + } +} + +function spawnLintWorker(files: {path: string}[], callback: (failures: number) => void) { + const child = cp.fork("./scripts/parallel-lint"); + let failures = 0; + child.on("message", function(data) { + switch (data.kind) { + case "result": + if (data.failures > 0) { + failures += data.failures; + console.log(data.output); + } + sendNextFile(files, child, callback, failures); + break; + case "error": + console.error(data.error); + failures++; + sendNextFile(files, child, callback, failures); + break; + } + }); + sendNextFile(files, child, callback, failures); +} gulp.task("lint", "Runs tslint on the compiler sources. Optional arguments are: --f[iles]=regex", ["build-rules"], () => { const fileMatcher = RegExp(cmdLineOptions["files"]); - const lintOptions = getLinterOptions(); - let failed = 0; - return gulp.src(lintTargets) - .pipe(insert.transform((contents, file) => { - if (!fileMatcher.test(file.path)) return contents; - const result = lintFile(lintOptions, file.path); - if (result.failureCount > 0) { - console.log(result.output); - failed += result.failureCount; + if (fold.isTravis()) console.log(fold.start("lint")); + + let files: {stat: fs.Stats, path: string}[] = []; + return gulp.src(lintTargets, { read: false }) + .pipe(through2.obj((chunk, enc, cb) => { + files.push(chunk); + cb(); + }, (cb) => { + files = files.filter(file => fileMatcher.test(file.path)).sort((filea, fileb) => filea.stat.size - fileb.stat.size); + const workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; + for (let i = 0; i < workerCount; i++) { + spawnLintWorker(files, finished); } - return contents; // TODO (weswig): Automatically apply fixes? :3 - })) - .on("end", () => { - if (failed > 0) { - console.error("Linter errors."); - process.exit(1); + + let completed = 0; + let failures = 0; + function finished(fails) { + completed++; + failures += fails; + if (completed === workerCount) { + if (fold.isTravis()) console.log(fold.end("lint")); + if (failures > 0) { + throw new Error(`Linter errors: ${failures}`); + } + else { + cb(); + } + } } - }); + })); }); diff --git a/Jakefile.js b/Jakefile.js index 3047d792af2..fe8ba4742fe 100644 --- a/Jakefile.js +++ b/Jakefile.js @@ -4,7 +4,7 @@ var fs = require("fs"); var os = require("os"); var path = require("path"); var child_process = require("child_process"); -var Linter = require("tslint"); +var fold = require("travis-fold"); var runTestsInParallel = require("./scripts/mocha-parallel").runTestsInParallel; // Variables @@ -27,9 +27,31 @@ var thirdParty = "ThirdPartyNoticeText.txt"; // add node_modules to path so we don't need global modules, prefer the modules by adding them first var nodeModulesPathPrefix = path.resolve("./node_modules/.bin/") + path.delimiter; if (process.env.path !== undefined) { - process.env.path = nodeModulesPathPrefix + process.env.path; + process.env.path = nodeModulesPathPrefix + process.env.path; } else if (process.env.PATH !== undefined) { - process.env.PATH = nodeModulesPathPrefix + process.env.PATH; + process.env.PATH = nodeModulesPathPrefix + process.env.PATH; +} + +function toNs(diff) { + return diff[0] * 1e9 + diff[1]; +} + +function mark() { + if (!fold.isTravis()) return; + var stamp = process.hrtime(); + var id = Math.floor(Math.random() * 0xFFFFFFFF).toString(16); + console.log("travis_time:start:" + id + "\r"); + return { + stamp: stamp, + id: id + }; +} + +function measure(marker) { + if (!fold.isTravis()) return; + var diff = process.hrtime(marker.stamp); + var total = [marker.stamp[0] + diff[0], marker.stamp[1] + diff[1]]; + console.log("travis_time:end:" + marker.id + ":start=" + toNs(marker.stamp) + ",finish=" + toNs(total) + ",duration=" + toNs(diff) + "\r"); } var compilerSources = [ @@ -184,7 +206,8 @@ var harnessSources = harnessCoreSources.concat([ "convertCompilerOptionsFromJson.ts", "convertTypingOptionsFromJson.ts", "tsserverProjectSystem.ts", - "matchFiles.ts" + "matchFiles.ts", + "initializeTSConfig.ts", ].map(function (f) { return path.join(unittestsDirectory, f); })).concat([ @@ -208,11 +231,11 @@ var es2015LibrarySources = [ "es2015.symbol.wellknown.d.ts" ]; -var es2015LibrarySourceMap = es2015LibrarySources.map(function(source) { - return { target: "lib." + source, sources: ["header.d.ts", source] }; +var es2015LibrarySourceMap = es2015LibrarySources.map(function (source) { + return { target: "lib." + source, sources: ["header.d.ts", source] }; }); -var es2016LibrarySource = [ "es2016.array.include.d.ts" ]; +var es2016LibrarySource = ["es2016.array.include.d.ts"]; var es2016LibrarySourceMap = es2016LibrarySource.map(function (source) { return { target: "lib." + source, sources: ["header.d.ts", source] }; @@ -230,21 +253,21 @@ var es2017LibrarySourceMap = es2017LibrarySource.map(function (source) { var hostsLibrarySources = ["dom.generated.d.ts", "webworker.importscripts.d.ts", "scripthost.d.ts"]; var librarySourceMap = [ - // Host library - { target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] }, - { target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] }, - { target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] }, - { target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] }, + // Host library + { target: "lib.dom.d.ts", sources: ["header.d.ts", "dom.generated.d.ts"] }, + { target: "lib.dom.iterable.d.ts", sources: ["header.d.ts", "dom.iterable.d.ts"] }, + { target: "lib.webworker.d.ts", sources: ["header.d.ts", "webworker.generated.d.ts"] }, + { target: "lib.scripthost.d.ts", sources: ["header.d.ts", "scripthost.d.ts"] }, - // JavaScript library - { target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] }, - { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, - { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, - { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, + // JavaScript library + { target: "lib.es5.d.ts", sources: ["header.d.ts", "es5.d.ts"] }, + { target: "lib.es2015.d.ts", sources: ["header.d.ts", "es2015.d.ts"] }, + { target: "lib.es2016.d.ts", sources: ["header.d.ts", "es2016.d.ts"] }, + { target: "lib.es2017.d.ts", sources: ["header.d.ts", "es2017.d.ts"] }, - // JavaScript + all host library - { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, - { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } + // JavaScript + all host library + { target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources) }, + { target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources, "dom.iterable.d.ts") } ].concat(es2015LibrarySourceMap, es2016LibrarySourceMap, es2017LibrarySourceMap); var libraryTargets = librarySourceMap.map(function (f) { @@ -260,7 +283,7 @@ function prependFile(prefixFile, destinationFile) { fail(destinationFile + " failed to be created!"); } var temp = "temptemp"; - jake.cpR(prefixFile, temp, {silent: true}); + jake.cpR(prefixFile, temp, { silent: true }); fs.appendFileSync(temp, fs.readFileSync(destinationFile)); fs.renameSync(temp, destinationFile); } @@ -272,11 +295,11 @@ function concatenateFiles(destinationFile, sourceFiles) { if (!fs.existsSync(sourceFiles[0])) { fail(sourceFiles[0] + " does not exist!"); } - jake.cpR(sourceFiles[0], temp, {silent: true}); + jake.cpR(sourceFiles[0], temp, { silent: true }); // append all files in sequence for (var i = 1; i < sourceFiles.length; i++) { if (!fs.existsSync(sourceFiles[i])) { - fail(sourceFiles[i] + " does not exist!"); + fail(sourceFiles[i] + " does not exist!"); } fs.appendFileSync(temp, fs.readFileSync(sourceFiles[i])); } @@ -314,9 +337,10 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts if (process.env.USE_TRANSFORMS === "false") { useBuiltCompiler = false; } + var startCompileTime = mark(); opts = opts || {}; var compilerPath = useBuiltCompiler ? builtLocalCompiler : LKGCompiler; - var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types " + var options = "--noImplicitAny --noImplicitThis --noEmitOnError --types " if (opts.types) { options += opts.types.join(","); } @@ -346,7 +370,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts options += " --module commonjs"; } - if(opts.noResolve) { + if (opts.noResolve) { options += " --noResolve"; } @@ -373,13 +397,13 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts var ex = jake.createExec([cmd]); // Add listeners for output and error - ex.addListener("stdout", function(output) { + ex.addListener("stdout", function (output) { process.stdout.write(output); }); - ex.addListener("stderr", function(error) { + ex.addListener("stderr", function (error) { process.stderr.write(error); }); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { if (!useDebugMode && prefixes && fs.existsSync(outFile)) { for (var i in prefixes) { prependFile(prefixes[i], outFile); @@ -390,14 +414,16 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, opts callback(); } + measure(startCompileTime); complete(); }); - ex.addListener("error", function() { + ex.addListener("error", function () { fs.unlinkSync(outFile); fail("Compilation of " + outFile + " unsuccessful"); + measure(startCompileTime); }); ex.run(); - }, {async: true}); + }, { async: true }); } // Prerequisite task for built directory and library typings @@ -410,7 +436,7 @@ for (var i in libraryTargets) { var sources = [copyright].concat(entry.sources.map(function (s) { return path.join(libraryDirectory, s); })); - file(target, [builtLocalDirectory].concat(sources), function() { + file(target, [builtLocalDirectory].concat(sources), function () { concatenateFiles(target, sources); }); })(i); @@ -433,30 +459,30 @@ file(processDiagnosticMessagesTs); // processDiagnosticMessages script compileFile(processDiagnosticMessagesJs, - [processDiagnosticMessagesTs], - [processDiagnosticMessagesTs], - [], + [processDiagnosticMessagesTs], + [processDiagnosticMessagesTs], + [], /*useBuiltCompiler*/ false); // The generated diagnostics map; built for the compiler and for the 'generate-diagnostics' task file(diagnosticInfoMapTs, [processDiagnosticMessagesJs, diagnosticMessagesJson], function () { - var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; + var cmd = host + " " + processDiagnosticMessagesJs + " " + diagnosticMessagesJson; console.log(cmd); var ex = jake.createExec([cmd]); // Add listeners for output and error - ex.addListener("stdout", function(output) { + ex.addListener("stdout", function (output) { process.stdout.write(output); }); - ex.addListener("stderr", function(error) { + ex.addListener("stderr", function (error) { process.stderr.write(error); }); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { complete(); }); ex.run(); -}, {async: true}); +}, { async: true }); -file(builtGeneratedDiagnosticMessagesJSON,[generatedDiagnosticMessagesJSON], function() { +file(builtGeneratedDiagnosticMessagesJSON, [generatedDiagnosticMessagesJSON], function () { if (fs.existsSync(builtLocalDirectory)) { jake.cpR(generatedDiagnosticMessagesJSON, builtGeneratedDiagnosticMessagesJSON); } @@ -474,17 +500,17 @@ var programTs = path.join(compilerDirectory, "program.ts"); file(configureNightlyTs); compileFile(/*outfile*/configureNightlyJs, - /*sources*/ [configureNightlyTs], - /*prereqs*/ [configureNightlyTs], - /*prefixes*/ [], + /*sources*/[configureNightlyTs], + /*prereqs*/[configureNightlyTs], + /*prefixes*/[], /*useBuiltCompiler*/ false, - { noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false }); + { noOutFile: false, generateDeclarations: false, keepComments: false, noResolve: false, stripInternal: false }); -task("setDebugMode", function() { +task("setDebugMode", function () { useDebugMode = true; }); -task("configure-nightly", [configureNightlyJs], function() { +task("configure-nightly", [configureNightlyJs], function () { var cmd = host + " " + configureNightlyJs + " " + packageJson + " " + programTs; console.log(cmd); exec(cmd); @@ -525,63 +551,65 @@ var nodePackageFile = path.join(builtLocalDirectory, "typescript.js"); var nodeDefinitionsFile = path.join(builtLocalDirectory, "typescript.d.ts"); var nodeStandaloneDefinitionsFile = path.join(builtLocalDirectory, "typescript_standalone.d.ts"); -compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].concat(servicesSources), - /*prefixes*/ [copyright], +compileFile(servicesFile, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), + /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - /*opts*/ { noOutFile: false, - generateDeclarations: true, - preserveConstEnums: true, - keepComments: true, - noResolve: false, - stripInternal: true - }, + /*opts*/ { + noOutFile: false, + generateDeclarations: true, + preserveConstEnums: true, + keepComments: true, + noResolve: false, + stripInternal: true + }, /*callback*/ function () { - jake.cpR(servicesFile, nodePackageFile, {silent: true}); + jake.cpR(servicesFile, nodePackageFile, { silent: true }); - prependFile(copyright, standaloneDefinitionsFile); + prependFile(copyright, standaloneDefinitionsFile); - // Stanalone/web definition file using global 'ts' namespace - jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, {silent: true}); - var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); - definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4'); - fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents); + // Stanalone/web definition file using global 'ts' namespace + jake.cpR(standaloneDefinitionsFile, nodeDefinitionsFile, { silent: true }); + var definitionFileContents = fs.readFileSync(nodeDefinitionsFile).toString(); + definitionFileContents = definitionFileContents.replace(/^(\s*)(export )?const enum (\S+) {(\s*)$/gm, '$1$2enum $3 {$4'); + fs.writeFileSync(standaloneDefinitionsFile, definitionFileContents); - // Official node package definition file, pointed to by 'typings' in package.json - // Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module - var nodeDefinitionsFileContents = definitionFileContents + "\r\nexport = ts;"; - fs.writeFileSync(nodeDefinitionsFile, nodeDefinitionsFileContents); + // Official node package definition file, pointed to by 'typings' in package.json + // Created by appending 'export = ts;' at the end of the standalone file to turn it into an external module + var nodeDefinitionsFileContents = definitionFileContents + "\r\nexport = ts;"; + fs.writeFileSync(nodeDefinitionsFile, nodeDefinitionsFileContents); - // Node package definition file to be distributed without the package. Created by replacing - // 'ts' namespace with '"typescript"' as a module. - var nodeStandaloneDefinitionsFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); - fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents); - }); + // Node package definition file to be distributed without the package. Created by replacing + // 'ts' namespace with '"typescript"' as a module. + var nodeStandaloneDefinitionsFileContents = definitionFileContents.replace(/declare (namespace|module) ts/g, 'declare module "typescript"'); + fs.writeFileSync(nodeStandaloneDefinitionsFile, nodeStandaloneDefinitionsFileContents); + }); compileFile( servicesFileInBrowserTest, servicesSources, [builtLocalDirectory, copyright].concat(servicesSources), - /*prefixes*/ [copyright], + /*prefixes*/[copyright], /*useBuiltCompiler*/ true, - { noOutFile: false, - generateDeclarations: true, - preserveConstEnums: true, - keepComments: true, - noResolve: false, - stripInternal: true, - noMapRoot: true, - inlineSourceMap: true - }); + { + noOutFile: false, + generateDeclarations: true, + preserveConstEnums: true, + keepComments: true, + noResolve: false, + stripInternal: true, + noMapRoot: true, + inlineSourceMap: true + }); var serverFile = path.join(builtLocalDirectory, "tsserver.js"); -compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true, { types: ["node"] }); +compileFile(serverFile, serverSources, [builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/[copyright], /*useBuiltCompiler*/ true, { types: ["node"] }); var tsserverLibraryFile = path.join(builtLocalDirectory, "tsserverlibrary.js"); var tsserverLibraryDefinitionFile = path.join(builtLocalDirectory, "tsserverlibrary.d.ts"); compileFile( tsserverLibraryFile, languageServiceLibrarySources, - [builtLocalDirectory, copyright].concat(languageServiceLibrarySources), - /*prefixes*/ [copyright], + [builtLocalDirectory, copyright, builtLocalCompiler].concat(languageServiceLibrarySources).concat(libraryTargets), + /*prefixes*/[copyright], /*useBuiltCompiler*/ true, { noOutFile: false, generateDeclarations: true }); @@ -589,9 +617,19 @@ compileFile( desc("Builds language service server library"); task("lssl", [tsserverLibraryFile, tsserverLibraryDefinitionFile]); +desc("Emit the start of the build fold"); +task("build-fold-start", [], function () { + if (fold.isTravis()) console.log(fold.start("build")); +}); + +desc("Emit the end of the build fold"); +task("build-fold-end", [], function () { + if (fold.isTravis()) console.log(fold.end("build")); +}); + // Local target to build the compiler and services desc("Builds the full compiler and services"); -task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON]); +task("local", ["build-fold-start", "generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile, builtGeneratedDiagnosticMessagesJSON, "lssl", "build-fold-end"]); // Local target to build only tsc.js desc("Builds only the compiler"); @@ -599,7 +637,7 @@ task("tsc", ["generate-diagnostics", "lib", tscFile]); // Local target to build the compiler and services desc("Sets release mode flag"); -task("release", function() { +task("release", function () { useDebugMode = false; }); @@ -609,7 +647,7 @@ task("default", ["local"]); // Cleans the built directory desc("Cleans the compiler output, declare files, and tests"); -task("clean", function() { +task("clean", function () { jake.rmRf(builtDirectory); }); @@ -623,9 +661,9 @@ file(word2mdTs); // word2md script compileFile(word2mdJs, - [word2mdTs], - [word2mdTs], - [], + [word2mdTs], + [word2mdTs], + [], /*useBuiltCompiler*/ false); // The generated spec.md; built for the 'generate-spec' task @@ -637,7 +675,7 @@ file(specMd, [word2mdJs, specWord], function () { child_process.exec(cmd, function () { complete(); }); -}, {async: true}); +}, { async: true }); desc("Generates a Markdown version of the Language Specification"); @@ -646,14 +684,14 @@ task("generate-spec", [specMd]); // Makes a new LKG. This target does not build anything, but errors if not all the outputs are present in the built/local directory desc("Makes a new LKG out of the built js files"); -task("LKG", ["clean", "release", "local", "lssl"].concat(libraryTargets), function() { +task("LKG", ["clean", "release", "local"].concat(libraryTargets), function () { var expectedFiles = [tscFile, servicesFile, serverFile, nodePackageFile, nodeDefinitionsFile, standaloneDefinitionsFile, tsserverLibraryFile, tsserverLibraryDefinitionFile].concat(libraryTargets); var missingFiles = expectedFiles.filter(function (f) { return !fs.existsSync(f); }); if (missingFiles.length > 0) { fail("Cannot replace the LKG unless all built targets are present in directory " + builtLocalDirectory + - ". The following files are missing:\n" + missingFiles.join("\n")); + ". The following files are missing:\n" + missingFiles.join("\n")); } // Copy all the targets into the LKG directory jake.mkdirP(LKGDirectory); @@ -674,8 +712,8 @@ var run = path.join(builtLocalDirectory, "run.js"); compileFile( /*outFile*/ run, /*source*/ harnessSources, - /*prereqs*/ [builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources), - /*prefixes*/ [], + /*prereqs*/[builtLocalDirectory, tscFile].concat(libraryTargets).concat(servicesSources).concat(harnessSources), + /*prefixes*/[], /*useBuiltCompiler:*/ true, /*opts*/ { inlineSourceMap: true, types: ["node", "mocha", "chai"] }); @@ -694,22 +732,22 @@ desc("Builds the test infrastructure using the built compiler"); task("tests", ["local", run].concat(libraryTargets)); function exec(cmd, completeHandler, errorHandler) { - var ex = jake.createExec([cmd], {windowsVerbatimArguments: true}); + var ex = jake.createExec([cmd], { windowsVerbatimArguments: true }); // Add listeners for output and error - ex.addListener("stdout", function(output) { + ex.addListener("stdout", function (output) { process.stdout.write(output); }); - ex.addListener("stderr", function(error) { + ex.addListener("stderr", function (error) { process.stderr.write(error); }); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { if (completeHandler) { completeHandler(); } complete(); }); - ex.addListener("error", function(e, status) { - if(errorHandler) { + ex.addListener("error", function (e, status) { + if (errorHandler) { errorHandler(e, status); } else { fail("Process exited with code " + status); @@ -797,7 +835,8 @@ function runConsoleTests(defaultReporter, runInParallel) { // timeout normally isn't necessary but Travis-CI has been timing out on compiler baselines occasionally // default timeout is 2sec which really should be enough, but maybe we just need a small amount longer - if(!runInParallel) { + if (!runInParallel) { + var startTime = mark(); tests = tests ? ' -g "' + tests + '"' : ''; var cmd = "mocha" + (debug ? " --debug-brk" : "") + " -R " + reporter + tests + colors + bail + ' -t ' + testTimeout + ' ' + run; console.log(cmd); @@ -806,10 +845,12 @@ function runConsoleTests(defaultReporter, runInParallel) { process.env.NODE_ENV = "development"; exec(cmd, function () { process.env.NODE_ENV = savedNodeEnv; + measure(startTime); runLinter(); finish(); - }, function(e, status) { + }, function (e, status) { process.env.NODE_ENV = savedNodeEnv; + measure(startTime); finish(status); }); @@ -817,9 +858,10 @@ function runConsoleTests(defaultReporter, runInParallel) { else { var savedNodeEnv = process.env.NODE_ENV; process.env.NODE_ENV = "development"; + var startTime = mark(); runTestsInParallel(taskConfigsFolder, run, { testTimeout: testTimeout, noColors: colors === " --no-colors " }, function (err) { process.env.NODE_ENV = savedNodeEnv; - + measure(startTime); // last worker clean everything and runs linter in case if there were no errors deleteTemporaryProjectOutput(); jake.rmRf(taskConfigsFolder); @@ -860,14 +902,14 @@ function runConsoleTests(defaultReporter, runInParallel) { var testTimeout = 20000; desc("Runs all the tests in parallel using the built run.js file. Optional arguments are: t[ests]=category1|category2|... d[ebug]=true."); -task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function() { +task("runtests-parallel", ["build-rules", "tests", builtLocalDirectory], function () { runConsoleTests('min', /*runInParallel*/ true); -}, {async: true}); +}, { async: true }); desc("Runs the tests using the built run.js file. Optional arguments are: t[ests]=regex r[eporter]=[list|spec|json|] d[ebug]=true color[s]=false lint=true bail=false dirty=false."); task("runtests", ["build-rules", "tests", builtLocalDirectory], function() { runConsoleTests('mocha-fivemat-progress-reporter', /*runInParallel*/ false); -}, {async: true}); +}, { async: true }); desc("Generates code coverage data via instanbul"); task("generate-code-coverage", ["tests", builtLocalDirectory], function () { @@ -885,20 +927,20 @@ desc("Runs browserify on run.js to produce a file suitable for running tests in task("browserify", ["tests", builtLocalDirectory, nodeServerOutFile], function() { var cmd = 'browserify built/local/run.js -t ./scripts/browserify-optional -d -o built/local/bundle.js'; exec(cmd); -}, {async: true}); +}, { async: true }); desc("Runs the tests using the built run.js file like 'jake runtests'. Syntax is jake runtests-browser. Additional optional parameters tests=[regex], browser=[chrome|IE]"); -task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function() { +task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFileInBrowserTest], function () { cleanTestDirs(); host = "node"; browser = process.env.browser || process.env.b || "IE"; tests = process.env.test || process.env.tests || process.env.t; var light = process.env.light || false; var testConfigFile = 'test.config'; - if(fs.existsSync(testConfigFile)) { + if (fs.existsSync(testConfigFile)) { fs.unlinkSync(testConfigFile); } - if(tests || light) { + if (tests || light) { writeTestConfigFile(tests, light); } @@ -906,7 +948,7 @@ task("runtests-browser", ["tests", "browserify", builtLocalDirectory, servicesFi var cmd = host + " tests/webTestServer.js " + browser + " " + JSON.stringify(tests); console.log(cmd); exec(cmd); -}, {async: true}); +}, { async: true }); function getDiffTool() { var program = process.env['DIFF']; @@ -919,17 +961,17 @@ function getDiffTool() { // Baseline Diff desc("Diffs the compiler baselines using the diff tool specified by the 'DIFF' environment variable"); task('diff', function () { - var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline; + var cmd = '"' + getDiffTool() + '" ' + refBaseline + ' ' + localBaseline; console.log(cmd); exec(cmd); -}, {async: true}); +}, { async: true }); desc("Diffs the RWC baselines using the diff tool specified by the 'DIFF' environment variable"); task('diff-rwc', function () { - var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline; + var cmd = '"' + getDiffTool() + '" ' + refRwcBaseline + ' ' + localRwcBaseline; console.log(cmd); exec(cmd); -}, {async: true}); +}, { async: true }); desc("Builds the test sources and automation in debug mode"); task("tests-debug", ["setDebugMode", "tests"]); @@ -937,30 +979,39 @@ task("tests-debug", ["setDebugMode", "tests"]); // Makes the test results the new baseline desc("Makes the most recent test results the new baseline, overwriting the old baseline"); -task("baseline-accept", function(hardOrSoft) { - if (!hardOrSoft || hardOrSoft === "hard") { - jake.rmRf(refBaseline); - fs.renameSync(localBaseline, refBaseline); - } - else if (hardOrSoft === "soft") { - var files = jake.readdirR(localBaseline); - for (var i in files) { - jake.cpR(files[i], refBaseline); - } - jake.rmRf(path.join(refBaseline, "local")); - } +task("baseline-accept", function () { + acceptBaseline(""); }); +function acceptBaseline(containerFolder) { + var sourceFolder = path.join(localBaseline, containerFolder); + var targetFolder = path.join(refBaseline, containerFolder); + console.log('Accept baselines from ' + sourceFolder + ' to ' + targetFolder); + var files = fs.readdirSync(sourceFolder); + var deleteEnding = '.delete'; + for (var i in files) { + var filename = files[i]; + if (filename.substr(filename.length - deleteEnding.length) === deleteEnding) { + filename = filename.substr(0, filename.length - deleteEnding.length); + fs.unlinkSync(path.join(targetFolder, filename)); + } else { + var target = path.join(targetFolder, filename); + if (fs.existsSync(target)) { + fs.unlinkSync(target); + } + fs.renameSync(path.join(sourceFolder, filename), target); + } + } +} + desc("Makes the most recent rwc test results the new baseline, overwriting the old baseline"); -task("baseline-accept-rwc", function() { - jake.rmRf(refRwcBaseline); - fs.renameSync(localRwcBaseline, refRwcBaseline); +task("baseline-accept-rwc", function () { + acceptBaseline("rwc"); }); desc("Makes the most recent test262 test results the new baseline, overwriting the old baseline"); -task("baseline-accept-test262", function() { - jake.rmRf(refTest262Baseline); - fs.renameSync(localTest262Baseline, refTest262Baseline); +task("baseline-accept-test262", function () { + acceptBaseline("test262"); }); @@ -970,8 +1021,8 @@ var webhostJsPath = "tests/webhost/webtsc.js"; compileFile(webhostJsPath, [webhostPath], [tscFile, webhostPath].concat(libraryTargets), [], /*useBuiltCompiler*/true); desc("Builds the tsc web host"); -task("webhost", [webhostJsPath], function() { - jake.cpR(path.join(builtLocalDirectory, "lib.d.ts"), "tests/webhost/", {silent: true}); +task("webhost", [webhostJsPath], function () { + jake.cpR(path.join(builtLocalDirectory, "lib.d.ts"), "tests/webhost/", { silent: true }); }); // Perf compiler @@ -984,38 +1035,38 @@ task("perftsc", [perftscJsPath]); // Instrumented compiler var loggedIOpath = harnessDirectory + 'loggedIO.ts'; var loggedIOJsPath = builtLocalDirectory + 'loggedIO.js'; -file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function() { +file(loggedIOJsPath, [builtLocalDirectory, loggedIOpath], function () { var temp = builtLocalDirectory + 'temp'; jake.mkdirP(temp); var options = "--outdir " + temp + ' ' + loggedIOpath; var cmd = host + " " + LKGDirectory + compilerFilename + " " + options + " "; console.log(cmd + "\n"); var ex = jake.createExec([cmd]); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { fs.renameSync(temp + '/harness/loggedIO.js', loggedIOJsPath); jake.rmRf(temp); complete(); }); ex.run(); -}, {async: true}); +}, { async: true }); var instrumenterPath = harnessDirectory + 'instrumenter.ts'; var instrumenterJsPath = builtLocalDirectory + 'instrumenter.js'; compileFile(instrumenterJsPath, [instrumenterPath], [tscFile, instrumenterPath].concat(libraryTargets), [], /*useBuiltCompiler*/ true); desc("Builds an instrumented tsc.js"); -task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function() { +task('tsc-instrumented', [loggedIOJsPath, instrumenterJsPath, tscFile], function () { var cmd = host + ' ' + instrumenterJsPath + ' record iocapture ' + builtLocalDirectory + compilerFilename; console.log(cmd); var ex = jake.createExec([cmd]); - ex.addListener("cmdEnd", function() { + ex.addListener("cmdEnd", function () { complete(); }); ex.run(); }, { async: true }); desc("Updates the sublime plugin's tsserver"); -task("update-sublime", ["local", serverFile], function() { +task("update-sublime", ["local", serverFile], function () { jake.cpR(serverFile, "../TypeScript-Sublime-Plugin/tsserver/"); jake.cpR(serverFile + ".map", "../TypeScript-Sublime-Plugin/tsserver/"); }); @@ -1031,124 +1082,111 @@ var tslintRules = [ "objectLiteralSurroundingSpaceRule", "noTypeAssertionWhitespaceRule" ]; -var tslintRulesFiles = tslintRules.map(function(p) { +var tslintRulesFiles = tslintRules.map(function (p) { return path.join(tslintRuleDir, p + ".ts"); }); -var tslintRulesOutFiles = tslintRules.map(function(p) { +var tslintRulesOutFiles = tslintRules.map(function (p) { return path.join(builtLocalDirectory, "tslint", p + ".js"); }); desc("Compiles tslint rules to js"); -task("build-rules", tslintRulesOutFiles); -tslintRulesFiles.forEach(function(ruleFile, i) { +task("build-rules", ["build-rules-start"].concat(tslintRulesOutFiles).concat(["build-rules-end"])); +tslintRulesFiles.forEach(function (ruleFile, i) { compileFile(tslintRulesOutFiles[i], [ruleFile], [ruleFile], [], /*useBuiltCompiler*/ false, - { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint")}); + { noOutFile: true, generateDeclarations: false, outDir: path.join(builtLocalDirectory, "tslint") }); }); -function getLinterOptions() { - return { - configuration: require("./tslint.json"), - formatter: "prose", - formattersDirectory: undefined, - rulesDirectory: "built/local/tslint" - }; -} +desc("Emit the start of the build-rules fold"); +task("build-rules-start", [], function () { + if (fold.isTravis()) console.log(fold.start("build-rules")); +}); -function lintFileContents(options, path, contents) { - var ll = new Linter(path, contents, options); - console.log("Linting '" + path + "'."); - return ll.lint(); -} - -function lintFile(options, path) { - var contents = fs.readFileSync(path, "utf8"); - return lintFileContents(options, path, contents); -} - -function lintFileAsync(options, path, cb) { - fs.readFile(path, "utf8", function(err, contents) { - if (err) { - return cb(err); - } - var result = lintFileContents(options, path, contents); - cb(undefined, result); - }); -} +desc("Emit the end of the build-rules fold"); +task("build-rules-end", [], function () { + if (fold.isTravis()) console.log(fold.end("build-rules")); +}); var lintTargets = compilerSources .concat(harnessSources) // Other harness sources - .concat(["instrumenter.ts"].map(function(f) { return path.join(harnessDirectory, f) })) + .concat(["instrumenter.ts"].map(function (f) { return path.join(harnessDirectory, f) })) .concat(serverCoreSources) .concat(tslintRulesFiles) .concat(servicesSources) .concat(["Gulpfile.ts"]) .concat([nodeServerInFile, perftscPath, "tests/perfsys.ts", webhostPath]); +function sendNextFile(files, child, callback, failures) { + var file = files.pop(); + if (file) { + console.log("Linting '" + file + "'."); + child.send({ kind: "file", name: file }); + } + else { + child.send({ kind: "close" }); + callback(failures); + } +} + +function spawnLintWorker(files, callback) { + var child = child_process.fork("./scripts/parallel-lint"); + var failures = 0; + child.on("message", function (data) { + switch (data.kind) { + case "result": + if (data.failures > 0) { + failures += data.failures; + console.log(data.output); + } + sendNextFile(files, child, callback, failures); + break; + case "error": + console.error(data.error); + failures++; + sendNextFile(files, child, callback, failures); + break; + } + }); + sendNextFile(files, child, callback, failures); +} desc("Runs tslint on the compiler sources. Optional arguments are: f[iles]=regex"); -task("lint", ["build-rules"], function() { - var lintOptions = getLinterOptions(); +task("lint", ["build-rules"], function () { + if (fold.isTravis()) console.log(fold.start("lint")); + var startTime = mark(); var failed = 0; var fileMatcher = RegExp(process.env.f || process.env.file || process.env.files || ""); var done = {}; for (var i in lintTargets) { var target = lintTargets[i]; if (!done[target] && fileMatcher.test(target)) { - var result = lintFile(lintOptions, target); - if (result.failureCount > 0) { - console.log(result.output); - failed += result.failureCount; - } - done[target] = true; + done[target] = fs.statSync(target).size; } } - if (failed > 0) { - fail('Linter errors.', failed); - } -}); -/** - * This is required because file watches on Windows get fires _twice_ - * when a file changes on some node/windows version configuations - * (node v4 and win 10, for example). By not running a lint for a file - * which already has a pending lint, we avoid duplicating our work. - * (And avoid printing duplicate results!) - */ -var lintSemaphores = {}; + var workerCount = (process.env.workerCount && +process.env.workerCount) || os.cpus().length; -function lintWatchFile(filename) { - fs.watch(filename, {persistent: true}, function(event) { - if (event !== "change") { - return; - } - - if (!lintSemaphores[filename]) { - lintSemaphores[filename] = true; - lintFileAsync(getLinterOptions(), filename, function(err, result) { - delete lintSemaphores[filename]; - if (err) { - console.log(err); - return; - } - if (result.failureCount > 0) { - console.log("***Lint failure***"); - for (var i = 0; i < result.failures.length; i++) { - var failure = result.failures[i]; - var start = failure.startPosition.lineAndCharacter; - var end = failure.endPosition.lineAndCharacter; - console.log("warning " + filename + " (" + (start.line + 1) + "," + (start.character + 1) + "," + (end.line + 1) + "," + (end.character + 1) + "): " + failure.failure); - } - console.log("*** Total " + result.failureCount + " failures."); - } - }); - } + var names = Object.keys(done).sort(function (namea, nameb) { + return done[namea] - done[nameb]; }); -} -desc("Watches files for changes to rerun a lint pass"); -task("lint-server", ["build-rules"], function() { - console.log("Watching ./src for changes to linted files"); - for (var i = 0; i < lintTargets.length; i++) { - lintWatchFile(lintTargets[i]); + for (var i = 0; i < workerCount; i++) { + spawnLintWorker(names, finished); } -}); + + var completed = 0; + var failures = 0; + function finished(fails) { + completed++; + failures += fails; + if (completed === workerCount) { + measure(startTime); + if (fold.isTravis()) console.log(fold.end("lint")); + if (failures > 0) { + fail('Linter errors.', failed); + } + else { + complete(); + } + } + } +}, { async: true }); diff --git a/README.md b/README.md index fca2890bc77..d16bc363b26 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Join the chat at https://gitter.im/Microsoft/TypeScript](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Microsoft/TypeScript?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](http://blogs.msdn.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). +[TypeScript](http://www.typescriptlang.org/) is a language for application-scale JavaScript. TypeScript adds optional types, classes, and modules to JavaScript. TypeScript supports tools for large-scale JavaScript applications for any browser, for any host, on any OS. TypeScript compiles to readable, standards-based JavaScript. Try it out at the [playground](http://www.typescriptlang.org/Playground), and stay up to date via [our blog](https://blogs.msdn.microsoft.com/typescript) and [Twitter account](https://twitter.com/typescriptlang). ## Installing diff --git a/package.json b/package.json index efe3866b6db..1f943f89788 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ }, "devDependencies": { "@types/browserify": "latest", - "@types/convert-source-map": "latest", "@types/chai": "latest", + "@types/convert-source-map": "latest", "@types/del": "latest", "@types/glob": "latest", "@types/gulp": "latest", @@ -69,9 +69,11 @@ "mkdirp": "latest", "mocha": "latest", "mocha-fivemat-progress-reporter": "latest", + "q": "latest", "run-sequence": "latest", "sorcery": "latest", "through2": "latest", + "travis-fold": "latest", "ts-node": "latest", "tsd": "latest", "tslint": "next", @@ -79,7 +81,7 @@ }, "scripts": { "pretest": "jake tests", - "test": "jake runtests", + "test": "jake runtests-parallel", "build": "npm run build:compiler && npm run build:tests", "build:compiler": "jake local", "build:tests": "jake tests", diff --git a/scripts/ior.ts b/scripts/ior.ts index eb67e62a275..91580203350 100644 --- a/scripts/ior.ts +++ b/scripts/ior.ts @@ -1,4 +1,4 @@ -/// +/// import fs = require('fs'); import path = require('path'); diff --git a/scripts/parallel-lint.js b/scripts/parallel-lint.js new file mode 100644 index 00000000000..a9aec06c2df --- /dev/null +++ b/scripts/parallel-lint.js @@ -0,0 +1,45 @@ +var Linter = require("tslint"); +var fs = require("fs"); + +function getLinterOptions() { + return { + configuration: require("../tslint.json"), + formatter: "prose", + formattersDirectory: undefined, + rulesDirectory: "built/local/tslint" + }; +} + +function lintFileContents(options, path, contents) { + var ll = new Linter(path, contents, options); + return ll.lint(); +} + +function lintFileAsync(options, path, cb) { + fs.readFile(path, "utf8", function (err, contents) { + if (err) { + return cb(err); + } + var result = lintFileContents(options, path, contents); + cb(undefined, result); + }); +} + +process.on("message", function (data) { + switch (data.kind) { + case "file": + var target = data.name; + var lintOptions = getLinterOptions(); + lintFileAsync(lintOptions, target, function (err, result) { + if (err) { + process.send({ kind: "error", error: err.toString() }); + return; + } + process.send({ kind: "result", failures: result.failureCount, output: result.output }); + }); + break; + case "close": + process.exit(0); + break; + } +}); \ No newline at end of file diff --git a/scripts/processDiagnosticMessages.ts b/scripts/processDiagnosticMessages.ts index 26632ba6bab..431cf460180 100644 --- a/scripts/processDiagnosticMessages.ts +++ b/scripts/processDiagnosticMessages.ts @@ -69,7 +69,7 @@ function checkForUniqueCodes(messages: string[], diagnosticTable: InputDiagnosti } function buildUniqueNameMap(names: string[]): ts.Map { - var nameMap: ts.Map = {}; + var nameMap = ts.createMap(); var uniqueNames = NameGenerator.ensureUniqueness(names, /* isCaseSensitive */ false, /* isFixed */ undefined); diff --git a/scripts/tslint/preferConstRule.ts b/scripts/tslint/preferConstRule.ts index aaa1b0e53d5..1d316692468 100644 --- a/scripts/tslint/preferConstRule.ts +++ b/scripts/tslint/preferConstRule.ts @@ -1,7 +1,6 @@ import * as Lint from "tslint/lib/lint"; import * as ts from "typescript"; - export class Rule extends Lint.Rules.AbstractRule { public static FAILURE_STRING_FACTORY = (identifier: string) => `Identifier '${identifier}' never appears on the LHS of an assignment - use const instead of let for its declaration.`; @@ -64,7 +63,7 @@ interface DeclarationUsages { } class PreferConstWalker extends Lint.RuleWalker { - private inScopeLetDeclarations: ts.Map[] = []; + private inScopeLetDeclarations: ts.MapLike[] = []; private errors: Lint.RuleFailure[] = []; private markAssignment(identifier: ts.Identifier) { const name = identifier.text; @@ -172,7 +171,7 @@ class PreferConstWalker extends Lint.RuleWalker { } private visitAnyForStatement(node: ts.ForOfStatement | ts.ForInStatement) { - const names: ts.Map = {}; + const names: ts.MapLike = {}; if (isLet(node.initializer)) { if (node.initializer.kind === ts.SyntaxKind.VariableDeclarationList) { this.collectLetIdentifiers(node.initializer as ts.VariableDeclarationList, names); @@ -194,7 +193,7 @@ class PreferConstWalker extends Lint.RuleWalker { } visitBlock(node: ts.Block) { - const names: ts.Map = {}; + const names: ts.MapLike = {}; for (const statement of node.statements) { if (statement.kind === ts.SyntaxKind.VariableStatement) { this.collectLetIdentifiers((statement as ts.VariableStatement).declarationList, names); @@ -205,7 +204,7 @@ class PreferConstWalker extends Lint.RuleWalker { this.popDeclarations(); } - private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.Map) { + private collectLetIdentifiers(list: ts.VariableDeclarationList, ret: ts.MapLike) { for (const node of list.declarations) { if (isLet(node) && !isExported(node)) { this.collectNameIdentifiers(node, node.name, ret); @@ -213,7 +212,7 @@ class PreferConstWalker extends Lint.RuleWalker { } } - private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.Map) { + private collectNameIdentifiers(declaration: ts.VariableDeclaration, node: ts.Identifier | ts.BindingPattern, table: ts.MapLike) { if (node.kind === ts.SyntaxKind.Identifier) { table[(node as ts.Identifier).text] = { declaration, usages: 0 }; } @@ -222,7 +221,7 @@ class PreferConstWalker extends Lint.RuleWalker { } } - private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.Map) { + private collectBindingPatternIdentifiers(value: ts.VariableDeclaration, pattern: ts.BindingPattern, table: ts.MapLike) { for (const element of pattern.elements) { this.collectNameIdentifiers(value, element.name, table); } diff --git a/scripts/types/ambient.d.ts b/scripts/types/ambient.d.ts index e77e3fe8c5a..4f4b118c432 100644 --- a/scripts/types/ambient.d.ts +++ b/scripts/types/ambient.d.ts @@ -10,7 +10,7 @@ declare module "gulp-insert" { export function append(text: string | Buffer): NodeJS.ReadWriteStream; export function prepend(text: string | Buffer): NodeJS.ReadWriteStream; export function wrap(text: string | Buffer, tail: string | Buffer): NodeJS.ReadWriteStream; - export function transform(cb: (contents: string, file: {path: string}) => string): NodeJS.ReadWriteStream; // file is a vinyl file + export function transform(cb: (contents: string, file: {path: string, relative: string}) => string): NodeJS.ReadWriteStream; // file is a vinyl file } declare module "into-stream" { @@ -22,3 +22,4 @@ declare module "into-stream" { } declare module "sorcery"; +declare module "travis-fold"; diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index cf3142a3241..50c3adf1310 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -89,9 +89,10 @@ namespace ts { const binder = createBinder(); export function bindSourceFile(file: SourceFile, options: CompilerOptions) { - const start = performance.mark(); + performance.mark("beforeBind"); binder(file, options); - performance.measure("Bind", start); + performance.mark("afterBind"); + performance.measure("Bind", "beforeBind", "afterBind"); } function createBinder(): (file: SourceFile, options: CompilerOptions) => void { @@ -139,7 +140,7 @@ namespace ts { options = opts; languageVersion = getEmitScriptTarget(options); inStrictMode = !!file.externalModuleIndicator; - classifiableNames = {}; + classifiableNames = createMap(); symbolCount = 0; skipTransformFlagAggregation = isDeclarationFile(file); @@ -189,11 +190,11 @@ namespace ts { symbol.declarations.push(node); if (symbolFlags & SymbolFlags.HasExports && !symbol.exports) { - symbol.exports = {}; + symbol.exports = createMap(); } if (symbolFlags & SymbolFlags.HasMembers && !symbol.members) { - symbol.members = {}; + symbol.members = createMap(); } if (symbolFlags & SymbolFlags.Value) { @@ -304,8 +305,10 @@ namespace ts { const name = isDefaultExport && parent ? "default" : getDeclarationName(node); let symbol: Symbol; - if (name !== undefined) { - + if (name === undefined) { + symbol = createSymbol(SymbolFlags.None, "__missing"); + } + else { // Check and see if the symbol table already has a symbol with this name. If not, // create a new symbol with this name and add it to the table. Note that we don't // give the new symbol any flags *yet*. This ensures that it will not conflict @@ -317,6 +320,11 @@ namespace ts { // declaration we have for this symbol, and then create a new symbol for this // declaration. // + // Note that when properties declared in Javascript constructors + // (marked by isReplaceableByMethod) conflict with another symbol, the property loses. + // Always. This allows the common Javascript pattern of overwriting a prototype method + // with an bound instance method of the same type: `this.method = this.method.bind(this)` + // // If we created a new symbol, either because we didn't have a symbol with this name // in the symbol table, or we conflicted with an existing symbol, then just add this // node as the sole declaration of the new symbol. @@ -324,42 +332,44 @@ namespace ts { // Otherwise, we'll be merging into a compatible existing symbol (for example when // you have multiple 'vars' with the same name in the same container). In this case // just add this node into the declarations list of the symbol. - symbol = hasProperty(symbolTable, name) - ? symbolTable[name] - : (symbolTable[name] = createSymbol(SymbolFlags.None, name)); + symbol = symbolTable[name] || (symbolTable[name] = createSymbol(SymbolFlags.None, name)); if (name && (includes & SymbolFlags.Classifiable)) { classifiableNames[name] = name; } if (symbol.flags & excludes) { - if (node.name) { - node.name.parent = node; + if (symbol.isReplaceableByMethod) { + // Javascript constructor-declared symbols can be discarded in favor of + // prototype symbols like methods. + symbol = symbolTable[name] = createSymbol(SymbolFlags.None, name); } - - // Report errors every position with duplicate declaration - // Report errors on previous encountered declarations - let message = symbol.flags & SymbolFlags.BlockScopedVariable - ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 - : Diagnostics.Duplicate_identifier_0; - - forEach(symbol.declarations, declaration => { - if (hasModifier(declaration, ModifierFlags.Default)) { - message = Diagnostics.A_module_cannot_have_multiple_default_exports; + else { + if (node.name) { + node.name.parent = node; } - }); - forEach(symbol.declarations, declaration => { - file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); - }); - file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + // Report errors every position with duplicate declaration + // Report errors on previous encountered declarations + let message = symbol.flags & SymbolFlags.BlockScopedVariable + ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 + : Diagnostics.Duplicate_identifier_0; - symbol = createSymbol(SymbolFlags.None, name); + forEach(symbol.declarations, declaration => { + if (hasModifier(declaration, ModifierFlags.Default)) { + message = Diagnostics.A_module_cannot_have_multiple_default_exports; + } + }); + + forEach(symbol.declarations, declaration => { + file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + }); + file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + + symbol = createSymbol(SymbolFlags.None, name); + } } } - else { - symbol = createSymbol(SymbolFlags.None, "__missing"); - } addDeclarationToSymbol(symbol, node, includes); symbol.parent = parent; @@ -440,7 +450,7 @@ namespace ts { if (containerFlags & ContainerFlags.IsContainer) { container = blockScopeContainer = node; if (containerFlags & ContainerFlags.HasLocals) { - container.locals = {}; + container.locals = createMap(); } addToContainerChain(container); } @@ -1422,7 +1432,8 @@ namespace ts { const typeLiteralSymbol = createSymbol(SymbolFlags.TypeLiteral, "__type"); addDeclarationToSymbol(typeLiteralSymbol, node, SymbolFlags.TypeLiteral); - typeLiteralSymbol.members = { [symbol.name]: symbol }; + typeLiteralSymbol.members = createMap(); + typeLiteralSymbol.members[symbol.name] = symbol; } function bindObjectLiteralExpression(node: ObjectLiteralExpression) { @@ -1432,7 +1443,7 @@ namespace ts { } if (inStrictMode) { - const seen: Map = {}; + const seen = createMap(); for (const prop of node.properties) { if (prop.name.kind !== SyntaxKind.Identifier) { @@ -1488,7 +1499,7 @@ namespace ts { // fall through. default: if (!blockScopeContainer.locals) { - blockScopeContainer.locals = {}; + blockScopeContainer.locals = createMap(); addToContainerChain(blockScopeContainer); } declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); @@ -1913,18 +1924,17 @@ namespace ts { } function bindExportAssignment(node: ExportAssignment | BinaryExpression) { - const boundExpression = node.kind === SyntaxKind.ExportAssignment ? (node).expression : (node).right; if (!container.symbol || !container.symbol.exports) { // Export assignment in some sort of block construct bindAnonymousDeclaration(node, SymbolFlags.Alias, getDeclarationName(node)); } - else if (boundExpression.kind === SyntaxKind.Identifier && node.kind === SyntaxKind.ExportAssignment) { - // An export default clause with an identifier exports all meanings of that identifier - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Alias, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); - } else { - // An export default clause with an expression exports a value - declareSymbol(container.symbol.exports, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); + const flags = node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node) + // An export default clause with an EntityNameExpression exports all meanings of that identifier + ? SymbolFlags.Alias + // An export default clause with any other expression exports a value + : SymbolFlags.Property; + declareSymbol(container.symbol.exports, container.symbol, node, flags, SymbolFlags.PropertyExcludes | SymbolFlags.AliasExcludes); } } @@ -1951,7 +1961,7 @@ namespace ts { } } - file.symbol.globalExports = file.symbol.globalExports || {}; + file.symbol.globalExports = file.symbol.globalExports || createMap(); declareSymbol(file.symbol.globalExports, file.symbol, node, SymbolFlags.Alias, SymbolFlags.AliasExcludes); } @@ -1993,20 +2003,25 @@ namespace ts { } function bindThisPropertyAssignment(node: BinaryExpression) { - // Declare a 'member' in case it turns out the container was an ES5 class or ES6 constructor - let assignee: Node; + Debug.assert(isInJavaScriptFile(node)); + // Declare a 'member' if the container is an ES5 class or ES6 constructor if (container.kind === SyntaxKind.FunctionDeclaration || container.kind === SyntaxKind.FunctionExpression) { - assignee = container; + container.symbol.members = container.symbol.members || createMap(); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); } else if (container.kind === SyntaxKind.Constructor) { - assignee = container.parent; + // this.foo assignment in a JavaScript class + // Bind this property to the containing class + const saveContainer = container; + container = container.parent; + const symbol = bindPropertyOrMethodOrAccessor(node, SymbolFlags.Property, SymbolFlags.None); + if (symbol) { + // constructor-declared symbols can be overwritten by subsequent method declarations + (symbol as Symbol).isReplaceableByMethod = true; + } + container = saveContainer; } - else { - return; - } - assignee.symbol.members = assignee.symbol.members || {}; - // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(assignee.symbol.members, assignee.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes & ~SymbolFlags.Property); } function bindPrototypePropertyAssignment(node: BinaryExpression) { @@ -2030,7 +2045,7 @@ namespace ts { // Set up the members collection if it doesn't exist already if (!funcSymbol.members) { - funcSymbol.members = {}; + funcSymbol.members = createMap(); } // Declare the method/property @@ -2079,7 +2094,7 @@ namespace ts { // module might have an exported variable called 'prototype'. We can't allow that as // that would clash with the built-in 'prototype' for the class. const prototypeSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Prototype, "prototype"); - if (hasProperty(symbol.exports, prototypeSymbol.name)) { + if (symbol.exports[prototypeSymbol.name]) { if (node.name) { node.name.parent = node; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0a5173efece..81f22e2f192 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -44,7 +44,7 @@ namespace ts { let symbolCount = 0; const emptyArray: any[] = []; - const emptySymbols: SymbolTable = {}; + const emptySymbols = createMap(); const compilerOptions = host.getCompilerOptions(); const languageVersion = compilerOptions.target || ScriptTarget.ES3; @@ -106,11 +106,11 @@ namespace ts { isOptionalParameter }; - const tupleTypes: Map = {}; - const unionTypes: Map = {}; - const intersectionTypes: Map = {}; - const stringLiteralTypes: Map = {}; - const numericLiteralTypes: Map = {}; + const tupleTypes: GenericType[] = []; + const unionTypes = createMap(); + const intersectionTypes = createMap(); + const stringLiteralTypes = createMap(); + const numericLiteralTypes = createMap(); const unknownSymbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "unknown"); const resolvingSymbol = createSymbol(SymbolFlags.Transient, "__resolving__"); @@ -132,7 +132,7 @@ namespace ts { const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); const emptyGenericType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); - emptyGenericType.instantiations = {}; + emptyGenericType.instantiations = createMap(); const anyFunctionType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined); // The anyFunctionType contains the anyFunctionType by definition. The flag is further propagated @@ -146,7 +146,7 @@ namespace ts { const enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); - const globals: SymbolTable = {}; + const globals = createMap(); /** * List of every ambient module with a "*" wildcard. * Unlike other ambient modules, these can't be stored in `globals` because symbol tables only deal with exact matches. @@ -246,7 +246,8 @@ namespace ts { NEUndefinedOrNull = 1 << 19, // x != undefined / x != null Truthy = 1 << 20, // x Falsy = 1 << 21, // !x - All = (1 << 22) - 1, + Discriminatable = 1 << 22, // May have discriminant property + All = (1 << 23) - 1, // The following members encode facts about particular kinds of types for use in the getTypeFacts function. // The presence of a particular fact means that the given test is true for some (and possibly all) values // of that kind of type. @@ -276,15 +277,15 @@ namespace ts { TrueFacts = BaseBooleanFacts | Truthy, SymbolStrictFacts = TypeofEQSymbol | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNEObject | TypeofNEFunction | TypeofNEHostObject | NEUndefined | NENull | NEUndefinedOrNull | Truthy, SymbolFacts = SymbolStrictFacts | EQUndefined | EQNull | EQUndefinedOrNull | Falsy, - ObjectStrictFacts = TypeofEQObject | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | NEUndefined | NENull | NEUndefinedOrNull | Truthy, + ObjectStrictFacts = TypeofEQObject | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | NEUndefined | NENull | NEUndefinedOrNull | Truthy | Discriminatable, ObjectFacts = ObjectStrictFacts | EQUndefined | EQNull | EQUndefinedOrNull | Falsy, - FunctionStrictFacts = TypeofEQFunction | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | NEUndefined | NENull | NEUndefinedOrNull | Truthy, + FunctionStrictFacts = TypeofEQFunction | TypeofEQHostObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | NEUndefined | NENull | NEUndefinedOrNull | Truthy | Discriminatable, FunctionFacts = FunctionStrictFacts | EQUndefined | EQNull | EQUndefinedOrNull | Falsy, UndefinedFacts = TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEObject | TypeofNEFunction | TypeofNEHostObject | EQUndefined | EQUndefinedOrNull | NENull | Falsy, NullFacts = TypeofEQObject | TypeofNEString | TypeofNENumber | TypeofNEBoolean | TypeofNESymbol | TypeofNEFunction | TypeofNEHostObject | EQNull | EQUndefinedOrNull | NEUndefined | Falsy, } - const typeofEQFacts: Map = { + const typeofEQFacts = createMap({ "string": TypeFacts.TypeofEQString, "number": TypeFacts.TypeofEQNumber, "boolean": TypeFacts.TypeofEQBoolean, @@ -292,9 +293,9 @@ namespace ts { "undefined": TypeFacts.EQUndefined, "object": TypeFacts.TypeofEQObject, "function": TypeFacts.TypeofEQFunction - }; + }); - const typeofNEFacts: Map = { + const typeofNEFacts = createMap({ "string": TypeFacts.TypeofNEString, "number": TypeFacts.TypeofNENumber, "boolean": TypeFacts.TypeofNEBoolean, @@ -302,19 +303,19 @@ namespace ts { "undefined": TypeFacts.NEUndefined, "object": TypeFacts.TypeofNEObject, "function": TypeFacts.TypeofNEFunction - }; + }); - const typeofTypesByName: Map = { + const typeofTypesByName = createMap({ "string": stringType, "number": numberType, "boolean": booleanType, "symbol": esSymbolType, "undefined": undefinedType - }; + }); let jsxElementType: ObjectType; /** Things we lazy load from the JSX namespace */ - const jsxTypes: Map = {}; + const jsxTypes = createMap(); const JsxNames = { JSX: "JSX", IntrinsicElements: "IntrinsicElements", @@ -325,10 +326,10 @@ namespace ts { IntrinsicClassAttributes: "IntrinsicClassAttributes" }; - const subtypeRelation: Map = {}; - const assignableRelation: Map = {}; - const comparableRelation: Map = {}; - const identityRelation: Map = {}; + const subtypeRelation = createMap(); + const assignableRelation = createMap(); + const comparableRelation = createMap(); + const identityRelation = createMap(); // This is for caching the result of getSymbolDisplayBuilder. Do not access directly. let _displayBuilder: SymbolDisplayBuilder; @@ -342,9 +343,8 @@ namespace ts { ResolvedReturnType } - const builtinGlobals: SymbolTable = { - [undefinedSymbol.name]: undefinedSymbol - }; + const builtinGlobals = createMap(); + builtinGlobals[undefinedSymbol.name] = undefinedSymbol; initializeTypeChecker(); @@ -404,8 +404,8 @@ namespace ts { result.parent = symbol.parent; if (symbol.valueDeclaration) result.valueDeclaration = symbol.valueDeclaration; if (symbol.constEnumOnlyModule) result.constEnumOnlyModule = true; - if (symbol.members) result.members = cloneSymbolTable(symbol.members); - if (symbol.exports) result.exports = cloneSymbolTable(symbol.exports); + if (symbol.members) result.members = cloneMap(symbol.members); + if (symbol.exports) result.exports = cloneMap(symbol.exports); recordMergedSymbol(result, symbol); return result; } @@ -427,11 +427,11 @@ namespace ts { target.declarations.push(node); }); if (source.members) { - if (!target.members) target.members = {}; + if (!target.members) target.members = createMap(); mergeSymbolTable(target.members, source.members); } if (source.exports) { - if (!target.exports) target.exports = {}; + if (!target.exports) target.exports = createMap(); mergeSymbolTable(target.exports, source.exports); } recordMergedSymbol(target, source); @@ -448,29 +448,17 @@ namespace ts { } } - function cloneSymbolTable(symbolTable: SymbolTable): SymbolTable { - const result: SymbolTable = {}; - for (const id in symbolTable) { - if (hasProperty(symbolTable, id)) { - result[id] = symbolTable[id]; - } - } - return result; - } - function mergeSymbolTable(target: SymbolTable, source: SymbolTable) { for (const id in source) { - if (hasProperty(source, id)) { - if (!hasProperty(target, id)) { - target[id] = source[id]; - } - else { - let symbol = target[id]; - if (!(symbol.flags & SymbolFlags.Merged)) { - target[id] = symbol = cloneSymbol(symbol); - } - mergeSymbol(symbol, source[id]); + let targetSymbol = target[id]; + if (!targetSymbol) { + target[id] = source[id]; + } + else { + if (!(targetSymbol.flags & SymbolFlags.Merged)) { + target[id] = targetSymbol = cloneSymbol(targetSymbol); } + mergeSymbol(targetSymbol, source[id]); } } } @@ -514,14 +502,12 @@ namespace ts { function addToSymbolTable(target: SymbolTable, source: SymbolTable, message: DiagnosticMessage) { for (const id in source) { - if (hasProperty(source, id)) { - if (hasProperty(target, id)) { - // Error on redeclarations - forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); - } - else { - target[id] = source[id]; - } + if (target[id]) { + // Error on redeclarations + forEach(target[id].declarations, addDeclarationDiagnostic(id, message)); + } + else { + target[id] = source[id]; } } @@ -538,7 +524,7 @@ namespace ts { function getNodeLinks(node: Node): NodeLinks { const nodeId = getNodeId(node); - return nodeLinks[nodeId] || (nodeLinks[nodeId] = {}); + return nodeLinks[nodeId] || (nodeLinks[nodeId] = { flags: 0 }); } function isGlobalSourceFile(node: Node) { @@ -546,18 +532,20 @@ namespace ts { } function getSymbol(symbols: SymbolTable, name: string, meaning: SymbolFlags): Symbol { - if (meaning && hasProperty(symbols, name)) { + if (meaning) { const symbol = symbols[name]; - Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); - if (symbol.flags & meaning) { - return symbol; - } - if (symbol.flags & SymbolFlags.Alias) { - const target = resolveAlias(symbol); - // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors - if (target === unknownSymbol || target.flags & meaning) { + if (symbol) { + Debug.assert((symbol.flags & SymbolFlags.Instantiated) === 0, "Should never get an instantiated symbol here."); + if (symbol.flags & meaning) { return symbol; } + if (symbol.flags & SymbolFlags.Alias) { + const target = resolveAlias(symbol); + // Unknown symbol means an error occurred in alias resolution, treat it as positive answer to avoid cascading errors + if (target === unknownSymbol || target.flags & meaning) { + return symbol; + } + } } } // return undefined if we can't find a symbol. @@ -665,7 +653,7 @@ namespace ts { // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with // the given name can be found. - function resolveName(location: Node, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): Symbol { + function resolveName(location: Node | undefined, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): Symbol { let result: Symbol; let lastLocation: Node; let propertyWithInvalidInitializer: Node; @@ -745,7 +733,7 @@ namespace ts { // 2. We check === SymbolFlags.Alias in order to check that the symbol is *purely* // an alias. If we used &, we'd be throwing out symbols that have non alias aspects, // which is not the desired behavior. - if (hasProperty(moduleExports, name) && + if (moduleExports[name] && moduleExports[name].flags === SymbolFlags.Alias && getDeclarationOfKind(moduleExports[name], SyntaxKind.ExportSpecifier)) { break; @@ -882,7 +870,8 @@ namespace ts { if (!result) { if (nameNotFoundMessage) { - if (!checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && + if (!errorLocation || + !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); } @@ -931,7 +920,7 @@ namespace ts { } function checkAndReportErrorForMissingPrefix(errorLocation: Node, name: string, nameArg: string | Identifier): boolean { - if (!errorLocation || (errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === SyntaxKind.Identifier && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } @@ -969,28 +958,30 @@ namespace ts { function checkAndReportErrorForExtendingInterface(errorLocation: Node): boolean { - let parentClassExpression = errorLocation; - while (parentClassExpression) { - const kind = parentClassExpression.kind; - if (kind === SyntaxKind.Identifier || kind === SyntaxKind.PropertyAccessExpression) { - parentClassExpression = parentClassExpression.parent; - continue; - } - if (kind === SyntaxKind.ExpressionWithTypeArguments) { - break; - } - return false; - } - if (!parentClassExpression) { - return false; - } - const expression = (parentClassExpression).expression; - if (resolveEntityName(expression, SymbolFlags.Interface, /*ignoreErrors*/ true)) { + const expression = getEntityNameForExtendingInterface(errorLocation); + const isError = !!(expression && resolveEntityName(expression, SymbolFlags.Interface, /*ignoreErrors*/ true)); + if (isError) { error(errorLocation, Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, getTextOfNode(expression)); - return true; } - return false; + return isError; } + /** + * Climbs up parents to an ExpressionWithTypeArguments, and returns its expression, + * but returns undefined if that expression is not an EntityNameExpression. + */ + function getEntityNameForExtendingInterface(node: Node): EntityNameExpression | undefined { + switch (node.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.PropertyAccessExpression: + return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; + case SyntaxKind.ExpressionWithTypeArguments: + Debug.assert(isEntityNameExpression((node).expression)); + return (node).expression; + default: + return undefined; + } + } + function checkResolvedBlockScopedVariable(result: Symbol, errorLocation: Node): void { Debug.assert((result.flags & SymbolFlags.BlockScopedVariable) !== 0); @@ -1034,7 +1025,7 @@ namespace ts { } function getDeclarationOfAliasSymbol(symbol: Symbol): Declaration { - return forEach(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); + return findMap(symbol.declarations, d => isAliasSymbolDeclaration(d) ? d : undefined); } function getTargetOfImportEqualsDeclaration(node: ImportEqualsDeclaration): Symbol { @@ -1102,9 +1093,9 @@ namespace ts { function getExportOfModule(symbol: Symbol, name: string): Symbol { if (symbol.flags & SymbolFlags.Module) { - const exports = getExportsOfSymbol(symbol); - if (hasProperty(exports, name)) { - return resolveSymbol(exports[name]); + const exportedSymbol = getExportsOfSymbol(symbol)[name]; + if (exportedSymbol) { + return resolveSymbol(exportedSymbol); } } } @@ -1136,13 +1127,13 @@ namespace ts { else { symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } - // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default - if (!symbolFromVariable && allowSyntheticDefaultImports && name.text === "default") { - symbolFromVariable = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); - } // if symbolFromVariable is export - get its final target symbolFromVariable = resolveSymbol(symbolFromVariable); - const symbolFromModule = getExportOfModule(targetSymbol, name.text); + let symbolFromModule = getExportOfModule(targetSymbol, name.text); + // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default + if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { + symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + } const symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : symbolFromModule || symbolFromVariable; @@ -1169,7 +1160,7 @@ namespace ts { } function getTargetOfExportAssignment(node: ExportAssignment): Symbol { - return resolveEntityName(node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace); + return resolveEntityName(node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace); } function getTargetOfAliasDeclaration(node: Declaration): Symbol { @@ -1279,7 +1270,7 @@ namespace ts { } // Resolves a qualified name and any involved aliases - function resolveEntityName(name: EntityName | Expression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean, location?: Node): Symbol { + function resolveEntityName(name: EntityNameOrEntityNameExpression, meaning: SymbolFlags, ignoreErrors?: boolean, dontResolveAlias?: boolean, location?: Node): Symbol | undefined { if (nodeIsMissing(name)) { return undefined; } @@ -1294,7 +1285,7 @@ namespace ts { } } else if (name.kind === SyntaxKind.QualifiedName || name.kind === SyntaxKind.PropertyAccessExpression) { - const left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; + const left = name.kind === SyntaxKind.QualifiedName ? (name).left : (name).expression; const right = name.kind === SyntaxKind.QualifiedName ? (name).right : (name).name; const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors, /*dontResolveAlias*/ false, location); @@ -1374,7 +1365,14 @@ namespace ts { if (moduleNotFoundError) { // report errors only if it was requested - error(errorNode, moduleNotFoundError, moduleName); + const tsExtension = tryExtractTypeScriptExtension(moduleName); + if (tsExtension) { + const diag = Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead; + error(errorNode, diag, tsExtension, removeExtension(moduleName, tsExtension)); + } + else { + error(errorNode, moduleNotFoundError, moduleName); + } } return undefined; } @@ -1425,7 +1423,7 @@ namespace ts { */ function extendExportSymbols(target: SymbolTable, source: SymbolTable, lookupTable?: Map, exportNode?: ExportDeclaration) { for (const id in source) { - if (id !== "default" && !hasProperty(target, id)) { + if (id !== "default" && !target[id]) { target[id] = source[id]; if (lookupTable && exportNode) { lookupTable[id] = { @@ -1433,7 +1431,7 @@ namespace ts { } as ExportCollisionTracker; } } - else if (lookupTable && exportNode && id !== "default" && hasProperty(target, id) && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { + else if (lookupTable && exportNode && id !== "default" && target[id] && resolveSymbol(target[id]) !== resolveSymbol(source[id])) { if (!lookupTable[id].exportsWithDuplicate) { lookupTable[id].exportsWithDuplicate = [exportNode]; } @@ -1455,12 +1453,12 @@ namespace ts { return; } visitedSymbols.push(symbol); - const symbols = cloneSymbolTable(symbol.exports); + const symbols = cloneMap(symbol.exports); // All export * declarations are collected in an __export symbol by the binder const exportStars = symbol.exports["__export"]; if (exportStars) { - const nestedSymbols: SymbolTable = {}; - const lookupTable: Map = {}; + const nestedSymbols = createMap(); + const lookupTable = createMap(); for (const node of exportStars.declarations) { const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier); const exportedSymbols = visit(resolvedModule); @@ -1474,7 +1472,7 @@ namespace ts { for (const id in lookupTable) { const { exportsWithDuplicate } = lookupTable[id]; // It's not an error if the file with multiple `export *`s with duplicate names exports a member with that name itself - if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || hasProperty(symbols, id)) { + if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols[id]) { continue; } for (const node of exportsWithDuplicate) { @@ -1542,8 +1540,8 @@ namespace ts { function createType(flags: TypeFlags): Type { const result = new Type(checker, flags); - result.id = typeCount; typeCount++; + result.id = typeCount; return result; } @@ -1580,13 +1578,11 @@ namespace ts { function getNamedMembers(members: SymbolTable): Symbol[] { let result: Symbol[]; for (const id in members) { - if (hasProperty(members, id)) { - if (!isReservedMemberName(id)) { - if (!result) result = []; - const symbol = members[id]; - if (symbolIsValue(symbol)) { - result.push(symbol); - } + if (!isReservedMemberName(id)) { + if (!result) result = []; + const symbol = members[id]; + if (symbolIsValue(symbol)) { + result.push(symbol); } } } @@ -1662,12 +1658,12 @@ namespace ts { } // If symbol is directly available by its name in the symbol table - if (isAccessible(lookUp(symbols, symbol.name))) { + if (isAccessible(symbols[symbol.name])) { return [symbol]; } // Check if symbol is any of the alias - return forEachValue(symbols, symbolFromSymbolTable => { + return forEachProperty(symbols, symbolFromSymbolTable => { if (symbolFromSymbolTable.flags & SymbolFlags.Alias && symbolFromSymbolTable.name !== "export=" && !getDeclarationOfKind(symbolFromSymbolTable, SyntaxKind.ExportSpecifier)) { @@ -1702,12 +1698,12 @@ namespace ts { let qualify = false; forEachSymbolTableInScope(enclosingDeclaration, symbolTable => { // If symbol of this name is not available in the symbol table we are ok - if (!hasProperty(symbolTable, symbol.name)) { + let symbolFromSymbolTable = symbolTable[symbol.name]; + if (!symbolFromSymbolTable) { // Continue to the next symbol table return false; } // If the symbol with this name is present it should refer to the symbol - let symbolFromSymbolTable = symbolTable[symbol.name]; if (symbolFromSymbolTable === symbol) { // No need to qualify return true; @@ -1853,7 +1849,7 @@ namespace ts { } } - function isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult { + function isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult { // get symbol of the first identifier of the entityName let meaning: SymbolFlags; if (entityName.parent.kind === SyntaxKind.TypeQuery || isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -2153,9 +2149,6 @@ namespace ts { // The specified symbol flags need to be reinterpreted as type flags buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, SymbolFlags.Type, SymbolFormatFlags.None, nextFlags); } - else if (type.flags & TypeFlags.Tuple) { - writeTupleType(type); - } else if (!(flags & TypeFormatFlags.InTypeAlias) && type.flags & (TypeFlags.Anonymous | TypeFlags.UnionOrIntersection) && type.aliasSymbol) { const typeArguments = type.aliasTypeArguments; writeSymbolTypeReference(type.aliasSymbol, typeArguments, 0, typeArguments ? typeArguments.length : 0, nextFlags); @@ -2222,6 +2215,11 @@ namespace ts { writePunctuation(writer, SyntaxKind.OpenBracketToken); writePunctuation(writer, SyntaxKind.CloseBracketToken); } + else if (type.target.flags & TypeFlags.Tuple) { + writePunctuation(writer, SyntaxKind.OpenBracketToken); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), SyntaxKind.CommaToken); + writePunctuation(writer, SyntaxKind.CloseBracketToken); + } else { // Write the type reference in the format f.g.C where A and B are type arguments // for outer type parameters, and f and g are the respective declaring containers of those @@ -2250,12 +2248,6 @@ namespace ts { } } - function writeTupleType(type: TupleType) { - writePunctuation(writer, SyntaxKind.OpenBracketToken); - writeTypeList(type.elementTypes, SyntaxKind.CommaToken); - writePunctuation(writer, SyntaxKind.CloseBracketToken); - } - function writeUnionOrIntersectionType(type: UnionOrIntersectionType, flags: TypeFormatFlags) { if (flags & TypeFormatFlags.InElementType) { writePunctuation(writer, SyntaxKind.OpenParenToken); @@ -2966,7 +2958,7 @@ namespace ts { : elementType; if (!type) { if (isTupleType(parentType)) { - error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), (parentType).elementTypes.length, pattern.elements.length); + error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), getTypeReferenceArity(parentType), pattern.elements.length); } else { error(declaration, Diagnostics.Type_0_has_no_property_1, typeToString(parentType), propName); @@ -3078,9 +3070,14 @@ namespace ts { } } // Use contextual parameter type if one is available - const type = declaration.symbol.name === "this" - ? getContextuallyTypedThisType(func) - : getContextuallyTypedParameterType(declaration); + let type: Type; + if (declaration.symbol.name === "this") { + const thisParameter = getContextualThisParameter(func); + type = thisParameter ? getTypeOfSymbol(thisParameter) : undefined; + } + else { + type = getContextuallyTypedParameterType(declaration); + } if (type) { return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } @@ -3098,7 +3095,7 @@ namespace ts { // If the declaration specifies a binding pattern, use the type implied by the binding pattern if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ false, /*reportErrors*/ true); } // No type specified and nothing can be inferred @@ -3108,24 +3105,22 @@ namespace ts { // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding // pattern. Otherwise, it is the type any. - function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean): Type { + function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean, reportErrors?: boolean): Type { if (element.initializer) { - const type = checkExpressionCached(element.initializer); - reportErrorsFromWidening(element, type); - return getWidenedType(type); + return checkExpressionCached(element.initializer); } if (isBindingPattern(element.name)) { - return getTypeFromBindingPattern(element.name, includePatternInType); + return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); } - if (compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { + if (reportErrors && compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; } // Return the type implied by an object binding pattern - function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { - const members: SymbolTable = {}; + function getTypeFromObjectBindingPattern(pattern: BindingPattern, includePatternInType: boolean, reportErrors: boolean): Type { + const members = createMap(); let hasComputedProperties = false; forEach(pattern.elements, e => { const name = e.propertyName || e.name; @@ -3138,7 +3133,7 @@ namespace ts { const text = getTextOfPropertyName(name); const flags = SymbolFlags.Property | SymbolFlags.Transient | (e.initializer ? SymbolFlags.Optional : 0); const symbol = createSymbol(flags, text); - symbol.type = getTypeFromBindingElement(e, includePatternInType); + symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors); symbol.bindingElement = e; members[symbol.name] = symbol; }); @@ -3153,19 +3148,19 @@ namespace ts { } // Return the type implied by an array binding pattern - function getTypeFromArrayBindingPattern(pattern: BindingPattern, includePatternInType: boolean): Type { + function getTypeFromArrayBindingPattern(pattern: BindingPattern, includePatternInType: boolean, reportErrors: boolean): Type { const elements = pattern.elements; if (elements.length === 0 || elements[elements.length - 1].dotDotDotToken) { return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType; } // If the pattern has at least one element, and no rest element, then it should imply a tuple type. - const elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType)); + const elementTypes = map(elements, e => e.kind === SyntaxKind.OmittedExpression ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors)); + let result = createTupleType(elementTypes); if (includePatternInType) { - const result = createNewTupleType(elementTypes); + result = cloneTypeReference(result); result.pattern = pattern; - return result; } - return createTupleType(elementTypes); + return result; } // Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself @@ -3175,10 +3170,10 @@ namespace ts { // used as the contextual type of an initializer associated with the binding pattern. Also, for a destructuring // parameter with no type annotation or initializer, the type implied by the binding pattern becomes the type of // the parameter. - function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType?: boolean): Type { + function getTypeFromBindingPattern(pattern: BindingPattern, includePatternInType?: boolean, reportErrors?: boolean): Type { return pattern.kind === SyntaxKind.ObjectBindingPattern - ? getTypeFromObjectBindingPattern(pattern, includePatternInType) - : getTypeFromArrayBindingPattern(pattern, includePatternInType); + ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) + : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } // Return the type associated with a variable, parameter, or property declaration. In the simple case this is the type @@ -3255,6 +3250,13 @@ namespace ts { // * className.prototype.method = expr if (declaration.kind === SyntaxKind.BinaryExpression || declaration.kind === SyntaxKind.PropertyAccessExpression && declaration.parent.kind === SyntaxKind.BinaryExpression) { + // Use JS Doc type if present on parent expression statement + if (declaration.flags & NodeFlags.JavaScriptFile) { + const typeTag = getJSDocTypeTag(declaration.parent); + if (typeTag && typeTag.typeExpression) { + return links.type = getTypeFromTypeNode(typeTag.typeExpression.type); + } + } const declaredTypes = map(symbol.declarations, decl => decl.kind === SyntaxKind.BinaryExpression ? checkExpressionCached((decl).right) : @@ -3567,18 +3569,21 @@ namespace ts { } function getBaseTypes(type: InterfaceType): ObjectType[] { - const isClass = type.symbol.flags & SymbolFlags.Class; - const isInterface = type.symbol.flags & SymbolFlags.Interface; if (!type.resolvedBaseTypes) { - if (!isClass && !isInterface) { + if (type.flags & TypeFlags.Tuple) { + type.resolvedBaseTypes = [createArrayType(getUnionType(type.typeParameters))]; + } + else if (type.symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + if (type.symbol.flags & SymbolFlags.Class) { + resolveBaseTypesOfClass(type); + } + if (type.symbol.flags & SymbolFlags.Interface) { + resolveBaseTypesOfInterface(type); + } + } + else { Debug.fail("type must be class or interface"); } - if (isClass) { - resolveBaseTypesOfClass(type); - } - if (isInterface) { - resolveBaseTypesOfInterface(type); - } } return type.resolvedBaseTypes; } @@ -3683,7 +3688,7 @@ namespace ts { const baseTypeNodes = getInterfaceBaseTypeNodes(declaration); if (baseTypeNodes) { for (const node of baseTypeNodes) { - if (isSupportedExpressionWithTypeArguments(node)) { + if (isEntityNameExpression(node.expression)) { const baseSymbol = resolveEntityName(node.expression, SymbolFlags.Type, /*ignoreErrors*/ true); if (!baseSymbol || !(baseSymbol.flags & SymbolFlags.Interface) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) { return false; @@ -3713,7 +3718,7 @@ namespace ts { type.typeParameters = concatenate(outerTypeParameters, localTypeParameters); type.outerTypeParameters = outerTypeParameters; type.localTypeParameters = localTypeParameters; - (type).instantiations = {}; + (type).instantiations = createMap(); (type).instantiations[getTypeListId(type.typeParameters)] = type; (type).target = type; (type).typeArguments = type.typeParameters; @@ -3755,7 +3760,7 @@ namespace ts { if (typeParameters) { // Initialize the instantiation cache for generic type aliases. The declared type corresponds to // an instantiation of the type alias with the type parameters supplied as type arguments. - links.instantiations = {}; + links.instantiations = createMap(); links.instantiations[getTypeListId(links.typeParameters)] = type; } } @@ -3776,7 +3781,7 @@ namespace ts { return expr.kind === SyntaxKind.NumericLiteral || expr.kind === SyntaxKind.PrefixUnaryExpression && (expr).operator === SyntaxKind.MinusToken && (expr).operand.kind === SyntaxKind.NumericLiteral || - expr.kind === SyntaxKind.Identifier && hasProperty(symbol.exports, (expr).text); + expr.kind === SyntaxKind.Identifier && !!symbol.exports[(expr).text]; } function enumHasLiteralMembers(symbol: Symbol) { @@ -3799,7 +3804,7 @@ namespace ts { enumType.symbol = symbol; if (enumHasLiteralMembers(symbol)) { const memberTypeList: Type[] = []; - const memberTypes: Map = {}; + const memberTypes = createMap(); for (const declaration of enumType.symbol.declarations) { if (declaration.kind === SyntaxKind.EnumDeclaration) { computeEnumMemberValues(declaration); @@ -3962,7 +3967,7 @@ namespace ts { } function createSymbolTable(symbols: Symbol[]): SymbolTable { - const result: SymbolTable = {}; + const result = createMap(); for (const symbol of symbols) { result[symbol.name] = symbol; } @@ -3972,7 +3977,7 @@ namespace ts { // The mappingThisOnly flag indicates that the only type parameter being mapped is "this". When the flag is true, // we check symbols to see if we can quickly conclude they are free of "this" references, thus needing no instantiation. function createInstantiatedSymbolTable(symbols: Symbol[], mapper: TypeMapper, mappingThisOnly: boolean): SymbolTable { - const result: SymbolTable = {}; + const result = createMap(); for (const symbol of symbols) { result[symbol.name] = mappingThisOnly && isIndependentMember(symbol) ? symbol : instantiateSymbol(symbol, mapper); } @@ -3981,7 +3986,7 @@ namespace ts { function addInheritedMembers(symbols: SymbolTable, baseSymbols: Symbol[]) { for (const s of baseSymbols) { - if (!hasProperty(symbols, s.name)) { + if (!symbols[s.name]) { symbols[s.name] = s; } } @@ -4008,13 +4013,21 @@ namespace ts { } function resolveObjectTypeMembers(type: ObjectType, source: InterfaceTypeWithDeclaredMembers, typeParameters: TypeParameter[], typeArguments: Type[]) { - let mapper = identityMapper; - let members = source.symbol.members; - let callSignatures = source.declaredCallSignatures; - let constructSignatures = source.declaredConstructSignatures; - let stringIndexInfo = source.declaredStringIndexInfo; - let numberIndexInfo = source.declaredNumberIndexInfo; - if (!rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + let mapper: TypeMapper; + let members: SymbolTable; + let callSignatures: Signature[]; + let constructSignatures: Signature[]; + let stringIndexInfo: IndexInfo; + let numberIndexInfo: IndexInfo; + if (rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) { + mapper = identityMapper; + members = source.symbol ? source.symbol.members : createSymbolTable(source.declaredProperties); + callSignatures = source.declaredCallSignatures; + constructSignatures = source.declaredConstructSignatures; + stringIndexInfo = source.declaredStringIndexInfo; + numberIndexInfo = source.declaredNumberIndexInfo; + } + else { mapper = createTypeMapper(typeParameters, typeArguments); members = createInstantiatedSymbolTable(source.declaredProperties, mapper, /*mappingThisOnly*/ typeParameters.length === 1); callSignatures = instantiateList(source.declaredCallSignatures, mapper, instantiateSignature); @@ -4024,7 +4037,7 @@ namespace ts { } const baseTypes = getBaseTypes(source); if (baseTypes.length) { - if (members === source.symbol.members) { + if (source.symbol && members === source.symbol.members) { members = createSymbolTable(source.declaredProperties); } const thisArgument = lastOrUndefined(typeArguments); @@ -4094,25 +4107,6 @@ namespace ts { return result; } - function createTupleTypeMemberSymbols(memberTypes: Type[]): SymbolTable { - const members: SymbolTable = {}; - for (let i = 0; i < memberTypes.length; i++) { - const symbol = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "" + i); - symbol.type = memberTypes[i]; - members[i] = symbol; - } - return members; - } - - function resolveTupleTypeMembers(type: TupleType) { - const arrayElementType = getUnionType(type.elementTypes); - // Make the tuple type itself the 'this' type by including an extra type argument - const arrayType = resolveStructuredTypeMembers(createTypeFromGenericGlobalType(globalArrayType, [arrayElementType, type])); - const members = createTupleTypeMemberSymbols(type.elementTypes); - addInheritedMembers(members, arrayType.properties); - setObjectTypeMembers(type, members, arrayType.callSignatures, arrayType.constructSignatures, arrayType.stringIndexInfo, arrayType.numberIndexInfo); - } - function findMatchingSignature(signatureList: Signature[], signature: Signature, partialMatch: boolean, ignoreThisTypes: boolean, ignoreReturnTypes: boolean): Signature { for (const s of signatureList) { if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypesIdentical)) { @@ -4291,9 +4285,6 @@ namespace ts { else if (type.flags & TypeFlags.Anonymous) { resolveAnonymousTypeMembers(type); } - else if (type.flags & TypeFlags.Tuple) { - resolveTupleTypeMembers(type); - } else if (type.flags & TypeFlags.Union) { resolveUnionTypeMembers(type); } @@ -4317,11 +4308,9 @@ namespace ts { function getPropertyOfObjectType(type: Type, name: string): Symbol { if (type.flags & TypeFlags.ObjectType) { const resolved = resolveStructuredTypeMembers(type); - if (hasProperty(resolved.members, name)) { - const symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } + const symbol = resolved.members[name]; + if (symbol && symbolIsValue(symbol)) { + return symbol; } } } @@ -4420,10 +4409,19 @@ namespace ts { } const propTypes: Type[] = []; const declarations: Declaration[] = []; + let commonType: Type = undefined; + let hasCommonType = true; for (const prop of props) { if (prop.declarations) { addRange(declarations, prop.declarations); } + const type = getTypeOfSymbol(prop); + if (!commonType) { + commonType = type; + } + else if (type !== commonType) { + hasCommonType = false; + } propTypes.push(getTypeOfSymbol(prop)); } const result = createSymbol( @@ -4433,6 +4431,7 @@ namespace ts { commonFlags, name); result.containingType = containingType; + result.hasCommonType = hasCommonType; result.declarations = declarations; result.isReadonly = isReadonly; result.type = containingType.flags & TypeFlags.Union ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -4440,29 +4439,32 @@ namespace ts { } function getPropertyOfUnionOrIntersectionType(type: UnionOrIntersectionType, name: string): Symbol { - const properties = type.resolvedProperties || (type.resolvedProperties = {}); - if (hasProperty(properties, name)) { - return properties[name]; - } - const property = createUnionOrIntersectionProperty(type, name); - if (property) { - properties[name] = property; + const properties = type.resolvedProperties || (type.resolvedProperties = createMap()); + let property = properties[name]; + if (!property) { + property = createUnionOrIntersectionProperty(type, name); + if (property) { + properties[name] = property; + } } return property; } - // Return the symbol for the property with the given name in the given type. Creates synthetic union properties when - // necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from - // Object and Function as appropriate. + /** + * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when + * necessary, maps primitive types and type parameters are to their apparent types, and augments with properties from + * Object and Function as appropriate. + * + * @param type a type to look up property from + * @param name a name of property to look up in a given type + */ function getPropertyOfType(type: Type, name: string): Symbol { type = getApparentType(type); if (type.flags & TypeFlags.ObjectType) { const resolved = resolveStructuredTypeMembers(type); - if (hasProperty(resolved.members, name)) { - const symbol = resolved.members[name]; - if (symbolIsValue(symbol)) { - return symbol; - } + const symbol = resolved.members[name]; + if (symbol && symbolIsValue(symbol)) { + return symbol; } if (resolved === anyFunctionType || resolved.callSignatures.length || resolved.constructSignatures.length) { const symbol = getPropertyOfObjectType(globalFunctionType, name); @@ -4682,6 +4684,9 @@ namespace ts { if (isJSConstructSignature) { minArgumentCount--; } + if (!thisParameter && isObjectLiteralMethod(declaration)) { + thisParameter = getContextualThisParameter(declaration); + } const classType = declaration.kind === SyntaxKind.Constructor ? getDeclaredTypeOfClassOrInterface(getMergedSymbol((declaration.parent).symbol)) @@ -4930,24 +4935,27 @@ namespace ts { } function getTypeListId(types: Type[]) { + let result = ""; if (types) { - switch (types.length) { - case 1: - return "" + types[0].id; - case 2: - return types[0].id + "," + types[1].id; - default: - let result = ""; - for (let i = 0; i < types.length; i++) { - if (i > 0) { - result += ","; - } - result += types[i].id; - } - return result; + const length = types.length; + let i = 0; + while (i < length) { + const startId = types[i].id; + let count = 1; + while (i + count < length && types[i + count].id === startId + count) { + count++; + } + if (result.length) { + result += ","; + } + result += startId; + if (count > 1) { + result += ":" + count; + } + i += count; } } - return ""; + return result; } // This function is used to propagate certain flags when creating new object type references and union types. @@ -4977,6 +4985,17 @@ namespace ts { return type; } + function cloneTypeReference(source: TypeReference): TypeReference { + const type = createObjectType(source.flags, source.symbol); + type.target = source.target; + type.typeArguments = source.typeArguments; + return type; + } + + function getTypeReferenceArity(type: TypeReference): number { + return type.target.typeParameters ? type.target.typeParameters.length : 0; + } + // Get type from reference to class or interface function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type { const type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); @@ -5030,7 +5049,7 @@ namespace ts { return getDeclaredTypeOfSymbol(symbol); } - function getTypeReferenceName(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): LeftHandSideExpression | EntityName { + function getTypeReferenceName(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): EntityNameOrEntityNameExpression | undefined { switch (node.kind) { case SyntaxKind.TypeReference: return (node).typeName; @@ -5039,8 +5058,9 @@ namespace ts { case SyntaxKind.ExpressionWithTypeArguments: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. - if (isSupportedExpressionWithTypeArguments(node)) { - return (node).expression; + const expr = (node).expression; + if (isEntityNameExpression(expr)) { + return expr; } // fall through; @@ -5051,7 +5071,7 @@ namespace ts { function resolveTypeReferenceName( node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, - typeReferenceName: LeftHandSideExpression | EntityName) { + typeReferenceName: EntityNameExpression | EntityName) { if (!typeReferenceName) { return unknownSymbol; @@ -5092,15 +5112,14 @@ namespace ts { const typeReferenceName = getTypeReferenceName(node); symbol = resolveTypeReferenceName(node, typeReferenceName); type = getTypeReferenceType(node, symbol); - - links.resolvedSymbol = symbol; - links.resolvedType = type; } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - const typeNameOrExpression = node.kind === SyntaxKind.TypeReference ? (node).typeName : - isSupportedExpressionWithTypeArguments(node) ? (node).expression : - undefined; + const typeNameOrExpression: EntityNameOrEntityNameExpression = node.kind === SyntaxKind.TypeReference + ? (node).typeName + : isEntityNameExpression((node).expression) + ? (node).expression + : undefined; symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; type = symbol === unknownSymbol ? unknownType : symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : @@ -5219,16 +5238,47 @@ namespace ts { return links.resolvedType; } - function createTupleType(elementTypes: Type[]) { - const id = getTypeListId(elementTypes); - return tupleTypes[id] || (tupleTypes[id] = createNewTupleType(elementTypes)); + // We represent tuple types as type references to synthesized generic interface types created by + // this function. The types are of the form: + // + // interface Tuple extends Array { 0: T0, 1: T1, 2: T2, ... } + // + // Note that the generic type created by this function has no symbol associated with it. The same + // is true for each of the synthesized type parameters. + function createTupleTypeOfArity(arity: number): GenericType { + const typeParameters: TypeParameter[] = []; + const properties: Symbol[] = []; + for (let i = 0; i < arity; i++) { + const typeParameter = createType(TypeFlags.TypeParameter); + typeParameters.push(typeParameter); + const property = createSymbol(SymbolFlags.Property | SymbolFlags.Transient, "" + i); + property.type = typeParameter; + properties.push(property); + } + const type = createObjectType(TypeFlags.Tuple | TypeFlags.Reference); + type.typeParameters = typeParameters; + type.outerTypeParameters = undefined; + type.localTypeParameters = typeParameters; + type.instantiations = createMap(); + type.instantiations[getTypeListId(type.typeParameters)] = type; + type.target = type; + type.typeArguments = type.typeParameters; + type.thisType = createType(TypeFlags.TypeParameter | TypeFlags.ThisType); + type.thisType.constraint = type; + type.declaredProperties = properties; + type.declaredCallSignatures = emptyArray; + type.declaredConstructSignatures = emptyArray; + type.declaredStringIndexInfo = undefined; + type.declaredNumberIndexInfo = undefined; + return type; } - function createNewTupleType(elementTypes: Type[]) { - const propagatedFlags = getPropagatingFlagsOfTypes(elementTypes, /*excludeKinds*/ 0); - const type = createObjectType(TypeFlags.Tuple | propagatedFlags); - type.elementTypes = elementTypes; - return type; + function getTupleTypeOfArity(arity: number): GenericType { + return tupleTypes[arity] || (tupleTypes[arity] = createTupleTypeOfArity(arity)); + } + + function createTupleType(elementTypes: Type[]) { + return createTypeReference(getTupleTypeOfArity(elementTypes.length), elementTypes); } function getTypeFromTupleTypeNode(node: TupleTypeNode): Type { @@ -5329,12 +5379,12 @@ namespace ts { } } - // We deduplicate the constituent types based on object identity. If the subtypeReduction flag is - // specified we also reduce the constituent type set to only include types that aren't subtypes of - // other types. Subtype reduction is expensive for large union types and is possible only when union + // We sort and deduplicate the constituent types based on object identity. If the subtypeReduction + // flag is specified we also reduce the constituent type set to only include types that aren't subtypes + // of other types. Subtype reduction is expensive for large union types and is possible only when union // types are known not to circularly reference themselves (as is the case with union types created by // expression constructs such as array literals and the || and ?: operators). Named types can - // circularly reference themselves and therefore cannot be deduplicated during their declaration. + // circularly reference themselves and therefore cannot be subtype reduced during their declaration. // For example, "type Item = string | (() => Item" is a named type that circularly references itself. function getUnionType(types: Type[], subtypeReduction?: boolean, aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type { if (types.length === 0) { @@ -5356,15 +5406,23 @@ namespace ts { typeSet.containsUndefined ? typeSet.containsNonWideningType ? undefinedType : undefinedWideningType : neverType; } - else if (typeSet.length === 1) { - return typeSet[0]; + return getUnionTypeFromSortedList(typeSet, aliasSymbol, aliasTypeArguments); + } + + // This function assumes the constituent type list is sorted and deduplicated. + function getUnionTypeFromSortedList(types: Type[], aliasSymbol?: Symbol, aliasTypeArguments?: Type[]): Type { + if (types.length === 0) { + return neverType; } - const id = getTypeListId(typeSet); + if (types.length === 1) { + return types[0]; + } + const id = getTypeListId(types); let type = unionTypes[id]; if (!type) { - const propagatedFlags = getPropagatingFlagsOfTypes(typeSet, /*excludeKinds*/ TypeFlags.Nullable); + const propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ TypeFlags.Nullable); type = unionTypes[id] = createObjectType(TypeFlags.Union | propagatedFlags); - type.types = typeSet; + type.types = types; type.aliasSymbol = aliasSymbol; type.aliasTypeArguments = aliasTypeArguments; } @@ -5456,7 +5514,7 @@ namespace ts { function getLiteralTypeForText(flags: TypeFlags, text: string) { const map = flags & TypeFlags.StringLiteral ? stringLiteralTypes : numericLiteralTypes; - return hasProperty(map, text) ? map[text] : map[text] = createLiteralType(flags, text); + return map[text] || (map[text] = createLiteralType(flags, text)); } function getTypeFromLiteralTypeNode(node: LiteralTypeNode): Type { @@ -5532,11 +5590,19 @@ namespace ts { return nullType; case SyntaxKind.NeverKeyword: return neverType; + case SyntaxKind.JSDocNullKeyword: + return nullType; + case SyntaxKind.JSDocUndefinedKeyword: + return undefinedType; + case SyntaxKind.JSDocNeverKeyword: + return neverType; case SyntaxKind.ThisType: case SyntaxKind.ThisKeyword: return getTypeFromThisTypeNode(node); case SyntaxKind.LiteralType: return getTypeFromLiteralTypeNode(node); + case SyntaxKind.JSDocLiteralType: + return getTypeFromLiteralTypeNode((node).literal); case SyntaxKind.TypeReference: case SyntaxKind.JSDocTypeReference: return getTypeFromTypeReference(node); @@ -5823,9 +5889,6 @@ namespace ts { if (type.flags & TypeFlags.Reference) { return createTypeReference((type).target, instantiateList((type).typeArguments, mapper, instantiateType)); } - if (type.flags & TypeFlags.Tuple) { - return createTupleType(instantiateList((type).elementTypes, mapper, instantiateType)); - } if (type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Primitive)) { return getUnionType(instantiateList((type).types, mapper, instantiateType), /*subtypeReduction*/ false, type.aliasSymbol, mapper.targetTypes); } @@ -5917,6 +5980,13 @@ namespace ts { return isTypeRelatedTo(source, target, assignableRelation); } + // A type S is considered to be an instance of a type T if S and T are the same type or if S is a + // subtype of T but not structurally identical to T. This specifically means that two distinct but + // structurally identical types (such as two classes) are not considered instances of each other. + function isTypeInstanceOf(source: Type, target: Type): boolean { + return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target); + } + /** * This is *not* a bi-directional relationship. * If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'. @@ -6238,6 +6308,18 @@ namespace ts { reportError(message, sourceType, targetType); } + function tryElaborateErrorsForPrimitivesAndObjects(source: Type, target: Type) { + const sourceType = typeToString(source); + const targetType = typeToString(target); + + if ((globalStringType === source && stringType === target) || + (globalNumberType === source && numberType === target) || + (globalBooleanType === source && booleanType === target) || + (getGlobalESSymbolType() === source && esSymbolType === target)) { + reportError(Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); + } + } + // Compare two types and return // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or @@ -6361,6 +6443,9 @@ namespace ts { } if (reportErrors) { + if (source.flags & TypeFlags.ObjectType && target.flags & TypeFlags.Primitive) { + tryElaborateErrorsForPrimitivesAndObjects(source, target); + } reportRelationError(headMessage, source, target); } return Ternary.False; @@ -6568,7 +6653,7 @@ namespace ts { } sourceStack[depth] = source; targetStack[depth] = target; - maybeStack[depth] = {}; + maybeStack[depth] = createMap(); maybeStack[depth][id] = RelationComparisonResult.Succeeded; depth++; const saveExpandingFlags = expandingFlags; @@ -6599,7 +6684,7 @@ namespace ts { const maybeCache = maybeStack[depth]; // If result is definitely true, copy assumptions to global cache, else copy to next level up const destinationCache = (result === Ternary.True || depth === 0) ? relation : maybeStack[depth - 1]; - copyMap(maybeCache, destinationCache); + copyProperties(maybeCache, destinationCache); } else { // A false result goes straight into global cache (when something is false under assumptions it @@ -7139,8 +7224,8 @@ namespace ts { * Check if a Type was written as a tuple type literal. * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. */ - function isTupleType(type: Type): type is TupleType { - return !!(type.flags & TypeFlags.Tuple); + function isTupleType(type: Type): boolean { + return !!(type.flags & TypeFlags.Reference && (type).target.flags & TypeFlags.Tuple); } function getFalsyFlagsOfTypes(types: Type[]): TypeFlags { @@ -7209,7 +7294,7 @@ namespace ts { } function transformTypeOfMembers(type: Type, f: (propertyType: Type) => Type) { - const members: SymbolTable = {}; + const members = createMap(); for (const property of getPropertiesOfObjectType(type)) { const original = getTypeOfSymbol(property); const updated = f(original); @@ -7272,11 +7357,8 @@ namespace ts { if (type.flags & TypeFlags.Union) { return getUnionType(map((type).types, getWidenedConstituentType)); } - if (isArrayType(type)) { - return createArrayType(getWidenedType((type).typeArguments[0])); - } - if (isTupleType(type)) { - return createTupleType(map(type.elementTypes, getWidenedType)); + if (isArrayType(type) || isTupleType(type)) { + return createTypeReference((type).target, map((type).typeArguments, getWidenedType)); } } return type; @@ -7302,11 +7384,8 @@ namespace ts { } } } - if (isArrayType(type)) { - return reportWideningErrorsInType((type).typeArguments[0]); - } - if (isTupleType(type)) { - for (const t of type.elementTypes) { + if (isArrayType(type) || isTupleType(type)) { + for (const t of (type).typeArguments) { if (reportWideningErrorsInType(t)) { errorReported = true; } @@ -7416,7 +7495,6 @@ namespace ts { function couldContainTypeParameters(type: Type): boolean { return !!(type.flags & TypeFlags.TypeParameter || type.flags & TypeFlags.Reference && forEach((type).typeArguments, couldContainTypeParameters) || - type.flags & TypeFlags.Tuple && forEach((type).elementTypes, couldContainTypeParameters) || type.flags & TypeFlags.Anonymous && type.symbol && type.symbol.flags & (SymbolFlags.Method | SymbolFlags.TypeLiteral | SymbolFlags.Class) || type.flags & TypeFlags.UnionOrIntersection && couldUnionOrIntersectionContainTypeParameters(type)); } @@ -7433,7 +7511,7 @@ namespace ts { let targetStack: Type[]; let depth = 0; let inferiority = 0; - const visited: Map = {}; + const visited = createMap(); inferFromTypes(source, target); function isInProcess(source: Type, target: Type) { @@ -7519,14 +7597,6 @@ namespace ts { inferFromTypes(sourceTypes[i], targetTypes[i]); } } - else if (source.flags & TypeFlags.Tuple && target.flags & TypeFlags.Tuple && (source).elementTypes.length === (target).elementTypes.length) { - // If source and target are tuples of the same size, infer from element types - const sourceTypes = (source).elementTypes; - const targetTypes = (target).elementTypes; - for (let i = 0; i < sourceTypes.length; i++) { - inferFromTypes(sourceTypes[i], targetTypes[i]); - } - } else if (target.flags & TypeFlags.UnionOrIntersection) { const targetTypes = (target).types; let typeParameterCount = 0; @@ -7567,7 +7637,7 @@ namespace ts { return; } const key = source.id + "," + target.id; - if (hasProperty(visited, key)) { + if (visited[key]) { return; } visited[key] = true; @@ -7801,8 +7871,49 @@ namespace ts { return false; } - function rootContainsMatchingReference(source: Node, target: Node) { - return target.kind === SyntaxKind.PropertyAccessExpression && containsMatchingReference(source, (target).expression); + // Return true if target is a property access xxx.yyy, source is a property access xxx.zzz, the declared + // type of xxx is a union type, and yyy is a property that is possibly a discriminant. We consider a property + // a possible discriminant if its type differs in the constituents of containing union type, and if every + // choice is a unit type or a union of unit types. + function containsMatchingReferenceDiscriminant(source: Node, target: Node) { + return target.kind === SyntaxKind.PropertyAccessExpression && + containsMatchingReference(source, (target).expression) && + isDiscriminantProperty(getDeclaredTypeOfReference((target).expression), (target).name.text); + } + + function getDeclaredTypeOfReference(expr: Node): Type { + if (expr.kind === SyntaxKind.Identifier) { + return getTypeOfSymbol(getResolvedSymbol(expr)); + } + if (expr.kind === SyntaxKind.PropertyAccessExpression) { + const type = getDeclaredTypeOfReference((expr).expression); + return type && getTypeOfPropertyOfType(type, (expr).name.text); + } + return undefined; + } + + function isDiscriminantProperty(type: Type, name: string) { + if (type && type.flags & TypeFlags.Union) { + let prop = getPropertyOfType(type, name); + if (!prop) { + // The type may be a union that includes nullable or primitive types. If filtering + // those out produces a different type, get the property from that type instead. + // Effectively, we're checking if this *could* be a discriminant property once nullable + // and primitive types are removed by other type guards. + const filteredType = getTypeWithFacts(type, TypeFacts.Discriminatable); + if (filteredType !== type && filteredType.flags & TypeFlags.Union) { + prop = getPropertyOfType(filteredType, name); + } + } + if (prop && prop.flags & SymbolFlags.SyntheticProperty) { + if ((prop).isDiscriminantProperty === undefined) { + (prop).isDiscriminantProperty = !(prop).hasCommonType && + isUnitUnionType(getTypeOfSymbol(prop)); + } + return (prop).isDiscriminantProperty; + } + } + return false; } function isOrContainsMatchingReference(source: Node, target: Node) { @@ -7848,10 +7959,10 @@ namespace ts { // For example, when a variable of type number | string | boolean is assigned a value of type number | boolean, // we remove type string. function getAssignmentReducedType(declaredType: UnionType, assignedType: Type) { - if (declaredType !== assignedType && declaredType.flags & TypeFlags.Union) { - const reducedTypes = filter(declaredType.types, t => typeMaybeAssignableTo(assignedType, t)); - if (reducedTypes.length) { - return reducedTypes.length === 1 ? reducedTypes[0] : getUnionType(reducedTypes); + if (declaredType !== assignedType) { + const reducedType = filterType(declaredType, t => typeMaybeAssignableTo(assignedType, t)); + if (reducedType !== neverType) { + return reducedType; } } return declaredType; @@ -7865,6 +7976,14 @@ namespace ts { return result; } + function isFunctionObjectType(type: ObjectType): boolean { + // We do a quick check for a "bind" property before performing the more expensive subtype + // check. This gives us a quicker out in the common case where an object type is not a function. + const resolved = resolveStructuredTypeMembers(type); + return !!(resolved.callSignatures.length || resolved.constructSignatures.length || + resolved.members["bind"] && isTypeSubtypeOf(type, globalFunctionType)); + } + function getTypeFacts(type: Type): TypeFacts { const flags = type.flags; if (flags & TypeFlags.String) { @@ -7893,8 +8012,7 @@ namespace ts { type === falseType ? TypeFacts.FalseFacts : TypeFacts.TrueFacts; } if (flags & TypeFlags.ObjectType) { - const resolved = resolveStructuredTypeMembers(type); - return resolved.callSignatures.length || resolved.constructSignatures.length || isTypeSubtypeOf(type, globalFunctionType) ? + return isFunctionObjectType(type) ? strictNullChecks ? TypeFacts.FunctionStrictFacts : TypeFacts.FunctionFacts : strictNullChecks ? TypeFacts.ObjectStrictFacts : TypeFacts.ObjectFacts; } @@ -7909,7 +8027,7 @@ namespace ts { } if (flags & TypeFlags.TypeParameter) { const constraint = getConstraintOfTypeParameter(type); - return constraint ? getTypeFacts(constraint) : TypeFacts.All; + return getTypeFacts(constraint || emptyObjectType); } if (flags & TypeFlags.UnionOrIntersection) { return getTypeFactsOfTypes((type).types); @@ -7918,25 +8036,7 @@ namespace ts { } function getTypeWithFacts(type: Type, include: TypeFacts) { - if (!(type.flags & TypeFlags.Union)) { - return getTypeFacts(type) & include ? type : neverType; - } - let firstType: Type; - let types: Type[]; - for (const t of (type as UnionType).types) { - if (getTypeFacts(t) & include) { - if (!firstType) { - firstType = t; - } - else { - if (!types) { - types = [firstType]; - } - types.push(t); - } - } - } - return firstType ? types ? getUnionType(types) : firstType : neverType; + return filterType(type, t => (getTypeFacts(t) & include) !== 0); } function getTypeWithDefault(type: Type, defaultExpression: Expression) { @@ -8092,10 +8192,32 @@ namespace ts { return source.flags & TypeFlags.Union ? !forEach((source).types, t => !contains(types, t)) : contains(types, source); } + function isTypeSubsetOf(source: Type, target: Type) { + return source === target || target.flags & TypeFlags.Union && isTypeSubsetOfUnion(source, target); + } + + function isTypeSubsetOfUnion(source: Type, target: UnionType) { + if (source.flags & TypeFlags.Union) { + for (const t of (source).types) { + if (!containsType(target.types, t)) { + return false; + } + } + return true; + } + if (source.flags & TypeFlags.EnumLiteral && target.flags & TypeFlags.Enum && (source).baseType === target) { + return true; + } + return containsType(target.types, source); + } + function filterType(type: Type, f: (t: Type) => boolean): Type { - return type.flags & TypeFlags.Union ? - getUnionType(filter((type).types, f)) : - f(type) ? type : neverType; + if (type.flags & TypeFlags.Union) { + const types = (type).types; + const filtered = filter(types, f); + return filtered === types ? type : getUnionTypeFromSortedList(filtered); + } + return f(type) ? type : neverType; } function isIncomplete(flowType: FlowType) { @@ -8110,7 +8232,7 @@ namespace ts { return incomplete ? { flags: 0, type } : type; } - function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, includeOuterFunctions: boolean) { + function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, flowContainer: Node) { let key: string; if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) { return declaredType; @@ -8162,7 +8284,7 @@ namespace ts { else if (flow.flags & FlowFlags.Start) { // Check if we should continue with the control flow of the containing function. const container = (flow).container; - if (container && includeOuterFunctions) { + if (container && container !== flowContainer && reference.kind !== SyntaxKind.PropertyAccessExpression) { flow = container.flowNode; continue; } @@ -8230,7 +8352,7 @@ namespace ts { if (isMatchingReference(reference, expr)) { type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd); } - else if (isMatchingPropertyAccess(expr)) { + else if (isMatchingReferenceDiscriminant(expr)) { type = narrowTypeByDiscriminant(type, expr, t => narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd)); } return createFlowType(type, isIncomplete(flowType)); @@ -8238,6 +8360,7 @@ namespace ts { function getTypeAtFlowBranchLabel(flow: FlowLabel): FlowType { const antecedentTypes: Type[] = []; + let subtypeReduction = false; let seenIncomplete = false; for (const antecedent of flow.antecedents) { const flowType = getTypeAtFlowNode(antecedent); @@ -8252,18 +8375,24 @@ namespace ts { if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); } + // If an antecedent type is not a subset of the declared type, we need to perform + // subtype reduction. This happens when a "foreign" type is injected into the control + // flow using the instanceof operator or a user defined type predicate. + if (!isTypeSubsetOf(type, declaredType)) { + subtypeReduction = true; + } if (isIncomplete(flowType)) { seenIncomplete = true; } } - return createFlowType(getUnionType(antecedentTypes), seenIncomplete); + return createFlowType(getUnionType(antecedentTypes, subtypeReduction), seenIncomplete); } function getTypeAtFlowLoopLabel(flow: FlowLabel): FlowType { // If we have previously computed the control flow type for the reference at // this flow loop junction, return the cached type. const id = getFlowNodeId(flow); - const cache = flowLoopCaches[id] || (flowLoopCaches[id] = {}); + const cache = flowLoopCaches[id] || (flowLoopCaches[id] = createMap()); if (!key) { key = getFlowCacheKey(reference); } @@ -8282,13 +8411,19 @@ namespace ts { // Add the flow loop junction and reference to the in-process stack and analyze // each antecedent code path. const antecedentTypes: Type[] = []; + let subtypeReduction = false; + let firstAntecedentType: FlowType; flowLoopNodes[flowLoopCount] = flow; flowLoopKeys[flowLoopCount] = key; flowLoopTypes[flowLoopCount] = antecedentTypes; for (const antecedent of flow.antecedents) { flowLoopCount++; - const type = getTypeFromFlowType(getTypeAtFlowNode(antecedent)); + const flowType = getTypeAtFlowNode(antecedent); flowLoopCount--; + if (!firstAntecedentType) { + firstAntecedentType = flowType; + } + const type = getTypeFromFlowType(flowType); // If we see a value appear in the cache it is a sign that control flow analysis // was restarted and completed by checkExpressionCached. We can simply pick up // the resulting type and bail out. @@ -8298,6 +8433,12 @@ namespace ts { if (!contains(antecedentTypes, type)) { antecedentTypes.push(type); } + // If an antecedent type is not a subset of the declared type, we need to perform + // subtype reduction. This happens when a "foreign" type is injected into the control + // flow using the instanceof operator or a user defined type predicate. + if (!isTypeSubsetOf(type, declaredType)) { + subtypeReduction = true; + } // If the type at a particular antecedent path is the declared type there is no // reason to process more antecedents since the only possible outcome is subtypes // that will be removed in the final union type anyway. @@ -8305,13 +8446,20 @@ namespace ts { break; } } - return cache[key] = getUnionType(antecedentTypes); + // The result is incomplete if the first antecedent (the non-looping control flow path) + // is incomplete. + const result = getUnionType(antecedentTypes, subtypeReduction); + if (isIncomplete(firstAntecedentType)) { + return createFlowType(result, /*incomplete*/ true); + } + return cache[key] = result; } - function isMatchingPropertyAccess(expr: Expression) { + function isMatchingReferenceDiscriminant(expr: Expression) { return expr.kind === SyntaxKind.PropertyAccessExpression && + declaredType.flags & TypeFlags.Union && isMatchingReference(reference, (expr).expression) && - (declaredType.flags & TypeFlags.Union) !== 0; + isDiscriminantProperty(declaredType, (expr).name.text); } function narrowTypeByDiscriminant(type: Type, propAccess: PropertyAccessExpression, narrowType: (t: Type) => Type): Type { @@ -8325,10 +8473,10 @@ namespace ts { if (isMatchingReference(reference, expr)) { return getTypeWithFacts(type, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy); } - if (isMatchingPropertyAccess(expr)) { + if (isMatchingReferenceDiscriminant(expr)) { return narrowTypeByDiscriminant(type, expr, t => getTypeWithFacts(t, assumeTrue ? TypeFacts.Truthy : TypeFacts.Falsy)); } - if (rootContainsMatchingReference(reference, expr)) { + if (containsMatchingReferenceDiscriminant(reference, expr)) { return declaredType; } return type; @@ -8357,13 +8505,13 @@ namespace ts { if (isMatchingReference(reference, right)) { return narrowTypeByEquality(type, operator, left, assumeTrue); } - if (isMatchingPropertyAccess(left)) { + if (isMatchingReferenceDiscriminant(left)) { return narrowTypeByDiscriminant(type, left, t => narrowTypeByEquality(t, operator, right, assumeTrue)); } - if (isMatchingPropertyAccess(right)) { + if (isMatchingReferenceDiscriminant(right)) { return narrowTypeByDiscriminant(type, right, t => narrowTypeByEquality(t, operator, left, assumeTrue)); } - if (rootContainsMatchingReference(reference, left) || rootContainsMatchingReference(reference, right)) { + if (containsMatchingReferenceDiscriminant(reference, left) || containsMatchingReferenceDiscriminant(reference, right)) { return declaredType; } break; @@ -8418,16 +8566,16 @@ namespace ts { } if (assumeTrue && !(type.flags & TypeFlags.Union)) { // We narrow a non-union type to an exact primitive type if the non-union type - // is a supertype of that primtive type. For example, type 'any' can be narrowed + // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. - const targetType = getProperty(typeofTypesByName, literal.text); + const targetType = typeofTypesByName[literal.text]; if (targetType && isTypeSubtypeOf(targetType, type)) { return targetType; } } const facts = assumeTrue ? - getProperty(typeofEQFacts, literal.text) || TypeFacts.TypeofEQHostObject : - getProperty(typeofNEFacts, literal.text) || TypeFacts.TypeofNEHostObject; + typeofEQFacts[literal.text] || TypeFacts.TypeofEQHostObject : + typeofNEFacts[literal.text] || TypeFacts.TypeofNEHostObject; return getTypeWithFacts(type, facts); } @@ -8458,10 +8606,6 @@ namespace ts { } return type; } - // We never narrow type any in an instanceof guard - if (isTypeAny(type)) { - return type; - } // Check that right operand is a function type with a prototype property const rightType = checkExpression(expr.right); @@ -8479,6 +8623,11 @@ namespace ts { } } + // Don't narrow from 'any' if the target type is exactly 'Object' or 'Function' + if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) { + return type; + } + if (!targetType) { // Target type is type of construct signature let constructSignatures: Signature[]; @@ -8502,29 +8651,30 @@ namespace ts { function getNarrowedType(type: Type, candidate: Type, assumeTrue: boolean) { if (!assumeTrue) { - return type.flags & TypeFlags.Union ? - getUnionType(filter((type).types, t => !isTypeSubtypeOf(t, candidate))) : - type; + return filterType(type, t => !isTypeInstanceOf(t, candidate)); } - // If the current type is a union type, remove all constituents that aren't assignable to + // If the current type is a union type, remove all constituents that couldn't be instances of // the candidate type. If one or more constituents remain, return a union of those. if (type.flags & TypeFlags.Union) { - const assignableConstituents = filter((type).types, t => isTypeAssignableTo(t, candidate)); - if (assignableConstituents.length) { - return getUnionType(assignableConstituents); + const assignableType = filterType(type, t => isTypeInstanceOf(t, candidate)); + if (assignableType !== neverType) { + return assignableType; } } - // If the candidate type is assignable to the target type, narrow to the candidate type. - // Otherwise, if the current type is assignable to the candidate, keep the current type. - // Otherwise, the types are completely unrelated, so narrow to the empty type. + // If the candidate type is a subtype of the target type, narrow to the candidate type. + // Otherwise, if the target type is assignable to the candidate type, keep the target type. + // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate + // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the + // two types. const targetType = type.flags & TypeFlags.TypeParameter ? getApparentType(type) : type; - return isTypeAssignableTo(candidate, targetType) ? candidate : + return isTypeSubtypeOf(candidate, targetType) ? candidate : isTypeAssignableTo(type, candidate) ? type : - getIntersectionType([type, candidate]); + isTypeAssignableTo(candidate, targetType) ? candidate : + getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type: Type, callExpression: CallExpression, assumeTrue: boolean): Type { - if (type.flags & TypeFlags.Any || !hasMatchingArgument(callExpression, reference)) { + if (!hasMatchingArgument(callExpression, reference)) { return type; } const signature = getResolvedSignature(callExpression); @@ -8532,6 +8682,12 @@ namespace ts { if (!predicate) { return type; } + + // Don't narrow from 'any' if the predicate type is exactly 'Object' or 'Function' + if (isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType)) { + return type; + } + if (isIdentifierTypePredicate(predicate)) { const predicateArgument = callExpression.arguments[predicate.parameterIndex]; if (predicateArgument) { @@ -8617,21 +8773,52 @@ namespace ts { function getControlFlowContainer(node: Node): Node { while (true) { node = node.parent; - if (isFunctionLike(node) || node.kind === SyntaxKind.ModuleBlock || node.kind === SyntaxKind.SourceFile || node.kind === SyntaxKind.PropertyDeclaration) { + if (isFunctionLike(node) && !getImmediatelyInvokedFunctionExpression(node) || + node.kind === SyntaxKind.ModuleBlock || + node.kind === SyntaxKind.SourceFile || + node.kind === SyntaxKind.PropertyDeclaration) { return node; } } } - function isDeclarationIncludedInFlow(reference: Node, declaration: Declaration, includeOuterFunctions: boolean) { - const declarationContainer = getControlFlowContainer(declaration); - let container = getControlFlowContainer(reference); - while (container !== declarationContainer && - (container.kind === SyntaxKind.FunctionExpression || container.kind === SyntaxKind.ArrowFunction) && - (includeOuterFunctions || getImmediatelyInvokedFunctionExpression(container))) { - container = getControlFlowContainer(container); + // Check if a parameter is assigned anywhere within its declaring function. + function isParameterAssigned(symbol: Symbol) { + const func = getRootDeclaration(symbol.valueDeclaration).parent; + const links = getNodeLinks(func); + if (!(links.flags & NodeCheckFlags.AssignmentsMarked)) { + links.flags |= NodeCheckFlags.AssignmentsMarked; + if (!hasParentWithAssignmentsMarked(func)) { + markParameterAssignments(func); + } + } + return symbol.isAssigned || false; + } + + function hasParentWithAssignmentsMarked(node: Node) { + while (true) { + node = node.parent; + if (!node) { + return false; + } + if (isFunctionLike(node) && getNodeLinks(node).flags & NodeCheckFlags.AssignmentsMarked) { + return true; + } + } + } + + function markParameterAssignments(node: Node) { + if (node.kind === SyntaxKind.Identifier) { + if (isAssignmentTarget(node)) { + const symbol = getResolvedSymbol(node); + if (symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration).kind === SyntaxKind.Parameter) { + symbol.isAssigned = true; + } + } + } + else { + forEachChild(node, markParameterAssignments); } - return container === declarationContainer; } function checkIdentifier(node: Identifier): Type { @@ -8708,15 +8895,35 @@ namespace ts { checkNestedBlockScopedBinding(node, symbol); const type = getTypeOfSymbol(localOrExportSymbol); - if (!(localOrExportSymbol.flags & SymbolFlags.Variable) || isAssignmentTarget(node)) { + const declaration = localOrExportSymbol.valueDeclaration; + // We only narrow variables and parameters occurring in a non-assignment position. For all other + // entities we simply return the declared type. + if (!(localOrExportSymbol.flags & SymbolFlags.Variable) || isAssignmentTarget(node) || !declaration) { return type; } - const declaration = localOrExportSymbol.valueDeclaration; - const includeOuterFunctions = isReadonlySymbol(localOrExportSymbol); - const assumeInitialized = !strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || !declaration || - getRootDeclaration(declaration).kind === SyntaxKind.Parameter || isInAmbientContext(declaration) || - !isDeclarationIncludedInFlow(node, declaration, includeOuterFunctions); - const flowType = getFlowTypeOfReference(node, type, assumeInitialized, includeOuterFunctions); + // The declaration container is the innermost function that encloses the declaration of the variable + // or parameter. The flow container is the innermost function starting with which we analyze the control + // flow graph to determine the control flow based type. + const isParameter = getRootDeclaration(declaration).kind === SyntaxKind.Parameter; + const declarationContainer = getControlFlowContainer(declaration); + let flowContainer = getControlFlowContainer(node); + // When the control flow originates in a function expression or arrow function and we are referencing + // a const variable or parameter from an outer function, we extend the origin of the control flow + // analysis to include the immediately enclosing function. + while (flowContainer !== declarationContainer && + (flowContainer.kind === SyntaxKind.FunctionExpression || flowContainer.kind === SyntaxKind.ArrowFunction) && + (isReadonlySymbol(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { + flowContainer = getControlFlowContainer(flowContainer); + } + // We only look for uninitialized variables in strict null checking mode, and only when we can analyze + // the entire control flow graph from the variable's declaration (i.e. when the flow container and + // declaration container are the same). + const assumeInitialized = !strictNullChecks || (type.flags & TypeFlags.Any) !== 0 || isParameter || + flowContainer !== declarationContainer || isInAmbientContext(declaration); + const flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + // A variable is considered uninitialized when it is possible to analyze the entire control flow graph + // from declaration to use, and when the variable's declared type doesn't include undefined but the + // control flow based type does include undefined. if (!assumeInitialized && !(getFalsyFlags(type) & TypeFlags.Undefined) && getFalsyFlags(flowType) & TypeFlags.Undefined) { error(node, Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol)); // Return the declared type to reduce follow-on errors @@ -8956,20 +9163,17 @@ namespace ts { return getInferredClassType(classSymbol); } } - const type = getContextuallyTypedThisType(container); - if (type) { - return type; - } const thisType = getThisTypeOfDeclaration(container); if (thisType) { return thisType; } } + if (isClassLike(container.parent)) { const symbol = getSymbolOfNode(container.parent); const type = hasModifier(container, ModifierFlags.Static) ? getTypeOfSymbol(symbol) : (getDeclaredTypeOfSymbol(symbol)).thisType; - return getFlowTypeOfReference(node, type, /*assumeInitialized*/ true, /*includeOuterFunctions*/ true); + return getFlowTypeOfReference(node, type, /*assumeInitialized*/ true, /*flowContainer*/ undefined); } if (isInJavaScriptFile(node)) { @@ -9200,11 +9404,11 @@ namespace ts { } } - function getContextuallyTypedThisType(func: FunctionLikeDeclaration): Type { + function getContextualThisParameter(func: FunctionLikeDeclaration): Symbol { if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== SyntaxKind.ArrowFunction) { const contextualSignature = getContextualSignature(func); if (contextualSignature) { - return getThisTypeOfSignature(contextualSignature); + return contextualSignature.thisParameter; } } @@ -9275,7 +9479,7 @@ namespace ts { } } if (isBindingPattern(declaration.name)) { - return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true); + return getTypeFromBindingPattern(declaration.name, /*includePatternInType*/ true, /*reportErrors*/ false); } if (isBindingPattern(declaration.parent)) { const parentDeclaration = declaration.parent.parent; @@ -9380,6 +9584,11 @@ namespace ts { const binaryExpression = node.parent; const operator = binaryExpression.operatorToken.kind; if (operator >= SyntaxKind.FirstAssignment && operator <= SyntaxKind.LastAssignment) { + // Don't do this for special property assignments to avoid circularity + if (getSpecialPropertyAssignmentKind(binaryExpression) !== SpecialPropertyAssignmentKind.None) { + return undefined; + } + // In an assignment expression, the right operand is contextually typed by the type of the left operand. if (node === binaryExpression.right) { return checkExpression(binaryExpression.left); @@ -9764,7 +9973,7 @@ namespace ts { // 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] = []". if (inDestructuringPattern && elementTypes.length) { - const type = createNewTupleType(elementTypes); + const type = cloneTypeReference(createTupleType(elementTypes)); type.pattern = node; return type; } @@ -9778,7 +9987,7 @@ namespace ts { for (let i = elementTypes.length; i < patternElements.length; i++) { const patternElement = patternElements[i]; if (hasDefaultValue(patternElement)) { - elementTypes.push((contextualType).elementTypes[i]); + elementTypes.push((contextualType).typeArguments[i]); } else { if (patternElement.kind !== SyntaxKind.OmittedExpression) { @@ -9871,7 +10080,7 @@ namespace ts { // Grammar checking checkGrammarObjectLiteralExpression(node, inDestructuringPattern); - const propertiesTable: SymbolTable = {}; + const propertiesTable = createMap(); const propertiesArray: Symbol[] = []; const contextualType = getApparentTypeOfContextualType(node); const contextualTypeHasPattern = contextualType && contextualType.pattern && @@ -9962,7 +10171,7 @@ namespace ts { // type with those properties for which the binding pattern specifies a default value. if (contextualTypeHasPattern) { for (const prop of getPropertiesOfType(contextualType)) { - if (!hasProperty(propertiesTable, prop.name)) { + if (!propertiesTable[prop.name]) { if (!(prop.flags & SymbolFlags.Optional)) { error(prop.valueDeclaration || (prop).bindingElement, Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); @@ -10052,10 +10261,9 @@ namespace ts { const correspondingPropSymbol = getPropertyOfType(elementAttributesType, node.name.text); correspondingPropType = correspondingPropSymbol && getTypeOfSymbol(correspondingPropSymbol); if (isUnhyphenatedJsxName(node.name.text)) { - // Maybe there's a string indexer? - const indexerType = getIndexTypeOfType(elementAttributesType, IndexKind.String); - if (indexerType) { - correspondingPropType = indexerType; + const attributeType = getTypeOfPropertyOfType(elementAttributesType, getTextOfPropertyName(node.name)) || getIndexTypeOfType(elementAttributesType, IndexKind.String); + if (attributeType) { + correspondingPropType = attributeType; } else { // If there's no corresponding property with this name, error @@ -10090,7 +10298,7 @@ namespace ts { for (const prop of props) { // Is there a corresponding property in the element attributes type? Skip checking of properties // that have already been assigned to, as these are not actually pushed into the resulting type - if (!hasProperty(nameTable, prop.name)) { + if (!nameTable[prop.name]) { const targetPropSym = getPropertyOfType(elementAttributesType, prop.name); if (targetPropSym) { const msg = chainDiagnosticMessages(undefined, Diagnostics.Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property, prop.name); @@ -10412,7 +10620,7 @@ namespace ts { const targetAttributesType = getJsxElementAttributesType(node); - const nameTable: Map = {}; + const nameTable = createMap(); // Process this array in right-to-left order so we know which // attributes (mostly from spreads) are being overwritten and // thus should have their types ignored @@ -10436,7 +10644,7 @@ namespace ts { const targetProperties = getPropertiesOfType(targetAttributesType); for (let i = 0; i < targetProperties.length; i++) { if (!(targetProperties[i].flags & SymbolFlags.Optional) && - !hasProperty(nameTable, targetProperties[i].name)) { + !nameTable[targetProperties[i].name]) { error(node, Diagnostics.Property_0_is_missing_in_type_1, targetProperties[i].name, typeToString(targetAttributesType)); } @@ -10634,7 +10842,7 @@ namespace ts { !(prop.flags & SymbolFlags.Method && propType.flags & TypeFlags.Union)) { return propType; } - return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*includeOuterFunctions*/ false); + return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); } function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean { @@ -10759,10 +10967,11 @@ namespace ts { } // Check for compatible indexer types. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol)) { + const allowedNullableFlags = strictNullChecks ? 0 : TypeFlags.Nullable; + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.StringLike | TypeFlags.NumberLike | TypeFlags.ESSymbol | allowedNullableFlags)) { // Try to use a number indexer. - if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { + if (isTypeAnyOrAllConstituentTypesHaveKind(indexType, TypeFlags.NumberLike | allowedNullableFlags) || isForInVariableForNumericPropertyNames(node.argumentExpression)) { const numberIndexInfo = getIndexInfoOfType(objectType, IndexKind.Number); if (numberIndexInfo) { getNodeLinks(node).resolvedIndexInfo = numberIndexInfo; @@ -12146,6 +12355,12 @@ namespace ts { function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) { const len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); + if (context.thisParameter) { + if (!signature.thisParameter) { + signature.thisParameter = createTransientSymbol(context.thisParameter, undefined); + } + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); + } for (let i = 0; i < len; i++) { const parameter = signature.parameters[i]; const contextualParameterType = getTypeAtPosition(context, i); @@ -12889,8 +13104,11 @@ namespace ts { return checkDestructuringAssignment(element, type, contextualMapper); } else { + // We still need to check element expression here because we may need to set appropriate flag on the expression + // such as NodeCheckFlags.LexicalThis on "this"expression. + checkExpression(element); if (isTupleType(sourceType)) { - error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), (sourceType).elementTypes.length, elements.length); + error(element, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(sourceType), getTypeReferenceArity(sourceType), elements.length); } else { error(element, Diagnostics.Type_0_has_no_property_1, typeToString(sourceType), propName); @@ -13719,15 +13937,19 @@ namespace ts { } function checkClassForDuplicateDeclarations(node: ClassLikeDeclaration) { - const getter = 1, setter = 2, property = getter | setter; + const enum Accessor { + Getter = 1, + Setter = 2, + Property = Getter | Setter + } - const instanceNames: Map = {}; - const staticNames: Map = {}; + const instanceNames = createMap(); + const staticNames = createMap(); for (const member of node.members) { if (member.kind === SyntaxKind.Constructor) { for (const param of (member as ConstructorDeclaration).parameters) { if (isParameterPropertyDeclaration(param)) { - addName(instanceNames, param.name, (param.name as Identifier).text, property); + addName(instanceNames, param.name, (param.name as Identifier).text, Accessor.Property); } } } @@ -13739,24 +13961,24 @@ namespace ts { if (memberName) { switch (member.kind) { case SyntaxKind.GetAccessor: - addName(names, member.name, memberName, getter); + addName(names, member.name, memberName, Accessor.Getter); break; case SyntaxKind.SetAccessor: - addName(names, member.name, memberName, setter); + addName(names, member.name, memberName, Accessor.Setter); break; case SyntaxKind.PropertyDeclaration: - addName(names, member.name, memberName, property); + addName(names, member.name, memberName, Accessor.Property); break; } } } } - function addName(names: Map, location: Node, name: string, meaning: number) { - if (hasProperty(names, name)) { - const prev = names[name]; + function addName(names: Map, location: Node, name: string, meaning: Accessor) { + const prev = names[name]; + if (prev) { if (prev & meaning) { error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location)); } @@ -13771,7 +13993,7 @@ namespace ts { } function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) { - const names: Map = {}; + const names = createMap(); for (const member of node.members) { if (member.kind == SyntaxKind.PropertySignature) { let memberName: string; @@ -13785,7 +14007,7 @@ namespace ts { continue; } - if (hasProperty(names, memberName)) { + if (names[memberName]) { error(member.symbol.valueDeclaration.name, Diagnostics.Duplicate_identifier_0, memberName); error(member.name, Diagnostics.Duplicate_identifier_0, memberName); } @@ -13974,12 +14196,7 @@ namespace ts { checkSignatureDeclaration(node); if (node.kind === SyntaxKind.GetAccessor) { if (!isInAmbientContext(node) && nodeIsPresent(node.body) && (node.flags & NodeFlags.HasImplicitReturn)) { - if (node.flags & NodeFlags.HasExplicitReturn) { - if (compilerOptions.noImplicitReturns) { - error(node.name, Diagnostics.Not_all_code_paths_return_a_value); - } - } - else { + if (!(node.flags & NodeFlags.HasExplicitReturn)) { error(node.name, Diagnostics.A_get_accessor_must_return_a_value); } } @@ -14009,7 +14226,10 @@ namespace ts { checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, Diagnostics.get_and_set_accessor_must_have_the_same_this_type); } } - getTypeOfAccessors(getSymbolOfNode(node)); + const returnType = getTypeOfAccessors(getSymbolOfNode(node)); + if (node.kind === SyntaxKind.GetAccessor) { + checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); + } } if (node.parent.kind !== SyntaxKind.ObjectLiteralExpression) { checkSourceElement(node.body); @@ -14997,22 +15217,20 @@ namespace ts { function checkUnusedLocalsAndParameters(node: Node): void { if (node.parent.kind !== SyntaxKind.InterfaceDeclaration && noUnusedIdentifiers && !isInAmbientContext(node)) { for (const key in node.locals) { - if (hasProperty(node.locals, key)) { - const local = node.locals[key]; - if (!local.isReferenced) { - if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) { - const parameter = local.valueDeclaration; - if (compilerOptions.noUnusedParameters && - !isParameterPropertyDeclaration(parameter) && - !parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(parameter)) { - error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); - } - } - else if (compilerOptions.noUnusedLocals) { - forEach(local.declarations, d => error(d.name || d, Diagnostics._0_is_declared_but_never_used, local.name)); + const local = node.locals[key]; + if (!local.isReferenced) { + if (local.valueDeclaration && local.valueDeclaration.kind === SyntaxKind.Parameter) { + const parameter = local.valueDeclaration; + if (compilerOptions.noUnusedParameters && + !isParameterPropertyDeclaration(parameter) && + !parameterIsThisKeyword(parameter) && + !parameterNameStartsWithUnderscore(parameter)) { + error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } + else if (compilerOptions.noUnusedLocals) { + forEach(local.declarations, d => error(d.name || d, Diagnostics._0_is_declared_but_never_used, local.name)); + } } } } @@ -15038,7 +15256,7 @@ namespace ts { else if (member.kind === SyntaxKind.Constructor) { for (const parameter of (member).parameters) { if (!parameter.symbol.isReferenced && getModifierFlags(parameter) & ModifierFlags.Private) { - error(parameter.name, Diagnostics._0_is_declared_but_never_used, parameter.symbol.name); + error(parameter.name, Diagnostics.Property_0_is_declared_but_never_used, parameter.symbol.name); } } } @@ -15069,13 +15287,11 @@ namespace ts { function checkUnusedModuleMembers(node: ModuleDeclaration | SourceFile): void { if (compilerOptions.noUnusedLocals && !isInAmbientContext(node)) { for (const key in node.locals) { - if (hasProperty(node.locals, key)) { - const local = node.locals[key]; - if (!local.isReferenced && !local.exportSymbol) { - for (const declaration of local.declarations) { - if (!isAmbientModule(declaration)) { - error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name); - } + const local = node.locals[key]; + if (!local.isReferenced && !local.exportSymbol) { + for (const declaration of local.declarations) { + if (!isAmbientModule(declaration)) { + error(declaration.name, Diagnostics._0_is_declared_but_never_used, local.name); } } } @@ -16084,7 +16300,7 @@ namespace ts { else { const identifierName = (catchClause.variableDeclaration.name).text; const locals = catchClause.block.locals; - if (locals && hasProperty(locals, identifierName)) { + if (locals) { const localSymbol = locals[identifierName]; if (localSymbol && (localSymbol.flags & SymbolFlags.BlockScopedVariable) !== 0) { grammarErrorOnNode(localSymbol.valueDeclaration, Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, identifierName); @@ -16321,7 +16537,7 @@ namespace ts { const implementedTypeNodes = getClassImplementsHeritageClauseElements(node); if (implementedTypeNodes) { for (const typeRefNode of implementedTypeNodes) { - if (!isSupportedExpressionWithTypeArguments(typeRefNode)) { + if (!isEntityNameExpression(typeRefNode.expression)) { error(typeRefNode.expression, Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments); } checkTypeReferenceNode(typeRefNode); @@ -16505,18 +16721,18 @@ namespace ts { return true; } - const seen: Map<{ prop: Symbol; containingType: Type }> = {}; + const seen = createMap<{ prop: Symbol; containingType: Type }>(); forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen[p.name] = { prop: p, containingType: type }; }); let ok = true; for (const base of baseTypes) { const properties = getPropertiesOfObjectType(getTypeWithThisArgument(base, type.thisType)); for (const prop of properties) { - if (!hasProperty(seen, prop.name)) { + const existing = seen[prop.name]; + if (!existing) { seen[prop.name] = { prop: prop, containingType: base }; } else { - const existing = seen[prop.name]; const isInheritedProperty = existing.containingType !== type; if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) { ok = false; @@ -16563,7 +16779,7 @@ namespace ts { checkObjectTypeForDuplicateDeclarations(node); } forEach(getInterfaceBaseTypeNodes(node), heritageElement => { - if (!isSupportedExpressionWithTypeArguments(heritageElement)) { + if (!isEntityNameExpression(heritageElement.expression)) { error(heritageElement.expression, Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments); } checkTypeReferenceNode(heritageElement); @@ -16963,11 +17179,6 @@ namespace ts { } } - if (compilerOptions.noImplicitAny && !node.body) { - // Ambient shorthand module is an implicit any - reportImplicitAnyError(node, anyType); - } - if (node.body) { checkSourceElement(node.body); if (!isGlobalScopeAugmentation(node)) { @@ -17028,20 +17239,21 @@ namespace ts { } } - function getFirstIdentifier(node: EntityName | Expression): Identifier { - while (true) { - if (node.kind === SyntaxKind.QualifiedName) { - node = (node).left; - } - else if (node.kind === SyntaxKind.PropertyAccessExpression) { - node = (node).expression; - } - else { - break; - } + function getFirstIdentifier(node: EntityNameOrEntityNameExpression): Identifier { + switch (node.kind) { + case SyntaxKind.Identifier: + return node; + case SyntaxKind.QualifiedName: + do { + node = (node).left; + } while (node.kind !== SyntaxKind.Identifier); + return node; + case SyntaxKind.PropertyAccessExpression: + do { + node = (node).expression; + } while (node.kind !== SyntaxKind.Identifier); + return node; } - Debug.assert(node.kind === SyntaxKind.Identifier); - return node; } function checkExternalImportOrExportDeclaration(node: ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration): boolean { @@ -17470,11 +17682,10 @@ namespace ts { } function checkSourceFile(node: SourceFile) { - const start = performance.mark(); - + performance.mark("beforeCheck"); checkSourceFileWorker(node); - - performance.measure("Check", start); + performance.mark("afterCheck"); + performance.measure("Check", "beforeCheck", "afterCheck"); } // Fully type check a source file and collect the relevant diagnostics. @@ -17574,7 +17785,7 @@ namespace ts { } function getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[] { - const symbols: SymbolTable = {}; + const symbols = createMap(); let memberFlags: ModifierFlags = ModifierFlags.None; if (isInsideWithStatementBody(location)) { @@ -17652,7 +17863,7 @@ namespace ts { // We will copy all symbol regardless of its reserved name because // symbolsToArray will check whether the key is a reserved name and // it will not copy symbol with reserved name to the array - if (!hasProperty(symbols, id)) { + if (!symbols[id]) { symbols[id] = symbol; } } @@ -17740,7 +17951,7 @@ namespace ts { return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } - function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol { + function getSymbolOfEntityNameOrPropertyAccessExpression(entityName: EntityName | PropertyAccessExpression): Symbol | undefined { if (isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } @@ -17759,22 +17970,20 @@ namespace ts { } } - if (entityName.parent.kind === SyntaxKind.ExportAssignment) { - return resolveEntityName(entityName, + if (entityName.parent.kind === SyntaxKind.ExportAssignment && isEntityNameExpression(entityName)) { + return resolveEntityName(entityName, /*all meanings*/ SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } - if (entityName.kind !== SyntaxKind.PropertyAccessExpression) { - if (isInRightSideOfImportOrExportAssignment(entityName)) { - // Since we already checked for ExportAssignment, this really could only be an Import - const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); - Debug.assert(importEqualsDeclaration !== undefined); - return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); - } + if (entityName.kind !== SyntaxKind.PropertyAccessExpression && isInRightSideOfImportOrExportAssignment(entityName)) { + // Since we already checked for ExportAssignment, this really could only be an Import + const importEqualsDeclaration = getAncestor(entityName, SyntaxKind.ImportEqualsDeclaration); + Debug.assert(importEqualsDeclaration !== undefined); + return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, importEqualsDeclaration, /*dontResolveAlias*/ true); } if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { - entityName = entityName.parent; + entityName = entityName.parent; } if (isHeritageClauseElementIdentifier(entityName)) { @@ -18073,7 +18282,7 @@ namespace ts { const propsByName = createSymbolTable(getPropertiesOfType(type)); if (getSignaturesOfType(type, SignatureKind.Call).length || getSignaturesOfType(type, SignatureKind.Construct).length) { forEach(getPropertiesOfType(globalFunctionType), p => { - if (!hasProperty(propsByName, p.name)) { + if (!propsByName[p.name]) { propsByName[p.name] = p; } }); @@ -18137,7 +18346,7 @@ namespace ts { // otherwise - check if at least one export is value symbolLinks.exportsSomeValue = hasExportAssignment ? !!(moduleSymbol.flags & SymbolFlags.Value) - : forEachValue(getExportsOfModule(moduleSymbol), isValue); + : forEachProperty(getExportsOfModule(moduleSymbol), isValue); } return symbolLinks.exportsSomeValue; @@ -18443,7 +18652,7 @@ namespace ts { else if (isTypeOfKind(type, TypeFlags.StringLike)) { return TypeReferenceSerializationKind.StringLikeType; } - else if (isTypeOfKind(type, TypeFlags.Tuple)) { + else if (isTupleType(type)) { return TypeReferenceSerializationKind.ArrayLikeType; } else if (isTypeOfKind(type, TypeFlags.ESSymbol)) { @@ -18488,7 +18697,7 @@ namespace ts { } function hasGlobalName(name: string): boolean { - return hasProperty(globals, name); + return !!globals[name]; } function getReferencedValueSymbol(reference: Identifier, startInDeclarationContainer?: boolean): Symbol { @@ -18533,9 +18742,6 @@ namespace ts { // populate reverse mapping: file path -> type reference directive that was resolved to this file fileToDirective = createFileMap(); for (const key in resolvedTypeReferenceDirectives) { - if (!hasProperty(resolvedTypeReferenceDirectives, key)) { - continue; - } const resolvedDirective = resolvedTypeReferenceDirectives[key]; if (!resolvedDirective) { continue; @@ -18575,7 +18781,7 @@ namespace ts { }; // defined here to avoid outer scope pollution - function getTypeReferenceDirectivesForEntityName(node: EntityName | PropertyAccessExpression): string[] { + function getTypeReferenceDirectivesForEntityName(node: EntityNameOrEntityNameExpression): string[] { // program does not have any files with type reference directives - bail out if (!fileToDirective) { return undefined; @@ -19376,7 +19582,7 @@ namespace ts { } function checkGrammarObjectLiteralExpression(node: ObjectLiteralExpression, inDestructuring: boolean) { - const seen: Map = {}; + const seen = createMap(); const Property = 1; const GetAccessor = 2; const SetAccessor = 4; @@ -19440,7 +19646,7 @@ namespace ts { continue; } - if (!hasProperty(seen, effectiveName)) { + if (!seen[effectiveName]) { seen[effectiveName] = currentKind; } else { @@ -19464,7 +19670,7 @@ namespace ts { } function checkGrammarJsxElement(node: JsxOpeningLikeElement) { - const seen: Map = {}; + const seen = createMap(); for (const attr of node.attributes) { if (attr.kind === SyntaxKind.JsxSpreadAttribute) { continue; @@ -19472,7 +19678,7 @@ namespace ts { const jsxAttr = (attr); const name = jsxAttr.name; - if (!hasProperty(seen, name.text)) { + if (!seen[name.text]) { seen[name.text] = true; } else { @@ -19887,7 +20093,7 @@ namespace ts { node.kind === SyntaxKind.ExportAssignment || node.kind === SyntaxKind.NamespaceExportDeclaration || getModifierFlags(node) & (ModifierFlags.Ambient | ModifierFlags.Export | ModifierFlags.Default)) { - return false; + return false; } return grammarErrorOnFirstToken(node, Diagnostics.A_declare_modifier_is_required_for_a_top_level_declaration_in_a_d_ts_file); diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6b0971d52ac..590fc13fe88 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -62,10 +62,10 @@ namespace ts { }, { name: "jsx", - type: { + type: createMap({ "preserve": JsxEmit.Preserve, "react": JsxEmit.React - }, + }), paramType: Diagnostics.KIND, description: Diagnostics.Specify_JSX_code_generation_Colon_preserve_or_react, }, @@ -92,7 +92,7 @@ namespace ts { { name: "module", shortName: "m", - type: { + type: createMap({ "none": ModuleKind.None, "commonjs": ModuleKind.CommonJS, "amd": ModuleKind.AMD, @@ -100,16 +100,16 @@ namespace ts { "umd": ModuleKind.UMD, "es6": ModuleKind.ES6, "es2015": ModuleKind.ES2015, - }, + }), description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: Diagnostics.KIND, }, { name: "newLine", - type: { + type: createMap({ "crlf": NewLineKind.CarriageReturnLineFeed, "lf": NewLineKind.LineFeed - }, + }), description: Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, paramType: Diagnostics.NEWLINE, }, @@ -127,6 +127,10 @@ namespace ts { type: "boolean", description: Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, }, + { + name: "noErrorTruncation", + type: "boolean" + }, { name: "noImplicitAny", type: "boolean", @@ -251,12 +255,12 @@ namespace ts { { name: "target", shortName: "t", - type: { + type: createMap({ "es3": ScriptTarget.ES3, "es5": ScriptTarget.ES5, "es6": ScriptTarget.ES6, "es2015": ScriptTarget.ES2015, - }, + }), description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015, paramType: Diagnostics.VERSION, }, @@ -285,10 +289,10 @@ namespace ts { }, { name: "moduleResolution", - type: { + type: createMap({ "node": ModuleResolutionKind.NodeJs, "classic": ModuleResolutionKind.Classic, - }, + }), description: Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, }, { @@ -393,7 +397,7 @@ namespace ts { type: "list", element: { name: "lib", - type: { + type: createMap({ // JavaScript only "es5": "lib.es5.d.ts", "es6": "lib.es2015.d.ts", @@ -418,7 +422,7 @@ namespace ts { "es2016.array.include": "lib.es2016.array.include.d.ts", "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts" - }, + }), }, description: Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, @@ -468,6 +472,14 @@ namespace ts { shortOptionNames: Map; } + /* @internal */ + export const defaultInitCompilerOptions: CompilerOptions = { + module: ModuleKind.CommonJS, + target: ScriptTarget.ES5, + noImplicitAny: false, + sourceMap: false, + }; + let optionNameMapCache: OptionNameMap; /* @internal */ @@ -476,8 +488,8 @@ namespace ts { return optionNameMapCache; } - const optionNameMap: Map = {}; - const shortOptionNames: Map = {}; + const optionNameMap = createMap(); + const shortOptionNames = createMap(); forEach(optionDeclarations, option => { optionNameMap[option.name.toLowerCase()] = option; if (option.shortName) { @@ -492,10 +504,9 @@ namespace ts { /* @internal */ export function createCompilerDiagnosticForInvalidCustomType(opt: CommandLineOptionOfCustomType): Diagnostic { const namesOfType: string[] = []; - forEachKey(opt.type, key => { + for (const key in opt.type) { namesOfType.push(` '${key}'`); - }); - + } return createCompilerDiagnostic(Diagnostics.Argument_for_0_option_must_be_Colon_1, `--${opt.name}`, namesOfType); } @@ -503,7 +514,7 @@ namespace ts { export function parseCustomTypeOption(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { const key = trimString((value || "")).toLowerCase(); const map = opt.type; - if (hasProperty(map, key)) { + if (key in map) { return map[key]; } else { @@ -557,11 +568,11 @@ namespace ts { s = s.slice(s.charCodeAt(1) === CharacterCodes.minus ? 2 : 1).toLowerCase(); // Try to translate short option names to their full equivalents. - if (hasProperty(shortOptionNames, s)) { + if (s in shortOptionNames) { s = shortOptionNames[s]; } - if (hasProperty(optionNameMap, s)) { + if (s in optionNameMap) { const opt = optionNameMap[s]; if (opt.isTSConfigOnly) { @@ -674,6 +685,94 @@ namespace ts { } } + /** + * Generate tsconfig configuration when running command line "--init" + * @param options commandlineOptions to be generated into tsconfig.json + * @param fileNames array of filenames to be generated into tsconfig.json + */ + /* @internal */ + export function generateTSConfig(options: CompilerOptions, fileNames: string[]): { compilerOptions: Map } { + const compilerOptions = extend(options, defaultInitCompilerOptions); + const configurations: any = { + compilerOptions: serializeCompilerOptions(compilerOptions) + }; + if (fileNames && fileNames.length) { + // only set the files property if we have at least one file + configurations.files = fileNames; + } + + return configurations; + + function getCustomTypeMapOfCommandLineOption(optionDefinition: CommandLineOption): Map | undefined { + if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { + // this is of a type CommandLineOptionOfPrimitiveType + return undefined; + } + else if (optionDefinition.type === "list") { + return getCustomTypeMapOfCommandLineOption((optionDefinition).element); + } + else { + return (optionDefinition).type; + } + } + + function getNameOfCompilerOptionValue(value: CompilerOptionsValue, customTypeMap: MapLike): string | undefined { + // There is a typeMap associated with this command-line option so use it to map value back to its name + for (const key in customTypeMap) { + if (customTypeMap[key] === value) { + return key; + } + } + return undefined; + } + + function serializeCompilerOptions(options: CompilerOptions): Map { + const result = createMap(); + const optionsNameMap = getOptionNameMap().optionNameMap; + + for (const name in options) { + if (hasProperty(options, name)) { + // tsconfig only options cannot be specified via command line, + // so we can assume that only types that can appear here string | number | boolean + switch (name) { + case "init": + case "watch": + case "version": + case "help": + case "project": + break; + default: + const value = options[name]; + let optionDefinition = optionsNameMap[name.toLowerCase()]; + if (optionDefinition) { + const customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + const convertedValue: string[] = []; + for (const element of value as (string | number)[]) { + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); + } + result[name] = convertedValue; + } + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } + } + break; + } + } + } + return result; + } + } + /** * Remove the comments from a json like text. * Comments can be single line comments (starting with # or //) or multiline comments using / * * / @@ -817,7 +916,7 @@ namespace ts { const optionNameMap = arrayToMap(optionDeclarations, opt => opt.name); for (const id in jsonOptions) { - if (hasProperty(optionNameMap, id)) { + if (id in optionNameMap) { const opt = optionNameMap[id]; defaultOptions[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors); } @@ -854,7 +953,7 @@ namespace ts { function convertJsonOptionOfCustomType(opt: CommandLineOptionOfCustomType, value: string, errors: Diagnostic[]) { const key = value.toLowerCase(); - if (hasProperty(opt.type, key)) { + if (key in opt.type) { return opt.type[key]; } else { @@ -964,12 +1063,12 @@ namespace ts { // Literal file names (provided via the "files" array in tsconfig.json) are stored in a // file map with a possibly case insensitive key. We use this map later when when including // wildcard paths. - const literalFileMap: Map = {}; + const literalFileMap = createMap(); // Wildcard paths (provided via the "includes" array in tsconfig.json) are stored in a // file map with a possibly case insensitive key. We use this map to store paths matched // via wildcard, and to handle extension priority. - const wildcardFileMap: Map = {}; + const wildcardFileMap = createMap(); if (include) { include = validateSpecs(include, errors, /*allowTrailingRecursion*/ false); @@ -1017,7 +1116,7 @@ namespace ts { removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper); const key = keyMapper(file); - if (!hasProperty(literalFileMap, key) && !hasProperty(wildcardFileMap, key)) { + if (!(key in literalFileMap) && !(key in wildcardFileMap)) { wildcardFileMap[key] = file; } } @@ -1069,7 +1168,7 @@ namespace ts { // /a/b/a?z - Watch /a/b directly to catch any new file matching a?z const rawExcludeRegex = getRegularExpressionForWildcard(exclude, path, "exclude"); const excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i"); - const wildcardDirectories: Map = {}; + const wildcardDirectories = createMap(); if (include !== undefined) { const recursiveKeys: string[] = []; for (const file of include) { @@ -1082,7 +1181,7 @@ namespace ts { if (match) { const key = useCaseSensitiveFileNames ? match[0] : match[0].toLowerCase(); const flags = watchRecursivePattern.test(name) ? WatchDirectoryFlags.Recursive : WatchDirectoryFlags.None; - const existingFlags = getProperty(wildcardDirectories, key); + const existingFlags = wildcardDirectories[key]; if (existingFlags === undefined || existingFlags < flags) { wildcardDirectories[key] = flags; if (flags === WatchDirectoryFlags.Recursive) { @@ -1094,11 +1193,9 @@ namespace ts { // Remove any subpaths under an existing recursively watched directory. for (const key in wildcardDirectories) { - if (hasProperty(wildcardDirectories, key)) { - for (const recursiveKey of recursiveKeys) { - if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { - delete wildcardDirectories[key]; - } + for (const recursiveKey of recursiveKeys) { + if (key !== recursiveKey && containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) { + delete wildcardDirectories[key]; } } } @@ -1121,7 +1218,7 @@ namespace ts { for (let i = ExtensionPriority.Highest; i < adjustedExtensionPriority; i++) { const higherPriorityExtension = extensions[i]; const higherPriorityPath = keyMapper(changeExtension(file, higherPriorityExtension)); - if (hasProperty(literalFiles, higherPriorityPath) || hasProperty(wildcardFiles, higherPriorityPath)) { + if (higherPriorityPath in literalFiles || higherPriorityPath in wildcardFiles) { return true; } } diff --git a/src/compiler/comments.ts b/src/compiler/comments.ts index f60260a19a1..1bca13a4bdb 100644 --- a/src/compiler/comments.ts +++ b/src/compiler/comments.ts @@ -53,9 +53,8 @@ namespace ts { } } else { - let commentStart: number; if (extendedDiagnostics) { - commentStart = performance.mark(); + performance.mark("preEmitNodeWithComment"); } const isEmittedNode = node.kind !== SyntaxKind.NotEmittedStatement; @@ -88,7 +87,7 @@ namespace ts { } if (extendedDiagnostics) { - performance.measure("commentTime", commentStart); + performance.measure("commentTime", "preEmitNodeWithComment"); } if (emitFlags & NodeEmitFlags.NoNestedComments) { @@ -99,7 +98,7 @@ namespace ts { } if (extendedDiagnostics) { - commentStart = performance.mark(); + performance.mark("beginEmitNodeWithComment"); } // Restore previous container state. @@ -114,16 +113,15 @@ namespace ts { } if (extendedDiagnostics) { - performance.measure("commentTime", commentStart); + performance.measure("commentTime", "beginEmitNodeWithComment"); } } } } function emitBodyWithDetachedComments(node: Node, detachedRange: TextRange, emitCallback: (node: Node) => void) { - let commentStart: number; if (extendedDiagnostics) { - commentStart = performance.mark(); + performance.mark("preEmitBodyWithDetachedComments"); } const { pos, end } = detachedRange; @@ -136,7 +134,7 @@ namespace ts { } if (extendedDiagnostics) { - performance.measure("commentTime", commentStart); + performance.measure("commentTime", "preEmitBodyWithDetachedComments"); } if (emitFlags & NodeEmitFlags.NoNestedComments) { @@ -147,7 +145,7 @@ namespace ts { } if (extendedDiagnostics) { - commentStart = performance.mark(); + performance.mark("beginEmitBodyWithDetachedCommetns"); } if (!skipTrailingComments) { @@ -155,7 +153,7 @@ namespace ts { } if (extendedDiagnostics) { - performance.measure("commentTime", commentStart); + performance.measure("commentTime", "beginEmitBodyWithDetachedCommetns"); } } @@ -227,15 +225,14 @@ namespace ts { return; } - let commentStart: number; if (extendedDiagnostics) { - commentStart = performance.mark(); + performance.mark("beforeEmitTrailingCommentsOfPosition"); } forEachTrailingCommentToEmit(pos, emitTrailingCommentOfPosition); if (extendedDiagnostics) { - performance.measure("commentTime", commentStart); + performance.measure("commentTime", "beforeEmitTrailingCommentsOfPosition"); } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 064f68849c6..e74ee64515d 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -19,8 +19,28 @@ namespace ts { True = -1 } + const createObject = Object.create; + + export function createMap(template?: MapLike): Map { + const map: Map = createObject(null); // tslint:disable-line:no-null-keyword + + // Using 'delete' on an object causes V8 to put the object in dictionary mode. + // This disables creation of hidden classes, which are expensive when an object is + // constantly changing shape. + map["__"] = undefined; + delete map["__"]; + + // Copies keys/values from template. Note that for..in will not throw if + // template is undefined, and instead will just exit the loop. + for (const key in template) if (hasOwnProperty.call(template, key)) { + map[key] = template[key]; + } + + return map; + } + export function createFileMap(keyMapper?: (key: string) => string): FileMap { - let files: Map = {}; + let files = createMap(); return { get, set, @@ -46,7 +66,7 @@ namespace ts { } function contains(path: Path) { - return hasProperty(files, toKey(path)); + return toKey(path) in files; } function remove(path: Path) { @@ -55,7 +75,7 @@ namespace ts { } function clear() { - files = {}; + files = createMap(); } function toKey(path: Path): string { @@ -81,7 +101,7 @@ namespace ts { * returns a truthy value, then returns that value. * If no such value is found, the callback is applied to each element of array and undefined is returned. */ - export function forEach(array: T[], callback: (element: T, index: number) => U): U { + export function forEach(array: T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined { if (array) { for (let i = 0, len = array.length; i < len; i++) { const result = callback(array[i], i); @@ -110,6 +130,31 @@ namespace ts { return true; } + /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ + export function find(array: T[], predicate: (element: T, index: number) => boolean): T | undefined { + for (let i = 0, len = array.length; i < len; i++) { + const value = array[i]; + if (predicate(value, i)) { + return value; + } + } + return undefined; + } + + /** + * Returns the first truthy result of `callback`, or else fails. + * This is like `forEach`, but never returns undefined. + */ + export function findMap(array: T[], callback: (element: T, index: number) => U | undefined): U { + for (let i = 0, len = array.length; i < len; i++) { + const result = callback(array[i], i); + if (result) { + return result; + } + } + Debug.fail(); + } + export function contains(array: T[], value: T): boolean { if (array) { for (const v of array) { @@ -154,20 +199,42 @@ namespace ts { return count; } - export function filter(array: T[], f: (x: T, i: number) => x is U): U[]; - export function filter(array: T[], f: (x: T, i: number) => boolean): T[]; - export function filter(array: T[], f: (x: T, i: number) => boolean): T[] { - let result: T[]; + export function filter(array: T[], f: (x: T) => x is U): U[]; + export function filter(array: T[], f: (x: T) => boolean): T[] + export function filter(array: T[], f: (x: T) => boolean): T[] { if (array) { - result = []; - for (let i = 0; i < array.length; i++) { - const v = array[i]; - if (f(v, i)) { - result.push(v); + const len = array.length; + let i = 0; + while (i < len && f(array[i])) i++; + if (i < len) { + const result = array.slice(0, i); + i++; + while (i < len) { + const item = array[i]; + if (f(item)) { + result.push(item); + } + i++; } + return result; } } - return result; + return array; + } + + export function removeWhere(array: T[], f: (x: T) => boolean): boolean { + let outIndex = 0; + for (const item of array) { + if (!f(item)) { + array[outIndex] = item; + outIndex++; + } + } + if (outIndex !== array.length) { + array.length = outIndex; + return true; + } + return false; } export function filterMutate(array: T[], f: (x: T) => boolean): void { @@ -487,82 +554,142 @@ namespace ts { const hasOwnProperty = Object.prototype.hasOwnProperty; - export function hasProperty(map: Map, key: string): boolean { + /** + * Indicates whether a map-like contains an own property with the specified key. + * + * NOTE: This is intended for use only with MapLike objects. For Map objects, use + * the 'in' operator. + * + * @param map A map-like. + * @param key A property key. + */ + export function hasProperty(map: MapLike, key: string): boolean { return hasOwnProperty.call(map, key); } - export function getKeys(map: Map): string[] { + /** + * Gets the value of an owned property in a map-like. + * + * NOTE: This is intended for use only with MapLike objects. For Map objects, use + * an indexer. + * + * @param map A map-like. + * @param key A property key. + */ + export function getProperty(map: MapLike, key: string): T | undefined { + return hasOwnProperty.call(map, key) ? map[key] : undefined; + } + + /** + * Gets the owned, enumerable property keys of a map-like. + * + * NOTE: This is intended for use with MapLike objects. For Map objects, use + * Object.keys instead as it offers better performance. + * + * @param map A map-like. + */ + export function getOwnKeys(map: MapLike): string[] { const keys: string[] = []; - for (const key in map) { + for (const key in map) if (hasOwnProperty.call(map, key)) { keys.push(key); } return keys; } - export function getProperty(map: Map, key: string): T | undefined { - return hasProperty(map, key) ? map[key] : undefined; + /** + * Enumerates the properties of a Map, invoking a callback and returning the first truthy result. + * + * @param map A map for which properties should be enumerated. + * @param callback A callback to invoke for each property. + */ + export function forEachProperty(map: Map, callback: (value: T, key: string) => U): U { + let result: U; + for (const key in map) { + if (result = callback(map[key], key)) break; + } + return result; } - export function getOrUpdateProperty(map: Map, key: string, makeValue: () => T): T { - return hasProperty(map, key) ? map[key] : map[key] = makeValue(); + /** + * Returns true if a Map has some matching property. + * + * @param map A map whose properties should be tested. + * @param predicate An optional callback used to test each property. + */ + export function someProperties(map: Map, predicate?: (value: T, key: string) => boolean) { + for (const key in map) { + if (!predicate || predicate(map[key], key)) return true; + } + return false; } - export function isEmpty(map: Map) { - for (const id in map) { - if (hasProperty(map, id)) { - return false; - } + /** + * Performs a shallow copy of the properties from a source Map to a target MapLike + * + * @param source A map from which properties should be copied. + * @param target A map to which properties should be copied. + */ + export function copyProperties(source: Map, target: MapLike): void { + for (const key in source) { + target[key] = source[key]; + } + } + + /** + * Reduce the properties of a map. + * + * NOTE: This is intended for use with Map objects. For MapLike objects, use + * reduceOwnProperties instead as it offers better runtime safety. + * + * @param map The map to reduce + * @param callback An aggregation function that is called for each entry in the map + * @param initial The initial value for the reduction. + */ + export function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { + let result = initial; + for (const key in map) { + result = callback(result, map[key], String(key)); + } + return result; + } + + /** + * Reduce the properties defined on a map-like (but not from its prototype chain). + * + * NOTE: This is intended for use with MapLike objects. For Map objects, use + * reduceProperties instead as it offers better performance. + * + * @param map The map-like to reduce + * @param callback An aggregation function that is called for each entry in the map + * @param initial The initial value for the reduction. + */ + export function reduceOwnProperties(map: MapLike, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { + let result = initial; + for (const key in map) if (hasOwnProperty.call(map, key)) { + result = callback(result, map[key], String(key)); + } + return result; + } + + /** + * Performs a shallow equality comparison of the contents of two map-likes. + * + * @param left A map-like whose properties should be compared. + * @param right A map-like whose properties should be compared. + */ + export function equalOwnProperties(left: MapLike, right: MapLike, equalityComparer?: (left: T, right: T) => boolean) { + if (left === right) return true; + if (!left || !right) return false; + for (const key in left) if (hasOwnProperty.call(left, key)) { + if (!hasOwnProperty.call(right, key) === undefined) return false; + if (equalityComparer ? !equalityComparer(left[key], right[key]) : left[key] !== right[key]) return false; + } + for (const key in right) if (hasOwnProperty.call(right, key)) { + if (!hasOwnProperty.call(left, key)) return false; } return true; } - export function clone(object: T): T { - const result: any = {}; - for (const id in object) { - result[id] = (object)[id]; - } - return result; - } - - export function extend, T2 extends Map<{}>>(first: T1 , second: T2): T1 & T2 { - const result: T1 & T2 = {}; - for (const id in first) { - (result as any)[id] = first[id]; - } - for (const id in second) { - if (!hasProperty(result, id)) { - (result as any)[id] = second[id]; - } - } - return result; - } - - export function forEachValue(map: Map, callback: (value: T) => U): U { - let result: U; - for (const id in map) { - if (result = callback(map[id])) break; - } - return result; - } - - export function forEachKey(map: Map, callback: (key: string) => U): U { - let result: U; - for (const id in map) { - if (result = callback(id)) break; - } - return result; - } - - export function lookUp(map: Map, key: string): T { - return hasProperty(map, key) ? map[key] : undefined; - } - - export function copyMap(source: Map, target: Map): void { - for (const p in source) { - target[p] = source[p]; - } - } - /** * Creates a map from the elements of an array. * @@ -573,33 +700,49 @@ namespace ts { * the same key with the given 'makeKey' function, then the element with the higher * index in the array will be the one associated with the produced key. */ - export function arrayToMap(array: T[], makeKey: (value: T) => string): Map { - const result: Map = {}; - - forEach(array, value => { - result[makeKey(value)] = value; - }); - + export function arrayToMap(array: T[], makeKey: (value: T) => string): Map; + export function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue: (value: T) => U): Map; + export function arrayToMap(array: T[], makeKey: (value: T) => string, makeValue?: (value: T) => U): Map { + const result = createMap(); + for (const value of array) { + result[makeKey(value)] = makeValue ? makeValue(value) : value; + } return result; } - /** - * Reduce the properties of a map. - * - * @param map The map to reduce - * @param callback An aggregation function that is called for each entry in the map - * @param initial The initial value for the reduction. - */ - export function reduceProperties(map: Map, callback: (aggregate: U, value: T, key: string) => U, initial: U): U { - let result = initial; - if (map) { - for (const key in map) { - if (hasProperty(map, key)) { - result = callback(result, map[key], String(key)); - } + export function isEmpty(map: Map) { + for (const id in map) { + if (hasProperty(map, id)) { + return false; } } + return true; + } + export function cloneMap(map: Map) { + const clone = createMap(); + copyProperties(map, clone); + return clone; + } + + export function clone(object: T): T { + const result: any = {}; + for (const id in object) { + if (hasOwnProperty.call(object, id)) { + result[id] = (object)[id]; + } + } + return result; + } + + export function extend(first: T1 , second: T2): T1 & T2 { + const result: T1 & T2 = {}; + for (const id in second) if (hasOwnProperty.call(second, id)) { + (result as any)[id] = (second as any)[id]; + } + for (const id in first) if (hasOwnProperty.call(first, id)) { + (result as any)[id] = (first as any)[id]; + } return result; } @@ -630,9 +773,7 @@ namespace ts { export let localizedDiagnosticMessages: Map = undefined; export function getLocaleSpecificMessage(message: DiagnosticMessage) { - return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] - ? localizedDiagnosticMessages[message.key] - : message.message; + return localizedDiagnosticMessages && localizedDiagnosticMessages[message.key] || message.message; } export function createFileDiagnostic(file: SourceFile, start: number, length: number, message: DiagnosticMessage, ...args: any[]): Diagnostic; @@ -1368,6 +1509,8 @@ namespace ts { * List of supported extensions in order of file resolution precedence. */ export const supportedTypeScriptExtensions = [".ts", ".tsx", ".d.ts"]; + /** Must have ".d.ts" first because if ".ts" goes first, that will be detected as the extension instead of ".d.ts". */ + export const supportedTypescriptExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"]; export const supportedJavascriptExtensions = [".js", ".jsx"]; const allSupportedExtensions = supportedTypeScriptExtensions.concat(supportedJavascriptExtensions); @@ -1450,8 +1593,12 @@ namespace ts { return path; } - export function tryRemoveExtension(path: string, extension: string): string { - return fileExtensionIs(path, extension) ? path.substring(0, path.length - extension.length) : undefined; + export function tryRemoveExtension(path: string, extension: string): string | undefined { + return fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined; + } + + export function removeExtension(path: string, extension: string): string { + return path.substring(0, path.length - extension.length); } export function isJsxOrTsxExtension(ext: string): boolean { diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index d109ad70d9c..dcc7ca7c1ae 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -157,9 +157,7 @@ namespace ts { if (usedTypeDirectiveReferences) { for (const directive in usedTypeDirectiveReferences) { - if (hasProperty(usedTypeDirectiveReferences, directive)) { - referencesOutput += `/// ${newLine}`; - } + referencesOutput += `/// ${newLine}`; } } @@ -269,10 +267,10 @@ namespace ts { } if (!usedTypeDirectiveReferences) { - usedTypeDirectiveReferences = {}; + usedTypeDirectiveReferences = createMap(); } for (const directive of typeReferenceDirectives) { - if (!hasProperty(usedTypeDirectiveReferences, directive)) { + if (!(directive in usedTypeDirectiveReferences)) { usedTypeDirectiveReferences[directive] = directive; } } @@ -441,7 +439,7 @@ namespace ts { } } - function emitEntityName(entityName: EntityName | PropertyAccessExpression) { + function emitEntityName(entityName: EntityNameOrEntityNameExpression) { const visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration entityName.parent.kind === SyntaxKind.ImportEqualsDeclaration ? entityName.parent : enclosingDeclaration); @@ -452,9 +450,9 @@ namespace ts { } function emitExpressionWithTypeArguments(node: ExpressionWithTypeArguments) { - if (isSupportedExpressionWithTypeArguments(node)) { + if (isEntityNameExpression(node.expression)) { Debug.assert(node.expression.kind === SyntaxKind.Identifier || node.expression.kind === SyntaxKind.PropertyAccessExpression); - emitEntityName(node.expression); + emitEntityName(node.expression); if (node.typeArguments) { write("<"); emitCommaList(node.typeArguments, emitType); @@ -537,14 +535,14 @@ namespace ts { // do not need to keep track of created temp names. function getExportDefaultTempVariableName(): string { const baseName = "_default"; - if (!hasProperty(currentIdentifiers, baseName)) { + if (!(baseName in currentIdentifiers)) { return baseName; } let count = 0; while (true) { count++; const name = baseName + "_" + count; - if (!hasProperty(currentIdentifiers, name)) { + if (!(name in currentIdentifiers)) { return name; } } @@ -1020,7 +1018,7 @@ namespace ts { } function emitTypeOfTypeReference(node: ExpressionWithTypeArguments) { - if (isSupportedExpressionWithTypeArguments(node)) { + if (isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) { diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8ef0698dea7..fef175388f7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1947,6 +1947,14 @@ "category": "Error", "code": 2690 }, + "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead.": { + "category": "Error", + "code": 2691 + }, + "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible.": { + "category": "Error", + "code": 2692 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 @@ -2227,7 +2235,7 @@ "category": "Error", "code": 4082 }, - "Conflicting library definitions for '{0}' found at '{1}' and '{2}'. Copy the correct file to the 'typings' folder to resolve this conflict.": { + "Conflicting definitions for '{0}' found at '{1}' and '{2}'. Consider installing a specific version of this library to resolve the conflict.": { "category": "Message", "code": 4090 }, @@ -2824,9 +2832,13 @@ "category": "Message", "code": 6137 }, + "Property '{0}' is declared but never used.": { + "category": "Error", + "code": 6138 + }, "Import emit helpers from 'tslib'.": { "category": "Message", - "code": 6138 + "code": 6139 }, "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 8b91a7c19d9..680c446c0d5 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -182,8 +182,7 @@ const _super = (function (geti, seti) { let isOwnFileEmit: boolean; let emitSkipped = false; - performance.emit("beforeTransform"); - const transformStart = performance.mark(); + performance.mark("beforeTransform"); // Transform the source files const transformed = transformFiles( @@ -192,8 +191,7 @@ const _super = (function (geti, seti) { getSourceFilesToEmit(host, targetSourceFile), transformers); - performance.measure("transformTime", transformStart); - performance.emit("afterTransform"); + performance.measure("transformTime", "beforeTransform"); // Extract helpers from the result const { @@ -204,8 +202,7 @@ const _super = (function (geti, seti) { onEmitNode } = transformed; - performance.emit("beforePrint"); - const printStart = performance.mark(); + performance.mark("beforePrint"); // Emit each output file forEachTransformedEmitFile(host, transformed.getSourceFiles(), emitFile); @@ -213,8 +210,7 @@ const _super = (function (geti, seti) { // Clean up after transformation transformed.dispose(); - performance.measure("printTime", printStart); - performance.emit("afterPrint"); + performance.measure("printTime", "beforePrint"); return { emitSkipped, @@ -251,7 +247,7 @@ const _super = (function (geti, seti) { sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFiles, isBundledEmit); nodeIdToGeneratedName = []; autoGeneratedIdToGeneratedName = []; - generatedNameSet = {}; + generatedNameSet = createMap(); isOwnFileEmit = !isBundledEmit; // Emit helpers from all the files @@ -2609,7 +2605,7 @@ const _super = (function (geti, seti) { function getTextOfNode(node: Node, includeTrivia?: boolean): string { if (isGeneratedIdentifier(node)) { - return getGeneratedIdentifier(node); + return getGeneratedIdentifier(node); } else if (isIdentifier(node) && (nodeIsSynthesized(node) || !node.parent)) { return unescapeIdentifier(node.text); diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 510360af143..a6cadb77728 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -420,14 +420,16 @@ namespace ts { visitNode(cbNode, (node).name); case SyntaxKind.PartiallyEmittedExpression: return visitNode(cbNode, (node).expression); + case SyntaxKind.JSDocLiteralType: + return visitNode(cbNode, (node).literal); } } export function createSourceFile(fileName: string, sourceText: string, languageVersion: ScriptTarget, setParentNodes = false, scriptKind?: ScriptKind): SourceFile { - const start = performance.mark(); + performance.mark("beforeParse"); const result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind); - - performance.measure("Parse", start); + performance.mark("afterParse"); + performance.measure("Parse", "beforeParse", "afterParse"); return result; } @@ -598,7 +600,7 @@ namespace ts { parseDiagnostics = []; parsingContext = 0; - identifiers = {}; + identifiers = createMap(); identifierCount = 0; nodeCount = 0; @@ -913,7 +915,7 @@ namespace ts { // Note: it is not actually necessary to save/restore the context flags here. That's // because the saving/restoring of these flags happens naturally through the recursive // descent nature of our parser. However, we still store this here just so we can - // assert that that invariant holds. + // assert that invariant holds. const saveContextFlags = contextFlags; // If we're only looking ahead, then tell the scanner to only lookahead as well. @@ -1097,7 +1099,7 @@ namespace ts { function internIdentifier(text: string): string { text = escapeIdentifier(text); - return hasProperty(identifiers, text) ? identifiers[text] : (identifiers[text] = text); + return identifiers[text] || (identifiers[text] = text); } // An identifier that starts with two underscores has an extra underscore character prepended to it to avoid issues @@ -2761,7 +2763,7 @@ namespace ts { // Note: for ease of implementation we treat productions '2' and '3' as the same thing. // (i.e. they're both BinaryExpressions with an assignment operator in it). - // First, do the simple check if we have a YieldExpression (production '5'). + // First, do the simple check if we have a YieldExpression (production '6'). if (isYieldExpression()) { return parseYieldExpression(); } @@ -3368,24 +3370,40 @@ namespace ts { } /** - * Parse ES7 unary expression and await expression + * Parse ES7 exponential expression and await expression + * + * ES7 ExponentiationExpression: + * 1) UnaryExpression[?Yield] + * 2) UpdateExpression[?Yield] ** ExponentiationExpression[?Yield] * - * ES7 UnaryExpression: - * 1) SimpleUnaryExpression[?yield] - * 2) IncrementExpression[?yield] ** UnaryExpression[?yield] */ function parseUnaryExpressionOrHigher(): UnaryExpression | BinaryExpression { - if (isAwaitExpression()) { - return parseAwaitExpression(); - } - - if (isIncrementExpression()) { + /** + * ES7 UpdateExpression: + * 1) LeftHandSideExpression[?Yield] + * 2) LeftHandSideExpression[?Yield][no LineTerminator here]++ + * 3) LeftHandSideExpression[?Yield][no LineTerminator here]-- + * 4) ++UnaryExpression[?Yield] + * 5) --UnaryExpression[?Yield] + */ + if (isUpdateExpression()) { const incrementExpression = parseIncrementExpression(); return token() === SyntaxKind.AsteriskAsteriskToken ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } + /** + * ES7 UnaryExpression: + * 1) UpdateExpression[?yield] + * 2) delete UpdateExpression[?yield] + * 3) void UpdateExpression[?yield] + * 4) typeof UpdateExpression[?yield] + * 5) + UpdateExpression[?yield] + * 6) - UpdateExpression[?yield] + * 7) ~ UpdateExpression[?yield] + * 8) ! UpdateExpression[?yield] + */ const unaryOperator = token(); const simpleUnaryExpression = parseSimpleUnaryExpression(); if (token() === SyntaxKind.AsteriskAsteriskToken) { @@ -3403,8 +3421,8 @@ namespace ts { /** * Parse ES7 simple-unary expression or higher: * - * ES7 SimpleUnaryExpression: - * 1) IncrementExpression[?yield] + * ES7 UnaryExpression: + * 1) UpdateExpression[?yield] * 2) delete UnaryExpression[?yield] * 3) void UnaryExpression[?yield] * 4) typeof UnaryExpression[?yield] @@ -3412,6 +3430,7 @@ namespace ts { * 6) - UnaryExpression[?yield] * 7) ~ UnaryExpression[?yield] * 8) ! UnaryExpression[?yield] + * 9) [+Await] await UnaryExpression[?yield] */ function parseSimpleUnaryExpression(): UnaryExpression { switch (token()) { @@ -3431,6 +3450,10 @@ namespace ts { // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); + case SyntaxKind.AwaitKeyword: + if (isAwaitExpression()) { + return parseAwaitExpression(); + } default: return parseIncrementExpression(); } @@ -3439,14 +3462,14 @@ namespace ts { /** * Check if the current token can possibly be an ES7 increment expression. * - * ES7 IncrementExpression: + * ES7 UpdateExpression: * LeftHandSideExpression[?Yield] * LeftHandSideExpression[?Yield][no LineTerminator here]++ * LeftHandSideExpression[?Yield][no LineTerminator here]-- * ++LeftHandSideExpression[?Yield] * --LeftHandSideExpression[?Yield] */ - function isIncrementExpression(): boolean { + function isUpdateExpression(): boolean { // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token()) { @@ -3457,6 +3480,7 @@ namespace ts { case SyntaxKind.DeleteKeyword: case SyntaxKind.TypeOfKeyword: case SyntaxKind.VoidKeyword: + case SyntaxKind.AwaitKeyword: return false; case SyntaxKind.LessThanToken: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression @@ -5883,10 +5907,17 @@ namespace ts { case SyntaxKind.BooleanKeyword: case SyntaxKind.SymbolKeyword: case SyntaxKind.VoidKeyword: + case SyntaxKind.NullKeyword: + case SyntaxKind.UndefinedKeyword: + case SyntaxKind.NeverKeyword: return parseTokenNode(); + case SyntaxKind.StringLiteral: + case SyntaxKind.NumericLiteral: + case SyntaxKind.TrueKeyword: + case SyntaxKind.FalseKeyword: + return parseJSDocLiteralType(); } - // TODO (drosen): Parse string literal types in JSDoc as well. return parseJSDocTypeReference(); } @@ -6063,6 +6094,12 @@ namespace ts { return finishNode(result); } + function parseJSDocLiteralType(): JSDocLiteralType { + const result = createNode(SyntaxKind.JSDocLiteralType); + result.literal = parseLiteralTypeNode(); + return finishNode(result); + } + function parseJSDocUnknownOrNullableType(): JSDocUnknownType | JSDocNullableType { const pos = scanner.getStartPos(); // skip the ? diff --git a/src/compiler/performance.ts b/src/compiler/performance.ts index 89db876ae5e..e8f064e81cd 100644 --- a/src/compiler/performance.ts +++ b/src/compiler/performance.ts @@ -6,71 +6,57 @@ namespace ts { } /*@internal*/ +/** Performance measurements for the compiler. */ namespace ts.performance { - /** Performance measurements for the compiler. */ declare const onProfilerEvent: { (markName: string): void; profiler: boolean; }; - let profilerEvent: (markName: string) => void; - let counters: Map; + + const profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true + ? onProfilerEvent + : (markName: string) => { }; + + let enabled = false; + let profilerStart = 0; + let counts: Map; + let marks: Map; let measures: Map; /** - * Emit a performance event if ts-profiler is connected. This is primarily used - * to generate heap snapshots. + * Marks a performance event. * - * @param eventName A name for the event. + * @param markName The name of the mark. */ - export function emit(eventName: string) { - if (profilerEvent) { - profilerEvent(eventName); + export function mark(markName: string) { + if (enabled) { + marks[markName] = timestamp(); + counts[markName] = (counts[markName] || 0) + 1; + profilerEvent(markName); } } - /** - * Increments a counter with the specified name. - * - * @param counterName The name of the counter. - */ - export function increment(counterName: string) { - if (counters) { - counters[counterName] = (getProperty(counters, counterName) || 0) + 1; - } - } - - /** - * Gets the value of the counter with the specified name. - * - * @param counterName The name of the counter. - */ - export function getCount(counterName: string) { - return counters && getProperty(counters, counterName) || 0; - } - - /** - * Marks the start of a performance measurement. - */ - export function mark() { - return measures ? timestamp() : 0; - } - /** * Adds a performance measurement with the specified name. * * @param measureName The name of the performance measurement. - * @param marker The timestamp of the starting mark. + * @param startMarkName The name of the starting mark. If not supplied, the point at which the + * profiler was enabled is used. + * @param endMarkName The name of the ending mark. If not supplied, the current timestamp is + * used. */ - export function measure(measureName: string, marker: number) { - if (measures) { - measures[measureName] = (getProperty(measures, measureName) || 0) + (timestamp() - marker); + export function measure(measureName: string, startMarkName?: string, endMarkName?: string) { + if (enabled) { + const end = endMarkName && marks[endMarkName] || timestamp(); + const start = startMarkName && marks[startMarkName] || profilerStart; + measures[measureName] = (measures[measureName] || 0) + (end - start); } } /** - * Iterate over each measure, performing some action - * - * @param cb The action to perform for each measure + * Gets the number of times a marker was encountered. + * + * @param markName The name of the mark. */ - export function forEachMeasure(cb: (measureName: string, duration: number) => void) { - return forEachKey(measures, key => cb(key, measures[key])); + export function getCount(markName: string) { + return counts && counts[markName] || 0; } /** @@ -79,31 +65,31 @@ namespace ts.performance { * @param measureName The name of the measure whose durations should be accumulated. */ export function getDuration(measureName: string) { - return measures && getProperty(measures, measureName) || 0; + return measures && measures[measureName] || 0; + } + + /** + * Iterate over each measure, performing some action + * + * @param cb The action to perform for each measure + */ + export function forEachMeasure(cb: (measureName: string, duration: number) => void) { + for (const key in measures) { + cb(key, measures[key]); + } } /** Enables (and resets) performance measurements for the compiler. */ export function enable() { - counters = { }; - measures = { - "I/O Read": 0, - "I/O Write": 0, - "Program": 0, - "Parse": 0, - "Bind": 0, - "Check": 0, - "Emit": 0, - }; - - profilerEvent = typeof onProfilerEvent === "function" && onProfilerEvent.profiler === true - ? onProfilerEvent - : undefined; + counts = createMap(); + marks = createMap(); + measures = createMap(); + enabled = true; + profilerStart = timestamp(); } - /** Disables (and clears) performance measurements for the compiler. */ + /** Disables performance measurements for the compiler. */ export function disable() { - counters = undefined; - measures = undefined; - profilerEvent = undefined; + enabled = false; } } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 58468bec628..345081c5e8e 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -119,49 +119,31 @@ namespace ts { } function tryReadTypesSection(packageJsonPath: string, baseDirectory: string, state: ModuleResolutionState): string { - let jsonContent: { typings?: string, types?: string, main?: string }; - try { - const jsonText = state.host.readFile(packageJsonPath); - jsonContent = jsonText ? <{ typings?: string, types?: string, main?: string }>JSON.parse(jsonText) : {}; - } - catch (e) { - // gracefully handle if readFile fails or returns not JSON - jsonContent = {}; + const jsonContent = readJson(packageJsonPath, state.host); + + function tryReadFromField(fieldName: string) { + if (hasProperty(jsonContent, fieldName)) { + const typesFile = (jsonContent)[fieldName]; + if (typeof typesFile === "string") { + const typesFilePath = normalizePath(combinePaths(baseDirectory, typesFile)); + if (state.traceEnabled) { + trace(state.host, Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); + } + return typesFilePath; + } + else { + if (state.traceEnabled) { + trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, fieldName, typeof typesFile); + } + } + } } - let typesFile: string; - let fieldName: string; - // first try to read content of 'typings' section (backward compatibility) - if (jsonContent.typings) { - if (typeof jsonContent.typings === "string") { - fieldName = "typings"; - typesFile = jsonContent.typings; - } - else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, "typings", typeof jsonContent.typings); - } - } - } - // then read 'types' - if (!typesFile && jsonContent.types) { - if (typeof jsonContent.types === "string") { - fieldName = "types"; - typesFile = jsonContent.types; - } - else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.Expected_type_of_0_field_in_package_json_to_be_string_got_1, "types", typeof jsonContent.types); - } - } - } - if (typesFile) { - const typesFilePath = normalizePath(combinePaths(baseDirectory, typesFile)); - if (state.traceEnabled) { - trace(state.host, Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, typesFile, typesFilePath); - } + const typesFilePath = tryReadFromField("typings") || tryReadFromField("types"); + if (typesFilePath) { return typesFilePath; } + // Use the main module for inferring types if no types package specified and the allowJs is set if (state.compilerOptions.allowJs && jsonContent.main && typeof jsonContent.main === "string") { if (state.traceEnabled) { @@ -173,6 +155,17 @@ namespace ts { return undefined; } + function readJson(path: string, host: ModuleResolutionHost): { typings?: string, types?: string, main?: string } { + try { + const jsonText = host.readFile(path); + return jsonText ? JSON.parse(jsonText) : {}; + } + catch (e) { + // gracefully handle if readFile fails or returns not JSON + return {}; + } + } + const typeReferenceExtensions = [".d.ts"]; function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) { @@ -508,7 +501,7 @@ namespace ts { if (state.traceEnabled) { trace(state.host, Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName); } - matchedPattern = matchPatternOrExact(getKeys(state.compilerOptions.paths), moduleName); + matchedPattern = matchPatternOrExact(getOwnKeys(state.compilerOptions.paths), moduleName); } if (matchedPattern) { @@ -668,24 +661,27 @@ namespace ts { * @param {boolean} onlyRecordFailures - if true then function won't try to actually load files but instead record all attempts as failures. This flag is necessary * in cases when we know upfront that all load attempts will fail (because containing folder does not exists) however we still need to record all failed lookup locations. */ - function loadModuleFromFile(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string { - // First try to keep/add an extension: importing "./foo.ts" can be matched by a file "./foo.ts", and "./foo" by "./foo.d.ts" - const resolvedByAddingOrKeepingExtension = loadModuleFromFileWorker(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); - if (resolvedByAddingOrKeepingExtension) { - return resolvedByAddingOrKeepingExtension; + function loadModuleFromFile(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string | undefined { + // First, try adding an extension. An import of "foo" could be matched by a file "foo.ts", or "foo.js" by "foo.js.ts" + const resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, failedLookupLocation, onlyRecordFailures, state); + if (resolvedByAddingExtension) { + return resolvedByAddingExtension; } - // Then try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one, e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" + + // If that didn't work, try stripping a ".js" or ".jsx" extension and replacing it with a TypeScript one; + // e.g. "./foo.js" can be matched by "./foo.ts" or "./foo.d.ts" if (hasJavaScriptFileExtension(candidate)) { const extensionless = removeFileExtension(candidate); if (state.traceEnabled) { const extension = candidate.substring(extensionless.length); trace(state.host, Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension); } - return loadModuleFromFileWorker(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); + return tryAddingExtensions(extensionless, extensions, failedLookupLocation, onlyRecordFailures, state); } } - function loadModuleFromFileWorker(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string { + /** Try to return an existing file that adds one of the `extensions` to `candidate`. */ + function tryAddingExtensions(candidate: string, extensions: string[], failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string | undefined { if (!onlyRecordFailures) { // check if containing folder exists - if it doesn't then just record failures for all supported extensions without disk probing const directory = getDirectoryPath(candidate); @@ -693,31 +689,29 @@ namespace ts { onlyRecordFailures = !directoryProbablyExists(directory, state.host); } } - return forEach(extensions, tryLoad); + return forEach(extensions, ext => + !(state.skipTsx && isJsxOrTsxExtension(ext)) && tryFile(candidate + ext, failedLookupLocation, onlyRecordFailures, state)); + } - function tryLoad(ext: string): string { - if (state.skipTsx && isJsxOrTsxExtension(ext)) { - return undefined; + /** Return the file if it exists. */ + function tryFile(fileName: string, failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string | undefined { + if (!onlyRecordFailures && state.host.fileExists(fileName)) { + if (state.traceEnabled) { + trace(state.host, Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); } - const fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext; - if (!onlyRecordFailures && state.host.fileExists(fileName)) { - if (state.traceEnabled) { - trace(state.host, Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName); - } - return fileName; - } - else { - if (state.traceEnabled) { - trace(state.host, Diagnostics.File_0_does_not_exist, fileName); - } - failedLookupLocation.push(fileName); - return undefined; + return fileName; + } + else { + if (state.traceEnabled) { + trace(state.host, Diagnostics.File_0_does_not_exist, fileName); } + failedLookupLocation.push(fileName); + return undefined; } } function loadNodeModuleFromDirectory(extensions: string[], candidate: string, failedLookupLocation: string[], onlyRecordFailures: boolean, state: ModuleResolutionState): string { - const packageJsonPath = combinePaths(candidate, "package.json"); + const packageJsonPath = pathToPackageJson(candidate); const directoryExists = !onlyRecordFailures && directoryProbablyExists(candidate, state.host); if (directoryExists && state.host.fileExists(packageJsonPath)) { if (state.traceEnabled) { @@ -725,7 +719,10 @@ namespace ts { } const typesFile = tryReadTypesSection(packageJsonPath, candidate, state); if (typesFile) { - const result = loadModuleFromFile(typesFile, extensions, failedLookupLocation, !directoryProbablyExists(getDirectoryPath(typesFile), state.host), state); + const onlyRecordFailures = !directoryProbablyExists(getDirectoryPath(typesFile), state.host); + // A package.json "typings" may specify an exact filename, or may choose to omit an extension. + const result = tryFile(typesFile, failedLookupLocation, onlyRecordFailures, state) || + tryAddingExtensions(typesFile, extensions, failedLookupLocation, onlyRecordFailures, state); if (result) { return result; } @@ -747,6 +744,10 @@ namespace ts { return loadModuleFromFile(combinePaths(candidate, "index"), extensions, failedLookupLocation, !directoryExists, state); } + function pathToPackageJson(directory: string): string { + return combinePaths(directory, "package.json"); + } + function loadModuleFromNodeModulesFolder(moduleName: string, directory: string, failedLookupLocations: string[], state: ModuleResolutionState): string { const nodeModulesFolder = combinePaths(directory, "node_modules"); const nodeModulesFolderExists = directoryProbablyExists(nodeModulesFolder, state.host); @@ -831,14 +832,6 @@ namespace ts { : { resolvedModule: undefined, failedLookupLocations }; } - /* @internal */ - export const defaultInitCompilerOptions: CompilerOptions = { - module: ModuleKind.CommonJS, - target: ScriptTarget.ES5, - noImplicitAny: false, - sourceMap: false, - }; - interface OutputFingerprint { hash: string; byteOrderMark: boolean; @@ -846,7 +839,7 @@ namespace ts { } export function createCompilerHost(options: CompilerOptions, setParentNodes?: boolean): CompilerHost { - const existingDirectories: Map = {}; + const existingDirectories = createMap(); function getCanonicalFileName(fileName: string): string { // if underlying system can distinguish between two files whose names differs only in cases then file name already in canonical form. @@ -860,9 +853,10 @@ namespace ts { function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void): SourceFile { let text: string; try { - const start = performance.mark(); + performance.mark("beforeIORead"); text = sys.readFile(fileName, options.charset); - performance.measure("I/O Read", start); + performance.mark("afterIORead"); + performance.measure("I/O Read", "beforeIORead", "afterIORead"); } catch (e) { if (onError) { @@ -877,7 +871,7 @@ namespace ts { } function directoryExists(directoryPath: string): boolean { - if (hasProperty(existingDirectories, directoryPath)) { + if (directoryPath in existingDirectories) { return true; } if (sys.directoryExists(directoryPath)) { @@ -899,13 +893,13 @@ namespace ts { function writeFileIfUpdated(fileName: string, data: string, writeByteOrderMark: boolean): void { if (!outputFingerprints) { - outputFingerprints = {}; + outputFingerprints = createMap(); } const hash = sys.createHash(data); const mtimeBefore = sys.getModifiedTime(fileName); - if (mtimeBefore && hasProperty(outputFingerprints, fileName)) { + if (mtimeBefore && fileName in outputFingerprints) { const fingerprint = outputFingerprints[fileName]; // If output has not been changed, and the file has no external modification @@ -929,7 +923,7 @@ namespace ts { function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) { try { - const start = performance.mark(); + performance.mark("beforeIOWrite"); ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); if (isWatchSet(options) && sys.createHash && sys.getModifiedTime) { @@ -939,7 +933,8 @@ namespace ts { sys.writeFile(fileName, data, writeByteOrderMark); } - performance.measure("I/O Write", start); + performance.mark("afterIOWrite"); + performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite"); } catch (e) { if (onError) { @@ -1041,16 +1036,11 @@ namespace ts { return []; } const resolutions: T[] = []; - const cache: Map = {}; + const cache = createMap(); for (const name of names) { - let result: T; - if (hasProperty(cache, name)) { - result = cache[name]; - } - else { - result = loader(name, containingFile); - cache[name] = result; - } + const result = name in cache + ? cache[name] + : cache[name] = loader(name, containingFile); resolutions.push(result); } return resolutions; @@ -1071,15 +1061,21 @@ namespace ts { } // Walk the primary type lookup locations - let result: string[] = []; + const result: string[] = []; if (host.directoryExists && host.getDirectories) { const typeRoots = getEffectiveTypeRoots(options, host); if (typeRoots) { for (const root of typeRoots) { if (host.directoryExists(root)) { for (const typeDirectivePath of host.getDirectories(root)) { - // Return just the type directive names - result = result.concat(getBaseFileName(normalizePath(typeDirectivePath))); + const normalized = normalizePath(typeDirectivePath); + const packageJsonPath = pathToPackageJson(combinePaths(root, normalized)); + // tslint:disable-next-line:no-null-keyword + const isNotNeededPackage = host.fileExists(packageJsonPath) && readJson(packageJsonPath, host).typings === null; + if (!isNotNeededPackage) { + // Return just the type directive names + result.push(getBaseFileName(normalized)); + } } } } @@ -1096,7 +1092,7 @@ namespace ts { let noDiagnosticsTypeChecker: TypeChecker; let classifiableNames: Map; - let resolvedTypeReferenceDirectives: Map = {}; + let resolvedTypeReferenceDirectives = createMap(); let fileProcessingDiagnostics = createDiagnosticCollection(); // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules. @@ -1111,12 +1107,12 @@ namespace ts { // If a module has some of its imports skipped due to being at the depth limit under node_modules, then track // this, as it may be imported at a shallower depth later, and then it will need its skipped imports processed. - const modulesWithElidedImports: Map = {}; + const modulesWithElidedImports = createMap(); // Track source files that are source files found by searching under node_modules, as these shouldn't be compiled. - const sourceFilesFoundSearchingNodeModules: Map = {}; + const sourceFilesFoundSearchingNodeModules = createMap(); - const start = performance.mark(); + performance.mark("beforeProgram"); host = host || createCompilerHost(options); @@ -1214,8 +1210,8 @@ namespace ts { }; verifyCompilerOptions(); - - performance.measure("Program", start); + performance.mark("afterProgram"); + performance.measure("Program", "beforeProgram", "afterProgram"); return program; @@ -1242,10 +1238,10 @@ namespace ts { if (!classifiableNames) { // Initialize a checker so that all our files are bound. getTypeChecker(); - classifiableNames = {}; + classifiableNames = createMap(); for (const sourceFile of files) { - copyMap(sourceFile.classifiableNames, classifiableNames); + copyProperties(sourceFile.classifiableNames, classifiableNames); } } @@ -1273,7 +1269,7 @@ namespace ts { (oldOptions.maxNodeModuleJsDepth !== options.maxNodeModuleJsDepth) || !arrayIsEqualTo(oldOptions.typeRoots, oldOptions.typeRoots) || !arrayIsEqualTo(oldOptions.rootDirs, options.rootDirs) || - !mapIsEqualTo(oldOptions.paths, options.paths)) { + !equalOwnProperties(oldOptions.paths, options.paths)) { return false; } @@ -1395,7 +1391,7 @@ namespace ts { getSourceFile: program.getSourceFile, getSourceFileByPath: program.getSourceFileByPath, getSourceFiles: program.getSourceFiles, - isSourceFileFromExternalLibrary: (file: SourceFile) => !!lookUp(sourceFilesFoundSearchingNodeModules, file.path), + isSourceFileFromExternalLibrary: (file: SourceFile) => !!sourceFilesFoundSearchingNodeModules[file.path], writeFile: writeFileCallback || ( (fileName, data, writeByteOrderMark, onError, sourceFiles) => host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles)), isEmitBlocked, @@ -1458,17 +1454,15 @@ namespace ts { // checked is to not pass the file to getEmitResolver. const emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); - performance.emit("beforeEmit"); - const start = performance.mark(); + performance.mark("beforeEmit"); const emitResult = emitFiles( emitResolver, getEmitHost(writeFileCallback), sourceFile); - performance.measure("Emit", start); - performance.emit("afterEmit"); - + performance.mark("afterEmit"); + performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; } @@ -1946,7 +1940,7 @@ namespace ts { // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file && lookUp(sourceFilesFoundSearchingNodeModules, file.path) && currentNodeModulesDepth == 0) { + if (file && sourceFilesFoundSearchingNodeModules[file.path] && currentNodeModulesDepth == 0) { sourceFilesFoundSearchingNodeModules[file.path] = false; if (!options.noResolve) { processReferencedFiles(file, getDirectoryPath(fileName), isDefaultLib); @@ -1957,7 +1951,7 @@ namespace ts { processImportedModules(file, getDirectoryPath(fileName)); } // See if we need to reprocess the imports due to prior skipped imports - else if (file && lookUp(modulesWithElidedImports, file.path)) { + else if (file && modulesWithElidedImports[file.path]) { if (currentNodeModulesDepth < maxNodeModulesJsDepth) { modulesWithElidedImports[file.path] = false; processImportedModules(file, getDirectoryPath(fileName)); @@ -2024,15 +2018,17 @@ namespace ts { } function processTypeReferenceDirectives(file: SourceFile) { - const typeDirectives = map(file.typeReferenceDirectives, l => l.fileName); + // We lower-case all type references because npm automatically lowercases all packages. See GH#9824. + const typeDirectives = map(file.typeReferenceDirectives, ref => ref.fileName.toLocaleLowerCase()); const resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file.fileName); for (let i = 0; i < typeDirectives.length; i++) { const ref = file.typeReferenceDirectives[i]; const resolvedTypeReferenceDirective = resolutions[i]; // store resolved type directive on the file - setResolvedTypeReferenceDirective(file, ref.fileName, resolvedTypeReferenceDirective); - processTypeReferenceDirective(ref.fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); + const fileName = ref.fileName.toLocaleLowerCase(); + setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective); + processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, file, ref.pos, ref.end); } } @@ -2057,7 +2053,7 @@ namespace ts { const otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName); if (otherFileText !== getSourceFile(previousResolution.resolvedFileName).text) { fileProcessingDiagnostics.add(createDiagnostic(refFile, refPos, refEnd, - Diagnostics.Conflicting_library_definitions_for_0_found_at_1_and_2_Copy_the_correct_file_to_the_typings_folder_to_resolve_this_conflict, + Diagnostics.Conflicting_definitions_for_0_found_at_1_and_2_Consider_installing_a_specific_version_of_this_library_to_resolve_the_conflict, typeReferenceDirective, resolvedTypeReferenceDirective.resolvedFileName, previousResolution.resolvedFileName @@ -2097,7 +2093,7 @@ namespace ts { function processImportedModules(file: SourceFile, basePath: string) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { - file.resolvedModules = {}; + file.resolvedModules = createMap(); const moduleNames = map(concatenate(file.imports, file.moduleAugmentations), getTextOfLiteral); const resolutions = resolveModuleNamesWorker(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory)); for (let i = 0; i < moduleNames.length; i++) { diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 50f569a643f..2d07c2998e0 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -55,7 +55,7 @@ namespace ts { tryScan(callback: () => T): T; } - const textToToken: Map = { + const textToToken = createMap({ "abstract": SyntaxKind.AbstractKeyword, "any": SyntaxKind.AnyKeyword, "as": SyntaxKind.AsKeyword, @@ -179,7 +179,7 @@ namespace ts { "|=": SyntaxKind.BarEqualsToken, "^=": SyntaxKind.CaretEqualsToken, "@": SyntaxKind.AtToken, - }; + }); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -274,9 +274,7 @@ namespace ts { function makeReverseMap(source: Map): string[] { const result: string[] = []; for (const name in source) { - if (source.hasOwnProperty(name)) { - result[source[name]] = name; - } + result[source[name]] = name; } return result; } diff --git a/src/compiler/sourcemap.ts b/src/compiler/sourcemap.ts index 4a31fffe81e..eb369be39d7 100644 --- a/src/compiler/sourcemap.ts +++ b/src/compiler/sourcemap.ts @@ -219,6 +219,7 @@ namespace ts { function createSourceMapWriterWorker(host: EmitHost, writer: EmitTextWriter): SourceMapWriter { const compilerOptions = host.getCompilerOptions(); + const extendedDiagnostics = compilerOptions.extendedDiagnostics; let currentSourceFile: SourceFile; let currentSourceText: string; let sourceMapDir: string; // The directory in which sourcemap will be @@ -462,7 +463,9 @@ namespace ts { return; } - const start = performance.mark(); + if (extendedDiagnostics) { + performance.mark("beforeSourcemap"); + } const sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos); @@ -504,7 +507,10 @@ namespace ts { updateLastEncodedAndRecordedSpans(); - performance.measure("Source Map", start); + if (extendedDiagnostics) { + performance.mark("afterSourcemap"); + performance.measure("Source Map", "beforeSourcemap", "afterSourcemap"); + } } function getStartPosPastDecorators(range: TextRange) { @@ -782,30 +788,30 @@ namespace ts { getSourceMapData, setSourceFile, emitPos(pos: number): void { - const sourcemapStart = performance.mark(); + performance.mark("sourcemapStart"); emitPos(pos); - performance.measure("sourceMapTime", sourcemapStart); + performance.measure("sourceMapTime", "sourcemapStart"); }, emitStart(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (node: Node) => boolean, ignoreChildrenCallback?: (node: Node) => boolean, getTextRangeCallback?: (node: Node) => TextRange): void { - const sourcemapStart = performance.mark(); + performance.mark("emitSourcemap:emitStart"); emitStart(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - performance.measure("sourceMapTime", sourcemapStart); + performance.measure("sourceMapTime", "emitSourcemap:emitStart"); }, emitEnd(range: TextRange, contextNode?: Node, ignoreNodeCallback?: (node: Node) => boolean, ignoreChildrenCallback?: (node: Node) => boolean, getTextRangeCallback?: (node: Node) => TextRange): void { - const sourcemapStart = performance.mark(); + performance.mark("emitSourcemap:emitEnd"); emitEnd(range, contextNode, ignoreNodeCallback, ignoreChildrenCallback, getTextRangeCallback); - performance.measure("sourceMapTime", sourcemapStart); + performance.measure("sourceMapTime", "emitSourcemap:emitEnd"); }, emitTokenStart(token: SyntaxKind, tokenStartPos: number, contextNode?: Node, ignoreTokenCallback?: (node: Node) => boolean, getTokenTextRangeCallback?: (node: Node, token: SyntaxKind) => TextRange): number { - const sourcemapStart = performance.mark(); + performance.mark("emitSourcemap:emitTokenStart"); tokenStartPos = emitTokenStart(token, tokenStartPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - performance.measure("sourceMapTime", sourcemapStart); + performance.measure("sourceMapTime", "emitSourcemap:emitTokenStart"); return tokenStartPos; }, emitTokenEnd(token: SyntaxKind, tokenEndPos: number, contextNode?: Node, ignoreTokenCallback?: (node: Node) => boolean, getTokenTextRangeCallback?: (node: Node, token: SyntaxKind) => TextRange): number { - const sourcemapStart = performance.mark(); + performance.mark("emitSourcemap:emitTokenEnd"); tokenEndPos = emitTokenEnd(token, tokenEndPos, contextNode, ignoreTokenCallback, getTokenTextRangeCallback); - performance.measure("sourceMapTime", sourcemapStart); + performance.measure("sourceMapTime", "emitSourcemap:emitTokenEnd"); return tokenEndPos; }, changeEmitSourcePos, diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index b7cbd33a19f..b4b776c498c 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -239,15 +239,15 @@ namespace ts { const useNonPollingWatchers = process.env["TSC_NONPOLLING_WATCHER"]; function createWatchedFileSet() { - const dirWatchers: Map = {}; + const dirWatchers = createMap(); // One file can have multiple watchers - const fileWatcherCallbacks: Map = {}; + const fileWatcherCallbacks = createMap(); return { addFile, removeFile }; function reduceDirWatcherRefCountForFile(fileName: string) { const dirName = getDirectoryPath(fileName); - if (hasProperty(dirWatchers, dirName)) { - const watcher = dirWatchers[dirName]; + const watcher = dirWatchers[dirName]; + if (watcher) { watcher.referenceCount -= 1; if (watcher.referenceCount <= 0) { watcher.close(); @@ -257,13 +257,12 @@ namespace ts { } function addDirWatcher(dirPath: string): void { - if (hasProperty(dirWatchers, dirPath)) { - const watcher = dirWatchers[dirPath]; + let watcher = dirWatchers[dirPath]; + if (watcher) { watcher.referenceCount += 1; return; } - - const watcher: DirectoryWatcher = _fs.watch( + watcher = _fs.watch( dirPath, { persistent: true }, (eventName: string, relativeFileName: string) => fileEventHandler(eventName, relativeFileName, dirPath) @@ -274,12 +273,7 @@ namespace ts { } function addFileWatcherCallback(filePath: string, callback: FileWatcherCallback): void { - if (hasProperty(fileWatcherCallbacks, filePath)) { - fileWatcherCallbacks[filePath].push(callback); - } - else { - fileWatcherCallbacks[filePath] = [callback]; - } + (fileWatcherCallbacks[filePath] || (fileWatcherCallbacks[filePath] = [])).push(callback); } function addFile(fileName: string, callback: FileWatcherCallback): WatchedFile { @@ -295,8 +289,9 @@ namespace ts { } function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) { - if (hasProperty(fileWatcherCallbacks, filePath)) { - const newCallbacks = copyListRemovingItem(callback, fileWatcherCallbacks[filePath]); + const callbacks = fileWatcherCallbacks[filePath]; + if (callbacks) { + const newCallbacks = copyListRemovingItem(callback, callbacks); if (newCallbacks.length === 0) { delete fileWatcherCallbacks[filePath]; } @@ -312,7 +307,7 @@ namespace ts { ? undefined : ts.getNormalizedAbsolutePath(relativeFileName, baseDirPath); // Some applications save a working file via rename operations - if ((eventName === "change" || eventName === "rename") && hasProperty(fileWatcherCallbacks, fileName)) { + if ((eventName === "change" || eventName === "rename") && fileWatcherCallbacks[fileName]) { for (const fileCallback of fileWatcherCallbacks[fileName]) { fileCallback(fileName); } @@ -443,7 +438,7 @@ namespace ts { } function getDirectories(path: string): string[] { - return filter(_fs.readdirSync(path), p => fileSystemEntryExists(combinePaths(path, p), FileSystemEntryKind.Directory)); + return filter(_fs.readdirSync(path), dir => fileSystemEntryExists(combinePaths(path, dir), FileSystemEntryKind.Directory)); } const nodeSystem: System = { diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index 84cd00ab79a..6242a2f2347 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -10,14 +10,14 @@ /* @internal */ namespace ts { - const moduleTransformerMap: Map = { + const moduleTransformerMap = createMap({ [ModuleKind.ES6]: transformES6Module, [ModuleKind.System]: transformSystemModule, [ModuleKind.AMD]: transformModule, [ModuleKind.CommonJS]: transformModule, [ModuleKind.UMD]: transformModule, [ModuleKind.None]: transformModule, - }; + }); const enum SyntaxKindFeatureFlags { Substitution = 1 << 0, @@ -206,7 +206,7 @@ namespace ts { const transformId = nextTransformId; nextTransformId++; - const tokenSourceMapRanges: Map = { }; + const tokenSourceMapRanges = createMap(); const lexicalEnvironmentVariableDeclarationsStack: VariableDeclaration[][] = []; const lexicalEnvironmentFunctionDeclarationsStack: FunctionDeclaration[][] = []; const enabledSyntaxKindFeatures = new Array(SyntaxKind.Count); diff --git a/src/compiler/transformers/es6.ts b/src/compiler/transformers/es6.ts index b63df6d5d6d..4e994c1acb0 100644 --- a/src/compiler/transformers/es6.ts +++ b/src/compiler/transformers/es6.ts @@ -1663,7 +1663,7 @@ namespace ts { function visitLabeledStatement(node: LabeledStatement): VisitResult { if (convertedLoopState) { if (!convertedLoopState.labels) { - convertedLoopState.labels = {}; + convertedLoopState.labels = createMap(); } convertedLoopState.labels[node.label.text] = node.label.text; } @@ -1815,7 +1815,9 @@ namespace ts { ); } else { - assignment.end = initializer.end; + // Currently there is not way to check that assignment is binary expression of destructing assignment + // so we have to cast never type to binaryExpression + (assignment).end = initializer.end; statements.push(createStatement(assignment, /*location*/ moveRangeEnd(initializer, -1))); } } @@ -2249,13 +2251,13 @@ namespace ts { function setLabeledJump(state: ConvertedLoopState, isBreak: boolean, labelText: string, labelMarker: string): void { if (isBreak) { if (!state.labeledNonLocalBreaks) { - state.labeledNonLocalBreaks = {}; + state.labeledNonLocalBreaks = createMap(); } state.labeledNonLocalBreaks[labelText] = labelMarker; } else { if (!state.labeledNonLocalContinues) { - state.labeledNonLocalContinues = {}; + state.labeledNonLocalContinues = createMap(); } state.labeledNonLocalContinues[labelText] = labelMarker; } diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 1dcb2446e0b..9a4b567cb80 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -216,13 +216,13 @@ namespace ts { Endfinally = 7, } - const instructionNames: Map = { + const instructionNames = createMap({ [Instruction.Return]: "return", [Instruction.Break]: "break", [Instruction.Yield]: "yield", [Instruction.YieldStar]: "yield*", [Instruction.Endfinally]: "endfinally", - }; + }); export function transformGenerators(context: TransformationContext) { const { @@ -1912,7 +1912,7 @@ namespace ts { function cacheExpression(node: Expression): Identifier { let temp: Identifier; if (isGeneratedIdentifier(node)) { - return node; + return node; } temp = createTempVariable(hoistVariableDeclaration); @@ -2060,8 +2060,8 @@ namespace ts { const name = declareLocal(text); if (!renamedCatchVariables) { - renamedCatchVariables = {}; - renamedCatchVariableDeclarations = {}; + renamedCatchVariables = createMap(); + renamedCatchVariableDeclarations = createMap(); context.enableSubstitution(SyntaxKind.Identifier); } diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index 90503d5a5f6..4bc523a262f 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -259,7 +259,7 @@ namespace ts { } function createEntitiesMap(): Map { - return { + return createMap({ "quot": 0x0022, "amp": 0x0026, "apos": 0x0027, @@ -513,6 +513,6 @@ namespace ts { "clubs": 0x2663, "hearts": 0x2665, "diams": 0x2666 - }; + }); } } \ No newline at end of file diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index bf908d4dbc5..144420b7ae9 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -4,12 +4,12 @@ /*@internal*/ namespace ts { export function transformModule(context: TransformationContext) { - const transformModuleDelegates: Map<(node: SourceFile) => SourceFile> = { + const transformModuleDelegates = createMap<(node: SourceFile) => SourceFile>({ [ModuleKind.None]: transformCommonJSModule, [ModuleKind.CommonJS]: transformCommonJSModule, [ModuleKind.AMD]: transformAMDModule, [ModuleKind.UMD]: transformUMDModule, - }; + }); const { startLexicalEnvironment, @@ -43,7 +43,7 @@ namespace ts { let bindingNameExportSpecifiersMap: Map; // Subset of exportSpecifiers that is a binding-name. // This is to reduce amount of memory we have to keep around even after we done with module-transformer - const bindingNameExportSpecifiersForFileMap: Map> = {}; + const bindingNameExportSpecifiersForFileMap = createMap>(); let hasExportStarsToExportValues: boolean; return transformSourceFile; @@ -667,7 +667,7 @@ namespace ts { if (!exportEquals && exportSpecifiers && hasProperty(exportSpecifiers, name.text)) { const sourceFileId = getOriginalNodeId(currentSourceFile); if (!bindingNameExportSpecifiersForFileMap[sourceFileId]) { - bindingNameExportSpecifiersForFileMap[sourceFileId] = {}; + bindingNameExportSpecifiersForFileMap[sourceFileId] = createMap(); } bindingNameExportSpecifiersForFileMap[sourceFileId][name.text] = exportSpecifiers[name.text]; addExportMemberAssignments(resultStatements, name); diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 1f7897b760c..d303dd580ef 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -1324,7 +1324,7 @@ namespace ts { } function collectDependencyGroups(externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]) { - const groupIndices: Map = {}; + const groupIndices = createMap(); const dependencyGroups: DependencyGroup[] = []; for (let i = 0; i < externalImports.length; i++) { const externalImport = externalImports[i]; diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index f66e4d6d998..6390c874885 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -3152,7 +3152,7 @@ namespace ts { context.enableSubstitution(SyntaxKind.Identifier); // Keep track of class aliases. - classAliases = {}; + classAliases = createMap(); } } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index fa2a4461b70..f6b1f33df84 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -127,11 +127,11 @@ namespace ts { const gutterSeparator = " "; const resetEscapeSequence = "\u001b[0m"; const ellipsis = "..."; - const categoryFormatMap: Map = { + const categoryFormatMap = createMap({ [DiagnosticCategory.Warning]: yellowForegroundEscapeSequence, [DiagnosticCategory.Error]: redForegroundEscapeSequence, [DiagnosticCategory.Message]: blueForegroundEscapeSequence, - }; + }); function formatAndReset(text: string, formatStyle: string) { return formatStyle + text + resetEscapeSequence; @@ -425,7 +425,7 @@ namespace ts { } // reset the cache of existing files - cachedExistingFiles = {}; + cachedExistingFiles = createMap(); const compileResult = compile(rootFileNames, compilerOptions, compilerHost); @@ -438,10 +438,9 @@ namespace ts { } function cachedFileExists(fileName: string): boolean { - if (hasProperty(cachedExistingFiles, fileName)) { - return cachedExistingFiles[fileName]; - } - return cachedExistingFiles[fileName] = hostFileExists(fileName); + return fileName in cachedExistingFiles + ? cachedExistingFiles[fileName] + : cachedExistingFiles[fileName] = hostFileExists(fileName); } function getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void) { @@ -704,7 +703,7 @@ namespace ts { const usageColumn: string[] = []; // Things like "-d, --declaration" go in here. const descriptionColumn: string[] = []; - const optionsDescriptionMap: Map = {}; // Map between option.description and list of option.type if it is a kind + const optionsDescriptionMap = createMap(); // Map between option.description and list of option.type if it is a kind for (let i = 0; i < optsList.length; i++) { const option = optsList[i]; @@ -732,9 +731,10 @@ namespace ts { description = getDiagnosticText(option.description); const options: string[] = []; const element = (option).element; - forEachKey(>element.type, key => { + const typeMap = >element.type; + for (const key in typeMap) { options.push(`'${key}'`); - }); + } optionsDescriptionMap[description] = options; } else { @@ -791,68 +791,11 @@ namespace ts { reportDiagnostic(createCompilerDiagnostic(Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), /* host */ undefined); } else { - const compilerOptions = extend(options, defaultInitCompilerOptions); - const configurations: any = { - compilerOptions: serializeCompilerOptions(compilerOptions) - }; - - if (fileNames && fileNames.length) { - // only set the files property if we have at least one file - configurations.files = fileNames; - } - else { - configurations.exclude = ["node_modules"]; - if (compilerOptions.outDir) { - configurations.exclude.push(compilerOptions.outDir); - } - } - - sys.writeFile(file, JSON.stringify(configurations, undefined, 4)); + sys.writeFile(file, JSON.stringify(generateTSConfig(options, fileNames), undefined, 4)); reportDiagnostic(createCompilerDiagnostic(Diagnostics.Successfully_created_a_tsconfig_json_file), /* host */ undefined); } return; - - function serializeCompilerOptions(options: CompilerOptions): Map { - const result: Map = {}; - const optionsNameMap = getOptionNameMap().optionNameMap; - - for (const name in options) { - if (hasProperty(options, name)) { - // tsconfig only options cannot be specified via command line, - // so we can assume that only types that can appear here string | number | boolean - const value = options[name]; - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - let optionDefinition = optionsNameMap[name.toLowerCase()]; - if (optionDefinition) { - if (typeof optionDefinition.type === "string") { - // string, number or boolean - result[name] = value; - } - else { - // Enum - const typeMap = >optionDefinition.type; - for (const key in typeMap) { - if (hasProperty(typeMap, key)) { - if (typeMap[key] === value) - result[name] = key; - } - } - } - } - break; - } - } - } - return result; - } } } diff --git a/src/compiler/types.ts b/src/compiler/types.ts index fc64ba6be8b..94aae9a2cd8 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1,9 +1,13 @@ - namespace ts { - export interface Map { + + export interface MapLike { [index: string]: T; } + export interface Map extends MapLike { + __mapBrand: any; + } + // branded string type used to store absolute, normalized and canonicalized paths // arbitrary file name can be converted to Path via toPath function export type Path = string & { __pathBrand: any }; @@ -346,6 +350,10 @@ namespace ts { JSDocTypedefTag, JSDocPropertyTag, JSDocTypeLiteral, + JSDocLiteralType, + JSDocNullKeyword, + JSDocUndefinedKeyword, + JSDocNeverKeyword, // Synthesized list SyntaxList, @@ -383,9 +391,9 @@ namespace ts { LastBinaryOperator = CaretEqualsToken, FirstNode = QualifiedName, FirstJSDocNode = JSDocTypeExpression, - LastJSDocNode = JSDocTypeLiteral, + LastJSDocNode = JSDocLiteralType, FirstJSDocTagNode = JSDocComment, - LastJSDocTagNode = JSDocTypeLiteral + LastJSDocTagNode = JSDocNeverKeyword } export const enum NodeFlags { @@ -585,7 +593,7 @@ namespace ts { // @kind(SyntaxKind.ConstructSignature) export interface ConstructSignatureDeclaration extends SignatureDeclaration, TypeElement { } - export type BindingName = Identifier | ObjectBindingPattern | ArrayBindingPattern; + export type BindingName = Identifier | BindingPattern; // @kind(SyntaxKind.VariableDeclaration) export interface VariableDeclaration extends Declaration { @@ -1038,13 +1046,19 @@ namespace ts { multiLine?: boolean; } + export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; + // @kind(SyntaxKind.PropertyAccessExpression) export interface PropertyAccessExpression extends MemberExpression, Declaration { expression: LeftHandSideExpression; name: Identifier; } - - export type IdentifierOrPropertyAccess = Identifier | PropertyAccessExpression; + /** Brand for a PropertyAccessExpression which, like a QualifiedName, consists of a sequence of identifiers separated by dots. */ + export interface PropertyAccessEntityNameExpression extends PropertyAccessExpression { + _propertyAccessExpressionLikeQualifiedNameBrand?: any; + expression: EntityNameExpression; + } // @kind(SyntaxKind.ElementAccessExpression) export interface ElementAccessExpression extends MemberExpression { @@ -1566,6 +1580,10 @@ namespace ts { type: JSDocType; } + export interface JSDocLiteralType extends JSDocType { + literal: LiteralTypeNode; + } + export type JSDocTypeReferencingNode = JSDocThisType | JSDocConstructorType | JSDocVariadicType | JSDocOptionalType | JSDocNullableType | JSDocNonNullableType; // @kind(SyntaxKind.JSDocRecordMember) @@ -2108,7 +2126,7 @@ namespace ts { writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags): SymbolAccessibilityResult; - isEntityNameVisible(entityName: EntityName | Expression, enclosingDeclaration: Node): SymbolVisibilityResult; + isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; getReferencedValueDeclaration(reference: Identifier): Declaration; @@ -2117,7 +2135,7 @@ namespace ts { moduleExportsSomeValue(moduleReferenceExpression: Expression): boolean; isArgumentsLocalBinding(node: Identifier): boolean; getExternalModuleFileFromDeclaration(declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): SourceFile; - getTypeReferenceDirectivesForEntityName(name: EntityName | PropertyAccessExpression): string[]; + getTypeReferenceDirectivesForEntityName(name: EntityNameOrEntityNameExpression): string[]; getTypeReferenceDirectivesForSymbol(symbol: Symbol, meaning?: SymbolFlags): string[]; } @@ -2224,6 +2242,8 @@ namespace ts { /* @internal */ exportSymbol?: Symbol; // Exported symbol associated with this symbol /* @internal */ constEnumOnlyModule?: boolean; // True if module contains only const enums or other modules with only const enums /* @internal */ isReferenced?: boolean; // True if the symbol is referenced elsewhere + /* @internal */ isReplaceableByMethod?: boolean; // Can this Javascript class property be replaced by a method symbol? + /* @internal */ isAssigned?: boolean; // True if the symbol is a parameter with assignments } /* @internal */ @@ -2237,6 +2257,8 @@ namespace ts { mapper?: TypeMapper; // Type mapper for instantiation alias referenced?: boolean; // True if alias symbol has been referenced as a value containingType?: UnionOrIntersectionType; // Containing union or intersection type for synthetic property + hasCommonType?: boolean; // True if constituents of synthetic property all have same type + isDiscriminantProperty?: boolean; // True if discriminant synthetic property resolvedExports?: SymbolTable; // Resolved exports of module exportsChecked?: boolean; // True if exports of external module have been checked isDeclarationWithCollidingName?: boolean; // True if symbol is block scoped redeclaration @@ -2247,9 +2269,7 @@ namespace ts { /* @internal */ export interface TransientSymbol extends Symbol, SymbolLinks { } - export interface SymbolTable { - [index: string]: Symbol; - } + export type SymbolTable = Map; /** Represents a "prefix*suffix" pattern. */ /* @internal */ @@ -2276,23 +2296,26 @@ namespace ts { AsyncMethodWithSuper = 0x00000800, // An async method that reads a value from a member of 'super'. AsyncMethodWithSuperBinding = 0x00001000, // An async method that assigns a value to a member of 'super'. CaptureArguments = 0x00002000, // Lexical 'arguments' used in body (for async functions) - EnumValuesComputed = 0x00004000, // Values for enum members have been computed, and any errors have been reported for them. - LexicalModuleMergesWithClass = 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration. - LoopWithCapturedBlockScopedBinding = 0x00010000, // Loop that contains block scoped variable captured in closure - CapturedBlockScopedBinding = 0x00020000, // Block-scoped binding that is captured in some function - BlockScopedBindingInLoop = 0x00040000, // Block-scoped binding with declaration nested inside iteration statement - ClassWithConstructorReference = 0x00080000, // Class that contains a binding to its constructor inside of the class body. - ConstructorReferenceInClass = 0x00100000, // Binding to a class constructor inside of the class's body. - NeedsLoopOutParameter = 0x00200000, // Block scoped binding whose value should be explicitly copied outside of the converted loop + EnumValuesComputed = 0x00004000, // Values for enum members have been computed, and any errors have been reported for them. + LexicalModuleMergesWithClass = 0x00008000, // Instantiated lexical module declaration is merged with a previous class declaration. + LoopWithCapturedBlockScopedBinding = 0x00010000, // Loop that contains block scoped variable captured in closure + CapturedBlockScopedBinding = 0x00020000, // Block-scoped binding that is captured in some function + BlockScopedBindingInLoop = 0x00040000, // Block-scoped binding with declaration nested inside iteration statement + ClassWithBodyScopedClassBinding = 0x00080000, // Decorated class that contains a binding to itself inside of the class body. + BodyScopedClassBinding = 0x00100000, // Binding to a decorated class inside of the class's body. + NeedsLoopOutParameter = 0x00200000, // Block scoped binding whose value should be explicitly copied outside of the converted loop + AssignmentsMarked = 0x00400000, // Parameter assignments have been marked + ClassWithConstructorReference = 0x00800000, // Class that contains a binding to its constructor inside of the class body. + ConstructorReferenceInClass = 0x01000000, // Binding to a class constructor inside of the class's body. } /* @internal */ export interface NodeLinks { + flags?: NodeCheckFlags; // Set of flags specific to Node resolvedType?: Type; // Cached type of type node resolvedSignature?: Signature; // Cached signature of signature node or call expression resolvedSymbol?: Symbol; // Cached name resolution result resolvedIndexInfo?: IndexInfo; // Cached indexing info resolution result - flags?: NodeCheckFlags; // Set of flags specific to Node enumMemberValue?: number; // Constant value of enum member isVisible?: boolean; // Is this node visible hasReportedStatementInAmbientContext?: boolean; // Cache boolean if we report statements in ambient context @@ -2322,7 +2345,7 @@ namespace ts { Class = 1 << 15, // Class Interface = 1 << 16, // Interface Reference = 1 << 17, // Generic type reference - Tuple = 1 << 18, // Tuple + Tuple = 1 << 18, // Synthesized generic tuple type Union = 1 << 19, // Union (T | U) Intersection = 1 << 20, // Intersection (T & U) Anonymous = 1 << 21, // Anonymous @@ -2444,10 +2467,6 @@ namespace ts { instantiations: Map; // Generic instantiation cache } - export interface TupleType extends ObjectType { - elementTypes: Type[]; // Element types - } - export interface UnionOrIntersectionType extends Type { types: Type[]; // Constituent types /* @internal */ @@ -2632,7 +2651,7 @@ namespace ts { } export type RootPaths = string[]; - export type PathSubstitutions = Map; + export type PathSubstitutions = MapLike; export type TsConfigOnlyOptions = RootPaths | PathSubstitutions; export type CompilerOptionsValue = string | number | boolean | (string | number)[] | TsConfigOnlyOptions; @@ -2793,7 +2812,7 @@ namespace ts { fileNames: string[]; raw?: any; errors: Diagnostic[]; - wildcardDirectories?: Map; + wildcardDirectories?: MapLike; } export const enum WatchDirectoryFlags { @@ -2803,7 +2822,7 @@ namespace ts { export interface ExpandResult { fileNames: string[]; - wildcardDirectories: Map; + wildcardDirectories: MapLike; } /* @internal */ @@ -2825,7 +2844,7 @@ namespace ts { /* @internal */ export interface CommandLineOptionOfCustomType extends CommandLineOptionBase { - type: Map; // an object literal mapping named values to actual values + type: Map; // an object literal mapping named values to actual values } /* @internal */ diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index a5848668bf0..030a3a33871 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -83,25 +83,6 @@ namespace ts { return node.end - node.pos; } - export function mapIsEqualTo(map1: Map, map2: Map): boolean { - if (!map1 || !map2) { - return map1 === map2; - } - return containsAll(map1, map2) && containsAll(map2, map1); - } - - function containsAll(map: Map, other: Map): boolean { - for (const key in map) { - if (!hasProperty(map, key)) { - continue; - } - if (!hasProperty(other, key) || map[key] !== other[key]) { - return false; - } - } - return true; - } - export function arrayIsEqualTo(array1: T[], array2: T[], equaler?: (a: T, b: T) => boolean): boolean { if (!array1 || !array2) { return array1 === array2; @@ -122,7 +103,7 @@ namespace ts { } export function hasResolvedModule(sourceFile: SourceFile, moduleNameText: string): boolean { - return sourceFile && sourceFile.resolvedModules && hasProperty(sourceFile.resolvedModules, moduleNameText); + return !!(sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules[moduleNameText]); } export function getResolvedModule(sourceFile: SourceFile, moduleNameText: string): ResolvedModule { @@ -131,7 +112,7 @@ namespace ts { export function setResolvedModule(sourceFile: SourceFile, moduleNameText: string, resolvedModule: ResolvedModule): void { if (!sourceFile.resolvedModules) { - sourceFile.resolvedModules = {}; + sourceFile.resolvedModules = createMap(); } sourceFile.resolvedModules[moduleNameText] = resolvedModule; @@ -139,7 +120,7 @@ namespace ts { export function setResolvedTypeReferenceDirective(sourceFile: SourceFile, typeReferenceDirectiveName: string, resolvedTypeReferenceDirective: ResolvedTypeReferenceDirective): void { if (!sourceFile.resolvedTypeReferenceDirectiveNames) { - sourceFile.resolvedTypeReferenceDirectiveNames = {}; + sourceFile.resolvedTypeReferenceDirectiveNames = createMap(); } sourceFile.resolvedTypeReferenceDirectiveNames[typeReferenceDirectiveName] = resolvedTypeReferenceDirective; @@ -162,7 +143,7 @@ namespace ts { } for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; - const oldResolution = oldResolutions && hasProperty(oldResolutions, names[i]) ? oldResolutions[names[i]] : undefined; + const oldResolution = oldResolutions && oldResolutions[names[i]]; const changed = oldResolution ? !newResolution || !comparer(oldResolution, newResolution) @@ -320,6 +301,10 @@ namespace ts { return node.kind >= SyntaxKind.FirstJSDocNode && node.kind <= SyntaxKind.LastJSDocNode; } + export function isJSDocTag(node: Node) { + return node.kind >= SyntaxKind.FirstJSDocTagNode && node.kind <= SyntaxKind.LastJSDocTagNode; + } + export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFile): number { if (nodeIsMissing(node) || !node.decorators) { return getTokenPosOfNode(node, sourceFile); @@ -1118,23 +1103,14 @@ namespace ts { && (node).expression.kind === SyntaxKind.SuperKeyword; } - export function isSuperPropertyCall(node: Node): node is CallExpression { - return node.kind === SyntaxKind.CallExpression - && isSuperProperty((node).expression); - } - - export function isSuperCall(node: Node): node is CallExpression { - return node.kind === SyntaxKind.CallExpression - && (node).expression.kind === SyntaxKind.SuperKeyword; - } - - export function getEntityNameFromTypeNode(node: TypeNode): EntityName | Expression { + export function getEntityNameFromTypeNode(node: TypeNode): EntityNameOrEntityNameExpression { if (node) { switch (node.kind) { case SyntaxKind.TypeReference: return (node).typeName; case SyntaxKind.ExpressionWithTypeArguments: - return (node).expression; + Debug.assert(isEntityNameExpression((node).expression)); + return (node).expression; case SyntaxKind.Identifier: case SyntaxKind.QualifiedName: return (node); @@ -1716,8 +1692,8 @@ namespace ts { // import * as from ... // import { x as } from ... // export { x as } from ... - // export = ... - // export default ... + // export = + // export default export function isAliasSymbolDeclaration(node: Node): boolean { return node.kind === SyntaxKind.ImportEqualsDeclaration || node.kind === SyntaxKind.NamespaceExportDeclaration || @@ -1725,7 +1701,11 @@ namespace ts { node.kind === SyntaxKind.NamespaceImport || node.kind === SyntaxKind.ImportSpecifier || node.kind === SyntaxKind.ExportSpecifier || - node.kind === SyntaxKind.ExportAssignment && (node).expression.kind === SyntaxKind.Identifier; + node.kind === SyntaxKind.ExportAssignment && exportAssignmentIsAlias(node); + } + + export function exportAssignmentIsAlias(node: ExportAssignment): boolean { + return isEntityNameExpression(node.expression); } export function getClassExtendsHeritageClauseElement(node: ClassLikeDeclaration | InterfaceDeclaration) { @@ -2043,7 +2023,6 @@ namespace ts { return Associativity.Right; } } - return Associativity.Left; } @@ -2198,7 +2177,7 @@ namespace ts { export function createDiagnosticCollection(): DiagnosticCollection { let nonFileDiagnostics: Diagnostic[] = []; - const fileDiagnostics: Map = {}; + const fileDiagnostics = createMap(); let diagnosticsModified = false; let modificationCount = 0; @@ -2262,9 +2241,7 @@ namespace ts { forEach(nonFileDiagnostics, pushDiagnostic); for (const key in fileDiagnostics) { - if (hasProperty(fileDiagnostics, key)) { - forEach(fileDiagnostics[key], pushDiagnostic); - } + forEach(fileDiagnostics[key], pushDiagnostic); } return sortAndDeduplicateDiagnostics(allDiagnostics); @@ -2279,9 +2256,7 @@ namespace ts { nonFileDiagnostics = sortAndDeduplicateDiagnostics(nonFileDiagnostics); for (const key in fileDiagnostics) { - if (hasProperty(fileDiagnostics, key)) { - fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]); - } + fileDiagnostics[key] = sortAndDeduplicateDiagnostics(fileDiagnostics[key]); } } } @@ -2292,7 +2267,7 @@ namespace ts { // the map below must be updated. Note that this regexp *does not* include the 'delete' character. // There is no reason for this other than that JSON.stringify does not handle it either. const escapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g; - const escapedCharsMap: Map = { + const escapedCharsMap = createMap({ "\0": "\\0", "\t": "\\t", "\v": "\\v", @@ -2305,7 +2280,7 @@ namespace ts { "\u2028": "\\u2028", // lineSeparator "\u2029": "\\u2029", // paragraphSeparator "\u0085": "\\u0085" // nextLine - }; + }); /** @@ -3083,6 +3058,11 @@ namespace ts { } } + export function isEntityNameExpression(node: Expression): node is EntityNameExpression { + return node.kind === SyntaxKind.Identifier || + node.kind === SyntaxKind.PropertyAccessExpression && isEntityNameExpression((node).expression); + } + export function isRightSideOfQualifiedNameOrPropertyAccess(node: Node) { return (node.parent.kind === SyntaxKind.QualifiedName && (node.parent).right === node) || (node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node); @@ -3111,6 +3091,11 @@ namespace ts { return forEach(supportedTypeScriptExtensions, extension => fileExtensionIs(fileName, extension)); } + /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ + export function tryExtractTypeScriptExtension(fileName: string): string | undefined { + return find(supportedTypescriptExtensionsForExtractExtension, extension => fileExtensionIs(fileName, extension)); + } + /** * Replace each instance of non-ascii characters by one, two, three, or four escape sequences * representing the UTF-8 encoding of the character, and return the expanded char code list. @@ -3190,7 +3175,7 @@ namespace ts { } function stringifyObject(value: any) { - return `{${reduceProperties(value, stringifyProperty, "")}}`; + return `{${reduceOwnProperties(value, stringifyProperty, "")}}`; } function stringifyProperty(memo: string, value: any, key: string) { @@ -3332,7 +3317,7 @@ namespace ts { return false; } - const syntaxKindCache: Map = {}; + const syntaxKindCache = createMap(); export function formatSyntaxKind(kind: SyntaxKind): string { const syntaxKindEnum = (ts).SyntaxKind; @@ -3480,7 +3465,7 @@ namespace ts { export function collectExternalModuleInfo(sourceFile: SourceFile, resolver: EmitResolver) { const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; - const exportSpecifiers: Map = {}; + const exportSpecifiers = createMap(); let exportEquals: ExportAssignment = undefined; let hasExportStarsToExportValues = false; for (const node of sourceFile.statements) { @@ -3521,7 +3506,7 @@ namespace ts { // export { x, y } for (const specifier of (node).exportClause.elements) { const name = (specifier.propertyName || specifier.name).text; - getOrUpdateProperty(exportSpecifiers, name, () => []).push(specifier); + (exportSpecifiers[name] || (exportSpecifiers[name] = [])).push(specifier); } } break; @@ -3623,7 +3608,7 @@ namespace ts { return node.kind === SyntaxKind.Identifier; } - export function isGeneratedIdentifier(node: Node): node is Identifier { + export function isGeneratedIdentifier(node: Node): boolean { // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None; } diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 8e6e2ec2765..648fd235c44 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -46,7 +46,7 @@ namespace ts { * supplant the existing `forEachChild` implementation if performance is not * significantly impacted. */ - const nodeEdgeTraversalMap: Map = { + const nodeEdgeTraversalMap = createMap({ [SyntaxKind.QualifiedName]: [ { name: "left", test: isEntityName }, { name: "right", test: isIdentifier } @@ -93,7 +93,7 @@ namespace ts { { name: "name", test: isPropertyName }, { name: "initializer", test: isExpression, optional: true, parenthesize: parenthesizeExpressionForList } ] - }; + }); function reduceNode(node: Node, f: (memo: T, node: Node) => T, initial: T) { return node ? f(initial, node) : initial; @@ -523,7 +523,7 @@ namespace ts { const edgeTraversalPath = nodeEdgeTraversalMap[kind]; if (edgeTraversalPath) { for (const edge of edgeTraversalPath) { - const value = (>node)[edge.name]; + const value = (>node)[edge.name]; if (value !== undefined) { result = isArray(value) ? reduceLeft(>value, f, result) @@ -1140,7 +1140,7 @@ namespace ts { visitNode((node).expression, visitor, isExpression)); default: - let updated: Node & Map; + let updated: Node & MapLike; const edgeTraversalPath = nodeEdgeTraversalMap[kind]; if (edgeTraversalPath) { for (const edge of edgeTraversalPath) { diff --git a/src/harness/compilerRunner.ts b/src/harness/compilerRunner.ts index 6e0c27a7ffd..63e01f0f814 100644 --- a/src/harness/compilerRunner.ts +++ b/src/harness/compilerRunner.ts @@ -1,8 +1,6 @@ /// /// /// -// In harness baselines, null is different than undefined. See `generateActual` in `harness.ts`. -/* tslint:disable:no-null-keyword */ const enum CompilerTestType { Conformance, @@ -52,7 +50,7 @@ class CompilerBaselineRunner extends RunnerBase { private makeUnitName(name: string, root: string) { const path = ts.toPath(name, root, (fileName) => Harness.Compiler.getCanonicalFileName(fileName)); const pathStart = ts.toPath(Harness.IO.getCurrentDirectory(), "", (fileName) => Harness.Compiler.getCanonicalFileName(fileName)); - return path.replace(pathStart, "/"); + return pathStart ? path.replace(pathStart, "/") : path; }; public checkTestCodeOutput(fileName: string) { @@ -136,27 +134,16 @@ class CompilerBaselineRunner extends RunnerBase { otherFiles = undefined; }); - function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string { - return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : ""; - } - - function getErrorBaseline(toBeCompiled: Harness.Compiler.TestFile[], otherFiles: Harness.Compiler.TestFile[], result: Harness.Compiler.CompilerResult) { - return Harness.Compiler.getErrorBaseline(toBeCompiled.concat(otherFiles), result.errors); - } - // check errors it("Correct errors for " + fileName, () => { if (this.errors) { - Harness.Baseline.runBaseline("Correct errors for " + fileName, justName.replace(/\.tsx?$/, ".errors.txt"), (): string => { - if (result.errors.length === 0) return null; - return getErrorBaseline(toBeCompiled, otherFiles, result); - }); + Harness.Compiler.doErrorBaseline(justName, toBeCompiled.concat(otherFiles), result.errors); } }); it (`Correct module resolution tracing for ${fileName}`, () => { if (options.traceResolution) { - Harness.Baseline.runBaseline("Correct module resolution tracing for " + fileName, justName.replace(/\.tsx?$/, ".trace.json"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".trace.json"), () => { return JSON.stringify(result.traceResults || [], undefined, 4); }); } @@ -165,11 +152,13 @@ class CompilerBaselineRunner extends RunnerBase { // Source maps? it("Correct sourcemap content for " + fileName, () => { if (options.sourceMap || options.inlineSourceMap) { - Harness.Baseline.runBaseline("Correct sourcemap content for " + fileName, justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".sourcemap.txt"), () => { const record = result.getSourceMapRecord(); if ((options.noEmitOnError && result.errors.length !== 0) || record === undefined) { - // Because of the noEmitOnError option no files are created. We need to return null because baselining isn"t required. + // Because of the noEmitOnError option no files are created. We need to return null because baselining isn't required. + /* tslint:disable:no-null-keyword */ return null; + /* tslint:enable:no-null-keyword */ } return record; }); @@ -178,87 +167,12 @@ class CompilerBaselineRunner extends RunnerBase { it("Correct JS output for " + fileName, () => { if (hasNonDtsFiles && this.emit) { - if (!options.noEmit && result.files.length === 0 && result.errors.length === 0) { - throw new Error("Expected at least one js file to be emitted or at least one error to be created."); - } - - // check js output - Harness.Baseline.runBaseline("Correct JS output for " + fileName, justName.replace(/\.tsx?/, ".js"), () => { - let tsCode = ""; - const tsSources = otherFiles.concat(toBeCompiled); - if (tsSources.length > 1) { - tsCode += "//// [" + fileName + "] ////\r\n\r\n"; - } - for (let i = 0; i < tsSources.length; i++) { - tsCode += "//// [" + Harness.Path.getFileName(tsSources[i].unitName) + "]\r\n"; - tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? "\r\n" : ""); - } - - let jsCode = ""; - for (let i = 0; i < result.files.length; i++) { - jsCode += "//// [" + Harness.Path.getFileName(result.files[i].fileName) + "]\r\n"; - jsCode += getByteOrderMarkText(result.files[i]); - jsCode += result.files[i].code; - } - - if (result.declFilesCode.length > 0) { - jsCode += "\r\n\r\n"; - for (let i = 0; i < result.declFilesCode.length; i++) { - jsCode += "//// [" + Harness.Path.getFileName(result.declFilesCode[i].fileName) + "]\r\n"; - jsCode += getByteOrderMarkText(result.declFilesCode[i]); - jsCode += result.declFilesCode[i].code; - } - } - - const declFileCompilationResult = - Harness.Compiler.compileDeclarationFiles( - toBeCompiled, otherFiles, result, harnessSettings, options, /*currentDirectory*/ undefined); - - if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) { - jsCode += "\r\n\r\n//// [DtsFileErrors]\r\n"; - jsCode += "\r\n\r\n"; - jsCode += getErrorBaseline(declFileCompilationResult.declInputFiles, declFileCompilationResult.declOtherFiles, declFileCompilationResult.declResult); - } - - if (jsCode.length > 0) { - return tsCode + "\r\n\r\n" + jsCode; - } - else { - return null; - } - }); + Harness.Compiler.doJsEmitBaseline(justName, fileName, options, result, toBeCompiled, otherFiles, harnessSettings); } }); it("Correct Sourcemap output for " + fileName, () => { - if (options.inlineSourceMap) { - if (result.sourceMaps.length > 0) { - throw new Error("No sourcemap files should be generated if inlineSourceMaps was set."); - } - return null; - } - else if (options.sourceMap) { - if (result.sourceMaps.length !== result.files.length) { - throw new Error("Number of sourcemap files should be same as js files."); - } - - Harness.Baseline.runBaseline("Correct Sourcemap output for " + fileName, justName.replace(/\.tsx?/, ".js.map"), () => { - if ((options.noEmitOnError && result.errors.length !== 0) || result.sourceMaps.length === 0) { - // We need to return null here or the runBaseLine will actually create a empty file. - // Baselining isn't required here because there is no output. - return null; - } - - let sourceMapCode = ""; - for (let i = 0; i < result.sourceMaps.length; i++) { - sourceMapCode += "//// [" + Harness.Path.getFileName(result.sourceMaps[i].fileName) + "]\r\n"; - sourceMapCode += getByteOrderMarkText(result.sourceMaps[i]); - sourceMapCode += result.sourceMaps[i].code; - } - - return sourceMapCode; - }); - } + Harness.Compiler.doSourcemapBaseline(justName, options, result); }); it("Correct type/symbol baselines for " + fileName, () => { @@ -266,129 +180,7 @@ class CompilerBaselineRunner extends RunnerBase { return; } - // NEWTODO: Type baselines - if (result.errors.length !== 0) { - return; - } - - // The full walker simulates the types that you would get from doing a full - // compile. The pull walker simulates the types you get when you just do - // a type query for a random node (like how the LS would do it). Most of the - // time, these will be the same. However, occasionally, they can be different. - // Specifically, when the compiler internally depends on symbol IDs to order - // things, then we may see different results because symbols can be created in a - // different order with 'pull' operations, and thus can produce slightly differing - // output. - // - // For example, with a full type check, we may see a type displayed as: number | string - // But with a pull type check, we may see it as: string | number - // - // These types are equivalent, but depend on what order the compiler observed - // certain parts of the program. - - const program = result.program; - const allFiles = toBeCompiled.concat(otherFiles).filter(file => !!program.getSourceFile(file.unitName)); - - const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true); - - const fullResults: ts.Map = {}; - const pullResults: ts.Map = {}; - - for (const sourceFile of allFiles) { - fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); - pullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); - } - - // Produce baselines. The first gives the types for all expressions. - // The second gives symbols for all identifiers. - let e1: Error, e2: Error; - try { - checkBaseLines(/*isSymbolBaseLine*/ false); - } - catch (e) { - e1 = e; - } - - try { - checkBaseLines(/*isSymbolBaseLine*/ true); - } - catch (e) { - e2 = e; - } - - if (e1 || e2) { - throw e1 || e2; - } - - return; - - function checkBaseLines(isSymbolBaseLine: boolean) { - const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); - const pullBaseLine = generateBaseLine(pullResults, isSymbolBaseLine); - - const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; - const pullExtension = isSymbolBaseLine ? ".symbols.pull" : ".types.pull"; - - if (fullBaseLine !== pullBaseLine) { - Harness.Baseline.runBaseline("Correct full information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); - Harness.Baseline.runBaseline("Correct pull information for " + fileName, justName.replace(/\.tsx?/, pullExtension), () => pullBaseLine); - } - else { - Harness.Baseline.runBaseline("Correct information for " + fileName, justName.replace(/\.tsx?/, fullExtension), () => fullBaseLine); - } - } - - function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { - const typeLines: string[] = []; - const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; - - allFiles.forEach(file => { - const codeLines = file.content.split("\n"); - typeWriterResults[file.unitName].forEach(result => { - if (isSymbolBaseline && !result.symbol) { - return; - } - - const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; - const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; - if (!typeMap[file.unitName]) { - typeMap[file.unitName] = {}; - } - - let typeInfo = [formattedLine]; - const existingTypeInfo = typeMap[file.unitName][result.line]; - if (existingTypeInfo) { - typeInfo = existingTypeInfo.concat(typeInfo); - } - typeMap[file.unitName][result.line] = typeInfo; - }); - - typeLines.push("=== " + file.unitName + " ===\r\n"); - for (let i = 0; i < codeLines.length; i++) { - const currentCodeLine = codeLines[i]; - typeLines.push(currentCodeLine + "\r\n"); - if (typeMap[file.unitName]) { - const typeInfo = typeMap[file.unitName][i]; - if (typeInfo) { - typeInfo.forEach(ty => { - typeLines.push(">" + ty + "\r\n"); - }); - if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === "")) { - } - else { - typeLines.push("\r\n"); - } - } - } - else { - typeLines.push("No type information for this code."); - } - } - }); - - return typeLines.join(""); - } - + Harness.Compiler.doTypeAndSymbolBaseline(justName, result, toBeCompiled.concat(otherFiles).filter(file => !!result.program.getSourceFile(file.unitName))); }); }); } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a42abbbc609..63731417f48 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -95,14 +95,14 @@ namespace FourSlash { export import IndentStyle = ts.IndentStyle; - const entityMap: ts.Map = { + const entityMap = ts.createMap({ "&": "&", "\"": """, "'": "'", "/": "/", "<": "<", ">": ">" - }; + }); export function escapeXmlAttributeValue(s: string) { return s.replace(/[&<>"'\/]/g, ch => entityMap[ch]); @@ -204,7 +204,7 @@ namespace FourSlash { public formatCodeOptions: ts.FormatCodeOptions; - private inputFiles: ts.Map = {}; // Map between inputFile's fileName and its content for easily looking up when resolving references + private inputFiles = ts.createMap(); // Map between inputFile's fileName and its content for easily looking up when resolving references // Add input file which has matched file name with the given reference-file path. // This is necessary when resolveReference flag is specified @@ -249,6 +249,7 @@ namespace FourSlash { if (compilationOptions.typeRoots) { compilationOptions.typeRoots = compilationOptions.typeRoots.map(p => ts.getNormalizedAbsolutePath(p, this.basePath)); } + compilationOptions.skipDefaultLibCheck = true; const languageServiceAdapter = this.getLanguageServiceAdapter(testType, this.cancellationToken, compilationOptions); this.languageServiceAdapterHost = languageServiceAdapter.getHost(); @@ -300,11 +301,11 @@ namespace FourSlash { } else { // resolveReference file-option is not specified then do not resolve any files and include all inputFiles - ts.forEachKey(this.inputFiles, fileName => { + for (const fileName in this.inputFiles) { if (!Harness.isDefaultLibraryFile(fileName)) { this.languageServiceAdapterHost.addScript(fileName, this.inputFiles[fileName], /*isRootFile*/ true); } - }); + } this.languageServiceAdapterHost.addScript(Harness.Compiler.defaultLibFileName, Harness.Compiler.getDefaultLibrarySourceFile().text, /*isRootFile*/ false); } @@ -376,7 +377,7 @@ namespace FourSlash { public verifyErrorExistsBetweenMarkers(startMarkerName: string, endMarkerName: string, negative: boolean) { const startMarker = this.getMarkerByName(startMarkerName); const endMarker = this.getMarkerByName(endMarkerName); - const predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { + const predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar === startPos) && (errorLimChar === endPos)) ? true : false; }; @@ -428,12 +429,12 @@ namespace FourSlash { let predicate: (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) => boolean; if (after) { - predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { + predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar >= startPos) && (errorLimChar >= startPos)) ? true : false; }; } else { - predicate = function (errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { + predicate = function(errorMinChar: number, errorLimChar: number, startPos: number, endPos: number) { return ((errorMinChar <= startPos) && (errorLimChar <= startPos)) ? true : false; }; } @@ -458,7 +459,7 @@ namespace FourSlash { endPos = endMarker.position; } - errors.forEach(function (error: ts.Diagnostic) { + errors.forEach(function(error: ts.Diagnostic) { if (predicate(error.start, error.start + error.length, startPos, endPos)) { exists = true; } @@ -475,7 +476,7 @@ namespace FourSlash { Harness.IO.log("Unexpected error(s) found. Error list is:"); } - errors.forEach(function (error: ts.Diagnostic) { + errors.forEach(function(error: ts.Diagnostic) { Harness.IO.log(" minChar: " + error.start + ", limChar: " + (error.start + error.length) + ", message: " + ts.flattenDiagnosticMessageText(error.messageText, Harness.IO.newLine()) + "\n"); @@ -593,9 +594,9 @@ namespace FourSlash { public noItemsWithSameNameButDifferentKind(): void { const completions = this.getCompletionListAtCaret(); - const uniqueItems: ts.Map = {}; + const uniqueItems = ts.createMap(); for (const item of completions.entries) { - if (!ts.hasProperty(uniqueItems, item.name)) { + if (!(item.name in uniqueItems)) { uniqueItems[item.name] = item.kind; } else { @@ -773,7 +774,7 @@ namespace FourSlash { } public verifyRangesWithSameTextReferenceEachOther() { - ts.forEachValue(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); + ts.forEachProperty(this.rangesByText(), ranges => this.verifyRangesReferenceEachOther(ranges)); } private verifyReferencesWorker(references: ts.ReferenceEntry[], fileName: string, start: number, end: number, isWriteAccess?: boolean, isDefinition?: boolean) { @@ -1131,12 +1132,10 @@ namespace FourSlash { } Harness.Baseline.runBaseline( - "Breakpoint Locations for " + this.activeFile.fileName, baselineFile, () => { return this.baselineCurrentFileLocations(pos => this.getBreakpointStatementLocation(pos)); - }, - true /* run immediately */); + }); } public baselineGetEmitOutput() { @@ -1158,7 +1157,6 @@ namespace FourSlash { } Harness.Baseline.runBaseline( - "Generate getEmitOutput baseline : " + emitFiles.join(" "), this.testData.globalOptions[metadataOptionNames.baselineFile], () => { let resultString = ""; @@ -1184,8 +1182,7 @@ namespace FourSlash { }); return resultString; - }, - true /* run immediately */); + }); } public printBreakpointLocation(pos: number) { @@ -1348,14 +1345,7 @@ namespace FourSlash { } // Enters lines of text at the current caret position - public type(text: string) { - return this.typeHighFidelity(text); - } - - // Enters lines of text at the current caret position, invoking - // language service APIs to mimic Visual Studio's behavior - // as much as possible - private typeHighFidelity(text: string) { + public type(text: string, highFidelity = false) { let offset = this.currentCaretPosition; const prevChar = " "; const checkCadence = (text.length >> 2) + 1; @@ -1364,24 +1354,26 @@ namespace FourSlash { // Make the edit const ch = text.charAt(i); this.languageServiceAdapterHost.editScript(this.activeFile.fileName, offset, offset, ch); - this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, offset); + if (highFidelity) { + this.languageService.getBraceMatchingAtPosition(this.activeFile.fileName, offset); + } this.updateMarkersForEdit(this.activeFile.fileName, offset, offset, ch); offset++; - if (ch === "(" || ch === ",") { - /* Signature help*/ - this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset); - } - else if (prevChar === " " && /A-Za-z_/.test(ch)) { - /* Completions */ - this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset); - } + if (highFidelity) { + if (ch === "(" || ch === ",") { + /* Signature help*/ + this.languageService.getSignatureHelpItems(this.activeFile.fileName, offset); + } + else if (prevChar === " " && /A-Za-z_/.test(ch)) { + /* Completions */ + this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset); + } - if (i % checkCadence === 0) { - this.checkPostEditInvariants(); - // this.languageService.getSyntacticDiagnostics(this.activeFile.fileName); - // this.languageService.getSemanticDiagnostics(this.activeFile.fileName); + if (i % checkCadence === 0) { + this.checkPostEditInvariants(); + } } // Handle post-keystroke formatting @@ -1389,14 +1381,12 @@ namespace FourSlash { const edits = this.languageService.getFormattingEditsAfterKeystroke(this.activeFile.fileName, offset, ch, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); - // this.checkPostEditInvariants(); } } } // Move the caret to wherever we ended up this.currentCaretPosition = offset; - this.fixCaretPosition(); this.checkPostEditInvariants(); } @@ -1415,7 +1405,6 @@ namespace FourSlash { const edits = this.languageService.getFormattingEditsForRange(this.activeFile.fileName, start, offset, this.formatCodeOptions); if (edits.length) { offset += this.applyEdits(this.activeFile.fileName, edits, /*isFormattingEdit*/ true); - this.checkPostEditInvariants(); } } @@ -1639,10 +1628,11 @@ namespace FourSlash { } public rangesByText(): ts.Map { - const result: ts.Map = {}; + const result = ts.createMap(); for (const range of this.getRanges()) { const text = this.rangeText(range); - (ts.getProperty(result, text) || (result[text] = [])).push(range); + const ranges = result[text] || (result[text] = []); + ranges.push(range); } return result; } @@ -1736,13 +1726,11 @@ namespace FourSlash { public baselineCurrentFileNameOrDottedNameSpans() { Harness.Baseline.runBaseline( - "Name OrDottedNameSpans for " + this.activeFile.fileName, this.testData.globalOptions[metadataOptionNames.baselineFile], () => { return this.baselineCurrentFileLocations(pos => this.getNameOrDottedNameSpan(pos)); - }, - true /* run immediately */); + }); } public printNameOrDottedNameSpans(pos: number) { @@ -1897,7 +1885,7 @@ namespace FourSlash { public verifyBraceCompletionAtPosition(negative: boolean, openingBrace: string) { - const openBraceMap: ts.Map = { + const openBraceMap = ts.createMap({ "(": ts.CharacterCodes.openParen, "{": ts.CharacterCodes.openBrace, "[": ts.CharacterCodes.openBracket, @@ -1905,7 +1893,7 @@ namespace FourSlash { '"': ts.CharacterCodes.doubleQuote, "`": ts.CharacterCodes.backtick, "<": ts.CharacterCodes.lessThan - }; + }); const charCode = openBraceMap[openingBrace]; @@ -2269,40 +2257,12 @@ namespace FourSlash { export function runFourSlashTestContent(basePath: string, testType: FourSlashTestType, content: string, fileName: string): void { // Parse out the files and their metadata const testData = parseTestData(basePath, content, fileName); - const state = new TestState(basePath, testType, testData); - - let result = ""; - const fourslashFile: Harness.Compiler.TestFile = { - unitName: Harness.Compiler.fourslashFileName, - content: undefined, - }; - const testFile: Harness.Compiler.TestFile = { - unitName: fileName, - content: content - }; - - const host = Harness.Compiler.createCompilerHost( - [fourslashFile, testFile], - (fn, contents) => result = contents, - ts.ScriptTarget.Latest, - Harness.IO.useCaseSensitiveFileNames(), - Harness.IO.getCurrentDirectory()); - - const program = ts.createProgram([Harness.Compiler.fourslashFileName, fileName], { outFile: "fourslashTestOutput.js", noResolve: true, target: ts.ScriptTarget.ES3 }, host); - - const sourceFile = host.getSourceFile(fileName, ts.ScriptTarget.ES3); - - const diagnostics = ts.getPreEmitDiagnostics(program, sourceFile); - if (diagnostics.length > 0) { - throw new Error(`Error compiling ${fileName}: ` + - diagnostics.map(e => ts.flattenDiagnosticMessageText(e.messageText, Harness.IO.newLine())).join("\r\n")); + const output = ts.transpileModule(content, { reportDiagnostics: true }); + if (output.diagnostics.length > 0) { + throw new Error(`Syntax error in ${basePath}: ${output.diagnostics[0].messageText}`); } - - program.emit(sourceFile); - - ts.Debug.assert(!!result); - runCode(result, state); + runCode(output.outputText, state); } function runCode(code: string, state: TestState): void { @@ -2395,13 +2355,14 @@ ${code} // Comment line, check for global/file @options and record them const match = optionRegex.exec(line.substr(2)); if (match) { - const fileMetadataNamesIndex = fileMetadataNames.indexOf(match[1]); + const [key, value] = match.slice(1); + const fileMetadataNamesIndex = fileMetadataNames.indexOf(key); if (fileMetadataNamesIndex === -1) { // Check if the match is already existed in the global options - if (globalOptions[match[1]] !== undefined) { - throw new Error("Global Option : '" + match[1] + "' is already existed"); + if (globalOptions[key] !== undefined) { + throw new Error(`Global option '${key}' already exists`); } - globalOptions[match[1]] = match[2]; + globalOptions[key] = value; } else { if (fileMetadataNamesIndex === fileMetadataNames.indexOf(metadataOptionNames.fileName)) { @@ -2416,12 +2377,12 @@ ${code} resetLocalData(); } - currentFileName = basePath + "/" + match[2]; - currentFileOptions[match[1]] = match[2]; + currentFileName = basePath + "/" + value; + currentFileOptions[key] = value; } else { // Add other fileMetadata flag - currentFileOptions[match[1]] = match[2]; + currentFileOptions[key] = value; } } } @@ -2509,7 +2470,7 @@ ${code} } const marker: Marker = { - fileName: fileName, + fileName, position: location.position, data: markerValue }; @@ -2526,7 +2487,7 @@ ${code} function recordMarker(fileName: string, location: LocationInformation, name: string, markerMap: MarkerMap, markers: Marker[]): Marker { const marker: Marker = { - fileName: fileName, + fileName, position: location.position }; diff --git a/src/harness/harness.ts b/src/harness/harness.ts index c38be7b07d6..fb063467698 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -822,7 +822,7 @@ namespace Harness { export function readDirectory(path: string, extension?: string[], exclude?: string[], include?: string[]) { const fs = new Utils.VirtualFileSystem(path, useCaseSensitiveFileNames()); - for (const file in listFiles(path)) { + for (const file of listFiles(path)) { fs.addFile(file); } return ts.matchFiles(path, extension, exclude, include, useCaseSensitiveFileNames(), getCurrentDirectory(), path => { @@ -922,9 +922,9 @@ namespace Harness { export const defaultLibFileName = "lib.d.ts"; export const es2015DefaultLibFileName = "lib.es2015.d.ts"; - const libFileNameSourceFileMap: ts.Map = { + const libFileNameSourceFileMap= ts.createMap({ [defaultLibFileName]: createSourceFileAndAssertInvariants(defaultLibFileName, IO.readFile(libFolder + "lib.es5.d.ts"), /*languageVersion*/ ts.ScriptTarget.Latest) - }; + }); export function getDefaultLibrarySourceFile(fileName = defaultLibFileName): ts.SourceFile { if (!isDefaultLibraryFile(fileName)) { @@ -1079,13 +1079,13 @@ namespace Harness { let optionsIndex: ts.Map; function getCommandLineOption(name: string): ts.CommandLineOption { if (!optionsIndex) { - optionsIndex = {}; + optionsIndex = ts.createMap(); const optionDeclarations = harnessOptionDeclarations.concat(ts.optionDeclarations); for (const option of optionDeclarations) { optionsIndex[option.name.toLowerCase()] = option; } } - return ts.lookUp(optionsIndex, name.toLowerCase()); + return optionsIndex[name.toLowerCase()]; } export function setCompilerOptionsFromHarnessSetting(settings: Harness.TestCaseParser.CompilerSettings, options: ts.CompilerOptions & HarnessOptions): void { @@ -1402,6 +1402,220 @@ namespace Harness { Harness.IO.newLine() + Harness.IO.newLine() + outputLines.join("\r\n"); } + export function doErrorBaseline(baselinePath: string, inputFiles: TestFile[], errors: ts.Diagnostic[]) { + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?$/, ".errors.txt"), (): string => { + if (errors.length === 0) { + /* tslint:disable:no-null-keyword */ + return null; + /* tslint:enable:no-null-keyword */ + } + return getErrorBaseline(inputFiles, errors); + }); + } + + export function doTypeAndSymbolBaseline(baselinePath: string, result: CompilerResult, allFiles: {unitName: string, content: string}[], opts?: Harness.Baseline.BaselineOptions) { + if (result.errors.length !== 0) { + return; + } + // The full walker simulates the types that you would get from doing a full + // compile. The pull walker simulates the types you get when you just do + // a type query for a random node (like how the LS would do it). Most of the + // time, these will be the same. However, occasionally, they can be different. + // Specifically, when the compiler internally depends on symbol IDs to order + // things, then we may see different results because symbols can be created in a + // different order with 'pull' operations, and thus can produce slightly differing + // output. + // + // For example, with a full type check, we may see a type displayed as: number | string + // But with a pull type check, we may see it as: string | number + // + // These types are equivalent, but depend on what order the compiler observed + // certain parts of the program. + + const program = result.program; + + const fullWalker = new TypeWriterWalker(program, /*fullTypeCheck*/ true); + + const fullResults = ts.createMap(); + + for (const sourceFile of allFiles) { + fullResults[sourceFile.unitName] = fullWalker.getTypeAndSymbols(sourceFile.unitName); + } + + // Produce baselines. The first gives the types for all expressions. + // The second gives symbols for all identifiers. + let e1: Error, e2: Error; + try { + checkBaseLines(/*isSymbolBaseLine*/ false); + } + catch (e) { + e1 = e; + } + + try { + checkBaseLines(/*isSymbolBaseLine*/ true); + } + catch (e) { + e2 = e; + } + + if (e1 || e2) { + throw e1 || e2; + } + + return; + + function checkBaseLines(isSymbolBaseLine: boolean) { + const fullBaseLine = generateBaseLine(fullResults, isSymbolBaseLine); + + const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; + + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, fullExtension), () => fullBaseLine, opts); + } + + function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { + const typeLines: string[] = []; + const typeMap: { [fileName: string]: { [lineNum: number]: string[]; } } = {}; + + allFiles.forEach(file => { + const codeLines = file.content.split("\n"); + typeWriterResults[file.unitName].forEach(result => { + if (isSymbolBaseline && !result.symbol) { + return; + } + + const typeOrSymbolString = isSymbolBaseline ? result.symbol : result.type; + const formattedLine = result.sourceText.replace(/\r?\n/g, "") + " : " + typeOrSymbolString; + if (!typeMap[file.unitName]) { + typeMap[file.unitName] = {}; + } + + let typeInfo = [formattedLine]; + const existingTypeInfo = typeMap[file.unitName][result.line]; + if (existingTypeInfo) { + typeInfo = existingTypeInfo.concat(typeInfo); + } + typeMap[file.unitName][result.line] = typeInfo; + }); + + typeLines.push("=== " + file.unitName + " ===\r\n"); + for (let i = 0; i < codeLines.length; i++) { + const currentCodeLine = codeLines[i]; + typeLines.push(currentCodeLine + "\r\n"); + if (typeMap[file.unitName]) { + const typeInfo = typeMap[file.unitName][i]; + if (typeInfo) { + typeInfo.forEach(ty => { + typeLines.push(">" + ty + "\r\n"); + }); + if (i + 1 < codeLines.length && (codeLines[i + 1].match(/^\s*[{|}]\s*$/) || codeLines[i + 1].trim() === "")) { + } + else { + typeLines.push("\r\n"); + } + } + } + else { + typeLines.push("No type information for this code."); + } + } + }); + + return typeLines.join(""); + } + } + + function getByteOrderMarkText(file: Harness.Compiler.GeneratedFile): string { + return file.writeByteOrderMark ? "\u00EF\u00BB\u00BF" : ""; + } + + export function doSourcemapBaseline(baselinePath: string, options: ts.CompilerOptions, result: CompilerResult) { + if (options.inlineSourceMap) { + if (result.sourceMaps.length > 0) { + throw new Error("No sourcemap files should be generated if inlineSourceMaps was set."); + } + return; + } + else if (options.sourceMap) { + if (result.sourceMaps.length !== result.files.length) { + throw new Error("Number of sourcemap files should be same as js files."); + } + + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, ".js.map"), () => { + if ((options.noEmitOnError && result.errors.length !== 0) || result.sourceMaps.length === 0) { + // We need to return null here or the runBaseLine will actually create a empty file. + // Baselining isn't required here because there is no output. + /* tslint:disable:no-null-keyword */ + return null; + /* tslint:enable:no-null-keyword */ + } + + let sourceMapCode = ""; + for (let i = 0; i < result.sourceMaps.length; i++) { + sourceMapCode += "//// [" + Harness.Path.getFileName(result.sourceMaps[i].fileName) + "]\r\n"; + sourceMapCode += getByteOrderMarkText(result.sourceMaps[i]); + sourceMapCode += result.sourceMaps[i].code; + } + + return sourceMapCode; + }); + } + } + + export function doJsEmitBaseline(baselinePath: string, header: string, options: ts.CompilerOptions, result: CompilerResult, toBeCompiled: Harness.Compiler.TestFile[], otherFiles: Harness.Compiler.TestFile[], harnessSettings: Harness.TestCaseParser.CompilerSettings) { + if (!options.noEmit && result.files.length === 0 && result.errors.length === 0) { + throw new Error("Expected at least one js file to be emitted or at least one error to be created."); + } + + // check js output + Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, ".js"), () => { + let tsCode = ""; + const tsSources = otherFiles.concat(toBeCompiled); + if (tsSources.length > 1) { + tsCode += "//// [" + header + "] ////\r\n\r\n"; + } + for (let i = 0; i < tsSources.length; i++) { + tsCode += "//// [" + Harness.Path.getFileName(tsSources[i].unitName) + "]\r\n"; + tsCode += tsSources[i].content + (i < (tsSources.length - 1) ? "\r\n" : ""); + } + + let jsCode = ""; + for (let i = 0; i < result.files.length; i++) { + jsCode += "//// [" + Harness.Path.getFileName(result.files[i].fileName) + "]\r\n"; + jsCode += getByteOrderMarkText(result.files[i]); + jsCode += result.files[i].code; + } + + if (result.declFilesCode.length > 0) { + jsCode += "\r\n\r\n"; + for (let i = 0; i < result.declFilesCode.length; i++) { + jsCode += "//// [" + Harness.Path.getFileName(result.declFilesCode[i].fileName) + "]\r\n"; + jsCode += getByteOrderMarkText(result.declFilesCode[i]); + jsCode += result.declFilesCode[i].code; + } + } + + const declFileCompilationResult = + Harness.Compiler.compileDeclarationFiles( + toBeCompiled, otherFiles, result, harnessSettings, options, /*currentDirectory*/ undefined); + + if (declFileCompilationResult && declFileCompilationResult.declResult.errors.length) { + jsCode += "\r\n\r\n//// [DtsFileErrors]\r\n"; + jsCode += "\r\n\r\n"; + jsCode += Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); + } + + if (jsCode.length > 0) { + return tsCode + "\r\n\r\n" + jsCode; + } + else { + /* tslint:disable:no-null-keyword */ + return null; + /* tslint:enable:no-null-keyword */ + } + }); + } + export function collateOutputs(outputFiles: Harness.Compiler.GeneratedFile[]): string { // Collect, test, and sort the fileNames outputFiles.sort((a, b) => cleanName(a.fileName).localeCompare(cleanName(b.fileName))); @@ -1643,6 +1857,7 @@ namespace Harness { /** Support class for baseline files */ export namespace Baseline { + const NoContent = ""; export interface BaselineOptions { Subfolder?: string; @@ -1677,7 +1892,42 @@ namespace Harness { } const fileCache: { [idx: string]: boolean } = {}; - function generateActual(actualFileName: string, generateContent: () => string): string { + function generateActual(generateContent: () => string): string { + + const actual = generateContent(); + + if (actual === undefined) { + throw new Error("The generated content was \"undefined\". Return \"null\" if no baselining is required.\""); + } + + return actual; + } + + function compareToBaseline(actual: string, relativeFileName: string, opts: BaselineOptions) { + // actual is now either undefined (the generator had an error), null (no file requested), + // or some real output of the function + if (actual === undefined) { + // Nothing to do + return; + } + + const refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); + + /* tslint:disable:no-null-keyword */ + if (actual === null) { + /* tslint:enable:no-null-keyword */ + actual = NoContent; + } + + let expected = ""; + if (IO.fileExists(refFileName)) { + expected = IO.readFile(refFileName); + } + + return { expected, actual }; + } + + function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string) { // For now this is written using TypeScript, because sys is not available when running old test cases. // But we need to move to sys once we have // Creates the directory including its parent if not already present @@ -1703,81 +1953,24 @@ namespace Harness { IO.deleteFile(actualFileName); } - const actual = generateContent(); - - if (actual === undefined) { - throw new Error("The generated content was \"undefined\". Return \"null\" if no baselining is required.\""); - } - - // Store the content in the 'local' folder so we - // can accept it later (manually) - /* tslint:disable:no-null-keyword */ - if (actual !== null) { - /* tslint:enable:no-null-keyword */ - IO.writeFile(actualFileName, actual); - } - - return actual; - } - - function compareToBaseline(actual: string, relativeFileName: string, opts: BaselineOptions) { - // actual is now either undefined (the generator had an error), null (no file requested), - // or some real output of the function - if (actual === undefined) { - // Nothing to do - return; - } - - const refFileName = referencePath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); - - /* tslint:disable:no-null-keyword */ - if (actual === null) { - /* tslint:enable:no-null-keyword */ - actual = ""; - } - - let expected = ""; - if (IO.fileExists(refFileName)) { - expected = IO.readFile(refFileName); - } - - return { expected, actual }; - } - - function writeComparison(expected: string, actual: string, relativeFileName: string, actualFileName: string, descriptionForDescribe: string) { const encoded_actual = Utils.encodeString(actual); - if (expected != encoded_actual) { - // Overwrite & issue error - const errMsg = "The baseline file " + relativeFileName + " has changed."; - throw new Error(errMsg); - } - } - - export function runBaseline( - descriptionForDescribe: string, - relativeFileName: string, - generateContent: () => string, - runImmediately = false, - opts?: BaselineOptions): void { - - let actual = undefined; - const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); - try { - if (runImmediately) { - actual = generateActual(actualFileName, generateContent); - const comparison = compareToBaseline(actual, relativeFileName, opts); - writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe); + if (expected !== encoded_actual) { + if (actual === NoContent) { + IO.writeFile(actualFileName + ".delete", ""); } else { - actual = generateActual(actualFileName, generateContent); - - const comparison = compareToBaseline(actual, relativeFileName, opts); - writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName, descriptionForDescribe); + IO.writeFile(actualFileName, actual); } + throw new Error(`The baseline file ${relativeFileName} has changed.`); } - catch (e) { - throw Utils.filterStack(e); - } + } + + export function runBaseline(relativeFileName: string, generateContent: () => string, opts?: BaselineOptions): void { + const actualFileName = localPath(relativeFileName, opts && opts.Baselinefolder, opts && opts.Subfolder); + + const actual = generateActual(generateContent); + const comparison = compareToBaseline(actual, relativeFileName, opts); + writeComparison(comparison.expected, comparison.actual, relativeFileName, actualFileName); } } diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index e17230aacf2..9421cbb3c89 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -123,7 +123,7 @@ namespace Harness.LanguageService { } export class LanguageServiceAdapterHost { - protected fileNameToScript: ts.Map = {}; + protected fileNameToScript = ts.createMap(); constructor(protected cancellationToken = DefaultHostCancellationToken.Instance, protected settings = ts.getDefaultCompilerOptions()) { @@ -135,7 +135,7 @@ namespace Harness.LanguageService { public getFilenames(): string[] { const fileNames: string[] = []; - ts.forEachValue(this.fileNameToScript, (scriptInfo) => { + ts.forEachProperty(this.fileNameToScript, (scriptInfo) => { if (scriptInfo.isRootFile) { // only include root files here // usually it means that we won't include lib.d.ts in the list of root files so it won't mess the computation of compilation root dir. @@ -146,7 +146,7 @@ namespace Harness.LanguageService { } public getScriptInfo(fileName: string): ScriptInfo { - return ts.lookUp(this.fileNameToScript, fileName); + return this.fileNameToScript[fileName]; } public addScript(fileName: string, content: string, isRootFile: boolean): void { @@ -235,7 +235,7 @@ namespace Harness.LanguageService { this.getModuleResolutionsForFile = (fileName) => { const scriptInfo = this.getScriptInfo(fileName); const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ true); - const imports: ts.Map = {}; + const imports = ts.createMap(); for (const module of preprocessInfo.importedFiles) { const resolutionInfo = ts.resolveModuleName(module.fileName, fileName, compilerOptions, moduleResolutionHost); if (resolutionInfo.resolvedModule) { @@ -248,7 +248,7 @@ namespace Harness.LanguageService { const scriptInfo = this.getScriptInfo(fileName); if (scriptInfo) { const preprocessInfo = ts.preProcessFile(scriptInfo.content, /*readImportFiles*/ false); - const resolutions: ts.Map = {}; + const resolutions = ts.createMap(); const settings = this.nativeHost.getCompilationSettings(); for (const typeReferenceDirective of preprocessInfo.typeReferenceDirectives) { const resolutionInfo = ts.resolveTypeReferenceDirective(typeReferenceDirective.fileName, fileName, settings, moduleResolutionHost); diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index d522940b740..6b10295122e 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -253,18 +253,15 @@ class ProjectRunner extends RunnerBase { moduleResolution: ts.ModuleResolutionKind.Classic, // currently all tests use classic module resolution kind, this will change in the future }; // Set the values specified using json - const optionNameMap: ts.Map = {}; - ts.forEach(ts.optionDeclarations, option => { - optionNameMap[option.name] = option; - }); + const optionNameMap = ts.arrayToMap(ts.optionDeclarations, option => option.name); for (const name in testCase) { - if (name !== "mapRoot" && name !== "sourceRoot" && ts.hasProperty(optionNameMap, name)) { + if (name !== "mapRoot" && name !== "sourceRoot" && name in optionNameMap) { const option = optionNameMap[name]; const optType = option.type; let value = testCase[name]; if (typeof optType !== "string") { const key = value.toLowerCase(); - if (ts.hasProperty(optType, key)) { + if (key in optType) { value = optType[key]; } } @@ -462,7 +459,7 @@ class ProjectRunner extends RunnerBase { }); it("Resolution information of (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { - Harness.Baseline.runBaseline("Resolution information of (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".json", () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".json", () => { return JSON.stringify(getCompilerResolutionInfo(), undefined, " "); }); }); @@ -470,7 +467,7 @@ class ProjectRunner extends RunnerBase { it("Errors for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { if (compilerResult.errors.length) { - Harness.Baseline.runBaseline("Errors for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".errors.txt", () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".errors.txt", () => { return getErrorsBaseline(compilerResult); }); } @@ -483,7 +480,7 @@ class ProjectRunner extends RunnerBase { // There may be multiple files with different baselines. Run all and report at the end, else // it stops copying the remaining emitted files from 'local/projectOutput' to 'local/project'. try { - Harness.Baseline.runBaseline("Baseline of emitted result (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + outputFile.fileName, () => { try { return Harness.IO.readFile(getProjectOutputFolder(outputFile.fileName, compilerResult.moduleKind)); } @@ -502,10 +499,9 @@ class ProjectRunner extends RunnerBase { } }); - // it("SourceMapRecord for (" + moduleNameToString(moduleKind) + "): " + testCaseFileName, () => { // if (compilerResult.sourceMapData) { - // Harness.Baseline.runBaseline("SourceMapRecord for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => { + // Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".sourcemap.txt", () => { // return Harness.SourceMapRecorder.getSourceMapRecord(compilerResult.sourceMapData, compilerResult.program, // ts.filter(compilerResult.outputFiles, outputFile => Harness.Compiler.isJS(outputFile.emittedFileName))); // }); @@ -518,7 +514,7 @@ class ProjectRunner extends RunnerBase { if (!compilerResult.errors.length && testCase.declaration) { const dTsCompileResult = compileCompileDTsFiles(compilerResult); if (dTsCompileResult && dTsCompileResult.errors.length) { - Harness.Baseline.runBaseline("Errors in generated Dts files for (" + moduleNameToString(compilerResult.moduleKind) + "): " + testCaseFileName, getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => { + Harness.Baseline.runBaseline(getBaselineFolder(compilerResult.moduleKind) + testCaseJustName + ".dts.errors.txt", () => { return getErrorsBaseline(dTsCompileResult); }); } diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index 1266ffa5d37..ba1ab71ec19 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -158,55 +158,56 @@ namespace RWC { it("has the expected emitted code", () => { - Harness.Baseline.runBaseline("has the expected emitted code", baseName + ".output.js", () => { + Harness.Baseline.runBaseline(`${baseName}.output.js`, () => { return Harness.Compiler.collateOutputs(compilerResult.files); - }, false, baselineOpts); + }, baselineOpts); }); it("has the expected declaration file content", () => { - Harness.Baseline.runBaseline("has the expected declaration file content", baseName + ".d.ts", () => { + Harness.Baseline.runBaseline(`${baseName}.d.ts`, () => { if (!compilerResult.declFilesCode.length) { return null; } return Harness.Compiler.collateOutputs(compilerResult.declFilesCode); - }, false, baselineOpts); + }, baselineOpts); }); it("has the expected source maps", () => { - Harness.Baseline.runBaseline("has the expected source maps", baseName + ".map", () => { + Harness.Baseline.runBaseline(`${baseName}.map`, () => { if (!compilerResult.sourceMaps.length) { return null; } return Harness.Compiler.collateOutputs(compilerResult.sourceMaps); - }, false, baselineOpts); + }, baselineOpts); }); /*it("has correct source map record", () => { if (compilerOptions.sourceMap) { - Harness.Baseline.runBaseline("has correct source map record", baseName + ".sourcemap.txt", () => { + Harness.Baseline.runBaseline(baseName + ".sourcemap.txt", () => { return compilerResult.getSourceMapRecord(); - }, false, baselineOpts); + }, baselineOpts); } });*/ it("has the expected errors", () => { - Harness.Baseline.runBaseline("has the expected errors", baseName + ".errors.txt", () => { + Harness.Baseline.runBaseline(`${baseName}.errors.txt`, () => { if (compilerResult.errors.length === 0) { return null; } // Do not include the library in the baselines to avoid noise const baselineFiles = inputFiles.concat(otherFiles).filter(f => !Harness.isDefaultLibraryFile(f.unitName)); - return Harness.Compiler.getErrorBaseline(baselineFiles, compilerResult.errors); - }, false, baselineOpts); + const errors = compilerResult.errors.filter(e => !Harness.isDefaultLibraryFile(e.file.fileName)); + return Harness.Compiler.getErrorBaseline(baselineFiles, errors); + }, baselineOpts); }); // Ideally, a generated declaration file will have no errors. But we allow generated // declaration file errors as part of the baseline. it("has the expected errors in generated declaration files", () => { if (compilerOptions.declaration && !compilerResult.errors.length) { - Harness.Baseline.runBaseline("has the expected errors in generated declaration files", baseName + ".dts.errors.txt", () => { + Harness.Baseline.runBaseline(`${baseName}.dts.errors.txt`, () => { const declFileCompilationResult = Harness.Compiler.compileDeclarationFiles( inputFiles, otherFiles, compilerResult, /*harnessSettings*/ undefined, compilerOptions, currentDirectory); @@ -217,11 +218,16 @@ namespace RWC { return Harness.Compiler.minimalDiagnosticsToString(declFileCompilationResult.declResult.errors) + Harness.IO.newLine() + Harness.IO.newLine() + Harness.Compiler.getErrorBaseline(declFileCompilationResult.declInputFiles.concat(declFileCompilationResult.declOtherFiles), declFileCompilationResult.declResult.errors); - }, false, baselineOpts); + }, baselineOpts); } }); - // TODO: Type baselines (need to refactor out from compilerRunner) + it("has the expected types", () => { + Harness.Compiler.doTypeAndSymbolBaseline(`${baseName}.types`, compilerResult, inputFiles + .concat(otherFiles) + .filter(file => !!compilerResult.program.getSourceFile(file.unitName)) + .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts); + }); }); } } diff --git a/src/harness/test262Runner.ts b/src/harness/test262Runner.ts index c44b2286b83..66cf474824b 100644 --- a/src/harness/test262Runner.ts +++ b/src/harness/test262Runner.ts @@ -67,21 +67,21 @@ class Test262BaselineRunner extends RunnerBase { }); it("has the expected emitted code", () => { - Harness.Baseline.runBaseline("has the expected emitted code", testState.filename + ".output.js", () => { + Harness.Baseline.runBaseline(testState.filename + ".output.js", () => { const files = testState.compilerResult.files.filter(f => f.fileName !== Test262BaselineRunner.helpersFilePath); return Harness.Compiler.collateOutputs(files); - }, false, Test262BaselineRunner.baselineOptions); + }, Test262BaselineRunner.baselineOptions); }); it("has the expected errors", () => { - Harness.Baseline.runBaseline("has the expected errors", testState.filename + ".errors.txt", () => { + Harness.Baseline.runBaseline(testState.filename + ".errors.txt", () => { const errors = testState.compilerResult.errors; if (errors.length === 0) { return null; } return Harness.Compiler.getErrorBaseline(testState.inputFiles, errors); - }, false, Test262BaselineRunner.baselineOptions); + }, Test262BaselineRunner.baselineOptions); }); it("satisfies invariants", () => { @@ -90,10 +90,10 @@ class Test262BaselineRunner extends RunnerBase { }); it("has the expected AST", () => { - Harness.Baseline.runBaseline("has the expected AST", testState.filename + ".AST.txt", () => { + Harness.Baseline.runBaseline(testState.filename + ".AST.txt", () => { const sourceFile = testState.compilerResult.program.getSourceFile(Test262BaselineRunner.getTestFilePath(testState.filename)); return Utils.sourceFileToJSON(sourceFile); - }, false, Test262BaselineRunner.baselineOptions); + }, Test262BaselineRunner.baselineOptions); }); }); } diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 3b9025c27c3..a21faf9dd07 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -89,6 +89,7 @@ "./unittests/convertCompilerOptionsFromJson.ts", "./unittests/convertTypingOptionsFromJson.ts", "./unittests/tsserverProjectSystem.ts", - "./unittests/matchFiles.ts" + "./unittests/matchFiles.ts", + "./unittests/initializeTSConfig.ts" ] } diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index ce2046ae6b6..0b8935b380e 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -7,16 +7,16 @@ namespace ts { } function createDefaultServerHost(fileMap: Map): server.ServerHost { - const existingDirectories: Map = {}; - forEachValue(fileMap, v => { - let dir = getDirectoryPath(v.name); + const existingDirectories = createMap(); + for (const name in fileMap) { + let dir = getDirectoryPath(name); let previous: string; do { existingDirectories[dir] = true; previous = dir; dir = getDirectoryPath(dir); } while (dir !== previous); - }); + } return { args: [], newLine: "\r\n", @@ -24,7 +24,7 @@ namespace ts { write: (s: string) => { }, readFile: (path: string, encoding?: string): string => { - return hasProperty(fileMap, path) && fileMap[path].content; + return path in fileMap ? fileMap[path].content : undefined; }, writeFile: (path: string, data: string, writeByteOrderMark?: boolean) => { throw new Error("NYI"); @@ -33,10 +33,10 @@ namespace ts { throw new Error("NYI"); }, fileExists: (path: string): boolean => { - return hasProperty(fileMap, path); + return path in fileMap; }, directoryExists: (path: string): boolean => { - return hasProperty(existingDirectories, path); + return existingDirectories[path] || false; }, createDirectory: (path: string) => { }, @@ -102,7 +102,7 @@ namespace ts { content: `foo()` }; - const serverHost = createDefaultServerHost({ [root.name]: root, [imported.name]: imported }); + const serverHost = createDefaultServerHost(createMap({ [root.name]: root, [imported.name]: imported })); const { project, rootScriptInfo } = createProject(root.name, serverHost); // ensure that imported file was found @@ -194,7 +194,7 @@ namespace ts { content: `export var y = 1` }; - const fileMap: Map = { [root.name]: root }; + const fileMap = createMap({ [root.name]: root }); const serverHost = createDefaultServerHost(fileMap); const originalFileExists = serverHost.fileExists; diff --git a/src/harness/unittests/initializeTSConfig.ts b/src/harness/unittests/initializeTSConfig.ts new file mode 100644 index 00000000000..cb995212a94 --- /dev/null +++ b/src/harness/unittests/initializeTSConfig.ts @@ -0,0 +1,44 @@ +/// +/// + +namespace ts { + describe("initTSConfig", () => { + function initTSConfigCorrectly(name: string, commandLinesArgs: string[]) { + describe(name, () => { + const commandLine = parseCommandLine(commandLinesArgs); + const initResult = generateTSConfig(commandLine.options, commandLine.fileNames); + const outputFileName = `tsConfig/${name.replace(/[^a-z0-9\-. ]/ig, "")}/tsconfig.json`; + + it(`Correct output for ${outputFileName}`, () => { + Harness.Baseline.runBaseline(outputFileName, () => { + if (initResult) { + return JSON.stringify(initResult, undefined, 4); + } + else { + // This can happen if compiler recieve invalid compiler-options + /* tslint:disable:no-null-keyword */ + return null; + /* tslint:enable:no-null-keyword */ + } + }); + }); + }); + } + + initTSConfigCorrectly("Default initialized TSConfig", ["--init"]); + + initTSConfigCorrectly("Initialized TSConfig with files options", ["--init", "file0.st", "file1.ts", "file2.ts"]); + + initTSConfigCorrectly("Initialized TSConfig with boolean value compiler options", ["--init", "--noUnusedLocals"]); + + initTSConfigCorrectly("Initialized TSConfig with enum value compiler options", ["--init", "--target", "es5", "--jsx", "react"]); + + initTSConfigCorrectly("Initialized TSConfig with list compiler options", ["--init", "--types", "jquery,mocha"]); + + initTSConfigCorrectly("Initialized TSConfig with list compiler options with enum value", ["--init", "--lib", "es5,es2015.core"]); + + initTSConfigCorrectly("Initialized TSConfig with incorrect compiler option", ["--init", "--someNonExistOption"]); + + initTSConfigCorrectly("Initialized TSConfig with incorrect compiler option value", ["--init", "--lib", "nonExistLib,es5,es2015.promise"]); + }); +} \ No newline at end of file diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index 936ea77a1dc..c8f6d60e4ad 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -9,7 +9,7 @@ namespace ts { const typeAndDiagnostics = ts.parseJSDocTypeExpressionForTests(content); assert.isTrue(typeAndDiagnostics && typeAndDiagnostics.diagnostics.length === 0); - Harness.Baseline.runBaseline("parseCorrectly", "JSDocParsing/TypeExpressions.parsesCorrectly." + name + ".json", + Harness.Baseline.runBaseline("JSDocParsing/TypeExpressions.parsesCorrectly." + name + ".json", () => Utils.sourceFileToJSON(typeAndDiagnostics.jsDocTypeExpression.type)); }); } @@ -99,7 +99,7 @@ namespace ts { Debug.fail("Comment has at least one diagnostic: " + comment.diagnostics[0].messageText); } - Harness.Baseline.runBaseline("parseCorrectly", "JSDocParsing/DocComments.parsesCorrectly." + name + ".json", + Harness.Baseline.runBaseline("JSDocParsing/DocComments.parsesCorrectly." + name + ".json", () => JSON.stringify(comment.jsDocComment, (k, v) => v && v.pos !== undefined ? JSON.parse(Utils.sourceFileToJSON(v)) : v, 4)); }); diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 5f63889b084..3e1ac171216 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -10,7 +10,7 @@ namespace ts { const map = arrayToMap(files, f => f.name); if (hasDirectoryExists) { - const directories: Map = {}; + const directories = createMap(); for (const f of files) { let name = getDirectoryPath(f.name); while (true) { @@ -25,19 +25,19 @@ namespace ts { return { readFile, directoryExists: path => { - return hasProperty(directories, path); + return path in directories; }, fileExists: path => { - assert.isTrue(hasProperty(directories, getDirectoryPath(path)), `'fileExists' '${path}' request in non-existing directory`); - return hasProperty(map, path); + assert.isTrue(getDirectoryPath(path) in directories, `'fileExists' '${path}' request in non-existing directory`); + return path in map; } }; } else { - return { readFile, fileExists: path => hasProperty(map, path), }; + return { readFile, fileExists: path => path in map, }; } function readFile(path: string): string { - return hasProperty(map, path) ? map[path].content : undefined; + return path in map ? map[path].content : undefined; } } @@ -287,7 +287,7 @@ namespace ts { const host: CompilerHost = { getSourceFile: (fileName: string, languageVersion: ScriptTarget) => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined; + return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, @@ -298,7 +298,7 @@ namespace ts { useCaseSensitiveFileNames: () => false, fileExists: fileName => { const path = normalizePath(combinePaths(currentDirectory, fileName)); - return hasProperty(files, path); + return path in files; }, readFile: (fileName): string => { throw new Error("NotImplemented"); } }; @@ -318,7 +318,7 @@ namespace ts { } it("should find all modules", () => { - const files: Map = { + const files = createMap({ "/a/b/c/first/shared.ts": ` class A {} export = A`, @@ -332,23 +332,23 @@ import Shared = require('../first/shared'); class C {} export = C; ` - }; + }); test(files, "/a/b/c/first/second", ["class_a.ts"], 3, ["../../../c/third/class_c.ts"]); }); it("should find modules in node_modules", () => { - const files: Map = { + const files = createMap({ "/parent/node_modules/mod/index.d.ts": "export var x", "/parent/app/myapp.ts": `import {x} from "mod"` - }; + }); test(files, "/parent/app", ["myapp.ts"], 2, []); }); it("should find file referenced via absolute and relative names", () => { - const files: Map = { + const files = createMap({ "/a/b/c.ts": `/// `, "/a/b/b.ts": "var x" - }; + }); test(files, "/a/b", ["c.ts", "/a/b/b.ts"], 2, []); }); }); @@ -358,11 +358,7 @@ export = C; function test(files: Map, options: CompilerOptions, currentDirectory: string, useCaseSensitiveFileNames: boolean, rootFiles: string[], diagnosticCodes: number[]): void { const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); if (!useCaseSensitiveFileNames) { - const f: Map = {}; - for (const fileName in files) { - f[getCanonicalFileName(fileName)] = files[fileName]; - } - files = f; + files = reduceProperties(files, (files, file, fileName) => (files[getCanonicalFileName(fileName)] = file, files), createMap()); } const host: CompilerHost = { @@ -371,7 +367,7 @@ export = C; return library; } const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return hasProperty(files, path) ? createSourceFile(fileName, files[path], languageVersion) : undefined; + return path in files ? createSourceFile(fileName, files[path], languageVersion) : undefined; }, getDefaultLibFileName: () => "lib.d.ts", writeFile: (fileName, content): void => { throw new Error("NotImplemented"); }, @@ -382,7 +378,7 @@ export = C; useCaseSensitiveFileNames: () => useCaseSensitiveFileNames, fileExists: fileName => { const path = getCanonicalFileName(normalizePath(combinePaths(currentDirectory, fileName))); - return hasProperty(files, path); + return path in files; }, readFile: (fileName): string => { throw new Error("NotImplemented"); } }; @@ -395,77 +391,77 @@ export = C; } it("should succeed when the same file is referenced using absolute and relative names", () => { - const files: Map = { + const files = createMap({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" - }; + }); test(files, { module: ts.ModuleKind.AMD }, "/a/b", /*useCaseSensitiveFileNames*/ false, ["c.ts", "/a/b/d.ts"], []); }); it("should fail when two files used in program differ only in casing (tripleslash references)", () => { - const files: Map = { + const files = createMap({ "/a/b/c.ts": `/// `, "/a/b/d.ts": "var x" - }; + }); test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /*useCaseSensitiveFileNames*/ false, ["c.ts", "d.ts"], [1149]); }); it("should fail when two files used in program differ only in casing (imports)", () => { - const files: Map = { + const files = createMap({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/d.ts": "export var x" - }; + }); test(files, { module: ts.ModuleKind.AMD, forceConsistentCasingInFileNames: true }, "/a/b", /*useCaseSensitiveFileNames*/ false, ["c.ts", "d.ts"], [1149]); }); it("should fail when two files used in program differ only in casing (imports, relative module names)", () => { - const files: Map = { + const files = createMap({ "moduleA.ts": `import {x} from "./ModuleB"`, "moduleB.ts": "export var x" - }; + }); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /*useCaseSensitiveFileNames*/ false, ["moduleA.ts", "moduleB.ts"], [1149]); }); it("should fail when two files exist on disk that differs only in casing", () => { - const files: Map = { + const files = createMap({ "/a/b/c.ts": `import {x} from "D"`, "/a/b/D.ts": "export var x", "/a/b/d.ts": "export var y" - }; + }); test(files, { module: ts.ModuleKind.AMD }, "/a/b", /*useCaseSensitiveFileNames*/ true, ["c.ts", "d.ts"], [1149]); }); it("should fail when module name in 'require' calls has inconsistent casing", () => { - const files: Map = { + const files = createMap({ "moduleA.ts": `import a = require("./ModuleC")`, "moduleB.ts": `import a = require("./moduleC")`, "moduleC.ts": "export var x" - }; + }); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "", /*useCaseSensitiveFileNames*/ false, ["moduleA.ts", "moduleB.ts", "moduleC.ts"], [1149, 1149]); }); it("should fail when module names in 'require' calls has inconsistent casing and current directory has uppercase chars", () => { - const files: Map = { + const files = createMap({ "/a/B/c/moduleA.ts": `import a = require("./ModuleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", "/a/B/c/moduleD.ts": ` -import a = require("./moduleA.ts"); -import b = require("./moduleB.ts"); +import a = require("./moduleA"); +import b = require("./moduleB"); ` - }; + }); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], [1149]); }); it("should not fail when module names in 'require' calls has consistent casing and current directory has uppercase chars", () => { - const files: Map = { + const files = createMap({ "/a/B/c/moduleA.ts": `import a = require("./moduleC")`, "/a/B/c/moduleB.ts": `import a = require("./moduleC")`, "/a/B/c/moduleC.ts": "export var x", "/a/B/c/moduleD.ts": ` -import a = require("./moduleA.ts"); -import b = require("./moduleB.ts"); +import a = require("./moduleA"); +import b = require("./moduleB"); ` - }; + }); test(files, { module: ts.ModuleKind.CommonJS, forceConsistentCasingInFileNames: true }, "/a/B/c", /*useCaseSensitiveFileNames*/ false, ["moduleD.ts"], []); }); }); @@ -1023,7 +1019,7 @@ import b = require("./moduleB.ts"); const names = map(files, f => f.name); const sourceFiles = arrayToMap(map(files, f => createSourceFile(f.name, f.content, ScriptTarget.ES6)), f => f.fileName); const compilerHost: CompilerHost = { - fileExists : fileName => hasProperty(sourceFiles, fileName), + fileExists : fileName => fileName in sourceFiles, getSourceFile: fileName => sourceFiles[fileName], getDefaultLibFileName: () => "lib.d.ts", writeFile(file, text) { @@ -1034,7 +1030,7 @@ import b = require("./moduleB.ts"); getCanonicalFileName: f => f.toLowerCase(), getNewLine: () => "\r\n", useCaseSensitiveFileNames: () => false, - readFile: fileName => hasProperty(sourceFiles, fileName) ? sourceFiles[fileName].text : undefined + readFile: fileName => fileName in sourceFiles ? sourceFiles[fileName].text : undefined }; const program1 = createProgram(names, {}, compilerHost); const diagnostics1 = program1.getFileProcessingDiagnostics().getDiagnostics(); diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 8b2b15c15b3..60687d34c55 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -95,13 +95,14 @@ namespace ts { } } + function createSourceFileWithText(fileName: string, sourceText: SourceText, target: ScriptTarget) { + const file = createSourceFile(fileName, sourceText.getFullText(), target); + file.sourceText = sourceText; + return file; + } + function createTestCompilerHost(texts: NamedSourceText[], target: ScriptTarget): CompilerHost { - const files: Map = {}; - for (const t of texts) { - const file = createSourceFile(t.name, t.text.getFullText(), target); - file.sourceText = t.text; - files[t.name] = file; - } + const files = arrayToMap(texts, t => t.name, t => createSourceFileWithText(t.name, t.text, target)); return { getSourceFile(fileName): SourceFile { @@ -128,10 +129,9 @@ namespace ts { getNewLine(): string { return sys ? sys.newLine : newLine; }, - fileExists: fileName => hasProperty(files, fileName), + fileExists: fileName => fileName in files, readFile: fileName => { - const file = lookUp(files, fileName); - return file && file.text; + return fileName in files ? files[fileName].text : undefined; } }; } @@ -152,29 +152,29 @@ namespace ts { return program; } - function getSizeOfMap(map: Map): number { - let size = 0; - for (const id in map) { - if (hasProperty(map, id)) { - size++; + function checkResolvedModule(expected: ResolvedModule, actual: ResolvedModule): boolean { + if (!expected === !actual) { + if (expected) { + assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); + assert.isTrue(expected.isExternalLibraryImport === actual.isExternalLibraryImport, `'isExternalLibraryImport': expected '${expected.isExternalLibraryImport}' to be equal to '${actual.isExternalLibraryImport}'`); } + return true; } - return size; + return false; } - function checkResolvedModule(expected: ResolvedModule, actual: ResolvedModule): void { - assert.isTrue(actual !== undefined); - assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); - assert.isTrue(expected.isExternalLibraryImport === actual.isExternalLibraryImport, `'isExternalLibraryImport': expected '${expected.isExternalLibraryImport}' to be equal to '${actual.isExternalLibraryImport}'`); + function checkResolvedTypeDirective(expected: ResolvedTypeReferenceDirective, actual: ResolvedTypeReferenceDirective): boolean { + if (!expected === !actual) { + if (expected) { + assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); + assert.isTrue(expected.primary === actual.primary, `'primary': expected '${expected.primary}' to be equal to '${actual.primary}'`); + } + return true; + } + return false; } - function checkResolvedTypeDirective(expected: ResolvedTypeReferenceDirective, actual: ResolvedTypeReferenceDirective): void { - assert.isTrue(actual !== undefined); - assert.isTrue(expected.resolvedFileName === actual.resolvedFileName, `'resolvedFileName': expected '${expected.resolvedFileName}' to be equal to '${actual.resolvedFileName}'`); - assert.isTrue(expected.primary === actual.primary, `'primary': expected '${expected.primary}' to be equal to '${actual.primary}'`); - } - - function checkCache(caption: string, program: Program, fileName: string, expectedContent: Map, getCache: (f: SourceFile) => Map, entryChecker: (expected: T, original: T) => void): void { + function checkCache(caption: string, program: Program, fileName: string, expectedContent: Map, getCache: (f: SourceFile) => Map, entryChecker: (expected: T, original: T) => boolean): void { const file = program.getSourceFile(fileName); assert.isTrue(file !== undefined, `cannot find file ${fileName}`); const cache = getCache(file); @@ -183,23 +183,7 @@ namespace ts { } else { assert.isTrue(cache !== undefined, `expected ${caption} to be set`); - const actualCacheSize = getSizeOfMap(cache); - const expectedSize = getSizeOfMap(expectedContent); - assert.isTrue(actualCacheSize === expectedSize, `expected actual size: ${actualCacheSize} to be equal to ${expectedSize}`); - - for (const id in expectedContent) { - if (hasProperty(expectedContent, id)) { - - if (expectedContent[id]) { - const expected = expectedContent[id]; - const actual = cache[id]; - entryChecker(expected, actual); - } - } - else { - assert.isTrue(cache[id] === undefined); - } - } + assert.isTrue(equalOwnProperties(expectedContent, cache, entryChecker), `contents of ${caption} did not match the expected contents.`); } } @@ -313,6 +297,8 @@ namespace ts { }); it("resolution cache follows imports", () => { + (Error).stackTraceLimit = Infinity; + const files = [ { name: "a.ts", text: SourceText.New("", "import {_} from 'b'", "var x = 1") }, { name: "b.ts", text: SourceText.New("", "", "var y = 2") }, @@ -320,7 +306,7 @@ namespace ts { const options: CompilerOptions = { target }; const program_1 = newProgram(files, ["a.ts"], options); - checkResolvedModulesCache(program_1, "a.ts", { "b": { resolvedFileName: "b.ts" } }); + checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": { resolvedFileName: "b.ts" } })); checkResolvedModulesCache(program_1, "b.ts", undefined); const program_2 = updateProgram(program_1, ["a.ts"], options, files => { @@ -329,7 +315,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedModulesCache(program_1, "a.ts", { "b": { resolvedFileName: "b.ts" } }); + checkResolvedModulesCache(program_1, "a.ts", createMap({ "b": { resolvedFileName: "b.ts" } })); checkResolvedModulesCache(program_1, "b.ts", undefined); // imports has changed - program is not reused @@ -346,7 +332,7 @@ namespace ts { files[0].text = files[0].text.updateImportsAndExports(newImports); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedModulesCache(program_4, "a.ts", { "b": { resolvedFileName: "b.ts" }, "c": undefined }); + checkResolvedModulesCache(program_4, "a.ts", createMap({ "b": { resolvedFileName: "b.ts" }, "c": undefined })); }); it("resolved type directives cache follows type directives", () => { @@ -357,7 +343,7 @@ namespace ts { const options: CompilerOptions = { target, typeRoots: ["/types"] }; const program_1 = newProgram(files, ["/a.ts"], options); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", { "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); const program_2 = updateProgram(program_1, ["/a.ts"], options, files => { @@ -366,7 +352,7 @@ namespace ts { assert.isTrue(program_1.structureIsReused); // content of resolution cache should not change - checkResolvedTypeDirectivesCache(program_1, "/a.ts", { "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); checkResolvedTypeDirectivesCache(program_1, "/types/typedefs/index.d.ts", undefined); // type reference directives has changed - program is not reused @@ -384,7 +370,7 @@ namespace ts { files[0].text = files[0].text.updateReferences(newReferences); }); assert.isTrue(!program_3.structureIsReused); - checkResolvedTypeDirectivesCache(program_1, "/a.ts", { "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } }); + checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMap({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); }); }); diff --git a/src/harness/unittests/session.ts b/src/harness/unittests/session.ts index ba3b99978fa..83baa20e3f7 100644 --- a/src/harness/unittests/session.ts +++ b/src/harness/unittests/session.ts @@ -107,7 +107,7 @@ namespace ts.server { describe("onMessage", () => { it("should not throw when commands are executed with invalid arguments", () => { let i = 0; - for (name in CommandNames) { + for (const name in CommandNames) { if (!Object.prototype.hasOwnProperty.call(CommandNames, name)) { continue; } @@ -363,13 +363,13 @@ namespace ts.server { class InProcClient { private server: InProcSession; private seq = 0; - private callbacks: ts.Map<(resp: protocol.Response) => void> = {}; - private eventHandlers: ts.Map<(args: any) => void> = {}; + private callbacks = createMap<(resp: protocol.Response) => void>(); + private eventHandlers = createMap<(args: any) => void>(); handle(msg: protocol.Message): void { if (msg.type === "response") { const response = msg; - if (this.callbacks[response.request_seq]) { + if (response.request_seq in this.callbacks) { this.callbacks[response.request_seq](response); delete this.callbacks[response.request_seq]; } @@ -381,7 +381,7 @@ namespace ts.server { } emit(name: string, args: any): void { - if (this.eventHandlers[name]) { + if (name in this.eventHandlers) { this.eventHandlers[name](args); } } diff --git a/src/harness/unittests/transpile.ts b/src/harness/unittests/transpile.ts index be1c2794f63..808a5df37c1 100644 --- a/src/harness/unittests/transpile.ts +++ b/src/harness/unittests/transpile.ts @@ -61,8 +61,8 @@ namespace ts { oldTranspileDiagnostics = undefined; }); - it("Correct errors", () => { - Harness.Baseline.runBaseline("Correct errors", justName.replace(/\.tsx?$/, ".errors.txt"), () => { + it("Correct errors for " + justName, () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".errors.txt"), () => { if (transpileResult.diagnostics.length === 0) { /* tslint:disable:no-null-keyword */ return null; @@ -74,8 +74,8 @@ namespace ts { }); if (canUseOldTranspile) { - it("Correct errors (old transpile)", () => { - Harness.Baseline.runBaseline("Correct errors", justName.replace(/\.tsx?$/, ".oldTranspile.errors.txt"), () => { + it("Correct errors (old transpile) for " + justName, () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".oldTranspile.errors.txt"), () => { if (oldTranspileDiagnostics.length === 0) { /* tslint:disable:no-null-keyword */ return null; @@ -87,8 +87,8 @@ namespace ts { }); } - it("Correct output", () => { - Harness.Baseline.runBaseline("Correct output", justName.replace(/\.tsx?$/, ".js"), () => { + it("Correct output for " + justName, () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".js"), () => { if (transpileResult.outputText) { return transpileResult.outputText; } @@ -102,8 +102,8 @@ namespace ts { }); if (canUseOldTranspile) { - it("Correct output (old transpile)", () => { - Harness.Baseline.runBaseline("Correct output", justName.replace(/\.tsx?$/, ".oldTranspile.js"), () => { + it("Correct output (old transpile) for " + justName, () => { + Harness.Baseline.runBaseline(justName.replace(/\.tsx?$/, ".oldTranspile.js"), () => { return oldTranspileResult; }); }); diff --git a/src/harness/unittests/tsconfigParsing.ts b/src/harness/unittests/tsconfigParsing.ts index 557379dff3b..2c9bcdb8423 100644 --- a/src/harness/unittests/tsconfigParsing.ts +++ b/src/harness/unittests/tsconfigParsing.ts @@ -181,5 +181,25 @@ namespace ts { ["/d.ts", "/folder/e.ts"] ); }); + + it("parse and re-emit tsconfig.json file with diagnostics", () => { + const content = `{ + "compilerOptions": { + "allowJs": true + "outDir": "bin" + } + "files": ["file1.ts"] + }`; + const { configJsonObject, diagnostics } = parseAndReEmitConfigJSONFile(content); + const expectedResult = { + compilerOptions: { + allowJs: true, + outDir: "bin" + }, + files: ["file1.ts"] + }; + assert.isTrue(diagnostics.length === 2); + assert.equal(JSON.stringify(configJsonObject), JSON.stringify(expectedResult)); + }); }); } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index 9ef100fd797..c9bef7fea7b 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -68,20 +68,10 @@ namespace ts { return entry; } - function sizeOfMap(map: Map): number { - let n = 0; - for (const name in map) { - if (hasProperty(map, name)) { - n++; - } - } - return n; - } - function checkMapKeys(caption: string, map: Map, expectedKeys: string[]) { - assert.equal(sizeOfMap(map), expectedKeys.length, `${caption}: incorrect size of map`); + assert.equal(reduceProperties(map, count => count + 1, 0), expectedKeys.length, `${caption}: incorrect size of map`); for (const name of expectedKeys) { - assert.isTrue(hasProperty(map, name), `${caption} is expected to contain ${name}, actual keys: ${getKeys(map)}`); + assert.isTrue(name in map, `${caption} is expected to contain ${name}, actual keys: ${Object.keys(map)}`); } } @@ -126,8 +116,8 @@ namespace ts { private getCanonicalFileName: (s: string) => string; private toPath: (f: string) => Path; private callbackQueue: TimeOutCallback[] = []; - readonly watchedDirectories: Map<{ cb: DirectoryWatcherCallback, recursive: boolean }[]> = {}; - readonly watchedFiles: Map = {}; + readonly watchedDirectories = createMap<{ cb: DirectoryWatcherCallback, recursive: boolean }[]>(); + readonly watchedFiles = createMap(); constructor(public useCaseSensitiveFileNames: boolean, private executingFilePath: string, private currentDirectory: string, fileOrFolderList: FileOrFolder[]) { this.getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); @@ -208,7 +198,7 @@ namespace ts { watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher { const path = this.toPath(directoryName); - const callbacks = lookUp(this.watchedDirectories, path) || (this.watchedDirectories[path] = []); + const callbacks = this.watchedDirectories[path] || (this.watchedDirectories[path] = []); callbacks.push({ cb: callback, recursive }); return { referenceCount: 0, @@ -229,7 +219,7 @@ namespace ts { triggerDirectoryWatcherCallback(directoryName: string, fileName: string): void { const path = this.toPath(directoryName); - const callbacks = lookUp(this.watchedDirectories, path); + const callbacks = this.watchedDirectories[path]; if (callbacks) { for (const callback of callbacks) { callback.cb(fileName); @@ -239,7 +229,7 @@ namespace ts { triggerFileWatcherCallback(fileName: string, removed?: boolean): void { const path = this.toPath(fileName); - const callbacks = lookUp(this.watchedFiles, path); + const callbacks = this.watchedFiles[path]; if (callbacks) { for (const callback of callbacks) { callback(path, removed); @@ -249,7 +239,7 @@ namespace ts { watchFile(fileName: string, callback: FileWatcherCallback) { const path = this.toPath(fileName); - const callbacks = lookUp(this.watchedFiles, path) || (this.watchedFiles[path] = []); + const callbacks = this.watchedFiles[path] || (this.watchedFiles[path] = []); callbacks.push(callback); return { close: () => { @@ -596,7 +586,7 @@ namespace ts { content: `{ "compilerOptions": { "target": "es6" - }, + }, "files": [ "main.ts" ] }` }; @@ -623,7 +613,7 @@ namespace ts { content: `{ "compilerOptions": { "target": "es6" - }, + }, "files": [ "main.ts" ] }` }; @@ -635,5 +625,23 @@ namespace ts { checkNumberOfConfiguredProjects(projectService, 1); checkNumberOfInferredProjects(projectService, 0); }); + + it("should tolerate config file errors and still try to build a project", () => { + const configFile: FileOrFolder = { + path: "/a/b/tsconfig.json", + content: `{ + "compilerOptions": { + "target": "es6", + "allowAnything": true + }, + "someOtherProperty": {} + }` + }; + const host = new TestServerHost(/*useCaseSensitiveFileNames*/ false, getExecutingFilePathFromLibFile(libFile), "/", [commonFile1, commonFile2, libFile, configFile]); + const projectService = new server.ProjectService(host, nullLogger); + projectService.openClientFile(commonFile1.path); + checkNumberOfConfiguredProjects(projectService, 1); + checkConfiguredProjectRootFiles(projectService.configuredProjects[0], [commonFile1.path, commonFile2.path]); + }); }); } \ No newline at end of file diff --git a/src/lib/dom.generated.d.ts b/src/lib/dom.generated.d.ts index d2938f6e983..ee657f64a65 100644 --- a/src/lib/dom.generated.d.ts +++ b/src/lib/dom.generated.d.ts @@ -126,6 +126,7 @@ interface KeyAlgorithm { } interface KeyboardEventInit extends EventModifierInit { + code?: string; key?: string; location?: number; repeat?: boolean; @@ -2288,7 +2289,7 @@ declare var DeviceRotationRate: { new(): DeviceRotationRate; } -interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent { +interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode { /** * Sets or gets the URL for the current document. */ @@ -3351,7 +3352,7 @@ declare var Document: { new(): Document; } -interface DocumentFragment extends Node, NodeSelector { +interface DocumentFragment extends Node, NodeSelector, ParentNode { addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -3420,7 +3421,7 @@ declare var EXT_texture_filter_anisotropic: { readonly TEXTURE_MAX_ANISOTROPY_EXT: number; } -interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode { +interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { readonly classList: DOMTokenList; className: string; readonly clientHeight: number; @@ -3675,6 +3676,16 @@ interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelec getElementsByClassName(classNames: string): NodeListOf; matches(selector: string): boolean; closest(selector: string): Element | null; + scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void; + scroll(options?: ScrollToOptions): void; + scroll(x: number, y: number): void; + scrollTo(options?: ScrollToOptions): void; + scrollTo(x: number, y: number): void; + scrollBy(options?: ScrollToOptions): void; + scrollBy(x: number, y: number): void; + insertAdjacentElement(position: string, insertedElement: Element): Element | null; + insertAdjacentHTML(where: string, html: string): void; + insertAdjacentText(where: string, text: string): void; addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -4446,7 +4457,7 @@ interface HTMLCanvasElement extends HTMLElement { * @param type The standard MIME type for the image format to return. If you do not specify this parameter, the default value is a PNG format image. */ toDataURL(type?: string, ...args: any[]): string; - toBlob(callback: (result: Blob | null) => void, ... arguments: any[]): void; + toBlob(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; } declare var HTMLCanvasElement: { @@ -4621,11 +4632,7 @@ interface HTMLElement extends Element { click(): void; dragDrop(): boolean; focus(): void; - insertAdjacentElement(position: string, insertedElement: Element): Element; - insertAdjacentHTML(where: string, html: string): void; - insertAdjacentText(where: string, text: string): void; msGetInputContext(): MSInputMethodContext; - scrollIntoView(top?: boolean): void; setActive(): void; addEventListener(type: "MSContentZoom", listener: (this: this, ev: UIEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -5890,6 +5897,7 @@ interface HTMLLinkElement extends HTMLElement, LinkStyle { */ type: string; import?: Document; + integrity: string; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -6178,7 +6186,7 @@ interface HTMLMediaElement extends HTMLElement { */ canPlayType(type: string): string; /** - * Fires immediately after the client loads the object. + * Resets the audio or video object and loads a new media resource. */ load(): void; /** @@ -6751,6 +6759,7 @@ interface HTMLScriptElement extends HTMLElement { * Sets or retrieves the MIME type for the associated scripting engine. */ type: string; + integrity: string; } declare var HTMLScriptElement: { @@ -7756,6 +7765,7 @@ interface KeyboardEvent extends UIEvent { readonly repeat: boolean; readonly shiftKey: boolean; readonly which: number; + readonly code: string; getModifierState(keyArg: string): boolean; initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; readonly DOM_KEY_LOCATION_JOYSTICK: number; @@ -9128,6 +9138,7 @@ interface PerformanceTiming { readonly responseStart: number; readonly unloadEventEnd: number; readonly unloadEventStart: number; + readonly secureConnectionStart: number; toJSON(): any; } @@ -11405,8 +11416,8 @@ declare var StereoPannerNode: { interface Storage { readonly length: number; clear(): void; - getItem(key: string): string; - key(index: number): string; + getItem(key: string): string | null; + key(index: number): string | null; removeItem(key: string): void; setItem(key: string, data: string): void; [key: string]: any; @@ -12947,7 +12958,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window onunload: (this: this, ev: Event) => any; onvolumechange: (this: this, ev: Event) => any; onwaiting: (this: this, ev: Event) => any; - readonly opener: Window; + opener: any; orientation: string | number; readonly outerHeight: number; readonly outerWidth: number; @@ -13002,6 +13013,9 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + scroll(options?: ScrollToOptions): void; + scrollTo(options?: ScrollToOptions): void; + scrollBy(options?: ScrollToOptions): void; addEventListener(type: "MSGestureChange", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureDoubleTap", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; addEventListener(type: "MSGestureEnd", listener: (this: this, ev: MSGestureEvent) => any, useCapture?: boolean): void; @@ -14029,6 +14043,20 @@ interface ProgressEventInit extends EventInit { total?: number; } +interface ScrollOptions { + behavior?: ScrollBehavior; +} + +interface ScrollToOptions extends ScrollOptions { + left?: number; + top?: number; +} + +interface ScrollIntoViewOptions extends ScrollOptions { + block?: ScrollLogicalPosition; + inline?: ScrollLogicalPosition; +} + interface ClipboardEventInit extends EventInit { data?: string; dataType?: string; @@ -14072,7 +14100,7 @@ interface EcdsaParams extends Algorithm { } interface EcKeyGenParams extends Algorithm { - typedCurve: string; + namedCurve: string; } interface EcKeyAlgorithm extends KeyAlgorithm { @@ -14208,6 +14236,13 @@ interface JsonWebKey { k?: string; } +interface ParentNode { + readonly children: HTMLCollection; + readonly firstElementChild: Element; + readonly lastElementChild: Element; + readonly childElementCount: number; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -14278,7 +14313,7 @@ declare var location: Location; declare var locationbar: BarProp; declare var menubar: BarProp; declare var msCredentials: MSCredentials; -declare var name: string; +declare const name: never; declare var navigator: Navigator; declare var offscreenBuffering: string | boolean; declare var onabort: (this: Window, ev: UIEvent) => any; @@ -14372,7 +14407,7 @@ declare var ontouchstart: (ev: TouchEvent) => any; declare var onunload: (this: Window, ev: Event) => any; declare var onvolumechange: (this: Window, ev: Event) => any; declare var onwaiting: (this: Window, ev: Event) => any; -declare var opener: Window; +declare var opener: any; declare var orientation: string | number; declare var outerHeight: number; declare var outerWidth: number; @@ -14425,6 +14460,9 @@ declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function scroll(options?: ScrollToOptions): void; +declare function scrollTo(options?: ScrollToOptions): void; +declare function scrollBy(options?: ScrollToOptions): void; declare function toString(): string; declare function addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; declare function dispatchEvent(evt: Event): boolean; @@ -14580,6 +14618,8 @@ type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; type RTCIceGatherCandidate = RTCIceCandidate | RTCIceCandidateComplete; type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; type payloadtype = number; +type ScrollBehavior = "auto" | "instant" | "smooth"; +type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; \ No newline at end of file diff --git a/src/lib/es2015.core.d.ts b/src/lib/es2015.core.d.ts index fef0b0ce3ce..15fbb1b77c5 100644 --- a/src/lib/es2015.core.d.ts +++ b/src/lib/es2015.core.d.ts @@ -68,6 +68,10 @@ interface ArrayConstructor { of(...items: T[]): Array; } +interface DateConstructor { + new (value: Date): Date; +} + interface Function { /** * Returns the name of the function. Function names are read-only and can not be changed. @@ -343,6 +347,30 @@ interface ObjectConstructor { defineProperty(o: any, propertyKey: PropertyKey, attributes: PropertyDescriptor): any; } +interface ReadonlyArray { + /** + * Returns the value of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, find + * immediately returns that element value. Otherwise, find returns undefined. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + find(predicate: (value: T, index: number, obj: ReadonlyArray) => boolean, thisArg?: any): T | undefined; + + /** + * Returns the index of the first element in the array where predicate is true, and undefined + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg If provided, it will be used as the this value for each invocation of + * predicate. If it is not provided, undefined is used instead. + */ + findIndex(predicate: (value: T) => boolean, thisArg?: any): number; +} + interface RegExp { /** * Returns a string indicating the flags of the regular expression in question. This field is read-only. diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index e1b9d99762b..de339e2bf2c 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -63,6 +63,26 @@ interface ArrayConstructor { from(iterable: Iterable): Array; } +interface ReadonlyArray { + /** Iterator */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an array of key, value pairs for every entry in the array + */ + entries(): IterableIterator<[number, T]>; + + /** + * Returns an list of keys in the array + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the array + */ + values(): IterableIterator; +} + interface IArguments { /** Iterator */ [Symbol.iterator](): IterableIterator; diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 496df578c19..e4cbe323c68 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1006,7 +1006,12 @@ interface ReadonlyArray { * Combines two or more arrays. * @param items Additional items to add to the end of array1. */ - concat(...items: T[]): T[]; + concat(...items: T[][]): T[]; + /** + * Combines two or more arrays. + * @param items Additional items to add to the end of array1. + */ + concat(...items: (T | T[])[]): T[]; /** * Adds all the elements of an array separated by the specified separator string. * @param separator A string used to separate one element of an array from the next in the resulting String. If omitted, the array elements are separated with a comma. diff --git a/src/lib/webworker.generated.d.ts b/src/lib/webworker.generated.d.ts index c61a1a8b8a6..483348f3f75 100644 --- a/src/lib/webworker.generated.d.ts +++ b/src/lib/webworker.generated.d.ts @@ -1000,7 +1000,7 @@ interface EcdsaParams extends Algorithm { } interface EcKeyGenParams extends Algorithm { - typedCurve: string; + namedCurve: string; } interface EcKeyAlgorithm extends KeyAlgorithm { diff --git a/src/server/client.ts b/src/server/client.ts index f04dbd8dc02..88177e91fad 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -21,7 +21,7 @@ namespace ts.server { export class SessionClient implements LanguageService { private sequence: number = 0; - private lineMaps: ts.Map = {}; + private lineMaps: ts.Map = ts.createMap(); private messages: string[] = []; private lastRenameEntry: RenameEntry; @@ -37,7 +37,7 @@ namespace ts.server { } private getLineMap(fileName: string): number[] { - let lineMap = ts.lookUp(this.lineMaps, fileName); + let lineMap = this.lineMaps[fileName]; if (!lineMap) { const scriptSnapshot = this.host.getScriptSnapshot(fileName); lineMap = this.lineMaps[fileName] = ts.computeLineStarts(scriptSnapshot.getText(0, scriptSnapshot.getLength())); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 6e9adad7f47..255ad8547ea 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -130,15 +130,15 @@ namespace ts.server { const path = toPath(containingFile, this.host.getCurrentDirectory(), this.getCanonicalFileName); const currentResolutionsInFile = cache.get(path); - const newResolutions: Map = {}; + const newResolutions = createMap(); const resolvedModules: R[] = []; const compilerOptions = this.getCompilationSettings(); for (const name of names) { // check if this is a duplicate entry in the list - let resolution = lookUp(newResolutions, name); + let resolution = newResolutions[name]; if (!resolution) { - const existingResolution = currentResolutionsInFile && ts.lookUp(currentResolutionsInFile, name); + const existingResolution = currentResolutionsInFile && currentResolutionsInFile[name]; if (moduleResolutionIsValid(existingResolution)) { // ok, it is safe to use existing name resolution results resolution = existingResolution; @@ -378,7 +378,7 @@ namespace ts.server { export interface ProjectOptions { // these fields can be present in the project file files?: string[]; - wildcardDirectories?: ts.Map; + wildcardDirectories?: ts.MapLike; compilerOptions?: ts.CompilerOptions; } @@ -391,7 +391,7 @@ namespace ts.server { // Used to keep track of what directories are watched for this project directoriesWatchedForTsconfig: string[] = []; program: ts.Program; - filenameToSourceFile: ts.Map = {}; + filenameToSourceFile = ts.createMap(); updateGraphSeq = 0; /** Used for configured projects which may have multiple open roots */ openRefCount = 0; @@ -504,7 +504,7 @@ namespace ts.server { return; } - this.filenameToSourceFile = {}; + this.filenameToSourceFile = createMap(); const sourceFiles = this.program.getSourceFiles(); for (let i = 0, len = sourceFiles.length; i < len; i++) { const normFilename = ts.normalizePath(sourceFiles[i].fileName); @@ -563,7 +563,7 @@ namespace ts.server { } let strBuilder = ""; - ts.forEachValue(this.filenameToSourceFile, + ts.forEachProperty(this.filenameToSourceFile, sourceFile => { strBuilder += sourceFile.fileName + "\n"; }); return strBuilder; } @@ -603,8 +603,11 @@ namespace ts.server { return projects.length > 1 ? deduplicate(result, areEqual) : result; } + export type ProjectServiceEvent = + { eventName: "context", data: { project: Project, fileName: string } } | { eventName: "configFileDiag", data: { triggerFile?: string, configFileName: string, diagnostics: Diagnostic[] } } + export interface ProjectServiceEventHandler { - (eventName: string, project: Project, fileName: string): void; + (event: ProjectServiceEvent): void; } export interface HostConfiguration { @@ -613,7 +616,7 @@ namespace ts.server { } export class ProjectService { - filenameToScriptInfo: ts.Map = {}; + filenameToScriptInfo = ts.createMap(); // open, non-configured root files openFileRoots: ScriptInfo[] = []; // projects built from openFileRoots @@ -625,12 +628,12 @@ namespace ts.server { // open files that are roots of a configured project openFileRootsConfigured: ScriptInfo[] = []; // a path to directory watcher map that detects added tsconfig files - directoryWatchersForTsconfig: ts.Map = {}; + directoryWatchersForTsconfig = ts.createMap(); // count of how many projects are using the directory watcher. If the // number becomes 0 for a watcher, then we should close it. - directoryWatchersRefCount: ts.Map = {}; + directoryWatchersRefCount = ts.createMap(); hostConfiguration: HostConfiguration; - timerForDetectingProjectFileListChanges: Map = {}; + timerForDetectingProjectFileListChanges = createMap(); constructor(public host: ServerHost, public psLogger: Logger, public eventHandler?: ProjectServiceEventHandler) { // ts.disableIncrementalParsing = true; @@ -699,7 +702,8 @@ namespace ts.server { } handleProjectFileListChanges(project: Project) { - const { projectOptions } = this.configFileToProjectOptions(project.projectFilename); + const { projectOptions, errors } = this.configFileToProjectOptions(project.projectFilename); + this.reportConfigFileDiagnostics(project.projectFilename, errors); const newRootFiles = projectOptions.files.map((f => this.getCanonicalFileName(f))); const currentRootFiles = project.getRootFiles().map((f => this.getCanonicalFileName(f))); @@ -717,18 +721,32 @@ namespace ts.server { } } + reportConfigFileDiagnostics(configFileName: string, diagnostics: Diagnostic[], triggerFile?: string) { + if (diagnostics && diagnostics.length > 0) { + this.eventHandler({ + eventName: "configFileDiag", + data: { configFileName, diagnostics, triggerFile } + }); + } + } + /** * This is the callback function when a watched directory has an added tsconfig file. */ directoryWatchedForTsconfigChanged(fileName: string) { - if (ts.getBaseFileName(fileName) != "tsconfig.json") { + if (ts.getBaseFileName(fileName) !== "tsconfig.json") { this.log(fileName + " is not tsconfig.json"); return; } this.log("Detected newly added tsconfig file: " + fileName); - const { projectOptions } = this.configFileToProjectOptions(fileName); + const { projectOptions, errors } = this.configFileToProjectOptions(fileName); + this.reportConfigFileDiagnostics(fileName, errors); + + if (!projectOptions) { + return; + } const rootFilesInTsconfig = projectOptions.files.map(f => this.getCanonicalFileName(f)); const openFileRoots = this.openFileRoots.map(s => this.getCanonicalFileName(s.fileName)); @@ -748,10 +766,13 @@ namespace ts.server { return ts.normalizePath(name); } - watchedProjectConfigFileChanged(project: Project) { + watchedProjectConfigFileChanged(project: Project): void { this.log("Config file changed: " + project.projectFilename); - this.updateConfiguredProject(project); + const configFileErrors = this.updateConfiguredProject(project); this.updateProjectStructure(); + if (configFileErrors && configFileErrors.length > 0) { + this.eventHandler({ eventName: "configFileDiag", data: { triggerFile: project.projectFilename, configFileName: project.projectFilename, diagnostics: configFileErrors } }); + } } log(msg: string, type = "Err") { @@ -828,13 +849,13 @@ namespace ts.server { for (let j = 0, flen = this.openFileRoots.length; j < flen; j++) { const openFile = this.openFileRoots[j]; if (this.eventHandler) { - this.eventHandler("context", openFile.defaultProject, openFile.fileName); + this.eventHandler({ eventName: "context", data: { project: openFile.defaultProject, fileName: openFile.fileName } }); } } for (let j = 0, flen = this.openFilesReferenced.length; j < flen; j++) { const openFile = this.openFilesReferenced[j]; if (this.eventHandler) { - this.eventHandler("context", openFile.defaultProject, openFile.fileName); + this.eventHandler({ eventName: "context", data: { project: openFile.defaultProject, fileName: openFile.fileName } }); } } } @@ -857,7 +878,7 @@ namespace ts.server { if (project.isConfiguredProject()) { project.projectFileWatcher.close(); project.directoryWatcher.close(); - forEachValue(project.directoriesWatchedForWildcards, watcher => { watcher.close(); }); + forEachProperty(project.directoriesWatchedForWildcards, watcher => { watcher.close(); }); delete project.directoriesWatchedForWildcards; this.configuredProjects = copyListRemovingItem(project, this.configuredProjects); } @@ -1124,7 +1145,7 @@ namespace ts.server { getScriptInfo(filename: string) { filename = ts.normalizePath(filename); - return ts.lookUp(this.filenameToScriptInfo, filename); + return this.filenameToScriptInfo[filename]; } /** @@ -1133,7 +1154,7 @@ namespace ts.server { */ openFile(fileName: string, openedByClient: boolean, fileContent?: string, scriptKind?: ScriptKind) { fileName = ts.normalizePath(fileName); - let info = ts.lookUp(this.filenameToScriptInfo, fileName); + let info = this.filenameToScriptInfo[fileName]; if (!info) { let content: string; if (this.host.fileExists(fileName)) { @@ -1218,7 +1239,7 @@ namespace ts.server { const project = this.findConfiguredProjectByConfigFile(configFileName); if (!project) { const configResult = this.openConfigFile(configFileName, fileName); - if (!configResult.success) { + if (!configResult.project) { return { configFileName, configFileErrors: configResult.errors }; } else { @@ -1234,11 +1255,12 @@ namespace ts.server { else { this.updateConfiguredProject(project); } + return { configFileName }; } else { this.log("No config files found."); } - return configFileName ? { configFileName } : {}; + return {}; } /** @@ -1246,7 +1268,7 @@ namespace ts.server { * @param filename is absolute pathname */ closeClientFile(filename: string) { - const info = ts.lookUp(this.filenameToScriptInfo, filename); + const info = this.filenameToScriptInfo[filename]; if (info) { this.closeOpenFile(info); info.isOpen = false; @@ -1255,14 +1277,14 @@ namespace ts.server { } getProjectForFile(filename: string) { - const scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); + const scriptInfo = this.filenameToScriptInfo[filename]; if (scriptInfo) { return scriptInfo.defaultProject; } } printProjectsForFile(filename: string) { - const scriptInfo = ts.lookUp(this.filenameToScriptInfo, filename); + const scriptInfo = this.filenameToScriptInfo[filename]; if (scriptInfo) { this.psLogger.startGroup(); this.psLogger.info("Projects for " + filename); @@ -1328,34 +1350,31 @@ namespace ts.server { return undefined; } - configFileToProjectOptions(configFilename: string): { succeeded: boolean, projectOptions?: ProjectOptions, errors?: Diagnostic[] } { + configFileToProjectOptions(configFilename: string): { projectOptions?: ProjectOptions, errors: Diagnostic[] } { configFilename = ts.normalizePath(configFilename); + let errors: Diagnostic[] = []; // file references will be relative to dirPath (or absolute) const dirPath = ts.getDirectoryPath(configFilename); const contents = this.host.readFile(configFilename); - const rawConfig: { config?: ProjectOptions; error?: Diagnostic; } = ts.parseConfigFileTextToJson(configFilename, contents); - if (rawConfig.error) { - return { succeeded: false, errors: [rawConfig.error] }; + const { configJsonObject, diagnostics } = ts.parseAndReEmitConfigJSONFile(contents); + errors = concatenate(errors, diagnostics); + const parsedCommandLine = ts.parseJsonConfigFileContent(configJsonObject, this.host, dirPath, /*existingOptions*/ {}, configFilename); + errors = concatenate(errors, parsedCommandLine.errors); + Debug.assert(!!parsedCommandLine.fileNames); + + if (parsedCommandLine.fileNames.length === 0) { + errors.push(createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename)); + return { errors }; } else { - const parsedCommandLine = ts.parseJsonConfigFileContent(rawConfig.config, this.host, dirPath, /*existingOptions*/ {}, configFilename); - Debug.assert(!!parsedCommandLine.fileNames); - - if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { - return { succeeded: false, errors: parsedCommandLine.errors }; - } - else if (parsedCommandLine.fileNames.length === 0) { - const error = createCompilerDiagnostic(Diagnostics.The_config_file_0_found_doesn_t_contain_any_source_files, configFilename); - return { succeeded: false, errors: [error] }; - } - else { - const projectOptions: ProjectOptions = { - files: parsedCommandLine.fileNames, - wildcardDirectories: parsedCommandLine.wildcardDirectories, - compilerOptions: parsedCommandLine.options, - }; - return { succeeded: true, projectOptions }; - } + // if the project has some files, we can continue with the parsed options and tolerate + // errors in the parsedCommandLine + const projectOptions: ProjectOptions = { + files: parsedCommandLine.fileNames, + wildcardDirectories: parsedCommandLine.wildcardDirectories, + compilerOptions: parsedCommandLine.options, + }; + return { projectOptions, errors }; } } @@ -1377,64 +1396,63 @@ namespace ts.server { return false; } - openConfigFile(configFilename: string, clientFileName?: string): { success: boolean, project?: Project, errors?: Diagnostic[] } { - const { succeeded, projectOptions, errors } = this.configFileToProjectOptions(configFilename); - if (!succeeded) { - return { success: false, errors }; + openConfigFile(configFilename: string, clientFileName?: string): { project?: Project, errors: Diagnostic[] } { + const parseConfigFileResult = this.configFileToProjectOptions(configFilename); + let errors = parseConfigFileResult.errors; + if (!parseConfigFileResult.projectOptions) { + return { errors }; } - else { - if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) { - if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { - const project = this.createProject(configFilename, projectOptions, /*languageServiceDisabled*/ true); + const projectOptions = parseConfigFileResult.projectOptions; + if (!projectOptions.compilerOptions.disableSizeLimit && projectOptions.compilerOptions.allowJs) { + if (this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { + const project = this.createProject(configFilename, projectOptions, /*languageServiceDisabled*/ true); - // for configured projects with languageService disabled, we only watch its config file, - // do not care about the directory changes in the folder. - project.projectFileWatcher = this.host.watchFile( - toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), - _ => this.watchedProjectConfigFileChanged(project)); - return { success: true, project }; - } + // for configured projects with languageService disabled, we only watch its config file, + // do not care about the directory changes in the folder. + project.projectFileWatcher = this.host.watchFile( + toPath(configFilename, configFilename, createGetCanonicalFileName(sys.useCaseSensitiveFileNames)), + _ => this.watchedProjectConfigFileChanged(project)); + return { project, errors }; + } + } + + const project = this.createProject(configFilename, projectOptions); + for (const rootFilename of projectOptions.files) { + if (this.host.fileExists(rootFilename)) { + const info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename); + project.addRoot(info); + } + else { + (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.File_0_not_found, rootFilename)); + } + } + project.finishGraph(); + project.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(project)); + + const configDirectoryPath = ts.getDirectoryPath(configFilename); + + this.log("Add recursive watcher for: " + configDirectoryPath); + project.directoryWatcher = this.host.watchDirectory( + configDirectoryPath, + path => this.directoryWatchedForSourceFilesChanged(project, path), + /*recursive*/ true + ); + + project.directoriesWatchedForWildcards = reduceProperties(createMap(projectOptions.wildcardDirectories), (watchers, flag, directory) => { + if (comparePaths(configDirectoryPath, directory, ".", !this.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { + const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; + this.log(`Add ${ recursive ? "recursive " : ""}watcher for: ${directory}`); + watchers[directory] = this.host.watchDirectory( + directory, + path => this.directoryWatchedForSourceFilesChanged(project, path), + recursive + ); } - const project = this.createProject(configFilename, projectOptions); - let errors: Diagnostic[]; - for (const rootFilename of projectOptions.files) { - if (this.host.fileExists(rootFilename)) { - const info = this.openFile(rootFilename, /*openedByClient*/ clientFileName == rootFilename); - project.addRoot(info); - } - else { - (errors || (errors = [])).push(createCompilerDiagnostic(Diagnostics.File_0_not_found, rootFilename)); - } - } - project.finishGraph(); - project.projectFileWatcher = this.host.watchFile(configFilename, _ => this.watchedProjectConfigFileChanged(project)); + return watchers; + }, >{}); - const configDirectoryPath = ts.getDirectoryPath(configFilename); - - this.log("Add recursive watcher for: " + configDirectoryPath); - project.directoryWatcher = this.host.watchDirectory( - configDirectoryPath, - path => this.directoryWatchedForSourceFilesChanged(project, path), - /*recursive*/ true - ); - - project.directoriesWatchedForWildcards = reduceProperties(projectOptions.wildcardDirectories, (watchers, flag, directory) => { - if (comparePaths(configDirectoryPath, directory, ".", !this.host.useCaseSensitiveFileNames) !== Comparison.EqualTo) { - const recursive = (flag & WatchDirectoryFlags.Recursive) !== 0; - this.log(`Add ${ recursive ? "recursive " : ""}watcher for: ${directory}`); - watchers[directory] = this.host.watchDirectory( - directory, - path => this.directoryWatchedForSourceFilesChanged(project, path), - recursive - ); - } - - return watchers; - }, >{}); - - return { success: true, project: project, errors }; - } + return { project: project, errors }; } updateConfiguredProject(project: Project): Diagnostic[] { @@ -1443,15 +1461,15 @@ namespace ts.server { this.removeProject(project); } else { - const { succeeded, projectOptions, errors } = this.configFileToProjectOptions(project.projectFilename); - if (!succeeded) { + const { projectOptions, errors } = this.configFileToProjectOptions(project.projectFilename); + if (!projectOptions) { return errors; } else { if (projectOptions.compilerOptions && !projectOptions.compilerOptions.disableSizeLimit && this.exceedTotalNonTsFileSizeLimit(projectOptions.files)) { project.setProjectOptions(projectOptions); if (project.languageServiceDiabled) { - return; + return errors; } project.disableLanguageService(); @@ -1459,7 +1477,7 @@ namespace ts.server { project.directoryWatcher.close(); project.directoryWatcher = undefined; } - return; + return errors; } if (project.languageServiceDiabled) { @@ -1478,7 +1496,7 @@ namespace ts.server { } } project.finishGraph(); - return; + return errors; } // if the project is too large, the root files might not have been all loaded if the total @@ -1524,6 +1542,7 @@ namespace ts.server { project.setProjectOptions(projectOptions); project.finishGraph(); } + return errors; } } diff --git a/src/server/session.ts b/src/server/session.ts index 7e1ca81e2af..00468330ffb 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -153,16 +153,22 @@ namespace ts.server { private logger: Logger ) { this.projectService = - new ProjectService(host, logger, (eventName, project, fileName) => { - this.handleEvent(eventName, project, fileName); + new ProjectService(host, logger, event => { + this.handleEvent(event); }); } - private handleEvent(eventName: string, project: Project, fileName: string) { - if (eventName == "context") { - this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); - this.updateErrorCheck([{ fileName, project }], this.changeSeq, - (n) => n === this.changeSeq, 100); + private handleEvent(event: ProjectServiceEvent) { + switch (event.eventName) { + case "context": + const { project, fileName } = event.data; + this.projectService.log("got context event, updating diagnostics for" + fileName, "Info"); + this.updateErrorCheck([{ fileName, project }], this.changeSeq, + (n) => n === this.changeSeq, 100); + break; + case "configFileDiag": + const { triggerFile, configFileName, diagnostics } = event.data; + this.configFileDiagnosticEvent(triggerFile, configFileName, diagnostics); } } @@ -1061,7 +1067,7 @@ namespace ts.server { return { response, responseRequired: true }; } - private handlers: Map<(request: protocol.Request) => { response?: any, responseRequired?: boolean }> = { + private handlers = createMap<(request: protocol.Request) => { response?: any, responseRequired?: boolean }>({ [CommandNames.Exit]: () => { this.exit(); return { responseRequired: false }; @@ -1198,9 +1204,10 @@ namespace ts.server { this.reloadProjects(); return { responseRequired: false }; } - }; + }); + public addProtocolHandler(command: string, handler: (request: protocol.Request) => { response?: any, responseRequired: boolean }) { - if (this.handlers[command]) { + if (command in this.handlers) { throw new Error(`Protocol handler already exists for command "${command}"`); } this.handlers[command] = handler; diff --git a/src/server/tsconfig.library.json b/src/server/tsconfig.library.json index 746283720bf..af04a74d557 100644 --- a/src/server/tsconfig.library.json +++ b/src/server/tsconfig.library.json @@ -10,6 +10,8 @@ "types": [] }, "files": [ + "../services/shims.ts", + "../services/utilities.ts", "editorServices.ts", "protocol.d.ts", "session.ts" diff --git a/src/services/jsTyping.ts b/src/services/jsTyping.ts index 3b013a4a924..4f0e06244d2 100644 --- a/src/services/jsTyping.ts +++ b/src/services/jsTyping.ts @@ -47,7 +47,7 @@ namespace ts.JsTyping { { cachedTypingPaths: string[], newTypingNames: string[], filesToWatch: string[] } { // A typing name to typing file path mapping - const inferredTypings: Map = {}; + const inferredTypings = createMap(); if (!typingOptions || !typingOptions.enableAutoDiscovery) { return { cachedTypingPaths: [], newTypingNames: [], filesToWatch: [] }; @@ -58,12 +58,7 @@ namespace ts.JsTyping { if (!safeList) { const result = readConfigFile(safeListPath, (path: string) => host.readFile(path)); - if (result.config) { - safeList = result.config; - } - else { - safeList = {}; - }; + safeList = createMap(result.config); } const filesToWatch: string[] = []; @@ -93,7 +88,7 @@ namespace ts.JsTyping { // Add the cached typing locations for inferred typings that are already installed for (const name in packageNameToTypingLocation) { - if (hasProperty(inferredTypings, name) && !inferredTypings[name]) { + if (name in inferredTypings && !inferredTypings[name]) { inferredTypings[name] = packageNameToTypingLocation[name]; } } @@ -124,7 +119,7 @@ namespace ts.JsTyping { } for (const typing of typingNames) { - if (!hasProperty(inferredTypings, typing)) { + if (!(typing in inferredTypings)) { inferredTypings[typing] = undefined; } } @@ -139,16 +134,16 @@ namespace ts.JsTyping { const jsonConfig: PackageJson = result.config; filesToWatch.push(jsonPath); if (jsonConfig.dependencies) { - mergeTypings(getKeys(jsonConfig.dependencies)); + mergeTypings(getOwnKeys(jsonConfig.dependencies)); } if (jsonConfig.devDependencies) { - mergeTypings(getKeys(jsonConfig.devDependencies)); + mergeTypings(getOwnKeys(jsonConfig.devDependencies)); } if (jsonConfig.optionalDependencies) { - mergeTypings(getKeys(jsonConfig.optionalDependencies)); + mergeTypings(getOwnKeys(jsonConfig.optionalDependencies)); } if (jsonConfig.peerDependencies) { - mergeTypings(getKeys(jsonConfig.peerDependencies)); + mergeTypings(getOwnKeys(jsonConfig.peerDependencies)); } } } @@ -167,7 +162,7 @@ namespace ts.JsTyping { mergeTypings(cleanedTypingNames); } else { - mergeTypings(filter(cleanedTypingNames, f => hasProperty(safeList, f))); + mergeTypings(filter(cleanedTypingNames, f => f in safeList)); } const hasJsxFile = forEach(fileNames, f => scriptKindIs(f, /*LanguageServiceHost*/ undefined, ScriptKind.JSX)); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index e9afb6925b5..ccded188e61 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -15,7 +15,7 @@ namespace ts.NavigateTo { const nameToDeclarations = sourceFile.getNamedDeclarations(); for (const name in nameToDeclarations) { - const declarations = getProperty(nameToDeclarations, name); + const declarations = nameToDeclarations[name]; if (declarations) { // First do a quick check to see if the name of the declaration matches the // last portion of the (possibly) dotted name they're searching for. diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 32d4244eaad..aa4f129c286 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -234,7 +234,7 @@ namespace ts.NavigationBar { /** Merge declarations of the same kind. */ function mergeChildren(children: NavigationBarNode[]): void { - const nameToItems: Map = {}; + const nameToItems = createMap(); filterMutate(children, child => { const decl = child.node; const name = decl.name && nodeText(decl.name); @@ -243,7 +243,7 @@ namespace ts.NavigationBar { return true; } - const itemsWithSameName = getProperty(nameToItems, name); + const itemsWithSameName = nameToItems[name]; if (!itemsWithSameName) { nameToItems[name] = child; return true; diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index 3d20337eca7..b4f67ca056d 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -113,7 +113,7 @@ namespace ts { // we see the name of a module that is used everywhere, or the name of an overload). As // such, we cache the information we compute about the candidate for the life of this // pattern matcher so we don't have to compute it multiple times. - const stringToWordSpans: Map = {}; + const stringToWordSpans = createMap(); pattern = pattern.trim(); @@ -188,7 +188,7 @@ namespace ts { } function getWordSpans(word: string): TextSpan[] { - if (!hasProperty(stringToWordSpans, word)) { + if (!(word in stringToWordSpans)) { stringToWordSpans[word] = breakIntoWordSpans(word); } diff --git a/src/services/services.ts b/src/services/services.ts index 86661bd5503..171532354b5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -304,6 +304,10 @@ namespace ts { processNode(jsDocComment); } } + // For syntactic classifications, all trivia are classcified together, including jsdoc comments. + // For that to work, the jsdoc comments should still be the leading trivia of the first child. + // Restoring the scanner position ensures that. + pos = this.pos; forEachChild(this, processNode, processNodes); if (pos < this.end) { this.addSyntheticNodes(children, pos, this.end); @@ -980,7 +984,7 @@ namespace ts { } private computeNamedDeclarations(): Map { - const result: Map = {}; + const result = createMap(); forEachChild(this, visit); @@ -995,7 +999,7 @@ namespace ts { } function getDeclarations(name: string) { - return getProperty(result, name) || (result[name] = []); + return result[name] || (result[name] = []); } function getDeclarationName(declaration: Declaration) { @@ -2030,7 +2034,7 @@ namespace ts { fileName?: string; reportDiagnostics?: boolean; moduleName?: string; - renamedDependencies?: Map; + renamedDependencies?: MapLike; } export interface TranspileOutput { @@ -2047,7 +2051,7 @@ namespace ts { function fixupCompilerOptions(options: CompilerOptions, diagnostics: Diagnostic[]): CompilerOptions { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || filter(optionDeclarations, o => - typeof o.type === "object" && !forEachValue(>o.type, v => typeof v !== "number")); + typeof o.type === "object" && !forEachProperty(o.type, v => typeof v !== "number")); options = clone(options); @@ -2063,7 +2067,7 @@ namespace ts { options[opt.name] = parseCustomTypeOption(opt, value, diagnostics); } else { - if (!forEachValue(opt.type, v => v === value)) { + if (!forEachProperty(opt.type, v => v === value)) { // Supplied value isn't a valid enum value. diagnostics.push(createCompilerDiagnosticForInvalidCustomType(opt)); } @@ -2122,7 +2126,9 @@ namespace ts { sourceFile.moduleName = transpileOptions.moduleName; } - sourceFile.renamedDependencies = transpileOptions.renamedDependencies; + if (transpileOptions.renamedDependencies) { + sourceFile.renamedDependencies = createMap(transpileOptions.renamedDependencies); + } const newLine = getNewLineCharacter(options); @@ -2248,7 +2254,7 @@ namespace ts { export function createDocumentRegistry(useCaseSensitiveFileNames?: boolean, currentDirectory = ""): DocumentRegistry { // Maps from compiler setting target (ES3, ES5, etc.) to all the cached documents we have // for those settings. - const buckets: Map> = {}; + const buckets = createMap>(); const getCanonicalFileName = createGetCanonicalFileName(!!useCaseSensitiveFileNames); function getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey { @@ -2256,7 +2262,7 @@ namespace ts { } function getBucketForCompilationSettings(key: DocumentRegistryBucketKey, createIfMissing: boolean): FileMap { - let bucket = lookUp(buckets, key); + let bucket = buckets[key]; if (!bucket && createIfMissing) { buckets[key] = bucket = createFileMap(); } @@ -2265,7 +2271,7 @@ namespace ts { function reportStats() { const bucketInfoArray = Object.keys(buckets).filter(name => name && name.charAt(0) === "_").map(name => { - const entries = lookUp(buckets, name); + const entries = buckets[name]; const sourceFiles: { name: string; refCount: number; references: string[]; }[] = []; entries.forEachValue((key, entry) => { sourceFiles.push({ @@ -3104,7 +3110,7 @@ namespace ts { oldSettings.allowJs !== newSettings.allowJs || oldSettings.disableSizeLimit !== oldSettings.disableSizeLimit || oldSettings.baseUrl !== newSettings.baseUrl || - !mapIsEqualTo(oldSettings.paths, newSettings.paths)); + !equalOwnProperties(oldSettings.paths, newSettings.paths)); // Now create a new compiler const compilerHost: CompilerHost = { @@ -3119,7 +3125,6 @@ namespace ts { getCurrentDirectory: () => currentDirectory, fileExists: (fileName): boolean => { // stub missing host functionality - Debug.assert(!host.resolveModuleNames || !host.resolveTypeReferenceDirectives); return hostCache.getOrCreateEntry(fileName) !== undefined; }, readFile: (fileName): string => { @@ -3793,7 +3798,11 @@ namespace ts { // other than those within the declared type. isNewIdentifierLocation = true; + // If the object literal is being assigned to something of type 'null | { hello: string }', + // it clearly isn't trying to satisfy the 'null' type. So we grab the non-nullable type if possible. typeForObject = typeChecker.getContextualType(objectLikeContainer); + typeForObject = typeForObject && typeForObject.getNonNullableType(); + existingMembers = (objectLikeContainer).properties; } else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) { @@ -3805,7 +3814,7 @@ namespace ts { // We don't want to complete using the type acquired by the shape // of the binding pattern; we are only interested in types acquired // through type declaration or inference. - // Also proceed if rootDeclaration is parameter and if its containing function expression\arrow function is contextually typed - + // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function let canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); if (!canGetType && rootDeclaration.kind === SyntaxKind.Parameter) { @@ -4107,7 +4116,7 @@ namespace ts { * do not occur at the current position and have not otherwise been typed. */ function filterNamedImportOrExportCompletionItems(exportsOfModule: Symbol[], namedImportsOrExports: ImportOrExportSpecifier[]): Symbol[] { - const existingImportsOrExports: Map = {}; + const existingImportsOrExports = createMap(); for (const element of namedImportsOrExports) { // If this is the current item we are editing right now, do not filter it out @@ -4119,11 +4128,11 @@ namespace ts { existingImportsOrExports[name.text] = true; } - if (isEmpty(existingImportsOrExports)) { + if (!someProperties(existingImportsOrExports)) { return filter(exportsOfModule, e => e.name !== "default"); } - return filter(exportsOfModule, e => e.name !== "default" && !lookUp(existingImportsOrExports, e.name)); + return filter(exportsOfModule, e => e.name !== "default" && !existingImportsOrExports[e.name]); } /** @@ -4137,7 +4146,7 @@ namespace ts { return contextualMemberSymbols; } - const existingMemberNames: Map = {}; + const existingMemberNames = createMap(); for (const m of existingMembers) { // Ignore omitted expressions for missing members if (m.kind !== SyntaxKind.PropertyAssignment && @@ -4170,7 +4179,7 @@ namespace ts { existingMemberNames[existingName] = true; } - return filter(contextualMemberSymbols, m => !lookUp(existingMemberNames, m.name)); + return filter(contextualMemberSymbols, m => !existingMemberNames[m.name]); } /** @@ -4180,7 +4189,7 @@ namespace ts { * do not occur at the current position and have not otherwise been typed. */ function filterJsxAttributes(symbols: Symbol[], attributes: NodeArray): Symbol[] { - const seenNames: Map = {}; + const seenNames = createMap(); for (const attr of attributes) { // If this is the current item we are editing right now, do not filter it out if (attr.getStart() <= position && position <= attr.getEnd()) { @@ -4192,7 +4201,7 @@ namespace ts { } } - return filter(symbols, a => !lookUp(seenNames, a.name)); + return filter(symbols, a => !seenNames[a.name]); } } @@ -4252,7 +4261,7 @@ namespace ts { addRange(entries, keywordCompletions); } - return { isMemberCompletion, isNewIdentifierLocation, entries }; + return { isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation || isSourceFileJavaScript(sourceFile), entries }; function getJavaScriptCompletionEntries(sourceFile: SourceFile, position: number, uniqueNames: Map): CompletionEntry[] { const entries: CompletionEntry[] = []; @@ -4322,13 +4331,13 @@ namespace ts { function getCompletionEntriesFromSymbols(symbols: Symbol[], entries: CompletionEntry[], location: Node, performCharacterChecks: boolean): Map { const start = timestamp(); - const uniqueNames: Map = {}; + const uniqueNames = createMap(); if (symbols) { for (const symbol of symbols) { const entry = createCompletionEntry(symbol, location, performCharacterChecks); if (entry) { const id = escapeIdentifier(entry.name); - if (!lookUp(uniqueNames, id)) { + if (!uniqueNames[id]) { entries.push(entry); uniqueNames[id] = id; } @@ -4917,6 +4926,28 @@ namespace ts { if (!documentation) { documentation = symbol.getDocumentationComment(); + if (documentation.length === 0 && symbol.flags & SymbolFlags.Property) { + // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` + // there documentation comments might be attached to the right hand side symbol of their declarations. + // The pattern of such special property access is that the parent symbol is the symbol of the file. + if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) { + for (const declaration of symbol.declarations) { + if (!declaration.parent || declaration.parent.kind !== SyntaxKind.BinaryExpression) { + continue; + } + + const rhsSymbol = program.getTypeChecker().getSymbolAtLocation((declaration.parent).right); + if (!rhsSymbol) { + continue; + } + + documentation = rhsSymbol.getDocumentationComment(); + if (documentation.length > 0) { + break; + } + } + } + } } return { displayParts, documentation, symbolKind }; @@ -5156,7 +5187,7 @@ namespace ts { // Type reference directives const typeReferenceDirective = findReferenceInPosition(sourceFile.typeReferenceDirectives, position); if (typeReferenceDirective) { - const referenceFile = lookUp(program.getResolvedTypeReferenceDirectives(), typeReferenceDirective.fileName); + const referenceFile = program.getResolvedTypeReferenceDirectives()[typeReferenceDirective.fileName]; if (referenceFile && referenceFile.resolvedFileName) { return [getDefinitionInfoForFileReference(typeReferenceDirective.fileName, referenceFile.resolvedFileName)]; } @@ -5323,12 +5354,12 @@ namespace ts { return undefined; } - const fileNameToDocumentHighlights: Map = {}; + const fileNameToDocumentHighlights = createMap(); const result: DocumentHighlights[] = []; for (const referencedSymbol of referencedSymbols) { for (const referenceEntry of referencedSymbol.references) { const fileName = referenceEntry.fileName; - let documentHighlights = getProperty(fileNameToDocumentHighlights, fileName); + let documentHighlights = fileNameToDocumentHighlights[fileName]; if (!documentHighlights) { documentHighlights = { fileName, highlightSpans: [] }; @@ -6073,7 +6104,7 @@ namespace ts { const nameTable = getNameTable(sourceFile); - if (lookUp(nameTable, internedName) !== undefined) { + if (nameTable[internedName] !== undefined) { result = result || []; getReferencesInNode(sourceFile, symbol, declaredName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex); } @@ -6718,7 +6749,7 @@ namespace ts { // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {}); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); } }); @@ -6750,7 +6781,7 @@ namespace ts { // the function will add any found symbol of the property-name, then its sub-routine will call // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (hasProperty(previousIterationSymbolsCache, symbol.name)) { + if (symbol.name in previousIterationSymbolsCache) { return; } @@ -6839,7 +6870,7 @@ namespace ts { // see if any is in the list if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { const result: Symbol[] = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ {}); + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); } @@ -7574,6 +7605,10 @@ namespace ts { * False will mean that node is not classified and traverse routine should recurse into node contents. */ function tryClassifyNode(node: Node): boolean { + if (isJSDocTag(node)) { + return true; + } + if (nodeIsMissing(node)) { return true; } @@ -8323,7 +8358,7 @@ namespace ts { } function initializeNameTable(sourceFile: SourceFile): void { - const nameTable: Map = {}; + const nameTable = createMap(); walk(sourceFile); sourceFile.nameTable = nameTable; diff --git a/src/services/shims.ts b/src/services/shims.ts index 45c4b284ae7..9a581ed6be1 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -311,9 +311,9 @@ namespace ts { // 'in' does not have this effect. if ("getModuleResolutionsForFile" in this.shimHost) { this.resolveModuleNames = (moduleNames: string[], containingFile: string) => { - const resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); + const resolutionsInFile = >JSON.parse(this.shimHost.getModuleResolutionsForFile(containingFile)); return map(moduleNames, name => { - const result = lookUp(resolutionsInFile, name); + const result = getProperty(resolutionsInFile, name); return result ? { resolvedFileName: result } : undefined; }); }; @@ -323,8 +323,8 @@ namespace ts { } if ("getTypeReferenceDirectiveResolutionsForFile" in this.shimHost) { this.resolveTypeReferenceDirectives = (typeDirectiveNames: string[], containingFile: string) => { - const typeDirectivesForFile = >JSON.parse(this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); - return map(typeDirectiveNames, name => lookUp(typeDirectivesForFile, name)); + const typeDirectivesForFile = >JSON.parse(this.shimHost.getTypeReferenceDirectiveResolutionsForFile(containingFile)); + return map(typeDirectiveNames, name => getProperty(typeDirectivesForFile, name)); }; } } @@ -1203,6 +1203,6 @@ namespace TypeScript.Services { // TODO: it should be moved into a namespace though. /* @internal */ -const toolsVersion = "1.9"; +const toolsVersion = "2.1"; /* tslint:enable:no-unused-variable */ diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 50378aa64b1..211e55b23ba 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -237,7 +237,7 @@ namespace ts.SignatureHelp { const typeChecker = program.getTypeChecker(); for (const sourceFile of program.getSourceFiles()) { const nameToDeclarations = sourceFile.getNamedDeclarations(); - const declarations = getProperty(nameToDeclarations, name.text); + const declarations = nameToDeclarations[name.text]; if (declarations) { for (const declaration of declarations) { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 215fbefc011..740201b8cfb 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -925,4 +925,24 @@ namespace ts { } return ensureScriptKind(fileName, scriptKind); } + + export function parseAndReEmitConfigJSONFile(content: string) { + const options: TranspileOptions = { + fileName: "config.js", + compilerOptions: { + target: ScriptTarget.ES6 + }, + reportDiagnostics: true + }; + const { outputText, diagnostics } = ts.transpileModule("(" + content + ")", options); + // Becasue the content was wrapped in "()", the start position of diagnostics needs to be subtract by 1 + // also, the emitted result will have "(" in the beginning and ");" in the end. We need to strip these + // as well + const trimmedOutput = outputText.trim(); + const configJsonObject = JSON.parse(trimmedOutput.substring(1, trimmedOutput.length - 2)); + for (const diagnostic of diagnostics) { + diagnostic.start = diagnostic.start - 1; + } + return { configJsonObject, diagnostics }; + } } \ No newline at end of file diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index 7573f2ba99e..cb7fc3a4c5c 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -20,7 +20,7 @@ declare var path: any; import * as ts from "typescript"; function watch(rootFileNames: string[], options: ts.CompilerOptions) { - const files: ts.Map<{ version: number }> = {}; + const files: ts.MapLike<{ version: number }> = {}; // initialize the list of files rootFileNames.forEach(fileName => { diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.keyword2.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.keyword2.json index 91972325847..4148937b278 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.keyword2.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.keyword2.json @@ -1,12 +1,5 @@ { - "kind": "JSDocTypeReference", + "kind": "NullKeyword", "pos": 1, - "end": 5, - "name": { - "kind": "Identifier", - "pos": 1, - "end": 5, - "originalKeywordKind": "NullKeyword", - "text": "null" - } + "end": 5 } \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.keyword3.json b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.keyword3.json index 408fb1c6f46..c61912f9eb8 100644 --- a/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.keyword3.json +++ b/tests/baselines/reference/JSDocParsing/TypeExpressions.parsesCorrectly.keyword3.json @@ -1,12 +1,5 @@ { - "kind": "JSDocTypeReference", + "kind": "UndefinedKeyword", "pos": 1, - "end": 10, - "name": { - "kind": "Identifier", - "pos": 1, - "end": 10, - "originalKeywordKind": "UndefinedKeyword", - "text": "undefined" - } + "end": 10 } \ No newline at end of file diff --git a/tests/baselines/reference/ambientShorthand_isImplicitAny.errors.txt b/tests/baselines/reference/ambientShorthand_isImplicitAny.errors.txt deleted file mode 100644 index 875a656202d..00000000000 --- a/tests/baselines/reference/ambientShorthand_isImplicitAny.errors.txt +++ /dev/null @@ -1,8 +0,0 @@ -tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts(1,16): error TS7005: Variable '"jquery"' implicitly has an 'any' type. - - -==== tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts (1 errors) ==== - declare module "jquery"; - ~~~~~~~~ -!!! error TS7005: Variable '"jquery"' implicitly has an 'any' type. - \ No newline at end of file diff --git a/tests/baselines/reference/ambientShorthand_isImplicitAny.js b/tests/baselines/reference/ambientShorthand_isImplicitAny.js deleted file mode 100644 index ab05d2a9979..00000000000 --- a/tests/baselines/reference/ambientShorthand_isImplicitAny.js +++ /dev/null @@ -1,5 +0,0 @@ -//// [ambientShorthand_isImplicitAny.ts] -declare module "jquery"; - - -//// [ambientShorthand_isImplicitAny.js] diff --git a/tests/baselines/reference/apparentTypeSubtyping.errors.txt b/tests/baselines/reference/apparentTypeSubtyping.errors.txt index e1a53ef6a73..01fffeb3824 100644 --- a/tests/baselines/reference/apparentTypeSubtyping.errors.txt +++ b/tests/baselines/reference/apparentTypeSubtyping.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts(9,7): error TS2415: Class 'Derived' incorrectly extends base class 'Base'. Types of property 'x' are incompatible. Type 'String' is not assignable to type 'string'. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtyping.ts (1 errors) ==== @@ -17,6 +18,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSubtypi !!! error TS2415: Class 'Derived' incorrectly extends base class 'Base'. !!! error TS2415: Types of property 'x' are incompatible. !!! error TS2415: Type 'String' is not assignable to type 'string'. +!!! error TS2415: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. x: String; } diff --git a/tests/baselines/reference/apparentTypeSupertype.errors.txt b/tests/baselines/reference/apparentTypeSupertype.errors.txt index 5fe5c92a5b3..c7610a80f2f 100644 --- a/tests/baselines/reference/apparentTypeSupertype.errors.txt +++ b/tests/baselines/reference/apparentTypeSupertype.errors.txt @@ -2,6 +2,7 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty Types of property 'x' are incompatible. Type 'U' is not assignable to type 'string'. Type 'String' is not assignable to type 'string'. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSupertype.ts (1 errors) ==== @@ -19,5 +20,6 @@ tests/cases/conformance/types/typeRelationships/apparentType/apparentTypeSuperty !!! error TS2415: Types of property 'x' are incompatible. !!! error TS2415: Type 'U' is not assignable to type 'string'. !!! error TS2415: Type 'String' is not assignable to type 'string'. +!!! error TS2415: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. x: U; } \ No newline at end of file diff --git a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt index d60f0b7d03c..a6a685069d6 100644 --- a/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt +++ b/tests/baselines/reference/arityAndOrderCompatibility01.errors.txt @@ -39,8 +39,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(26,5): error tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(27,5): error TS2322: Type '{ 0: string; 1: number; }' is not assignable to type '[string]'. Property 'length' is missing in type '{ 0: string; 1: number; }'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(28,5): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(29,5): error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. Types of property '0' are incompatible. Type 'string' is not assignable to type 'number'. @@ -136,8 +135,7 @@ tests/cases/conformance/types/tuple/arityAndOrderCompatibility01.ts(30,5): error var n1: [number, string] = x; ~~ !!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. var n2: [number, string] = y; ~~ !!! error TS2322: Type 'StrNum' is not assignable to type '[number, string]'. diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index 8e6c7eccf81..1f0dd30c09c 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -1,8 +1,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(10,5): error TS2322: Type 'undefined[]' is not assignable to type '[any, any, any]'. Property '0' is missing in type 'undefined[]'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'boolean'. + Type 'string' is not assignable to type 'boolean'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'. Types of property 'pop' are incompatible. Type '() => string | number | boolean' is not assignable to type '() => number'. @@ -18,6 +17,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error Types of parameters 'items' and 'items' are incompatible. Type 'Number' is not assignable to type 'string | number'. Type 'Number' is not assignable to type 'number'. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. ==== tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts (6 errors) ==== @@ -37,8 +37,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error var a1: [boolean, string, number] = ["string", 1, true]; // Error ~~ !!! error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type 'string' is not assignable to type 'boolean'. // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), @@ -81,4 +80,5 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error !!! error TS2322: Types of parameters 'items' and 'items' are incompatible. !!! error TS2322: Type 'Number' is not assignable to type 'string | number'. !!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt new file mode 100644 index 00000000000..6f4a0ef9d6d --- /dev/null +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -0,0 +1,46 @@ +tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray'. + Types of property 'concat' are incompatible. + Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. + Type 'A[]' is not assignable to type 'B[]'. + Type 'A' is not assignable to type 'B'. + Property 'b' is missing in type 'A'. +tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error TS2322: Type 'C' is not assignable to type 'ReadonlyArray'. + Types of property 'concat' are incompatible. + Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. + Type 'A[]' is not assignable to type 'B[]'. + Type 'A' is not assignable to type 'B'. + + +==== tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts (2 errors) ==== + class A { a } + class B extends A { b } + class C extends Array { c } + declare var ara: A[]; + declare var arb: B[]; + declare var cra: C; + declare var crb: C; + declare var rra: ReadonlyArray; + declare var rrb: ReadonlyArray; + rra = ara; + rrb = arb; // OK, Array is assignable to ReadonlyArray + rra = arb; + rrb = ara; // error: 'A' is not assignable to 'B' + ~~~ +!!! error TS2322: Type 'A[]' is not assignable to type 'ReadonlyArray'. +!!! error TS2322: Types of property 'concat' are incompatible. +!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. +!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. +!!! error TS2322: Property 'b' is missing in type 'A'. + + rra = cra; + rra = crb; // OK, C is assignable to ReadonlyArray + rrb = crb; + rrb = cra; // error: 'A' is not assignable to 'B' + ~~~ +!!! error TS2322: Type 'C' is not assignable to type 'ReadonlyArray'. +!!! error TS2322: Types of property 'concat' are incompatible. +!!! error TS2322: Type '{ (...items: A[][]): A[]; (...items: (A | A[])[]): A[]; }' is not assignable to type '{ >(...items: U[]): B[]; (...items: B[][]): B[]; (...items: (B | B[])[]): B[]; }'. +!!! error TS2322: Type 'A[]' is not assignable to type 'B[]'. +!!! error TS2322: Type 'A' is not assignable to type 'B'. + \ No newline at end of file diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js new file mode 100644 index 00000000000..255b52e16c9 --- /dev/null +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.js @@ -0,0 +1,54 @@ +//// [arrayOfSubtypeIsAssignableToReadonlyArray.ts] +class A { a } +class B extends A { b } +class C extends Array { c } +declare var ara: A[]; +declare var arb: B[]; +declare var cra: C; +declare var crb: C; +declare var rra: ReadonlyArray; +declare var rrb: ReadonlyArray; +rra = ara; +rrb = arb; // OK, Array is assignable to ReadonlyArray +rra = arb; +rrb = ara; // error: 'A' is not assignable to 'B' + +rra = cra; +rra = crb; // OK, C is assignable to ReadonlyArray +rrb = crb; +rrb = cra; // error: 'A' is not assignable to 'B' + + +//// [arrayOfSubtypeIsAssignableToReadonlyArray.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var A = (function () { + function A() { + } + return A; +}()); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +}(A)); +var C = (function (_super) { + __extends(C, _super); + function C() { + _super.apply(this, arguments); + } + return C; +}(Array)); +rra = ara; +rrb = arb; // OK, Array is assignable to ReadonlyArray +rra = arb; +rrb = ara; // error: 'A' is not assignable to 'B' +rra = cra; +rra = crb; // OK, C is assignable to ReadonlyArray +rrb = crb; +rrb = cra; // error: 'A' is not assignable to 'B' diff --git a/tests/baselines/reference/assignFromBooleanInterface.errors.txt b/tests/baselines/reference/assignFromBooleanInterface.errors.txt index 4b06603a9bf..555b645cd7d 100644 --- a/tests/baselines/reference/assignFromBooleanInterface.errors.txt +++ b/tests/baselines/reference/assignFromBooleanInterface.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts(3,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. + 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. ==== tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts (1 errors) ==== @@ -7,4 +8,5 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface.ts(3 x = a; ~ !!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. +!!! error TS2322: 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromBooleanInterface2.errors.txt b/tests/baselines/reference/assignFromBooleanInterface2.errors.txt index c03eab60c74..6c7ebbe5ee8 100644 --- a/tests/baselines/reference/assignFromBooleanInterface2.errors.txt +++ b/tests/baselines/reference/assignFromBooleanInterface2.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts( Type '() => Object' is not assignable to type '() => boolean'. Type 'Object' is not assignable to type 'boolean'. tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(19,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. + 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts(20,1): error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'. @@ -33,6 +34,7 @@ tests/cases/conformance/types/primitives/boolean/assignFromBooleanInterface2.ts( x = a; // expected error ~ !!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. +!!! error TS2322: 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotBoolean' is not assignable to type 'boolean'. diff --git a/tests/baselines/reference/assignFromNumberInterface.errors.txt b/tests/baselines/reference/assignFromNumberInterface.errors.txt index 0c8c4a5f5ac..1a70ef342d2 100644 --- a/tests/baselines/reference/assignFromNumberInterface.errors.txt +++ b/tests/baselines/reference/assignFromNumberInterface.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts(3,1): error TS2322: Type 'Number' is not assignable to type 'number'. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. ==== tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts (1 errors) ==== @@ -7,4 +8,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface.ts(3,1 x = a; ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromNumberInterface2.errors.txt b/tests/baselines/reference/assignFromNumberInterface2.errors.txt index 85639cdeeaf..3297501d612 100644 --- a/tests/baselines/reference/assignFromNumberInterface2.errors.txt +++ b/tests/baselines/reference/assignFromNumberInterface2.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(24,1): error TS2322: Type 'Number' is not assignable to type 'number'. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(25,1): error TS2322: Type 'NotNumber' is not assignable to type 'number'. @@ -29,6 +30,7 @@ tests/cases/conformance/types/primitives/number/assignFromNumberInterface2.ts(25 x = a; // expected error ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotNumber' is not assignable to type 'number'. diff --git a/tests/baselines/reference/assignFromStringInterface.errors.txt b/tests/baselines/reference/assignFromStringInterface.errors.txt index 6ec8afad120..7e7af4d1b9d 100644 --- a/tests/baselines/reference/assignFromStringInterface.errors.txt +++ b/tests/baselines/reference/assignFromStringInterface.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts(3,1): error TS2322: Type 'String' is not assignable to type 'string'. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. ==== tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts (1 errors) ==== @@ -7,4 +8,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface.ts(3,1 x = a; ~ !!! error TS2322: Type 'String' is not assignable to type 'string'. +!!! error TS2322: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. a = x; \ No newline at end of file diff --git a/tests/baselines/reference/assignFromStringInterface2.errors.txt b/tests/baselines/reference/assignFromStringInterface2.errors.txt index 4e09eb6eacb..0fc3284bf00 100644 --- a/tests/baselines/reference/assignFromStringInterface2.errors.txt +++ b/tests/baselines/reference/assignFromStringInterface2.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(47,1): error TS2322: Type 'String' is not assignable to type 'string'. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(48,1): error TS2322: Type 'NotString' is not assignable to type 'string'. @@ -52,6 +53,7 @@ tests/cases/conformance/types/primitives/string/assignFromStringInterface2.ts(48 x = a; // expected error ~ !!! error TS2322: Type 'String' is not assignable to type 'string'. +!!! error TS2322: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. x = b; // expected error ~ !!! error TS2322: Type 'NotString' is not assignable to type 'string'. diff --git a/tests/baselines/reference/await_unaryExpression_es6.js b/tests/baselines/reference/await_unaryExpression_es6.js new file mode 100644 index 00000000000..46065bdada9 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6.js @@ -0,0 +1,47 @@ +//// [await_unaryExpression_es6.ts] + +async function bar() { + !await 42; // OK +} + +async function bar1() { + +await 42; // OK +} + +async function bar3() { + -await 42; // OK +} + +async function bar4() { + ~await 42; // OK +} + +//// [await_unaryExpression_es6.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function bar() { + return __awaiter(this, void 0, void 0, function* () { + !(yield 42); // OK + }); +} +function bar1() { + return __awaiter(this, void 0, void 0, function* () { + +(yield 42); // OK + }); +} +function bar3() { + return __awaiter(this, void 0, void 0, function* () { + -(yield 42); // OK + }); +} +function bar4() { + return __awaiter(this, void 0, void 0, function* () { + ~(yield 42); // OK + }); +} diff --git a/tests/baselines/reference/await_unaryExpression_es6.symbols b/tests/baselines/reference/await_unaryExpression_es6.symbols new file mode 100644 index 00000000000..81edd4b981b --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6.symbols @@ -0,0 +1,25 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6.ts === + +async function bar() { +>bar : Symbol(bar, Decl(await_unaryExpression_es6.ts, 0, 0)) + + !await 42; // OK +} + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es6.ts, 3, 1)) + + +await 42; // OK +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6.ts, 7, 1)) + + -await 42; // OK +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es6.ts, 11, 1)) + + ~await 42; // OK +} diff --git a/tests/baselines/reference/await_unaryExpression_es6.types b/tests/baselines/reference/await_unaryExpression_es6.types new file mode 100644 index 00000000000..2a4b7354d3e --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6.types @@ -0,0 +1,37 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6.ts === + +async function bar() { +>bar : () => Promise + + !await 42; // OK +>!await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar1() { +>bar1 : () => Promise + + +await 42; // OK +>+await 42 : number +>await 42 : number +>42 : number +} + +async function bar3() { +>bar3 : () => Promise + + -await 42; // OK +>-await 42 : number +>await 42 : number +>42 : number +} + +async function bar4() { +>bar4 : () => Promise + + ~await 42; // OK +>~await 42 : number +>await 42 : number +>42 : number +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.js b/tests/baselines/reference/await_unaryExpression_es6_1.js new file mode 100644 index 00000000000..c6f5f1142c0 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_1.js @@ -0,0 +1,56 @@ +//// [await_unaryExpression_es6_1.ts] + +async function bar() { + !await 42; // OK +} + +async function bar1() { + delete await 42; // OK +} + +async function bar2() { + delete await 42; // OK +} + +async function bar3() { + void await 42; +} + +async function bar4() { + +await 42; +} + +//// [await_unaryExpression_es6_1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function bar() { + return __awaiter(this, void 0, void 0, function* () { + !(yield 42); // OK + }); +} +function bar1() { + return __awaiter(this, void 0, void 0, function* () { + delete (yield 42); // OK + }); +} +function bar2() { + return __awaiter(this, void 0, void 0, function* () { + delete (yield 42); // OK + }); +} +function bar3() { + return __awaiter(this, void 0, void 0, function* () { + void (yield 42); + }); +} +function bar4() { + return __awaiter(this, void 0, void 0, function* () { + +(yield 42); + }); +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.symbols b/tests/baselines/reference/await_unaryExpression_es6_1.symbols new file mode 100644 index 00000000000..ed7d7e4ed02 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_1.symbols @@ -0,0 +1,31 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts === + +async function bar() { +>bar : Symbol(bar, Decl(await_unaryExpression_es6_1.ts, 0, 0)) + + !await 42; // OK +} + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es6_1.ts, 3, 1)) + + delete await 42; // OK +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_1.ts, 7, 1)) + + delete await 42; // OK +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_1.ts, 11, 1)) + + void await 42; +} + +async function bar4() { +>bar4 : Symbol(bar4, Decl(await_unaryExpression_es6_1.ts, 15, 1)) + + +await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.types b/tests/baselines/reference/await_unaryExpression_es6_1.types new file mode 100644 index 00000000000..a5c3740b677 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_1.types @@ -0,0 +1,46 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts === + +async function bar() { +>bar : () => Promise + + !await 42; // OK +>!await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar1() { +>bar1 : () => Promise + + delete await 42; // OK +>delete await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar2() { +>bar2 : () => Promise + + delete await 42; // OK +>delete await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar3() { +>bar3 : () => Promise + + void await 42; +>void await 42 : undefined +>await 42 : number +>42 : number +} + +async function bar4() { +>bar4 : () => Promise + + +await 42; +>+await 42 : number +>await 42 : number +>42 : number +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.js b/tests/baselines/reference/await_unaryExpression_es6_2.js new file mode 100644 index 00000000000..3c341018ed1 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_2.js @@ -0,0 +1,38 @@ +//// [await_unaryExpression_es6_2.ts] + +async function bar1() { + delete await 42; +} + +async function bar2() { + delete await 42; +} + +async function bar3() { + void await 42; +} + +//// [await_unaryExpression_es6_2.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function bar1() { + return __awaiter(this, void 0, void 0, function* () { + delete (yield 42); + }); +} +function bar2() { + return __awaiter(this, void 0, void 0, function* () { + delete (yield 42); + }); +} +function bar3() { + return __awaiter(this, void 0, void 0, function* () { + void (yield 42); + }); +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.symbols b/tests/baselines/reference/await_unaryExpression_es6_2.symbols new file mode 100644 index 00000000000..574ea4d433a --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_2.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts === + +async function bar1() { +>bar1 : Symbol(bar1, Decl(await_unaryExpression_es6_2.ts, 0, 0)) + + delete await 42; +} + +async function bar2() { +>bar2 : Symbol(bar2, Decl(await_unaryExpression_es6_2.ts, 3, 1)) + + delete await 42; +} + +async function bar3() { +>bar3 : Symbol(bar3, Decl(await_unaryExpression_es6_2.ts, 7, 1)) + + void await 42; +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.types b/tests/baselines/reference/await_unaryExpression_es6_2.types new file mode 100644 index 00000000000..b438f063add --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_2.types @@ -0,0 +1,28 @@ +=== tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts === + +async function bar1() { +>bar1 : () => Promise + + delete await 42; +>delete await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar2() { +>bar2 : () => Promise + + delete await 42; +>delete await 42 : boolean +>await 42 : number +>42 : number +} + +async function bar3() { +>bar3 : () => Promise + + void await 42; +>void await 42 : undefined +>await 42 : number +>42 : number +} diff --git a/tests/baselines/reference/await_unaryExpression_es6_3.errors.txt b/tests/baselines/reference/await_unaryExpression_es6_3.errors.txt new file mode 100644 index 00000000000..5518f84983f --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_3.errors.txt @@ -0,0 +1,27 @@ +tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts(3,7): error TS1109: Expression expected. +tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts(7,7): error TS1109: Expression expected. + + +==== tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts (2 errors) ==== + + async function bar1() { + ++await 42; // Error + ~~~~~ +!!! error TS1109: Expression expected. + } + + async function bar2() { + --await 42; // Error + ~~~~~ +!!! error TS1109: Expression expected. + } + + async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis + } + + async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis + } \ No newline at end of file diff --git a/tests/baselines/reference/await_unaryExpression_es6_3.js b/tests/baselines/reference/await_unaryExpression_es6_3.js new file mode 100644 index 00000000000..077e264c450 --- /dev/null +++ b/tests/baselines/reference/await_unaryExpression_es6_3.js @@ -0,0 +1,53 @@ +//// [await_unaryExpression_es6_3.ts] + +async function bar1() { + ++await 42; // Error +} + +async function bar2() { + --await 42; // Error +} + +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} + +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} + +//// [await_unaryExpression_es6_3.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function bar1() { + return __awaiter(this, void 0, void 0, function* () { + ++; + yield 42; // Error + }); +} +function bar2() { + return __awaiter(this, void 0, void 0, function* () { + --; + yield 42; // Error + }); +} +function bar3() { + return __awaiter(this, void 0, void 0, function* () { + var x = 42; + yield x++; // OK but shouldn't need parenthesis + }); +} +function bar4() { + return __awaiter(this, void 0, void 0, function* () { + var x = 42; + yield x--; // OK but shouldn't need parenthesis + }); +} diff --git a/tests/baselines/reference/castOfAwait.js b/tests/baselines/reference/castOfAwait.js new file mode 100644 index 00000000000..26e9812bf43 --- /dev/null +++ b/tests/baselines/reference/castOfAwait.js @@ -0,0 +1,28 @@ +//// [castOfAwait.ts] +async function f() { + await 0; + typeof await 0; + void await 0; + await void typeof void await 0; + await await 0; +} + + +//// [castOfAwait.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments)).next()); + }); +}; +function f() { + return __awaiter(this, void 0, void 0, function* () { + yield 0; + typeof (yield 0); + void (yield 0); + yield void typeof void (yield 0); + yield yield 0; + }); +} diff --git a/tests/baselines/reference/castOfAwait.symbols b/tests/baselines/reference/castOfAwait.symbols new file mode 100644 index 00000000000..574ee21f773 --- /dev/null +++ b/tests/baselines/reference/castOfAwait.symbols @@ -0,0 +1,11 @@ +=== tests/cases/compiler/castOfAwait.ts === +async function f() { +>f : Symbol(f, Decl(castOfAwait.ts, 0, 0)) + + await 0; + typeof await 0; + void await 0; + await void typeof void await 0; + await await 0; +} + diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types new file mode 100644 index 00000000000..ad3597f6c01 --- /dev/null +++ b/tests/baselines/reference/castOfAwait.types @@ -0,0 +1,35 @@ +=== tests/cases/compiler/castOfAwait.ts === +async function f() { +>f : () => Promise + + await 0; +> await 0 : number +>await 0 : number +>0 : number + + typeof await 0; +>typeof await 0 : string +>await 0 : number +>0 : number + + void await 0; +>void await 0 : undefined +>await 0 : number +>0 : number + + await void typeof void await 0; +>await void typeof void await 0 : any +>void typeof void await 0 : undefined +> typeof void await 0 : string +>typeof void await 0 : string +> void await 0 : number +>void await 0 : undefined +>await 0 : number +>0 : number + + await await 0; +>await await 0 : number +>await 0 : number +>0 : number +} + diff --git a/tests/baselines/reference/castOfYield.errors.txt b/tests/baselines/reference/castOfYield.errors.txt new file mode 100644 index 00000000000..abafe678784 --- /dev/null +++ b/tests/baselines/reference/castOfYield.errors.txt @@ -0,0 +1,12 @@ +tests/cases/compiler/castOfYield.ts(4,14): error TS1109: Expression expected. + + +==== tests/cases/compiler/castOfYield.ts (1 errors) ==== + function* f() { + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + yield 0; + ~~~~~ +!!! error TS1109: Expression expected. + } + \ No newline at end of file diff --git a/tests/baselines/reference/castOfYield.js b/tests/baselines/reference/castOfYield.js new file mode 100644 index 00000000000..633f780a6a1 --- /dev/null +++ b/tests/baselines/reference/castOfYield.js @@ -0,0 +1,15 @@ +//// [castOfYield.ts] +function* f() { + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + yield 0; +} + + +//// [castOfYield.js] +function* f() { + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + ; + yield 0; +} diff --git a/tests/baselines/reference/castingTuple.errors.txt b/tests/baselines/reference/castingTuple.errors.txt index 6d5549c6bf2..2f9eeedf9ef 100644 --- a/tests/baselines/reference/castingTuple.errors.txt +++ b/tests/baselines/reference/castingTuple.errors.txt @@ -1,10 +1,8 @@ tests/cases/conformance/types/tuple/castingTuple.ts(28,10): error TS2352: Type '[number, string]' cannot be converted to type '[number, number]'. - Types of property '1' are incompatible. - Type 'string' is not comparable to type 'number'. + Type 'string' is not comparable to type 'number'. tests/cases/conformance/types/tuple/castingTuple.ts(29,10): error TS2352: Type '[C, D]' cannot be converted to type '[A, I]'. - Types of property '0' are incompatible. - Type 'C' is not comparable to type 'A'. - Property 'a' is missing in type 'C'. + Type 'C' is not comparable to type 'A'. + Property 'a' is missing in type 'C'. tests/cases/conformance/types/tuple/castingTuple.ts(30,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'. tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot find name 't4'. @@ -40,14 +38,12 @@ tests/cases/conformance/types/tuple/castingTuple.ts(31,1): error TS2304: Cannot var t3 = <[number, number]>numStrTuple; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2352: Type '[number, string]' cannot be converted to type '[number, number]'. -!!! error TS2352: Types of property '1' are incompatible. -!!! error TS2352: Type 'string' is not comparable to type 'number'. +!!! error TS2352: Type 'string' is not comparable to type 'number'. var t9 = <[A, I]>classCDTuple; ~~~~~~~~~~~~~~~~~~~~ !!! error TS2352: Type '[C, D]' cannot be converted to type '[A, I]'. -!!! error TS2352: Types of property '0' are incompatible. -!!! error TS2352: Type 'C' is not comparable to type 'A'. -!!! error TS2352: Property 'a' is missing in type 'C'. +!!! error TS2352: Type 'C' is not comparable to type 'A'. +!!! error TS2352: Property 'a' is missing in type 'C'. var array1 = numStrTuple; ~~~~~~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'array1' must be of type '{}[]', but here has type 'number[]'. diff --git a/tests/baselines/reference/contextualTypeWithTuple.errors.txt b/tests/baselines/reference/contextualTypeWithTuple.errors.txt index e0580ca2379..a488d8c7648 100644 --- a/tests/baselines/reference/contextualTypeWithTuple.errors.txt +++ b/tests/baselines/reference/contextualTypeWithTuple.errors.txt @@ -5,9 +5,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(3,5): error TS232 Type 'true' is not assignable to type 'string | number'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(15,1): error TS2322: Type '[number, string, boolean]' is not assignable to type '[number, string]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(18,1): error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'. - Types of property '0' are incompatible. - Type '{}' is not assignable to type '{ a: string; }'. - Property 'a' is missing in type '{}'. + Type '{}' is not assignable to type '{ a: string; }'. + Property 'a' is missing in type '{}'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(19,1): error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'. Property '2' is missing in type '[number, string]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(20,5): error TS2322: Type '[string, string, number]' is not assignable to type '[string, string]'. @@ -18,9 +17,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(20,5): error TS23 tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(24,1): error TS2322: Type '[C, string | number]' is not assignable to type '[C, string | number, D]'. Property '2' is missing in type '[C, string | number]'. tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS2322: Type '[number, string | number]' is not assignable to type '[number, string]'. - Types of property '1' are incompatible. - Type 'string | number' is not assignable to type 'string'. - Type 'number' is not assignable to type 'string'. + Type 'string | number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts (7 errors) ==== @@ -52,9 +50,8 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23 objNumTuple = [ {}, 5]; ~~~~~~~~~~~ !!! error TS2322: Type '[{}, number]' is not assignable to type '[{ a: string; }, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type '{ a: string; }'. -!!! error TS2322: Property 'a' is missing in type '{}'. +!!! error TS2322: Type '{}' is not assignable to type '{ a: string; }'. +!!! error TS2322: Property 'a' is missing in type '{}'. numStrBoolTuple = numStrTuple; ~~~~~~~~~~~~~~~ !!! error TS2322: Type '[number, string]' is not assignable to type '[number, string, boolean]'. @@ -76,6 +73,5 @@ tests/cases/conformance/types/tuple/contextualTypeWithTuple.ts(25,1): error TS23 numStrTuple = unionTuple3; ~~~~~~~~~~~ !!! error TS2322: Type '[number, string | number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type 'string | number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt index 42d617887e0..447ccec5ddf 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt @@ -11,8 +11,7 @@ tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTyp tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(16,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(21,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. - Types of property '0' are incompatible. - Type 'number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(26,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. @@ -57,8 +56,7 @@ tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTyp function g({ prop = [101, 1234] }: Tuples) {} ~~~~ !!! error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. interface StringUnion { prop: "foo" | "bar"; diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.symbols b/tests/baselines/reference/controlFlowBinaryOrExpression.symbols index e76cfbf4cab..217e11dc95d 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.symbols +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.symbols @@ -64,9 +64,9 @@ if (isNodeList(sourceObj)) { >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) sourceObj.length; ->sourceObj.length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>sourceObj.length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27)) >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) ->length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>length : Symbol(NodeList.length, Decl(controlFlowBinaryOrExpression.ts, 10, 27)) } if (isHTMLCollection(sourceObj)) { @@ -74,9 +74,9 @@ if (isHTMLCollection(sourceObj)) { >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) sourceObj.length; ->sourceObj.length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>sourceObj.length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33)) >sourceObj : Symbol(sourceObj, Decl(controlFlowBinaryOrExpression.ts, 23, 3)) ->length : Symbol(length, Decl(controlFlowBinaryOrExpression.ts, 10, 27), Decl(controlFlowBinaryOrExpression.ts, 14, 33)) +>length : Symbol(HTMLCollection.length, Decl(controlFlowBinaryOrExpression.ts, 14, 33)) } if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.types b/tests/baselines/reference/controlFlowBinaryOrExpression.types index 0bf5ab524b9..7e92fcdbbd1 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.types +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.types @@ -80,7 +80,7 @@ if (isNodeList(sourceObj)) { sourceObj.length; >sourceObj.length : number ->sourceObj : NodeList | HTMLCollection +>sourceObj : NodeList >length : number } @@ -91,7 +91,7 @@ if (isHTMLCollection(sourceObj)) { sourceObj.length; >sourceObj.length : number ->sourceObj : NodeList | HTMLCollection +>sourceObj : HTMLCollection >length : number } @@ -102,11 +102,11 @@ if (isNodeList(sourceObj) || isHTMLCollection(sourceObj)) { >sourceObj : EventTargetLike >isHTMLCollection(sourceObj) : boolean >isHTMLCollection : (sourceObj: any) => sourceObj is HTMLCollection ->sourceObj : { a: string; } +>sourceObj : HTMLCollection | { a: string; } sourceObj.length; >sourceObj.length : number ->sourceObj : NodeList | HTMLCollection | ({ a: string; } & HTMLCollection) +>sourceObj : NodeList | HTMLCollection >length : number } diff --git a/tests/baselines/reference/controlFlowIfStatement.js b/tests/baselines/reference/controlFlowIfStatement.js index a70c07d38dc..e40b831552f 100644 --- a/tests/baselines/reference/controlFlowIfStatement.js +++ b/tests/baselines/reference/controlFlowIfStatement.js @@ -35,6 +35,22 @@ function b() { } x; // string } +function c(data: string | T): T { + if (typeof data === 'string') { + return JSON.parse(data); + } + else { + return data; + } +} +function d(data: string | T): never { + if (typeof data === 'string') { + throw new Error('will always happen'); + } + else { + return data; + } +} //// [controlFlowIfStatement.js] @@ -72,3 +88,19 @@ function b() { } x; // string } +function c(data) { + if (typeof data === 'string') { + return JSON.parse(data); + } + else { + return data; + } +} +function d(data) { + if (typeof data === 'string') { + throw new Error('will always happen'); + } + else { + return data; + } +} diff --git a/tests/baselines/reference/controlFlowIfStatement.symbols b/tests/baselines/reference/controlFlowIfStatement.symbols index 1d85b31c998..e4d2bb9f184 100644 --- a/tests/baselines/reference/controlFlowIfStatement.symbols +++ b/tests/baselines/reference/controlFlowIfStatement.symbols @@ -71,4 +71,42 @@ function b() { x; // string >x : Symbol(x, Decl(controlFlowIfStatement.ts, 26, 7)) } +function c(data: string | T): T { +>c : Symbol(c, Decl(controlFlowIfStatement.ts, 35, 1)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 36, 11)) +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 36, 14)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 36, 11)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 36, 11)) + + if (typeof data === 'string') { +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 36, 14)) + + return JSON.parse(data); +>JSON.parse : Symbol(JSON.parse, Decl(lib.d.ts, --, --)) +>JSON : Symbol(JSON, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>parse : Symbol(JSON.parse, Decl(lib.d.ts, --, --)) +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 36, 14)) + } + else { + return data; +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 36, 14)) + } +} +function d(data: string | T): never { +>d : Symbol(d, Decl(controlFlowIfStatement.ts, 43, 1)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 44, 11)) +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 44, 29)) +>T : Symbol(T, Decl(controlFlowIfStatement.ts, 44, 11)) + + if (typeof data === 'string') { +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 44, 29)) + + throw new Error('will always happen'); +>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + } + else { + return data; +>data : Symbol(data, Decl(controlFlowIfStatement.ts, 44, 29)) + } +} diff --git a/tests/baselines/reference/controlFlowIfStatement.types b/tests/baselines/reference/controlFlowIfStatement.types index 716491ea58b..79985378bf5 100644 --- a/tests/baselines/reference/controlFlowIfStatement.types +++ b/tests/baselines/reference/controlFlowIfStatement.types @@ -90,4 +90,51 @@ function b() { x; // string >x : string } +function c(data: string | T): T { +>c : (data: string | T) => T +>T : T +>data : string | T +>T : T +>T : T + + if (typeof data === 'string') { +>typeof data === 'string' : boolean +>typeof data : string +>data : string | T +>'string' : "string" + + return JSON.parse(data); +>JSON.parse(data) : any +>JSON.parse : (text: string, reviver?: (key: any, value: any) => any) => any +>JSON : JSON +>parse : (text: string, reviver?: (key: any, value: any) => any) => any +>data : string + } + else { + return data; +>data : T + } +} +function d(data: string | T): never { +>d : (data: string | T) => never +>T : T +>data : string | T +>T : T + + if (typeof data === 'string') { +>typeof data === 'string' : boolean +>typeof data : string +>data : string | T +>'string' : "string" + + throw new Error('will always happen'); +>new Error('will always happen') : Error +>Error : ErrorConstructor +>'will always happen' : string + } + else { + return data; +>data : never + } +} diff --git a/tests/baselines/reference/controlFlowInstanceof.js b/tests/baselines/reference/controlFlowInstanceof.js new file mode 100644 index 00000000000..3f2287b4628 --- /dev/null +++ b/tests/baselines/reference/controlFlowInstanceof.js @@ -0,0 +1,184 @@ +//// [controlFlowInstanceof.ts] + +// Repros from #10167 + +function f1(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + s; // Set + s.add(42); +} + +function f2(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Promise) { + s; // Set & Promise + } + s; // Set + s.add(42); +} + +function f3(s: Set | Set) { + s; // Set | Set + if (s instanceof Set) { + s; // Set | Set + } + else { + s; // never + } +} + +function f4(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + else { + s; // never + } +} + +// More tests + +class A { a: string } +class B extends A { b: string } +class C extends A { c: string } + +function foo(x: A | undefined) { + x; // A | undefined + if (x instanceof B || x instanceof C) { + x; // B | C + } + x; // A | undefined + if (x instanceof B && x instanceof C) { + x; // B & C + } + x; // A | undefined + if (!x) { + return; + } + x; // A + if (x instanceof B) { + x; // B + if (x instanceof C) { + x; // B & C + } + else { + x; // B + } + x; // B + } + else { + x; // A + } + x; // A +} + +// X is neither assignable to Y nor a subtype of Y +// Y is assignable to X, but not a subtype of X + +interface X { + x?: string; +} + +class Y { + y: string; +} + +function goo(x: X) { + x; + if (x instanceof Y) { + x.y; + } + x; +} + +//// [controlFlowInstanceof.js] +// Repros from #10167 +function f1(s) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + s; // Set + s.add(42); +} +function f2(s) { + s = new Set(); + s; // Set + if (s instanceof Promise) { + s; // Set & Promise + } + s; // Set + s.add(42); +} +function f3(s) { + s; // Set | Set + if (s instanceof Set) { + s; // Set | Set + } + else { + s; // never + } +} +function f4(s) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + else { + s; // never + } +} +// More tests +class A { +} +class B extends A { +} +class C extends A { +} +function foo(x) { + x; // A | undefined + if (x instanceof B || x instanceof C) { + x; // B | C + } + x; // A | undefined + if (x instanceof B && x instanceof C) { + x; // B & C + } + x; // A | undefined + if (!x) { + return; + } + x; // A + if (x instanceof B) { + x; // B + if (x instanceof C) { + x; // B & C + } + else { + x; // B + } + x; // B + } + else { + x; // A + } + x; // A +} +class Y { +} +function goo(x) { + x; + if (x instanceof Y) { + x.y; + } + x; +} diff --git a/tests/baselines/reference/controlFlowInstanceof.symbols b/tests/baselines/reference/controlFlowInstanceof.symbols new file mode 100644 index 00000000000..31894827990 --- /dev/null +++ b/tests/baselines/reference/controlFlowInstanceof.symbols @@ -0,0 +1,232 @@ +=== tests/cases/compiler/controlFlowInstanceof.ts === + +// Repros from #10167 + +function f1(s: Set | Set) { +>f1 : Symbol(f1, Decl(controlFlowInstanceof.ts, 0, 0)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s = new Set(); +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) + + if (s instanceof Set) { +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) + } + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) + + s.add(42); +>s.add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 3, 12)) +>add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) +} + +function f2(s: Set | Set) { +>f2 : Symbol(f2, Decl(controlFlowInstanceof.ts, 11, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s = new Set(); +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) + + if (s instanceof Promise) { +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) +>Promise : Symbol(Promise, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --)) + + s; // Set & Promise +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) + } + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) + + s.add(42); +>s.add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 13, 12)) +>add : Symbol(Set.add, Decl(lib.es2015.collection.d.ts, --, --)) +} + +function f3(s: Set | Set) { +>f3 : Symbol(f3, Decl(controlFlowInstanceof.ts, 21, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set | Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) + + if (s instanceof Set) { +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set | Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) + } + else { + s; // never +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 23, 12)) + } +} + +function f4(s: Set | Set) { +>f4 : Symbol(f4, Decl(controlFlowInstanceof.ts, 31, 1)) +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s = new Set(); +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) + + if (s instanceof Set) { +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) +>Set : Symbol(Set, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --)) + + s; // Set +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) + } + else { + s; // never +>s : Symbol(s, Decl(controlFlowInstanceof.ts, 33, 12)) + } +} + +// More tests + +class A { a: string } +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 42, 1)) +>a : Symbol(A.a, Decl(controlFlowInstanceof.ts, 46, 9)) + +class B extends A { b: string } +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 46, 21)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 42, 1)) +>b : Symbol(B.b, Decl(controlFlowInstanceof.ts, 47, 19)) + +class C extends A { c: string } +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 47, 31)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 42, 1)) +>c : Symbol(C.c, Decl(controlFlowInstanceof.ts, 48, 19)) + +function foo(x: A | undefined) { +>foo : Symbol(foo, Decl(controlFlowInstanceof.ts, 48, 31)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>A : Symbol(A, Decl(controlFlowInstanceof.ts, 42, 1)) + + x; // A | undefined +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (x instanceof B || x instanceof C) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 46, 21)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 47, 31)) + + x; // B | C +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + x; // A | undefined +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (x instanceof B && x instanceof C) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 46, 21)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 47, 31)) + + x; // B & C +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + x; // A | undefined +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (!x) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + return; + } + x; // A +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (x instanceof B) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>B : Symbol(B, Decl(controlFlowInstanceof.ts, 46, 21)) + + x; // B +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + + if (x instanceof C) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +>C : Symbol(C, Decl(controlFlowInstanceof.ts, 47, 31)) + + x; // B & C +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + else { + x; // B +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + x; // B +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + else { + x; // A +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) + } + x; // A +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 50, 13)) +} + +// X is neither assignable to Y nor a subtype of Y +// Y is assignable to X, but not a subtype of X + +interface X { +>X : Symbol(X, Decl(controlFlowInstanceof.ts, 78, 1)) + + x?: string; +>x : Symbol(X.x, Decl(controlFlowInstanceof.ts, 83, 13)) +} + +class Y { +>Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 85, 1)) + + y: string; +>y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 87, 9)) +} + +function goo(x: X) { +>goo : Symbol(goo, Decl(controlFlowInstanceof.ts, 89, 1)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) +>X : Symbol(X, Decl(controlFlowInstanceof.ts, 78, 1)) + + x; +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) + + if (x instanceof Y) { +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) +>Y : Symbol(Y, Decl(controlFlowInstanceof.ts, 85, 1)) + + x.y; +>x.y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 87, 9)) +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) +>y : Symbol(Y.y, Decl(controlFlowInstanceof.ts, 87, 9)) + } + x; +>x : Symbol(x, Decl(controlFlowInstanceof.ts, 91, 13)) +} diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types new file mode 100644 index 00000000000..e52d1a25b1d --- /dev/null +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -0,0 +1,256 @@ +=== tests/cases/compiler/controlFlowInstanceof.ts === + +// Repros from #10167 + +function f1(s: Set | Set) { +>f1 : (s: Set | Set) => void +>s : Set | Set +>Set : Set +>Set : Set + + s = new Set(); +>s = new Set() : Set +>s : Set | Set +>new Set() : Set +>Set : SetConstructor + + s; // Set +>s : Set + + if (s instanceof Set) { +>s instanceof Set : boolean +>s : Set +>Set : SetConstructor + + s; // Set +>s : Set + } + s; // Set +>s : Set + + s.add(42); +>s.add(42) : Set +>s.add : (value: number) => Set +>s : Set +>add : (value: number) => Set +>42 : number +} + +function f2(s: Set | Set) { +>f2 : (s: Set | Set) => void +>s : Set | Set +>Set : Set +>Set : Set + + s = new Set(); +>s = new Set() : Set +>s : Set | Set +>new Set() : Set +>Set : SetConstructor + + s; // Set +>s : Set + + if (s instanceof Promise) { +>s instanceof Promise : boolean +>s : Set +>Promise : PromiseConstructor + + s; // Set & Promise +>s : Set & Promise + } + s; // Set +>s : Set + + s.add(42); +>s.add(42) : Set +>s.add : (value: number) => Set +>s : Set +>add : (value: number) => Set +>42 : number +} + +function f3(s: Set | Set) { +>f3 : (s: Set | Set) => void +>s : Set | Set +>Set : Set +>Set : Set + + s; // Set | Set +>s : Set | Set + + if (s instanceof Set) { +>s instanceof Set : boolean +>s : Set | Set +>Set : SetConstructor + + s; // Set | Set +>s : Set | Set + } + else { + s; // never +>s : never + } +} + +function f4(s: Set | Set) { +>f4 : (s: Set | Set) => void +>s : Set | Set +>Set : Set +>Set : Set + + s = new Set(); +>s = new Set() : Set +>s : Set | Set +>new Set() : Set +>Set : SetConstructor + + s; // Set +>s : Set + + if (s instanceof Set) { +>s instanceof Set : boolean +>s : Set +>Set : SetConstructor + + s; // Set +>s : Set + } + else { + s; // never +>s : never + } +} + +// More tests + +class A { a: string } +>A : A +>a : string + +class B extends A { b: string } +>B : B +>A : A +>b : string + +class C extends A { c: string } +>C : C +>A : A +>c : string + +function foo(x: A | undefined) { +>foo : (x: A) => void +>x : A +>A : A + + x; // A | undefined +>x : A + + if (x instanceof B || x instanceof C) { +>x instanceof B || x instanceof C : boolean +>x instanceof B : boolean +>x : A +>B : typeof B +>x instanceof C : boolean +>x : A +>C : typeof C + + x; // B | C +>x : B | C + } + x; // A | undefined +>x : A + + if (x instanceof B && x instanceof C) { +>x instanceof B && x instanceof C : boolean +>x instanceof B : boolean +>x : A +>B : typeof B +>x instanceof C : boolean +>x : B +>C : typeof C + + x; // B & C +>x : B & C + } + x; // A | undefined +>x : A + + if (!x) { +>!x : boolean +>x : A + + return; + } + x; // A +>x : A + + if (x instanceof B) { +>x instanceof B : boolean +>x : A +>B : typeof B + + x; // B +>x : B + + if (x instanceof C) { +>x instanceof C : boolean +>x : B +>C : typeof C + + x; // B & C +>x : B & C + } + else { + x; // B +>x : B + } + x; // B +>x : B + } + else { + x; // A +>x : A + } + x; // A +>x : A +} + +// X is neither assignable to Y nor a subtype of Y +// Y is assignable to X, but not a subtype of X + +interface X { +>X : X + + x?: string; +>x : string +} + +class Y { +>Y : Y + + y: string; +>y : string +} + +function goo(x: X) { +>goo : (x: X) => void +>x : X +>X : X + + x; +>x : X + + if (x instanceof Y) { +>x instanceof Y : boolean +>x : X +>Y : typeof Y + + x.y; +>x.y : string +>x : Y +>y : string + } + x; +>x : X +} diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 517eaafe4ab..3ed9e241c39 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -18,11 +18,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. - Types of property '1' are incompatible. - Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. - Types of property '1' are incompatible. - Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. - Property 'x' is missing in type '{ y: boolean; }'. + Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. + Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. + Property 'x' is missing in type '{ y: boolean; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. @@ -174,11 +172,9 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): f14([2, ["abc", { y: false }]]); // Error, no x ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. -!!! error TS2345: Types of property '1' are incompatible. -!!! error TS2345: Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. -!!! error TS2345: Types of property '1' are incompatible. -!!! error TS2345: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. -!!! error TS2345: Property 'x' is missing in type '{ y: boolean; }'. +!!! error TS2345: Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. +!!! error TS2345: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. +!!! error TS2345: Property 'x' is missing in type '{ y: boolean; }'. module M { export var [a, b] = [1, 2]; diff --git a/tests/baselines/reference/decoratorOnClassConstructor2.errors.txt b/tests/baselines/reference/decoratorOnClassConstructor2.errors.txt new file mode 100644 index 00000000000..c4585b8301f --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructor2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/conformance/decorators/class/constructor/2.ts(1,20): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './0' instead. +tests/cases/conformance/decorators/class/constructor/2.ts(2,19): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './0' instead. + + +==== tests/cases/conformance/decorators/class/constructor/0.ts (0 errors) ==== + + export class base { } + export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { } + +==== tests/cases/conformance/decorators/class/constructor/2.ts (2 errors) ==== + import {base} from "./0.ts" + ~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './0' instead. + import {foo} from "./0.ts" + ~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './0' instead. + export class C extends base{ + constructor(@foo prop: any) { + super(); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index 3348effe822..e22b23122d3 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -2,8 +2,7 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. - Types of property '1' are incompatible. - Type 'number' is not assignable to type 'boolean'. + Type 'number' is not assignable to type 'boolean'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'. Property '0' is missing in type 'number[]'. @@ -30,8 +29,7 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"]; // Error ~~~~~~~~~~~~ !!! error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. +!!! error TS2322: Type 'number' is not assignable to type 'boolean'. interface J extends Array { 2: number; } diff --git a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt index 878bb38abf0..d76a4efe5f1 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration2.errors.txt @@ -1,6 +1,5 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,4): error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. - Types of property '1' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(7,29): error TS1005: ',' expected. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(8,4): error TS2345: Argument of type '[number, number, string[][], string]' is not assignable to parameter of type '[number, number, string[][]]'. Types of property 'pop' are incompatible. @@ -32,12 +31,9 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( Types of property '2' are incompatible. Type 'boolean' is not assignable to type '[[any]]'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(40,4): error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'. - Types of property '2' are incompatible. - Type '[[string]]' is not assignable to type '[[number]]'. - Types of property '0' are incompatible. - Type '[string]' is not assignable to type '[number]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Type '[[string]]' is not assignable to type '[[number]]'. + Type '[string]' is not assignable to type '[number]'. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(46,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(47,13): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts(55,7): error TS2420: Class 'C4' incorrectly implements interface 'F2'. @@ -62,8 +58,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( a0([1, "string", [["world"]]); // Error ~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, string, string[][]]' is not assignable to parameter of type '[number, number, string[][]]'. -!!! error TS2345: Types of property '1' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. ~ !!! error TS1005: ',' expected. a0([1, 2, [["world"]], "string"]); // Error @@ -142,12 +137,9 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration2.ts( c6([1, 2, [["string"]]]); // Error, implied type is [any, any, [[number]]] // Use initializer ~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, number, [[string]]]' is not assignable to parameter of type '[any, any, [[number]]]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type '[[string]]' is not assignable to type '[[number]]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type '[string]' is not assignable to type '[number]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'number'. +!!! error TS2345: Type '[[string]]' is not assignable to type '[[number]]'. +!!! error TS2345: Type '[string]' is not assignable to type '[number]'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. // A parameter can be marked optional by following its name or binding pattern with a question mark (?) // or by including an initializer. Initializers (including binding property or element initializers) are diff --git a/tests/baselines/reference/destructuringParameterProperties2.errors.txt b/tests/baselines/reference/destructuringParameterProperties2.errors.txt index ec0f400631f..deb039aa67d 100644 --- a/tests/baselines/reference/destructuringParameterProperties2.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties2.errors.txt @@ -6,8 +6,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9 tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. - Types of property '2' are incompatible. - Type 'string' is not assignable to type 'boolean'. + Type 'string' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ==== @@ -48,8 +47,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2 var x = new C1(undefined, [0, undefined, ""]); ~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. -!!! error TS2345: Types of property '2' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. +!!! error TS2345: Type 'string' is not assignable to type 'boolean'. var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; var y = new C1(10, [0, "", true]); diff --git a/tests/baselines/reference/destructuringParameterProperties5.errors.txt b/tests/baselines/reference/destructuringParameterProperties5.errors.txt index 6f5801b7898..8eff6ad0feb 100644 --- a/tests/baselines/reference/destructuringParameterProperties5.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties5.errors.txt @@ -8,9 +8,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7 tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,19): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. - Types of property '0' are incompatible. - Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. - Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. + Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. + Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ==== @@ -45,7 +44,6 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(1 var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]); ~~~~~~ !!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. -!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. +!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'. +!!! error TS2345: Object literal may only specify known properties, and 'x1' does not exist in type '{ x: number; y: string; z: boolean; }'. var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z]; \ No newline at end of file diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt index 1a655837743..bdbda6f9a96 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt @@ -2,12 +2,9 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3 Types of property 'a1' are incompatible. Type 'boolean' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,5): error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'. - Types of property '1' are incompatible. - Type '[[boolean]]' is not assignable to type '[[string]]'. - Types of property '0' are incompatible. - Type '[boolean]' is not assignable to type '[string]'. - Types of property '0' are incompatible. - Type 'boolean' is not assignable to type 'string'. + Type '[[boolean]]' is not assignable to type '[[string]]'. + Type '[boolean]' is not assignable to type '[string]'. + Type 'boolean' is not assignable to type 'string'. tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(9,25): error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'. Types of property 't2' are incompatible. Type 'string' is not assignable to type 'number'. @@ -28,12 +25,9 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(1 var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error ~~~~~~~~~~~~~~~~ !!! error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type '[[boolean]]' is not assignable to type '[[string]]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '[boolean]' is not assignable to type '[string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. +!!! error TS2322: Type '[[boolean]]' is not assignable to type '[[string]]'. +!!! error TS2322: Type '[boolean]' is not assignable to type '[string]'. +!!! error TS2322: Type 'boolean' is not assignable to type 'string'. // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. diff --git a/tests/baselines/reference/discriminantPropertyCheck.errors.txt b/tests/baselines/reference/discriminantPropertyCheck.errors.txt new file mode 100644 index 00000000000..41593c4b224 --- /dev/null +++ b/tests/baselines/reference/discriminantPropertyCheck.errors.txt @@ -0,0 +1,77 @@ +tests/cases/compiler/discriminantPropertyCheck.ts(30,9): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/discriminantPropertyCheck.ts(66,9): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/discriminantPropertyCheck.ts (2 errors) ==== + + type Item = Item1 | Item2; + + interface Base { + bar: boolean; + } + + interface Item1 extends Base { + kind: "A"; + foo: string | undefined; + baz: boolean; + qux: true; + } + + interface Item2 extends Base { + kind: "B"; + foo: string | undefined; + baz: boolean; + qux: false; + } + + function goo1(x: Item) { + if (x.kind === "A" && x.foo !== undefined) { + x.foo.length; + } + } + + function goo2(x: Item) { + if (x.foo !== undefined && x.kind === "A") { + x.foo.length; // Error, intervening discriminant guard + ~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + + function foo1(x: Item) { + if (x.bar && x.foo !== undefined) { + x.foo.length; + } + } + + function foo2(x: Item) { + if (x.foo !== undefined && x.bar) { + x.foo.length; + } + } + + function foo3(x: Item) { + if (x.baz && x.foo !== undefined) { + x.foo.length; + } + } + + function foo4(x: Item) { + if (x.foo !== undefined && x.baz) { + x.foo.length; + } + } + + function foo5(x: Item) { + if (x.qux && x.foo !== undefined) { + x.foo.length; + } + } + + function foo6(x: Item) { + if (x.foo !== undefined && x.qux) { + x.foo.length; // Error, intervening discriminant guard + ~~~~~ +!!! error TS2532: Object is possibly 'undefined'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/discriminantPropertyCheck.js b/tests/baselines/reference/discriminantPropertyCheck.js new file mode 100644 index 00000000000..b75a6277735 --- /dev/null +++ b/tests/baselines/reference/discriminantPropertyCheck.js @@ -0,0 +1,111 @@ +//// [discriminantPropertyCheck.ts] + +type Item = Item1 | Item2; + +interface Base { + bar: boolean; +} + +interface Item1 extends Base { + kind: "A"; + foo: string | undefined; + baz: boolean; + qux: true; +} + +interface Item2 extends Base { + kind: "B"; + foo: string | undefined; + baz: boolean; + qux: false; +} + +function goo1(x: Item) { + if (x.kind === "A" && x.foo !== undefined) { + x.foo.length; + } +} + +function goo2(x: Item) { + if (x.foo !== undefined && x.kind === "A") { + x.foo.length; // Error, intervening discriminant guard + } +} + +function foo1(x: Item) { + if (x.bar && x.foo !== undefined) { + x.foo.length; + } +} + +function foo2(x: Item) { + if (x.foo !== undefined && x.bar) { + x.foo.length; + } +} + +function foo3(x: Item) { + if (x.baz && x.foo !== undefined) { + x.foo.length; + } +} + +function foo4(x: Item) { + if (x.foo !== undefined && x.baz) { + x.foo.length; + } +} + +function foo5(x: Item) { + if (x.qux && x.foo !== undefined) { + x.foo.length; + } +} + +function foo6(x: Item) { + if (x.foo !== undefined && x.qux) { + x.foo.length; // Error, intervening discriminant guard + } +} + +//// [discriminantPropertyCheck.js] +function goo1(x) { + if (x.kind === "A" && x.foo !== undefined) { + x.foo.length; + } +} +function goo2(x) { + if (x.foo !== undefined && x.kind === "A") { + x.foo.length; // Error, intervening discriminant guard + } +} +function foo1(x) { + if (x.bar && x.foo !== undefined) { + x.foo.length; + } +} +function foo2(x) { + if (x.foo !== undefined && x.bar) { + x.foo.length; + } +} +function foo3(x) { + if (x.baz && x.foo !== undefined) { + x.foo.length; + } +} +function foo4(x) { + if (x.foo !== undefined && x.baz) { + x.foo.length; + } +} +function foo5(x) { + if (x.qux && x.foo !== undefined) { + x.foo.length; + } +} +function foo6(x) { + if (x.foo !== undefined && x.qux) { + x.foo.length; // Error, intervening discriminant guard + } +} diff --git a/tests/baselines/reference/discriminantsAndNullOrUndefined.js b/tests/baselines/reference/discriminantsAndNullOrUndefined.js new file mode 100644 index 00000000000..153950f8ab5 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndNullOrUndefined.js @@ -0,0 +1,44 @@ +//// [discriminantsAndNullOrUndefined.ts] + +// Repro from #10228 + +interface A { kind: 'A'; } +interface B { kind: 'B'; } + +type C = A | B | undefined; + +function never(_: never): never { + throw new Error(); +} + +function useA(_: A): void { } +function useB(_: B): void { } + +declare var c: C; + +if (c !== undefined) { + switch (c.kind) { + case 'A': useA(c); break; + case 'B': useB(c); break; + default: never(c); + } +} + +//// [discriminantsAndNullOrUndefined.js] +// Repro from #10228 +function never(_) { + throw new Error(); +} +function useA(_) { } +function useB(_) { } +if (c !== undefined) { + switch (c.kind) { + case 'A': + useA(c); + break; + case 'B': + useB(c); + break; + default: never(c); + } +} diff --git a/tests/baselines/reference/discriminantsAndNullOrUndefined.symbols b/tests/baselines/reference/discriminantsAndNullOrUndefined.symbols new file mode 100644 index 00000000000..3f95fcf3a3f --- /dev/null +++ b/tests/baselines/reference/discriminantsAndNullOrUndefined.symbols @@ -0,0 +1,61 @@ +=== tests/cases/compiler/discriminantsAndNullOrUndefined.ts === + +// Repro from #10228 + +interface A { kind: 'A'; } +>A : Symbol(A, Decl(discriminantsAndNullOrUndefined.ts, 0, 0)) +>kind : Symbol(A.kind, Decl(discriminantsAndNullOrUndefined.ts, 3, 13)) + +interface B { kind: 'B'; } +>B : Symbol(B, Decl(discriminantsAndNullOrUndefined.ts, 3, 26)) +>kind : Symbol(B.kind, Decl(discriminantsAndNullOrUndefined.ts, 4, 13)) + +type C = A | B | undefined; +>C : Symbol(C, Decl(discriminantsAndNullOrUndefined.ts, 4, 26)) +>A : Symbol(A, Decl(discriminantsAndNullOrUndefined.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndNullOrUndefined.ts, 3, 26)) + +function never(_: never): never { +>never : Symbol(never, Decl(discriminantsAndNullOrUndefined.ts, 6, 27)) +>_ : Symbol(_, Decl(discriminantsAndNullOrUndefined.ts, 8, 15)) + + throw new Error(); +>Error : Symbol(Error, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +function useA(_: A): void { } +>useA : Symbol(useA, Decl(discriminantsAndNullOrUndefined.ts, 10, 1)) +>_ : Symbol(_, Decl(discriminantsAndNullOrUndefined.ts, 12, 14)) +>A : Symbol(A, Decl(discriminantsAndNullOrUndefined.ts, 0, 0)) + +function useB(_: B): void { } +>useB : Symbol(useB, Decl(discriminantsAndNullOrUndefined.ts, 12, 29)) +>_ : Symbol(_, Decl(discriminantsAndNullOrUndefined.ts, 13, 14)) +>B : Symbol(B, Decl(discriminantsAndNullOrUndefined.ts, 3, 26)) + +declare var c: C; +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) +>C : Symbol(C, Decl(discriminantsAndNullOrUndefined.ts, 4, 26)) + +if (c !== undefined) { +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) +>undefined : Symbol(undefined) + + switch (c.kind) { +>c.kind : Symbol(kind, Decl(discriminantsAndNullOrUndefined.ts, 3, 13), Decl(discriminantsAndNullOrUndefined.ts, 4, 13)) +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) +>kind : Symbol(kind, Decl(discriminantsAndNullOrUndefined.ts, 3, 13), Decl(discriminantsAndNullOrUndefined.ts, 4, 13)) + + case 'A': useA(c); break; +>useA : Symbol(useA, Decl(discriminantsAndNullOrUndefined.ts, 10, 1)) +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) + + case 'B': useB(c); break; +>useB : Symbol(useB, Decl(discriminantsAndNullOrUndefined.ts, 12, 29)) +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) + + default: never(c); +>never : Symbol(never, Decl(discriminantsAndNullOrUndefined.ts, 6, 27)) +>c : Symbol(c, Decl(discriminantsAndNullOrUndefined.ts, 15, 11)) + } +} diff --git a/tests/baselines/reference/discriminantsAndNullOrUndefined.types b/tests/baselines/reference/discriminantsAndNullOrUndefined.types new file mode 100644 index 00000000000..7a2918ab83b --- /dev/null +++ b/tests/baselines/reference/discriminantsAndNullOrUndefined.types @@ -0,0 +1,68 @@ +=== tests/cases/compiler/discriminantsAndNullOrUndefined.ts === + +// Repro from #10228 + +interface A { kind: 'A'; } +>A : A +>kind : "A" + +interface B { kind: 'B'; } +>B : B +>kind : "B" + +type C = A | B | undefined; +>C : C +>A : A +>B : B + +function never(_: never): never { +>never : (_: never) => never +>_ : never + + throw new Error(); +>new Error() : Error +>Error : ErrorConstructor +} + +function useA(_: A): void { } +>useA : (_: A) => void +>_ : A +>A : A + +function useB(_: B): void { } +>useB : (_: B) => void +>_ : B +>B : B + +declare var c: C; +>c : C +>C : C + +if (c !== undefined) { +>c !== undefined : boolean +>c : C +>undefined : undefined + + switch (c.kind) { +>c.kind : "A" | "B" +>c : A | B +>kind : "A" | "B" + + case 'A': useA(c); break; +>'A' : "A" +>useA(c) : void +>useA : (_: A) => void +>c : A + + case 'B': useB(c); break; +>'B' : "B" +>useB(c) : void +>useB : (_: B) => void +>c : B + + default: never(c); +>never(c) : never +>never : (_: never) => never +>c : never + } +} diff --git a/tests/baselines/reference/discriminantsAndPrimitives.js b/tests/baselines/reference/discriminantsAndPrimitives.js new file mode 100644 index 00000000000..1d11781a707 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndPrimitives.js @@ -0,0 +1,84 @@ +//// [discriminantsAndPrimitives.ts] + +// Repro from #10257 plus other tests + +interface Foo { + kind: "foo"; + name: string; +} + +interface Bar { + kind: "bar"; + length: string; +} + +function f1(x: Foo | Bar | string) { + if (typeof x !== 'string') { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f2(x: Foo | Bar | string | undefined) { + if (typeof x === "object") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f3(x: Foo | Bar | string | null) { + if (x && typeof x !== "string") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f4(x: Foo | Bar | string | number | null) { + if (x && typeof x === "object") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +//// [discriminantsAndPrimitives.js] +// Repro from #10257 plus other tests +function f1(x) { + if (typeof x !== 'string') { + switch (x.kind) { + case 'foo': + x.name; + } + } +} +function f2(x) { + if (typeof x === "object") { + switch (x.kind) { + case 'foo': + x.name; + } + } +} +function f3(x) { + if (x && typeof x !== "string") { + switch (x.kind) { + case 'foo': + x.name; + } + } +} +function f4(x) { + if (x && typeof x === "object") { + switch (x.kind) { + case 'foo': + x.name; + } + } +} diff --git a/tests/baselines/reference/discriminantsAndPrimitives.symbols b/tests/baselines/reference/discriminantsAndPrimitives.symbols new file mode 100644 index 00000000000..c84f32cd990 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndPrimitives.symbols @@ -0,0 +1,117 @@ +=== tests/cases/compiler/discriminantsAndPrimitives.ts === + +// Repro from #10257 plus other tests + +interface Foo { +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) + + kind: "foo"; +>kind : Symbol(Foo.kind, Decl(discriminantsAndPrimitives.ts, 3, 15)) + + name: string; +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +} + +interface Bar { +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + kind: "bar"; +>kind : Symbol(Bar.kind, Decl(discriminantsAndPrimitives.ts, 8, 15)) + + length: string; +>length : Symbol(Bar.length, Decl(discriminantsAndPrimitives.ts, 9, 16)) +} + +function f1(x: Foo | Bar | string) { +>f1 : Symbol(f1, Decl(discriminantsAndPrimitives.ts, 11, 1)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 13, 12)) +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + if (typeof x !== 'string') { +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 13, 12)) + + switch(x.kind) { +>x.kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 13, 12)) +>kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) + + case 'foo': + x.name; +>x.name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 13, 12)) +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) + } + } +} + +function f2(x: Foo | Bar | string | undefined) { +>f2 : Symbol(f2, Decl(discriminantsAndPrimitives.ts, 20, 1)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 22, 12)) +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + if (typeof x === "object") { +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 22, 12)) + + switch(x.kind) { +>x.kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 22, 12)) +>kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) + + case 'foo': + x.name; +>x.name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 22, 12)) +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) + } + } +} + +function f3(x: Foo | Bar | string | null) { +>f3 : Symbol(f3, Decl(discriminantsAndPrimitives.ts, 29, 1)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + if (x && typeof x !== "string") { +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) + + switch(x.kind) { +>x.kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) +>kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) + + case 'foo': + x.name; +>x.name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 31, 12)) +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) + } + } +} + +function f4(x: Foo | Bar | string | number | null) { +>f4 : Symbol(f4, Decl(discriminantsAndPrimitives.ts, 38, 1)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) +>Foo : Symbol(Foo, Decl(discriminantsAndPrimitives.ts, 0, 0)) +>Bar : Symbol(Bar, Decl(discriminantsAndPrimitives.ts, 6, 1)) + + if (x && typeof x === "object") { +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) + + switch(x.kind) { +>x.kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) +>kind : Symbol(kind, Decl(discriminantsAndPrimitives.ts, 3, 15), Decl(discriminantsAndPrimitives.ts, 8, 15)) + + case 'foo': + x.name; +>x.name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) +>x : Symbol(x, Decl(discriminantsAndPrimitives.ts, 40, 12)) +>name : Symbol(Foo.name, Decl(discriminantsAndPrimitives.ts, 4, 16)) + } + } +} diff --git a/tests/baselines/reference/discriminantsAndPrimitives.types b/tests/baselines/reference/discriminantsAndPrimitives.types new file mode 100644 index 00000000000..d3e1b70e599 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndPrimitives.types @@ -0,0 +1,141 @@ +=== tests/cases/compiler/discriminantsAndPrimitives.ts === + +// Repro from #10257 plus other tests + +interface Foo { +>Foo : Foo + + kind: "foo"; +>kind : "foo" + + name: string; +>name : string +} + +interface Bar { +>Bar : Bar + + kind: "bar"; +>kind : "bar" + + length: string; +>length : string +} + +function f1(x: Foo | Bar | string) { +>f1 : (x: string | Foo | Bar) => void +>x : string | Foo | Bar +>Foo : Foo +>Bar : Bar + + if (typeof x !== 'string') { +>typeof x !== 'string' : boolean +>typeof x : string +>x : string | Foo | Bar +>'string' : "string" + + switch(x.kind) { +>x.kind : "foo" | "bar" +>x : Foo | Bar +>kind : "foo" | "bar" + + case 'foo': +>'foo' : "foo" + + x.name; +>x.name : string +>x : Foo +>name : string + } + } +} + +function f2(x: Foo | Bar | string | undefined) { +>f2 : (x: string | Foo | Bar | undefined) => void +>x : string | Foo | Bar | undefined +>Foo : Foo +>Bar : Bar + + if (typeof x === "object") { +>typeof x === "object" : boolean +>typeof x : string +>x : string | Foo | Bar | undefined +>"object" : "object" + + switch(x.kind) { +>x.kind : "foo" | "bar" +>x : Foo | Bar +>kind : "foo" | "bar" + + case 'foo': +>'foo' : "foo" + + x.name; +>x.name : string +>x : Foo +>name : string + } + } +} + +function f3(x: Foo | Bar | string | null) { +>f3 : (x: string | Foo | Bar | null) => void +>x : string | Foo | Bar | null +>Foo : Foo +>Bar : Bar +>null : null + + if (x && typeof x !== "string") { +>x && typeof x !== "string" : boolean | "" | null +>x : string | Foo | Bar | null +>typeof x !== "string" : boolean +>typeof x : string +>x : string | Foo | Bar +>"string" : "string" + + switch(x.kind) { +>x.kind : "foo" | "bar" +>x : Foo | Bar +>kind : "foo" | "bar" + + case 'foo': +>'foo' : "foo" + + x.name; +>x.name : string +>x : Foo +>name : string + } + } +} + +function f4(x: Foo | Bar | string | number | null) { +>f4 : (x: string | number | Foo | Bar | null) => void +>x : string | number | Foo | Bar | null +>Foo : Foo +>Bar : Bar +>null : null + + if (x && typeof x === "object") { +>x && typeof x === "object" : boolean | "" | 0 | null +>x : string | number | Foo | Bar | null +>typeof x === "object" : boolean +>typeof x : string +>x : string | number | Foo | Bar +>"object" : "object" + + switch(x.kind) { +>x.kind : "foo" | "bar" +>x : Foo | Bar +>kind : "foo" | "bar" + + case 'foo': +>'foo' : "foo" + + x.name; +>x.name : string +>x : Foo +>name : string + } + } +} diff --git a/tests/baselines/reference/discriminantsAndTypePredicates.js b/tests/baselines/reference/discriminantsAndTypePredicates.js new file mode 100644 index 00000000000..66cfe056ab7 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndTypePredicates.js @@ -0,0 +1,59 @@ +//// [discriminantsAndTypePredicates.ts] +// Repro from #10145 + +interface A { type: 'A' } +interface B { type: 'B' } + +function isA(x: A | B): x is A { return x.type === 'A'; } +function isB(x: A | B): x is B { return x.type === 'B'; } + +function foo1(x: A | B): any { + x; // A | B + if (isA(x)) { + return x; // A + } + x; // B + if (isB(x)) { + return x; // B + } + x; // never +} + +function foo2(x: A | B): any { + x; // A | B + if (x.type === 'A') { + return x; // A + } + x; // B + if (x.type === 'B') { + return x; // B + } + x; // never +} + +//// [discriminantsAndTypePredicates.js] +// Repro from #10145 +function isA(x) { return x.type === 'A'; } +function isB(x) { return x.type === 'B'; } +function foo1(x) { + x; // A | B + if (isA(x)) { + return x; // A + } + x; // B + if (isB(x)) { + return x; // B + } + x; // never +} +function foo2(x) { + x; // A | B + if (x.type === 'A') { + return x; // A + } + x; // B + if (x.type === 'B') { + return x; // B + } + x; // never +} diff --git a/tests/baselines/reference/discriminantsAndTypePredicates.symbols b/tests/baselines/reference/discriminantsAndTypePredicates.symbols new file mode 100644 index 00000000000..4f412823936 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndTypePredicates.symbols @@ -0,0 +1,94 @@ +=== tests/cases/compiler/discriminantsAndTypePredicates.ts === +// Repro from #10145 + +interface A { type: 'A' } +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>type : Symbol(A.type, Decl(discriminantsAndTypePredicates.ts, 2, 13)) + +interface B { type: 'B' } +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) +>type : Symbol(B.type, Decl(discriminantsAndTypePredicates.ts, 3, 13)) + +function isA(x: A | B): x is A { return x.type === 'A'; } +>isA : Symbol(isA, Decl(discriminantsAndTypePredicates.ts, 3, 25)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 5, 13)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 5, 13)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>x.type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 5, 13)) +>type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) + +function isB(x: A | B): x is B { return x.type === 'B'; } +>isB : Symbol(isB, Decl(discriminantsAndTypePredicates.ts, 5, 57)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 6, 13)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 6, 13)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) +>x.type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 6, 13)) +>type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) + +function foo1(x: A | B): any { +>foo1 : Symbol(foo1, Decl(discriminantsAndTypePredicates.ts, 6, 57)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) + + x; // A | B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + + if (isA(x)) { +>isA : Symbol(isA, Decl(discriminantsAndTypePredicates.ts, 3, 25)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + + return x; // A +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + } + x; // B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + + if (isB(x)) { +>isB : Symbol(isB, Decl(discriminantsAndTypePredicates.ts, 5, 57)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + + return x; // B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) + } + x; // never +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 8, 14)) +} + +function foo2(x: A | B): any { +>foo2 : Symbol(foo2, Decl(discriminantsAndTypePredicates.ts, 18, 1)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) +>A : Symbol(A, Decl(discriminantsAndTypePredicates.ts, 0, 0)) +>B : Symbol(B, Decl(discriminantsAndTypePredicates.ts, 2, 25)) + + x; // A | B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) + + if (x.type === 'A') { +>x.type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) +>type : Symbol(type, Decl(discriminantsAndTypePredicates.ts, 2, 13), Decl(discriminantsAndTypePredicates.ts, 3, 13)) + + return x; // A +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) + } + x; // B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) + + if (x.type === 'B') { +>x.type : Symbol(B.type, Decl(discriminantsAndTypePredicates.ts, 3, 13)) +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) +>type : Symbol(B.type, Decl(discriminantsAndTypePredicates.ts, 3, 13)) + + return x; // B +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) + } + x; // never +>x : Symbol(x, Decl(discriminantsAndTypePredicates.ts, 20, 14)) +} diff --git a/tests/baselines/reference/discriminantsAndTypePredicates.types b/tests/baselines/reference/discriminantsAndTypePredicates.types new file mode 100644 index 00000000000..f7675b14756 --- /dev/null +++ b/tests/baselines/reference/discriminantsAndTypePredicates.types @@ -0,0 +1,104 @@ +=== tests/cases/compiler/discriminantsAndTypePredicates.ts === +// Repro from #10145 + +interface A { type: 'A' } +>A : A +>type : "A" + +interface B { type: 'B' } +>B : B +>type : "B" + +function isA(x: A | B): x is A { return x.type === 'A'; } +>isA : (x: A | B) => x is A +>x : A | B +>A : A +>B : B +>x : any +>A : A +>x.type === 'A' : boolean +>x.type : "A" | "B" +>x : A | B +>type : "A" | "B" +>'A' : "A" + +function isB(x: A | B): x is B { return x.type === 'B'; } +>isB : (x: A | B) => x is B +>x : A | B +>A : A +>B : B +>x : any +>B : B +>x.type === 'B' : boolean +>x.type : "A" | "B" +>x : A | B +>type : "A" | "B" +>'B' : "B" + +function foo1(x: A | B): any { +>foo1 : (x: A | B) => any +>x : A | B +>A : A +>B : B + + x; // A | B +>x : A | B + + if (isA(x)) { +>isA(x) : boolean +>isA : (x: A | B) => x is A +>x : A | B + + return x; // A +>x : A + } + x; // B +>x : B + + if (isB(x)) { +>isB(x) : boolean +>isB : (x: A | B) => x is B +>x : B + + return x; // B +>x : B + } + x; // never +>x : never +} + +function foo2(x: A | B): any { +>foo2 : (x: A | B) => any +>x : A | B +>A : A +>B : B + + x; // A | B +>x : A | B + + if (x.type === 'A') { +>x.type === 'A' : boolean +>x.type : "A" | "B" +>x : A | B +>type : "A" | "B" +>'A' : "A" + + return x; // A +>x : A + } + x; // B +>x : B + + if (x.type === 'B') { +>x.type === 'B' : boolean +>x.type : "B" +>x : B +>type : "B" +>'B' : "B" + + return x; // B +>x : B + } + x; // never +>x : never +} diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.errors.txt b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.errors.txt new file mode 100644 index 00000000000..d0f11d056ca --- /dev/null +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts(3,17): error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'. +tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts(3,29): error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'. + + +==== tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts (2 errors) ==== + declare function wrapper(x: any); + wrapper((array: [any]) => { + [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" + ~~~~~~~~~~ +!!! error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'. + ~~~~~~~~~~ +!!! error TS2493: Tuple type '[any]' with length '1' cannot be assigned to tuple with length '3'. + }); \ No newline at end of file diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.js b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.js new file mode 100644 index 00000000000..9dd7453ba4f --- /dev/null +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring1.js @@ -0,0 +1,11 @@ +//// [emitCapturingThisInTupleDestructuring1.ts] +declare function wrapper(x: any); +wrapper((array: [any]) => { + [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" +}); + +//// [emitCapturingThisInTupleDestructuring1.js] +var _this = this; +wrapper(function (array) { + _this.test = array[0], _this.test1 = array[1], _this.test2 = array[2]; // even though there is a compiler error, we should still emit lexical capture for "this" +}); diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.errors.txt b/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.errors.txt new file mode 100644 index 00000000000..25207e28c79 --- /dev/null +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.errors.txt @@ -0,0 +1,16 @@ +tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts(8,39): error TS2493: Tuple type '[number, number]' with length '2' cannot be assigned to tuple with length '3'. + + +==== tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts (1 errors) ==== + var array1: [number, number] = [1, 2]; + + class B { + test: number; + test1: any; + test2: any; + method() { + () => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this" + ~~~~~~~~~~ +!!! error TS2493: Tuple type '[number, number]' with length '2' cannot be assigned to tuple with length '3'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.js b/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.js new file mode 100644 index 00000000000..890b9d4c9b8 --- /dev/null +++ b/tests/baselines/reference/emitCapturingThisInTupleDestructuring2.js @@ -0,0 +1,23 @@ +//// [emitCapturingThisInTupleDestructuring2.ts] +var array1: [number, number] = [1, 2]; + +class B { + test: number; + test1: any; + test2: any; + method() { + () => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this" + } +} + +//// [emitCapturingThisInTupleDestructuring2.js] +var array1 = [1, 2]; +var B = (function () { + function B() { + } + B.prototype.method = function () { + var _this = this; + (function () { return _this.test = array1[0], _this.test1 = array1[1], _this.test2 = array1[2], array1; }); // even though there is a compiler error, we should still emit lexical capture for "this" + }; + return B; +}()); diff --git a/tests/baselines/reference/exportDefaultProperty.js b/tests/baselines/reference/exportDefaultProperty.js new file mode 100644 index 00000000000..10ba6d6419a --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty.js @@ -0,0 +1,76 @@ +//// [tests/cases/compiler/exportDefaultProperty.ts] //// + +//// [declarations.d.ts] +// This test is just like exportEqualsProperty, but with `export default`. + +declare namespace foo.bar { + export type X = number; + export const X: number; +} + +declare module "foobar" { + export default foo.bar; +} + +declare module "foobarx" { + export default foo.bar.X; +} + +//// [a.ts] +namespace A { + export class B { constructor(b: number) {} } + export namespace B { export const b: number = 0; } +} +export default A.B; + +//// [b.ts] +export default "foo".length; + +//// [index.ts] +/// +import fooBar from "foobar"; +import X = fooBar.X; +import X2 from "foobarx"; +const x: X = X; +const x2: X2 = X2; + +import B from "./a"; +const b: B = new B(B.b); + +import fooLength from "./b"; +fooLength + 1; + + +//// [a.js] +"use strict"; +var A; +(function (A) { + var B = (function () { + function B(b) { + } + return B; + }()); + A.B = B; + var B; + (function (B) { + B.b = 0; + })(B = A.B || (A.B = {})); +})(A || (A = {})); +exports.__esModule = true; +exports["default"] = A.B; +//// [b.js] +"use strict"; +exports.__esModule = true; +exports["default"] = "foo".length; +//// [index.js] +"use strict"; +/// +var foobar_1 = require("foobar"); +var X = foobar_1["default"].X; +var foobarx_1 = require("foobarx"); +var x = X; +var x2 = foobarx_1["default"]; +var a_1 = require("./a"); +var b = new a_1["default"](a_1["default"].b); +var b_1 = require("./b"); +b_1["default"] + 1; diff --git a/tests/baselines/reference/exportDefaultProperty.symbols b/tests/baselines/reference/exportDefaultProperty.symbols new file mode 100644 index 00000000000..f9edcd154cc --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty.symbols @@ -0,0 +1,92 @@ +=== tests/cases/compiler/index.ts === +/// +import fooBar from "foobar"; +>fooBar : Symbol(fooBar, Decl(index.ts, 1, 6)) + +import X = fooBar.X; +>X : Symbol(X, Decl(index.ts, 1, 28)) +>fooBar : Symbol(fooBar, Decl(index.ts, 1, 6)) +>X : Symbol(fooBar.X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) + +import X2 from "foobarx"; +>X2 : Symbol(X2, Decl(index.ts, 3, 6)) + +const x: X = X; +>x : Symbol(x, Decl(index.ts, 4, 5)) +>X : Symbol(X, Decl(index.ts, 1, 28)) +>X : Symbol(X, Decl(index.ts, 1, 28)) + +const x2: X2 = X2; +>x2 : Symbol(x2, Decl(index.ts, 5, 5)) +>X2 : Symbol(X2, Decl(index.ts, 3, 6)) +>X2 : Symbol(X2, Decl(index.ts, 3, 6)) + +import B from "./a"; +>B : Symbol(B, Decl(index.ts, 7, 6)) + +const b: B = new B(B.b); +>b : Symbol(b, Decl(index.ts, 8, 5)) +>B : Symbol(B, Decl(index.ts, 7, 6)) +>B : Symbol(B, Decl(index.ts, 7, 6)) +>B.b : Symbol(B.b, Decl(a.ts, 2, 37)) +>B : Symbol(B, Decl(index.ts, 7, 6)) +>b : Symbol(B.b, Decl(a.ts, 2, 37)) + +import fooLength from "./b"; +>fooLength : Symbol(fooLength, Decl(index.ts, 10, 6)) + +fooLength + 1; +>fooLength : Symbol(fooLength, Decl(index.ts, 10, 6)) + +=== tests/cases/compiler/declarations.d.ts === +// This test is just like exportEqualsProperty, but with `export default`. + +declare namespace foo.bar { +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(bar, Decl(declarations.d.ts, 2, 22)) + + export type X = number; +>X : Symbol(X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) + + export const X: number; +>X : Symbol(X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +} + +declare module "foobar" { + export default foo.bar; +>foo.bar : Symbol(default, Decl(declarations.d.ts, 2, 22)) +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(default, Decl(declarations.d.ts, 2, 22)) +} + +declare module "foobarx" { + export default foo.bar.X; +>foo.bar.X : Symbol(default, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +>foo.bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>X : Symbol(default, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +} + +=== tests/cases/compiler/a.ts === +namespace A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export class B { constructor(b: number) {} } +>B : Symbol(B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>b : Symbol(b, Decl(a.ts, 1, 33)) + + export namespace B { export const b: number = 0; } +>B : Symbol(B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>b : Symbol(b, Decl(a.ts, 2, 37)) +} +export default A.B; +>A.B : Symbol(default, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>A : Symbol(A, Decl(a.ts, 0, 0)) +>B : Symbol(default, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) + +=== tests/cases/compiler/b.ts === +export default "foo".length; +>"foo".length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/exportDefaultProperty.types b/tests/baselines/reference/exportDefaultProperty.types new file mode 100644 index 00000000000..47cfabfbc16 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty.types @@ -0,0 +1,97 @@ +=== tests/cases/compiler/index.ts === +/// +import fooBar from "foobar"; +>fooBar : typeof fooBar + +import X = fooBar.X; +>X : number +>fooBar : typeof fooBar +>X : number + +import X2 from "foobarx"; +>X2 : number + +const x: X = X; +>x : number +>X : number +>X : number + +const x2: X2 = X2; +>x2 : number +>X2 : number +>X2 : number + +import B from "./a"; +>B : typeof B + +const b: B = new B(B.b); +>b : B +>B : B +>new B(B.b) : B +>B : typeof B +>B.b : number +>B : typeof B +>b : number + +import fooLength from "./b"; +>fooLength : number + +fooLength + 1; +>fooLength + 1 : number +>fooLength : number +>1 : number + +=== tests/cases/compiler/declarations.d.ts === +// This test is just like exportEqualsProperty, but with `export default`. + +declare namespace foo.bar { +>foo : typeof foo +>bar : typeof bar + + export type X = number; +>X : number + + export const X: number; +>X : number +} + +declare module "foobar" { + export default foo.bar; +>foo.bar : typeof default +>foo : typeof foo +>bar : typeof default +} + +declare module "foobarx" { + export default foo.bar.X; +>foo.bar.X : number +>foo.bar : typeof foo.bar +>foo : typeof foo +>bar : typeof foo.bar +>X : number +} + +=== tests/cases/compiler/a.ts === +namespace A { +>A : typeof A + + export class B { constructor(b: number) {} } +>B : B +>b : number + + export namespace B { export const b: number = 0; } +>B : typeof B +>b : number +>0 : number +} +export default A.B; +>A.B : typeof default +>A : typeof A +>B : typeof default + +=== tests/cases/compiler/b.ts === +export default "foo".length; +>"foo".length : number +>"foo" : string +>length : number + diff --git a/tests/baselines/reference/exportDefaultProperty2.js b/tests/baselines/reference/exportDefaultProperty2.js new file mode 100644 index 00000000000..2b0a5dce526 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty2.js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/exportDefaultProperty2.ts] //// + +//// [a.ts] +// This test is just like exportEqualsProperty2, but with `export default`. + +class C { + static B: number; +} +namespace C { + export interface B { c: number } +} + +export default C.B; + +//// [b.ts] +import B from "./a"; +const x: B = { c: B }; + + +//// [a.js] +// This test is just like exportEqualsProperty2, but with `export default`. +"use strict"; +var C = (function () { + function C() { + } + return C; +}()); +exports.__esModule = true; +exports["default"] = C.B; +//// [b.js] +"use strict"; +var a_1 = require("./a"); +var x = { c: a_1["default"] }; diff --git a/tests/baselines/reference/exportDefaultProperty2.symbols b/tests/baselines/reference/exportDefaultProperty2.symbols new file mode 100644 index 00000000000..d3d7519aa94 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty2.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/a.ts === +// This test is just like exportEqualsProperty2, but with `export default`. + +class C { +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) + + static B: number; +>B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +} +namespace C { +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) + + export interface B { c: number } +>B : Symbol(B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>c : Symbol(B.c, Decl(a.ts, 6, 24)) +} + +export default C.B; +>C.B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) +>B : Symbol(default, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) + +=== tests/cases/compiler/b.ts === +import B from "./a"; +>B : Symbol(B, Decl(b.ts, 0, 6)) + +const x: B = { c: B }; +>x : Symbol(x, Decl(b.ts, 1, 5)) +>B : Symbol(B, Decl(b.ts, 0, 6)) +>c : Symbol(c, Decl(b.ts, 1, 14)) +>B : Symbol(B, Decl(b.ts, 0, 6)) + diff --git a/tests/baselines/reference/exportDefaultProperty2.types b/tests/baselines/reference/exportDefaultProperty2.types new file mode 100644 index 00000000000..2fc9d3a4750 --- /dev/null +++ b/tests/baselines/reference/exportDefaultProperty2.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/a.ts === +// This test is just like exportEqualsProperty2, but with `export default`. + +class C { +>C : C + + static B: number; +>B : number +} +namespace C { +>C : typeof C + + export interface B { c: number } +>B : B +>c : number +} + +export default C.B; +>C.B : number +>C : typeof C +>B : number + +=== tests/cases/compiler/b.ts === +import B from "./a"; +>B : number + +const x: B = { c: B }; +>x : B +>B : B +>{ c: B } : { c: number; } +>c : number +>B : number + diff --git a/tests/baselines/reference/exportEqualsProperty.js b/tests/baselines/reference/exportEqualsProperty.js new file mode 100644 index 00000000000..2fd8a8c8511 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty.js @@ -0,0 +1,72 @@ +//// [tests/cases/compiler/exportEqualsProperty.ts] //// + +//// [declarations.d.ts] +// This test is just like exportDefaultProperty, but with `export =`. + +declare namespace foo.bar { + export type X = number; + export const X: number; +} + +declare module "foobar" { + export = foo.bar; +} + +declare module "foobarx" { + export = foo.bar.X; +} + +//// [a.ts] +namespace A { + export class B { constructor(b: number) {} } + export namespace B { export const b: number = 0; } +} +export = A.B; + +//// [b.ts] +export = "foo".length; + +//// [index.ts] +/// +import { X } from "foobar"; +import X2 = require("foobarx"); +const x: X = X; +const x2: X2 = X2; + +import B = require("./a"); +const b: B = new B(B.b); + +import fooLength = require("./b"); +fooLength + 1; + + +//// [a.js] +"use strict"; +var A; +(function (A) { + var B = (function () { + function B(b) { + } + return B; + }()); + A.B = B; + var B; + (function (B) { + B.b = 0; + })(B = A.B || (A.B = {})); +})(A || (A = {})); +module.exports = A.B; +//// [b.js] +"use strict"; +module.exports = "foo".length; +//// [index.js] +"use strict"; +/// +var foobar_1 = require("foobar"); +var X2 = require("foobarx"); +var x = foobar_1.X; +var x2 = X2; +var B = require("./a"); +var b = new B(B.b); +var fooLength = require("./b"); +fooLength + 1; diff --git a/tests/baselines/reference/exportEqualsProperty.symbols b/tests/baselines/reference/exportEqualsProperty.symbols new file mode 100644 index 00000000000..43c9ed32518 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty.symbols @@ -0,0 +1,87 @@ +=== tests/cases/compiler/index.ts === +/// +import { X } from "foobar"; +>X : Symbol(X, Decl(index.ts, 1, 8)) + +import X2 = require("foobarx"); +>X2 : Symbol(X2, Decl(index.ts, 1, 27)) + +const x: X = X; +>x : Symbol(x, Decl(index.ts, 3, 5)) +>X : Symbol(X, Decl(index.ts, 1, 8)) +>X : Symbol(X, Decl(index.ts, 1, 8)) + +const x2: X2 = X2; +>x2 : Symbol(x2, Decl(index.ts, 4, 5)) +>X2 : Symbol(X2, Decl(index.ts, 1, 27)) +>X2 : Symbol(X2, Decl(index.ts, 1, 27)) + +import B = require("./a"); +>B : Symbol(B, Decl(index.ts, 4, 18)) + +const b: B = new B(B.b); +>b : Symbol(b, Decl(index.ts, 7, 5)) +>B : Symbol(B, Decl(index.ts, 4, 18)) +>B : Symbol(B, Decl(index.ts, 4, 18)) +>B.b : Symbol(B.b, Decl(a.ts, 2, 37)) +>B : Symbol(B, Decl(index.ts, 4, 18)) +>b : Symbol(B.b, Decl(a.ts, 2, 37)) + +import fooLength = require("./b"); +>fooLength : Symbol(fooLength, Decl(index.ts, 7, 24)) + +fooLength + 1; +>fooLength : Symbol(fooLength, Decl(index.ts, 7, 24)) + +=== tests/cases/compiler/declarations.d.ts === +// This test is just like exportDefaultProperty, but with `export =`. + +declare namespace foo.bar { +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(bar, Decl(declarations.d.ts, 2, 22)) + + export type X = number; +>X : Symbol(X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) + + export const X: number; +>X : Symbol(X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +} + +declare module "foobar" { + export = foo.bar; +>foo.bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +} + +declare module "foobarx" { + export = foo.bar.X; +>foo.bar.X : Symbol(foo.bar.X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +>foo.bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>foo : Symbol(foo, Decl(declarations.d.ts, 0, 0)) +>bar : Symbol(foo.bar, Decl(declarations.d.ts, 2, 22)) +>X : Symbol(foo.bar.X, Decl(declarations.d.ts, 2, 27), Decl(declarations.d.ts, 4, 16)) +} + +=== tests/cases/compiler/a.ts === +namespace A { +>A : Symbol(A, Decl(a.ts, 0, 0)) + + export class B { constructor(b: number) {} } +>B : Symbol(B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>b : Symbol(b, Decl(a.ts, 1, 33)) + + export namespace B { export const b: number = 0; } +>B : Symbol(B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>b : Symbol(b, Decl(a.ts, 2, 37)) +} +export = A.B; +>A.B : Symbol(A.B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) +>A : Symbol(A, Decl(a.ts, 0, 0)) +>B : Symbol(A.B, Decl(a.ts, 0, 13), Decl(a.ts, 1, 48)) + +=== tests/cases/compiler/b.ts === +export = "foo".length; +>"foo".length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + diff --git a/tests/baselines/reference/exportEqualsProperty.types b/tests/baselines/reference/exportEqualsProperty.types new file mode 100644 index 00000000000..a92af53b12b --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty.types @@ -0,0 +1,92 @@ +=== tests/cases/compiler/index.ts === +/// +import { X } from "foobar"; +>X : number + +import X2 = require("foobarx"); +>X2 : number + +const x: X = X; +>x : number +>X : number +>X : number + +const x2: X2 = X2; +>x2 : number +>X2 : number +>X2 : number + +import B = require("./a"); +>B : typeof B + +const b: B = new B(B.b); +>b : B +>B : B +>new B(B.b) : B +>B : typeof B +>B.b : number +>B : typeof B +>b : number + +import fooLength = require("./b"); +>fooLength : number + +fooLength + 1; +>fooLength + 1 : number +>fooLength : number +>1 : number + +=== tests/cases/compiler/declarations.d.ts === +// This test is just like exportDefaultProperty, but with `export =`. + +declare namespace foo.bar { +>foo : typeof foo +>bar : typeof bar + + export type X = number; +>X : number + + export const X: number; +>X : number +} + +declare module "foobar" { + export = foo.bar; +>foo.bar : typeof foo.bar +>foo : typeof foo +>bar : typeof foo.bar +} + +declare module "foobarx" { + export = foo.bar.X; +>foo.bar.X : number +>foo.bar : typeof foo.bar +>foo : typeof foo +>bar : typeof foo.bar +>X : number +} + +=== tests/cases/compiler/a.ts === +namespace A { +>A : typeof A + + export class B { constructor(b: number) {} } +>B : B +>b : number + + export namespace B { export const b: number = 0; } +>B : typeof B +>b : number +>0 : number +} +export = A.B; +>A.B : typeof A.B +>A : typeof A +>B : typeof A.B + +=== tests/cases/compiler/b.ts === +export = "foo".length; +>"foo".length : number +>"foo" : string +>length : number + diff --git a/tests/baselines/reference/exportEqualsProperty2.js b/tests/baselines/reference/exportEqualsProperty2.js new file mode 100644 index 00000000000..b5d91431722 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty2.js @@ -0,0 +1,32 @@ +//// [tests/cases/compiler/exportEqualsProperty2.ts] //// + +//// [a.ts] +// This test is just like exportDefaultProperty2, but with `export =`. + +class C { + static B: number; +} +namespace C { + export interface B { c: number } +} + +export = C.B; + +//// [b.ts] +import B = require("./a"); +const x: B = { c: B }; + + +//// [a.js] +// This test is just like exportDefaultProperty2, but with `export =`. +"use strict"; +var C = (function () { + function C() { + } + return C; +}()); +module.exports = C.B; +//// [b.js] +"use strict"; +var B = require("./a"); +var x = { c: B }; diff --git a/tests/baselines/reference/exportEqualsProperty2.symbols b/tests/baselines/reference/exportEqualsProperty2.symbols new file mode 100644 index 00000000000..df7eda76661 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty2.symbols @@ -0,0 +1,32 @@ +=== tests/cases/compiler/b.ts === +import B = require("./a"); +>B : Symbol(B, Decl(b.ts, 0, 0)) + +const x: B = { c: B }; +>x : Symbol(x, Decl(b.ts, 1, 5)) +>B : Symbol(B, Decl(b.ts, 0, 0)) +>c : Symbol(c, Decl(b.ts, 1, 14)) +>B : Symbol(B, Decl(b.ts, 0, 0)) + +=== tests/cases/compiler/a.ts === +// This test is just like exportDefaultProperty2, but with `export =`. + +class C { +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) + + static B: number; +>B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +} +namespace C { +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) + + export interface B { c: number } +>B : Symbol(B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>c : Symbol(B.c, Decl(a.ts, 6, 24)) +} + +export = C.B; +>C.B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) +>C : Symbol(C, Decl(a.ts, 0, 0), Decl(a.ts, 4, 1)) +>B : Symbol(C.B, Decl(a.ts, 2, 9), Decl(a.ts, 5, 13)) + diff --git a/tests/baselines/reference/exportEqualsProperty2.types b/tests/baselines/reference/exportEqualsProperty2.types new file mode 100644 index 00000000000..4594cbfd015 --- /dev/null +++ b/tests/baselines/reference/exportEqualsProperty2.types @@ -0,0 +1,33 @@ +=== tests/cases/compiler/b.ts === +import B = require("./a"); +>B : number + +const x: B = { c: B }; +>x : B +>B : B +>{ c: B } : { c: number; } +>c : number +>B : number + +=== tests/cases/compiler/a.ts === +// This test is just like exportDefaultProperty2, but with `export =`. + +class C { +>C : C + + static B: number; +>B : number +} +namespace C { +>C : typeof C + + export interface B { c: number } +>B : B +>c : number +} + +export = C.B; +>C.B : number +>C : typeof C +>B : number + diff --git a/tests/baselines/reference/genericCallWithTupleType.errors.txt b/tests/baselines/reference/genericCallWithTupleType.errors.txt index 0194dc61311..617c4f7159b 100644 --- a/tests/baselines/reference/genericCallWithTupleType.errors.txt +++ b/tests/baselines/reference/genericCallWithTupleType.errors.txt @@ -6,11 +6,9 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(14,1): error TS2322: Type '{ a: string; }' is not assignable to type 'string | number'. Type '{ a: string; }' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(22,1): error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. - Types of property '0' are incompatible. - Type 'number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(23,1): error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. - Types of property '0' are incompatible. - Type '{}' is not assignable to type 'string'. + Type '{}' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTupleType.ts(24,1): error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. Property '1' is missing in type '[{}]'. @@ -49,13 +47,11 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithTup i1.tuple1 = [5, "foo"]; ~~~~~~~~~ !!! error TS2322: Type '[number, string]' is not assignable to type '[string, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. i1.tuple1 = [{}, {}]; ~~~~~~~~~ !!! error TS2322: Type '[{}, {}]' is not assignable to type '[string, number]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type '{}' is not assignable to type 'string'. i2.tuple1 = [{}]; ~~~~~~~~~ !!! error TS2322: Type '[{}]' is not assignable to type '[{}, {}]'. diff --git a/tests/baselines/reference/getterControlFlowStrictNull.errors.txt b/tests/baselines/reference/getterControlFlowStrictNull.errors.txt new file mode 100644 index 00000000000..1c4f02d6a75 --- /dev/null +++ b/tests/baselines/reference/getterControlFlowStrictNull.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/getterControlFlowStrictNull.ts(2,9): error TS2366: Function lacks ending return statement and return type does not include 'undefined'. +tests/cases/compiler/getterControlFlowStrictNull.ts(11,14): error TS2366: Function lacks ending return statement and return type does not include 'undefined'. + + +==== tests/cases/compiler/getterControlFlowStrictNull.ts (2 errors) ==== + class A { + a(): string | null { + ~~~~~~~~~~~~~ +!!! error TS2366: Function lacks ending return statement and return type does not include 'undefined'. + if (Math.random() > 0.5) { + return ''; + } + + // it does error here as expected + } + } + class B { + get a(): string | null { + ~~~~~~~~~~~~~ +!!! error TS2366: Function lacks ending return statement and return type does not include 'undefined'. + if (Math.random() > 0.5) { + return ''; + } + + // it should error here because it returns undefined + } + } \ No newline at end of file diff --git a/tests/baselines/reference/getterControlFlowStrictNull.js b/tests/baselines/reference/getterControlFlowStrictNull.js new file mode 100644 index 00000000000..c3f7e410d0a --- /dev/null +++ b/tests/baselines/reference/getterControlFlowStrictNull.js @@ -0,0 +1,47 @@ +//// [getterControlFlowStrictNull.ts] +class A { + a(): string | null { + if (Math.random() > 0.5) { + return ''; + } + + // it does error here as expected + } +} +class B { + get a(): string | null { + if (Math.random() > 0.5) { + return ''; + } + + // it should error here because it returns undefined + } +} + +//// [getterControlFlowStrictNull.js] +var A = (function () { + function A() { + } + A.prototype.a = function () { + if (Math.random() > 0.5) { + return ''; + } + // it does error here as expected + }; + return A; +}()); +var B = (function () { + function B() { + } + Object.defineProperty(B.prototype, "a", { + get: function () { + if (Math.random() > 0.5) { + return ''; + } + // it should error here because it returns undefined + }, + enumerable: true, + configurable: true + }); + return B; +}()); diff --git a/tests/baselines/reference/implicitConstParameters.errors.txt b/tests/baselines/reference/implicitConstParameters.errors.txt new file mode 100644 index 00000000000..95ff60d71f8 --- /dev/null +++ b/tests/baselines/reference/implicitConstParameters.errors.txt @@ -0,0 +1,65 @@ +tests/cases/compiler/implicitConstParameters.ts(39,27): error TS2532: Object is possibly 'undefined'. +tests/cases/compiler/implicitConstParameters.ts(45,27): error TS2532: Object is possibly 'undefined'. + + +==== tests/cases/compiler/implicitConstParameters.ts (2 errors) ==== + + function doSomething(cb: () => void) { + cb(); + } + + function fn(x: number | string) { + if (typeof x === 'number') { + doSomething(() => x.toFixed()); + } + } + + function f1(x: string | undefined) { + if (!x) { + return; + } + doSomething(() => x.length); + } + + function f2(x: string | undefined) { + if (x) { + doSomething(() => { + doSomething(() => x.length); + }); + } + } + + function f3(x: string | undefined) { + inner(); + function inner() { + if (x) { + doSomething(() => x.length); + } + } + } + + function f4(x: string | undefined) { + x = "abc"; // causes x to be considered non-const + if (x) { + doSomething(() => x.length); + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + } + + function f5(x: string | undefined) { + if (x) { + doSomething(() => x.length); + ~ +!!! error TS2532: Object is possibly 'undefined'. + } + x = "abc"; // causes x to be considered non-const + } + + + function f6(x: string | undefined) { + const y = x || ""; + if (x) { + doSomething(() => y.length); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/implicitConstParameters.js b/tests/baselines/reference/implicitConstParameters.js new file mode 100644 index 00000000000..a5faf5b1253 --- /dev/null +++ b/tests/baselines/reference/implicitConstParameters.js @@ -0,0 +1,106 @@ +//// [implicitConstParameters.ts] + +function doSomething(cb: () => void) { + cb(); +} + +function fn(x: number | string) { + if (typeof x === 'number') { + doSomething(() => x.toFixed()); + } +} + +function f1(x: string | undefined) { + if (!x) { + return; + } + doSomething(() => x.length); +} + +function f2(x: string | undefined) { + if (x) { + doSomething(() => { + doSomething(() => x.length); + }); + } +} + +function f3(x: string | undefined) { + inner(); + function inner() { + if (x) { + doSomething(() => x.length); + } + } +} + +function f4(x: string | undefined) { + x = "abc"; // causes x to be considered non-const + if (x) { + doSomething(() => x.length); + } +} + +function f5(x: string | undefined) { + if (x) { + doSomething(() => x.length); + } + x = "abc"; // causes x to be considered non-const +} + + +function f6(x: string | undefined) { + const y = x || ""; + if (x) { + doSomething(() => y.length); + } +} + +//// [implicitConstParameters.js] +function doSomething(cb) { + cb(); +} +function fn(x) { + if (typeof x === 'number') { + doSomething(function () { return x.toFixed(); }); + } +} +function f1(x) { + if (!x) { + return; + } + doSomething(function () { return x.length; }); +} +function f2(x) { + if (x) { + doSomething(function () { + doSomething(function () { return x.length; }); + }); + } +} +function f3(x) { + inner(); + function inner() { + if (x) { + doSomething(function () { return x.length; }); + } + } +} +function f4(x) { + x = "abc"; // causes x to be considered non-const + if (x) { + doSomething(function () { return x.length; }); + } +} +function f5(x) { + if (x) { + doSomething(function () { return x.length; }); + } + x = "abc"; // causes x to be considered non-const +} +function f6(x) { + var y = x || ""; + if (x) { + doSomething(function () { return y.length; }); + } +} diff --git a/tests/baselines/reference/indexWithUndefinedAndNull.js b/tests/baselines/reference/indexWithUndefinedAndNull.js new file mode 100644 index 00000000000..f885323efae --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNull.js @@ -0,0 +1,22 @@ +//// [indexWithUndefinedAndNull.ts] +interface N { + [n: number]: string; +} +interface S { + [s: string]: number; +} +let n: N; +let s: S; +let str: string = n[undefined]; +str = n[null]; +let num: number = s[undefined]; +num = s[null]; + + +//// [indexWithUndefinedAndNull.js] +var n; +var s; +var str = n[undefined]; +str = n[null]; +var num = s[undefined]; +num = s[null]; diff --git a/tests/baselines/reference/indexWithUndefinedAndNull.symbols b/tests/baselines/reference/indexWithUndefinedAndNull.symbols new file mode 100644 index 00000000000..15e8bbdbf41 --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNull.symbols @@ -0,0 +1,39 @@ +=== tests/cases/compiler/indexWithUndefinedAndNull.ts === +interface N { +>N : Symbol(N, Decl(indexWithUndefinedAndNull.ts, 0, 0)) + + [n: number]: string; +>n : Symbol(n, Decl(indexWithUndefinedAndNull.ts, 1, 5)) +} +interface S { +>S : Symbol(S, Decl(indexWithUndefinedAndNull.ts, 2, 1)) + + [s: string]: number; +>s : Symbol(s, Decl(indexWithUndefinedAndNull.ts, 4, 5)) +} +let n: N; +>n : Symbol(n, Decl(indexWithUndefinedAndNull.ts, 6, 3)) +>N : Symbol(N, Decl(indexWithUndefinedAndNull.ts, 0, 0)) + +let s: S; +>s : Symbol(s, Decl(indexWithUndefinedAndNull.ts, 7, 3)) +>S : Symbol(S, Decl(indexWithUndefinedAndNull.ts, 2, 1)) + +let str: string = n[undefined]; +>str : Symbol(str, Decl(indexWithUndefinedAndNull.ts, 8, 3)) +>n : Symbol(n, Decl(indexWithUndefinedAndNull.ts, 6, 3)) +>undefined : Symbol(undefined) + +str = n[null]; +>str : Symbol(str, Decl(indexWithUndefinedAndNull.ts, 8, 3)) +>n : Symbol(n, Decl(indexWithUndefinedAndNull.ts, 6, 3)) + +let num: number = s[undefined]; +>num : Symbol(num, Decl(indexWithUndefinedAndNull.ts, 10, 3)) +>s : Symbol(s, Decl(indexWithUndefinedAndNull.ts, 7, 3)) +>undefined : Symbol(undefined) + +num = s[null]; +>num : Symbol(num, Decl(indexWithUndefinedAndNull.ts, 10, 3)) +>s : Symbol(s, Decl(indexWithUndefinedAndNull.ts, 7, 3)) + diff --git a/tests/baselines/reference/indexWithUndefinedAndNull.types b/tests/baselines/reference/indexWithUndefinedAndNull.types new file mode 100644 index 00000000000..07b6050503a --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNull.types @@ -0,0 +1,47 @@ +=== tests/cases/compiler/indexWithUndefinedAndNull.ts === +interface N { +>N : N + + [n: number]: string; +>n : number +} +interface S { +>S : S + + [s: string]: number; +>s : string +} +let n: N; +>n : N +>N : N + +let s: S; +>s : S +>S : S + +let str: string = n[undefined]; +>str : string +>n[undefined] : string +>n : N +>undefined : undefined + +str = n[null]; +>str = n[null] : string +>str : string +>n[null] : string +>n : N +>null : null + +let num: number = s[undefined]; +>num : number +>s[undefined] : number +>s : S +>undefined : undefined + +num = s[null]; +>num = s[null] : number +>num : number +>s[null] : number +>s : S +>null : null + diff --git a/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt new file mode 100644 index 00000000000..a1fce75c54e --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.errors.txt @@ -0,0 +1,40 @@ +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,19): error TS2454: Variable 'n' is used before being assigned. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(9,19): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,7): error TS2454: Variable 'n' is used before being assigned. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(10,7): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,19): error TS2454: Variable 's' is used before being assigned. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(11,19): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error TS2454: Variable 's' is used before being assigned. +tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts(12,7): error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + + +==== tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts (8 errors) ==== + interface N { + [n: number]: string; + } + interface S { + [s: string]: number; + } + let n: N; + let s: S; + let str: string = n[undefined]; + ~ +!!! error TS2454: Variable 'n' is used before being assigned. + ~~~~~~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + str = n[null]; + ~ +!!! error TS2454: Variable 'n' is used before being assigned. + ~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + let num: number = s[undefined]; + ~ +!!! error TS2454: Variable 's' is used before being assigned. + ~~~~~~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + num = s[null]; + ~ +!!! error TS2454: Variable 's' is used before being assigned. + ~~~~~~~ +!!! error TS2342: An index expression argument must be of type 'string', 'number', 'symbol', or 'any'. + \ No newline at end of file diff --git a/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.js b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.js new file mode 100644 index 00000000000..9300b7c0549 --- /dev/null +++ b/tests/baselines/reference/indexWithUndefinedAndNullStrictNullChecks.js @@ -0,0 +1,22 @@ +//// [indexWithUndefinedAndNullStrictNullChecks.ts] +interface N { + [n: number]: string; +} +interface S { + [s: string]: number; +} +let n: N; +let s: S; +let str: string = n[undefined]; +str = n[null]; +let num: number = s[undefined]; +num = s[null]; + + +//// [indexWithUndefinedAndNullStrictNullChecks.js] +var n; +var s; +var str = n[undefined]; +str = n[null]; +var num = s[undefined]; +num = s[null]; diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js new file mode 100644 index 00000000000..97be2137722 --- /dev/null +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.js @@ -0,0 +1,172 @@ +//// [instanceofWithStructurallyIdenticalTypes.ts] +// Repro from #7271 + +class C1 { item: string } +class C2 { item: string[] } +class C3 { item: string } + +function foo1(x: C1 | C2 | C3): string { + if (x instanceof C1) { + return x.item; + } + else if (x instanceof C2) { + return x.item[0]; + } + else if (x instanceof C3) { + return x.item; + } + return "error"; +} + +function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } +function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } +function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } + +function foo2(x: C1 | C2 | C3): string { + if (isC1(x)) { + return x.item; + } + else if (isC2(x)) { + return x.item[0]; + } + else if (isC3(x)) { + return x.item; + } + return "error"; +} + +// More tests + +class A { a: string } +class A1 extends A { } +class A2 { a: string } +class B extends A { b: string } + +function goo(x: A) { + if (x instanceof A) { + x; // A + } + else { + x; // never + } + if (x instanceof A1) { + x; // A1 + } + else { + x; // A + } + if (x instanceof A2) { + x; // A2 + } + else { + x; // A + } + if (x instanceof B) { + x; // B + } + else { + x; // A + } +} + + +//// [instanceofWithStructurallyIdenticalTypes.js] +// Repro from #7271 +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var C1 = (function () { + function C1() { + } + return C1; +}()); +var C2 = (function () { + function C2() { + } + return C2; +}()); +var C3 = (function () { + function C3() { + } + return C3; +}()); +function foo1(x) { + if (x instanceof C1) { + return x.item; + } + else if (x instanceof C2) { + return x.item[0]; + } + else if (x instanceof C3) { + return x.item; + } + return "error"; +} +function isC1(c) { return c instanceof C1; } +function isC2(c) { return c instanceof C2; } +function isC3(c) { return c instanceof C3; } +function foo2(x) { + if (isC1(x)) { + return x.item; + } + else if (isC2(x)) { + return x.item[0]; + } + else if (isC3(x)) { + return x.item; + } + return "error"; +} +// More tests +var A = (function () { + function A() { + } + return A; +}()); +var A1 = (function (_super) { + __extends(A1, _super); + function A1() { + _super.apply(this, arguments); + } + return A1; +}(A)); +var A2 = (function () { + function A2() { + } + return A2; +}()); +var B = (function (_super) { + __extends(B, _super); + function B() { + _super.apply(this, arguments); + } + return B; +}(A)); +function goo(x) { + if (x instanceof A) { + x; // A + } + else { + x; // never + } + if (x instanceof A1) { + x; // A1 + } + else { + x; // A + } + if (x instanceof A2) { + x; // A2 + } + else { + x; // A + } + if (x instanceof B) { + x; // B + } + else { + x; // A + } +} diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.symbols b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.symbols new file mode 100644 index 00000000000..f2eb40eea47 --- /dev/null +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.symbols @@ -0,0 +1,192 @@ +=== tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts === +// Repro from #7271 + +class C1 { item: string } +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) + +class C2 { item: string[] } +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) + +class C3 { item: string } +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) + +function foo1(x: C1 | C2 | C3): string { +>foo1 : Symbol(foo1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 25)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) + + if (x instanceof C1) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) + + return x.item; +>x.item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) + } + else if (x instanceof C2) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) + + return x.item[0]; +>x.item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) + } + else if (x instanceof C3) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) + + return x.item; +>x.item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 6, 14)) +>item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) + } + return "error"; +} + +function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } +>isC1 : Symbol(isC1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 17, 1)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) + +function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } +>isC2 : Symbol(isC2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 66)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 14)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 14)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) + +function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } +>isC3 : Symbol(isC3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 66)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 21, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 21, 14)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) +>c : Symbol(c, Decl(instanceofWithStructurallyIdenticalTypes.ts, 21, 14)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) + +function foo2(x: C1 | C2 | C3): string { +>foo2 : Symbol(foo2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 21, 66)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) +>C1 : Symbol(C1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 0, 0)) +>C2 : Symbol(C2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 25)) +>C3 : Symbol(C3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 27)) + + if (isC1(x)) { +>isC1 : Symbol(isC1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 17, 1)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) + + return x.item; +>x.item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) +>item : Symbol(C1.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 2, 10)) + } + else if (isC2(x)) { +>isC2 : Symbol(isC2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 19, 66)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) + + return x.item[0]; +>x.item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) +>item : Symbol(C2.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 3, 10)) + } + else if (isC3(x)) { +>isC3 : Symbol(isC3, Decl(instanceofWithStructurallyIdenticalTypes.ts, 20, 66)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) + + return x.item; +>x.item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 23, 14)) +>item : Symbol(C3.item, Decl(instanceofWithStructurallyIdenticalTypes.ts, 4, 10)) + } + return "error"; +} + +// More tests + +class A { a: string } +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) +>a : Symbol(A.a, Decl(instanceofWithStructurallyIdenticalTypes.ts, 38, 9)) + +class A1 extends A { } +>A1 : Symbol(A1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 38, 21)) +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) + +class A2 { a: string } +>A2 : Symbol(A2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 39, 22)) +>a : Symbol(A2.a, Decl(instanceofWithStructurallyIdenticalTypes.ts, 40, 10)) + +class B extends A { b: string } +>B : Symbol(B, Decl(instanceofWithStructurallyIdenticalTypes.ts, 40, 22)) +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) +>b : Symbol(B.b, Decl(instanceofWithStructurallyIdenticalTypes.ts, 41, 19)) + +function goo(x: A) { +>goo : Symbol(goo, Decl(instanceofWithStructurallyIdenticalTypes.ts, 41, 31)) +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) + + if (x instanceof A) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>A : Symbol(A, Decl(instanceofWithStructurallyIdenticalTypes.ts, 34, 1)) + + x; // A +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + else { + x; // never +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + if (x instanceof A1) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>A1 : Symbol(A1, Decl(instanceofWithStructurallyIdenticalTypes.ts, 38, 21)) + + x; // A1 +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + else { + x; // A +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + if (x instanceof A2) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>A2 : Symbol(A2, Decl(instanceofWithStructurallyIdenticalTypes.ts, 39, 22)) + + x; // A2 +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + else { + x; // A +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + if (x instanceof B) { +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) +>B : Symbol(B, Decl(instanceofWithStructurallyIdenticalTypes.ts, 40, 22)) + + x; // B +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } + else { + x; // A +>x : Symbol(x, Decl(instanceofWithStructurallyIdenticalTypes.ts, 43, 13)) + } +} + diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types new file mode 100644 index 00000000000..d98a6025796 --- /dev/null +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types @@ -0,0 +1,211 @@ +=== tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts === +// Repro from #7271 + +class C1 { item: string } +>C1 : C1 +>item : string + +class C2 { item: string[] } +>C2 : C2 +>item : string[] + +class C3 { item: string } +>C3 : C3 +>item : string + +function foo1(x: C1 | C2 | C3): string { +>foo1 : (x: C1 | C2 | C3) => string +>x : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 + + if (x instanceof C1) { +>x instanceof C1 : boolean +>x : C1 | C2 | C3 +>C1 : typeof C1 + + return x.item; +>x.item : string +>x : C1 +>item : string + } + else if (x instanceof C2) { +>x instanceof C2 : boolean +>x : C2 | C3 +>C2 : typeof C2 + + return x.item[0]; +>x.item[0] : string +>x.item : string[] +>x : C2 +>item : string[] +>0 : number + } + else if (x instanceof C3) { +>x instanceof C3 : boolean +>x : C3 +>C3 : typeof C3 + + return x.item; +>x.item : string +>x : C3 +>item : string + } + return "error"; +>"error" : string +} + +function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } +>isC1 : (c: C1 | C2 | C3) => c is C1 +>c : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 +>c : any +>C1 : C1 +>c instanceof C1 : boolean +>c : C1 | C2 | C3 +>C1 : typeof C1 + +function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } +>isC2 : (c: C1 | C2 | C3) => c is C2 +>c : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 +>c : any +>C2 : C2 +>c instanceof C2 : boolean +>c : C1 | C2 | C3 +>C2 : typeof C2 + +function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } +>isC3 : (c: C1 | C2 | C3) => c is C3 +>c : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 +>c : any +>C3 : C3 +>c instanceof C3 : boolean +>c : C1 | C2 | C3 +>C3 : typeof C3 + +function foo2(x: C1 | C2 | C3): string { +>foo2 : (x: C1 | C2 | C3) => string +>x : C1 | C2 | C3 +>C1 : C1 +>C2 : C2 +>C3 : C3 + + if (isC1(x)) { +>isC1(x) : boolean +>isC1 : (c: C1 | C2 | C3) => c is C1 +>x : C1 | C2 | C3 + + return x.item; +>x.item : string +>x : C1 +>item : string + } + else if (isC2(x)) { +>isC2(x) : boolean +>isC2 : (c: C1 | C2 | C3) => c is C2 +>x : C2 | C3 + + return x.item[0]; +>x.item[0] : string +>x.item : string[] +>x : C2 +>item : string[] +>0 : number + } + else if (isC3(x)) { +>isC3(x) : boolean +>isC3 : (c: C1 | C2 | C3) => c is C3 +>x : C3 + + return x.item; +>x.item : string +>x : C3 +>item : string + } + return "error"; +>"error" : string +} + +// More tests + +class A { a: string } +>A : A +>a : string + +class A1 extends A { } +>A1 : A1 +>A : A + +class A2 { a: string } +>A2 : A2 +>a : string + +class B extends A { b: string } +>B : B +>A : A +>b : string + +function goo(x: A) { +>goo : (x: A) => void +>x : A +>A : A + + if (x instanceof A) { +>x instanceof A : boolean +>x : A +>A : typeof A + + x; // A +>x : A + } + else { + x; // never +>x : never + } + if (x instanceof A1) { +>x instanceof A1 : boolean +>x : A +>A1 : typeof A1 + + x; // A1 +>x : A1 + } + else { + x; // A +>x : A + } + if (x instanceof A2) { +>x instanceof A2 : boolean +>x : A +>A2 : typeof A2 + + x; // A2 +>x : A2 + } + else { + x; // A +>x : A + } + if (x instanceof B) { +>x instanceof B : boolean +>x : A +>B : typeof B + + x; // B +>x : B + } + else { + x; // A +>x : A + } +} + diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js new file mode 100644 index 00000000000..176df15985f --- /dev/null +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.js @@ -0,0 +1,20 @@ +//// [instantiateContextuallyTypedGenericThis.ts] +interface JQuery { + each( + collection: T[], callback: (this: T, dit: T) => T + ): T[]; +} + +let $: JQuery; +let lines: string[]; +$.each(lines, function(dit) { + return dit.charAt(0) + this.charAt(1); +}); + + +//// [instantiateContextuallyTypedGenericThis.js] +var $; +var lines; +$.each(lines, function (dit) { + return dit.charAt(0) + this.charAt(1); +}); diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols new file mode 100644 index 00000000000..1db5b30dd0b --- /dev/null +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.symbols @@ -0,0 +1,46 @@ +=== tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts === +interface JQuery { +>JQuery : Symbol(JQuery, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 0)) + + each( +>each : Symbol(JQuery.each, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 18)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) + + collection: T[], callback: (this: T, dit: T) => T +>collection : Symbol(collection, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 12)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) +>callback : Symbol(callback, Decl(instantiateContextuallyTypedGenericThis.ts, 2, 24)) +>this : Symbol(this, Decl(instantiateContextuallyTypedGenericThis.ts, 2, 36)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) +>dit : Symbol(dit, Decl(instantiateContextuallyTypedGenericThis.ts, 2, 44)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) + + ): T[]; +>T : Symbol(T, Decl(instantiateContextuallyTypedGenericThis.ts, 1, 9)) +} + +let $: JQuery; +>$ : Symbol($, Decl(instantiateContextuallyTypedGenericThis.ts, 6, 3)) +>JQuery : Symbol(JQuery, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 0)) + +let lines: string[]; +>lines : Symbol(lines, Decl(instantiateContextuallyTypedGenericThis.ts, 7, 3)) + +$.each(lines, function(dit) { +>$.each : Symbol(JQuery.each, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 18)) +>$ : Symbol($, Decl(instantiateContextuallyTypedGenericThis.ts, 6, 3)) +>each : Symbol(JQuery.each, Decl(instantiateContextuallyTypedGenericThis.ts, 0, 18)) +>lines : Symbol(lines, Decl(instantiateContextuallyTypedGenericThis.ts, 7, 3)) +>dit : Symbol(dit, Decl(instantiateContextuallyTypedGenericThis.ts, 8, 23)) + + return dit.charAt(0) + this.charAt(1); +>dit.charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) +>dit : Symbol(dit, Decl(instantiateContextuallyTypedGenericThis.ts, 8, 23)) +>charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) +>this.charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) +>this : Symbol(this, Decl(instantiateContextuallyTypedGenericThis.ts, 2, 36)) +>charAt : Symbol(String.charAt, Decl(lib.d.ts, --, --)) + +}); + diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types new file mode 100644 index 00000000000..5cdce6b99fe --- /dev/null +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types @@ -0,0 +1,53 @@ +=== tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts === +interface JQuery { +>JQuery : JQuery + + each( +>each : (collection: T[], callback: (this: T, dit: T) => T) => T[] +>T : T + + collection: T[], callback: (this: T, dit: T) => T +>collection : T[] +>T : T +>callback : (this: T, dit: T) => T +>this : T +>T : T +>dit : T +>T : T +>T : T + + ): T[]; +>T : T +} + +let $: JQuery; +>$ : JQuery +>JQuery : JQuery + +let lines: string[]; +>lines : string[] + +$.each(lines, function(dit) { +>$.each(lines, function(dit) { return dit.charAt(0) + this.charAt(1);}) : string[] +>$.each : (collection: T[], callback: (this: T, dit: T) => T) => T[] +>$ : JQuery +>each : (collection: T[], callback: (this: T, dit: T) => T) => T[] +>lines : string[] +>function(dit) { return dit.charAt(0) + this.charAt(1);} : (this: string, dit: string) => string +>dit : string + + return dit.charAt(0) + this.charAt(1); +>dit.charAt(0) + this.charAt(1) : string +>dit.charAt(0) : string +>dit.charAt : (pos: number) => string +>dit : string +>charAt : (pos: number) => string +>0 : number +>this.charAt(1) : string +>this.charAt : (pos: number) => string +>this : string +>charAt : (pos: number) => string +>1 : number + +}); + diff --git a/tests/baselines/reference/iterableArrayPattern29.errors.txt b/tests/baselines/reference/iterableArrayPattern29.errors.txt index b34d0317d57..29e5d0d2a3f 100644 --- a/tests/baselines/reference/iterableArrayPattern29.errors.txt +++ b/tests/baselines/reference/iterableArrayPattern29.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(1,33): error TS2501: A rest element cannot contain a binding pattern. tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(2,21): error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'. - Types of property '1' are incompatible. - Type 'boolean' is not assignable to type 'number'. + Type 'boolean' is not assignable to type 'number'. ==== tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts (2 errors) ==== @@ -11,5 +10,4 @@ tests/cases/conformance/es6/destructuring/iterableArrayPattern29.ts(2,21): error takeFirstTwoEntries(...new Map([["", true], ["hello", true]])); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[string, boolean]' is not assignable to parameter of type '[string, number]'. -!!! error TS2345: Types of property '1' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2345: Type 'boolean' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/jsdocLiteral.js b/tests/baselines/reference/jsdocLiteral.js new file mode 100644 index 00000000000..1a017160302 --- /dev/null +++ b/tests/baselines/reference/jsdocLiteral.js @@ -0,0 +1,24 @@ +//// [in.js] +/** + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 + */ +function f(p1, p2, p3, p4, p5) { + return p1 + p2 + p3 + p4 + p5 + '.'; +} + + +//// [out.js] +/** + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 + */ +function f(p1, p2, p3, p4, p5) { + return p1 + p2 + p3 + p4 + p5 + '.'; +} diff --git a/tests/baselines/reference/jsdocLiteral.symbols b/tests/baselines/reference/jsdocLiteral.symbols new file mode 100644 index 00000000000..9f01fe782aa --- /dev/null +++ b/tests/baselines/reference/jsdocLiteral.symbols @@ -0,0 +1,24 @@ +=== tests/cases/conformance/jsdoc/in.js === +/** + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 + */ +function f(p1, p2, p3, p4, p5) { +>f : Symbol(f, Decl(in.js, 0, 0)) +>p1 : Symbol(p1, Decl(in.js, 7, 11)) +>p2 : Symbol(p2, Decl(in.js, 7, 14)) +>p3 : Symbol(p3, Decl(in.js, 7, 18)) +>p4 : Symbol(p4, Decl(in.js, 7, 22)) +>p5 : Symbol(p5, Decl(in.js, 7, 26)) + + return p1 + p2 + p3 + p4 + p5 + '.'; +>p1 : Symbol(p1, Decl(in.js, 7, 11)) +>p2 : Symbol(p2, Decl(in.js, 7, 14)) +>p3 : Symbol(p3, Decl(in.js, 7, 18)) +>p4 : Symbol(p4, Decl(in.js, 7, 22)) +>p5 : Symbol(p5, Decl(in.js, 7, 26)) +} + diff --git a/tests/baselines/reference/jsdocLiteral.types b/tests/baselines/reference/jsdocLiteral.types new file mode 100644 index 00000000000..b6c9e522ac3 --- /dev/null +++ b/tests/baselines/reference/jsdocLiteral.types @@ -0,0 +1,30 @@ +=== tests/cases/conformance/jsdoc/in.js === +/** + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 + */ +function f(p1, p2, p3, p4, p5) { +>f : (p1: "literal", p2: "literal", p3: "literal" | "other", p4: number | "literal", p5: true | 12 | "str") => string +>p1 : "literal" +>p2 : "literal" +>p3 : "literal" | "other" +>p4 : number | "literal" +>p5 : true | 12 | "str" + + return p1 + p2 + p3 + p4 + p5 + '.'; +>p1 + p2 + p3 + p4 + p5 + '.' : string +>p1 + p2 + p3 + p4 + p5 : string +>p1 + p2 + p3 + p4 : string +>p1 + p2 + p3 : string +>p1 + p2 : string +>p1 : "literal" +>p2 : "literal" +>p3 : "literal" | "other" +>p4 : number | "literal" +>p5 : true | 12 | "str" +>'.' : string +} + diff --git a/tests/baselines/reference/jsdocNeverUndefinedNull.js b/tests/baselines/reference/jsdocNeverUndefinedNull.js new file mode 100644 index 00000000000..e57b7091a3b --- /dev/null +++ b/tests/baselines/reference/jsdocNeverUndefinedNull.js @@ -0,0 +1,20 @@ +//// [in.js] +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +} + + +//// [out.js] +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +} diff --git a/tests/baselines/reference/jsdocNeverUndefinedNull.symbols b/tests/baselines/reference/jsdocNeverUndefinedNull.symbols new file mode 100644 index 00000000000..a57636ed344 --- /dev/null +++ b/tests/baselines/reference/jsdocNeverUndefinedNull.symbols @@ -0,0 +1,14 @@ +=== tests/cases/conformance/jsdoc/in.js === +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +>f : Symbol(f, Decl(in.js, 0, 0)) +>p1 : Symbol(p1, Decl(in.js, 6, 11)) +>p2 : Symbol(p2, Decl(in.js, 6, 14)) +>p3 : Symbol(p3, Decl(in.js, 6, 18)) +} + diff --git a/tests/baselines/reference/jsdocNeverUndefinedNull.types b/tests/baselines/reference/jsdocNeverUndefinedNull.types new file mode 100644 index 00000000000..fe57cc298e2 --- /dev/null +++ b/tests/baselines/reference/jsdocNeverUndefinedNull.types @@ -0,0 +1,14 @@ +=== tests/cases/conformance/jsdoc/in.js === +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +>f : (p1: never, p2: undefined, p3: null) => void +>p1 : never +>p2 : undefined +>p3 : null +} + diff --git a/tests/baselines/reference/library-reference-5.errors.txt b/tests/baselines/reference/library-reference-5.errors.txt index a3729bc3a99..c23b49c61de 100644 --- a/tests/baselines/reference/library-reference-5.errors.txt +++ b/tests/baselines/reference/library-reference-5.errors.txt @@ -1,4 +1,4 @@ -/node_modules/bar/index.d.ts(1,1): message TS4090: Conflicting library definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict. +/node_modules/bar/index.d.ts(1,1): message TS4090: Conflicting definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Consider installing a specific version of this library to resolve the conflict. ==== /src/root.ts (0 errors) ==== @@ -18,7 +18,7 @@ ==== /node_modules/bar/index.d.ts (1 errors) ==== /// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! message TS4090: Conflicting library definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Copy the correct file to the 'typings' folder to resolve this conflict. +!!! message TS4090: Conflicting definitions for 'alpha' found at '/node_modules/bar/node_modules/alpha/index.d.ts' and '/node_modules/foo/node_modules/alpha/index.d.ts'. Consider installing a specific version of this library to resolve the conflict. declare var bar: any; ==== /node_modules/bar/node_modules/alpha/index.d.ts (0 errors) ==== diff --git a/tests/baselines/reference/missingFunctionImplementation2.errors.txt b/tests/baselines/reference/missingFunctionImplementation2.errors.txt index a695482e1fb..86d8baba6f7 100644 --- a/tests/baselines/reference/missingFunctionImplementation2.errors.txt +++ b/tests/baselines/reference/missingFunctionImplementation2.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/missingFunctionImplementation2_b.ts(1,17): error TS2391: Fu ==== tests/cases/compiler/missingFunctionImplementation2_a.ts (1 errors) ==== export {}; - declare module "./missingFunctionImplementation2_b.ts" { + declare module "./missingFunctionImplementation2_b" { export function f(a, b): void; ~ !!! error TS2384: Overload signatures must all be ambient or non-ambient. diff --git a/tests/baselines/reference/missingFunctionImplementation2.js b/tests/baselines/reference/missingFunctionImplementation2.js index 104b6dd9443..7b3456015c8 100644 --- a/tests/baselines/reference/missingFunctionImplementation2.js +++ b/tests/baselines/reference/missingFunctionImplementation2.js @@ -2,7 +2,7 @@ //// [missingFunctionImplementation2_a.ts] export {}; -declare module "./missingFunctionImplementation2_b.ts" { +declare module "./missingFunctionImplementation2_b" { export function f(a, b): void; } diff --git a/tests/baselines/reference/moduleResolutionNoTs.errors.txt b/tests/baselines/reference/moduleResolutionNoTs.errors.txt new file mode 100644 index 00000000000..c0543307311 --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoTs.errors.txt @@ -0,0 +1,31 @@ +tests/cases/compiler/user.ts(1,15): error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x' instead. +tests/cases/compiler/user.ts(2,15): error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './y' instead. +tests/cases/compiler/user.ts(3,15): error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './z' instead. + + +==== tests/cases/compiler/x.ts (0 errors) ==== + export default 0; + +==== tests/cases/compiler/y.tsx (0 errors) ==== + export default 0; + +==== tests/cases/compiler/z.d.ts (0 errors) ==== + declare const x: number; + export default x; + +==== tests/cases/compiler/user.ts (3 errors) ==== + import x from "./x.ts"; + ~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x' instead. + import y from "./y.tsx"; + ~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.tsx' extension. Consider importing './y' instead. + import z from "./z.d.ts"; + ~~~~~~~~~~ +!!! error TS2691: An import path cannot end with a '.d.ts' extension. Consider importing './z' instead. + + // Making sure the suggested fixes are valid: + import x2 from "./x"; + import y2 from "./y"; + import z2 from "./z"; + \ No newline at end of file diff --git a/tests/baselines/reference/moduleResolutionNoTs.js b/tests/baselines/reference/moduleResolutionNoTs.js new file mode 100644 index 00000000000..9ff33d688ea --- /dev/null +++ b/tests/baselines/reference/moduleResolutionNoTs.js @@ -0,0 +1,33 @@ +//// [tests/cases/compiler/moduleResolutionNoTs.ts] //// + +//// [x.ts] +export default 0; + +//// [y.tsx] +export default 0; + +//// [z.d.ts] +declare const x: number; +export default x; + +//// [user.ts] +import x from "./x.ts"; +import y from "./y.tsx"; +import z from "./z.d.ts"; + +// Making sure the suggested fixes are valid: +import x2 from "./x"; +import y2 from "./y"; +import z2 from "./z"; + + +//// [x.js] +"use strict"; +exports.__esModule = true; +exports["default"] = 0; +//// [y.js] +"use strict"; +exports.__esModule = true; +exports["default"] = 0; +//// [user.js] +"use strict"; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.js b/tests/baselines/reference/moduleResolutionWithExtensions.js index df12a3531bc..16d176872ca 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.js +++ b/tests/baselines/reference/moduleResolutionWithExtensions.js @@ -8,10 +8,6 @@ export default 0; //// [b.ts] import a from './a'; -// Matching extension -//// [c.ts] -import a from './a.ts'; - // '.js' extension: stripped and replaced with '.ts' //// [d.ts] import a from './a.js'; @@ -36,9 +32,6 @@ exports["default"] = 0; // No extension: '.ts' added //// [b.js] "use strict"; -// Matching extension -//// [c.js] -"use strict"; // '.js' extension: stripped and replaced with '.ts' //// [d.js] "use strict"; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.symbols b/tests/baselines/reference/moduleResolutionWithExtensions.symbols index e9934946a64..eaaa1d51cc0 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.symbols +++ b/tests/baselines/reference/moduleResolutionWithExtensions.symbols @@ -7,11 +7,6 @@ No type information for this code.=== /src/b.ts === import a from './a'; >a : Symbol(a, Decl(b.ts, 0, 6)) -// Matching extension -=== /src/c.ts === -import a from './a.ts'; ->a : Symbol(a, Decl(c.ts, 0, 6)) - // '.js' extension: stripped and replaced with '.ts' === /src/d.ts === import a from './a.js'; diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.trace.json b/tests/baselines/reference/moduleResolutionWithExtensions.trace.json index 7dc9e8c104b..5060006ac56 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.trace.json +++ b/tests/baselines/reference/moduleResolutionWithExtensions.trace.json @@ -5,12 +5,6 @@ "File '/src/a.ts' exist - use it as a name resolution result.", "Resolving real path for '/src/a.ts', result '/src/a.ts'", "======== Module name './a' was successfully resolved to '/src/a.ts'. ========", - "======== Resolving module './a.ts' from '/src/c.ts'. ========", - "Module resolution kind is not specified, using 'NodeJs'.", - "Loading module as file / folder, candidate module location '/src/a.ts'.", - "File '/src/a.ts' exist - use it as a name resolution result.", - "Resolving real path for '/src/a.ts', result '/src/a.ts'", - "======== Module name './a.ts' was successfully resolved to '/src/a.ts'. ========", "======== Resolving module './a.js' from '/src/d.ts'. ========", "Module resolution kind is not specified, using 'NodeJs'.", "Loading module as file / folder, candidate module location '/src/a.js'.", diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.types b/tests/baselines/reference/moduleResolutionWithExtensions.types index fbc0091ee3b..f59eda1a81e 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.types +++ b/tests/baselines/reference/moduleResolutionWithExtensions.types @@ -7,11 +7,6 @@ No type information for this code.=== /src/b.ts === import a from './a'; >a : number -// Matching extension -=== /src/c.ts === -import a from './a.ts'; ->a : number - // '.js' extension: stripped and replaced with '.ts' === /src/d.ts === import a from './a.js'; diff --git a/tests/baselines/reference/multipleDeclarations.js b/tests/baselines/reference/multipleDeclarations.js index 5f5ac29e909..7fb7e0bca02 100644 --- a/tests/baselines/reference/multipleDeclarations.js +++ b/tests/baselines/reference/multipleDeclarations.js @@ -1,11 +1,38 @@ //// [input.js] - function C() { this.m = null; } C.prototype.m = function() { this.nothing(); -}; +} +class X { + constructor() { + this.m = this.m.bind(this); + this.mistake = 'frankly, complete nonsense'; + } + m() { + } + mistake() { + } +} +let x = new X(); +X.prototype.mistake = false; +x.m(); +x.mistake; +class Y { + mistake() { + } + m() { + } + constructor() { + this.m = this.m.bind(this); + this.mistake = 'even more nonsense'; + } +} +Y.prototype.mistake = true; +let y = new Y(); +y.m(); +y.mistake(); //// [output.js] @@ -15,3 +42,33 @@ function C() { C.prototype.m = function () { this.nothing(); }; +var X = (function () { + function X() { + this.m = this.m.bind(this); + this.mistake = 'frankly, complete nonsense'; + } + X.prototype.m = function () { + }; + X.prototype.mistake = function () { + }; + return X; +}()); +var x = new X(); +X.prototype.mistake = false; +x.m(); +x.mistake; +var Y = (function () { + function Y() { + this.m = this.m.bind(this); + this.mistake = 'even more nonsense'; + } + Y.prototype.mistake = function () { + }; + Y.prototype.m = function () { + }; + return Y; +}()); +Y.prototype.mistake = true; +var y = new Y(); +y.m(); +y.mistake(); diff --git a/tests/baselines/reference/multipleDeclarations.symbols b/tests/baselines/reference/multipleDeclarations.symbols index a256943dd50..9e49c2fc00c 100644 --- a/tests/baselines/reference/multipleDeclarations.symbols +++ b/tests/baselines/reference/multipleDeclarations.symbols @@ -1,19 +1,106 @@ === tests/cases/conformance/salsa/input.js === - function C() { >C : Symbol(C, Decl(input.js, 0, 0)) this.m = null; ->m : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1)) +>m : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1)) } C.prototype.m = function() { ->C.prototype : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1)) +>C.prototype : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1)) >C : Symbol(C, Decl(input.js, 0, 0)) >prototype : Symbol(Function.prototype, Decl(lib.d.ts, --, --)) ->m : Symbol(C.m, Decl(input.js, 1, 14), Decl(input.js, 3, 1)) +>m : Symbol(C.m, Decl(input.js, 0, 14), Decl(input.js, 2, 1)) this.nothing(); >this : Symbol(C, Decl(input.js, 0, 0)) +} +class X { +>X : Symbol(X, Decl(input.js, 5, 1)) -}; + constructor() { + this.m = this.m.bind(this); +>this.m : Symbol(X.m, Decl(input.js, 10, 5)) +>this : Symbol(X, Decl(input.js, 5, 1)) +>m : Symbol(X.m, Decl(input.js, 7, 19)) +>this.m.bind : Symbol(Function.bind, Decl(lib.d.ts, --, --)) +>this.m : Symbol(X.m, Decl(input.js, 10, 5)) +>this : Symbol(X, Decl(input.js, 5, 1)) +>m : Symbol(X.m, Decl(input.js, 10, 5)) +>bind : Symbol(Function.bind, Decl(lib.d.ts, --, --)) +>this : Symbol(X, Decl(input.js, 5, 1)) + + this.mistake = 'frankly, complete nonsense'; +>this.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>this : Symbol(X, Decl(input.js, 5, 1)) +>mistake : Symbol(X.mistake, Decl(input.js, 8, 35)) + } + m() { +>m : Symbol(X.m, Decl(input.js, 10, 5)) + } + mistake() { +>mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) + } +} +let x = new X(); +>x : Symbol(x, Decl(input.js, 16, 3)) +>X : Symbol(X, Decl(input.js, 5, 1)) + +X.prototype.mistake = false; +>X.prototype.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>X : Symbol(X, Decl(input.js, 5, 1)) +>prototype : Symbol(X.prototype) + +x.m(); +>x.m : Symbol(X.m, Decl(input.js, 10, 5)) +>x : Symbol(x, Decl(input.js, 16, 3)) +>m : Symbol(X.m, Decl(input.js, 10, 5)) + +x.mistake; +>x.mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) +>x : Symbol(x, Decl(input.js, 16, 3)) +>mistake : Symbol(X.mistake, Decl(input.js, 12, 5)) + +class Y { +>Y : Symbol(Y, Decl(input.js, 19, 10)) + + mistake() { +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) + } + m() { +>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) + } + constructor() { + this.m = this.m.bind(this); +>this.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>this : Symbol(Y, Decl(input.js, 19, 10)) +>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>this.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>this : Symbol(Y, Decl(input.js, 19, 10)) +>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>this : Symbol(Y, Decl(input.js, 19, 10)) + + this.mistake = 'even more nonsense'; +>this.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>this : Symbol(Y, Decl(input.js, 19, 10)) +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) + } +} +Y.prototype.mistake = true; +>Y.prototype.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>Y : Symbol(Y, Decl(input.js, 19, 10)) +>prototype : Symbol(Y.prototype) + +let y = new Y(); +>y : Symbol(y, Decl(input.js, 31, 3)) +>Y : Symbol(Y, Decl(input.js, 19, 10)) + +y.m(); +>y.m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) +>y : Symbol(y, Decl(input.js, 31, 3)) +>m : Symbol(Y.m, Decl(input.js, 22, 5), Decl(input.js, 25, 19)) + +y.mistake(); +>y.mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) +>y : Symbol(y, Decl(input.js, 31, 3)) +>mistake : Symbol(Y.mistake, Decl(input.js, 20, 9), Decl(input.js, 26, 35)) diff --git a/tests/baselines/reference/multipleDeclarations.types b/tests/baselines/reference/multipleDeclarations.types index 7c0a3de70c9..900d03195d4 100644 --- a/tests/baselines/reference/multipleDeclarations.types +++ b/tests/baselines/reference/multipleDeclarations.types @@ -1,5 +1,4 @@ === tests/cases/conformance/salsa/input.js === - function C() { >C : () => void @@ -24,6 +23,117 @@ C.prototype.m = function() { >this.nothing : any >this : { m: () => void; } >nothing : any +} +class X { +>X : X -}; + constructor() { + this.m = this.m.bind(this); +>this.m = this.m.bind(this) : any +>this.m : () => void +>this : this +>m : () => void +>this.m.bind(this) : any +>this.m.bind : (this: Function, thisArg: any, ...argArray: any[]) => any +>this.m : () => void +>this : this +>m : () => void +>bind : (this: Function, thisArg: any, ...argArray: any[]) => any +>this : this + + this.mistake = 'frankly, complete nonsense'; +>this.mistake = 'frankly, complete nonsense' : string +>this.mistake : () => void +>this : this +>mistake : () => void +>'frankly, complete nonsense' : string + } + m() { +>m : () => void + } + mistake() { +>mistake : () => void + } +} +let x = new X(); +>x : X +>new X() : X +>X : typeof X + +X.prototype.mistake = false; +>X.prototype.mistake = false : boolean +>X.prototype.mistake : () => void +>X.prototype : X +>X : typeof X +>prototype : X +>mistake : () => void +>false : boolean + +x.m(); +>x.m() : void +>x.m : () => void +>x : X +>m : () => void + +x.mistake; +>x.mistake : () => void +>x : X +>mistake : () => void + +class Y { +>Y : Y + + mistake() { +>mistake : any + } + m() { +>m : any + } + constructor() { + this.m = this.m.bind(this); +>this.m = this.m.bind(this) : any +>this.m : any +>this : this +>m : any +>this.m.bind(this) : any +>this.m.bind : any +>this.m : any +>this : this +>m : any +>bind : any +>this : this + + this.mistake = 'even more nonsense'; +>this.mistake = 'even more nonsense' : string +>this.mistake : any +>this : this +>mistake : any +>'even more nonsense' : string + } +} +Y.prototype.mistake = true; +>Y.prototype.mistake = true : boolean +>Y.prototype.mistake : any +>Y.prototype : Y +>Y : typeof Y +>prototype : Y +>mistake : any +>true : boolean + +let y = new Y(); +>y : Y +>new Y() : Y +>Y : typeof Y + +y.m(); +>y.m() : any +>y.m : any +>y : Y +>m : any + +y.mistake(); +>y.mistake() : any +>y.mistake : any +>y : Y +>mistake : any diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt new file mode 100644 index 00000000000..e435b98050d --- /dev/null +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(11,17): error TS2339: Property 'doPanic' does not exist on type '{ type: "foo"; dontPanic(): any; }'. +tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts(16,17): error TS2339: Property 'massage' does not exist on type 'Error'. + + +==== tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts (2 errors) ==== + declare function isFooError(x: any): x is { type: 'foo'; dontPanic(); }; + + function tryCatch() { + try { + // do stuff... + } + catch (err) { // err is implicitly 'any' and cannot be annotated + + if (isFooError(err)) { + err.dontPanic(); // OK + err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' + ~~~~~~~ +!!! error TS2339: Property 'doPanic' does not exist on type '{ type: "foo"; dontPanic(): any; }'. + } + + else if (err instanceof Error) { + err.message; + err.massage; // ERROR: Property 'massage' does not exist on type 'Error' + ~~~~~~~ +!!! error TS2339: Property 'massage' does not exist on type 'Error'. + } + + else { + throw err; + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/narrowExceptionVariableInCatchClause.js b/tests/baselines/reference/narrowExceptionVariableInCatchClause.js new file mode 100644 index 00000000000..5808ed76826 --- /dev/null +++ b/tests/baselines/reference/narrowExceptionVariableInCatchClause.js @@ -0,0 +1,44 @@ +//// [narrowExceptionVariableInCatchClause.ts] +declare function isFooError(x: any): x is { type: 'foo'; dontPanic(); }; + +function tryCatch() { + try { + // do stuff... + } + catch (err) { // err is implicitly 'any' and cannot be annotated + + if (isFooError(err)) { + err.dontPanic(); // OK + err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' + } + + else if (err instanceof Error) { + err.message; + err.massage; // ERROR: Property 'massage' does not exist on type 'Error' + } + + else { + throw err; + } + } +} + + +//// [narrowExceptionVariableInCatchClause.js] +function tryCatch() { + try { + } + catch (err) { + if (isFooError(err)) { + err.dontPanic(); // OK + err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' + } + else if (err instanceof Error) { + err.message; + err.massage; // ERROR: Property 'massage' does not exist on type 'Error' + } + else { + throw err; + } + } +} diff --git a/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt new file mode 100644 index 00000000000..3e152b0faf4 --- /dev/null +++ b/tests/baselines/reference/narrowFromAnyWithInstanceof.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(17,7): error TS2339: Property 'mesage' does not exist on type 'Error'. +tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts(22,7): error TS2339: Property 'getHuors' does not exist on type 'Date'. + + +==== tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts (2 errors) ==== + declare var x: any; + + if (x instanceof Function) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; + } + + if (x instanceof Object) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); + } + + if (x instanceof Error) { // 'any' is narrowed to types other than 'Function'/'Object' + x.message; + x.mesage; + ~~~~~~ +!!! error TS2339: Property 'mesage' does not exist on type 'Error'. + } + + if (x instanceof Date) { + x.getDate(); + x.getHuors(); + ~~~~~~~~ +!!! error TS2339: Property 'getHuors' does not exist on type 'Date'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/narrowFromAnyWithInstanceof.js b/tests/baselines/reference/narrowFromAnyWithInstanceof.js new file mode 100644 index 00000000000..4cf1ca174aa --- /dev/null +++ b/tests/baselines/reference/narrowFromAnyWithInstanceof.js @@ -0,0 +1,45 @@ +//// [narrowFromAnyWithInstanceof.ts] +declare var x: any; + +if (x instanceof Function) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} + +if (x instanceof Object) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); +} + +if (x instanceof Error) { // 'any' is narrowed to types other than 'Function'/'Object' + x.message; + x.mesage; +} + +if (x instanceof Date) { + x.getDate(); + x.getHuors(); +} + + +//// [narrowFromAnyWithInstanceof.js] +if (x instanceof Function) { + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} +if (x instanceof Object) { + x.method(); + x(); +} +if (x instanceof Error) { + x.message; + x.mesage; +} +if (x instanceof Date) { + x.getDate(); + x.getHuors(); +} diff --git a/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt new file mode 100644 index 00000000000..94f41becdad --- /dev/null +++ b/tests/baselines/reference/narrowFromAnyWithTypePredicate.errors.txt @@ -0,0 +1,50 @@ +tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(22,7): error TS2339: Property 'method' does not exist on type '{}'. +tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(23,5): error TS2349: Cannot invoke an expression whose type lacks a call signature. +tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(28,7): error TS2339: Property 'mesage' does not exist on type 'Error'. +tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts(33,7): error TS2339: Property 'getHuors' does not exist on type 'Date'. + + +==== tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts (4 errors) ==== + declare var x: any; + declare function isFunction(x): x is Function; + declare function isObject(x): x is Object; + declare function isAnything(x): x is {}; + declare function isError(x): x is Error; + declare function isDate(x): x is Date; + + + if (isFunction(x)) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; + } + + if (isObject(x)) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); + } + + if (isAnything(x)) { // 'any' is narrowed to types other than 'Function'/'Object' (including {}) + x.method(); + ~~~~~~ +!!! error TS2339: Property 'method' does not exist on type '{}'. + x(); + ~~~ +!!! error TS2349: Cannot invoke an expression whose type lacks a call signature. + } + + if (isError(x)) { + x.message; + x.mesage; + ~~~~~~ +!!! error TS2339: Property 'mesage' does not exist on type 'Error'. + } + + if (isDate(x)) { + x.getDate(); + x.getHuors(); + ~~~~~~~~ +!!! error TS2339: Property 'getHuors' does not exist on type 'Date'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/narrowFromAnyWithTypePredicate.js b/tests/baselines/reference/narrowFromAnyWithTypePredicate.js new file mode 100644 index 00000000000..958a3cfd70d --- /dev/null +++ b/tests/baselines/reference/narrowFromAnyWithTypePredicate.js @@ -0,0 +1,60 @@ +//// [narrowFromAnyWithTypePredicate.ts] +declare var x: any; +declare function isFunction(x): x is Function; +declare function isObject(x): x is Object; +declare function isAnything(x): x is {}; +declare function isError(x): x is Error; +declare function isDate(x): x is Date; + + +if (isFunction(x)) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} + +if (isObject(x)) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); +} + +if (isAnything(x)) { // 'any' is narrowed to types other than 'Function'/'Object' (including {}) + x.method(); + x(); +} + +if (isError(x)) { + x.message; + x.mesage; +} + +if (isDate(x)) { + x.getDate(); + x.getHuors(); +} + + +//// [narrowFromAnyWithTypePredicate.js] +if (isFunction(x)) { + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} +if (isObject(x)) { + x.method(); + x(); +} +if (isAnything(x)) { + x.method(); + x(); +} +if (isError(x)) { + x.message; + x.mesage; +} +if (isDate(x)) { + x.getDate(); + x.getHuors(); +} diff --git a/tests/baselines/reference/nativeToBoxedTypes.errors.txt b/tests/baselines/reference/nativeToBoxedTypes.errors.txt new file mode 100644 index 00000000000..03186a6d7e3 --- /dev/null +++ b/tests/baselines/reference/nativeToBoxedTypes.errors.txt @@ -0,0 +1,36 @@ +tests/cases/compiler/nativeToBoxedTypes.ts(3,1): error TS2322: Type 'Number' is not assignable to type 'number'. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. +tests/cases/compiler/nativeToBoxedTypes.ts(7,1): error TS2322: Type 'String' is not assignable to type 'string'. + 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. +tests/cases/compiler/nativeToBoxedTypes.ts(11,1): error TS2322: Type 'Boolean' is not assignable to type 'boolean'. + 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. +tests/cases/compiler/nativeToBoxedTypes.ts(14,10): error TS2304: Cannot find name 'Symbol'. + + +==== tests/cases/compiler/nativeToBoxedTypes.ts (4 errors) ==== + var N = new Number(); + var n = 100; + n = N; + ~ +!!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. + + var S = new String(); + var s = "foge"; + s = S; + ~ +!!! error TS2322: Type 'String' is not assignable to type 'string'. +!!! error TS2322: 'string' is a primitive, but 'String' is a wrapper object. Prefer using 'string' when possible. + + var B = new Boolean(); + var b = true; + b = B; + ~ +!!! error TS2322: Type 'Boolean' is not assignable to type 'boolean'. +!!! error TS2322: 'boolean' is a primitive, but 'Boolean' is a wrapper object. Prefer using 'boolean' when possible. + + var sym: symbol; + var Sym: Symbol; + ~~~~~~ +!!! error TS2304: Cannot find name 'Symbol'. + sym = Sym; \ No newline at end of file diff --git a/tests/baselines/reference/nativeToBoxedTypes.js b/tests/baselines/reference/nativeToBoxedTypes.js new file mode 100644 index 00000000000..db47c72fa10 --- /dev/null +++ b/tests/baselines/reference/nativeToBoxedTypes.js @@ -0,0 +1,30 @@ +//// [nativeToBoxedTypes.ts] +var N = new Number(); +var n = 100; +n = N; + +var S = new String(); +var s = "foge"; +s = S; + +var B = new Boolean(); +var b = true; +b = B; + +var sym: symbol; +var Sym: Symbol; +sym = Sym; + +//// [nativeToBoxedTypes.js] +var N = new Number(); +var n = 100; +n = N; +var S = new String(); +var s = "foge"; +s = S; +var B = new Boolean(); +var b = true; +b = B; +var sym; +var Sym; +sym = Sym; diff --git a/tests/baselines/reference/nestedLoopTypeGuards.js b/tests/baselines/reference/nestedLoopTypeGuards.js new file mode 100644 index 00000000000..ab1148413ef --- /dev/null +++ b/tests/baselines/reference/nestedLoopTypeGuards.js @@ -0,0 +1,63 @@ +//// [nestedLoopTypeGuards.ts] +// Repros from #10378 + +function f1() { + var a: boolean | number | string; + if (typeof a !== 'boolean') { + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { + for (var j = 0; j < 1; j++) {} + if (typeof a === 'string') { + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { + a.length; // Should not error here + } + } + } + } +} + +function f2() { + var a: string | number; + if (typeof a === 'string') { + while (1) { + while (1) {} + if (typeof a === 'string') { + while (1) { + a.length; // Should not error here + } + } + } + } +} + +//// [nestedLoopTypeGuards.js] +// Repros from #10378 +function f1() { + var a; + if (typeof a !== 'boolean') { + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { + for (var j = 0; j < 1; j++) { } + if (typeof a === 'string') { + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { + a.length; // Should not error here + } + } + } + } +} +function f2() { + var a; + if (typeof a === 'string') { + while (1) { + while (1) { } + if (typeof a === 'string') { + while (1) { + a.length; // Should not error here + } + } + } + } +} diff --git a/tests/baselines/reference/nestedLoopTypeGuards.symbols b/tests/baselines/reference/nestedLoopTypeGuards.symbols new file mode 100644 index 00000000000..74426576d5a --- /dev/null +++ b/tests/baselines/reference/nestedLoopTypeGuards.symbols @@ -0,0 +1,66 @@ +=== tests/cases/compiler/nestedLoopTypeGuards.ts === +// Repros from #10378 + +function f1() { +>f1 : Symbol(f1, Decl(nestedLoopTypeGuards.ts, 0, 0)) + + var a: boolean | number | string; +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 3, 7)) + + if (typeof a !== 'boolean') { +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 3, 7)) + + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { +>i : Symbol(i, Decl(nestedLoopTypeGuards.ts, 6, 16)) +>i : Symbol(i, Decl(nestedLoopTypeGuards.ts, 6, 16)) +>i : Symbol(i, Decl(nestedLoopTypeGuards.ts, 6, 16)) + + for (var j = 0; j < 1; j++) {} +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) + + if (typeof a === 'string') { +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 3, 7)) + + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) +>j : Symbol(j, Decl(nestedLoopTypeGuards.ts, 7, 20), Decl(nestedLoopTypeGuards.ts, 10, 24)) + + a.length; // Should not error here +>a.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 3, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } + } + } + } +} + +function f2() { +>f2 : Symbol(f2, Decl(nestedLoopTypeGuards.ts, 16, 1)) + + var a: string | number; +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 19, 7)) + + if (typeof a === 'string') { +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 19, 7)) + + while (1) { + while (1) {} + if (typeof a === 'string') { +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 19, 7)) + + while (1) { + a.length; // Should not error here +>a.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>a : Symbol(a, Decl(nestedLoopTypeGuards.ts, 19, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + } + } + } + } +} diff --git a/tests/baselines/reference/nestedLoopTypeGuards.types b/tests/baselines/reference/nestedLoopTypeGuards.types new file mode 100644 index 00000000000..9611fba2fbf --- /dev/null +++ b/tests/baselines/reference/nestedLoopTypeGuards.types @@ -0,0 +1,96 @@ +=== tests/cases/compiler/nestedLoopTypeGuards.ts === +// Repros from #10378 + +function f1() { +>f1 : () => void + + var a: boolean | number | string; +>a : string | number | boolean + + if (typeof a !== 'boolean') { +>typeof a !== 'boolean' : boolean +>typeof a : string +>a : string | number | boolean +>'boolean' : "boolean" + + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { +>i : number +>0 : number +>i < 1 : boolean +>i : number +>1 : number +>i++ : number +>i : number + + for (var j = 0; j < 1; j++) {} +>j : number +>0 : number +>j < 1 : boolean +>j : number +>1 : number +>j++ : number +>j : number + + if (typeof a === 'string') { +>typeof a === 'string' : boolean +>typeof a : string +>a : string | number +>'string' : "string" + + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { +>j : number +>0 : number +>j < 1 : boolean +>j : number +>1 : number +>j++ : number +>j : number + + a.length; // Should not error here +>a.length : number +>a : string +>length : number + } + } + } + } +} + +function f2() { +>f2 : () => void + + var a: string | number; +>a : string | number + + if (typeof a === 'string') { +>typeof a === 'string' : boolean +>typeof a : string +>a : string | number +>'string' : "string" + + while (1) { +>1 : number + + while (1) {} +>1 : number + + if (typeof a === 'string') { +>typeof a === 'string' : boolean +>typeof a : string +>a : string +>'string' : "string" + + while (1) { +>1 : number + + a.length; // Should not error here +>a.length : number +>a : string +>length : number + } + } + } + } +} diff --git a/tests/baselines/reference/noErrorTruncation.errors.txt b/tests/baselines/reference/noErrorTruncation.errors.txt new file mode 100644 index 00000000000..d27fad84e50 --- /dev/null +++ b/tests/baselines/reference/noErrorTruncation.errors.txt @@ -0,0 +1,22 @@ +tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type 'number' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. + + +==== tests/cases/compiler/noErrorTruncation.ts (1 errors) ==== + // @noErrorTruncation + + type SomeLongOptionA = { someLongOptionA: string } + type SomeLongOptionB = { someLongOptionB: string } + type SomeLongOptionC = { someLongOptionC: string } + type SomeLongOptionD = { someLongOptionD: string } + type SomeLongOptionE = { someLongOptionE: string } + type SomeLongOptionF = { someLongOptionF: string } + + const x: SomeLongOptionA + ~ +!!! error TS2322: Type 'number' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42; + \ No newline at end of file diff --git a/tests/baselines/reference/noErrorTruncation.js b/tests/baselines/reference/noErrorTruncation.js new file mode 100644 index 00000000000..70bbc6bd8dc --- /dev/null +++ b/tests/baselines/reference/noErrorTruncation.js @@ -0,0 +1,21 @@ +//// [noErrorTruncation.ts] +// @noErrorTruncation + +type SomeLongOptionA = { someLongOptionA: string } +type SomeLongOptionB = { someLongOptionB: string } +type SomeLongOptionC = { someLongOptionC: string } +type SomeLongOptionD = { someLongOptionD: string } +type SomeLongOptionE = { someLongOptionE: string } +type SomeLongOptionF = { someLongOptionF: string } + +const x: SomeLongOptionA + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42; + + +//// [noErrorTruncation.js] +// @noErrorTruncation +var x = 42; diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt index 10d6b05c622..f7e6475b971 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.errors.txt @@ -15,11 +15,14 @@ tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(5,18): error TS tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,5): error TS1182: A destructuring declaration must have an initializer. tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,13): error TS7008: Member 'b3' implicitly has an 'any' type. tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(7,25): error TS7008: Member 'b3' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,6): error TS7031: Binding element 'a1' implicitly has an 'any' type. -tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,26): error TS7031: Binding element 'b1' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,6): error TS7031: Binding element 'a4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,26): error TS7031: Binding element 'b4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,46): error TS7005: Variable 'c4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,62): error TS7005: Variable 'd4' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(11,6): error TS7031: Binding element 'a5' implicitly has an 'any' type. -==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts (19 errors) ==== +==== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts (22 errors) ==== var [a], {b}, c, d; // error ~~~ !!! error TS1182: A destructuring declaration must have an initializer. @@ -62,8 +65,16 @@ tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts(9,26): error TS ~~ !!! error TS7008: Member 'b3' implicitly has an 'any' type. - var [a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null; // error + var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error ~~ -!!! error TS7031: Binding element 'a1' implicitly has an 'any' type. +!!! error TS7031: Binding element 'a4' implicitly has an 'any' type. ~~ -!!! error TS7031: Binding element 'b1' implicitly has an 'any' type. \ No newline at end of file +!!! error TS7031: Binding element 'b4' implicitly has an 'any' type. + ~~ +!!! error TS7005: Variable 'c4' implicitly has an 'any' type. + ~~ +!!! error TS7005: Variable 'd4' implicitly has an 'any' type. + + var [a5 = undefined] = []; // error + ~~ +!!! error TS7031: Binding element 'a5' implicitly has an 'any' type. \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js index cbc15c01e9e..85358df666e 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration.js @@ -7,11 +7,14 @@ var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any; var {b3}: { b3 }, c3: { b3 }; // error in type instead -var [a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null; // error +var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error + +var [a5 = undefined] = []; // error //// [noImplicitAnyDestructuringVarDeclaration.js] var a = (void 0)[0], b = (void 0).b, c, d; // error var _a = (void 0)[0], a1 = _a === void 0 ? undefined : _a, _b = (void 0).b1, b1 = _b === void 0 ? null : _b, c1 = undefined, d1 = null; // error var a2 = (void 0)[0], b2 = (void 0).b2, c2, d2; var b3 = (void 0).b3, c3; // error in type instead -var a1 = [undefined][0], b1 = { b1: null }.b1, c1 = undefined, d1 = null; // error +var a4 = [undefined][0], b4 = { b4: null }.b4, c4 = undefined, d4 = null; // error +var _c = [][0], a5 = _c === void 0 ? undefined : _c; // error diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js new file mode 100644 index 00000000000..79ee0b8830f --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.js @@ -0,0 +1,25 @@ +//// [noImplicitAnyDestructuringVarDeclaration2.ts] +let [a, b, c] = [1, 2, 3]; // no error +let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error +let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error +let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error +let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error + +let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error +let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error +let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error +let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error +let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error + + +//// [noImplicitAnyDestructuringVarDeclaration2.js] +var _a = [1, 2, 3], a = _a[0], b = _a[1], c = _a[2]; // no error +var _b = [1, 2, 3], _c = _b[0], a1 = _c === void 0 ? 10 : _c, _d = _b[1], b1 = _d === void 0 ? 10 : _d, _e = _b[2], c1 = _e === void 0 ? 10 : _e; // no error +var _f = [1, 2, 3], _g = _f[0], a2 = _g === void 0 ? undefined : _g, _h = _f[1], b2 = _h === void 0 ? undefined : _h, _j = _f[2], c2 = _j === void 0 ? undefined : _j; // no error +var _k = [1, 2, 3], _l = _k[0], a3 = _l === void 0 ? undefined : _l, _m = _k[1], b3 = _m === void 0 ? null : _m, _o = _k[2], c3 = _o === void 0 ? undefined : _o; // no error +var a4 = [undefined][0], b4 = [null][0], c4 = undefined, d4 = null; // no error +var _p = { x: 1, y: 2, z: 3 }, x = _p.x, y = _p.y, z = _p.z; // no error +var _q = { x1: 1, y1: 2, z1: 3 }, _r = _q.x1, x1 = _r === void 0 ? 10 : _r, _s = _q.y1, y1 = _s === void 0 ? 10 : _s, _t = _q.z1, z1 = _t === void 0 ? 10 : _t; // no error +var _u = { x2: 1, y2: 2, z2: 3 }, _v = _u.x2, x2 = _v === void 0 ? undefined : _v, _w = _u.y2, y2 = _w === void 0 ? undefined : _w, _x = _u.z2, z2 = _x === void 0 ? undefined : _x; // no error +var _y = { x3: 1, y3: 2, z3: 3 }, _z = _y.x3, x3 = _z === void 0 ? undefined : _z, _0 = _y.y3, y3 = _0 === void 0 ? null : _0, _1 = _y.z3, z3 = _1 === void 0 ? undefined : _1; // no error +var x4 = { x4: undefined }.x4, y4 = { y4: null }.y4; // no error diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.symbols b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.symbols new file mode 100644 index 00000000000..ee7fe9f7edd --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.symbols @@ -0,0 +1,78 @@ +=== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts === +let [a, b, c] = [1, 2, 3]; // no error +>a : Symbol(a, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 5)) +>b : Symbol(b, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 7)) +>c : Symbol(c, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 0, 10)) + +let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error +>a1 : Symbol(a1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 5)) +>b1 : Symbol(b1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 13)) +>c1 : Symbol(c1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 1, 22)) + +let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error +>a2 : Symbol(a2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 5)) +>undefined : Symbol(undefined) +>b2 : Symbol(b2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 20)) +>undefined : Symbol(undefined) +>c2 : Symbol(c2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 2, 36)) +>undefined : Symbol(undefined) + +let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error +>a3 : Symbol(a3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 5)) +>undefined : Symbol(undefined) +>b3 : Symbol(b3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 25)) +>c3 : Symbol(c3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 3, 41)) +>undefined : Symbol(undefined) + +let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error +>a4 : Symbol(a4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 5)) +>undefined : Symbol(undefined) +>b4 : Symbol(b4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 30)) +>c4 : Symbol(c4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 48)) +>undefined : Symbol(undefined) +>d4 : Symbol(d4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 4, 69)) + +let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error +>x : Symbol(x, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 5)) +>y : Symbol(y, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 7)) +>z : Symbol(z, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 10)) +>x : Symbol(x, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 17)) +>y : Symbol(y, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 23)) +>z : Symbol(z, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 6, 29)) + +let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error +>x1 : Symbol(x1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 5)) +>y1 : Symbol(y1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 13)) +>z1 : Symbol(z1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 22)) +>x1 : Symbol(x1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 35)) +>y1 : Symbol(y1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 42)) +>z1 : Symbol(z1, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 7, 49)) + +let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error +>x2 : Symbol(x2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 5)) +>undefined : Symbol(undefined) +>y2 : Symbol(y2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 20)) +>undefined : Symbol(undefined) +>z2 : Symbol(z2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 36)) +>undefined : Symbol(undefined) +>x2 : Symbol(x2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 56)) +>y2 : Symbol(y2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 63)) +>z2 : Symbol(z2, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 8, 70)) + +let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error +>x3 : Symbol(x3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 5)) +>undefined : Symbol(undefined) +>y3 : Symbol(y3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 25)) +>z3 : Symbol(z3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 41)) +>undefined : Symbol(undefined) +>x3 : Symbol(x3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 66)) +>y3 : Symbol(y3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 73)) +>z3 : Symbol(z3, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 9, 80)) + +let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error +>x4 : Symbol(x4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 5)) +>x4 : Symbol(x4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 12)) +>undefined : Symbol(undefined) +>y4 : Symbol(y4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 36)) +>y4 : Symbol(y4, Decl(noImplicitAnyDestructuringVarDeclaration2.ts, 10, 43)) + diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types new file mode 100644 index 00000000000..ef0a3f2c25b --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types @@ -0,0 +1,137 @@ +=== tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts === +let [a, b, c] = [1, 2, 3]; // no error +>a : number +>b : number +>c : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error +>a1 : number +>10 : number +>b1 : number +>10 : number +>c1 : number +>10 : number +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error +>a2 : number +>undefined : undefined +>b2 : number +>undefined : undefined +>c2 : number +>undefined : undefined +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error +>a3 : number +>undefined : any +>undefined : undefined +>b3 : number +>null : any +>null : null +>c3 : number +>undefined : any +>undefined : undefined +>[1, 2, 3] : [number, number, number] +>1 : number +>2 : number +>3 : number + +let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error +>a4 : any +>[undefined] : [any] +>undefined : any +>undefined : undefined +>b4 : any +>[null] : [any] +>null : any +>null : null +>c4 : any +>undefined : any +>undefined : undefined +>d4 : any +>null : any +>null : null + +let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error +>x : number +>y : number +>z : number +>{ x: 1, y: 2, z: 3 } : { x: number; y: number; z: number; } +>x : number +>1 : number +>y : number +>2 : number +>z : number +>3 : number + +let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error +>x1 : number +>10 : number +>y1 : number +>10 : number +>z1 : number +>10 : number +>{ x1: 1, y1: 2, z1: 3 } : { x1?: number; y1?: number; z1?: number; } +>x1 : number +>1 : number +>y1 : number +>2 : number +>z1 : number +>3 : number + +let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error +>x2 : number +>undefined : undefined +>y2 : number +>undefined : undefined +>z2 : number +>undefined : undefined +>{ x2: 1, y2: 2, z2: 3 } : { x2?: number; y2?: number; z2?: number; } +>x2 : number +>1 : number +>y2 : number +>2 : number +>z2 : number +>3 : number + +let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error +>x3 : number +>undefined : any +>undefined : undefined +>y3 : number +>null : any +>null : null +>z3 : number +>undefined : any +>undefined : undefined +>{ x3: 1, y3: 2, z3: 3 } : { x3?: number; y3?: number; z3?: number; } +>x3 : number +>1 : number +>y3 : number +>2 : number +>z3 : number +>3 : number + +let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error +>x4 : any +>{ x4: undefined } : { x4: any; } +>x4 : any +>undefined : any +>undefined : undefined +>y4 : any +>{ y4: null } : { y4: any; } +>y4 : any +>null : any +>null : null + diff --git a/tests/baselines/reference/optionalBindingParameters1.errors.txt b/tests/baselines/reference/optionalBindingParameters1.errors.txt index 78fc1cbddf1..0780c626baf 100644 --- a/tests/baselines/reference/optionalBindingParameters1.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters1.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(2,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. - Types of property '0' are incompatible. - Type 'boolean' is not assignable to type 'string'. + Type 'boolean' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (2 errors) ==== @@ -17,5 +16,4 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): er foo([false, 0, ""]); ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt index 312603d2c2e..30ec4037c88 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt +++ b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt @@ -1,6 +1,5 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(9,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. - Types of property '0' are incompatible. - Type 'boolean' is not assignable to type 'string'. + Type 'boolean' is not assignable to type 'string'. ==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (1 errors) ==== @@ -15,5 +14,4 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1. foo([false, 0, ""]); ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. -!!! error TS2345: Types of property '0' are incompatible. -!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/primitiveMembers.errors.txt b/tests/baselines/reference/primitiveMembers.errors.txt index da8b75f9bc5..49ef8c4e3cf 100644 --- a/tests/baselines/reference/primitiveMembers.errors.txt +++ b/tests/baselines/reference/primitiveMembers.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/primitiveMembers.ts(5,3): error TS2339: Property 'toBAZ' does not exist on type 'number'. tests/cases/compiler/primitiveMembers.ts(11,1): error TS2322: Type 'Number' is not assignable to type 'number'. + 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. ==== tests/cases/compiler/primitiveMembers.ts (2 errors) ==== @@ -18,6 +19,7 @@ tests/cases/compiler/primitiveMembers.ts(11,1): error TS2322: Type 'Number' is n n = N; // should not work, as 'number' has a different brand ~ !!! error TS2322: Type 'Number' is not assignable to type 'number'. +!!! error TS2322: 'number' is a primitive, but 'Number' is a wrapper object. Prefer using 'number' when possible. N = n; // should work var o: Object = {} diff --git a/tests/baselines/reference/staticInstanceResolution5.errors.txt b/tests/baselines/reference/staticInstanceResolution5.errors.txt index da6f0fde143..f36851b2b97 100644 --- a/tests/baselines/reference/staticInstanceResolution5.errors.txt +++ b/tests/baselines/reference/staticInstanceResolution5.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/staticInstanceResolution5_1.ts(6,16): error TS2304: Cannot ==== tests/cases/compiler/staticInstanceResolution5_1.ts (3 errors) ==== - import WinJS = require('staticInstanceResolution5_0.ts'); + import WinJS = require('staticInstanceResolution5_0'); // these 3 should be errors var x = (w1: WinJS) => { }; diff --git a/tests/baselines/reference/staticInstanceResolution5.js b/tests/baselines/reference/staticInstanceResolution5.js index 0809d1af5f0..b3514e00aad 100644 --- a/tests/baselines/reference/staticInstanceResolution5.js +++ b/tests/baselines/reference/staticInstanceResolution5.js @@ -8,7 +8,7 @@ export class Promise { } //// [staticInstanceResolution5_1.ts] -import WinJS = require('staticInstanceResolution5_0.ts'); +import WinJS = require('staticInstanceResolution5_0'); // these 3 should be errors var x = (w1: WinJS) => { }; diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.types b/tests/baselines/reference/stringLiteralTypesAsTags01.types index e00fd18163d..e95a7364f93 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.types @@ -99,8 +99,8 @@ if (hasKind(x, "A")) { } else { let b = x; ->b : A ->x : A +>b : never +>x : never } if (!hasKind(x, "B")) { diff --git a/tests/baselines/reference/stringLiteralTypesAsTags02.types b/tests/baselines/reference/stringLiteralTypesAsTags02.types index fb1632559ea..c984b8a78f9 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags02.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags02.types @@ -93,8 +93,8 @@ if (hasKind(x, "A")) { } else { let b = x; ->b : A ->x : A +>b : never +>x : never } if (!hasKind(x, "B")) { diff --git a/tests/baselines/reference/stringLiteralTypesAsTags03.types b/tests/baselines/reference/stringLiteralTypesAsTags03.types index 05be633813b..fbe71ff07c1 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags03.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags03.types @@ -96,8 +96,8 @@ if (hasKind(x, "A")) { } else { let b = x; ->b : A ->x : A +>b : never +>x : never } if (!hasKind(x, "B")) { diff --git a/tests/baselines/reference/symbolType15.errors.txt b/tests/baselines/reference/symbolType15.errors.txt index eb63e5798d5..205a2a999d0 100644 --- a/tests/baselines/reference/symbolType15.errors.txt +++ b/tests/baselines/reference/symbolType15.errors.txt @@ -1,4 +1,5 @@ tests/cases/conformance/es6/Symbols/symbolType15.ts(5,1): error TS2322: Type 'Symbol' is not assignable to type 'symbol'. + 'symbol' is a primitive, but 'Symbol' is a wrapper object. Prefer using 'symbol' when possible. ==== tests/cases/conformance/es6/Symbols/symbolType15.ts (1 errors) ==== @@ -8,4 +9,5 @@ tests/cases/conformance/es6/Symbols/symbolType15.ts(5,1): error TS2322: Type 'Sy symObj = sym; sym = symObj; ~~~ -!!! error TS2322: Type 'Symbol' is not assignable to type 'symbol'. \ No newline at end of file +!!! error TS2322: Type 'Symbol' is not assignable to type 'symbol'. +!!! error TS2322: 'symbol' is a primitive, but 'Symbol' is a wrapper object. Prefer using 'symbol' when possible. \ No newline at end of file diff --git a/tests/baselines/reference/thisInTupleTypeParameterConstraints.js b/tests/baselines/reference/thisInTupleTypeParameterConstraints.js new file mode 100644 index 00000000000..c63fbf61991 --- /dev/null +++ b/tests/baselines/reference/thisInTupleTypeParameterConstraints.js @@ -0,0 +1,29 @@ +//// [thisInTupleTypeParameterConstraints.ts] +/// + +interface Boolean {} +interface IArguments {} +interface Function {} +interface Number {} +interface RegExp {} +interface Object {} +interface String {} + +interface Array { + // 4 methods will run out of memory if this-types are not instantiated + // correctly for tuple types that are type parameter constraints + map(arg: this): void; + reduceRight(arg: this): void; + reduce(arg: this): void; + reduce2(arg: this): void; +} + +declare function f number]>(a: T): void; +let x: [(x: number) => number]; +f(x); + + +//// [thisInTupleTypeParameterConstraints.js] +/// +var x; +f(x); diff --git a/tests/baselines/reference/thisInTupleTypeParameterConstraints.symbols b/tests/baselines/reference/thisInTupleTypeParameterConstraints.symbols new file mode 100644 index 00000000000..4d2bef22c55 --- /dev/null +++ b/tests/baselines/reference/thisInTupleTypeParameterConstraints.symbols @@ -0,0 +1,66 @@ +=== tests/cases/compiler/thisInTupleTypeParameterConstraints.ts === +/// + +interface Boolean {} +>Boolean : Symbol(Boolean, Decl(thisInTupleTypeParameterConstraints.ts, 0, 0)) + +interface IArguments {} +>IArguments : Symbol(IArguments, Decl(thisInTupleTypeParameterConstraints.ts, 2, 20)) + +interface Function {} +>Function : Symbol(Function, Decl(thisInTupleTypeParameterConstraints.ts, 3, 23)) + +interface Number {} +>Number : Symbol(Number, Decl(thisInTupleTypeParameterConstraints.ts, 4, 21)) + +interface RegExp {} +>RegExp : Symbol(RegExp, Decl(thisInTupleTypeParameterConstraints.ts, 5, 19)) + +interface Object {} +>Object : Symbol(Object, Decl(thisInTupleTypeParameterConstraints.ts, 6, 19)) + +interface String {} +>String : Symbol(String, Decl(thisInTupleTypeParameterConstraints.ts, 7, 19)) + +interface Array { +>Array : Symbol(Array, Decl(thisInTupleTypeParameterConstraints.ts, 8, 19)) +>T : Symbol(T, Decl(thisInTupleTypeParameterConstraints.ts, 10, 16)) + + // 4 methods will run out of memory if this-types are not instantiated + // correctly for tuple types that are type parameter constraints + map(arg: this): void; +>map : Symbol(Array.map, Decl(thisInTupleTypeParameterConstraints.ts, 10, 20)) +>U : Symbol(U, Decl(thisInTupleTypeParameterConstraints.ts, 13, 8)) +>arg : Symbol(arg, Decl(thisInTupleTypeParameterConstraints.ts, 13, 11)) + + reduceRight(arg: this): void; +>reduceRight : Symbol(Array.reduceRight, Decl(thisInTupleTypeParameterConstraints.ts, 13, 28)) +>U : Symbol(U, Decl(thisInTupleTypeParameterConstraints.ts, 14, 16)) +>arg : Symbol(arg, Decl(thisInTupleTypeParameterConstraints.ts, 14, 19)) + + reduce(arg: this): void; +>reduce : Symbol(Array.reduce, Decl(thisInTupleTypeParameterConstraints.ts, 14, 36)) +>U : Symbol(U, Decl(thisInTupleTypeParameterConstraints.ts, 15, 11)) +>arg : Symbol(arg, Decl(thisInTupleTypeParameterConstraints.ts, 15, 14)) + + reduce2(arg: this): void; +>reduce2 : Symbol(Array.reduce2, Decl(thisInTupleTypeParameterConstraints.ts, 15, 31)) +>U : Symbol(U, Decl(thisInTupleTypeParameterConstraints.ts, 16, 12)) +>arg : Symbol(arg, Decl(thisInTupleTypeParameterConstraints.ts, 16, 15)) +} + +declare function f number]>(a: T): void; +>f : Symbol(f, Decl(thisInTupleTypeParameterConstraints.ts, 17, 1)) +>T : Symbol(T, Decl(thisInTupleTypeParameterConstraints.ts, 19, 19)) +>x : Symbol(x, Decl(thisInTupleTypeParameterConstraints.ts, 19, 31)) +>a : Symbol(a, Decl(thisInTupleTypeParameterConstraints.ts, 19, 54)) +>T : Symbol(T, Decl(thisInTupleTypeParameterConstraints.ts, 19, 19)) + +let x: [(x: number) => number]; +>x : Symbol(x, Decl(thisInTupleTypeParameterConstraints.ts, 20, 3)) +>x : Symbol(x, Decl(thisInTupleTypeParameterConstraints.ts, 20, 9)) + +f(x); +>f : Symbol(f, Decl(thisInTupleTypeParameterConstraints.ts, 17, 1)) +>x : Symbol(x, Decl(thisInTupleTypeParameterConstraints.ts, 20, 3)) + diff --git a/tests/baselines/reference/thisInTupleTypeParameterConstraints.types b/tests/baselines/reference/thisInTupleTypeParameterConstraints.types new file mode 100644 index 00000000000..7daafe02bfc --- /dev/null +++ b/tests/baselines/reference/thisInTupleTypeParameterConstraints.types @@ -0,0 +1,67 @@ +=== tests/cases/compiler/thisInTupleTypeParameterConstraints.ts === +/// + +interface Boolean {} +>Boolean : Boolean + +interface IArguments {} +>IArguments : IArguments + +interface Function {} +>Function : Function + +interface Number {} +>Number : Number + +interface RegExp {} +>RegExp : RegExp + +interface Object {} +>Object : Object + +interface String {} +>String : String + +interface Array { +>Array : T[] +>T : T + + // 4 methods will run out of memory if this-types are not instantiated + // correctly for tuple types that are type parameter constraints + map(arg: this): void; +>map : (arg: this) => void +>U : U +>arg : this + + reduceRight(arg: this): void; +>reduceRight : (arg: this) => void +>U : U +>arg : this + + reduce(arg: this): void; +>reduce : (arg: this) => void +>U : U +>arg : this + + reduce2(arg: this): void; +>reduce2 : (arg: this) => void +>U : U +>arg : this +} + +declare function f number]>(a: T): void; +>f : number]>(a: T) => void +>T : T +>x : number +>a : T +>T : T + +let x: [(x: number) => number]; +>x : [(x: number) => number] +>x : number + +f(x); +>f(x) : void +>f : number]>(a: T) => void +>x : [(x: number) => number] + diff --git a/tests/baselines/reference/thisTypeInFunctions.symbols b/tests/baselines/reference/thisTypeInFunctions.symbols index 8a0be7427ed..ad16785f288 100644 --- a/tests/baselines/reference/thisTypeInFunctions.symbols +++ b/tests/baselines/reference/thisTypeInFunctions.symbols @@ -135,7 +135,7 @@ let impl: I = { return this.a; >this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 24, 28)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 24, 23)) >a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) }, @@ -144,7 +144,7 @@ let impl: I = { return this.a; >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 22)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) }, @@ -153,7 +153,7 @@ let impl: I = { return this.a; >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 17)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) }, @@ -173,7 +173,7 @@ impl.explicitStructural = function() { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) >explicitStructural : Symbol(I.explicitStructural, Decl(thisTypeInFunctions.ts, 23, 38)) >this.a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 24, 28)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 24, 23)) >a : Symbol(a, Decl(thisTypeInFunctions.ts, 24, 30)) impl.explicitInterface = function() { return this.a; }; @@ -181,7 +181,7 @@ impl.explicitInterface = function() { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) >explicitInterface : Symbol(I.explicitInterface, Decl(thisTypeInFunctions.ts, 24, 50)) >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 25, 22)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) impl.explicitStructural = () => 12; @@ -199,7 +199,7 @@ impl.explicitThis = function () { return this.a; }; >impl : Symbol(impl, Decl(thisTypeInFunctions.ts, 37, 3)) >explicitThis : Symbol(I.explicitThis, Decl(thisTypeInFunctions.ts, 25, 39)) >this.a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) ->this : Symbol(I, Decl(thisTypeInFunctions.ts, 19, 21)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 26, 17)) >a : Symbol(I.a, Decl(thisTypeInFunctions.ts, 20, 13)) // parameter checking @@ -536,7 +536,7 @@ c.explicitC = function(m) { return this.n + m }; >explicitC : Symbol(C.explicitC, Decl(thisTypeInFunctions.ts, 8, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 23)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 9, 14)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 126, 23)) @@ -546,7 +546,7 @@ c.explicitProperty = function(m) { return this.n + m }; >explicitProperty : Symbol(C.explicitProperty, Decl(thisTypeInFunctions.ts, 11, 5)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 30)) >this.n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) ->this : Symbol(, Decl(thisTypeInFunctions.ts, 12, 26)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 12, 21)) >n : Symbol(n, Decl(thisTypeInFunctions.ts, 12, 28)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 127, 30)) @@ -556,7 +556,7 @@ c.explicitThis = function(m) { return this.n + m }; >explicitThis : Symbol(C.explicitThis, Decl(thisTypeInFunctions.ts, 5, 14)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) >this.n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) ->this : Symbol(C, Decl(thisTypeInFunctions.ts, 3, 1)) +>this : Symbol(this, Decl(thisTypeInFunctions.ts, 6, 17)) >n : Symbol(C.n, Decl(thisTypeInFunctions.ts, 4, 9)) >m : Symbol(m, Decl(thisTypeInFunctions.ts, 128, 26)) diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 24c4fb87baf..863ecbce628 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -132,7 +132,7 @@ function implicitThis(n: number): number { let impl: I = { >impl : I >I : I ->{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; },} : { a: number; explicitVoid2: () => any; explicitVoid1(): number; explicitStructural(): number; explicitInterface(): number; explicitThis(): number; } +>{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; },} : { a: number; explicitVoid2: () => any; explicitVoid1(this: void): number; explicitStructural(this: { a: number; }): number; explicitInterface(this: I): number; explicitThis(this: I): number; } a: 12, >a : number @@ -146,11 +146,11 @@ let impl: I = { >a : any explicitVoid1() { return 12; }, ->explicitVoid1 : () => number +>explicitVoid1 : (this: void) => number >12 : number explicitStructural() { ->explicitStructural : () => number +>explicitStructural : (this: { a: number; }) => number return this.a; >this.a : number @@ -159,7 +159,7 @@ let impl: I = { }, explicitInterface() { ->explicitInterface : () => number +>explicitInterface : (this: I) => number return this.a; >this.a : number @@ -168,7 +168,7 @@ let impl: I = { }, explicitThis() { ->explicitThis : () => number +>explicitThis : (this: I) => number return this.a; >this.a : number @@ -178,11 +178,11 @@ let impl: I = { }, } impl.explicitVoid1 = function () { return 12; }; ->impl.explicitVoid1 = function () { return 12; } : () => number +>impl.explicitVoid1 = function () { return 12; } : (this: void) => number >impl.explicitVoid1 : (this: void) => number >impl : I >explicitVoid1 : (this: void) => number ->function () { return 12; } : () => number +>function () { return 12; } : (this: void) => number >12 : number impl.explicitVoid2 = () => 12; @@ -194,21 +194,21 @@ impl.explicitVoid2 = () => 12; >12 : number impl.explicitStructural = function() { return this.a; }; ->impl.explicitStructural = function() { return this.a; } : () => number +>impl.explicitStructural = function() { return this.a; } : (this: { a: number; }) => number >impl.explicitStructural : (this: { a: number; }) => number >impl : I >explicitStructural : (this: { a: number; }) => number ->function() { return this.a; } : () => number +>function() { return this.a; } : (this: { a: number; }) => number >this.a : number >this : { a: number; } >a : number impl.explicitInterface = function() { return this.a; }; ->impl.explicitInterface = function() { return this.a; } : () => number +>impl.explicitInterface = function() { return this.a; } : (this: I) => number >impl.explicitInterface : (this: I) => number >impl : I >explicitInterface : (this: I) => number ->function() { return this.a; } : () => number +>function() { return this.a; } : (this: I) => number >this.a : number >this : I >a : number @@ -230,11 +230,11 @@ impl.explicitInterface = () => 12; >12 : number impl.explicitThis = function () { return this.a; }; ->impl.explicitThis = function () { return this.a; } : () => number +>impl.explicitThis = function () { return this.a; } : (this: I) => number >impl.explicitThis : (this: I) => number >impl : I >explicitThis : (this: I) => number ->function () { return this.a; } : () => number +>function () { return this.a; } : (this: I) => number >this.a : number >this : I >a : number @@ -433,7 +433,7 @@ let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + th >this : { y: number; } >y : number >x : number ->x => x + this.y : (x: number) => any +>x => x + this.y : (this: { y: number; }, x: number) => any >x : number >x + this.y : any >x : number @@ -472,7 +472,7 @@ let specifiedLambda: (this: void, x: number) => number = x => x + 12; >specifiedLambda : (this: void, x: number) => number >this : void >x : number ->x => x + 12 : (x: number) => number +>x => x + 12 : (this: void, x: number) => number >x : number >x + 12 : number >x : number @@ -560,40 +560,40 @@ c.explicitProperty = reconstructed.explicitProperty; // lambdas are assignable to anything c.explicitC = m => m; ->c.explicitC = m => m : (m: number) => number +>c.explicitC = m => m : (this: C, m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->m => m : (m: number) => number +>m => m : (this: C, m: number) => number >m : number >m : number c.explicitThis = m => m; ->c.explicitThis = m => m : (m: number) => number +>c.explicitThis = m => m : (this: C, m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->m => m : (m: number) => number +>m => m : (this: C, m: number) => number >m : number >m : number c.explicitProperty = m => m; ->c.explicitProperty = m => m : (m: number) => number +>c.explicitProperty = m => m : (this: { n: number; }, m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->m => m : (m: number) => number +>m => m : (this: { n: number; }, m: number) => number >m : number >m : number // this inside lambdas refer to outer scope // the outer-scoped lambda at top-level is still just `any` c.explicitC = m => m + this.n; ->c.explicitC = m => m + this.n : (m: number) => any +>c.explicitC = m => m + this.n : (this: C, m: number) => any >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->m => m + this.n : (m: number) => any +>m => m + this.n : (this: C, m: number) => any >m : number >m + this.n : any >m : number @@ -602,11 +602,11 @@ c.explicitC = m => m + this.n; >n : any c.explicitThis = m => m + this.n; ->c.explicitThis = m => m + this.n : (m: number) => any +>c.explicitThis = m => m + this.n : (this: C, m: number) => any >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->m => m + this.n : (m: number) => any +>m => m + this.n : (this: C, m: number) => any >m : number >m + this.n : any >m : number @@ -615,11 +615,11 @@ c.explicitThis = m => m + this.n; >n : any c.explicitProperty = m => m + this.n; ->c.explicitProperty = m => m + this.n : (m: number) => any +>c.explicitProperty = m => m + this.n : (this: { n: number; }, m: number) => any >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->m => m + this.n : (m: number) => any +>m => m + this.n : (this: { n: number; }, m: number) => any >m : number >m + this.n : any >m : number @@ -652,11 +652,11 @@ c.explicitThis = function(this: C, m: number) { return this.n + m }; // this:any compatibility c.explicitC = function(m) { return this.n + m }; ->c.explicitC = function(m) { return this.n + m } : (m: number) => number +>c.explicitC = function(m) { return this.n + m } : (this: C, m: number) => number >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: C, m: number) => number >m : number >this.n + m : number >this.n : number @@ -665,11 +665,11 @@ c.explicitC = function(m) { return this.n + m }; >m : number c.explicitProperty = function(m) { return this.n + m }; ->c.explicitProperty = function(m) { return this.n + m } : (m: number) => number +>c.explicitProperty = function(m) { return this.n + m } : (this: { n: number; }, m: number) => number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: { n: number; }, m: number) => number >m : number >this.n + m : number >this.n : number @@ -678,11 +678,11 @@ c.explicitProperty = function(m) { return this.n + m }; >m : number c.explicitThis = function(m) { return this.n + m }; ->c.explicitThis = function(m) { return this.n + m } : (m: number) => number +>c.explicitThis = function(m) { return this.n + m } : (this: C, m: number) => number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->function(m) { return this.n + m } : (m: number) => number +>function(m) { return this.n + m } : (this: C, m: number) => number >m : number >this.n + m : number >this.n : number @@ -723,11 +723,11 @@ c.explicitC = function(this: B, m: number) { return this.n + m }; // this:void compatibility c.explicitVoid = n => n; ->c.explicitVoid = n => n : (n: number) => number +>c.explicitVoid = n => n : (this: void, n: number) => number >c.explicitVoid : (this: void, m: number) => number >c : C >explicitVoid : (this: void, m: number) => number ->n => n : (n: number) => number +>n => n : (this: void, n: number) => number >n : number >n : number diff --git a/tests/baselines/reference/thisTypeInFunctions2.symbols b/tests/baselines/reference/thisTypeInFunctions2.symbols index cdc7fb321d4..5cc26e3ad43 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.symbols +++ b/tests/baselines/reference/thisTypeInFunctions2.symbols @@ -61,12 +61,12 @@ extend1({ >init : Symbol(init, Decl(thisTypeInFunctions2.ts, 20, 9)) this // this: IndexedWithThis because of contextual typing. ->this : Symbol(IndexedWithThis, Decl(thisTypeInFunctions2.ts, 0, 0)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 2, 12)) // this.mine this.willDestroy >this.willDestroy : Symbol(IndexedWithThis.willDestroy, Decl(thisTypeInFunctions2.ts, 2, 32)) ->this : Symbol(IndexedWithThis, Decl(thisTypeInFunctions2.ts, 0, 0)) +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 2, 12)) >willDestroy : Symbol(IndexedWithThis.willDestroy, Decl(thisTypeInFunctions2.ts, 2, 32)) }, @@ -77,7 +77,10 @@ extend1({ >foo : Symbol(foo, Decl(thisTypeInFunctions2.ts, 26, 13)) this.url; // this: any because 'foo' matches the string indexer +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 4, 87)) + this.willDestroy; +>this : Symbol(this, Decl(thisTypeInFunctions2.ts, 4, 87)) } }); extend2({ diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types index 371b5f5cafc..25fb2f28a60 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.types +++ b/tests/baselines/reference/thisTypeInFunctions2.types @@ -58,10 +58,10 @@ declare function simple(arg: SimpleInterface): void; extend1({ >extend1({ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }}) : void >extend1 : (args: IndexedWithThis) => void ->{ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }} : { init(): void; mine: number; foo(): void; } +>{ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }} : { init(this: IndexedWithThis): void; mine: number; foo(this: any): void; } init() { ->init : () => void +>init : (this: IndexedWithThis) => void this // this: IndexedWithThis because of contextual typing. >this : IndexedWithThis @@ -78,7 +78,7 @@ extend1({ >12 : number foo() { ->foo : () => void +>foo : (this: any) => void this.url; // this: any because 'foo' matches the string indexer >this.url : any diff --git a/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json new file mode 100644 index 00000000000..ea891967cb5 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Default initialized TSConfig/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json new file mode 100644 index 00000000000..abe135b4f16 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with boolean value compiler options/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "noUnusedLocals": true + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json new file mode 100644 index 00000000000..e28b66c8c2b --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with enum value compiler options/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "jsx": "react" + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json new file mode 100644 index 00000000000..5273b3cb7c8 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with files options/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + }, + "files": [ + "file0.st", + "file1.ts", + "file2.ts" + ] +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json new file mode 100644 index 00000000000..fa9cb6cad84 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option value/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "lib": [ + "es5", + "es2015.promise" + ] + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json new file mode 100644 index 00000000000..ea891967cb5 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with incorrect compiler option/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json new file mode 100644 index 00000000000..3ff8208d9d6 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options with enum value/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "lib": [ + "es5", + "es2015.core" + ] + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json new file mode 100644 index 00000000000..b1740ac4c12 --- /dev/null +++ b/tests/baselines/reference/tsConfig/Initialized TSConfig with list compiler options/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es5", + "noImplicitAny": false, + "sourceMap": false, + "types": [ + "jquery", + "mocha" + ] + } +} \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution14.errors.txt b/tests/baselines/reference/tsxAttributeResolution14.errors.txt new file mode 100644 index 00000000000..81d42e49059 --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution14.errors.txt @@ -0,0 +1,38 @@ +tests/cases/conformance/jsx/file.tsx(14,28): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'boolean' is not assignable to type 'string | number'. + + +==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== + + declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any; + } + interface ElementAttributesProperty { prop: any } + } + +==== tests/cases/conformance/jsx/file.tsx (2 errors) ==== + + interface IProps { + primaryText: string, + [propName: string]: string | number + } + + function VerticalNavMenuItem(prop: IProps) { + return
props.primaryText
+ } + + function VerticalNav() { + return ( +
+ // error + ~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'number' is not assignable to type 'string'. + // ok + // error + ~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. +
+ ) + } \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution14.js b/tests/baselines/reference/tsxAttributeResolution14.js new file mode 100644 index 00000000000..d920179458c --- /dev/null +++ b/tests/baselines/reference/tsxAttributeResolution14.js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/jsx/tsxAttributeResolution14.tsx] //// + +//// [react.d.ts] + +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any; + } + interface ElementAttributesProperty { prop: any } +} + +//// [file.tsx] + +interface IProps { + primaryText: string, + [propName: string]: string | number +} + +function VerticalNavMenuItem(prop: IProps) { + return
props.primaryText
+} + +function VerticalNav() { + return ( +
+ // error + // ok + // error +
+ ) +} + +//// [file.jsx] +function VerticalNavMenuItem(prop) { + return
props.primaryText
; +} +function VerticalNav() { + return (
+ // error + // error + // ok + // ok + // error + // error +
); +} diff --git a/tests/baselines/reference/tsxDefaultImports.js b/tests/baselines/reference/tsxDefaultImports.js new file mode 100644 index 00000000000..e7e0a13860d --- /dev/null +++ b/tests/baselines/reference/tsxDefaultImports.js @@ -0,0 +1,34 @@ +//// [tests/cases/compiler/tsxDefaultImports.ts] //// + +//// [a.ts] + +enum SomeEnum { + one, +} +export default class SomeClass { + public static E = SomeEnum; +} + +//// [b.ts] +import {default as Def} from "./a" +let a = Def.E.one; + + +//// [a.js] +"use strict"; +var SomeEnum; +(function (SomeEnum) { + SomeEnum[SomeEnum["one"] = 0] = "one"; +})(SomeEnum || (SomeEnum = {})); +var SomeClass = (function () { + function SomeClass() { + } + return SomeClass; +}()); +exports.__esModule = true; +exports["default"] = SomeClass; +SomeClass.E = SomeEnum; +//// [b.js] +"use strict"; +var a_1 = require("./a"); +var a = a_1["default"].E.one; diff --git a/tests/baselines/reference/tsxDefaultImports.symbols b/tests/baselines/reference/tsxDefaultImports.symbols new file mode 100644 index 00000000000..e42392e24aa --- /dev/null +++ b/tests/baselines/reference/tsxDefaultImports.symbols @@ -0,0 +1,29 @@ +=== tests/cases/compiler/a.ts === + +enum SomeEnum { +>SomeEnum : Symbol(SomeEnum, Decl(a.ts, 0, 0)) + + one, +>one : Symbol(SomeEnum.one, Decl(a.ts, 1, 15)) +} +export default class SomeClass { +>SomeClass : Symbol(SomeClass, Decl(a.ts, 3, 1)) + + public static E = SomeEnum; +>E : Symbol(SomeClass.E, Decl(a.ts, 4, 32)) +>SomeEnum : Symbol(SomeEnum, Decl(a.ts, 0, 0)) +} + +=== tests/cases/compiler/b.ts === +import {default as Def} from "./a" +>default : Symbol(Def, Decl(b.ts, 0, 8)) +>Def : Symbol(Def, Decl(b.ts, 0, 8)) + +let a = Def.E.one; +>a : Symbol(a, Decl(b.ts, 1, 3)) +>Def.E.one : Symbol(SomeEnum.one, Decl(a.ts, 1, 15)) +>Def.E : Symbol(Def.E, Decl(a.ts, 4, 32)) +>Def : Symbol(Def, Decl(b.ts, 0, 8)) +>E : Symbol(Def.E, Decl(a.ts, 4, 32)) +>one : Symbol(SomeEnum.one, Decl(a.ts, 1, 15)) + diff --git a/tests/baselines/reference/tsxDefaultImports.types b/tests/baselines/reference/tsxDefaultImports.types new file mode 100644 index 00000000000..a9bdedf3efd --- /dev/null +++ b/tests/baselines/reference/tsxDefaultImports.types @@ -0,0 +1,29 @@ +=== tests/cases/compiler/a.ts === + +enum SomeEnum { +>SomeEnum : SomeEnum + + one, +>one : SomeEnum +} +export default class SomeClass { +>SomeClass : SomeClass + + public static E = SomeEnum; +>E : typeof SomeEnum +>SomeEnum : typeof SomeEnum +} + +=== tests/cases/compiler/b.ts === +import {default as Def} from "./a" +>default : typeof Def +>Def : typeof Def + +let a = Def.E.one; +>a : SomeEnum +>Def.E.one : SomeEnum +>Def.E : typeof SomeEnum +>Def : typeof Def +>E : typeof SomeEnum +>one : SomeEnum + diff --git a/tests/baselines/reference/tupleTypes.errors.txt b/tests/baselines/reference/tupleTypes.errors.txt index 75f413eb170..3b55476e4b1 100644 --- a/tests/baselines/reference/tupleTypes.errors.txt +++ b/tests/baselines/reference/tupleTypes.errors.txt @@ -4,8 +4,7 @@ tests/cases/compiler/tupleTypes.ts(14,1): error TS2322: Type 'undefined[]' is no tests/cases/compiler/tupleTypes.ts(15,1): error TS2322: Type '[number]' is not assignable to type '[number, string]'. Property '1' is missing in type '[number]'. tests/cases/compiler/tupleTypes.ts(17,1): error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. - Types of property '0' are incompatible. - Type 'string' is not assignable to type 'number'. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(41,1): error TS2322: Type 'undefined[]' is not assignable to type '[number, string]'. tests/cases/compiler/tupleTypes.ts(47,1): error TS2322: Type '[number, string]' is not assignable to type 'number[]'. Types of property 'pop' are incompatible. @@ -18,11 +17,9 @@ tests/cases/compiler/tupleTypes.ts(49,1): error TS2322: Type '[number, {}]' is n Type 'number | {}' is not assignable to type 'number'. Type '{}' is not assignable to type 'number'. tests/cases/compiler/tupleTypes.ts(50,1): error TS2322: Type '[number, number]' is not assignable to type '[number, string]'. - Types of property '1' are incompatible. - Type 'number' is not assignable to type 'string'. + Type 'number' is not assignable to type 'string'. tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is not assignable to type '[number, string]'. - Types of property '1' are incompatible. - Type '{}' is not assignable to type 'string'. + Type '{}' is not assignable to type 'string'. ==== tests/cases/compiler/tupleTypes.ts (9 errors) ==== @@ -53,8 +50,7 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n t = ["hello", 1]; // Error ~ !!! error TS2322: Type '[string, number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '0' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type 'string' is not assignable to type 'number'. t = [1, "hello", 2]; // Ok var tf: [string, (x: string) => number] = ["hello", x => x.length]; @@ -104,13 +100,11 @@ tests/cases/compiler/tupleTypes.ts(51,1): error TS2322: Type '[number, {}]' is n a1 = a2; // Error ~~ !!! error TS2322: Type '[number, number]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type 'number' is not assignable to type 'string'. a1 = a3; // Error ~~ !!! error TS2322: Type '[number, {}]' is not assignable to type '[number, string]'. -!!! error TS2322: Types of property '1' are incompatible. -!!! error TS2322: Type '{}' is not assignable to type 'string'. +!!! error TS2322: Type '{}' is not assignable to type 'string'. a3 = a1; a3 = a2; \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt index c574118f91d..b67f7328856 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt @@ -1,16 +1,26 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(12,10): error TS2339: Property 'bar' does not exist on type 'A'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(18,10): error TS2339: Property 'bar' does not exist on type 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(33,5): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(34,10): error TS2339: Property 'bar' does not exist on type 'B'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(41,10): error TS2339: Property 'bar' does not exist on type 'B'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(66,10): error TS2339: Property 'bar2' does not exist on type 'C1'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(72,10): error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(73,10): error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(85,10): error TS2339: Property 'bar' does not exist on type 'D'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(91,10): error TS2339: Property 'bar' does not exist on type 'D'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(112,10): error TS2339: Property 'bar2' does not exist on type 'E1'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(118,11): error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(119,11): error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(134,11): error TS2339: Property 'foo' does not exist on type 'string | F'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(135,11): error TS2339: Property 'bar' does not exist on type 'string | F'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(160,11): error TS2339: Property 'foo2' does not exist on type 'G1'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(166,11): error TS2339: Property 'foo2' does not exist on type 'G1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(182,11): error TS2339: Property 'bar' does not exist on type 'H'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(187,11): error TS2339: Property 'foo1' does not exist on type 'H'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(188,11): error TS2339: Property 'foo2' does not exist on type 'H'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts (10 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts (20 errors) ==== interface AConstructor { new (): A; } @@ -28,9 +38,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj2: any; - if (obj2 instanceof A) { // can't narrow type from 'any' + if (obj2 instanceof A) { obj2.foo; obj2.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'A'. } // a construct signature with generics @@ -54,10 +66,12 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj4: any; - if (obj4 instanceof B) { // can't narrow type from 'any' + if (obj4 instanceof B) { obj4.foo = "str"; obj4.foo = 1; obj4.bar = "str"; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'B'. } // has multiple construct signature @@ -88,10 +102,14 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj6: any; - if (obj6 instanceof C) { // can't narrow type from 'any' + if (obj6 instanceof C) { obj6.foo; obj6.bar1; + ~~~~ +!!! error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. obj6.bar2; + ~~~~ +!!! error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. } // with object type literal @@ -109,9 +127,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj8: any; - if (obj8 instanceof D) { // can't narrow type from 'any' + if (obj8 instanceof D) { obj8.foo; obj8.bar; + ~~~ +!!! error TS2339: Property 'bar' does not exist on type 'D'. } // a construct signature that returns a union type @@ -138,10 +158,14 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj10: any; - if (obj10 instanceof E) { // can't narrow type from 'any' + if (obj10 instanceof E) { obj10.foo; obj10.bar1; + ~~~~ +!!! error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. obj10.bar2; + ~~~~ +!!! error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. } // a construct signature that returns any @@ -165,7 +189,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj12: any; - if (obj12 instanceof F) { // can't narrow type from 'any' + if (obj12 instanceof F) { obj12.foo; obj12.bar; } @@ -192,9 +216,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj14: any; - if (obj14 instanceof G) { // can't narrow type from 'any' + if (obj14 instanceof G) { obj14.foo1; obj14.foo2; + ~~~~ +!!! error TS2339: Property 'foo2' does not exist on type 'G1'. } // a type with a prototype that has any type @@ -216,8 +242,24 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru } var obj16: any; - if (obj16 instanceof H) { // can't narrow type from 'any' + if (obj16 instanceof H) { obj16.foo1; + ~~~~ +!!! error TS2339: Property 'foo1' does not exist on type 'H'. obj16.foo2; + ~~~~ +!!! error TS2339: Property 'foo2' does not exist on type 'H'. + } + + var obj17: any; + if (obj17 instanceof Object) { // can't narrow type from 'any' to 'Object' + obj17.foo1; + obj17.foo2; + } + + var obj18: any; + if (obj18 instanceof Function) { // can't narrow type from 'any' to 'Function' + obj18.foo1; + obj18.foo2; } \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js index 7e6b3324470..40ef6587e75 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.js @@ -14,7 +14,7 @@ if (obj1 instanceof A) { // narrowed to A. } var obj2: any; -if (obj2 instanceof A) { // can't narrow type from 'any' +if (obj2 instanceof A) { obj2.foo; obj2.bar; } @@ -36,7 +36,7 @@ if (obj3 instanceof B) { // narrowed to B. } var obj4: any; -if (obj4 instanceof B) { // can't narrow type from 'any' +if (obj4 instanceof B) { obj4.foo = "str"; obj4.foo = 1; obj4.bar = "str"; @@ -68,7 +68,7 @@ if (obj5 instanceof C) { // narrowed to C1|C2. } var obj6: any; -if (obj6 instanceof C) { // can't narrow type from 'any' +if (obj6 instanceof C) { obj6.foo; obj6.bar1; obj6.bar2; @@ -87,7 +87,7 @@ if (obj7 instanceof D) { // narrowed to D. } var obj8: any; -if (obj8 instanceof D) { // can't narrow type from 'any' +if (obj8 instanceof D) { obj8.foo; obj8.bar; } @@ -114,7 +114,7 @@ if (obj9 instanceof E) { // narrowed to E1 | E2 } var obj10: any; -if (obj10 instanceof E) { // can't narrow type from 'any' +if (obj10 instanceof E) { obj10.foo; obj10.bar1; obj10.bar2; @@ -137,7 +137,7 @@ if (obj11 instanceof F) { // can't type narrowing, construct signature returns a } var obj12: any; -if (obj12 instanceof F) { // can't narrow type from 'any' +if (obj12 instanceof F) { obj12.foo; obj12.bar; } @@ -162,7 +162,7 @@ if (obj13 instanceof G) { // narrowed to G1. G1 is return type of prototype prop } var obj14: any; -if (obj14 instanceof G) { // can't narrow type from 'any' +if (obj14 instanceof G) { obj14.foo1; obj14.foo2; } @@ -184,10 +184,22 @@ if (obj15 instanceof H) { // narrowed to H. } var obj16: any; -if (obj16 instanceof H) { // can't narrow type from 'any' +if (obj16 instanceof H) { obj16.foo1; obj16.foo2; } + +var obj17: any; +if (obj17 instanceof Object) { // can't narrow type from 'any' to 'Object' + obj17.foo1; + obj17.foo2; +} + +var obj18: any; +if (obj18 instanceof Function) { // can't narrow type from 'any' to 'Function' + obj18.foo1; + obj18.foo2; +} //// [typeGuardsWithInstanceOfByConstructorSignature.js] @@ -278,3 +290,13 @@ if (obj16 instanceof H) { obj16.foo1; obj16.foo2; } +var obj17; +if (obj17 instanceof Object) { + obj17.foo1; + obj17.foo2; +} +var obj18; +if (obj18 instanceof Function) { + obj18.foo1; + obj18.foo2; +} diff --git a/tests/baselines/reference/typingsLookup2.js b/tests/baselines/reference/typingsLookup2.js new file mode 100644 index 00000000000..3e816526af2 --- /dev/null +++ b/tests/baselines/reference/typingsLookup2.js @@ -0,0 +1,9 @@ +//// [tests/cases/conformance/typings/typingsLookup2.ts] //// + +//// [package.json] +{ "typings": null } + +//// [a.ts] + + +//// [a.js] diff --git a/tests/baselines/reference/typingsLookup2.symbols b/tests/baselines/reference/typingsLookup2.symbols new file mode 100644 index 00000000000..7223c8589a6 --- /dev/null +++ b/tests/baselines/reference/typingsLookup2.symbols @@ -0,0 +1,3 @@ +=== /a.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup2.trace.json b/tests/baselines/reference/typingsLookup2.trace.json new file mode 100644 index 00000000000..0637a088a01 --- /dev/null +++ b/tests/baselines/reference/typingsLookup2.trace.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup2.types b/tests/baselines/reference/typingsLookup2.types new file mode 100644 index 00000000000..7223c8589a6 --- /dev/null +++ b/tests/baselines/reference/typingsLookup2.types @@ -0,0 +1,3 @@ +=== /a.ts === + +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup3.js b/tests/baselines/reference/typingsLookup3.js new file mode 100644 index 00000000000..b3be036b4ae --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.js @@ -0,0 +1,13 @@ +//// [tests/cases/conformance/typings/typingsLookup3.ts] //// + +//// [index.d.ts] +declare var $: { x: any }; + +//// [a.ts] +/// +$.x; + + +//// [a.js] +/// +$.x; diff --git a/tests/baselines/reference/typingsLookup3.symbols b/tests/baselines/reference/typingsLookup3.symbols new file mode 100644 index 00000000000..e641afb183b --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.symbols @@ -0,0 +1,12 @@ +=== /a.ts === +/// +$.x; +>$.x : Symbol(x, Decl(index.d.ts, 0, 16)) +>$ : Symbol($, Decl(index.d.ts, 0, 11)) +>x : Symbol(x, Decl(index.d.ts, 0, 16)) + +=== /node_modules/@types/jquery/index.d.ts === +declare var $: { x: any }; +>$ : Symbol($, Decl(index.d.ts, 0, 11)) +>x : Symbol(x, Decl(index.d.ts, 0, 16)) + diff --git a/tests/baselines/reference/typingsLookup3.trace.json b/tests/baselines/reference/typingsLookup3.trace.json new file mode 100644 index 00000000000..83b0e91d6c7 --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.trace.json @@ -0,0 +1,12 @@ +[ + "======== Resolving type reference directive 'jquery', containing file '/a.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "File '/node_modules/@types/jquery/package.json' does not exist.", + "File '/node_modules/@types/jquery/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/index.d.ts', primary: true. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup3.types b/tests/baselines/reference/typingsLookup3.types new file mode 100644 index 00000000000..f57a974077e --- /dev/null +++ b/tests/baselines/reference/typingsLookup3.types @@ -0,0 +1,12 @@ +=== /a.ts === +/// +$.x; +>$.x : any +>$ : { x: any; } +>x : any + +=== /node_modules/@types/jquery/index.d.ts === +declare var $: { x: any }; +>$ : { x: any; } +>x : any + diff --git a/tests/baselines/reference/typingsLookup4.js b/tests/baselines/reference/typingsLookup4.js new file mode 100644 index 00000000000..c11bc13c613 --- /dev/null +++ b/tests/baselines/reference/typingsLookup4.js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/typings/typingsLookup4.ts] //// + +//// [package.json] +{ "typings": "jquery.d.ts" } + +//// [jquery.d.ts] +export const j: number; + +//// [package.json] +{ "typings": "kquery" } + +//// [kquery.d.ts] +export const k: number; + +//// [package.json] +{ "typings": "lquery" } + +//// [lquery.ts] +export const l = 2; + +//// [a.ts] +import { j } from "jquery"; +import { k } from "kquery"; +import { l } from "lquery"; +j + k + l; + + +//// [lquery.js] +"use strict"; +exports.l = 2; +//// [a.js] +"use strict"; +var jquery_1 = require("jquery"); +var kquery_1 = require("kquery"); +var lquery_1 = require("lquery"); +jquery_1.j + kquery_1.k + lquery_1.l; diff --git a/tests/baselines/reference/typingsLookup4.symbols b/tests/baselines/reference/typingsLookup4.symbols new file mode 100644 index 00000000000..144548c6452 --- /dev/null +++ b/tests/baselines/reference/typingsLookup4.symbols @@ -0,0 +1,27 @@ +=== /a.ts === +import { j } from "jquery"; +>j : Symbol(j, Decl(a.ts, 0, 8)) + +import { k } from "kquery"; +>k : Symbol(k, Decl(a.ts, 1, 8)) + +import { l } from "lquery"; +>l : Symbol(l, Decl(a.ts, 2, 8)) + +j + k + l; +>j : Symbol(j, Decl(a.ts, 0, 8)) +>k : Symbol(k, Decl(a.ts, 1, 8)) +>l : Symbol(l, Decl(a.ts, 2, 8)) + +=== /node_modules/@types/jquery/jquery.d.ts === +export const j: number; +>j : Symbol(j, Decl(jquery.d.ts, 0, 12)) + +=== /node_modules/@types/kquery/kquery.d.ts === +export const k: number; +>k : Symbol(k, Decl(kquery.d.ts, 0, 12)) + +=== /node_modules/@types/lquery/lquery.ts === +export const l = 2; +>l : Symbol(l, Decl(lquery.ts, 0, 12)) + diff --git a/tests/baselines/reference/typingsLookup4.trace.json b/tests/baselines/reference/typingsLookup4.trace.json new file mode 100644 index 00000000000..4bca8456f58 --- /dev/null +++ b/tests/baselines/reference/typingsLookup4.trace.json @@ -0,0 +1,93 @@ +[ + "======== Resolving module 'jquery' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'jquery' from 'node_modules' folder.", + "File '/node_modules/jquery.ts' does not exist.", + "File '/node_modules/jquery.tsx' does not exist.", + "File '/node_modules/jquery.d.ts' does not exist.", + "File '/node_modules/jquery/package.json' does not exist.", + "File '/node_modules/jquery/index.ts' does not exist.", + "File '/node_modules/jquery/index.tsx' does not exist.", + "File '/node_modules/jquery/index.d.ts' does not exist.", + "File '/node_modules/@types/jquery.ts' does not exist.", + "File '/node_modules/@types/jquery.tsx' does not exist.", + "File '/node_modules/@types/jquery.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", + "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", + "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/jquery/jquery.d.ts', result '/node_modules/@types/jquery/jquery.d.ts'", + "======== Module name 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts'. ========", + "======== Resolving module 'kquery' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'kquery' from 'node_modules' folder.", + "File '/node_modules/kquery.ts' does not exist.", + "File '/node_modules/kquery.tsx' does not exist.", + "File '/node_modules/kquery.d.ts' does not exist.", + "File '/node_modules/kquery/package.json' does not exist.", + "File '/node_modules/kquery/index.ts' does not exist.", + "File '/node_modules/kquery/index.tsx' does not exist.", + "File '/node_modules/kquery/index.d.ts' does not exist.", + "File '/node_modules/@types/kquery.ts' does not exist.", + "File '/node_modules/@types/kquery.tsx' does not exist.", + "File '/node_modules/@types/kquery.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", + "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", + "File '/node_modules/@types/kquery/kquery' does not exist.", + "File '/node_modules/@types/kquery/kquery.ts' does not exist.", + "File '/node_modules/@types/kquery/kquery.tsx' does not exist.", + "File '/node_modules/@types/kquery/kquery.d.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/kquery/kquery.d.ts', result '/node_modules/@types/kquery/kquery.d.ts'", + "======== Module name 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts'. ========", + "======== Resolving module 'lquery' from '/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'lquery' from 'node_modules' folder.", + "File '/node_modules/lquery.ts' does not exist.", + "File '/node_modules/lquery.tsx' does not exist.", + "File '/node_modules/lquery.d.ts' does not exist.", + "File '/node_modules/lquery/package.json' does not exist.", + "File '/node_modules/lquery/index.ts' does not exist.", + "File '/node_modules/lquery/index.tsx' does not exist.", + "File '/node_modules/lquery/index.d.ts' does not exist.", + "File '/node_modules/@types/lquery.ts' does not exist.", + "File '/node_modules/@types/lquery.tsx' does not exist.", + "File '/node_modules/@types/lquery.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", + "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", + "File '/node_modules/@types/lquery/lquery' does not exist.", + "File '/node_modules/@types/lquery/lquery.ts' exist - use it as a name resolution result.", + "Resolving real path for '/node_modules/@types/lquery/lquery.ts', result '/node_modules/@types/lquery/lquery.ts'", + "======== Module name 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts'. ========", + "======== Resolving type reference directive 'jquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "Found 'package.json' at '/node_modules/@types/jquery/package.json'.", + "'package.json' has 'typings' field 'jquery.d.ts' that references '/node_modules/@types/jquery/jquery.d.ts'.", + "File '/node_modules/@types/jquery/jquery.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'jquery' was successfully resolved to '/node_modules/@types/jquery/jquery.d.ts', primary: true. ========", + "======== Resolving type reference directive 'kquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "Found 'package.json' at '/node_modules/@types/kquery/package.json'.", + "'package.json' has 'typings' field 'kquery' that references '/node_modules/@types/kquery/kquery'.", + "File '/node_modules/@types/kquery/kquery' does not exist.", + "File '/node_modules/@types/kquery/kquery.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'kquery' was successfully resolved to '/node_modules/@types/kquery/kquery.d.ts', primary: true. ========", + "======== Resolving type reference directive 'lquery', containing file '/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", + "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", + "File '/node_modules/@types/lquery/lquery' does not exist.", + "File '/node_modules/@types/lquery/lquery.d.ts' does not exist.", + "File '/node_modules/@types/lquery/index.d.ts' does not exist.", + "Looking up in 'node_modules' folder, initial location '/'", + "File '/node_modules/lquery.ts' does not exist.", + "File '/node_modules/lquery.d.ts' does not exist.", + "File '/node_modules/lquery/package.json' does not exist.", + "File '/node_modules/lquery/index.ts' does not exist.", + "File '/node_modules/lquery/index.d.ts' does not exist.", + "File '/node_modules/@types/lquery.ts' does not exist.", + "File '/node_modules/@types/lquery.d.ts' does not exist.", + "Found 'package.json' at '/node_modules/@types/lquery/package.json'.", + "'package.json' has 'typings' field 'lquery' that references '/node_modules/@types/lquery/lquery'.", + "File '/node_modules/@types/lquery/lquery' does not exist.", + "File '/node_modules/@types/lquery/lquery.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'lquery' was successfully resolved to '/node_modules/@types/lquery/lquery.ts', primary: false. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/typingsLookup4.types b/tests/baselines/reference/typingsLookup4.types new file mode 100644 index 00000000000..d922c7b1dfa --- /dev/null +++ b/tests/baselines/reference/typingsLookup4.types @@ -0,0 +1,30 @@ +=== /a.ts === +import { j } from "jquery"; +>j : number + +import { k } from "kquery"; +>k : number + +import { l } from "lquery"; +>l : number + +j + k + l; +>j + k + l : number +>j + k : number +>j : number +>k : number +>l : number + +=== /node_modules/@types/jquery/jquery.d.ts === +export const j: number; +>j : number + +=== /node_modules/@types/kquery/kquery.d.ts === +export const k: number; +>k : number + +=== /node_modules/@types/lquery/lquery.ts === +export const l = 2; +>l : number +>2 : number + diff --git a/tests/baselines/reference/unusedParameterProperty1.errors.txt b/tests/baselines/reference/unusedParameterProperty1.errors.txt new file mode 100644 index 00000000000..0581199313f --- /dev/null +++ b/tests/baselines/reference/unusedParameterProperty1.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedParameterProperty1.ts(3,25): error TS6138: Property 'used' is declared but never used. + + +==== tests/cases/compiler/unusedParameterProperty1.ts (1 errors) ==== + + class A { + constructor(private used: string) { + ~~~~ +!!! error TS6138: Property 'used' is declared but never used. + let foge = used; + foge += ""; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterProperty1.js b/tests/baselines/reference/unusedParameterProperty1.js new file mode 100644 index 00000000000..d0b608a6d87 --- /dev/null +++ b/tests/baselines/reference/unusedParameterProperty1.js @@ -0,0 +1,19 @@ +//// [unusedParameterProperty1.ts] + +class A { + constructor(private used: string) { + let foge = used; + foge += ""; + } +} + + +//// [unusedParameterProperty1.js] +var A = (function () { + function A(used) { + this.used = used; + var foge = used; + foge += ""; + } + return A; +}()); diff --git a/tests/baselines/reference/unusedParameterProperty2.errors.txt b/tests/baselines/reference/unusedParameterProperty2.errors.txt new file mode 100644 index 00000000000..cb3b3e95556 --- /dev/null +++ b/tests/baselines/reference/unusedParameterProperty2.errors.txt @@ -0,0 +1,14 @@ +tests/cases/compiler/unusedParameterProperty2.ts(3,25): error TS6138: Property 'used' is declared but never used. + + +==== tests/cases/compiler/unusedParameterProperty2.ts (1 errors) ==== + + class A { + constructor(private used) { + ~~~~ +!!! error TS6138: Property 'used' is declared but never used. + let foge = used; + foge += ""; + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/unusedParameterProperty2.js b/tests/baselines/reference/unusedParameterProperty2.js new file mode 100644 index 00000000000..2bb04fde088 --- /dev/null +++ b/tests/baselines/reference/unusedParameterProperty2.js @@ -0,0 +1,19 @@ +//// [unusedParameterProperty2.ts] + +class A { + constructor(private used) { + let foge = used; + foge += ""; + } +} + + +//// [unusedParameterProperty2.js] +var A = (function () { + function A(used) { + this.used = used; + var foge = used; + foge += ""; + } + return A; +}()); diff --git a/tests/cases/compiler/APISample_watcher.ts b/tests/cases/compiler/APISample_watcher.ts index 34baa04c850..07922bd35c7 100644 --- a/tests/cases/compiler/APISample_watcher.ts +++ b/tests/cases/compiler/APISample_watcher.ts @@ -23,7 +23,7 @@ declare var path: any; import * as ts from "typescript"; function watch(rootFileNames: string[], options: ts.CompilerOptions) { - const files: ts.Map<{ version: number }> = {}; + const files: ts.MapLike<{ version: number }> = {}; // initialize the list of files rootFileNames.forEach(fileName => { diff --git a/tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts b/tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts new file mode 100644 index 00000000000..d621cf460bc --- /dev/null +++ b/tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts @@ -0,0 +1,18 @@ +class A { a } +class B extends A { b } +class C extends Array { c } +declare var ara: A[]; +declare var arb: B[]; +declare var cra: C
; +declare var crb: C; +declare var rra: ReadonlyArray; +declare var rrb: ReadonlyArray; +rra = ara; +rrb = arb; // OK, Array is assignable to ReadonlyArray +rra = arb; +rrb = ara; // error: 'A' is not assignable to 'B' + +rra = cra; +rra = crb; // OK, C is assignable to ReadonlyArray +rrb = crb; +rrb = cra; // error: 'A' is not assignable to 'B' diff --git a/tests/cases/compiler/castOfAwait.ts b/tests/cases/compiler/castOfAwait.ts new file mode 100644 index 00000000000..fcd8f999e9f --- /dev/null +++ b/tests/cases/compiler/castOfAwait.ts @@ -0,0 +1,8 @@ +// @target: es6 +async function f() { + await 0; + typeof await 0; + void await 0; + await void typeof void await 0; + await await 0; +} diff --git a/tests/cases/compiler/castOfYield.ts b/tests/cases/compiler/castOfYield.ts new file mode 100644 index 00000000000..9a85e6b21c2 --- /dev/null +++ b/tests/cases/compiler/castOfYield.ts @@ -0,0 +1,5 @@ +function* f() { + (yield 0); + // Unlike await, yield is not allowed to appear in a simple unary expression. + yield 0; +} diff --git a/tests/cases/compiler/controlFlowInstanceof.ts b/tests/cases/compiler/controlFlowInstanceof.ts new file mode 100644 index 00000000000..56f3ff97e4c --- /dev/null +++ b/tests/cases/compiler/controlFlowInstanceof.ts @@ -0,0 +1,99 @@ +// @target: es6 + +// Repros from #10167 + +function f1(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + s; // Set + s.add(42); +} + +function f2(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Promise) { + s; // Set & Promise + } + s; // Set + s.add(42); +} + +function f3(s: Set | Set) { + s; // Set | Set + if (s instanceof Set) { + s; // Set | Set + } + else { + s; // never + } +} + +function f4(s: Set | Set) { + s = new Set(); + s; // Set + if (s instanceof Set) { + s; // Set + } + else { + s; // never + } +} + +// More tests + +class A { a: string } +class B extends A { b: string } +class C extends A { c: string } + +function foo(x: A | undefined) { + x; // A | undefined + if (x instanceof B || x instanceof C) { + x; // B | C + } + x; // A | undefined + if (x instanceof B && x instanceof C) { + x; // B & C + } + x; // A | undefined + if (!x) { + return; + } + x; // A + if (x instanceof B) { + x; // B + if (x instanceof C) { + x; // B & C + } + else { + x; // B + } + x; // B + } + else { + x; // A + } + x; // A +} + +// X is neither assignable to Y nor a subtype of Y +// Y is assignable to X, but not a subtype of X + +interface X { + x?: string; +} + +class Y { + y: string; +} + +function goo(x: X) { + x; + if (x instanceof Y) { + x.y; + } + x; +} \ No newline at end of file diff --git a/tests/cases/compiler/discriminantPropertyCheck.ts b/tests/cases/compiler/discriminantPropertyCheck.ts new file mode 100644 index 00000000000..e493f6bf770 --- /dev/null +++ b/tests/cases/compiler/discriminantPropertyCheck.ts @@ -0,0 +1,69 @@ +// @strictNullChecks: true + +type Item = Item1 | Item2; + +interface Base { + bar: boolean; +} + +interface Item1 extends Base { + kind: "A"; + foo: string | undefined; + baz: boolean; + qux: true; +} + +interface Item2 extends Base { + kind: "B"; + foo: string | undefined; + baz: boolean; + qux: false; +} + +function goo1(x: Item) { + if (x.kind === "A" && x.foo !== undefined) { + x.foo.length; + } +} + +function goo2(x: Item) { + if (x.foo !== undefined && x.kind === "A") { + x.foo.length; // Error, intervening discriminant guard + } +} + +function foo1(x: Item) { + if (x.bar && x.foo !== undefined) { + x.foo.length; + } +} + +function foo2(x: Item) { + if (x.foo !== undefined && x.bar) { + x.foo.length; + } +} + +function foo3(x: Item) { + if (x.baz && x.foo !== undefined) { + x.foo.length; + } +} + +function foo4(x: Item) { + if (x.foo !== undefined && x.baz) { + x.foo.length; + } +} + +function foo5(x: Item) { + if (x.qux && x.foo !== undefined) { + x.foo.length; + } +} + +function foo6(x: Item) { + if (x.foo !== undefined && x.qux) { + x.foo.length; // Error, intervening discriminant guard + } +} \ No newline at end of file diff --git a/tests/cases/compiler/discriminantsAndNullOrUndefined.ts b/tests/cases/compiler/discriminantsAndNullOrUndefined.ts new file mode 100644 index 00000000000..8346fa8adea --- /dev/null +++ b/tests/cases/compiler/discriminantsAndNullOrUndefined.ts @@ -0,0 +1,25 @@ +// @strictNullChecks: true + +// Repro from #10228 + +interface A { kind: 'A'; } +interface B { kind: 'B'; } + +type C = A | B | undefined; + +function never(_: never): never { + throw new Error(); +} + +function useA(_: A): void { } +function useB(_: B): void { } + +declare var c: C; + +if (c !== undefined) { + switch (c.kind) { + case 'A': useA(c); break; + case 'B': useB(c); break; + default: never(c); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/discriminantsAndPrimitives.ts b/tests/cases/compiler/discriminantsAndPrimitives.ts new file mode 100644 index 00000000000..6352d741808 --- /dev/null +++ b/tests/cases/compiler/discriminantsAndPrimitives.ts @@ -0,0 +1,49 @@ +// @strictNullChecks: true + +// Repro from #10257 plus other tests + +interface Foo { + kind: "foo"; + name: string; +} + +interface Bar { + kind: "bar"; + length: string; +} + +function f1(x: Foo | Bar | string) { + if (typeof x !== 'string') { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f2(x: Foo | Bar | string | undefined) { + if (typeof x === "object") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f3(x: Foo | Bar | string | null) { + if (x && typeof x !== "string") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} + +function f4(x: Foo | Bar | string | number | null) { + if (x && typeof x === "object") { + switch(x.kind) { + case 'foo': + x.name; + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/discriminantsAndTypePredicates.ts b/tests/cases/compiler/discriminantsAndTypePredicates.ts new file mode 100644 index 00000000000..c21ab7ec8f4 --- /dev/null +++ b/tests/cases/compiler/discriminantsAndTypePredicates.ts @@ -0,0 +1,31 @@ +// Repro from #10145 + +interface A { type: 'A' } +interface B { type: 'B' } + +function isA(x: A | B): x is A { return x.type === 'A'; } +function isB(x: A | B): x is B { return x.type === 'B'; } + +function foo1(x: A | B): any { + x; // A | B + if (isA(x)) { + return x; // A + } + x; // B + if (isB(x)) { + return x; // B + } + x; // never +} + +function foo2(x: A | B): any { + x; // A | B + if (x.type === 'A') { + return x; // A + } + x; // B + if (x.type === 'B') { + return x; // B + } + x; // never +} \ No newline at end of file diff --git a/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts b/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts new file mode 100644 index 00000000000..e369cd9fb50 --- /dev/null +++ b/tests/cases/compiler/emitCapturingThisInTupleDestructuring1.ts @@ -0,0 +1,4 @@ +declare function wrapper(x: any); +wrapper((array: [any]) => { + [this.test, this.test1, this.test2] = array; // even though there is a compiler error, we should still emit lexical capture for "this" +}); \ No newline at end of file diff --git a/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts b/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts new file mode 100644 index 00000000000..2bb931c4f4f --- /dev/null +++ b/tests/cases/compiler/emitCapturingThisInTupleDestructuring2.ts @@ -0,0 +1,10 @@ +var array1: [number, number] = [1, 2]; + +class B { + test: number; + test1: any; + test2: any; + method() { + () => [this.test, this.test1, this.test2] = array1; // even though there is a compiler error, we should still emit lexical capture for "this" + } +} \ No newline at end of file diff --git a/tests/cases/compiler/exportDefaultProperty.ts b/tests/cases/compiler/exportDefaultProperty.ts new file mode 100644 index 00000000000..4a4b4139025 --- /dev/null +++ b/tests/cases/compiler/exportDefaultProperty.ts @@ -0,0 +1,39 @@ +// This test is just like exportEqualsProperty, but with `export default`. + +// @Filename: declarations.d.ts +declare namespace foo.bar { + export type X = number; + export const X: number; +} + +declare module "foobar" { + export default foo.bar; +} + +declare module "foobarx" { + export default foo.bar.X; +} + +// @Filename: a.ts +namespace A { + export class B { constructor(b: number) {} } + export namespace B { export const b: number = 0; } +} +export default A.B; + +// @Filename: b.ts +export default "foo".length; + +// @Filename: index.ts +/// +import fooBar from "foobar"; +import X = fooBar.X; +import X2 from "foobarx"; +const x: X = X; +const x2: X2 = X2; + +import B from "./a"; +const b: B = new B(B.b); + +import fooLength from "./b"; +fooLength + 1; diff --git a/tests/cases/compiler/exportDefaultProperty2.ts b/tests/cases/compiler/exportDefaultProperty2.ts new file mode 100644 index 00000000000..0db617c93e1 --- /dev/null +++ b/tests/cases/compiler/exportDefaultProperty2.ts @@ -0,0 +1,15 @@ +// This test is just like exportEqualsProperty2, but with `export default`. + +// @Filename: a.ts +class C { + static B: number; +} +namespace C { + export interface B { c: number } +} + +export default C.B; + +// @Filename: b.ts +import B from "./a"; +const x: B = { c: B }; diff --git a/tests/cases/compiler/exportEqualsProperty.ts b/tests/cases/compiler/exportEqualsProperty.ts new file mode 100644 index 00000000000..0d14815a5bd --- /dev/null +++ b/tests/cases/compiler/exportEqualsProperty.ts @@ -0,0 +1,38 @@ +// This test is just like exportDefaultProperty, but with `export =`. + +// @Filename: declarations.d.ts +declare namespace foo.bar { + export type X = number; + export const X: number; +} + +declare module "foobar" { + export = foo.bar; +} + +declare module "foobarx" { + export = foo.bar.X; +} + +// @Filename: a.ts +namespace A { + export class B { constructor(b: number) {} } + export namespace B { export const b: number = 0; } +} +export = A.B; + +// @Filename: b.ts +export = "foo".length; + +// @Filename: index.ts +/// +import { X } from "foobar"; +import X2 = require("foobarx"); +const x: X = X; +const x2: X2 = X2; + +import B = require("./a"); +const b: B = new B(B.b); + +import fooLength = require("./b"); +fooLength + 1; diff --git a/tests/cases/compiler/exportEqualsProperty2.ts b/tests/cases/compiler/exportEqualsProperty2.ts new file mode 100644 index 00000000000..61f117f1629 --- /dev/null +++ b/tests/cases/compiler/exportEqualsProperty2.ts @@ -0,0 +1,15 @@ +// This test is just like exportDefaultProperty2, but with `export =`. + +// @Filename: a.ts +class C { + static B: number; +} +namespace C { + export interface B { c: number } +} + +export = C.B; + +// @Filename: b.ts +import B = require("./a"); +const x: B = { c: B }; diff --git a/tests/cases/compiler/getterControlFlowStrictNull.ts b/tests/cases/compiler/getterControlFlowStrictNull.ts new file mode 100644 index 00000000000..44fbe359789 --- /dev/null +++ b/tests/cases/compiler/getterControlFlowStrictNull.ts @@ -0,0 +1,20 @@ +//@strictNullChecks: true +//@target: ES5 +class A { + a(): string | null { + if (Math.random() > 0.5) { + return ''; + } + + // it does error here as expected + } +} +class B { + get a(): string | null { + if (Math.random() > 0.5) { + return ''; + } + + // it should error here because it returns undefined + } +} \ No newline at end of file diff --git a/tests/cases/compiler/implicitConstParameters.ts b/tests/cases/compiler/implicitConstParameters.ts new file mode 100644 index 00000000000..97996789124 --- /dev/null +++ b/tests/cases/compiler/implicitConstParameters.ts @@ -0,0 +1,57 @@ +// @strictNullChecks: true + +function doSomething(cb: () => void) { + cb(); +} + +function fn(x: number | string) { + if (typeof x === 'number') { + doSomething(() => x.toFixed()); + } +} + +function f1(x: string | undefined) { + if (!x) { + return; + } + doSomething(() => x.length); +} + +function f2(x: string | undefined) { + if (x) { + doSomething(() => { + doSomething(() => x.length); + }); + } +} + +function f3(x: string | undefined) { + inner(); + function inner() { + if (x) { + doSomething(() => x.length); + } + } +} + +function f4(x: string | undefined) { + x = "abc"; // causes x to be considered non-const + if (x) { + doSomething(() => x.length); + } +} + +function f5(x: string | undefined) { + if (x) { + doSomething(() => x.length); + } + x = "abc"; // causes x to be considered non-const +} + + +function f6(x: string | undefined) { + const y = x || ""; + if (x) { + doSomething(() => y.length); + } +} \ No newline at end of file diff --git a/tests/cases/compiler/indexWithUndefinedAndNull.ts b/tests/cases/compiler/indexWithUndefinedAndNull.ts new file mode 100644 index 00000000000..2aeb2ee0b1d --- /dev/null +++ b/tests/cases/compiler/indexWithUndefinedAndNull.ts @@ -0,0 +1,13 @@ +// @strictNullChecks: false +interface N { + [n: number]: string; +} +interface S { + [s: string]: number; +} +let n: N; +let s: S; +let str: string = n[undefined]; +str = n[null]; +let num: number = s[undefined]; +num = s[null]; diff --git a/tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts b/tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts new file mode 100644 index 00000000000..f8fe0a323c6 --- /dev/null +++ b/tests/cases/compiler/indexWithUndefinedAndNullStrictNullChecks.ts @@ -0,0 +1,13 @@ +// @strictNullChecks: true +interface N { + [n: number]: string; +} +interface S { + [s: string]: number; +} +let n: N; +let s: S; +let str: string = n[undefined]; +str = n[null]; +let num: number = s[undefined]; +num = s[null]; diff --git a/tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts b/tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts new file mode 100644 index 00000000000..564f7a9c22e --- /dev/null +++ b/tests/cases/compiler/instanceofWithStructurallyIdenticalTypes.ts @@ -0,0 +1,69 @@ +// Repro from #7271 + +class C1 { item: string } +class C2 { item: string[] } +class C3 { item: string } + +function foo1(x: C1 | C2 | C3): string { + if (x instanceof C1) { + return x.item; + } + else if (x instanceof C2) { + return x.item[0]; + } + else if (x instanceof C3) { + return x.item; + } + return "error"; +} + +function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } +function isC2(c: C1 | C2 | C3): c is C2 { return c instanceof C2 } +function isC3(c: C1 | C2 | C3): c is C3 { return c instanceof C3 } + +function foo2(x: C1 | C2 | C3): string { + if (isC1(x)) { + return x.item; + } + else if (isC2(x)) { + return x.item[0]; + } + else if (isC3(x)) { + return x.item; + } + return "error"; +} + +// More tests + +class A { a: string } +class A1 extends A { } +class A2 { a: string } +class B extends A { b: string } + +function goo(x: A) { + if (x instanceof A) { + x; // A + } + else { + x; // never + } + if (x instanceof A1) { + x; // A1 + } + else { + x; // A + } + if (x instanceof A2) { + x; // A2 + } + else { + x; // A + } + if (x instanceof B) { + x; // B + } + else { + x; // A + } +} diff --git a/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts b/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts new file mode 100644 index 00000000000..f06f06ee7a1 --- /dev/null +++ b/tests/cases/compiler/instantiateContextuallyTypedGenericThis.ts @@ -0,0 +1,11 @@ +interface JQuery { + each( + collection: T[], callback: (this: T, dit: T) => T + ): T[]; +} + +let $: JQuery; +let lines: string[]; +$.each(lines, function(dit) { + return dit.charAt(0) + this.charAt(1); +}); diff --git a/tests/cases/compiler/missingFunctionImplementation2.ts b/tests/cases/compiler/missingFunctionImplementation2.ts index 25909b6add4..1717bc663f2 100644 --- a/tests/cases/compiler/missingFunctionImplementation2.ts +++ b/tests/cases/compiler/missingFunctionImplementation2.ts @@ -1,6 +1,6 @@ // @Filename: missingFunctionImplementation2_a.ts export {}; -declare module "./missingFunctionImplementation2_b.ts" { +declare module "./missingFunctionImplementation2_b" { export function f(a, b): void; } diff --git a/tests/cases/compiler/moduleResolutionNoTs.ts b/tests/cases/compiler/moduleResolutionNoTs.ts new file mode 100644 index 00000000000..2051bc259bf --- /dev/null +++ b/tests/cases/compiler/moduleResolutionNoTs.ts @@ -0,0 +1,19 @@ +// @filename: x.ts +export default 0; + +// @filename: y.tsx +export default 0; + +// @filename: z.d.ts +declare const x: number; +export default x; + +// @filename: user.ts +import x from "./x.ts"; +import y from "./y.tsx"; +import z from "./z.d.ts"; + +// Making sure the suggested fixes are valid: +import x2 from "./x"; +import y2 from "./y"; +import z2 from "./z"; diff --git a/tests/cases/compiler/nativeToBoxedTypes.ts b/tests/cases/compiler/nativeToBoxedTypes.ts new file mode 100644 index 00000000000..a34dd5cdd3b --- /dev/null +++ b/tests/cases/compiler/nativeToBoxedTypes.ts @@ -0,0 +1,15 @@ +var N = new Number(); +var n = 100; +n = N; + +var S = new String(); +var s = "foge"; +s = S; + +var B = new Boolean(); +var b = true; +b = B; + +var sym: symbol; +var Sym: Symbol; +sym = Sym; \ No newline at end of file diff --git a/tests/cases/compiler/nestedLoopTypeGuards.ts b/tests/cases/compiler/nestedLoopTypeGuards.ts new file mode 100644 index 00000000000..90d7912dec5 --- /dev/null +++ b/tests/cases/compiler/nestedLoopTypeGuards.ts @@ -0,0 +1,31 @@ +// Repros from #10378 + +function f1() { + var a: boolean | number | string; + if (typeof a !== 'boolean') { + // a is narrowed to "number | string" + for (var i = 0; i < 1; i++) { + for (var j = 0; j < 1; j++) {} + if (typeof a === 'string') { + // a is narrowed to "string' + for (var j = 0; j < 1; j++) { + a.length; // Should not error here + } + } + } + } +} + +function f2() { + var a: string | number; + if (typeof a === 'string') { + while (1) { + while (1) {} + if (typeof a === 'string') { + while (1) { + a.length; // Should not error here + } + } + } + } +} \ No newline at end of file diff --git a/tests/cases/compiler/noErrorTruncation.ts b/tests/cases/compiler/noErrorTruncation.ts new file mode 100644 index 00000000000..5bd6ecf1d74 --- /dev/null +++ b/tests/cases/compiler/noErrorTruncation.ts @@ -0,0 +1,15 @@ +// @noErrorTruncation + +type SomeLongOptionA = { someLongOptionA: string } +type SomeLongOptionB = { someLongOptionB: string } +type SomeLongOptionC = { someLongOptionC: string } +type SomeLongOptionD = { someLongOptionD: string } +type SomeLongOptionE = { someLongOptionE: string } +type SomeLongOptionF = { someLongOptionF: string } + +const x: SomeLongOptionA + | SomeLongOptionB + | SomeLongOptionC + | SomeLongOptionD + | SomeLongOptionE + | SomeLongOptionF = 42; diff --git a/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts index 6988416d4de..ea99d03bd7c 100644 --- a/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts +++ b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration.ts @@ -7,4 +7,6 @@ var [a2]: [any], {b2}: { b2: any }, c2: any, d2: any; var {b3}: { b3 }, c3: { b3 }; // error in type instead -var [a1] = [undefined], {b1} = { b1: null }, c1 = undefined, d1 = null; // error \ No newline at end of file +var [a4] = [undefined], {b4} = { b4: null }, c4 = undefined, d4 = null; // error + +var [a5 = undefined] = []; // error \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts new file mode 100644 index 00000000000..a964bd96dba --- /dev/null +++ b/tests/cases/compiler/noImplicitAnyDestructuringVarDeclaration2.ts @@ -0,0 +1,12 @@ +// @noimplicitany: true +let [a, b, c] = [1, 2, 3]; // no error +let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error +let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error +let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error +let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error + +let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error +let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error +let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error +let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error +let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error diff --git a/tests/cases/compiler/staticInstanceResolution5.ts b/tests/cases/compiler/staticInstanceResolution5.ts index 3adb8667be5..ed34dbd535f 100644 --- a/tests/cases/compiler/staticInstanceResolution5.ts +++ b/tests/cases/compiler/staticInstanceResolution5.ts @@ -7,7 +7,7 @@ export class Promise { } // @Filename: staticInstanceResolution5_1.ts -import WinJS = require('staticInstanceResolution5_0.ts'); +import WinJS = require('staticInstanceResolution5_0'); // these 3 should be errors var x = (w1: WinJS) => { }; diff --git a/tests/cases/compiler/thisInTupleTypeParameterConstraints.ts b/tests/cases/compiler/thisInTupleTypeParameterConstraints.ts new file mode 100644 index 00000000000..b6d0d338d85 --- /dev/null +++ b/tests/cases/compiler/thisInTupleTypeParameterConstraints.ts @@ -0,0 +1,22 @@ +/// + +interface Boolean {} +interface IArguments {} +interface Function {} +interface Number {} +interface RegExp {} +interface Object {} +interface String {} + +interface Array { + // 4 methods will run out of memory if this-types are not instantiated + // correctly for tuple types that are type parameter constraints + map(arg: this): void; + reduceRight(arg: this): void; + reduce(arg: this): void; + reduce2(arg: this): void; +} + +declare function f number]>(a: T): void; +let x: [(x: number) => number]; +f(x); diff --git a/tests/cases/compiler/tsxDefaultImports.ts b/tests/cases/compiler/tsxDefaultImports.ts new file mode 100644 index 00000000000..4e313b33eac --- /dev/null +++ b/tests/cases/compiler/tsxDefaultImports.ts @@ -0,0 +1,12 @@ +// @Filename: a.ts + +enum SomeEnum { + one, +} +export default class SomeClass { + public static E = SomeEnum; +} + +// @Filename: b.ts +import {default as Def} from "./a" +let a = Def.E.one; diff --git a/tests/cases/compiler/unusedParameterProperty1.ts b/tests/cases/compiler/unusedParameterProperty1.ts new file mode 100644 index 00000000000..61c4374c60a --- /dev/null +++ b/tests/cases/compiler/unusedParameterProperty1.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + constructor(private used: string) { + let foge = used; + foge += ""; + } +} diff --git a/tests/cases/compiler/unusedParameterProperty2.ts b/tests/cases/compiler/unusedParameterProperty2.ts new file mode 100644 index 00000000000..b9e05fbc967 --- /dev/null +++ b/tests/cases/compiler/unusedParameterProperty2.ts @@ -0,0 +1,9 @@ +//@noUnusedLocals:true +//@noUnusedParameters:true + +class A { + constructor(private used) { + let foge = used; + foge += ""; + } +} diff --git a/tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts b/tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts deleted file mode 100644 index bf7de709ef2..00000000000 --- a/tests/cases/conformance/ambient/ambientShorthand_isImplicitAny.ts +++ /dev/null @@ -1,2 +0,0 @@ -// @noImplicitAny: true -declare module "jquery"; diff --git a/tests/cases/conformance/async/es6/await_unaryExpression_es6.ts b/tests/cases/conformance/async/es6/await_unaryExpression_es6.ts new file mode 100644 index 00000000000..09cf0a87a5a --- /dev/null +++ b/tests/cases/conformance/async/es6/await_unaryExpression_es6.ts @@ -0,0 +1,17 @@ +// @target: es6 + +async function bar() { + !await 42; // OK +} + +async function bar1() { + +await 42; // OK +} + +async function bar3() { + -await 42; // OK +} + +async function bar4() { + ~await 42; // OK +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts b/tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts new file mode 100644 index 00000000000..5ccf1a1c35a --- /dev/null +++ b/tests/cases/conformance/async/es6/await_unaryExpression_es6_1.ts @@ -0,0 +1,21 @@ +// @target: es6 + +async function bar() { + !await 42; // OK +} + +async function bar1() { + delete await 42; // OK +} + +async function bar2() { + delete await 42; // OK +} + +async function bar3() { + void await 42; +} + +async function bar4() { + +await 42; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts b/tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts new file mode 100644 index 00000000000..24683765d19 --- /dev/null +++ b/tests/cases/conformance/async/es6/await_unaryExpression_es6_2.ts @@ -0,0 +1,13 @@ +// @target: es6 + +async function bar1() { + delete await 42; +} + +async function bar2() { + delete await 42; +} + +async function bar3() { + void await 42; +} \ No newline at end of file diff --git a/tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts b/tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts new file mode 100644 index 00000000000..b595ab5e748 --- /dev/null +++ b/tests/cases/conformance/async/es6/await_unaryExpression_es6_3.ts @@ -0,0 +1,19 @@ +// @target: es6 + +async function bar1() { + ++await 42; // Error +} + +async function bar2() { + --await 42; // Error +} + +async function bar3() { + var x = 42; + await x++; // OK but shouldn't need parenthesis +} + +async function bar4() { + var x = 42; + await x--; // OK but shouldn't need parenthesis +} \ No newline at end of file diff --git a/tests/cases/conformance/controlFlow/controlFlowIfStatement.ts b/tests/cases/conformance/controlFlow/controlFlowIfStatement.ts index c9e9be92f8e..dc1cf97fe59 100644 --- a/tests/cases/conformance/controlFlow/controlFlowIfStatement.ts +++ b/tests/cases/conformance/controlFlow/controlFlowIfStatement.ts @@ -34,3 +34,19 @@ function b() { } x; // string } +function c(data: string | T): T { + if (typeof data === 'string') { + return JSON.parse(data); + } + else { + return data; + } +} +function d(data: string | T): never { + if (typeof data === 'string') { + throw new Error('will always happen'); + } + else { + return data; + } +} diff --git a/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts index b81dd26652b..0817954c35c 100644 --- a/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts +++ b/tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts @@ -13,7 +13,7 @@ if (obj1 instanceof A) { // narrowed to A. } var obj2: any; -if (obj2 instanceof A) { // can't narrow type from 'any' +if (obj2 instanceof A) { obj2.foo; obj2.bar; } @@ -35,7 +35,7 @@ if (obj3 instanceof B) { // narrowed to B. } var obj4: any; -if (obj4 instanceof B) { // can't narrow type from 'any' +if (obj4 instanceof B) { obj4.foo = "str"; obj4.foo = 1; obj4.bar = "str"; @@ -67,7 +67,7 @@ if (obj5 instanceof C) { // narrowed to C1|C2. } var obj6: any; -if (obj6 instanceof C) { // can't narrow type from 'any' +if (obj6 instanceof C) { obj6.foo; obj6.bar1; obj6.bar2; @@ -86,7 +86,7 @@ if (obj7 instanceof D) { // narrowed to D. } var obj8: any; -if (obj8 instanceof D) { // can't narrow type from 'any' +if (obj8 instanceof D) { obj8.foo; obj8.bar; } @@ -113,7 +113,7 @@ if (obj9 instanceof E) { // narrowed to E1 | E2 } var obj10: any; -if (obj10 instanceof E) { // can't narrow type from 'any' +if (obj10 instanceof E) { obj10.foo; obj10.bar1; obj10.bar2; @@ -136,7 +136,7 @@ if (obj11 instanceof F) { // can't type narrowing, construct signature returns a } var obj12: any; -if (obj12 instanceof F) { // can't narrow type from 'any' +if (obj12 instanceof F) { obj12.foo; obj12.bar; } @@ -161,7 +161,7 @@ if (obj13 instanceof G) { // narrowed to G1. G1 is return type of prototype prop } var obj14: any; -if (obj14 instanceof G) { // can't narrow type from 'any' +if (obj14 instanceof G) { obj14.foo1; obj14.foo2; } @@ -183,7 +183,19 @@ if (obj15 instanceof H) { // narrowed to H. } var obj16: any; -if (obj16 instanceof H) { // can't narrow type from 'any' +if (obj16 instanceof H) { obj16.foo1; obj16.foo2; } + +var obj17: any; +if (obj17 instanceof Object) { // can't narrow type from 'any' to 'Object' + obj17.foo1; + obj17.foo2; +} + +var obj18: any; +if (obj18 instanceof Function) { // can't narrow type from 'any' to 'Function' + obj18.foo1; + obj18.foo2; +} diff --git a/tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts b/tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts index 6ad35658623..429289546c5 100644 --- a/tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts +++ b/tests/cases/conformance/externalModules/moduleResolutionWithExtensions.ts @@ -7,10 +7,6 @@ export default 0; // @Filename: /src/b.ts import a from './a'; -// Matching extension -// @Filename: /src/c.ts -import a from './a.ts'; - // '.js' extension: stripped and replaced with '.ts' // @Filename: /src/d.ts import a from './a.js'; diff --git a/tests/cases/conformance/jsdoc/jsdocLiteral.ts b/tests/cases/conformance/jsdoc/jsdocLiteral.ts new file mode 100644 index 00000000000..bd0d2d562f9 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocLiteral.ts @@ -0,0 +1,13 @@ +// @allowJs: true +// @filename: in.js +// @out: out.js +/** + * @param {'literal'} p1 + * @param {"literal"} p2 + * @param {'literal' | 'other'} p3 + * @param {'literal' | number} p4 + * @param {12 | true | 'str'} p5 + */ +function f(p1, p2, p3, p4, p5) { + return p1 + p2 + p3 + p4 + p5 + '.'; +} diff --git a/tests/cases/conformance/jsdoc/jsdocNeverUndefinedNull.ts b/tests/cases/conformance/jsdoc/jsdocNeverUndefinedNull.ts new file mode 100644 index 00000000000..c095bc1c920 --- /dev/null +++ b/tests/cases/conformance/jsdoc/jsdocNeverUndefinedNull.ts @@ -0,0 +1,11 @@ +// @allowJs: true +// @filename: in.js +// @out: out.js +/** + * @param {never} p1 + * @param {undefined} p2 + * @param {null} p3 + * @returns {void} nothing + */ +function f(p1, p2, p3) { +} diff --git a/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx b/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx new file mode 100644 index 00000000000..1e4418e7fba --- /dev/null +++ b/tests/cases/conformance/jsx/tsxAttributeResolution14.tsx @@ -0,0 +1,32 @@ +//@jsx: preserve +//@module: amd + +//@filename: react.d.ts +declare module JSX { + interface Element { } + interface IntrinsicElements { + div: any; + } + interface ElementAttributesProperty { prop: any } +} + +//@filename: file.tsx + +interface IProps { + primaryText: string, + [propName: string]: string | number +} + +function VerticalNavMenuItem(prop: IProps) { + return
props.primaryText
+} + +function VerticalNav() { + return ( +
+ // error + // ok + // error +
+ ) +} \ No newline at end of file diff --git a/tests/cases/conformance/salsa/multipleDeclarations.ts b/tests/cases/conformance/salsa/multipleDeclarations.ts index 6899be2ec89..ba2e14e11e9 100644 --- a/tests/cases/conformance/salsa/multipleDeclarations.ts +++ b/tests/cases/conformance/salsa/multipleDeclarations.ts @@ -1,10 +1,37 @@ // @filename: input.js // @out: output.js // @allowJs: true - function C() { this.m = null; } C.prototype.m = function() { this.nothing(); -}; +} +class X { + constructor() { + this.m = this.m.bind(this); + this.mistake = 'frankly, complete nonsense'; + } + m() { + } + mistake() { + } +} +let x = new X(); +X.prototype.mistake = false; +x.m(); +x.mistake; +class Y { + mistake() { + } + m() { + } + constructor() { + this.m = this.m.bind(this); + this.mistake = 'even more nonsense'; + } +} +Y.prototype.mistake = true; +let y = new Y(); +y.m(); +y.mistake(); diff --git a/tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts b/tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts new file mode 100644 index 00000000000..dfa60a415f9 --- /dev/null +++ b/tests/cases/conformance/types/any/narrowExceptionVariableInCatchClause.ts @@ -0,0 +1,23 @@ +declare function isFooError(x: any): x is { type: 'foo'; dontPanic(); }; + +function tryCatch() { + try { + // do stuff... + } + catch (err) { // err is implicitly 'any' and cannot be annotated + + if (isFooError(err)) { + err.dontPanic(); // OK + err.doPanic(); // ERROR: Property 'doPanic' does not exist on type '{...}' + } + + else if (err instanceof Error) { + err.message; + err.massage; // ERROR: Property 'massage' does not exist on type 'Error' + } + + else { + throw err; + } + } +} diff --git a/tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts b/tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts new file mode 100644 index 00000000000..4fbfc46060a --- /dev/null +++ b/tests/cases/conformance/types/any/narrowFromAnyWithInstanceof.ts @@ -0,0 +1,23 @@ +declare var x: any; + +if (x instanceof Function) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} + +if (x instanceof Object) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); +} + +if (x instanceof Error) { // 'any' is narrowed to types other than 'Function'/'Object' + x.message; + x.mesage; +} + +if (x instanceof Date) { + x.getDate(); + x.getHuors(); +} diff --git a/tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts b/tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts new file mode 100644 index 00000000000..473bd349b5f --- /dev/null +++ b/tests/cases/conformance/types/any/narrowFromAnyWithTypePredicate.ts @@ -0,0 +1,34 @@ +declare var x: any; +declare function isFunction(x): x is Function; +declare function isObject(x): x is Object; +declare function isAnything(x): x is {}; +declare function isError(x): x is Error; +declare function isDate(x): x is Date; + + +if (isFunction(x)) { // 'any' is not narrowed when target type is 'Function' + x(); + x(1, 2, 3); + x("hello!"); + x.prop; +} + +if (isObject(x)) { // 'any' is not narrowed when target type is 'Object' + x.method(); + x(); +} + +if (isAnything(x)) { // 'any' is narrowed to types other than 'Function'/'Object' (including {}) + x.method(); + x(); +} + +if (isError(x)) { + x.message; + x.mesage; +} + +if (isDate(x)) { + x.getDate(); + x.getHuors(); +} diff --git a/tests/cases/conformance/typings/typingsLookup2.ts b/tests/cases/conformance/typings/typingsLookup2.ts new file mode 100644 index 00000000000..90e1e463f0a --- /dev/null +++ b/tests/cases/conformance/typings/typingsLookup2.ts @@ -0,0 +1,13 @@ +// @traceResolution: true +// @noImplicitReferences: true +// @currentDirectory: / +// This tests that an @types package with `"typings": null` is not automatically included. +// (If it were, this test would break because there are no typings to be found.) + +// @filename: /tsconfig.json +{} + +// @filename: /node_modules/@types/angular2/package.json +{ "typings": null } + +// @filename: /a.ts diff --git a/tests/cases/conformance/typings/typingsLookup3.ts b/tests/cases/conformance/typings/typingsLookup3.ts new file mode 100644 index 00000000000..a0bb15476b9 --- /dev/null +++ b/tests/cases/conformance/typings/typingsLookup3.ts @@ -0,0 +1,14 @@ +// @traceResolution: true +// @noImplicitReferences: true +// @currentDirectory: / +// This tests that `types` references are automatically lowercased. + +// @filename: /tsconfig.json +{ "files": "a.ts" } + +// @filename: /node_modules/@types/jquery/index.d.ts +declare var $: { x: any }; + +// @filename: /a.ts +/// +$.x; diff --git a/tests/cases/conformance/typings/typingsLookup4.ts b/tests/cases/conformance/typings/typingsLookup4.ts new file mode 100644 index 00000000000..234090aebad --- /dev/null +++ b/tests/cases/conformance/typings/typingsLookup4.ts @@ -0,0 +1,31 @@ +// @traceResolution: true +// @noImplicitReferences: true +// @currentDirectory: / +// A file extension is optional in typings entries. + +// @filename: /tsconfig.json +{} + +// @filename: /node_modules/@types/jquery/package.json +{ "typings": "jquery.d.ts" } + +// @filename: /node_modules/@types/jquery/jquery.d.ts +export const j: number; + +// @filename: /node_modules/@types/kquery/package.json +{ "typings": "kquery" } + +// @filename: /node_modules/@types/kquery/kquery.d.ts +export const k: number; + +// @filename: /node_modules/@types/lquery/package.json +{ "typings": "lquery" } + +// @filename: /node_modules/@types/lquery/lquery.ts +export const l = 2; + +// @filename: /a.ts +import { j } from "jquery"; +import { k } from "kquery"; +import { l } from "lquery"; +j + k + l; diff --git a/tests/cases/fourslash/completionForStringLiteral4.ts b/tests/cases/fourslash/completionForStringLiteral4.ts new file mode 100644 index 00000000000..11ae699eab8 --- /dev/null +++ b/tests/cases/fourslash/completionForStringLiteral4.ts @@ -0,0 +1,23 @@ +/// +// @allowJs: true +// @Filename: in.js +/////** I am documentation +//// * @param {'literal'} p1 +//// * @param {"literal"} p2 +//// * @param {'other1' | 'other2'} p3 +//// * @param {'literal' | number} p4 +//// * @param {12 | true} p5 +//// */ +////function f(p1, p2, p3, p4, p5) { +//// return p1 + p2 + p3 + p4 + p5 + '.'; +////} +////f/*1*/('literal', 'literal', "o/*2*/ther1", 12); + +goTo.marker('1'); +verify.quickInfoExists(); +verify.quickInfoIs('function f(p1: "literal", p2: "literal", p3: "other1" | "other2", p4: number | "literal", p5: true | 12): string', 'I am documentation'); + +goTo.marker('2'); +verify.completionListContains("other1"); +verify.completionListContains("other2"); +verify.memberListCount(2); diff --git a/tests/cases/fourslash/completionListInObjectLiteral4.ts b/tests/cases/fourslash/completionListInObjectLiteral4.ts new file mode 100644 index 00000000000..c00462c8255 --- /dev/null +++ b/tests/cases/fourslash/completionListInObjectLiteral4.ts @@ -0,0 +1,28 @@ +/// + +// @strictNullChecks: true +////interface Thing { +//// hello: number; +//// world: string; +////} +//// +////declare function funcA(x : Thing): void; +////declare function funcB(x?: Thing): void; +////declare function funcC(x : Thing | null): void; +////declare function funcD(x : Thing | undefined): void; +////declare function funcE(x : Thing | null | undefined): void; +////declare function funcF(x?: Thing | null | undefined): void; +//// +////funcA({ /*A*/ }); +////funcB({ /*B*/ }); +////funcC({ /*C*/ }); +////funcD({ /*D*/ }); +////funcE({ /*E*/ }); +////funcF({ /*F*/ }); + + +for (const marker of test.markers()) { + goTo.position(marker.position); + verify.completionListContains("hello"); + verify.completionListContains("world"); +} diff --git a/tests/cases/fourslash/javaScriptClass1.ts b/tests/cases/fourslash/javaScriptClass1.ts new file mode 100644 index 00000000000..19f7a39b615 --- /dev/null +++ b/tests/cases/fourslash/javaScriptClass1.ts @@ -0,0 +1,31 @@ +/// + +// Classes have their shape inferred from assignments +// to properties of 'this' in the constructor + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// class Foo { +//// constructor() { +//// this.bar = 'world'; +//// this.thing = () => 0; +//// this.union = 'foo'; +//// this.union = 100; +//// } +//// } +//// var x = new Foo(); +//// x/**/ + + +goTo.marker(); +edit.insert('.'); +verify.completionListContains("bar", /*displayText*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("thing", /*displayText*/ undefined, /*documentation*/ undefined, "property"); +verify.completionListContains("union", /*displayText*/ undefined, /*documentation*/ undefined, "property"); + +edit.insert('bar.'); +verify.completionListContains("substr", /*displayText*/ undefined, /*documentation*/ undefined, "method"); +edit.backspace('bar.'.length); + +edit.insert('union.'); +verify.completionListContains("toString", /*displayText*/ undefined, /*documentation*/ undefined, "method"); \ No newline at end of file diff --git a/tests/cases/fourslash/javaScriptClass2.ts b/tests/cases/fourslash/javaScriptClass2.ts new file mode 100644 index 00000000000..d6daa320c5a --- /dev/null +++ b/tests/cases/fourslash/javaScriptClass2.ts @@ -0,0 +1,22 @@ +/// + +// In an inferred class, we can rename successfully + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// class Foo { +//// constructor() { +//// this.[|union|] = 'foo'; +//// this./*1*/[|union|] = 100; +//// } +//// method() { return this./*2*/[|union|]; } +//// } +//// var x = new Foo(); +//// x./*3*/[|union|]; + +goTo.marker('1'); +verify.renameLocations(/*findInStrings*/false, /*findInComments*/false); +goTo.marker('2'); +verify.renameLocations(/*findInStrings*/false, /*findInComments*/false); +goTo.marker('3'); +verify.renameLocations(/*findInStrings*/false, /*findInComments*/false); diff --git a/tests/cases/fourslash/javaScriptClass3.ts b/tests/cases/fourslash/javaScriptClass3.ts new file mode 100644 index 00000000000..47004d53b04 --- /dev/null +++ b/tests/cases/fourslash/javaScriptClass3.ts @@ -0,0 +1,24 @@ +/// + +// In an inferred class, we can to-to-def successfully + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// class Foo { +//// constructor() { +//// /*dst1*/this.alpha = 10; +//// /*dst2*/this.beta = 'gamma'; +//// } +//// method() { return this.alpha; } +//// } +//// var x = new Foo(); +//// x.alpha/*src1*/; +//// x.beta/*src2*/; + +goTo.marker('src1'); +goTo.definition(); +verify.caretAtMarker('dst1'); + +goTo.marker('src2'); +goTo.definition(); +verify.caretAtMarker('dst2'); diff --git a/tests/cases/fourslash/javaScriptClass4.ts b/tests/cases/fourslash/javaScriptClass4.ts new file mode 100644 index 00000000000..1148d5f320e --- /dev/null +++ b/tests/cases/fourslash/javaScriptClass4.ts @@ -0,0 +1,22 @@ +/// + +// Classes have their shape inferred from assignments +// to properties of 'this' in the constructor + +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// class Foo { +//// constructor() { +//// /** +//// * @type {string} +//// */ +//// this.baz = null; +//// } +//// } +//// var x = new Foo(); +//// x/**/ + +goTo.marker(); +edit.insert('.baz.'); +verify.completionListContains("substr", /*displayText*/ undefined, /*documentation*/ undefined, "method"); + diff --git a/tests/cases/fourslash/jsdocNullableUnion.ts b/tests/cases/fourslash/jsdocNullableUnion.ts new file mode 100644 index 00000000000..19dc9818d69 --- /dev/null +++ b/tests/cases/fourslash/jsdocNullableUnion.ts @@ -0,0 +1,23 @@ +/// +// @allowNonTsExtensions: true +// @Filename: Foo.js +//// +//// * @param {never | {x: string}} p1 +//// * @param {undefined | {y: number}} p2 +//// * @param {null | {z: boolean}} p3 +//// * @returns {void} nothing +//// */ +////function f(p1, p2, p3) { +//// p1./*1*/ +//// p2./*2*/ +//// p3./*3*/ +////} + +goTo.marker('1'); +verify.memberListContains("x"); + +goTo.marker('2'); +verify.memberListContains("y"); + +goTo.marker('3'); +verify.memberListContains("z"); diff --git a/tests/cases/fourslash/localGetReferences.ts b/tests/cases/fourslash/localGetReferences.ts index ada4947acde..b05346a366a 100644 --- a/tests/cases/fourslash/localGetReferences.ts +++ b/tests/cases/fourslash/localGetReferences.ts @@ -205,12 +205,13 @@ const rangesByText = test.rangesByText(); for (const text in rangesByText) { const ranges = rangesByText[text]; if (text === "globalVar") { - function isShadow(r) { - return r.marker && r.marker.data && r.marker.data.shadow; - } verify.rangesReferenceEachOther(ranges.filter(isShadow)); verify.rangesReferenceEachOther(ranges.filter(r => !isShadow(r))); } else { verify.rangesReferenceEachOther(ranges); } } + +function isShadow(r) { + return r.marker && r.marker.data && r.marker.data.shadow; +} diff --git a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts new file mode 100644 index 00000000000..243975fde2d --- /dev/null +++ b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles01.ts @@ -0,0 +1,20 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: a.js +//// /** +//// * Modify the parameter +//// * @param {string} p1 +//// */ +//// var foo = function (p1) { } +//// exports.foo = foo; +//// fo/*1*/ + +// @Filename: b.ts +//// import a = require("./a"); +//// a.fo/*2*/ + +goTo.marker('1'); +verify.completionEntryDetailIs("foo", "var foo: (p1: string) => void", "Modify the parameter"); +goTo.marker('2'); +verify.completionEntryDetailIs("foo", "(property) a.foo: (p1: string) => void", "Modify the parameter"); diff --git a/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts new file mode 100644 index 00000000000..2c5e53ea224 --- /dev/null +++ b/tests/cases/fourslash/server/completionEntryDetailAcrossFiles02.ts @@ -0,0 +1,20 @@ +/// + +// @allowNonTsExtensions: true +// @Filename: a.js +//// /** +//// * Modify the parameter +//// * @param {string} p1 +//// */ +//// var foo = function (p1) { } +//// module.exports.foo = foo; +//// fo/*1*/ + +// @Filename: b.ts +//// import a = require("./a"); +//// a.fo/*2*/ + +goTo.marker('1'); +verify.completionEntryDetailIs("foo", "var foo: (p1: string) => void", "Modify the parameter"); +goTo.marker('2'); +verify.completionEntryDetailIs("foo", "(property) a.foo: (p1: string) => void", "Modify the parameter"); diff --git a/tests/cases/fourslash/syntacticClassificationsDocComment4.ts b/tests/cases/fourslash/syntacticClassificationsDocComment4.ts new file mode 100644 index 00000000000..d8ac2f12d8b --- /dev/null +++ b/tests/cases/fourslash/syntacticClassificationsDocComment4.ts @@ -0,0 +1,24 @@ +/// + +//// /** @param {number} p1 */ +//// function foo(p1) {} + +var c = classification; +verify.syntacticClassificationsAre( + c.comment("/** "), + c.punctuation("@"), + c.docCommentTagName("param"), + c.comment(" "), + c.punctuation("{"), + c.keyword("number"), + c.punctuation("}"), + c.comment(" "), + c.parameterName("p1"), + c.comment(" */"), + c.keyword("function"), + c.identifier("foo"), + c.punctuation("("), + c.parameterName("p1"), + c.punctuation(")"), + c.punctuation("{"), + c.punctuation("}")); diff --git a/tests/webTestServer.ts b/tests/webTestServer.ts index f7b1437d9ff..97027dfdd49 100644 --- a/tests/webTestServer.ts +++ b/tests/webTestServer.ts @@ -152,19 +152,21 @@ function handleResolutionRequest(filePath: string, res: http.ServerResponse) { let resolvedPath = path.resolve(filePath, ""); resolvedPath = resolvedPath.substring(resolvedPath.indexOf("tests")); resolvedPath = switchToForwardSlashes(resolvedPath); - send("success", res, resolvedPath, "text/javascript"); - return; + send(ResponseCode.Success, res, resolvedPath); } -function send(result: "fail", res: http.ServerResponse, contents: string, contentType?: string): void; -function send(result: "success", res: http.ServerResponse, contents: string, contentType?: string): void; -function send(result: "unknown", res: http.ServerResponse, contents: string, contentType?: string): void; -function send(result: string, res: http.ServerResponse, contents: string, contentType?: string): void -function send(result: string, res: http.ServerResponse, contents: string, contentType = "binary"): void { - const responseCode = result === "success" ? 200 : result === "fail" ? 500 : result === "unknown" ? 404 : parseInt(result); +const enum ResponseCode { + Success = 200, + BadRequest = 400, + NotFound = 404, + MethodNotAllowed = 405, + PayloadTooLarge = 413, + Fail = 500 +} + +function send(responseCode: number, res: http.ServerResponse, contents: string, contentType = "binary"): void { res.writeHead(responseCode, { "Content-Type": contentType }); res.end(contents); - return; } // Reads the data from a post request and passes it to the given callback @@ -177,7 +179,7 @@ function processPost(req: http.ServerRequest, res: http.ServerResponse, callback queryData += data; if (queryData.length > 1e8) { queryData = ""; - send("413", res, undefined); + send(ResponseCode.PayloadTooLarge, res, undefined); console.log("ERROR: destroying connection"); req.connection.destroy(); } @@ -190,7 +192,7 @@ function processPost(req: http.ServerRequest, res: http.ServerResponse, callback } else { - send("405", res, undefined); + send(ResponseCode.MethodNotAllowed, res, undefined); } } @@ -237,16 +239,16 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons switch (operation) { case RequestType.GetDir: const filesInFolder = dir(reqPath, "", { recursive: true }); - send("success", res, filesInFolder.join(",")); + send(ResponseCode.Success, res, filesInFolder.join(",")); break; case RequestType.GetFile: fs.readFile(reqPath, (err, file) => { const contentType = contentTypeForExtension(path.extname(reqPath)); if (err) { - send("fail", res, err.message, contentType); + send(ResponseCode.NotFound, res, err.message, contentType); } else { - send("success", res, file, contentType); + send(ResponseCode.Success, res, file, contentType); } }); break; @@ -258,33 +260,33 @@ function handleRequestOperation(req: http.ServerRequest, res: http.ServerRespons processPost(req, res, (data) => { writeFile(reqPath, data, { recursive: true }); }); - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.WriteDir: - ensureDirectoriesExist(reqPath); - send("success", res, undefined); + fs.mkdirSync(reqPath); + send(ResponseCode.Success, res, undefined); break; case RequestType.DeleteFile: if (fs.existsSync(reqPath)) { fs.unlinkSync(reqPath); } - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.DeleteDir: if (fs.existsSync(reqPath)) { fs.rmdirSync(reqPath); } - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.AppendFile: processPost(req, res, (data) => { fs.appendFileSync(reqPath, data); }); - send("success", res, undefined); + send(ResponseCode.Success, res, undefined); break; case RequestType.Unknown: default: - send("unknown", res, undefined); + send(ResponseCode.BadRequest, res, undefined); break; } diff --git a/tslint.json b/tslint.json index a46e58f8c29..f058eab3dd6 100644 --- a/tslint.json +++ b/tslint.json @@ -32,7 +32,7 @@ "property-declaration": "nospace", "variable-declaration": "nospace" }], - "next-line": [true, + "next-line": [true, "check-catch", "check-else" ], @@ -44,7 +44,6 @@ "boolean-trivia": true, "type-operator-spacing": true, "prefer-const": true, - "no-in-operator": true, "no-increment-decrement": true, "object-literal-surrounding-space": true, "no-type-assertion-whitespace": true From e62f1181b6a94161f8bfa88a84c2cf4c0f66bc3a Mon Sep 17 00:00:00 2001 From: Yui Date: Fri, 26 Aug 2016 16:46:10 -0700 Subject: [PATCH 281/508] fix typo of missing node.kind (#10569) --- src/compiler/emitter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index d0f7918dc89..f02cf266744 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -6587,7 +6587,7 @@ const _super = (function (geti, seti) { // import { x, y } from "foo" // import d, * as x from "foo" // import d, { x, y } from "foo" - const isNakedImport = SyntaxKind.ImportDeclaration && !(node).importClause; + const isNakedImport = node.kind === SyntaxKind.ImportDeclaration && !(node).importClause; if (!isNakedImport) { write(varOrConst); write(getGeneratedNameForNode(node)); From d72ed3c0b0fcf1f3c5f2b06d430c5e9c2ea6ca6f Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 26 Aug 2016 16:52:25 -0700 Subject: [PATCH 282/508] Check for this symbol before getting display parts --- src/services/services.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index dd99c0dba52..c19eb487d75 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6570,8 +6570,8 @@ namespace ts { const thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - const { displayParts } = getSymbolDisplayPartsDocumentationAndSymbolKind( - thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword); + const displayParts = thisOrSuperSymbol && getSymbolDisplayPartsDocumentationAndSymbolKind( + thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; return [{ definition: { From fb6ff42b93d46c33ff9439ca392b36511e95093d Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Fri, 26 Aug 2016 18:03:20 -0700 Subject: [PATCH 283/508] Reuse effective type roots code in language service --- src/compiler/program.ts | 11 ++++------- src/services/services.ts | 15 ++++----------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index f48f29785d9..7048496ada1 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -168,22 +168,19 @@ namespace ts { const typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) { + export function getEffectiveTypeRoots(options: CompilerOptions, currentDirectory: string) { if (options.typeRoots) { return options.typeRoots; } - let currentDirectory: string; if (options.configFilePath) { currentDirectory = getDirectoryPath(options.configFilePath); } - else if (host.getCurrentDirectory) { - currentDirectory = host.getCurrentDirectory(); - } if (!currentDirectory) { return undefined; } + return map(defaultTypeRoots, d => combinePaths(currentDirectory, d)); } @@ -201,7 +198,7 @@ namespace ts { traceEnabled }; - const typeRoots = getEffectiveTypeRoots(options, host); + const typeRoots = getEffectiveTypeRoots(options, host.getCurrentDirectory && host.getCurrentDirectory()); if (traceEnabled) { if (containingFile === undefined) { if (typeRoots === undefined) { @@ -1061,7 +1058,7 @@ namespace ts { // Walk the primary type lookup locations const result: string[] = []; if (host.directoryExists && host.getDirectories) { - const typeRoots = getEffectiveTypeRoots(options, host); + const typeRoots = getEffectiveTypeRoots(options, host.getCurrentDirectory && host.getCurrentDirectory()); if (typeRoots) { for (const root of typeRoots) { if (host.directoryExists(root)) { diff --git a/src/services/services.ts b/src/services/services.ts index 8bb378e090a..519a5abe8cf 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4846,17 +4846,10 @@ namespace ts { result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); } } - else if (host.getDirectories && options.typeRoots) { - const absoluteRoots = map(options.typeRoots, rootDirectory => { - if (isRootedDiskPath(rootDirectory)) { - return normalizePath(rootDirectory); - } - - const basePath = options.project || host.getCurrentDirectory(); - return normalizePath(combinePaths(basePath, rootDirectory)); - }); - for (const absoluteRoot of absoluteRoots) { - getCompletionEntriesFromDirectories(host, options, absoluteRoot, result); + else if (host.getDirectories) { + const typeRoots = getEffectiveTypeRoots(options, host.getCurrentDirectory()); + for (const root of typeRoots) { + getCompletionEntriesFromDirectories(host, options, root, result); } } From 28371b1fe4d3fc2166d5ae7b7cc4d31e73bdc7a9 Mon Sep 17 00:00:00 2001 From: Yuichi Nukiyama Date: Sat, 27 Aug 2016 11:56:16 +0900 Subject: [PATCH 284/508] Change error message which warn unexposed namespace member --- src/compiler/checker.ts | 2 +- src/compiler/diagnosticMessages.json | 4 + tests/baselines/reference/aliasBug.errors.txt | 4 +- .../reference/aliasErrors.errors.txt | 4 +- .../reference/bluebirdStaticThis.errors.txt | 20 +- .../reference/complicatedPrivacy.errors.txt | 4 +- ...ierReferencingOuterDeclaration3.errors.txt | 4 +- ...ierReferencingOuterDeclaration4.errors.txt | 4 +- .../genericFunduleInModule.errors.txt | 4 +- .../genericFunduleInModule2.errors.txt | 4 +- ...peReferenceWithoutTypeArgument2.errors.txt | 4 +- .../reference/importAnImport.errors.txt | 4 +- .../importDeclWithClassModifiers.errors.txt | 12 +- .../importDeclWithDeclareModifier.errors.txt | 4 +- .../importDeclWithExportModifier.errors.txt | 4 +- ...portModifierAndExportAssignment.errors.txt | 4 +- .../reference/innerAliases.errors.txt | 4 +- ...lModuleWithoutExportAccessError.errors.txt | 4 +- ...lModuleWithoutExportAccessError.errors.txt | 4 +- .../moduleClassArrayCodeGenTest.errors.txt | 4 +- .../reference/moduleImport.errors.txt | 6 +- .../reference/moduleNewExportBug.errors.txt | 4 +- .../moduleVisibilityTest2.errors.txt | 8 +- .../moduleVisibilityTest3.errors.txt | 8 +- .../reference/namespacesDeclaration1.js | 22 ++ .../reference/namespacesDeclaration1.symbols | 16 + .../reference/namespacesDeclaration1.types | 16 + .../namespacesDeclaration2.errors.txt | 27 ++ .../reference/namespacesDeclaration2.js | 42 +++ .../reference/parserRealSource14.errors.txt | 288 +++++++++--------- .../reference/parserharness.errors.txt | 4 +- .../reference/sourceMapSample.errors.txt | 4 +- ...claration.ts => namespacesDeclaration1.ts} | 0 .../cases/compiler/namespacesDeclaration2.ts | 16 + 34 files changed, 353 insertions(+), 210 deletions(-) create mode 100644 tests/baselines/reference/namespacesDeclaration1.js create mode 100644 tests/baselines/reference/namespacesDeclaration1.symbols create mode 100644 tests/baselines/reference/namespacesDeclaration1.types create mode 100644 tests/baselines/reference/namespacesDeclaration2.errors.txt create mode 100644 tests/baselines/reference/namespacesDeclaration2.js rename tests/cases/compiler/{namespacesDeclaration.ts => namespacesDeclaration1.ts} (100%) create mode 100644 tests/cases/compiler/namespacesDeclaration2.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c1e401912d..026e0c57046 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1300,7 +1300,7 @@ namespace ts { symbol = getSymbol(getExportsOfSymbol(namespace), right.text, meaning); if (!symbol) { if (!ignoreErrors) { - error(right, Diagnostics.Module_0_has_no_exported_member_1, getFullyQualifiedName(namespace), declarationNameToString(right)); + error(right, Diagnostics.Module_or_namespace_0_has_no_exported_member_1, getFullyQualifiedName(namespace), declarationNameToString(right)); } return undefined; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b8978b32571..ce205039bda 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1959,6 +1959,10 @@ "category": "Error", "code": 2692 }, + "Module or namespace '{0}' has no exported member '{1}'.": { + "category": "Error", + "code": 2693 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", "code": 4000 diff --git a/tests/baselines/reference/aliasBug.errors.txt b/tests/baselines/reference/aliasBug.errors.txt index 398b093aa88..1d861fcb50b 100644 --- a/tests/baselines/reference/aliasBug.errors.txt +++ b/tests/baselines/reference/aliasBug.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/aliasBug.ts(17,15): error TS2305: Module 'foo.bar.baz' has no exported member 'bar'. +tests/cases/compiler/aliasBug.ts(17,15): error TS2693: Module or namespace 'foo.bar.baz' has no exported member 'bar'. ==== tests/cases/compiler/aliasBug.ts (1 errors) ==== @@ -20,7 +20,7 @@ tests/cases/compiler/aliasBug.ts(17,15): error TS2305: Module 'foo.bar.baz' has var p2: foo.Provide; var p3:booz.bar; ~~~ -!!! error TS2305: Module 'foo.bar.baz' has no exported member 'bar'. +!!! error TS2693: Module or namespace 'foo.bar.baz' has no exported member 'bar'. var p22 = new provide.Provide(); } \ No newline at end of file diff --git a/tests/baselines/reference/aliasErrors.errors.txt b/tests/baselines/reference/aliasErrors.errors.txt index c74649618ba..740655cb86d 100644 --- a/tests/baselines/reference/aliasErrors.errors.txt +++ b/tests/baselines/reference/aliasErrors.errors.txt @@ -4,7 +4,7 @@ tests/cases/compiler/aliasErrors.ts(13,12): error TS1003: Identifier expected. tests/cases/compiler/aliasErrors.ts(14,12): error TS1003: Identifier expected. tests/cases/compiler/aliasErrors.ts(15,12): error TS1003: Identifier expected. tests/cases/compiler/aliasErrors.ts(16,12): error TS2503: Cannot find namespace 'undefined'. -tests/cases/compiler/aliasErrors.ts(26,15): error TS2305: Module 'foo.bar.baz' has no exported member 'bar'. +tests/cases/compiler/aliasErrors.ts(26,15): error TS2693: Module or namespace 'foo.bar.baz' has no exported member 'bar'. ==== tests/cases/compiler/aliasErrors.ts (7 errors) ==== @@ -47,7 +47,7 @@ tests/cases/compiler/aliasErrors.ts(26,15): error TS2305: Module 'foo.bar.baz' h var p2: foo.Provide; var p3:booz.bar; ~~~ -!!! error TS2305: Module 'foo.bar.baz' has no exported member 'bar'. +!!! error TS2693: Module or namespace 'foo.bar.baz' has no exported member 'bar'. var p22 = new provide.Provide(); } diff --git a/tests/baselines/reference/bluebirdStaticThis.errors.txt b/tests/baselines/reference/bluebirdStaticThis.errors.txt index 6e78a90db4b..5c6086dde4c 100644 --- a/tests/baselines/reference/bluebirdStaticThis.errors.txt +++ b/tests/baselines/reference/bluebirdStaticThis.errors.txt @@ -1,10 +1,10 @@ tests/cases/compiler/bluebirdStaticThis.ts(5,15): error TS2420: Class 'Promise' incorrectly implements interface 'Thenable'. Property 'then' is missing in type 'Promise'. -tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2305: Module 'Promise' has no exported member 'Resolver'. -tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2305: Module 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2305: Module 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2305: Module 'Promise' has no exported member 'Inspection'. -tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2305: Module 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(22,51): error TS2693: Module or namespace 'Promise' has no exported member 'Resolver'. +tests/cases/compiler/bluebirdStaticThis.ts(57,109): error TS2693: Module or namespace 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(58,91): error TS2693: Module or namespace 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(59,91): error TS2693: Module or namespace 'Promise' has no exported member 'Inspection'. +tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2693: Module or namespace 'Promise' has no exported member 'Inspection'. ==== tests/cases/compiler/bluebirdStaticThis.ts (6 errors) ==== @@ -34,7 +34,7 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2305: Module 'Promise static defer(dit: typeof Promise): Promise.Resolver; ~~~~~~~~ -!!! error TS2305: Module 'Promise' has no exported member 'Resolver'. +!!! error TS2693: Module or namespace 'Promise' has no exported member 'Resolver'. static cast(dit: typeof Promise, value: Promise.Thenable): Promise; static cast(dit: typeof Promise, value: R): Promise; @@ -71,16 +71,16 @@ tests/cases/compiler/bluebirdStaticThis.ts(60,73): error TS2305: Module 'Promise static settle(dit: typeof Promise, values: Promise.Thenable[]>): Promise[]>; ~~~~~~~~~~ -!!! error TS2305: Module 'Promise' has no exported member 'Inspection'. +!!! error TS2693: Module or namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable): Promise[]>; ~~~~~~~~~~ -!!! error TS2305: Module 'Promise' has no exported member 'Inspection'. +!!! error TS2693: Module or namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: Promise.Thenable[]): Promise[]>; ~~~~~~~~~~ -!!! error TS2305: Module 'Promise' has no exported member 'Inspection'. +!!! error TS2693: Module or namespace 'Promise' has no exported member 'Inspection'. static settle(dit: typeof Promise, values: R[]): Promise[]>; ~~~~~~~~~~ -!!! error TS2305: Module 'Promise' has no exported member 'Inspection'. +!!! error TS2693: Module or namespace 'Promise' has no exported member 'Inspection'. static any(dit: typeof Promise, values: Promise.Thenable[]>): Promise; static any(dit: typeof Promise, values: Promise.Thenable): Promise; diff --git a/tests/baselines/reference/complicatedPrivacy.errors.txt b/tests/baselines/reference/complicatedPrivacy.errors.txt index 2ba3abbab8a..00966025f50 100644 --- a/tests/baselines/reference/complicatedPrivacy.errors.txt +++ b/tests/baselines/reference/complicatedPrivacy.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/complicatedPrivacy.ts(11,24): error TS1054: A 'get' accessor cannot have parameters. tests/cases/compiler/complicatedPrivacy.ts(35,5): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. tests/cases/compiler/complicatedPrivacy.ts(35,6): error TS2304: Cannot find name 'number'. -tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2305: Module 'mglo5' has no exported member 'i6'. +tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2693: Module or namespace 'mglo5' has no exported member 'i6'. ==== tests/cases/compiler/complicatedPrivacy.ts (4 errors) ==== @@ -85,7 +85,7 @@ tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2305: Module 'mglo5' export class c_pr implements mglo5.i5, mglo5.i6 { ~~ -!!! error TS2305: Module 'mglo5' has no exported member 'i6'. +!!! error TS2693: Module or namespace 'mglo5' has no exported member 'i6'. f1() { return "Hello"; } diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt index e144c48bea4..7d0a6890b25 100644 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts(6,30): error TS2305: Module 'X' has no exported member 'bar'. +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts(6,30): error TS2693: Module or namespace 'X' has no exported member 'bar'. ==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/compiler/exportSpecifierReferencingOuterDeclaration3.ts(6,30): error export function foo(): X.foo; export function bar(): X.bar; // error ~~~ -!!! error TS2305: Module 'X' has no exported member 'bar'. +!!! error TS2693: Module or namespace 'X' has no exported member 'bar'. } \ No newline at end of file diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt index 6ac67c70d17..3946a230194 100644 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts(4,34): error TS2305: Module 'X' has no exported member 'bar'. +tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts(4,34): error TS2693: Module or namespace 'X' has no exported member 'bar'. ==== tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_A.ts (0 errors) ==== @@ -10,4 +10,4 @@ tests/cases/compiler/exportSpecifierReferencingOuterDeclaration2_B.ts(4,34): err export declare function foo(): X.foo; export declare function bar(): X.bar; // error ~~~ -!!! error TS2305: Module 'X' has no exported member 'bar'. \ No newline at end of file +!!! error TS2693: Module or namespace 'X' has no exported member 'bar'. \ No newline at end of file diff --git a/tests/baselines/reference/genericFunduleInModule.errors.txt b/tests/baselines/reference/genericFunduleInModule.errors.txt index 752517667b0..a911bb6b5fa 100644 --- a/tests/baselines/reference/genericFunduleInModule.errors.txt +++ b/tests/baselines/reference/genericFunduleInModule.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericFunduleInModule.ts(8,10): error TS2305: Module 'A' has no exported member 'B'. +tests/cases/compiler/genericFunduleInModule.ts(8,10): error TS2693: Module or namespace 'A' has no exported member 'B'. ==== tests/cases/compiler/genericFunduleInModule.ts (1 errors) ==== @@ -11,5 +11,5 @@ tests/cases/compiler/genericFunduleInModule.ts(8,10): error TS2305: Module 'A' h var b: A.B; ~ -!!! error TS2305: Module 'A' has no exported member 'B'. +!!! error TS2693: Module or namespace 'A' has no exported member 'B'. A.B(1); \ No newline at end of file diff --git a/tests/baselines/reference/genericFunduleInModule2.errors.txt b/tests/baselines/reference/genericFunduleInModule2.errors.txt index 156549e8190..d9b8b2ce205 100644 --- a/tests/baselines/reference/genericFunduleInModule2.errors.txt +++ b/tests/baselines/reference/genericFunduleInModule2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericFunduleInModule2.ts(11,10): error TS2305: Module 'A' has no exported member 'B'. +tests/cases/compiler/genericFunduleInModule2.ts(11,10): error TS2693: Module or namespace 'A' has no exported member 'B'. ==== tests/cases/compiler/genericFunduleInModule2.ts (1 errors) ==== @@ -14,5 +14,5 @@ tests/cases/compiler/genericFunduleInModule2.ts(11,10): error TS2305: Module 'A' var b: A.B; ~ -!!! error TS2305: Module 'A' has no exported member 'B'. +!!! error TS2693: Module or namespace 'A' has no exported member 'B'. A.B(1); \ No newline at end of file diff --git a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt index b6767a3b938..b7cbdfe938c 100644 --- a/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt +++ b/tests/baselines/reference/genericTypeReferenceWithoutTypeArgument2.errors.txt @@ -17,7 +17,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(23,21): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(29,18): error TS2304: Cannot find name 'M'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(30,24): error TS2314: Generic type 'E' requires 1 type argument(s). -tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(31,24): error TS2305: Module 'M' has no exported member 'C'. +tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(31,24): error TS2693: Module or namespace 'M' has no exported member 'C'. tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(33,22): error TS2314: Generic type 'I' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(34,22): error TS2314: Generic type 'E' requires 1 type argument(s). tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenceWithoutTypeArgument2.ts(36,10): error TS2304: Cannot find name 'C'. @@ -95,7 +95,7 @@ tests/cases/conformance/types/specifyingTypes/typeReferences/genericTypeReferenc !!! error TS2314: Generic type 'E' requires 1 type argument(s). interface I2 extends M.C { } ~ -!!! error TS2305: Module 'M' has no exported member 'C'. +!!! error TS2693: Module or namespace 'M' has no exported member 'C'. function h(x: T) { } ~ diff --git a/tests/baselines/reference/importAnImport.errors.txt b/tests/baselines/reference/importAnImport.errors.txt index 5f79b21f375..5dc5afb4587 100644 --- a/tests/baselines/reference/importAnImport.errors.txt +++ b/tests/baselines/reference/importAnImport.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/importAnImport.ts(6,23): error TS2305: Module 'c.a.b' has no exported member 'ma'. +tests/cases/compiler/importAnImport.ts(6,23): error TS2693: Module or namespace 'c.a.b' has no exported member 'ma'. ==== tests/cases/compiler/importAnImport.ts (1 errors) ==== @@ -9,5 +9,5 @@ tests/cases/compiler/importAnImport.ts(6,23): error TS2305: Module 'c.a.b' has n module m0 { import m8 = c.a.b.ma; ~~ -!!! error TS2305: Module 'c.a.b' has no exported member 'ma'. +!!! error TS2693: Module or namespace 'c.a.b' has no exported member 'ma'. } \ No newline at end of file diff --git a/tests/baselines/reference/importDeclWithClassModifiers.errors.txt b/tests/baselines/reference/importDeclWithClassModifiers.errors.txt index 1116741818b..ef903574b7f 100644 --- a/tests/baselines/reference/importDeclWithClassModifiers.errors.txt +++ b/tests/baselines/reference/importDeclWithClassModifiers.errors.txt @@ -1,12 +1,12 @@ tests/cases/compiler/importDeclWithClassModifiers.ts(5,8): error TS1044: 'public' modifier cannot appear on a module or namespace element. tests/cases/compiler/importDeclWithClassModifiers.ts(5,26): error TS2304: Cannot find name 'x'. -tests/cases/compiler/importDeclWithClassModifiers.ts(5,28): error TS2305: Module 'x' has no exported member 'c'. +tests/cases/compiler/importDeclWithClassModifiers.ts(5,28): error TS2693: Module or namespace 'x' has no exported member 'c'. tests/cases/compiler/importDeclWithClassModifiers.ts(6,8): error TS1044: 'private' modifier cannot appear on a module or namespace element. tests/cases/compiler/importDeclWithClassModifiers.ts(6,27): error TS2304: Cannot find name 'x'. -tests/cases/compiler/importDeclWithClassModifiers.ts(6,29): error TS2305: Module 'x' has no exported member 'c'. +tests/cases/compiler/importDeclWithClassModifiers.ts(6,29): error TS2693: Module or namespace 'x' has no exported member 'c'. tests/cases/compiler/importDeclWithClassModifiers.ts(7,8): error TS1044: 'static' modifier cannot appear on a module or namespace element. tests/cases/compiler/importDeclWithClassModifiers.ts(7,26): error TS2304: Cannot find name 'x'. -tests/cases/compiler/importDeclWithClassModifiers.ts(7,28): error TS2305: Module 'x' has no exported member 'c'. +tests/cases/compiler/importDeclWithClassModifiers.ts(7,28): error TS2693: Module or namespace 'x' has no exported member 'c'. ==== tests/cases/compiler/importDeclWithClassModifiers.ts (9 errors) ==== @@ -20,20 +20,20 @@ tests/cases/compiler/importDeclWithClassModifiers.ts(7,28): error TS2305: Module ~ !!! error TS2304: Cannot find name 'x'. ~ -!!! error TS2305: Module 'x' has no exported member 'c'. +!!! error TS2693: Module or namespace 'x' has no exported member 'c'. export private import b = x.c; ~~~~~~~ !!! error TS1044: 'private' modifier cannot appear on a module or namespace element. ~ !!! error TS2304: Cannot find name 'x'. ~ -!!! error TS2305: Module 'x' has no exported member 'c'. +!!! error TS2693: Module or namespace 'x' has no exported member 'c'. export static import c = x.c; ~~~~~~ !!! error TS1044: 'static' modifier cannot appear on a module or namespace element. ~ !!! error TS2304: Cannot find name 'x'. ~ -!!! error TS2305: Module 'x' has no exported member 'c'. +!!! error TS2693: Module or namespace 'x' has no exported member 'c'. var b: a; \ No newline at end of file diff --git a/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt b/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt index 8de1a1cea68..a49ab9a1053 100644 --- a/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt +++ b/tests/baselines/reference/importDeclWithDeclareModifier.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/importDeclWithDeclareModifier.ts(5,9): error TS1029: 'export' modifier must precede 'declare' modifier. tests/cases/compiler/importDeclWithDeclareModifier.ts(5,27): error TS2304: Cannot find name 'x'. -tests/cases/compiler/importDeclWithDeclareModifier.ts(5,29): error TS2305: Module 'x' has no exported member 'c'. +tests/cases/compiler/importDeclWithDeclareModifier.ts(5,29): error TS2693: Module or namespace 'x' has no exported member 'c'. ==== tests/cases/compiler/importDeclWithDeclareModifier.ts (3 errors) ==== @@ -14,6 +14,6 @@ tests/cases/compiler/importDeclWithDeclareModifier.ts(5,29): error TS2305: Modul ~ !!! error TS2304: Cannot find name 'x'. ~ -!!! error TS2305: Module 'x' has no exported member 'c'. +!!! error TS2693: Module or namespace 'x' has no exported member 'c'. var b: a; \ No newline at end of file diff --git a/tests/baselines/reference/importDeclWithExportModifier.errors.txt b/tests/baselines/reference/importDeclWithExportModifier.errors.txt index b20896ec6e7..d488cd6a0ce 100644 --- a/tests/baselines/reference/importDeclWithExportModifier.errors.txt +++ b/tests/baselines/reference/importDeclWithExportModifier.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/importDeclWithExportModifier.ts(5,19): error TS2304: Cannot find name 'x'. -tests/cases/compiler/importDeclWithExportModifier.ts(5,21): error TS2305: Module 'x' has no exported member 'c'. +tests/cases/compiler/importDeclWithExportModifier.ts(5,21): error TS2693: Module or namespace 'x' has no exported member 'c'. ==== tests/cases/compiler/importDeclWithExportModifier.ts (2 errors) ==== @@ -11,6 +11,6 @@ tests/cases/compiler/importDeclWithExportModifier.ts(5,21): error TS2305: Module ~ !!! error TS2304: Cannot find name 'x'. ~ -!!! error TS2305: Module 'x' has no exported member 'c'. +!!! error TS2693: Module or namespace 'x' has no exported member 'c'. var b: a; \ No newline at end of file diff --git a/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.errors.txt b/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.errors.txt index d5c2f2b9712..78c65e8b266 100644 --- a/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.errors.txt +++ b/tests/baselines/reference/importDeclWithExportModifierAndExportAssignment.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(5,19): error TS2304: Cannot find name 'x'. -tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(5,21): error TS2305: Module 'x' has no exported member 'c'. +tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(5,21): error TS2693: Module or namespace 'x' has no exported member 'c'. tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. @@ -12,7 +12,7 @@ tests/cases/compiler/importDeclWithExportModifierAndExportAssignment.ts(6,1): er ~ !!! error TS2304: Cannot find name 'x'. ~ -!!! error TS2305: Module 'x' has no exported member 'c'. +!!! error TS2693: Module or namespace 'x' has no exported member 'c'. export = x; ~~~~~~~~~~~ !!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/tests/baselines/reference/innerAliases.errors.txt b/tests/baselines/reference/innerAliases.errors.txt index e4699c0825b..c712b433a5b 100644 --- a/tests/baselines/reference/innerAliases.errors.txt +++ b/tests/baselines/reference/innerAliases.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/innerAliases.ts(19,10): error TS2305: Module 'D' has no exported member 'inner'. +tests/cases/compiler/innerAliases.ts(19,10): error TS2693: Module or namespace 'D' has no exported member 'inner'. tests/cases/compiler/innerAliases.ts(21,11): error TS2339: Property 'inner' does not exist on type 'typeof D'. @@ -23,7 +23,7 @@ tests/cases/compiler/innerAliases.ts(21,11): error TS2339: Property 'inner' does var c: D.inner.Class1; ~~~~~ -!!! error TS2305: Module 'D' has no exported member 'inner'. +!!! error TS2693: Module or namespace 'D' has no exported member 'inner'. c = new D.inner.Class1(); ~~~~~ diff --git a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt index 7bd34f1d5d3..7b8793b3693 100644 --- a/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt +++ b/tests/baselines/reference/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(11,10): error TS2305: Module '"tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. +tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts(11,10): error TS2693: Module or namespace '"tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. ==== tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError.ts (1 errors) ==== @@ -14,4 +14,4 @@ tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessE var x: c.b; ~ -!!! error TS2305: Module '"tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. \ No newline at end of file +!!! error TS2693: Module or namespace '"tests/cases/compiler/internalAliasInterfaceInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt index 865929890c0..72a13b5fc10 100644 --- a/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt +++ b/tests/baselines/reference/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(16,17): error TS2305: Module '"tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. +tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts(16,17): error TS2693: Module or namespace '"tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. ==== tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError.ts (1 errors) ==== @@ -19,4 +19,4 @@ tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExp export var z: c.b.I; ~ -!!! error TS2305: Module '"tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. \ No newline at end of file +!!! error TS2693: Module or namespace '"tests/cases/compiler/internalAliasUninitializedModuleInsideLocalModuleWithoutExportAccessError".c' has no exported member 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/moduleClassArrayCodeGenTest.errors.txt b/tests/baselines/reference/moduleClassArrayCodeGenTest.errors.txt index 702beffa290..40e5ad41271 100644 --- a/tests/baselines/reference/moduleClassArrayCodeGenTest.errors.txt +++ b/tests/baselines/reference/moduleClassArrayCodeGenTest.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/moduleClassArrayCodeGenTest.ts(10,11): error TS2305: Module 'M' has no exported member 'B'. +tests/cases/compiler/moduleClassArrayCodeGenTest.ts(10,11): error TS2693: Module or namespace 'M' has no exported member 'B'. ==== tests/cases/compiler/moduleClassArrayCodeGenTest.ts (1 errors) ==== @@ -13,4 +13,4 @@ tests/cases/compiler/moduleClassArrayCodeGenTest.ts(10,11): error TS2305: Module var t: M.A[] = []; var t2: M.B[] = []; ~ -!!! error TS2305: Module 'M' has no exported member 'B'. \ No newline at end of file +!!! error TS2693: Module or namespace 'M' has no exported member 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/moduleImport.errors.txt b/tests/baselines/reference/moduleImport.errors.txt index 7b18c80ba24..39bee6c4314 100644 --- a/tests/baselines/reference/moduleImport.errors.txt +++ b/tests/baselines/reference/moduleImport.errors.txt @@ -1,14 +1,14 @@ -tests/cases/compiler/moduleImport.ts(2,17): error TS2305: Module 'X' has no exported member 'Y'. tests/cases/compiler/moduleImport.ts(2,17): error TS2339: Property 'Y' does not exist on type 'typeof X'. +tests/cases/compiler/moduleImport.ts(2,17): error TS2693: Module or namespace 'X' has no exported member 'Y'. ==== tests/cases/compiler/moduleImport.ts (2 errors) ==== module A.B.C { import XYZ = X.Y.Z; ~ -!!! error TS2305: Module 'X' has no exported member 'Y'. - ~ !!! error TS2339: Property 'Y' does not exist on type 'typeof X'. + ~ +!!! error TS2693: Module or namespace 'X' has no exported member 'Y'. export function ping(x: number) { if (x>0) XYZ.pong (x-1); } diff --git a/tests/baselines/reference/moduleNewExportBug.errors.txt b/tests/baselines/reference/moduleNewExportBug.errors.txt index 779d51e4699..0e8a0750d63 100644 --- a/tests/baselines/reference/moduleNewExportBug.errors.txt +++ b/tests/baselines/reference/moduleNewExportBug.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/moduleNewExportBug.ts(10,14): error TS2305: Module 'mod1' has no exported member 'C'. +tests/cases/compiler/moduleNewExportBug.ts(10,14): error TS2693: Module or namespace 'mod1' has no exported member 'C'. ==== tests/cases/compiler/moduleNewExportBug.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/moduleNewExportBug.ts(10,14): error TS2305: Module 'mod1' h var c : mod1.C; // ERROR: C should not be visible ~ -!!! error TS2305: Module 'mod1' has no exported member 'C'. +!!! error TS2693: Module or namespace 'mod1' has no exported member 'C'. \ No newline at end of file diff --git a/tests/baselines/reference/moduleVisibilityTest2.errors.txt b/tests/baselines/reference/moduleVisibilityTest2.errors.txt index 9ff92604392..f565d17f94a 100644 --- a/tests/baselines/reference/moduleVisibilityTest2.errors.txt +++ b/tests/baselines/reference/moduleVisibilityTest2.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/moduleVisibilityTest2.ts(57,17): error TS2304: Cannot find name 'x'. tests/cases/compiler/moduleVisibilityTest2.ts(58,21): error TS2339: Property 'E' does not exist on type 'typeof M'. -tests/cases/compiler/moduleVisibilityTest2.ts(61,16): error TS2305: Module 'M' has no exported member 'I'. -tests/cases/compiler/moduleVisibilityTest2.ts(61,23): error TS2305: Module 'M' has no exported member 'I'. +tests/cases/compiler/moduleVisibilityTest2.ts(61,16): error TS2693: Module or namespace 'M' has no exported member 'I'. +tests/cases/compiler/moduleVisibilityTest2.ts(61,23): error TS2693: Module or namespace 'M' has no exported member 'I'. tests/cases/compiler/moduleVisibilityTest2.ts(64,11): error TS2339: Property 'x' does not exist on type 'typeof M'. tests/cases/compiler/moduleVisibilityTest2.ts(65,15): error TS2339: Property 'E' does not exist on type 'typeof M'. @@ -73,9 +73,9 @@ tests/cases/compiler/moduleVisibilityTest2.ts(65,15): error TS2339: Property 'E' var cprime : M.I = null; ~ -!!! error TS2305: Module 'M' has no exported member 'I'. +!!! error TS2693: Module or namespace 'M' has no exported member 'I'. ~ -!!! error TS2305: Module 'M' has no exported member 'I'. +!!! error TS2693: Module or namespace 'M' has no exported member 'I'. var c = new M.C(); var z = M.x; diff --git a/tests/baselines/reference/moduleVisibilityTest3.errors.txt b/tests/baselines/reference/moduleVisibilityTest3.errors.txt index 0ad8a789a8f..741a9e408b2 100644 --- a/tests/baselines/reference/moduleVisibilityTest3.errors.txt +++ b/tests/baselines/reference/moduleVisibilityTest3.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/moduleVisibilityTest3.ts(20,22): error TS2304: Cannot find name 'modes'. -tests/cases/compiler/moduleVisibilityTest3.ts(20,39): error TS2305: Module '_modes' has no exported member 'Mode'. -tests/cases/compiler/moduleVisibilityTest3.ts(21,22): error TS2305: Module '_modes' has no exported member 'Mode'. +tests/cases/compiler/moduleVisibilityTest3.ts(20,39): error TS2693: Module or namespace '_modes' has no exported member 'Mode'. +tests/cases/compiler/moduleVisibilityTest3.ts(21,22): error TS2693: Module or namespace '_modes' has no exported member 'Mode'. ==== tests/cases/compiler/moduleVisibilityTest3.ts (3 errors) ==== @@ -27,10 +27,10 @@ tests/cases/compiler/moduleVisibilityTest3.ts(21,22): error TS2305: Module '_mod ~~~~~ !!! error TS2304: Cannot find name 'modes'. ~~~~ -!!! error TS2305: Module '_modes' has no exported member 'Mode'. +!!! error TS2693: Module or namespace '_modes' has no exported member 'Mode'. var x:modes.Mode; ~~~~ -!!! error TS2305: Module '_modes' has no exported member 'Mode'. +!!! error TS2693: Module or namespace '_modes' has no exported member 'Mode'. } } diff --git a/tests/baselines/reference/namespacesDeclaration1.js b/tests/baselines/reference/namespacesDeclaration1.js new file mode 100644 index 00000000000..b722dc1fc00 --- /dev/null +++ b/tests/baselines/reference/namespacesDeclaration1.js @@ -0,0 +1,22 @@ +//// [namespacesDeclaration1.ts] + +module M { + export namespace N { + export module M2 { + export interface I {} + } + } +} + +//// [namespacesDeclaration1.js] + + +//// [namespacesDeclaration1.d.ts] +declare module M { + namespace N { + module M2 { + interface I { + } + } + } +} diff --git a/tests/baselines/reference/namespacesDeclaration1.symbols b/tests/baselines/reference/namespacesDeclaration1.symbols new file mode 100644 index 00000000000..512bc9757aa --- /dev/null +++ b/tests/baselines/reference/namespacesDeclaration1.symbols @@ -0,0 +1,16 @@ +=== tests/cases/compiler/namespacesDeclaration1.ts === + +module M { +>M : Symbol(M, Decl(namespacesDeclaration1.ts, 0, 0)) + + export namespace N { +>N : Symbol(N, Decl(namespacesDeclaration1.ts, 1, 10)) + + export module M2 { +>M2 : Symbol(M2, Decl(namespacesDeclaration1.ts, 2, 23)) + + export interface I {} +>I : Symbol(I, Decl(namespacesDeclaration1.ts, 3, 24)) + } + } +} diff --git a/tests/baselines/reference/namespacesDeclaration1.types b/tests/baselines/reference/namespacesDeclaration1.types new file mode 100644 index 00000000000..e99f5d0e6c3 --- /dev/null +++ b/tests/baselines/reference/namespacesDeclaration1.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/namespacesDeclaration1.ts === + +module M { +>M : any + + export namespace N { +>N : any + + export module M2 { +>M2 : any + + export interface I {} +>I : I + } + } +} diff --git a/tests/baselines/reference/namespacesDeclaration2.errors.txt b/tests/baselines/reference/namespacesDeclaration2.errors.txt new file mode 100644 index 00000000000..c0f4817734a --- /dev/null +++ b/tests/baselines/reference/namespacesDeclaration2.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/namespacesDeclaration2.ts(13,13): error TS2693: Module or namespace 'N' has no exported member 'S'. +tests/cases/compiler/namespacesDeclaration2.ts(14,12): error TS2693: Module or namespace 'M' has no exported member 'F'. +tests/cases/compiler/namespacesDeclaration2.ts(15,11): error TS2693: Module or namespace 'ns' has no exported member 'A'. + + +==== tests/cases/compiler/namespacesDeclaration2.ts (3 errors) ==== + + namespace N { + function S() {} + } + module M { + function F() {} + } + + declare namespace ns { + let f: number; + } + + var foge: N.S; + ~ +!!! error TS2693: Module or namespace 'N' has no exported member 'S'. + var foo: M.F; + ~ +!!! error TS2693: Module or namespace 'M' has no exported member 'F'. + let x: ns.A; + ~ +!!! error TS2693: Module or namespace 'ns' has no exported member 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/namespacesDeclaration2.js b/tests/baselines/reference/namespacesDeclaration2.js new file mode 100644 index 00000000000..d680e781145 --- /dev/null +++ b/tests/baselines/reference/namespacesDeclaration2.js @@ -0,0 +1,42 @@ +//// [namespacesDeclaration2.ts] + +namespace N { + function S() {} +} +module M { + function F() {} +} + +declare namespace ns { + let f: number; +} + +var foge: N.S; +var foo: M.F; +let x: ns.A; + +//// [namespacesDeclaration2.js] +var N; +(function (N) { + function S() { } +})(N || (N = {})); +var M; +(function (M) { + function F() { } +})(M || (M = {})); +var foge; +var foo; +var x; + + +//// [namespacesDeclaration2.d.ts] +declare namespace N { +} +declare module M { +} +declare namespace ns { + let f: number; +} +declare var foge: N.S; +declare var foo: M.F; +declare let x: ns.A; diff --git a/tests/baselines/reference/parserRealSource14.errors.txt b/tests/baselines/reference/parserRealSource14.errors.txt index 4881864e236..8dea51d35df 100644 --- a/tests/baselines/reference/parserRealSource14.errors.txt +++ b/tests/baselines/reference/parserRealSource14.errors.txt @@ -1,30 +1,30 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(4,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/typescript.ts' not found. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(24,33): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(38,34): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(48,37): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(68,39): error TS2305: Module 'TypeScript' has no exported member 'NodeType'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(24,33): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(38,34): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(48,37): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(68,39): error TS2693: Module or namespace 'TypeScript' has no exported member 'NodeType'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(70,35): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(75,32): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(79,32): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(86,47): error TS2305: Module 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(75,32): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(79,32): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(86,47): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(94,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(95,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(96,31): error TS2305: Module 'TypeScript' has no exported member 'InterfaceDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(96,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'InterfaceDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(103,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(104,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(105,31): error TS2305: Module 'TypeScript' has no exported member 'InterfaceDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(105,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'InterfaceDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(112,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(113,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(114,31): error TS2305: Module 'TypeScript' has no exported member 'ArgDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(114,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'ArgDecl'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(121,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(122,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(123,31): error TS2305: Module 'TypeScript' has no exported member 'VarDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(123,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'VarDecl'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(130,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(131,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(132,31): error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(132,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(139,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(140,56): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(141,31): error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(141,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(148,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(149,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(156,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. @@ -35,128 +35,128 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(172,65): error tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(173,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(174,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(175,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(176,31): error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(177,31): error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(178,31): error TS2305: Module 'TypeScript' has no exported member 'ClassDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(176,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(177,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(178,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'ClassDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(185,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(186,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(191,61): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(192,28): error TS2339: Property 'hasFlag' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(192,49): error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(192,49): error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(192,109): error TS2339: Property 'ModuleFlags' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(197,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(198,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(199,31): error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(199,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(200,28): error TS2339: Property 'hasFlag' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(200,49): error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(200,49): error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(200,113): error TS2339: Property 'ModuleFlags' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(205,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(206,31): error TS2305: Module 'TypeScript' has no exported member 'Script'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(206,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'Script'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(211,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(212,31): error TS2305: Module 'TypeScript' has no exported member 'SwitchStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(212,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'SwitchStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(217,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(218,31): error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(218,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(223,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(224,31): error TS2305: Module 'TypeScript' has no exported member 'ClassDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(224,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'ClassDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(229,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(230,31): error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(230,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(235,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(236,31): error TS2305: Module 'TypeScript' has no exported member 'InterfaceDeclaration'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(236,31): error TS2693: Module or namespace 'TypeScript' has no exported member 'InterfaceDeclaration'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(241,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(242,30): error TS2305: Module 'TypeScript' has no exported member 'Block'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(242,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'Block'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(247,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(248,30): error TS2305: Module 'TypeScript' has no exported member 'ForStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(248,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'ForStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(253,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(254,30): error TS2305: Module 'TypeScript' has no exported member 'CaseStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(254,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'CaseStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(259,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(260,30): error TS2305: Module 'TypeScript' has no exported member 'Try'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(260,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'Try'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(265,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(266,30): error TS2305: Module 'TypeScript' has no exported member 'Catch'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(266,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'Catch'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(271,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(272,30): error TS2305: Module 'TypeScript' has no exported member 'DoWhileStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(272,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'DoWhileStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(277,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(278,30): error TS2305: Module 'TypeScript' has no exported member 'WhileStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(278,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'WhileStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(283,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(284,30): error TS2305: Module 'TypeScript' has no exported member 'ForInStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(284,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'ForInStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(289,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(290,30): error TS2305: Module 'TypeScript' has no exported member 'WithStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(290,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'WithStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(295,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(296,30): error TS2305: Module 'TypeScript' has no exported member 'Finally'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(296,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'Finally'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(301,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(302,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(303,30): error TS2305: Module 'TypeScript' has no exported member 'SwitchStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(303,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'SwitchStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(308,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(309,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(310,30): error TS2305: Module 'TypeScript' has no exported member 'SwitchStatement'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(311,30): error TS2305: Module 'TypeScript' has no exported member 'SwitchStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(310,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'SwitchStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(311,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'SwitchStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(316,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(317,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(318,30): error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(318,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(327,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(328,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(329,30): error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(330,30): error TS2305: Module 'TypeScript' has no exported member 'ASTList'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(329,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(330,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'ASTList'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(335,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(336,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(337,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(338,30): error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(338,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(343,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(344,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(345,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(346,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(347,30): error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(347,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(352,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(353,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(354,30): error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(354,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(359,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(360,30): error TS2305: Module 'TypeScript' has no exported member 'BinaryExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(360,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'BinaryExpression'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(365,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(366,30): error TS2305: Module 'TypeScript' has no exported member 'BinaryExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(366,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'BinaryExpression'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(371,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(377,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(378,30): error TS2305: Module 'TypeScript' has no exported member 'IfStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(378,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'IfStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(383,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(384,30): error TS2305: Module 'TypeScript' has no exported member 'IfStatement'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(384,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'IfStatement'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(393,61): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(394,30): error TS2305: Module 'TypeScript' has no exported member 'ASTList'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(394,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'ASTList'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(399,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(400,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(401,30): error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(401,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(406,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(407,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(408,30): error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(408,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(413,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(414,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(415,30): error TS2305: Module 'TypeScript' has no exported member 'CallExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(415,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'CallExpression'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(420,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(421,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(422,30): error TS2305: Module 'TypeScript' has no exported member 'CallExpression'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(422,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'CallExpression'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(427,65): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(428,30): error TS2305: Module 'TypeScript' has no exported member 'Block'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(432,52): error TS2305: Module 'TypeScript' has no exported member 'ASTSpan'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(462,61): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(463,52): error TS2305: Module 'TypeScript' has no exported member 'Comment'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(478,45): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(478,69): error TS2305: Module 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(428,30): error TS2693: Module or namespace 'TypeScript' has no exported member 'Block'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(432,52): error TS2693: Module or namespace 'TypeScript' has no exported member 'ASTSpan'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(462,61): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(463,52): error TS2693: Module or namespace 'TypeScript' has no exported member 'Comment'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(478,45): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(478,69): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(478,82): error TS2304: Cannot find name 'IAstWalker'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(489,21): error TS2304: Cannot find name 'hasFlag'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(490,49): error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(516,22): error TS2304: Cannot find name 'hasFlag'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(525,20): error TS2339: Property 'getAstWalkerFactory' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(533,62): error TS2305: Module 'TypeScript' has no exported member 'Script'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(535,36): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(535,60): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(535,84): error TS2305: Module 'TypeScript' has no exported member 'IAstWalker'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(535,108): error TS2305: Module 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(533,62): error TS2693: Module or namespace 'TypeScript' has no exported member 'Script'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(535,36): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(535,60): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(535,84): error TS2693: Module or namespace 'TypeScript' has no exported member 'IAstWalker'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(535,108): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(551,20): error TS2339: Property 'getAstWalkerFactory' does not exist on type 'typeof TypeScript'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(558,45): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(558,95): error TS2305: Module 'TypeScript' has no exported member 'IAstWalker'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(559,45): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(559,69): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(559,93): error TS2305: Module 'TypeScript' has no exported member 'IAstWalker'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(565,46): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(565,70): error TS2305: Module 'TypeScript' has no exported member 'AST'. -tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(565,94): error TS2305: Module 'TypeScript' has no exported member 'IAstWalker'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(558,45): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(558,95): error TS2693: Module or namespace 'TypeScript' has no exported member 'IAstWalker'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(559,45): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(559,69): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(559,93): error TS2693: Module or namespace 'TypeScript' has no exported member 'IAstWalker'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(565,46): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(565,70): error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. +tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(565,94): error TS2693: Module or namespace 'TypeScript' has no exported member 'IAstWalker'. tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error TS2339: Property 'getAstWalkerFactory' does not exist on type 'typeof TypeScript'. @@ -188,7 +188,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error export class AstPath { public asts: TypeScript.AST[] = []; ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. public top: number = -1; static reverseIndexOf(items: any[], index: number): any { @@ -204,7 +204,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error public pop(): TypeScript.AST { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. var head = this.ast(); this.up(); @@ -216,7 +216,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error public push(ast: TypeScript.AST) { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. while (this.asts.length > this.count()) { this.asts.pop(); } @@ -238,7 +238,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error public nodeType(): TypeScript.NodeType { ~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'NodeType'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'NodeType'. if (this.ast() == null) return TypeScript.NodeType.None; ~~~~~~~~ @@ -249,13 +249,13 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error public ast() { return AstPath.reverseIndexOf(this.asts, this.asts.length - (this.top + 1)); ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. } public parent() { return AstPath.reverseIndexOf(this.asts, this.asts.length - this.top); ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. } public count() { @@ -264,7 +264,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error public get(index: number): TypeScript.AST { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. return this.asts[index]; } @@ -280,7 +280,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. ((this.parent()).name === this.ast()); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'InterfaceDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'InterfaceDeclaration'. } public isNameOfInterface(): boolean { @@ -295,7 +295,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. ((this.parent()).name === this.ast()); ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'InterfaceDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'InterfaceDeclaration'. } public isNameOfArgument(): boolean { @@ -310,7 +310,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. ((this.parent()).id === this.ast()); ~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ArgDecl'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ArgDecl'. } public isNameOfVariable(): boolean { @@ -325,7 +325,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. ((this.parent()).id === this.ast()); ~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'VarDecl'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'VarDecl'. } public isNameOfModule(): boolean { @@ -340,7 +340,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. ((this.parent()).name === this.ast()); ~~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. } public isNameOfFunction(): boolean { @@ -355,7 +355,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. ((this.parent()).name === this.ast()); ~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. } public isChildOfScript(): boolean { @@ -412,13 +412,13 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. ((this.asts[this.top - 2]).isConstructor) && ~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. ((this.asts[this.top - 2]).arguments === this.asts[this.top - 1]) && ~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. ((this.asts[this.top - 4]).constructorDecl === this.asts[this.top - 2]); ~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ClassDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ClassDeclaration'. } public isChildOfInterface(): boolean { @@ -442,7 +442,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error ~~~~~~~ !!! error TS2339: Property 'hasFlag' does not exist on type 'typeof TypeScript'. ~~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. ~~~~~~~~~~~ !!! error TS2339: Property 'ModuleFlags' does not exist on type 'typeof TypeScript'. } @@ -457,12 +457,12 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).members == this.asts[this.top - 0] && ~~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. TypeScript.hasFlag((this.asts[this.top - 1]).modFlags, TypeScript.ModuleFlags.IsWholeFile); ~~~~~~~ !!! error TS2339: Property 'hasFlag' does not exist on type 'typeof TypeScript'. ~~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. ~~~~~~~~~~~ !!! error TS2339: Property 'ModuleFlags' does not exist on type 'typeof TypeScript'. } @@ -474,7 +474,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).bod == this.asts[this.top - 0]; ~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'Script'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'Script'. } public isBodyOfSwitch(): boolean { @@ -484,7 +484,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).caseList == this.asts[this.top - 0]; ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'SwitchStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'SwitchStatement'. } public isBodyOfModule(): boolean { @@ -494,7 +494,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).members == this.asts[this.top - 0]; ~~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ModuleDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ModuleDeclaration'. } public isBodyOfClass(): boolean { @@ -504,7 +504,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).members == this.asts[this.top - 0]; ~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ClassDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ClassDeclaration'. } public isBodyOfFunction(): boolean { @@ -514,7 +514,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).bod == this.asts[this.top - 0]; ~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. } public isBodyOfInterface(): boolean { @@ -524,7 +524,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).members == this.asts[this.top - 0]; ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'InterfaceDeclaration'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'InterfaceDeclaration'. } public isBodyOfBlock(): boolean { @@ -534,7 +534,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).statements == this.asts[this.top - 0]; ~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'Block'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'Block'. } public isBodyOfFor(): boolean { @@ -544,7 +544,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ForStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ForStatement'. } public isBodyOfCase(): boolean { @@ -554,7 +554,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'CaseStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'CaseStatement'. } public isBodyOfTry(): boolean { @@ -564,7 +564,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'Try'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'Try'. } public isBodyOfCatch(): boolean { @@ -574,7 +574,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'Catch'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'Catch'. } public isBodyOfDoWhile(): boolean { @@ -584,7 +584,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'DoWhileStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'DoWhileStatement'. } public isBodyOfWhile(): boolean { @@ -594,7 +594,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'WhileStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'WhileStatement'. } public isBodyOfForIn(): boolean { @@ -604,7 +604,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ForInStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ForInStatement'. } public isBodyOfWith(): boolean { @@ -614,7 +614,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'WithStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'WithStatement'. } public isBodyOfFinally(): boolean { @@ -624,7 +624,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).body == this.asts[this.top - 0]; ~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'Finally'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'Finally'. } public isCaseOfSwitch(): boolean { @@ -637,7 +637,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 2]).caseList == this.asts[this.top - 1]; ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'SwitchStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'SwitchStatement'. } public isDefaultCaseOfSwitch(): boolean { @@ -650,10 +650,10 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 2]).caseList == this.asts[this.top - 1] && ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'SwitchStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'SwitchStatement'. (this.asts[this.top - 2]).defaultCase == this.asts[this.top - 0]; ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'SwitchStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'SwitchStatement'. } public isListOfObjectLit(): boolean { @@ -666,7 +666,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).operand == this.asts[this.top - 0]; ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. } public isBodyOfObjectLit(): boolean { @@ -683,10 +683,10 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).operand == this.asts[this.top - 0] && ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. (this.asts[this.top - 0]).members.length == 0; ~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ASTList'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ASTList'. } public isMemberOfObjectLit(): boolean { @@ -702,7 +702,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 2]).operand == this.asts[this.top - 1]; ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. } public isNameOfMemberOfObjectLit(): boolean { @@ -721,7 +721,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 3]).operand == this.asts[this.top - 2]; ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. } public isListOfArrayLit(): boolean { @@ -734,7 +734,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).operand == this.asts[this.top - 0]; ~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'UnaryExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'UnaryExpression'. } public isTargetOfMember(): boolean { @@ -744,7 +744,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).operand1 === this.asts[this.top - 0]; ~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'BinaryExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'BinaryExpression'. } public isMemberOfMember(): boolean { @@ -754,7 +754,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).operand2 === this.asts[this.top - 0]; ~~~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'BinaryExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'BinaryExpression'. } public isItemOfList(): boolean { @@ -772,7 +772,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).thenBod == this.asts[this.top - 0]; ~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'IfStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'IfStatement'. } public isElseOfIf(): boolean { @@ -782,7 +782,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).elseBod == this.asts[this.top - 0]; ~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'IfStatement'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'IfStatement'. } public isBodyOfDefaultCase(): boolean { @@ -796,7 +796,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top]).members.length === 1; ~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ASTList'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ASTList'. } public isArgumentListOfFunction(): boolean { @@ -809,7 +809,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).arguments === this.asts[this.top - 0]; ~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. } public isArgumentOfFunction(): boolean { @@ -822,7 +822,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 2]).arguments === this.asts[this.top - 1]; ~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'FuncDecl'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'FuncDecl'. } public isArgumentListOfCall(): boolean { @@ -835,7 +835,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).arguments === this.asts[this.top - 0]; ~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'CallExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'CallExpression'. } public isArgumentListOfNew(): boolean { @@ -848,7 +848,7 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 1]).arguments === this.asts[this.top - 0]; ~~~~~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'CallExpression'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'CallExpression'. } public isSynthesizedBlock(): boolean { @@ -858,13 +858,13 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error !!! error TS2339: Property 'NodeType' does not exist on type 'typeof TypeScript'. (this.asts[this.top - 0]).isStatementBlock === false; ~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'Block'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'Block'. } } export function isValidAstNode(ast: TypeScript.ASTSpan): boolean { ~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'ASTSpan'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'ASTSpan'. if (ast === null) return false; @@ -896,10 +896,10 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error /// export function getAstPathToPosition(script: TypeScript.AST, pos: number, options = GetAstPathOptions.Default): TypeScript.AstPath { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. var lookInComments = (comments: TypeScript.Comment[]) => { ~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'Comment'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'Comment'. if (comments && comments.length > 0) { for (var i = 0; i < comments.length; i++) { var minChar = comments[i].minChar; @@ -916,9 +916,9 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error var pre = function (cur: TypeScript.AST, parent: TypeScript.AST, walker: IAstWalker) { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~~~~~~~~ !!! error TS2304: Cannot find name 'IAstWalker'. if (isValidAstNode(cur)) { @@ -985,17 +985,17 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error // export function getTokenizationOffset(script: TypeScript.Script, position: number): number { ~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'Script'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'Script'. var bestOffset = 0; var pre = (cur: TypeScript.AST, parent: TypeScript.AST, walker: TypeScript.IAstWalker): TypeScript.AST => { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'IAstWalker'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'IAstWalker'. ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. if (TypeScript.isValidAstNode(cur)) { // Did we find a closer offset? if (cur.minChar <= position) { @@ -1022,16 +1022,16 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error /// export function walkAST(ast: TypeScript.AST, callback: (path: AstPath, walker: TypeScript.IAstWalker) => void ): void { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'IAstWalker'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'IAstWalker'. var pre = function (cur: TypeScript.AST, parent: TypeScript.AST, walker: TypeScript.IAstWalker) { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'IAstWalker'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'IAstWalker'. var path: TypeScript.AstPath = walker.state; path.push(cur); callback(path, walker); @@ -1039,11 +1039,11 @@ tests/cases/conformance/parser/ecmascript5/parserRealSource14.ts(572,20): error } var post = function (cur: TypeScript.AST, parent: TypeScript.AST, walker: TypeScript.IAstWalker) { ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'AST'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'AST'. ~~~~~~~~~~ -!!! error TS2305: Module 'TypeScript' has no exported member 'IAstWalker'. +!!! error TS2693: Module or namespace 'TypeScript' has no exported member 'IAstWalker'. var path: TypeScript.AstPath = walker.state; path.pop(); return cur; diff --git a/tests/baselines/reference/parserharness.errors.txt b/tests/baselines/reference/parserharness.errors.txt index fd9ad6d3a10..cbf26e03e70 100644 --- a/tests/baselines/reference/parserharness.errors.txt +++ b/tests/baselines/reference/parserharness.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(16,1): err tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(17,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/compiler/typescript.ts' not found. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(18,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/services/typescriptServices.ts' not found. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(19,1): error TS6053: File 'tests/cases/conformance/parser/ecmascript5/RealWorld/diff.ts' not found. -tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(21,29): error TS2305: Module 'Harness' has no exported member 'Assert'. +tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(21,29): error TS2693: Module or namespace 'Harness' has no exported member 'Assert'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(25,17): error TS2304: Cannot find name 'IIO'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(41,12): error TS2304: Cannot find name 'ActiveXObject'. tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(43,19): error TS2304: Cannot find name 'require'. @@ -141,7 +141,7 @@ tests/cases/conformance/parser/ecmascript5/RealWorld/parserharness.ts(2030,32): declare var assert: Harness.Assert; ~~~~~~ -!!! error TS2305: Module 'Harness' has no exported member 'Assert'. +!!! error TS2693: Module or namespace 'Harness' has no exported member 'Assert'. declare var it; declare var describe; declare var run; diff --git a/tests/baselines/reference/sourceMapSample.errors.txt b/tests/baselines/reference/sourceMapSample.errors.txt index 25072de7c0e..2300e72d04a 100644 --- a/tests/baselines/reference/sourceMapSample.errors.txt +++ b/tests/baselines/reference/sourceMapSample.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/sourceMapSample.ts(14,45): error TS2305: Module 'Foo.Bar' has no exported member 'Greeter'. +tests/cases/compiler/sourceMapSample.ts(14,45): error TS2693: Module or namespace 'Foo.Bar' has no exported member 'Greeter'. ==== tests/cases/compiler/sourceMapSample.ts (1 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/sourceMapSample.ts(14,45): error TS2305: Module 'Foo.Bar' h function foo(greeting: string): Foo.Bar.Greeter { ~~~~~~~ -!!! error TS2305: Module 'Foo.Bar' has no exported member 'Greeter'. +!!! error TS2693: Module or namespace 'Foo.Bar' has no exported member 'Greeter'. return new Greeter(greeting); } diff --git a/tests/cases/compiler/namespacesDeclaration.ts b/tests/cases/compiler/namespacesDeclaration1.ts similarity index 100% rename from tests/cases/compiler/namespacesDeclaration.ts rename to tests/cases/compiler/namespacesDeclaration1.ts diff --git a/tests/cases/compiler/namespacesDeclaration2.ts b/tests/cases/compiler/namespacesDeclaration2.ts new file mode 100644 index 00000000000..6c4a1790354 --- /dev/null +++ b/tests/cases/compiler/namespacesDeclaration2.ts @@ -0,0 +1,16 @@ +// @declaration: true + +namespace N { + function S() {} +} +module M { + function F() {} +} + +declare namespace ns { + let f: number; +} + +var foge: N.S; +var foo: M.F; +let x: ns.A; \ No newline at end of file From a25104e152dcb34db31eaba16218e7ff9cc6eceb Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 27 Aug 2016 09:40:49 -0700 Subject: [PATCH 285/508] Use union type when binding element has initializer --- src/compiler/checker.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c1e401912d..9afa1c1e2c3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2974,7 +2974,9 @@ namespace ts { if (strictNullChecks && declaration.initializer && !(getFalsyFlags(checkExpressionCached(declaration.initializer)) & TypeFlags.Undefined)) { type = getTypeWithFacts(type, TypeFacts.NEUndefined); } - return type; + return declaration.initializer ? + getUnionType([type, checkExpressionCached(declaration.initializer)], /*subtypeReduction*/ true) : + type; } function getTypeForVariableLikeDeclarationFromJSDocComment(declaration: VariableLikeDeclaration) { From 65ef06edf4696dc788f105ce3c0a94ac16715ba8 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 27 Aug 2016 09:41:39 -0700 Subject: [PATCH 286/508] Accept new baselines --- ...TypedBindingInitializerNegative.errors.txt | 67 ------------ ...llyTypedBindingInitializerNegative.symbols | 88 +++++++++++++++ ...uallyTypedBindingInitializerNegative.types | 100 ++++++++++++++++++ .../declarationsAndAssignments.errors.txt | 6 +- ...rayBindingPatternAndAssignment2.errors.txt | 5 +- ...destructuringVariableDeclaration1ES5.types | 6 +- ...destructuringVariableDeclaration1ES6.types | 6 +- ...structuringVariableDeclaration2.errors.txt | 16 +-- tests/baselines/reference/for-of43.errors.txt | 11 -- tests/baselines/reference/for-of43.symbols | 19 ++++ tests/baselines/reference/for-of43.types | 25 +++++ ...licitAnyDestructuringVarDeclaration2.types | 12 +-- 12 files changed, 250 insertions(+), 111 deletions(-) delete mode 100644 tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt create mode 100644 tests/baselines/reference/contextuallyTypedBindingInitializerNegative.symbols create mode 100644 tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types delete mode 100644 tests/baselines/reference/for-of43.errors.txt create mode 100644 tests/baselines/reference/for-of43.symbols create mode 100644 tests/baselines/reference/for-of43.types diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt deleted file mode 100644 index 447ccec5ddf..00000000000 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.errors.txt +++ /dev/null @@ -1,67 +0,0 @@ -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(4,20): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(5,23): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(6,25): error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(11,23): error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. - Types of property 'show' are incompatible. - Type '(v: number) => number' is not assignable to type '(x: number) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(16,23): error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(21,14): error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. - Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts(26,14): error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. - - -==== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts (7 errors) ==== - interface Show { - show: (x: number) => string; - } - function f({ show: showRename = v => v }: Show) {} - ~~~~~~~~~~ -!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - function f2({ "show": showRename = v => v }: Show) {} - ~~~~~~~~~~ -!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - function f3({ ["show"]: showRename = v => v }: Show) {} - ~~~~~~~~~~ -!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - - interface Nested { - nested: Show - } - function ff({ nested: nestedRename = { show: v => v } }: Nested) {} - ~~~~~~~~~~~~ -!!! error TS2322: Type '{ show: (v: number) => number; }' is not assignable to type 'Show'. -!!! error TS2322: Types of property 'show' are incompatible. -!!! error TS2322: Type '(v: number) => number' is not assignable to type '(x: number) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - - interface StringIdentity { - stringIdentity(s: string): string; - } - let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; - ~~ -!!! error TS2322: Type '(arg: string) => number' is not assignable to type '(s: string) => string'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - - interface Tuples { - prop: [string, number]; - } - function g({ prop = [101, 1234] }: Tuples) {} - ~~~~ -!!! error TS2322: Type '[number, number]' is not assignable to type '[string, number]'. -!!! error TS2322: Type 'number' is not assignable to type 'string'. - - interface StringUnion { - prop: "foo" | "bar"; - } - function h({ prop = "baz" }: StringUnion) {} - ~~~~ -!!! error TS2322: Type '"baz"' is not assignable to type '"foo" | "bar"'. - \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.symbols b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.symbols new file mode 100644 index 00000000000..a9013e7f98e --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.symbols @@ -0,0 +1,88 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts === +interface Show { +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) + + show: (x: number) => string; +>show : Symbol(Show.show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 16)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializerNegative.ts, 1, 11)) +} +function f({ show: showRename = v => v }: Show) {} +>f : Symbol(f, Decl(contextuallyTypedBindingInitializerNegative.ts, 2, 1)) +>show : Symbol(Show.show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 16)) +>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 3, 12)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 3, 31)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 3, 31)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) + +function f2({ "show": showRename = v => v }: Show) {} +>f2 : Symbol(f2, Decl(contextuallyTypedBindingInitializerNegative.ts, 3, 50)) +>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 4, 13)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 4, 34)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 4, 34)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) + +function f3({ ["show"]: showRename = v => v }: Show) {} +>f3 : Symbol(f3, Decl(contextuallyTypedBindingInitializerNegative.ts, 4, 53)) +>"show" : Symbol(showRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 13)) +>showRename : Symbol(showRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 13)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 36)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 36)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) + +interface Nested { +>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 55)) + + nested: Show +>nested : Symbol(Nested.nested, Decl(contextuallyTypedBindingInitializerNegative.ts, 7, 18)) +>Show : Symbol(Show, Decl(contextuallyTypedBindingInitializerNegative.ts, 0, 0)) +} +function ff({ nested: nestedRename = { show: v => v } }: Nested) {} +>ff : Symbol(ff, Decl(contextuallyTypedBindingInitializerNegative.ts, 9, 1)) +>nested : Symbol(Nested.nested, Decl(contextuallyTypedBindingInitializerNegative.ts, 7, 18)) +>nestedRename : Symbol(nestedRename, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 13)) +>show : Symbol(show, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 38)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 44)) +>v : Symbol(v, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 44)) +>Nested : Symbol(Nested, Decl(contextuallyTypedBindingInitializerNegative.ts, 5, 55)) + +interface StringIdentity { +>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 67)) + + stringIdentity(s: string): string; +>stringIdentity : Symbol(StringIdentity.stringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 12, 26)) +>s : Symbol(s, Decl(contextuallyTypedBindingInitializerNegative.ts, 13, 19)) +} +let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; +>stringIdentity : Symbol(StringIdentity.stringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 12, 26)) +>id : Symbol(id, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 5)) +>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 26)) +>arg.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>arg : Symbol(arg, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 26)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>StringIdentity : Symbol(StringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 10, 67)) +>stringIdentity : Symbol(stringIdentity, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 66)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 82)) +>x : Symbol(x, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 82)) + +interface Tuples { +>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 91)) + + prop: [string, number]; +>prop : Symbol(Tuples.prop, Decl(contextuallyTypedBindingInitializerNegative.ts, 17, 18)) +} +function g({ prop = [101, 1234] }: Tuples) {} +>g : Symbol(g, Decl(contextuallyTypedBindingInitializerNegative.ts, 19, 1)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializerNegative.ts, 20, 12)) +>Tuples : Symbol(Tuples, Decl(contextuallyTypedBindingInitializerNegative.ts, 15, 91)) + +interface StringUnion { +>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializerNegative.ts, 20, 45)) + + prop: "foo" | "bar"; +>prop : Symbol(StringUnion.prop, Decl(contextuallyTypedBindingInitializerNegative.ts, 22, 23)) +} +function h({ prop = "baz" }: StringUnion) {} +>h : Symbol(h, Decl(contextuallyTypedBindingInitializerNegative.ts, 24, 1)) +>prop : Symbol(prop, Decl(contextuallyTypedBindingInitializerNegative.ts, 25, 12)) +>StringUnion : Symbol(StringUnion, Decl(contextuallyTypedBindingInitializerNegative.ts, 20, 45)) + diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types new file mode 100644 index 00000000000..7e922332055 --- /dev/null +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types @@ -0,0 +1,100 @@ +=== tests/cases/conformance/types/contextualTypes/methodDeclarations/contextuallyTypedBindingInitializerNegative.ts === +interface Show { +>Show : Show + + show: (x: number) => string; +>show : (x: number) => string +>x : number +} +function f({ show: showRename = v => v }: Show) {} +>f : ({show: showRename}: Show) => void +>show : any +>showRename : ((x: number) => string) | ((v: number) => number) +>v => v : (v: number) => number +>v : number +>v : number +>Show : Show + +function f2({ "show": showRename = v => v }: Show) {} +>f2 : ({"show": showRename}: Show) => void +>showRename : ((x: number) => string) | ((v: number) => number) +>v => v : (v: number) => number +>v : number +>v : number +>Show : Show + +function f3({ ["show"]: showRename = v => v }: Show) {} +>f3 : ({["show"]: showRename}: Show) => void +>"show" : string +>showRename : ((x: number) => string) | ((v: number) => number) +>v => v : (v: number) => number +>v : number +>v : number +>Show : Show + +interface Nested { +>Nested : Nested + + nested: Show +>nested : Show +>Show : Show +} +function ff({ nested: nestedRename = { show: v => v } }: Nested) {} +>ff : ({nested: nestedRename}: Nested) => void +>nested : any +>nestedRename : Show | { show: (v: number) => number; } +>{ show: v => v } : { show: (v: number) => number; } +>show : (v: number) => number +>v => v : (v: number) => number +>v : number +>v : number +>Nested : Nested + +interface StringIdentity { +>StringIdentity : StringIdentity + + stringIdentity(s: string): string; +>stringIdentity : (s: string) => string +>s : string +} +let { stringIdentity: id = arg => arg.length }: StringIdentity = { stringIdentity: x => x}; +>stringIdentity : any +>id : ((s: string) => string) | ((arg: string) => number) +>arg => arg.length : (arg: string) => number +>arg : string +>arg.length : number +>arg : string +>length : number +>StringIdentity : StringIdentity +>{ stringIdentity: x => x} : { stringIdentity: (x: string) => string; } +>stringIdentity : (x: string) => string +>x => x : (x: string) => string +>x : string +>x : string + +interface Tuples { +>Tuples : Tuples + + prop: [string, number]; +>prop : [string, number] +} +function g({ prop = [101, 1234] }: Tuples) {} +>g : ({prop}: Tuples) => void +>prop : [string, number] | [number, number] +>[101, 1234] : [number, number] +>101 : number +>1234 : number +>Tuples : Tuples + +interface StringUnion { +>StringUnion : StringUnion + + prop: "foo" | "bar"; +>prop : "foo" | "bar" +} +function h({ prop = "baz" }: StringUnion) {} +>h : ({prop}: StringUnion) => void +>prop : "foo" | "bar" | "baz" +>"baz" : "baz" +>StringUnion : StringUnion + diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 3ed9e241c39..33c2db0a550 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(29,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(58,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'string | number', but here has type 'string'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,10): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. @@ -96,10 +96,10 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): function f7() { var [x = 0, y = 1] = [1, "hello"]; // Error, initializer for y must be string - ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. var x: number; var y: string; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'string | number', but here has type 'string'. } function f8() { diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index e22b23122d3..610167a1bc0 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -3,7 +3,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. Type 'number' is not assignable to type 'boolean'. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(17,6): error TS2322: Type 'string' is not assignable to type 'Number'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'. Property '0' is missing in type 'number[]'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'. @@ -11,7 +10,7 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(34,5): error TS2461: Type 'F' is not an array type. -==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (8 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts (7 errors) ==== // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is the type Any, or var [[a0], [[a1]]] = [] // Error @@ -38,8 +37,6 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss return <[number, number, number]>[1, 2, 3]; } var [b3 = "string", b4, b5] = bar(); // Error - ~~ -!!! error TS2322: Type 'string' is not assignable to type 'Number'. // V is an array assignment pattern, S is the type Any or an array-like type (section 3.3.2), and, for each assignment element E in V, // S is not a tuple- like type and the numeric index signature type of S is assignable to the target given in E. diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index c4693fac23f..35eb23c9e6a 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -62,11 +62,11 @@ var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; >"hello" : string var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; ->b5 : any +>b5 : number >3 : number ->b6 : any +>b6 : boolean >true : boolean ->b7 : any +>b7 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } >[undefined, undefined, undefined] : [undefined, undefined, undefined] >undefined : undefined diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index 847831ccc84..f124e203e1f 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -62,11 +62,11 @@ var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; >"hello" : string var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; ->b5 : any +>b5 : number >3 : number ->b6 : any +>b6 : boolean >true : boolean ->b7 : any +>b7 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } >[undefined, undefined, undefined] : [undefined, undefined, undefined] >undefined : undefined diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt index bdbda6f9a96..7658de962d9 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt @@ -5,16 +5,11 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4 Type '[[boolean]]' is not assignable to type '[[string]]'. Type '[boolean]' is not assignable to type '[string]'. Type 'boolean' is not assignable to type 'string'. -tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(9,25): error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'. - Types of property 't2' are incompatible. - Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,16): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c3' and no string index signature. tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(14,24): error TS2459: Type 'number | { c3: number; c5: number; }' has no property 'c5' and no string index signature. -tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(19,10): error TS2322: Type 'string[]' is not assignable to type 'number[]'. - Type 'string' is not assignable to type 'number'. -==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (6 errors) ==== +==== tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts (4 errors) ==== // The type T associated with a destructuring variable declaration is determined as follows: // If the declaration includes a type annotation, T is that type. var {a1, a2}: { a1: number, a2: string } = { a1: true, a2: 1 } // Error @@ -33,10 +28,6 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(1 // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. var temp = { t1: true, t2: "false" }; var [b0 = 3, b1 = true, b2 = temp] = [3, false, { t1: false, t2: 5}]; // Error - ~~ -!!! error TS2322: Type '{ t1: boolean; t2: string; }' is not assignable to type '{ t1: boolean; t2: number; }'. -!!! error TS2322: Types of property 't2' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. // The type T associated with a binding element is determined as follows: // If the binding element is a rest element, T is an array type with @@ -50,7 +41,4 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(1 // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable // to the widened form of the type associated with the destructuring variable declaration, binding property, or binding element. - var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error - ~~ -!!! error TS2322: Type 'string[]' is not assignable to type 'number[]'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file + var {d: {d1 = ["string", null]}}: { d: { d1: number[] } } = { d: { d1: [1, 2] } }; // Error \ No newline at end of file diff --git a/tests/baselines/reference/for-of43.errors.txt b/tests/baselines/reference/for-of43.errors.txt deleted file mode 100644 index c5790278e53..00000000000 --- a/tests/baselines/reference/for-of43.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -tests/cases/conformance/es6/for-ofStatements/for-of43.ts(2,25): error TS2322: Type 'boolean' is not assignable to type 'number'. - - -==== tests/cases/conformance/es6/for-ofStatements/for-of43.ts (1 errors) ==== - var array = [{ x: "", y: 0 }] - for (var {x: a = "", y: b = true} of array) { - ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. - a; - b; - } \ No newline at end of file diff --git a/tests/baselines/reference/for-of43.symbols b/tests/baselines/reference/for-of43.symbols new file mode 100644 index 00000000000..4add17ad547 --- /dev/null +++ b/tests/baselines/reference/for-of43.symbols @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of43.ts === +var array = [{ x: "", y: 0 }] +>array : Symbol(array, Decl(for-of43.ts, 0, 3)) +>x : Symbol(x, Decl(for-of43.ts, 0, 14)) +>y : Symbol(y, Decl(for-of43.ts, 0, 21)) + +for (var {x: a = "", y: b = true} of array) { +>x : Symbol(x, Decl(for-of43.ts, 0, 14)) +>a : Symbol(a, Decl(for-of43.ts, 1, 10)) +>y : Symbol(y, Decl(for-of43.ts, 0, 21)) +>b : Symbol(b, Decl(for-of43.ts, 1, 20)) +>array : Symbol(array, Decl(for-of43.ts, 0, 3)) + + a; +>a : Symbol(a, Decl(for-of43.ts, 1, 10)) + + b; +>b : Symbol(b, Decl(for-of43.ts, 1, 20)) +} diff --git a/tests/baselines/reference/for-of43.types b/tests/baselines/reference/for-of43.types new file mode 100644 index 00000000000..a11cd47182c --- /dev/null +++ b/tests/baselines/reference/for-of43.types @@ -0,0 +1,25 @@ +=== tests/cases/conformance/es6/for-ofStatements/for-of43.ts === +var array = [{ x: "", y: 0 }] +>array : { x: string; y: number; }[] +>[{ x: "", y: 0 }] : { x: string; y: number; }[] +>{ x: "", y: 0 } : { x: string; y: number; } +>x : string +>"" : string +>y : number +>0 : number + +for (var {x: a = "", y: b = true} of array) { +>x : any +>a : string +>"" : string +>y : any +>b : number | boolean +>true : boolean +>array : { x: string; y: number; }[] + + a; +>a : string + + b; +>b : number | boolean +} diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types index ef0a3f2c25b..9d07a26558d 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types @@ -33,13 +33,13 @@ let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error >3 : number let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error ->a3 : number +>a3 : any >undefined : any >undefined : undefined ->b3 : number +>b3 : any >null : any >null : null ->c3 : number +>c3 : any >undefined : any >undefined : undefined >[1, 2, 3] : [number, number, number] @@ -106,13 +106,13 @@ let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; >3 : number let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error ->x3 : number +>x3 : any >undefined : any >undefined : undefined ->y3 : number +>y3 : any >null : any >null : null ->z3 : number +>z3 : any >undefined : any >undefined : undefined >{ x3: 1, y3: 2, z3: 3 } : { x3?: number; y3?: number; z3?: number; } From dba310949f1fc05beaa8603320a2ec6e434a4472 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 27 Aug 2016 09:50:23 -0700 Subject: [PATCH 287/508] Use 'true' and 'false' types when contextual type is 'boolean' --- 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 9afa1c1e2c3..b59e4eae607 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -13464,7 +13464,7 @@ namespace ts { return maybeTypeOfKind(contextualType, (TypeFlags.NumberLiteral | TypeFlags.EnumLiteral)); } if (type.flags & TypeFlags.Boolean) { - return maybeTypeOfKind(contextualType, TypeFlags.BooleanLiteral) && !isTypeAssignableTo(booleanType, contextualType); + return maybeTypeOfKind(contextualType, TypeFlags.BooleanLiteral); } if (type.flags & TypeFlags.Enum) { return typeContainsLiteralFromEnum(contextualType, type); From d5c0c054beb671f073f6a8e292a878c495260804 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Sat, 27 Aug 2016 09:50:43 -0700 Subject: [PATCH 288/508] Accept new baselines --- .../amdImportNotAsPrimaryExpression.types | 2 +- .../reference/arrayBestCommonTypes.types | 28 ++++++------- .../reference/assignmentTypeNarrowing.types | 32 +++++++------- .../reference/asyncFunctionReturnType.types | 4 +- .../reference/bestCommonTypeOfTuple.types | 2 +- .../bitwiseNotOperatorWithBooleanType.types | 2 +- tests/baselines/reference/castTest.types | 2 +- .../checkSuperCallBeforeThisAccessing3.types | 4 +- ...OperatorWithSecondOperandBooleanType.types | 42 +++++++++---------- ...aOperatorWithSecondOperandNumberType.types | 8 ++-- ...commonJSImportNotAsPrimaryExpression.types | 2 +- ...onAssignmentWithInvalidOperands.errors.txt | 4 +- ...utedPropertyNamesContextualType6_ES5.types | 4 +- ...utedPropertyNamesContextualType6_ES6.types | 4 +- ...tionalOperatorConditionIsBooleanType.types | 4 +- .../reference/constEnumPropertyAccess1.types | 4 +- .../reference/contextuallyTypedIife.types | 2 +- .../controlFlowAssignmentExpression.types | 4 +- .../reference/controlFlowCommaOperator.types | 8 ++-- .../controlFlowDoWhileStatement.types | 10 ++--- .../reference/controlFlowForInStatement.types | 6 +-- .../reference/controlFlowForOfStatement.types | 6 +-- .../reference/controlFlowForStatement.types | 10 ++--- .../reference/controlFlowIfStatement.types | 10 ++--- .../reference/controlFlowWhileStatement.types | 10 ++--- .../reference/declFileFunctions.types | 8 ++-- .../declFileTypeAnnotationBuiltInType.types | 2 +- .../declarationsAndAssignments.errors.txt | 16 +++---- .../deleteOperatorWithBooleanType.types | 2 +- ...bjectBindingPatternAndAssignment1ES5.types | 8 ++-- ...bjectBindingPatternAndAssignment1ES6.types | 8 ++-- ...destructuringVariableDeclaration1ES5.types | 14 +++---- ...destructuringVariableDeclaration1ES6.types | 14 +++---- ...structuringVariableDeclaration2.errors.txt | 4 +- .../reference/emitArrowFunction.types | 8 ++-- .../reference/emitArrowFunctionES6.types | 8 ++-- .../emitArrowFunctionThisCapturing.types | 4 +- .../emitArrowFunctionThisCapturingES6.types | 4 +- .../emitClassDeclarationWithMethodInES6.types | 2 +- ...clarationWithPropertyAssignmentInES6.types | 4 +- .../reference/escapedIdentifiers.types | 10 ++--- tests/baselines/reference/for-of36.types | 4 +- tests/baselines/reference/for-of37.types | 6 +-- tests/baselines/reference/for-of38.types | 6 +-- tests/baselines/reference/for-of40.types | 6 +-- tests/baselines/reference/for-of44.types | 6 +-- tests/baselines/reference/for-of45.types | 12 +++--- tests/baselines/reference/for-of50.types | 6 +-- .../reference/functionOverloads39.types | 8 ++-- ...nericArgumentCallSigAssignmentCompat.types | 8 ++-- .../genericCallTypeArgumentInference.types | 12 +++--- .../genericClassWithStaticFactory.types | 16 +++---- .../genericTypeArgumentInference1.types | 8 ++-- ...CallSignatureReturningSpecialization.types | 2 +- .../reference/getterSetterNonAccessor.types | 8 ++-- .../reference/indexerWithTuple.types | 4 +- .../reference/interfaceContextualType.types | 20 ++++----- .../interfaceWithPropertyOfEveryType.types | 6 +-- .../reference/iterableArrayPattern30.types | 10 ++--- .../logicalNotOperatorWithBooleanType.types | 2 +- .../memberVariableDeclarations1.types | 4 +- .../moduleMemberWithoutTypeAnnotation1.types | 2 +- .../negateOperatorWithBooleanType.types | 2 +- .../reference/noImplicitReturnsInAsync1.types | 2 +- .../plusOperatorWithBooleanType.types | 2 +- ...ivacyCheckAnonymousFunctionParameter.types | 4 +- .../reference/returnStatements.types | 2 +- ...ymousTypeNotReferencingTypeParameter.types | 10 ++--- .../stringLiteralTypesOverloads01.types | 2 +- .../reference/symbolProperty18.types | 4 +- .../reference/symbolProperty21.errors.txt | 4 +- .../baselines/reference/targetTypeArgs.types | 16 +++---- ...rgedInterfacesWithDifferingOverloads.types | 2 +- ...gedInterfacesWithDifferingOverloads2.types | 6 +-- tests/baselines/reference/typeAliases.types | 4 +- .../reference/typeGuardFunction.types | 6 +-- .../typeGuardFunctionOfFormThis.types | 8 ++-- .../reference/typeGuardNesting.types | 8 ++-- .../reference/typeGuardOfFormIsType.types | 6 +-- .../typeGuardOfFormIsTypeOnInterfaces.types | 6 +-- .../reference/typeGuardsInDoStatement.types | 12 +++--- .../reference/typeGuardsOnClassProperty.types | 6 +-- ...sTypeParameterConstraintTransitively.types | 12 +++--- ...TypeParameterConstraintTransitively2.types | 12 +++--- .../typeofOperatorWithBooleanType.types | 2 +- .../baselines/reference/underscoreTest1.types | 20 ++++----- .../reference/unionTypeCallSignatures2.types | 12 +++--- .../reference/unionTypeInference.types | 4 +- .../voidOperatorWithBooleanType.types | 2 +- 89 files changed, 331 insertions(+), 331 deletions(-) diff --git a/tests/baselines/reference/amdImportNotAsPrimaryExpression.types b/tests/baselines/reference/amdImportNotAsPrimaryExpression.types index 5d90a8dadc2..9d9faf05af8 100644 --- a/tests/baselines/reference/amdImportNotAsPrimaryExpression.types +++ b/tests/baselines/reference/amdImportNotAsPrimaryExpression.types @@ -28,7 +28,7 @@ var y: typeof foo.C1.s1 = false; >foo : typeof foo >C1 : typeof foo.C1 >s1 : boolean ->false : boolean +>false : false var z: foo.M1.I2; >z : f.I2 diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index 2e87dc2ca15..0b4a871cd40 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -255,16 +255,16 @@ module EmptyTypes { >x : boolean >y : base >base : base ->[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: derived; }[] ->{ x: true, y: new derived() } : { x: boolean; y: derived; } ->x : boolean ->true : boolean +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: true; y: derived; } | { x: false; y: base; })[] +>{ x: true, y: new derived() } : { x: true; y: derived; } +>x : true +>true : true >y : derived >new derived() : derived >derived : typeof derived ->{ x: false, y: new base() } : { x: boolean; y: base; } ->x : boolean ->false : boolean +>{ x: false, y: new base() } : { x: false; y: base; } +>x : false +>false : false >y : base >new base() : base >base : typeof base @@ -658,16 +658,16 @@ module NonEmptyTypes { >x : boolean >y : base >base : base ->[{ x: true, y: new derived() }, { x: false, y: new base() }] : { x: boolean; y: base; }[] ->{ x: true, y: new derived() } : { x: boolean; y: derived; } ->x : boolean ->true : boolean +>[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: true; y: derived; } | { x: false; y: base; })[] +>{ x: true, y: new derived() } : { x: true; y: derived; } +>x : true +>true : true >y : derived >new derived() : derived >derived : typeof derived ->{ x: false, y: new base() } : { x: boolean; y: base; } ->x : boolean ->false : boolean +>{ x: false, y: new base() } : { x: false; y: base; } +>x : false +>false : false >y : base >new base() : base >base : typeof base diff --git a/tests/baselines/reference/assignmentTypeNarrowing.types b/tests/baselines/reference/assignmentTypeNarrowing.types index be99a31501d..f46b2a16c3b 100644 --- a/tests/baselines/reference/assignmentTypeNarrowing.types +++ b/tests/baselines/reference/assignmentTypeNarrowing.types @@ -12,14 +12,14 @@ x; // string >x : string [x] = [true]; ->[x] = [true] : [boolean] +>[x] = [true] : [true] >[x] : [string | number | boolean | RegExp] >x : string | number | boolean | RegExp ->[true] : [boolean] ->true : boolean +>[true] : [true] +>true : true x; // boolean ->x : boolean +>x : true [x = ""] = [1]; >[x = ""] = [1] : [number] @@ -34,16 +34,16 @@ x; // string | number >x : string | number ({x} = {x: true}); ->({x} = {x: true}) : { x: boolean; } ->{x} = {x: true} : { x: boolean; } +>({x} = {x: true}) : { x: true; } +>{x} = {x: true} : { x: true; } >{x} : { x: string | number | boolean | RegExp; } >x : string | number | boolean | RegExp ->{x: true} : { x: boolean; } ->x : boolean ->true : boolean +>{x: true} : { x: true; } +>x : true +>true : true x; // boolean ->x : boolean +>x : true ({y: x} = {y: 1}); >({y: x} = {y: 1}) : { y: number; } @@ -59,16 +59,16 @@ x; // number >x : number ({x = ""} = {x: true}); ->({x = ""} = {x: true}) : { x?: boolean; } ->{x = ""} = {x: true} : { x?: boolean; } +>({x = ""} = {x: true}) : { x?: true; } +>{x = ""} = {x: true} : { x?: true; } >{x = ""} : { x?: string | number | boolean | RegExp; } >x : string | number | boolean | RegExp ->{x: true} : { x?: boolean; } ->x : boolean ->true : boolean +>{x: true} : { x?: true; } +>x : true +>true : true x; // string | boolean ->x : string | boolean +>x : string | true ({y: x = /a/} = {y: 1}); >({y: x = /a/} = {y: 1}) : { y?: number; } diff --git a/tests/baselines/reference/asyncFunctionReturnType.types b/tests/baselines/reference/asyncFunctionReturnType.types index c6289ab012d..f848f7e1546 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.types +++ b/tests/baselines/reference/asyncFunctionReturnType.types @@ -15,8 +15,8 @@ async function fAsyncExplicit(): Promise<[number, boolean]> { // This is contextually typed as a tuple. return [1, true]; ->[1, true] : [number, boolean] +>[1, true] : [number, true] >1 : number ->true : boolean +>true : true } diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.types b/tests/baselines/reference/bestCommonTypeOfTuple.types index 6aa84f37eba..02c504b6ec3 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple.types @@ -12,7 +12,7 @@ function f2(x: number): number { return 10; } function f3(x: number): boolean { return true; } >f3 : (x: number) => boolean >x : number ->true : boolean +>true : true enum E1 { one } >E1 : E1 diff --git a/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types b/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types index 234c01e2241..34e2b31a7e8 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types +++ b/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types @@ -5,7 +5,7 @@ var BOOLEAN: boolean; function foo(): boolean { return true; } >foo : () => boolean ->true : boolean +>true : true class A { >A : A diff --git a/tests/baselines/reference/castTest.types b/tests/baselines/reference/castTest.types index 35698219fd4..03e119d17ed 100644 --- a/tests/baselines/reference/castTest.types +++ b/tests/baselines/reference/castTest.types @@ -23,7 +23,7 @@ var a = 0; var b = true; >b : boolean >true : boolean ->true : boolean +>true : true var s = ""; >s : string diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types index c4e9e15ed8e..a26ca2a6d79 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types @@ -18,11 +18,11 @@ class Derived extends Based { constructor() { this.y = true; ->this.y = true : boolean +>this.y = true : true >this.y : boolean >this : this >y : boolean ->true : boolean +>true : true } } super(); diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandBooleanType.types b/tests/baselines/reference/commaOperatorWithSecondOperandBooleanType.types index dba5285d880..b846d2cd56b 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandBooleanType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandBooleanType.types @@ -111,32 +111,32 @@ ANY = undefined, BOOLEAN; >BOOLEAN : boolean OBJECT = [1, 2, 3], BOOLEAN = false; ->OBJECT = [1, 2, 3], BOOLEAN = false : boolean +>OBJECT = [1, 2, 3], BOOLEAN = false : false >OBJECT = [1, 2, 3] : number[] >OBJECT : Object >[1, 2, 3] : number[] >1 : number >2 : number >3 : number ->BOOLEAN = false : boolean +>BOOLEAN = false : false >BOOLEAN : boolean ->false : boolean +>false : false var resultIsBoolean6 = (null, BOOLEAN); ->resultIsBoolean6 : boolean ->(null, BOOLEAN) : boolean ->null, BOOLEAN : boolean +>resultIsBoolean6 : false +>(null, BOOLEAN) : false +>null, BOOLEAN : false >null : null ->BOOLEAN : boolean +>BOOLEAN : false var resultIsBoolean7 = (ANY = undefined, BOOLEAN); ->resultIsBoolean7 : boolean ->(ANY = undefined, BOOLEAN) : boolean ->ANY = undefined, BOOLEAN : boolean +>resultIsBoolean7 : false +>(ANY = undefined, BOOLEAN) : false +>ANY = undefined, BOOLEAN : false >ANY = undefined : undefined >ANY : any >undefined : undefined ->BOOLEAN : boolean +>BOOLEAN : false var resultIsBoolean8 = (1, true); >resultIsBoolean8 : boolean @@ -154,27 +154,27 @@ var resultIsBoolean9 = (++NUMBER, true); >true : boolean var resultIsBoolean10 = ([1, 2, 3], !BOOLEAN); ->resultIsBoolean10 : boolean ->([1, 2, 3], !BOOLEAN) : boolean ->[1, 2, 3], !BOOLEAN : boolean +>resultIsBoolean10 : true +>([1, 2, 3], !BOOLEAN) : true +>[1, 2, 3], !BOOLEAN : true >[1, 2, 3] : number[] >1 : number >2 : number >3 : number ->!BOOLEAN : boolean ->BOOLEAN : boolean +>!BOOLEAN : true +>BOOLEAN : false var resultIsBoolean11 = (OBJECT = [1, 2, 3], BOOLEAN = false); ->resultIsBoolean11 : boolean ->(OBJECT = [1, 2, 3], BOOLEAN = false) : boolean ->OBJECT = [1, 2, 3], BOOLEAN = false : boolean +>resultIsBoolean11 : false +>(OBJECT = [1, 2, 3], BOOLEAN = false) : false +>OBJECT = [1, 2, 3], BOOLEAN = false : false >OBJECT = [1, 2, 3] : number[] >OBJECT : Object >[1, 2, 3] : number[] >1 : number >2 : number >3 : number ->BOOLEAN = false : boolean +>BOOLEAN = false : false >BOOLEAN : boolean ->false : boolean +>false : false diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandNumberType.types b/tests/baselines/reference/commaOperatorWithSecondOperandNumberType.types index 13aae51e0cb..7706cc55441 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandNumberType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandNumberType.types @@ -97,9 +97,9 @@ true, 1; BOOLEAN = false, 1; >BOOLEAN = false, 1 : number ->BOOLEAN = false : boolean +>BOOLEAN = false : false >BOOLEAN : boolean ->false : boolean +>false : false >1 : number "", NUMBER = 1; @@ -146,9 +146,9 @@ var resultIsNumber9 = (BOOLEAN = false, 1); >resultIsNumber9 : number >(BOOLEAN = false, 1) : number >BOOLEAN = false, 1 : number ->BOOLEAN = false : boolean +>BOOLEAN = false : false >BOOLEAN : boolean ->false : boolean +>false : false >1 : number var resultIsNumber10 = ("", NUMBER = 1); diff --git a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.types b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.types index 5d90a8dadc2..9d9faf05af8 100644 --- a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.types +++ b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.types @@ -28,7 +28,7 @@ var y: typeof foo.C1.s1 = false; >foo : typeof foo >C1 : typeof foo.C1 >s1 : boolean ->false : boolean +>false : false var z: foo.M1.I2; >z : f.I2 diff --git a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt index 45be0c3129f..2bc8a82ed3b 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(6,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'void'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(7,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(7,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(8,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'number'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. @@ -38,7 +38,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen !!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'void'. x1 += true; ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. +!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'true'. x1 += 0; ~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'number'. diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types index e5b7440f49e..564689ffdeb 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; [x: number]: number | (() => void) | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | true | (() => void) | number[]; [x: number]: number | (() => void) | number[]; 0: () => void; p: string; } p: "", >p : string @@ -32,7 +32,7 @@ foo({ >"hi" + "bye" : string >"hi" : string >"bye" : string ->true : boolean +>true : true [0 + 1]: 0, >0 + 1 : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types index 71498d7f3d4..a771faba97e 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types @@ -19,7 +19,7 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | boolean | (() => void) | number[]; [x: number]: number | (() => void) | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | true | (() => void) | number[]; [x: number]: number | (() => void) | number[]; 0: () => void; p: string; } p: "", >p : string @@ -32,7 +32,7 @@ foo({ >"hi" + "bye" : string >"hi" : string >"bye" : string ->true : boolean +>true : true [0 + 1]: 0, >0 + 1 : number diff --git a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types index ec3bd526e9e..7733b80f69b 100644 --- a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types +++ b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.types @@ -146,7 +146,7 @@ true || false ? exprIsObject1 : exprIsObject2; >true || false ? exprIsObject1 : exprIsObject2 : Object >true || false : boolean >true : boolean ->false : boolean +>false : false >exprIsObject1 : Object >exprIsObject2 : Object @@ -291,7 +291,7 @@ var resultIsObject3 = true || false ? exprIsObject1 : exprIsObject2; >true || false ? exprIsObject1 : exprIsObject2 : Object >true || false : boolean >true : boolean ->false : boolean +>false : false >exprIsObject1 : Object >exprIsObject2 : Object diff --git a/tests/baselines/reference/constEnumPropertyAccess1.types b/tests/baselines/reference/constEnumPropertyAccess1.types index f0e00fe7717..e32ae5a6449 100644 --- a/tests/baselines/reference/constEnumPropertyAccess1.types +++ b/tests/baselines/reference/constEnumPropertyAccess1.types @@ -35,10 +35,10 @@ var o: { >idx : number } = { ->{ 1: true } : { 1: boolean; } +>{ 1: true } : { 1: true; } 1: true ->true : boolean +>true : true }; diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index 8777e3cef3f..2f12e543356 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -43,7 +43,7 @@ >c : boolean >"foo" : string >101 : number ->false : boolean +>false : false // default parameters ((m = 10) => m + 1)(12); diff --git a/tests/baselines/reference/controlFlowAssignmentExpression.types b/tests/baselines/reference/controlFlowAssignmentExpression.types index 107fb4cb332..94e71b1fd2a 100644 --- a/tests/baselines/reference/controlFlowAssignmentExpression.types +++ b/tests/baselines/reference/controlFlowAssignmentExpression.types @@ -21,9 +21,9 @@ x; // number >x : number x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean ->true : boolean +>true : true (x = "", obj).foo = (x = x.length); >(x = "", obj).foo = (x = x.length) : number diff --git a/tests/baselines/reference/controlFlowCommaOperator.types b/tests/baselines/reference/controlFlowCommaOperator.types index 211fae3655a..8df5b8e7889 100644 --- a/tests/baselines/reference/controlFlowCommaOperator.types +++ b/tests/baselines/reference/controlFlowCommaOperator.types @@ -5,11 +5,11 @@ function f(x: string | number | boolean) { let y: string | number | boolean = false; >y : string | number | boolean ->false : boolean +>false : false let z: string | number | boolean = false; >z : string | number | boolean ->false : boolean +>false : false if (y = "", typeof x === "string") { >y = "", typeof x === "string" : boolean @@ -28,7 +28,7 @@ function f(x: string | number | boolean) { >y : string z; // boolean ->z : boolean +>z : false } else if (z = 1, typeof x === "number") { >z = 1, typeof x === "number" : boolean @@ -66,6 +66,6 @@ function f(x: string | number | boolean) { >y : string z; // number | boolean ->z : number | boolean +>z : number | false } diff --git a/tests/baselines/reference/controlFlowDoWhileStatement.types b/tests/baselines/reference/controlFlowDoWhileStatement.types index 55329cbcea1..d7916f51dfb 100644 --- a/tests/baselines/reference/controlFlowDoWhileStatement.types +++ b/tests/baselines/reference/controlFlowDoWhileStatement.types @@ -155,9 +155,9 @@ function f() { >cond : boolean x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean | Function | RegExp ->true : boolean +>true : true continue; } @@ -170,7 +170,7 @@ function f() { >cond : boolean x; // number | boolean | RegExp ->x : number | boolean | RegExp +>x : number | true | RegExp } function g() { >g : () => void @@ -200,9 +200,9 @@ function g() { >cond : boolean x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean | Function | RegExp ->true : boolean +>true : true continue; } diff --git a/tests/baselines/reference/controlFlowForInStatement.types b/tests/baselines/reference/controlFlowForInStatement.types index cab3a701602..1930071aeb5 100644 --- a/tests/baselines/reference/controlFlowForInStatement.types +++ b/tests/baselines/reference/controlFlowForInStatement.types @@ -38,13 +38,13 @@ for (let y in obj) { >cond : boolean x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean | Function | RegExp ->true : boolean +>true : true break; } } x; // RegExp | string | number | boolean ->x : string | number | boolean | RegExp +>x : string | number | true | RegExp diff --git a/tests/baselines/reference/controlFlowForOfStatement.types b/tests/baselines/reference/controlFlowForOfStatement.types index 41e312347e7..91e0d0a5758 100644 --- a/tests/baselines/reference/controlFlowForOfStatement.types +++ b/tests/baselines/reference/controlFlowForOfStatement.types @@ -10,9 +10,9 @@ function a() { >a : () => void x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean | RegExp ->true : boolean +>true : true for (x of obj) { >x : string | number | boolean | RegExp @@ -27,6 +27,6 @@ function a() { >toExponential : (fractionDigits?: number) => string } x; // string | boolean ->x : string | boolean +>x : string | true } diff --git a/tests/baselines/reference/controlFlowForStatement.types b/tests/baselines/reference/controlFlowForStatement.types index d0b0a2e6b8a..c16ee4f45ec 100644 --- a/tests/baselines/reference/controlFlowForStatement.types +++ b/tests/baselines/reference/controlFlowForStatement.types @@ -108,16 +108,16 @@ function e() { >0 : number >typeof x !== "string" : boolean >typeof x : string ->x : string | number | boolean +>x : string | number | true >"string" : "string" ->x = "" || true : string | boolean +>x = "" || true : string | true >x : string | number | boolean | RegExp ->"" || true : string | boolean +>"" || true : string | true >"" : string ->true : boolean +>true : true x; // number | boolean ->x : number | boolean +>x : number | true } } function f() { diff --git a/tests/baselines/reference/controlFlowIfStatement.types b/tests/baselines/reference/controlFlowIfStatement.types index 79985378bf5..fe609d98fb4 100644 --- a/tests/baselines/reference/controlFlowIfStatement.types +++ b/tests/baselines/reference/controlFlowIfStatement.types @@ -12,12 +12,12 @@ x = /a/; >/a/ : RegExp if (x /* RegExp */, (x = true)) { ->x /* RegExp */, (x = true) : boolean +>x /* RegExp */, (x = true) : true >x : RegExp ->(x = true) : boolean ->x = true : boolean +>(x = true) : true +>x = true : true >x : string | number | boolean | RegExp ->true : boolean +>true : true x; // boolean >x : true @@ -29,7 +29,7 @@ if (x /* RegExp */, (x = true)) { } else { x; // boolean ->x : boolean +>x : true x = 42; >x = 42 : number diff --git a/tests/baselines/reference/controlFlowWhileStatement.types b/tests/baselines/reference/controlFlowWhileStatement.types index 8caae2238d2..09a127ab51e 100644 --- a/tests/baselines/reference/controlFlowWhileStatement.types +++ b/tests/baselines/reference/controlFlowWhileStatement.types @@ -161,9 +161,9 @@ function f() { >cond : true x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean | Function | RegExp ->true : boolean +>true : true continue; } @@ -173,7 +173,7 @@ function f() { >/a/ : RegExp } x; // string | number | boolean | RegExp ->x : string | number | boolean | RegExp +>x : string | number | true | RegExp } function g() { >g : () => void @@ -205,9 +205,9 @@ function g() { >cond : boolean x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean | Function | RegExp ->true : boolean +>true : true continue; } diff --git a/tests/baselines/reference/declFileFunctions.types b/tests/baselines/reference/declFileFunctions.types index 9ad974463b7..87840f39430 100644 --- a/tests/baselines/reference/declFileFunctions.types +++ b/tests/baselines/reference/declFileFunctions.types @@ -66,7 +66,7 @@ export function fooWithTypePredicate(a: any): a is number { >a : any return true; ->true : boolean +>true : true } export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a is number { >fooWithTypePredicateAndMulitpleParams : (a: any, b: any, c: any) => a is number @@ -76,7 +76,7 @@ export function fooWithTypePredicateAndMulitpleParams(a: any, b: any, c: any): a >a : any return true; ->true : boolean +>true : true } export function fooWithTypeTypePredicateAndGeneric(a: any): a is T { >fooWithTypeTypePredicateAndGeneric : (a: any) => a is T @@ -86,7 +86,7 @@ export function fooWithTypeTypePredicateAndGeneric(a: any): a is T { >T : T return true; ->true : boolean +>true : true } export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is number { >fooWithTypeTypePredicateAndRestParam : (a: any, ...rest: any[]) => a is number @@ -95,7 +95,7 @@ export function fooWithTypeTypePredicateAndRestParam(a: any, ...rest): a is numb >a : any return true; ->true : boolean +>true : true } /** This comment should appear for nonExportedFoo*/ diff --git a/tests/baselines/reference/declFileTypeAnnotationBuiltInType.types b/tests/baselines/reference/declFileTypeAnnotationBuiltInType.types index a1b2d9edd43..2e187f0ec83 100644 --- a/tests/baselines/reference/declFileTypeAnnotationBuiltInType.types +++ b/tests/baselines/reference/declFileTypeAnnotationBuiltInType.types @@ -33,7 +33,7 @@ function foo5(): boolean { >foo5 : () => boolean return true; ->true : boolean +>true : true } function foo6() { >foo6 : () => boolean diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 33c2db0a550..4aa81dce7ae 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -17,10 +17,10 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,11): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(73,14): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,11): error TS2459: Type 'undefined[]' has no property 'a' and no string index signature. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(74,14): error TS2459: Type 'undefined[]' has no property 'b' and no string index signature. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. - Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. - Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. - Property 'x' is missing in type '{ y: boolean; }'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(106,5): error TS2345: Argument of type '[number, [string, { y: false; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. + Type '[string, { y: false; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. + Type '{ y: false; }' is not assignable to type '{ x: any; y?: boolean; }'. + Property 'x' is missing in type '{ y: false; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,6): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): error TS2322: Type 'number' is not assignable to type 'string'. @@ -171,10 +171,10 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): f14([2, ["abc", { x: 0 }]]); f14([2, ["abc", { y: false }]]); // Error, no x ~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, [string, { y: boolean; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. -!!! error TS2345: Type '[string, { y: boolean; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. -!!! error TS2345: Type '{ y: boolean; }' is not assignable to type '{ x: any; y?: boolean; }'. -!!! error TS2345: Property 'x' is missing in type '{ y: boolean; }'. +!!! error TS2345: Argument of type '[number, [string, { y: false; }]]' is not assignable to parameter of type '[number, [string, { x: any; y?: boolean; }]]'. +!!! error TS2345: Type '[string, { y: false; }]' is not assignable to type '[string, { x: any; y?: boolean; }]'. +!!! error TS2345: Type '{ y: false; }' is not assignable to type '{ x: any; y?: boolean; }'. +!!! error TS2345: Property 'x' is missing in type '{ y: false; }'. module M { export var [a, b] = [1, 2]; diff --git a/tests/baselines/reference/deleteOperatorWithBooleanType.types b/tests/baselines/reference/deleteOperatorWithBooleanType.types index 068c67031ef..81c12ad6182 100644 --- a/tests/baselines/reference/deleteOperatorWithBooleanType.types +++ b/tests/baselines/reference/deleteOperatorWithBooleanType.types @@ -5,7 +5,7 @@ var BOOLEAN: boolean; function foo(): boolean { return true; } >foo : () => boolean ->true : boolean +>true : true class A { >A : A diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types index cb6052d93fd..2301902bf64 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types @@ -69,10 +69,10 @@ function foo(): F { >F : F return { ->{ 1: true } : { 1: boolean; } +>{ 1: true } : { 1: true; } 1: true ->true : boolean +>true : true }; } @@ -82,10 +82,10 @@ function bar(): F { >F : F return { ->{ 2: true } : { 2: boolean; } +>{ 2: true } : { 2: true; } 2: true ->true : boolean +>true : true }; } diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types index 2d77c20f65b..48428881290 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types @@ -69,10 +69,10 @@ function foo(): F { >F : F return { ->{ 1: true } : { 1: boolean; } +>{ 1: true } : { 1: true; } 1: true ->true : boolean +>true : true }; } @@ -82,10 +82,10 @@ function bar(): F { >F : F return { ->{ 2: true } : { 2: boolean; } +>{ 2: true } : { 2: true; } 2: true ->true : boolean +>true : true }; } diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index 35eb23c9e6a..191cdc169b1 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -16,12 +16,12 @@ var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; >a3 : number >a4 : string >a5 : boolean ->[1, [["hello"]], true] : [number, [[string]], boolean] +>[1, [["hello"]], true] : [number, [[string]], true] >1 : number >[["hello"]] : [[string]] >["hello"] : [string] >"hello" : string ->true : boolean +>true : true // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. @@ -52,12 +52,12 @@ var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; >true : boolean >b4 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } ->[3, false, { t1: false, t2: "hello" }] : [number, boolean, { t1: boolean; t2: string; }] +>[3, false, { t1: false, t2: "hello" }] : [number, false, { t1: false; t2: string; }] >3 : number ->false : boolean ->{ t1: false, t2: "hello" } : { t1: boolean; t2: string; } ->t1 : boolean ->false : boolean +>false : false +>{ t1: false, t2: "hello" } : { t1: false; t2: string; } +>t1 : false +>false : false >t2 : string >"hello" : string diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index f124e203e1f..50f5cfc8a5a 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -16,12 +16,12 @@ var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; >a3 : number >a4 : string >a5 : boolean ->[1, [["hello"]], true] : [number, [[string]], boolean] +>[1, [["hello"]], true] : [number, [[string]], true] >1 : number >[["hello"]] : [[string]] >["hello"] : [string] >"hello" : string ->true : boolean +>true : true // The type T associated with a destructuring variable declaration is determined as follows: // Otherwise, if the declaration includes an initializer expression, T is the type of that initializer expression. @@ -52,12 +52,12 @@ var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; >true : boolean >b4 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } ->[3, false, { t1: false, t2: "hello" }] : [number, boolean, { t1: boolean; t2: string; }] +>[3, false, { t1: false, t2: "hello" }] : [number, false, { t1: false; t2: string; }] >3 : number ->false : boolean ->{ t1: false, t2: "hello" } : { t1: boolean; t2: string; } ->t1 : boolean ->false : boolean +>false : false +>{ t1: false, t2: "hello" } : { t1: false; t2: string; } +>t1 : false +>false : false >t2 : string >"hello" : string diff --git a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt index 7658de962d9..c831b10a467 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt +++ b/tests/baselines/reference/destructuringVariableDeclaration2.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(3,5): error TS2322: Type '{ a1: boolean; a2: number; }' is not assignable to type '{ a1: number; a2: string; }'. Types of property 'a1' are incompatible. Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,5): error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'. +tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(4,5): error TS2322: Type '[number, [[boolean]], true]' is not assignable to type '[number, [[string]], boolean]'. Type '[[boolean]]' is not assignable to type '[[string]]'. Type '[boolean]' is not assignable to type '[string]'. Type 'boolean' is not assignable to type 'string'. @@ -19,7 +19,7 @@ tests/cases/conformance/es6/destructuring/destructuringVariableDeclaration2.ts(1 !!! error TS2322: Type 'boolean' is not assignable to type 'number'. var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [[false]], true]; // Error ~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '[number, [[boolean]], boolean]' is not assignable to type '[number, [[string]], boolean]'. +!!! error TS2322: Type '[number, [[boolean]], true]' is not assignable to type '[number, [[string]], boolean]'. !!! error TS2322: Type '[[boolean]]' is not assignable to type '[[string]]'. !!! error TS2322: Type '[boolean]' is not assignable to type '[string]'. !!! error TS2322: Type 'boolean' is not assignable to type 'string'. diff --git a/tests/baselines/reference/emitArrowFunction.types b/tests/baselines/reference/emitArrowFunction.types index 2ac9ef07af4..a4671ea5a31 100644 --- a/tests/baselines/reference/emitArrowFunction.types +++ b/tests/baselines/reference/emitArrowFunction.types @@ -31,12 +31,12 @@ function foo(func: () => boolean) { } foo(() => true); >foo(() => true) : void >foo : (func: () => boolean) => void ->() => true : () => boolean ->true : boolean +>() => true : () => true +>true : true foo(() => { return false; }); >foo(() => { return false; }) : void >foo : (func: () => boolean) => void ->() => { return false; } : () => boolean ->false : boolean +>() => { return false; } : () => false +>false : false diff --git a/tests/baselines/reference/emitArrowFunctionES6.types b/tests/baselines/reference/emitArrowFunctionES6.types index d37c08f855c..2cadcf2cac9 100644 --- a/tests/baselines/reference/emitArrowFunctionES6.types +++ b/tests/baselines/reference/emitArrowFunctionES6.types @@ -31,14 +31,14 @@ function foo(func: () => boolean) { } foo(() => true); >foo(() => true) : void >foo : (func: () => boolean) => void ->() => true : () => boolean ->true : boolean +>() => true : () => true +>true : true foo(() => { return false; }); >foo(() => { return false; }) : void >foo : (func: () => boolean) => void ->() => { return false; } : () => boolean ->false : boolean +>() => { return false; } : () => false +>false : false // Binding patterns in arrow functions var p1 = ([a]) => { }; diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.types b/tests/baselines/reference/emitArrowFunctionThisCapturing.types index 2cfe06579af..81dc5d83f0d 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.types +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.types @@ -32,7 +32,7 @@ function foo(func: () => boolean) { } foo(() => { >foo(() => { this.age = 100; return true;}) : void >foo : (func: () => boolean) => void ->() => { this.age = 100; return true;} : () => boolean +>() => { this.age = 100; return true;} : () => true this.age = 100; >this.age = 100 : number @@ -42,7 +42,7 @@ foo(() => { >100 : number return true; ->true : boolean +>true : true }); diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types index cc5405cebb4..a16b6391f02 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types @@ -32,7 +32,7 @@ function foo(func: () => boolean){ } foo(() => { >foo(() => { this.age = 100; return true;}) : void >foo : (func: () => boolean) => void ->() => { this.age = 100; return true;} : () => boolean +>() => { this.age = 100; return true;} : () => true this.age = 100; >this.age = 100 : number @@ -42,7 +42,7 @@ foo(() => { >100 : number return true; ->true : boolean +>true : true }); diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types index 02a90729486..a42c019cd40 100644 --- a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types @@ -46,7 +46,7 @@ class D { static ["computedname6"](a: string): boolean { return true; } >"computedname6" : string >a : string ->true : boolean +>true : true static staticMethod() { >staticMethod : () => number diff --git a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types index ccf4ca3ca9d..79899e77bee 100644 --- a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types @@ -33,7 +33,7 @@ class E extends D{ z: boolean = true; >z : boolean ->true : boolean +>true : true } class F extends D{ @@ -42,7 +42,7 @@ class F extends D{ z: boolean = true; >z : boolean ->true : boolean +>true : true j: string; >j : string diff --git a/tests/baselines/reference/escapedIdentifiers.types b/tests/baselines/reference/escapedIdentifiers.types index 67713976bd6..151408de308 100644 --- a/tests/baselines/reference/escapedIdentifiers.types +++ b/tests/baselines/reference/escapedIdentifiers.types @@ -238,9 +238,9 @@ class testClass { >'string' : string arg\u0033 = true; ->arg\u0033 = true : boolean +>arg\u0033 = true : true >arg\u0033 : boolean ->true : boolean +>true : true arg4 = 2; >arg4 = 2 : number @@ -266,7 +266,7 @@ var constructorTestObject = new constructorTestClass(1, 'string', true, 2); >constructorTestClass : typeof constructorTestClass >1 : number >'string' : string ->true : boolean +>true : true >2 : number constructorTestObject.arg\u0031 = 1; @@ -284,11 +284,11 @@ constructorTestObject.arg2 = 'string'; >'string' : string constructorTestObject.arg\u0033 = true; ->constructorTestObject.arg\u0033 = true : boolean +>constructorTestObject.arg\u0033 = true : true >constructorTestObject.arg\u0033 : boolean >constructorTestObject : constructorTestClass >arg\u0033 : boolean ->true : boolean +>true : true constructorTestObject.arg4 = 2; >constructorTestObject.arg4 = 2 : number diff --git a/tests/baselines/reference/for-of36.types b/tests/baselines/reference/for-of36.types index e23ea79d0a9..f55b5377acc 100644 --- a/tests/baselines/reference/for-of36.types +++ b/tests/baselines/reference/for-of36.types @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/for-ofStatements/for-of36.ts === var tuple: [string, boolean] = ["", true]; >tuple : [string, boolean] ->["", true] : [string, boolean] +>["", true] : [string, true] >"" : string ->true : boolean +>true : true for (var v of tuple) { >v : string | boolean diff --git a/tests/baselines/reference/for-of37.types b/tests/baselines/reference/for-of37.types index 89272742f62..986e2678402 100644 --- a/tests/baselines/reference/for-of37.types +++ b/tests/baselines/reference/for-of37.types @@ -3,10 +3,10 @@ var map = new Map([["", true]]); >map : Map >new Map([["", true]]) : Map >Map : MapConstructor ->[["", true]] : [string, boolean][] ->["", true] : [string, boolean] +>[["", true]] : [string, true][] +>["", true] : [string, true] >"" : string ->true : boolean +>true : true for (var v of map) { >v : [string, boolean] diff --git a/tests/baselines/reference/for-of38.types b/tests/baselines/reference/for-of38.types index f8b7555781f..78223cfc5be 100644 --- a/tests/baselines/reference/for-of38.types +++ b/tests/baselines/reference/for-of38.types @@ -3,10 +3,10 @@ var map = new Map([["", true]]); >map : Map >new Map([["", true]]) : Map >Map : MapConstructor ->[["", true]] : [string, boolean][] ->["", true] : [string, boolean] +>[["", true]] : [string, true][] +>["", true] : [string, true] >"" : string ->true : boolean +>true : true for (var [k, v] of map) { >k : string diff --git a/tests/baselines/reference/for-of40.types b/tests/baselines/reference/for-of40.types index 6693514ec53..9d2207409f3 100644 --- a/tests/baselines/reference/for-of40.types +++ b/tests/baselines/reference/for-of40.types @@ -3,10 +3,10 @@ var map = new Map([["", true]]); >map : Map >new Map([["", true]]) : Map >Map : MapConstructor ->[["", true]] : [string, boolean][] ->["", true] : [string, boolean] +>[["", true]] : [string, true][] +>["", true] : [string, true] >"" : string ->true : boolean +>true : true for (var [k = "", v = false] of map) { >k : string diff --git a/tests/baselines/reference/for-of44.types b/tests/baselines/reference/for-of44.types index e6f4e0450b3..152edd6f165 100644 --- a/tests/baselines/reference/for-of44.types +++ b/tests/baselines/reference/for-of44.types @@ -1,13 +1,13 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : [number, string | boolean | symbol][] ->[[0, ""], [0, true], [1, Symbol()]] : ([number, string] | [number, boolean] | [number, symbol])[] +>[[0, ""], [0, true], [1, Symbol()]] : ([number, string] | [number, true] | [number, symbol])[] >[0, ""] : [number, string] >0 : number >"" : string ->[0, true] : [number, boolean] +>[0, true] : [number, true] >0 : number ->true : boolean +>true : true >[1, Symbol()] : [number, symbol] >1 : number >Symbol() : symbol diff --git a/tests/baselines/reference/for-of45.types b/tests/baselines/reference/for-of45.types index 7c853993b0a..a2a70ddfed3 100644 --- a/tests/baselines/reference/for-of45.types +++ b/tests/baselines/reference/for-of45.types @@ -7,19 +7,19 @@ var map = new Map([["", true]]); >map : Map >new Map([["", true]]) : Map >Map : MapConstructor ->[["", true]] : [string, boolean][] ->["", true] : [string, boolean] +>[["", true]] : [string, true][] +>["", true] : [string, true] >"" : string ->true : boolean +>true : true for ([k = "", v = false] of map) { ->[k = "", v = false] : [string, boolean] +>[k = "", v = false] : [string, false] >k = "" : string >k : string >"" : string ->v = false : boolean +>v = false : false >v : boolean ->false : boolean +>false : false >map : Map k; diff --git a/tests/baselines/reference/for-of50.types b/tests/baselines/reference/for-of50.types index 5d5dac7abed..87ad29793e8 100644 --- a/tests/baselines/reference/for-of50.types +++ b/tests/baselines/reference/for-of50.types @@ -3,10 +3,10 @@ var map = new Map([["", true]]); >map : Map >new Map([["", true]]) : Map >Map : MapConstructor ->[["", true]] : [string, boolean][] ->["", true] : [string, boolean] +>[["", true]] : [string, true][] +>["", true] : [string, true] >"" : string ->true : boolean +>true : true for (const [k, v] of map) { >k : string diff --git a/tests/baselines/reference/functionOverloads39.types b/tests/baselines/reference/functionOverloads39.types index 78c0e78bca1..bf4a6ec5ae9 100644 --- a/tests/baselines/reference/functionOverloads39.types +++ b/tests/baselines/reference/functionOverloads39.types @@ -19,8 +19,8 @@ var x = foo([{a:true}]); >x : number >foo([{a:true}]) : number >foo : { (bar: { a: number; }[]): string; (bar: { a: boolean; }[]): number; } ->[{a:true}] : { a: boolean; }[] ->{a:true} : { a: boolean; } ->a : boolean ->true : boolean +>[{a:true}] : { a: true; }[] +>{a:true} : { a: true; } +>a : true +>true : true diff --git a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types index c5fd984d327..f7dd10b11dd 100644 --- a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types +++ b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types @@ -49,8 +49,8 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean ->[true, 1, null, 'yes'] : (string | number | boolean)[] ->true : boolean +>[true, 1, null, 'yes'] : (string | number | true)[] +>true : true >1 : number >null : null >'yes' : string @@ -64,8 +64,8 @@ _.all([true], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean ->[true] : boolean[] ->true : boolean +>[true] : true[] +>true : true >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericCallTypeArgumentInference.types b/tests/baselines/reference/genericCallTypeArgumentInference.types index 0208ec74f1e..09cd907a5a9 100644 --- a/tests/baselines/reference/genericCallTypeArgumentInference.types +++ b/tests/baselines/reference/genericCallTypeArgumentInference.types @@ -202,7 +202,7 @@ var r6 = c.foo3(true, 1); // boolean >c.foo3 : (t: T, u: number) => T >c : C >foo3 : (t: T, u: number) => T ->true : boolean +>true : true >1 : number var r7 = c.foo4('', true); // string @@ -212,7 +212,7 @@ var r7 = c.foo4('', true); // string >c : C >foo4 : (t: string, u: U) => string >'' : string ->true : boolean +>true : true var r8 = c.foo5(true, 1); // boolean >r8 : boolean @@ -220,7 +220,7 @@ var r8 = c.foo5(true, 1); // boolean >c.foo5 : (t: T, u: U) => T >c : C >foo5 : (t: T, u: U) => T ->true : boolean +>true : true >1 : number var r9 = c.foo6(); // {} @@ -349,7 +349,7 @@ var r6 = i.foo3(true, 1); // boolean >i.foo3 : (t: T, u: number) => T >i : I >foo3 : (t: T, u: number) => T ->true : boolean +>true : true >1 : number var r7 = i.foo4('', true); // string @@ -359,7 +359,7 @@ var r7 = i.foo4('', true); // string >i : I >foo4 : (t: string, u: U) => string >'' : string ->true : boolean +>true : true var r8 = i.foo5(true, 1); // boolean >r8 : boolean @@ -367,7 +367,7 @@ var r8 = i.foo5(true, 1); // boolean >i.foo5 : (t: T, u: U) => T >i : I >foo5 : (t: T, u: U) => T ->true : boolean +>true : true >1 : number var r9 = i.foo6(); // {} diff --git a/tests/baselines/reference/genericClassWithStaticFactory.types b/tests/baselines/reference/genericClassWithStaticFactory.types index 2daad9003eb..c1af646e7fb 100644 --- a/tests/baselines/reference/genericClassWithStaticFactory.types +++ b/tests/baselines/reference/genericClassWithStaticFactory.types @@ -175,11 +175,11 @@ module Editor { >T : T entry.isHead = false; ->entry.isHead = false : boolean +>entry.isHead = false : false >entry.isHead : boolean >entry : List >isHead : boolean ->false : boolean +>false : false entry.next = this.next; >entry.next = this.next : List @@ -237,11 +237,11 @@ module Editor { >data : T entry.isHead = false; ->entry.isHead = false : boolean +>entry.isHead = false : false >entry.isHead : boolean >entry : List >isHead : boolean ->false : boolean +>false : false entry.next = this.next; >entry.next = this.next : List @@ -317,11 +317,11 @@ module Editor { >T : T entry.isHead = false; ->entry.isHead = false : boolean +>entry.isHead = false : false >entry.isHead : boolean >entry : List >isHead : boolean ->false : boolean +>false : false this.prev.next = entry; >this.prev.next = entry : List @@ -501,7 +501,7 @@ module Editor { >new List(true, null) : List >List : typeof List >T : T ->true : boolean +>true : true >null : null entry.prev = entry; @@ -537,7 +537,7 @@ module Editor { >new List(false, data) : List >List : typeof List >T : T ->false : boolean +>false : false >data : T entry.prev = entry; diff --git a/tests/baselines/reference/genericTypeArgumentInference1.types b/tests/baselines/reference/genericTypeArgumentInference1.types index 2d64c8f5c58..e2a570de28f 100644 --- a/tests/baselines/reference/genericTypeArgumentInference1.types +++ b/tests/baselines/reference/genericTypeArgumentInference1.types @@ -47,8 +47,8 @@ var r = _.all([true, 1, null, 'yes'], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T ->[true, 1, null, 'yes'] : (string | number | boolean)[] ->true : boolean +>[true, 1, null, 'yes'] : (string | number | true)[] +>true : true >1 : number >null : null >'yes' : string @@ -62,8 +62,8 @@ var r2 = _.all([true], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T ->[true] : boolean[] ->true : boolean +>[true] : true[] +>true : true >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericWithCallSignatureReturningSpecialization.types b/tests/baselines/reference/genericWithCallSignatureReturningSpecialization.types index c58d56e3a75..b314839a97e 100644 --- a/tests/baselines/reference/genericWithCallSignatureReturningSpecialization.types +++ b/tests/baselines/reference/genericWithCallSignatureReturningSpecialization.types @@ -18,5 +18,5 @@ var x: B; x(true); // was error >x(true) : void >x : B ->true : boolean +>true : true diff --git a/tests/baselines/reference/getterSetterNonAccessor.types b/tests/baselines/reference/getterSetterNonAccessor.types index 48d9f9c85e0..0534ca623e7 100644 --- a/tests/baselines/reference/getterSetterNonAccessor.types +++ b/tests/baselines/reference/getterSetterNonAccessor.types @@ -16,8 +16,8 @@ Object.defineProperty({}, "0", ({ >"0" : string >({ get: getFunc, set: setFunc, configurable: true }) : PropertyDescriptor >PropertyDescriptor : PropertyDescriptor ->({ get: getFunc, set: setFunc, configurable: true }) : { get: () => any; set: (v: any) => void; configurable: boolean; } ->{ get: getFunc, set: setFunc, configurable: true } : { get: () => any; set: (v: any) => void; configurable: boolean; } +>({ get: getFunc, set: setFunc, configurable: true }) : { get: () => any; set: (v: any) => void; configurable: true; } +>{ get: getFunc, set: setFunc, configurable: true } : { get: () => any; set: (v: any) => void; configurable: true; } get: getFunc, >get : () => any @@ -28,8 +28,8 @@ Object.defineProperty({}, "0", ({ >setFunc : (v: any) => void configurable: true ->configurable : boolean ->true : boolean +>configurable : true +>true : true })); diff --git a/tests/baselines/reference/indexerWithTuple.types b/tests/baselines/reference/indexerWithTuple.types index 4faae2cda29..54ee714f5ef 100644 --- a/tests/baselines/reference/indexerWithTuple.types +++ b/tests/baselines/reference/indexerWithTuple.types @@ -21,8 +21,8 @@ var unionTuple1: [number, string| number] = [10, "foo"]; var unionTuple2: [boolean, string| number] = [true, "foo"]; >unionTuple2 : [boolean, string | number] ->[true, "foo"] : [boolean, string] ->true : boolean +>[true, "foo"] : [true, string] +>true : true >"foo" : string // no error diff --git a/tests/baselines/reference/interfaceContextualType.types b/tests/baselines/reference/interfaceContextualType.types index 0e835a2f1f9..d1ff4021c5d 100644 --- a/tests/baselines/reference/interfaceContextualType.types +++ b/tests/baselines/reference/interfaceContextualType.types @@ -34,31 +34,31 @@ class Bug { >{} : {} this.values['comments'] = { italic: true }; ->this.values['comments'] = { italic: true } : { italic: boolean; } +>this.values['comments'] = { italic: true } : { italic: true; } >this.values['comments'] : IOptions >this.values : IMap >this : this >values : IMap >'comments' : string ->{ italic: true } : { italic: boolean; } ->italic : boolean ->true : boolean +>{ italic: true } : { italic: true; } +>italic : true +>true : true } shouldBeOK() { >shouldBeOK : () => void this.values = { ->this.values = { comments: { italic: true } } : { comments: { italic: boolean; }; } +>this.values = { comments: { italic: true } } : { comments: { italic: true; }; } >this.values : IMap >this : this >values : IMap ->{ comments: { italic: true } } : { comments: { italic: boolean; }; } +>{ comments: { italic: true } } : { comments: { italic: true; }; } comments: { italic: true } ->comments : { italic: boolean; } ->{ italic: true } : { italic: boolean; } ->italic : boolean ->true : boolean +>comments : { italic: true; } +>{ italic: true } : { italic: true; } +>italic : true +>true : true }; } diff --git a/tests/baselines/reference/interfaceWithPropertyOfEveryType.types b/tests/baselines/reference/interfaceWithPropertyOfEveryType.types index 7428ee73aa1..0ad754476a2 100644 --- a/tests/baselines/reference/interfaceWithPropertyOfEveryType.types +++ b/tests/baselines/reference/interfaceWithPropertyOfEveryType.types @@ -80,7 +80,7 @@ interface Foo { var a: Foo = { >a : Foo >Foo : Foo ->{ a: 1, b: '', c: true, d: {}, e: null , f: [1], g: {}, h: (x: number) => 1, i: (x: T) => x, j: null, k: new C(), l: f1, m: M, n: {}, o: E.A} : { a: number; b: string; c: boolean; d: {}; e: null; f: number[]; g: {}; h: (x: number) => number; i: (x: T) => T; j: Foo; k: C; l: () => void; m: typeof M; n: {}; o: E; } +>{ a: 1, b: '', c: true, d: {}, e: null , f: [1], g: {}, h: (x: number) => 1, i: (x: T) => x, j: null, k: new C(), l: f1, m: M, n: {}, o: E.A} : { a: number; b: string; c: true; d: {}; e: null; f: number[]; g: {}; h: (x: number) => number; i: (x: T) => T; j: Foo; k: C; l: () => void; m: typeof M; n: {}; o: E; } a: 1, >a : number @@ -91,8 +91,8 @@ var a: Foo = { >'' : string c: true, ->c : boolean ->true : boolean +>c : true +>true : true d: {}, >d : {} diff --git a/tests/baselines/reference/iterableArrayPattern30.types b/tests/baselines/reference/iterableArrayPattern30.types index d27db2e7544..8cfb50c3abb 100644 --- a/tests/baselines/reference/iterableArrayPattern30.types +++ b/tests/baselines/reference/iterableArrayPattern30.types @@ -6,11 +6,11 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >v2 : boolean >new Map([["", true], ["hello", true]]) : Map >Map : MapConstructor ->[["", true], ["hello", true]] : [string, boolean][] ->["", true] : [string, boolean] +>[["", true], ["hello", true]] : [string, true][] +>["", true] : [string, true] >"" : string ->true : boolean ->["hello", true] : [string, boolean] +>true : true +>["hello", true] : [string, true] >"hello" : string ->true : boolean +>true : true diff --git a/tests/baselines/reference/logicalNotOperatorWithBooleanType.types b/tests/baselines/reference/logicalNotOperatorWithBooleanType.types index b8aa6feac4c..63d5d38edda 100644 --- a/tests/baselines/reference/logicalNotOperatorWithBooleanType.types +++ b/tests/baselines/reference/logicalNotOperatorWithBooleanType.types @@ -5,7 +5,7 @@ var BOOLEAN: boolean; function foo(): boolean { return true; } >foo : () => boolean ->true : boolean +>true : true class A { >A : A diff --git a/tests/baselines/reference/memberVariableDeclarations1.types b/tests/baselines/reference/memberVariableDeclarations1.types index b7ec0fbaba0..6f3a3856e1c 100644 --- a/tests/baselines/reference/memberVariableDeclarations1.types +++ b/tests/baselines/reference/memberVariableDeclarations1.types @@ -47,11 +47,11 @@ class Employee2 { constructor() { this.retired = false; ->this.retired = false : boolean +>this.retired = false : false >this.retired : boolean >this : this >retired : boolean ->false : boolean +>false : false this.manager = null; >this.manager = null : null diff --git a/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types b/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types index c308f535a7a..733eb617c66 100644 --- a/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types +++ b/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types @@ -64,7 +64,7 @@ module TypeScript { >findToken : (position: number, includeSkippedTokens?: boolean) => PositionedToken >position : number >includeSkippedTokens : boolean ->false : boolean +>false : false >PositionedToken : PositionedToken var positionedToken = this.findTokenInternal(null, position, 0); diff --git a/tests/baselines/reference/negateOperatorWithBooleanType.types b/tests/baselines/reference/negateOperatorWithBooleanType.types index 89f5afc1c2b..bd61a560898 100644 --- a/tests/baselines/reference/negateOperatorWithBooleanType.types +++ b/tests/baselines/reference/negateOperatorWithBooleanType.types @@ -5,7 +5,7 @@ var BOOLEAN: boolean; function foo(): boolean { return true; } >foo : () => boolean ->true : boolean +>true : true class A { >A : A diff --git a/tests/baselines/reference/noImplicitReturnsInAsync1.types b/tests/baselines/reference/noImplicitReturnsInAsync1.types index 1dfc098675c..27746bdec5a 100644 --- a/tests/baselines/reference/noImplicitReturnsInAsync1.types +++ b/tests/baselines/reference/noImplicitReturnsInAsync1.types @@ -3,7 +3,7 @@ async function test(isError: boolean = false) { >test : (isError?: boolean) => Promise >isError : boolean ->false : boolean +>false : false if (isError === true) { >isError === true : boolean diff --git a/tests/baselines/reference/plusOperatorWithBooleanType.types b/tests/baselines/reference/plusOperatorWithBooleanType.types index d2218d3cc95..f688706c2e5 100644 --- a/tests/baselines/reference/plusOperatorWithBooleanType.types +++ b/tests/baselines/reference/plusOperatorWithBooleanType.types @@ -5,7 +5,7 @@ var BOOLEAN: boolean; function foo(): boolean { return true; } >foo : () => boolean ->true : boolean +>true : true class A { >A : A diff --git a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.types b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.types index c8e4d237091..fd5cafc037b 100644 --- a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.types +++ b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.types @@ -31,11 +31,11 @@ module Query { return fromDoWhile(test => { >fromDoWhile(test => { return true; }) : Iterator<{}> >fromDoWhile : (doWhile: (test: Iterator) => boolean) => Iterator ->test => { return true; } : (test: Iterator<{}>) => boolean +>test => { return true; } : (test: Iterator<{}>) => true >test : Iterator<{}> return true; ->true : boolean +>true : true }); } diff --git a/tests/baselines/reference/returnStatements.types b/tests/baselines/reference/returnStatements.types index e5332b2e6ac..d64e7beb39f 100644 --- a/tests/baselines/reference/returnStatements.types +++ b/tests/baselines/reference/returnStatements.types @@ -17,7 +17,7 @@ function fn4(): void { return; } function fn5(): boolean { return true; } >fn5 : () => boolean ->true : boolean +>true : true function fn6(): Date { return new Date(12); } >fn6 : () => Date diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types index 69de032ca2e..ba720d78612 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types @@ -471,10 +471,10 @@ class ListWrapper { >1 : number return true; ->true : boolean +>true : true } return false; ->false : boolean +>false : false } static clear(dit: typeof ListWrapper, list: any[]) { list.length = 0; } >clear : (dit: typeof ListWrapper, list: any[]) => void @@ -540,7 +540,7 @@ class ListWrapper { >b.length : number >b : any[] >length : number ->false : boolean +>false : false for (var i = 0; i < a.length; ++i) { >i : number @@ -561,10 +561,10 @@ class ListWrapper { >b[i] : any >b : any[] >i : number ->false : boolean +>false : false } return true; ->true : boolean +>true : true } static slice(dit: typeof ListWrapper, l: T[], from: number = 0, to: number = null): T[] { >slice : (dit: typeof ListWrapper, l: T[], from?: number, to?: number) => T[] diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.types b/tests/baselines/reference/stringLiteralTypesOverloads01.types index 3b9df5c0066..6a46c7676f7 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads01.types +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.types @@ -58,7 +58,7 @@ function getFalsyPrimitive(x: PrimitiveName): number | string | boolean { >"boolean" : "boolean" return false; ->false : boolean +>false : false } // Should be unreachable. diff --git a/tests/baselines/reference/symbolProperty18.types b/tests/baselines/reference/symbolProperty18.types index 772e6aff2f7..681f86af117 100644 --- a/tests/baselines/reference/symbolProperty18.types +++ b/tests/baselines/reference/symbolProperty18.types @@ -40,11 +40,11 @@ var str = i[Symbol.toStringTag](); >toStringTag : symbol i[Symbol.toPrimitive] = false; ->i[Symbol.toPrimitive] = false : boolean +>i[Symbol.toPrimitive] = false : false >i[Symbol.toPrimitive] : boolean >i : { [Symbol.iterator]: number; [Symbol.toStringTag](): string; [Symbol.toPrimitive]: boolean; } >Symbol.toPrimitive : symbol >Symbol : SymbolConstructor >toPrimitive : symbol ->false : boolean +>false : false diff --git a/tests/baselines/reference/symbolProperty21.errors.txt b/tests/baselines/reference/symbolProperty21.errors.txt index fa9cabc9b61..766af0659e8 100644 --- a/tests/baselines/reference/symbolProperty21.errors.txt +++ b/tests/baselines/reference/symbolProperty21.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty21.ts(10,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. +tests/cases/conformance/es6/Symbols/symbolProperty21.ts(10,5): error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: true; }' is not assignable to parameter of type 'I'. Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. @@ -14,7 +14,7 @@ tests/cases/conformance/es6/Symbols/symbolProperty21.ts(10,5): error TS2345: Arg [Symbol.isConcatSpreadable]: "", [Symbol.toPrimitive]: 0, ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: boolean; }' is not assignable to parameter of type 'I'. +!!! error TS2345: Argument of type '{ [Symbol.isConcatSpreadable]: string; [Symbol.toPrimitive]: number; [Symbol.unscopables]: true; }' is not assignable to parameter of type 'I'. !!! error TS2345: Object literal may only specify known properties, and '[Symbol.toPrimitive]' does not exist in type 'I'. [Symbol.unscopables]: true }); \ No newline at end of file diff --git a/tests/baselines/reference/targetTypeArgs.types b/tests/baselines/reference/targetTypeArgs.types index cda814d52c5..48dd35401b4 100644 --- a/tests/baselines/reference/targetTypeArgs.types +++ b/tests/baselines/reference/targetTypeArgs.types @@ -35,11 +35,11 @@ foo(function(x) { x }); >["hello"] : string[] >"hello" : string >every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => boolean +>function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true >v : string >i : number >a : string[] ->true : boolean +>true : true [1].every(function(v,i,a) {return true;}); >[1].every(function(v,i,a) {return true;}) : boolean @@ -47,11 +47,11 @@ foo(function(x) { x }); >[1] : number[] >1 : number >every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => boolean +>function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true >v : number >i : number >a : number[] ->true : boolean +>true : true [1].every(function(v,i,a) {return true;}); >[1].every(function(v,i,a) {return true;}) : boolean @@ -59,11 +59,11 @@ foo(function(x) { x }); >[1] : number[] >1 : number >every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => boolean +>function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true >v : number >i : number >a : number[] ->true : boolean +>true : true ["s"].every(function(v,i,a) {return true;}); >["s"].every(function(v,i,a) {return true;}) : boolean @@ -71,11 +71,11 @@ foo(function(x) { x }); >["s"] : string[] >"s" : string >every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean ->function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => boolean +>function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true >v : string >i : number >a : string[] ->true : boolean +>true : true ["s"].forEach(function(v,i,a) { v }); >["s"].forEach(function(v,i,a) { v }) : void diff --git a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types index e9ed0031928..d9702b59954 100644 --- a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types +++ b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types @@ -63,7 +63,7 @@ var r = b.foo(true); // returns Date >b.foo : { (x: boolean): number; (x: string): string; (x: boolean): Date; (x: Date): string; } >b : B >foo : { (x: boolean): number; (x: string): string; (x: boolean): Date; (x: Date): string; } ->true : boolean +>true : true // add generic overload interface C { diff --git a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types index afbafba4920..a796d65cf61 100644 --- a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types +++ b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types @@ -83,13 +83,13 @@ module G { >r2 : boolean >a(true) : boolean >a : A ->true : boolean +>true : true var r3 = a(true, 2); >r3 : boolean >a(true, 2) : boolean >a : A ->true : boolean +>true : true >2 : number var r4 = a(1, true); @@ -97,5 +97,5 @@ module G { >a(1, true) : number >a : A >1 : number ->true : boolean +>true : true } diff --git a/tests/baselines/reference/typeAliases.types b/tests/baselines/reference/typeAliases.types index d6bce143c9b..06dfd402829 100644 --- a/tests/baselines/reference/typeAliases.types +++ b/tests/baselines/reference/typeAliases.types @@ -231,9 +231,9 @@ f16(x); var y: StringAndBoolean = ["1", false]; >y : [string, boolean] >StringAndBoolean : [string, boolean] ->["1", false] : [string, boolean] +>["1", false] : [string, false] >"1" : string ->false : boolean +>false : false y[0].toLowerCase(); >y[0].toLowerCase() : string diff --git a/tests/baselines/reference/typeGuardFunction.types b/tests/baselines/reference/typeGuardFunction.types index 1e2be413a2b..00dfc39f04a 100644 --- a/tests/baselines/reference/typeGuardFunction.types +++ b/tests/baselines/reference/typeGuardFunction.types @@ -151,7 +151,7 @@ class D { >C : C return true; ->true : boolean +>true : true } } @@ -163,7 +163,7 @@ let f1 = (p1: A): p1 is C => false; >A : A >p1 : any >C : C ->false : boolean +>false : false // Function type declare function f2(p1: (p1: A) => p1 is C); @@ -185,7 +185,7 @@ f2(function(p1: A): p1 is C { >C : C return true; ->true : boolean +>true : true }); diff --git a/tests/baselines/reference/typeGuardFunctionOfFormThis.types b/tests/baselines/reference/typeGuardFunctionOfFormThis.types index 66d1a4b5b11..7b4b1fc76c8 100644 --- a/tests/baselines/reference/typeGuardFunctionOfFormThis.types +++ b/tests/baselines/reference/typeGuardFunctionOfFormThis.types @@ -259,13 +259,13 @@ if (crate.isSundries()) { >isSundries : () => this is Crate crate.contents.broken = true; ->crate.contents.broken = true : boolean +>crate.contents.broken = true : true >crate.contents.broken : boolean >crate.contents : Sundries >crate : Crate >contents : Sundries >broken : boolean ->true : boolean +>true : true } else if (crate.isSupplies()) { >crate.isSupplies() : boolean @@ -274,13 +274,13 @@ else if (crate.isSupplies()) { >isSupplies : () => this is Crate crate.contents.spoiled = true; ->crate.contents.spoiled = true : boolean +>crate.contents.spoiled = true : true >crate.contents.spoiled : boolean >crate.contents : Supplies >crate : Crate >contents : Supplies >spoiled : boolean ->true : boolean +>true : true } // Matching guards should be assignable diff --git a/tests/baselines/reference/typeGuardNesting.types b/tests/baselines/reference/typeGuardNesting.types index 6c2df126df1..2417dbe797c 100644 --- a/tests/baselines/reference/typeGuardNesting.types +++ b/tests/baselines/reference/typeGuardNesting.types @@ -37,7 +37,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >strOrBool : string | boolean >'boolean' : "boolean" >strOrBool : boolean ->false : boolean +>false : false let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; >label2 : string @@ -59,7 +59,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >strOrBool : string | boolean >'string' : "string" >strOrBool : boolean ->false : boolean +>false : false } if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boolean') { @@ -97,7 +97,7 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >strOrBool : string | boolean >'boolean' : "boolean" >strOrBool : boolean ->false : boolean +>false : false let label2: string = (typeof strOrBool !== 'boolean') ? strOrBool : "string"; >label2 : string @@ -119,6 +119,6 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >strOrBool : string | boolean >'string' : "string" >strOrBool : boolean ->false : boolean +>false : false } diff --git a/tests/baselines/reference/typeGuardOfFormIsType.types b/tests/baselines/reference/typeGuardOfFormIsType.types index e2059be7b63..53b2fab53f4 100644 --- a/tests/baselines/reference/typeGuardOfFormIsType.types +++ b/tests/baselines/reference/typeGuardOfFormIsType.types @@ -35,7 +35,7 @@ function isC1(x: any): x is C1 { >C1 : C1 return true; ->true : boolean +>true : true } function isC2(x: any): x is C2 { @@ -45,7 +45,7 @@ function isC2(x: any): x is C2 { >C2 : C2 return true; ->true : boolean +>true : true } function isD1(x: any): x is D1 { @@ -55,7 +55,7 @@ function isD1(x: any): x is D1 { >D1 : D1 return true; ->true : boolean +>true : true } var c1Orc2: C1 | C2; diff --git a/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types b/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types index ea169e95413..1295d0f6123 100644 --- a/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types +++ b/tests/baselines/reference/typeGuardOfFormIsTypeOnInterfaces.types @@ -54,7 +54,7 @@ function isC1(x: any): x is C1 { >C1 : C1 return true; ->true : boolean +>true : true } function isC2(x: any): x is C2 { @@ -64,7 +64,7 @@ function isC2(x: any): x is C2 { >C2 : C2 return true; ->true : boolean +>true : true } function isD1(x: any): x is D1 { @@ -74,7 +74,7 @@ function isD1(x: any): x is D1 { >D1 : D1 return true; ->true : boolean +>true : true } var c1: C1; diff --git a/tests/baselines/reference/typeGuardsInDoStatement.types b/tests/baselines/reference/typeGuardsInDoStatement.types index 58b6343a2f5..bc1e56bb1e4 100644 --- a/tests/baselines/reference/typeGuardsInDoStatement.types +++ b/tests/baselines/reference/typeGuardsInDoStatement.types @@ -7,13 +7,13 @@ function a(x: string | number | boolean) { >x : string | number | boolean x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean ->true : boolean +>true : true do { x; // boolean | string ->x : string | boolean +>x : string | true x = undefined; >x = undefined : undefined @@ -34,13 +34,13 @@ function b(x: string | number | boolean) { >x : string | number | boolean x = true; ->x = true : boolean +>x = true : true >x : string | number | boolean ->true : boolean +>true : true do { x; // boolean | string ->x : string | boolean +>x : string | true if (cond) continue; >cond : boolean diff --git a/tests/baselines/reference/typeGuardsOnClassProperty.types b/tests/baselines/reference/typeGuardsOnClassProperty.types index 85af4540fb9..afff0afb03f 100644 --- a/tests/baselines/reference/typeGuardsOnClassProperty.types +++ b/tests/baselines/reference/typeGuardsOnClassProperty.types @@ -67,15 +67,15 @@ var o: { >prop2 : string | boolean } = { ->{ prop1: "string" , prop2: true } : { prop1: string; prop2: boolean; } +>{ prop1: "string" , prop2: true } : { prop1: string; prop2: true; } prop1: "string" , >prop1 : string >"string" : string prop2: true ->prop2 : boolean ->true : boolean +>prop2 : true +>true : true } if (typeof o.prop1 === "string" && o.prop1.toLowerCase()) {} diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types index e2d41c5c136..680e86f5c85 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types @@ -62,13 +62,13 @@ foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: '', z: true }); >1 : number >y : string >'' : string ->{ x: 2, y: '', z: true } : { x: number; y: string; z: boolean; } +>{ x: 2, y: '', z: true } : { x: number; y: string; z: true; } >x : number >2 : number >y : string >'' : string ->z : boolean ->true : boolean +>z : true +>true : true foo(a, b, c); >foo(a, b, c) : C @@ -82,13 +82,13 @@ foo(a, b, { foo: 1, bar: '', hm: true }); >foo : (x: T, y: U, z: V) => V >a : A >b : B ->{ foo: 1, bar: '', hm: true } : { foo: number; bar: string; hm: boolean; } +>{ foo: 1, bar: '', hm: true } : { foo: number; bar: string; hm: true; } >foo : number >1 : number >bar : string >'' : string ->hm : boolean ->true : boolean +>hm : true +>true : true foo((x: number, y) => { }, (x) => { }, () => { }); >foo((x: number, y) => { }, (x) => { }, () => { }) : () => void diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types index 3d51ad80832..145bf081b18 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types @@ -62,13 +62,13 @@ foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: 2, z: true }); >1 : number >y : string >'' : string ->{ x: 2, y: 2, z: true } : { x: number; y: number; z: boolean; } +>{ x: 2, y: 2, z: true } : { x: number; y: number; z: true; } >x : number >2 : number >y : number >2 : number ->z : boolean ->true : boolean +>z : true +>true : true foo(a, b, a); >foo(a, b, a) : A @@ -81,13 +81,13 @@ foo(a, { foo: 1, bar: '', hm: true }, b); >foo(a, { foo: 1, bar: '', hm: true }, b) : B >foo : (x: T, y: U, z: V) => V >a : A ->{ foo: 1, bar: '', hm: true } : { foo: number; bar: string; hm: boolean; } +>{ foo: 1, bar: '', hm: true } : { foo: number; bar: string; hm: true; } >foo : number >1 : number >bar : string >'' : string ->hm : boolean ->true : boolean +>hm : true +>true : true >b : B foo((x: number, y: string) => { }, (x, y: boolean) => { }, () => { }); diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.types b/tests/baselines/reference/typeofOperatorWithBooleanType.types index 043307cfb00..edf3c4e0871 100644 --- a/tests/baselines/reference/typeofOperatorWithBooleanType.types +++ b/tests/baselines/reference/typeofOperatorWithBooleanType.types @@ -6,7 +6,7 @@ var BOOLEAN: boolean; function foo(): boolean { return true; } >foo : () => boolean ->true : boolean +>true : true class A { >A : A diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index 5950e50efa1..ac794e1f2f9 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -235,8 +235,8 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } >_ : Underscore.Static >all : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } ->[true, 1, null, 'yes'] : (string | number | boolean)[] ->true : boolean +>[true, 1, null, 'yes'] : (string | number | true)[] +>true : true >1 : number >null : null >'yes' : string @@ -249,11 +249,11 @@ _.any([null, 0, 'yes', false]); >_.any : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } >_ : Underscore.Static >any : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } ->[null, 0, 'yes', false] : (string | number | boolean)[] +>[null, 0, 'yes', false] : (string | number | false)[] >null : null >0 : number >'yes' : string ->false : boolean +>false : false _.contains([1, 2, 3], 3); >_.contains([1, 2, 3], 3) : boolean @@ -512,10 +512,10 @@ _.compact([0, 1, false, 2, '', 3]); >_.compact : (list: T[]) => T[] >_ : Underscore.Static >compact : (list: T[]) => T[] ->[0, 1, false, 2, '', 3] : (string | number | boolean)[] +>[0, 1, false, 2, '', 3] : (string | number | false)[] >0 : number >1 : number ->false : boolean +>false : false >2 : number >'' : string >3 : number @@ -571,7 +571,7 @@ _.flatten([1, [2], [3, [[4]]]], true); >[[4]] : number[][] >[4] : number[] >4 : number ->true : boolean +>true : true _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); >_.without([1, 2, 1, 0, 3, 1, 4], 0, 1) : number[] @@ -668,9 +668,9 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); >40 : number >50 : number >[true, false, false] : boolean[] ->true : boolean ->false : boolean ->false : boolean +>true : true +>false : false +>false : false _.object(['moe', 'larry', 'curly'], [30, 40, 50]); >_.object(['moe', 'larry', 'curly'], [30, 40, 50]) : any diff --git a/tests/baselines/reference/unionTypeCallSignatures2.types b/tests/baselines/reference/unionTypeCallSignatures2.types index ce49e9ba1c7..f55875eac44 100644 --- a/tests/baselines/reference/unionTypeCallSignatures2.types +++ b/tests/baselines/reference/unionTypeCallSignatures2.types @@ -81,8 +81,8 @@ var a1 = f1([true, false]); // boolean[] >f1([true, false]) : boolean[] >f1 : A | B | C >[true, false] : boolean[] ->true : boolean ->false : boolean +>true : true +>false : false var f2: C | B | A; >f2 : A | B | C @@ -107,8 +107,8 @@ var a2 = f2([true, false]); // boolean[] >f2([true, false]) : boolean[] >f2 : A | B | C >[true, false] : boolean[] ->true : boolean ->false : boolean +>true : true +>false : false var f3: B | A | C; >f3 : A | B | C @@ -133,7 +133,7 @@ var a3 = f3([true, false]); // boolean[] >f3([true, false]) : boolean[] >f3 : A | B | C >[true, false] : boolean[] ->true : boolean ->false : boolean +>true : true +>false : false diff --git a/tests/baselines/reference/unionTypeInference.types b/tests/baselines/reference/unionTypeInference.types index efc150da918..c1980206cc1 100644 --- a/tests/baselines/reference/unionTypeInference.types +++ b/tests/baselines/reference/unionTypeInference.types @@ -77,9 +77,9 @@ var b1 = g(["string", true]); >b1 : boolean >g(["string", true]) : boolean >g : (value: [string, T]) => T ->["string", true] : [string, boolean] +>["string", true] : [string, true] >"string" : string ->true : boolean +>true : true function h(x: string|boolean|T): T { >h : (x: string | boolean | T) => T diff --git a/tests/baselines/reference/voidOperatorWithBooleanType.types b/tests/baselines/reference/voidOperatorWithBooleanType.types index 060d2d545c6..7a35ad3367f 100644 --- a/tests/baselines/reference/voidOperatorWithBooleanType.types +++ b/tests/baselines/reference/voidOperatorWithBooleanType.types @@ -5,7 +5,7 @@ var BOOLEAN: boolean; function foo(): boolean { return true; } >foo : () => boolean ->true : boolean +>true : true class A { >A : A From 59d027b49bf1aae2541238f5693cfe560dde75a2 Mon Sep 17 00:00:00 2001 From: Omer Sheikh Date: Sun, 28 Aug 2016 12:29:05 +0500 Subject: [PATCH 289/508] Show elaboration for property not existing in union Fixes #10256. Accessing a non-existant property on union types should now show an elaboration in the error message specifying the first constituent type that lacks the property. --- src/compiler/checker.ts | 16 +++++++++++++++- .../reference/propertyAccess3.errors.txt | 4 +++- .../reference/typeGuardsWithAny.errors.txt | 2 ++ ...thInstanceOfByConstructorSignature.errors.txt | 12 ++++++++++++ .../reference/unionTypeMembers.errors.txt | 10 +++++++++- .../reference/unionTypeReadonly.errors.txt | 2 ++ 6 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8c1e401912d..16633d2dbe1 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10773,7 +10773,7 @@ namespace ts { const prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text && !checkAndReportErrorForExtendingInterface(node)) { - error(right, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(right), typeToString(type.flags & TypeFlags.ThisType ? apparentType : type)); + reportNonexistantProperty(right, type.flags & TypeFlags.ThisType ? apparentType : type); } return unknownType; } @@ -10810,6 +10810,20 @@ namespace ts { return propType; } return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + + function reportNonexistantProperty(propNode: Identifier, containingType: Type) { + let errorInfo: DiagnosticMessageChain; + if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Enum)) { + for (const subtype of (containingType as UnionType).types) { + if (!getPropertyOfType(subtype, propNode.text)) { + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(subtype)); + break; + } + } + } + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType)); + diagnostics.add(createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); + } } function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean { diff --git a/tests/baselines/reference/propertyAccess3.errors.txt b/tests/baselines/reference/propertyAccess3.errors.txt index dd09b7147f7..ab3661d5232 100644 --- a/tests/baselines/reference/propertyAccess3.errors.txt +++ b/tests/baselines/reference/propertyAccess3.errors.txt @@ -1,8 +1,10 @@ tests/cases/compiler/propertyAccess3.ts(2,5): error TS2339: Property 'toBAZ' does not exist on type 'boolean'. + Property 'toBAZ' does not exist on type 'true'. ==== tests/cases/compiler/propertyAccess3.ts (1 errors) ==== var foo: boolean; foo.toBAZ(); ~~~~~ -!!! error TS2339: Property 'toBAZ' does not exist on type 'boolean'. \ No newline at end of file +!!! error TS2339: Property 'toBAZ' does not exist on type 'boolean'. +!!! error TS2339: Property 'toBAZ' does not exist on type 'true'. \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithAny.errors.txt b/tests/baselines/reference/typeGuardsWithAny.errors.txt index 653c89c7554..2444cb88012 100644 --- a/tests/baselines/reference/typeGuardsWithAny.errors.txt +++ b/tests/baselines/reference/typeGuardsWithAny.errors.txt @@ -1,6 +1,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(11,7): error TS2339: Property 'p' does not exist on type 'string'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(18,7): error TS2339: Property 'p' does not exist on type 'number'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(25,7): error TS2339: Property 'p' does not exist on type 'boolean'. + Property 'p' does not exist on type 'true'. ==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts (3 errors) ==== @@ -35,6 +36,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(25,7): error x.p; // Error, type any narrowed by primitive type check ~ !!! error TS2339: Property 'p' does not exist on type 'boolean'. +!!! error TS2339: Property 'p' does not exist on type 'true'. } else { x.p; // No error, type unaffected in this branch diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt index b67f7328856..36aa370df25 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt @@ -5,14 +5,20 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(41,10): error TS2339: Property 'bar' does not exist on type 'B'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(66,10): error TS2339: Property 'bar2' does not exist on type 'C1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(72,10): error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. + Property 'bar1' does not exist on type 'C2'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(73,10): error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. + Property 'bar2' does not exist on type 'C1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(85,10): error TS2339: Property 'bar' does not exist on type 'D'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(91,10): error TS2339: Property 'bar' does not exist on type 'D'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(112,10): error TS2339: Property 'bar2' does not exist on type 'E1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(118,11): error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. + Property 'bar1' does not exist on type 'E2'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(119,11): error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. + Property 'bar2' does not exist on type 'E1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(134,11): error TS2339: Property 'foo' does not exist on type 'string | F'. + Property 'foo' does not exist on type 'string'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(135,11): error TS2339: Property 'bar' does not exist on type 'string | F'. + Property 'bar' does not exist on type 'string'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(160,11): error TS2339: Property 'foo2' does not exist on type 'G1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(166,11): error TS2339: Property 'foo2' does not exist on type 'G1'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(182,11): error TS2339: Property 'bar' does not exist on type 'H'. @@ -107,9 +113,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru obj6.bar1; ~~~~ !!! error TS2339: Property 'bar1' does not exist on type 'C1 | C2'. +!!! error TS2339: Property 'bar1' does not exist on type 'C2'. obj6.bar2; ~~~~ !!! error TS2339: Property 'bar2' does not exist on type 'C1 | C2'. +!!! error TS2339: Property 'bar2' does not exist on type 'C1'. } // with object type literal @@ -163,9 +171,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru obj10.bar1; ~~~~ !!! error TS2339: Property 'bar1' does not exist on type 'E1 | E2'. +!!! error TS2339: Property 'bar1' does not exist on type 'E2'. obj10.bar2; ~~~~ !!! error TS2339: Property 'bar2' does not exist on type 'E1 | E2'. +!!! error TS2339: Property 'bar2' does not exist on type 'E1'. } // a construct signature that returns any @@ -183,9 +193,11 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru obj11.foo; ~~~ !!! error TS2339: Property 'foo' does not exist on type 'string | F'. +!!! error TS2339: Property 'foo' does not exist on type 'string'. obj11.bar; ~~~ !!! error TS2339: Property 'bar' does not exist on type 'string | F'. +!!! error TS2339: Property 'bar' does not exist on type 'string'. } var obj12: any; diff --git a/tests/baselines/reference/unionTypeMembers.errors.txt b/tests/baselines/reference/unionTypeMembers.errors.txt index 21f1204ac6d..e4f73a51f77 100644 --- a/tests/baselines/reference/unionTypeMembers.errors.txt +++ b/tests/baselines/reference/unionTypeMembers.errors.txt @@ -1,8 +1,12 @@ tests/cases/conformance/types/union/unionTypeMembers.ts(44,1): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/conformance/types/union/unionTypeMembers.ts(51,3): error TS2339: Property 'propertyOnlyInI1' does not exist on type 'I1 | I2'. + Property 'propertyOnlyInI1' does not exist on type 'I2'. tests/cases/conformance/types/union/unionTypeMembers.ts(52,3): error TS2339: Property 'propertyOnlyInI2' does not exist on type 'I1 | I2'. + Property 'propertyOnlyInI2' does not exist on type 'I1'. tests/cases/conformance/types/union/unionTypeMembers.ts(53,3): error TS2339: Property 'methodOnlyInI1' does not exist on type 'I1 | I2'. + Property 'methodOnlyInI1' does not exist on type 'I2'. tests/cases/conformance/types/union/unionTypeMembers.ts(54,3): error TS2339: Property 'methodOnlyInI2' does not exist on type 'I1 | I2'. + Property 'methodOnlyInI2' does not exist on type 'I1'. ==== tests/cases/conformance/types/union/unionTypeMembers.ts (5 errors) ==== @@ -61,12 +65,16 @@ tests/cases/conformance/types/union/unionTypeMembers.ts(54,3): error TS2339: Pro x.propertyOnlyInI1; // error ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'propertyOnlyInI1' does not exist on type 'I1 | I2'. +!!! error TS2339: Property 'propertyOnlyInI1' does not exist on type 'I2'. x.propertyOnlyInI2; // error ~~~~~~~~~~~~~~~~ !!! error TS2339: Property 'propertyOnlyInI2' does not exist on type 'I1 | I2'. +!!! error TS2339: Property 'propertyOnlyInI2' does not exist on type 'I1'. x.methodOnlyInI1("hello"); // error ~~~~~~~~~~~~~~ !!! error TS2339: Property 'methodOnlyInI1' does not exist on type 'I1 | I2'. +!!! error TS2339: Property 'methodOnlyInI1' does not exist on type 'I2'. x.methodOnlyInI2(10); // error ~~~~~~~~~~~~~~ -!!! error TS2339: Property 'methodOnlyInI2' does not exist on type 'I1 | I2'. \ No newline at end of file +!!! error TS2339: Property 'methodOnlyInI2' does not exist on type 'I1 | I2'. +!!! error TS2339: Property 'methodOnlyInI2' does not exist on type 'I1'. \ No newline at end of file diff --git a/tests/baselines/reference/unionTypeReadonly.errors.txt b/tests/baselines/reference/unionTypeReadonly.errors.txt index 0875b2b5af3..ec660fc3a81 100644 --- a/tests/baselines/reference/unionTypeReadonly.errors.txt +++ b/tests/baselines/reference/unionTypeReadonly.errors.txt @@ -3,6 +3,7 @@ tests/cases/conformance/types/union/unionTypeReadonly.ts(19,1): error TS2450: Le tests/cases/conformance/types/union/unionTypeReadonly.ts(21,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/types/union/unionTypeReadonly.ts(23,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. tests/cases/conformance/types/union/unionTypeReadonly.ts(25,15): error TS2339: Property 'value' does not exist on type 'Base | DifferentName'. + Property 'value' does not exist on type 'DifferentName'. ==== tests/cases/conformance/types/union/unionTypeReadonly.ts (5 errors) ==== @@ -41,5 +42,6 @@ tests/cases/conformance/types/union/unionTypeReadonly.ts(25,15): error TS2339: P differentName.value = 12; // error, property 'value' doesn't exist ~~~~~ !!! error TS2339: Property 'value' does not exist on type 'Base | DifferentName'. +!!! error TS2339: Property 'value' does not exist on type 'DifferentName'. \ No newline at end of file From 4eaee735644b2a013b542ada4b50351277f38937 Mon Sep 17 00:00:00 2001 From: Omer Sheikh Date: Mon, 29 Aug 2016 01:07:10 +0500 Subject: [PATCH 290/508] Add test for invalid property access in unions --- .../unionPropertyExistance.errors.txt | 60 +++++++++++++++++++ .../reference/unionPropertyExistance.js | 44 ++++++++++++++ .../cases/compiler/unionPropertyExistance.ts | 32 ++++++++++ 3 files changed, 136 insertions(+) create mode 100644 tests/baselines/reference/unionPropertyExistance.errors.txt create mode 100644 tests/baselines/reference/unionPropertyExistance.js create mode 100644 tests/cases/compiler/unionPropertyExistance.ts diff --git a/tests/baselines/reference/unionPropertyExistance.errors.txt b/tests/baselines/reference/unionPropertyExistance.errors.txt new file mode 100644 index 00000000000..5dcb6b4d6c3 --- /dev/null +++ b/tests/baselines/reference/unionPropertyExistance.errors.txt @@ -0,0 +1,60 @@ +tests/cases/compiler/unionPropertyExistance.ts(24,4): error TS2339: Property 'onlyInB' does not exist on type 'AB'. + Property 'onlyInB' does not exist on type 'A'. +tests/cases/compiler/unionPropertyExistance.ts(27,5): error TS2339: Property 'notInC' does not exist on type 'ABC'. + Property 'notInC' does not exist on type 'C'. +tests/cases/compiler/unionPropertyExistance.ts(28,4): error TS2339: Property 'notInB' does not exist on type 'AB'. + Property 'notInB' does not exist on type 'B'. +tests/cases/compiler/unionPropertyExistance.ts(29,5): error TS2339: Property 'notInB' does not exist on type 'ABC'. + Property 'notInB' does not exist on type 'B'. +tests/cases/compiler/unionPropertyExistance.ts(32,5): error TS2339: Property 'inNone' does not exist on type 'ABC'. + Property 'inNone' does not exist on type 'A'. + + +==== tests/cases/compiler/unionPropertyExistance.ts (5 errors) ==== + interface A { + inAll: string; + notInB: string; + notInC: string; + } + + interface B { + inAll: boolean; + onlyInB: number; + notInC: string; + } + + interface C { + inAll: number; + notInB: string; + } + + type AB = A | B; + type ABC = C | AB; + + var ab: AB; + var abc: ABC; + + ab.onlyInB; + ~~~~~~~ +!!! error TS2339: Property 'onlyInB' does not exist on type 'AB'. +!!! error TS2339: Property 'onlyInB' does not exist on type 'A'. + + ab.notInC; // Ok + abc.notInC; + ~~~~~~ +!!! error TS2339: Property 'notInC' does not exist on type 'ABC'. +!!! error TS2339: Property 'notInC' does not exist on type 'C'. + ab.notInB; + ~~~~~~ +!!! error TS2339: Property 'notInB' does not exist on type 'AB'. +!!! error TS2339: Property 'notInB' does not exist on type 'B'. + abc.notInB; + ~~~~~~ +!!! error TS2339: Property 'notInB' does not exist on type 'ABC'. +!!! error TS2339: Property 'notInB' does not exist on type 'B'. + + abc.inAll; // Ok + abc.inNone; + ~~~~~~ +!!! error TS2339: Property 'inNone' does not exist on type 'ABC'. +!!! error TS2339: Property 'inNone' does not exist on type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/unionPropertyExistance.js b/tests/baselines/reference/unionPropertyExistance.js new file mode 100644 index 00000000000..0836032c6db --- /dev/null +++ b/tests/baselines/reference/unionPropertyExistance.js @@ -0,0 +1,44 @@ +//// [unionPropertyExistance.ts] +interface A { + inAll: string; + notInB: string; + notInC: string; +} + +interface B { + inAll: boolean; + onlyInB: number; + notInC: string; +} + +interface C { + inAll: number; + notInB: string; +} + +type AB = A | B; +type ABC = C | AB; + +var ab: AB; +var abc: ABC; + +ab.onlyInB; + +ab.notInC; // Ok +abc.notInC; +ab.notInB; +abc.notInB; + +abc.inAll; // Ok +abc.inNone; + +//// [unionPropertyExistance.js] +var ab; +var abc; +ab.onlyInB; +ab.notInC; // Ok +abc.notInC; +ab.notInB; +abc.notInB; +abc.inAll; // Ok +abc.inNone; diff --git a/tests/cases/compiler/unionPropertyExistance.ts b/tests/cases/compiler/unionPropertyExistance.ts new file mode 100644 index 00000000000..d0bee2fb829 --- /dev/null +++ b/tests/cases/compiler/unionPropertyExistance.ts @@ -0,0 +1,32 @@ +interface A { + inAll: string; + notInB: string; + notInC: string; +} + +interface B { + inAll: boolean; + onlyInB: number; + notInC: string; +} + +interface C { + inAll: number; + notInB: string; +} + +type AB = A | B; +type ABC = C | AB; + +var ab: AB; +var abc: ABC; + +ab.onlyInB; + +ab.notInC; // Ok +abc.notInC; +ab.notInB; +abc.notInB; + +abc.inAll; // Ok +abc.inNone; \ No newline at end of file From fe570ba764b011543ae6485de01ce82f3b490487 Mon Sep 17 00:00:00 2001 From: Omer Sheikh Date: Mon, 29 Aug 2016 09:34:46 +0500 Subject: [PATCH 291/508] Do not elaborate on primitive type unions --- src/compiler/checker.ts | 6 +++--- tests/baselines/reference/propertyAccess3.errors.txt | 4 +--- .../baselines/reference/typeGuardsWithAny.errors.txt | 2 -- ....errors.txt => unionPropertyExistence.errors.txt} | 12 ++++++------ ...ropertyExistance.js => unionPropertyExistence.js} | 4 ++-- ...ropertyExistance.ts => unionPropertyExistence.ts} | 0 6 files changed, 12 insertions(+), 16 deletions(-) rename tests/baselines/reference/{unionPropertyExistance.errors.txt => unionPropertyExistence.errors.txt} (82%) rename tests/baselines/reference/{unionPropertyExistance.js => unionPropertyExistence.js} (85%) rename tests/cases/compiler/{unionPropertyExistance.ts => unionPropertyExistence.ts} (100%) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 16633d2dbe1..919ba02998e 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -10773,7 +10773,7 @@ namespace ts { const prop = getPropertyOfType(apparentType, right.text); if (!prop) { if (right.text && !checkAndReportErrorForExtendingInterface(node)) { - reportNonexistantProperty(right, type.flags & TypeFlags.ThisType ? apparentType : type); + reportNonexistentProperty(right, type.flags & TypeFlags.ThisType ? apparentType : type); } return unknownType; } @@ -10811,9 +10811,9 @@ namespace ts { } return getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); - function reportNonexistantProperty(propNode: Identifier, containingType: Type) { + function reportNonexistentProperty(propNode: Identifier, containingType: Type) { let errorInfo: DiagnosticMessageChain; - if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Enum)) { + if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Primitive)) { for (const subtype of (containingType as UnionType).types) { if (!getPropertyOfType(subtype, propNode.text)) { errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(subtype)); diff --git a/tests/baselines/reference/propertyAccess3.errors.txt b/tests/baselines/reference/propertyAccess3.errors.txt index ab3661d5232..dd09b7147f7 100644 --- a/tests/baselines/reference/propertyAccess3.errors.txt +++ b/tests/baselines/reference/propertyAccess3.errors.txt @@ -1,10 +1,8 @@ tests/cases/compiler/propertyAccess3.ts(2,5): error TS2339: Property 'toBAZ' does not exist on type 'boolean'. - Property 'toBAZ' does not exist on type 'true'. ==== tests/cases/compiler/propertyAccess3.ts (1 errors) ==== var foo: boolean; foo.toBAZ(); ~~~~~ -!!! error TS2339: Property 'toBAZ' does not exist on type 'boolean'. -!!! error TS2339: Property 'toBAZ' does not exist on type 'true'. \ No newline at end of file +!!! error TS2339: Property 'toBAZ' does not exist on type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/typeGuardsWithAny.errors.txt b/tests/baselines/reference/typeGuardsWithAny.errors.txt index 2444cb88012..653c89c7554 100644 --- a/tests/baselines/reference/typeGuardsWithAny.errors.txt +++ b/tests/baselines/reference/typeGuardsWithAny.errors.txt @@ -1,7 +1,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(11,7): error TS2339: Property 'p' does not exist on type 'string'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(18,7): error TS2339: Property 'p' does not exist on type 'number'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(25,7): error TS2339: Property 'p' does not exist on type 'boolean'. - Property 'p' does not exist on type 'true'. ==== tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts (3 errors) ==== @@ -36,7 +35,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithAny.ts(25,7): error x.p; // Error, type any narrowed by primitive type check ~ !!! error TS2339: Property 'p' does not exist on type 'boolean'. -!!! error TS2339: Property 'p' does not exist on type 'true'. } else { x.p; // No error, type unaffected in this branch diff --git a/tests/baselines/reference/unionPropertyExistance.errors.txt b/tests/baselines/reference/unionPropertyExistence.errors.txt similarity index 82% rename from tests/baselines/reference/unionPropertyExistance.errors.txt rename to tests/baselines/reference/unionPropertyExistence.errors.txt index 5dcb6b4d6c3..1fbaa790bd6 100644 --- a/tests/baselines/reference/unionPropertyExistance.errors.txt +++ b/tests/baselines/reference/unionPropertyExistence.errors.txt @@ -1,16 +1,16 @@ -tests/cases/compiler/unionPropertyExistance.ts(24,4): error TS2339: Property 'onlyInB' does not exist on type 'AB'. +tests/cases/compiler/unionPropertyExistence.ts(24,4): error TS2339: Property 'onlyInB' does not exist on type 'AB'. Property 'onlyInB' does not exist on type 'A'. -tests/cases/compiler/unionPropertyExistance.ts(27,5): error TS2339: Property 'notInC' does not exist on type 'ABC'. +tests/cases/compiler/unionPropertyExistence.ts(27,5): error TS2339: Property 'notInC' does not exist on type 'ABC'. Property 'notInC' does not exist on type 'C'. -tests/cases/compiler/unionPropertyExistance.ts(28,4): error TS2339: Property 'notInB' does not exist on type 'AB'. +tests/cases/compiler/unionPropertyExistence.ts(28,4): error TS2339: Property 'notInB' does not exist on type 'AB'. Property 'notInB' does not exist on type 'B'. -tests/cases/compiler/unionPropertyExistance.ts(29,5): error TS2339: Property 'notInB' does not exist on type 'ABC'. +tests/cases/compiler/unionPropertyExistence.ts(29,5): error TS2339: Property 'notInB' does not exist on type 'ABC'. Property 'notInB' does not exist on type 'B'. -tests/cases/compiler/unionPropertyExistance.ts(32,5): error TS2339: Property 'inNone' does not exist on type 'ABC'. +tests/cases/compiler/unionPropertyExistence.ts(32,5): error TS2339: Property 'inNone' does not exist on type 'ABC'. Property 'inNone' does not exist on type 'A'. -==== tests/cases/compiler/unionPropertyExistance.ts (5 errors) ==== +==== tests/cases/compiler/unionPropertyExistence.ts (5 errors) ==== interface A { inAll: string; notInB: string; diff --git a/tests/baselines/reference/unionPropertyExistance.js b/tests/baselines/reference/unionPropertyExistence.js similarity index 85% rename from tests/baselines/reference/unionPropertyExistance.js rename to tests/baselines/reference/unionPropertyExistence.js index 0836032c6db..22931f151f5 100644 --- a/tests/baselines/reference/unionPropertyExistance.js +++ b/tests/baselines/reference/unionPropertyExistence.js @@ -1,4 +1,4 @@ -//// [unionPropertyExistance.ts] +//// [unionPropertyExistence.ts] interface A { inAll: string; notInB: string; @@ -32,7 +32,7 @@ abc.notInB; abc.inAll; // Ok abc.inNone; -//// [unionPropertyExistance.js] +//// [unionPropertyExistence.js] var ab; var abc; ab.onlyInB; diff --git a/tests/cases/compiler/unionPropertyExistance.ts b/tests/cases/compiler/unionPropertyExistence.ts similarity index 100% rename from tests/cases/compiler/unionPropertyExistance.ts rename to tests/cases/compiler/unionPropertyExistence.ts From f825b9c0f3ae4c89e5d8a8da7b1ba1ff7728028d Mon Sep 17 00:00:00 2001 From: Omer Sheikh Date: Mon, 29 Aug 2016 09:48:17 +0500 Subject: [PATCH 292/508] Add additional tests to unionPropertyExistence --- .../unionPropertyExistence.errors.txt | 38 +++++++++++++++---- .../reference/unionPropertyExistence.js | 15 +++++++- .../cases/compiler/unionPropertyExistence.ts | 10 ++++- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/tests/baselines/reference/unionPropertyExistence.errors.txt b/tests/baselines/reference/unionPropertyExistence.errors.txt index 1fbaa790bd6..c13aa7d4d15 100644 --- a/tests/baselines/reference/unionPropertyExistence.errors.txt +++ b/tests/baselines/reference/unionPropertyExistence.errors.txt @@ -1,16 +1,22 @@ -tests/cases/compiler/unionPropertyExistence.ts(24,4): error TS2339: Property 'onlyInB' does not exist on type 'AB'. +tests/cases/compiler/unionPropertyExistence.ts(27,3): error TS2339: Property 'nope' does not exist on type '"foo" | "bar"'. + Property 'nope' does not exist on type '"foo"'. +tests/cases/compiler/unionPropertyExistence.ts(28,6): error TS2339: Property 'onlyInB' does not exist on type 'B | "foo"'. + Property 'onlyInB' does not exist on type '"foo"'. +tests/cases/compiler/unionPropertyExistence.ts(30,6): error TS2339: Property 'length' does not exist on type 'B | "foo"'. + Property 'length' does not exist on type 'B'. +tests/cases/compiler/unionPropertyExistence.ts(32,4): error TS2339: Property 'onlyInB' does not exist on type 'AB'. Property 'onlyInB' does not exist on type 'A'. -tests/cases/compiler/unionPropertyExistence.ts(27,5): error TS2339: Property 'notInC' does not exist on type 'ABC'. +tests/cases/compiler/unionPropertyExistence.ts(35,5): error TS2339: Property 'notInC' does not exist on type 'ABC'. Property 'notInC' does not exist on type 'C'. -tests/cases/compiler/unionPropertyExistence.ts(28,4): error TS2339: Property 'notInB' does not exist on type 'AB'. +tests/cases/compiler/unionPropertyExistence.ts(36,4): error TS2339: Property 'notInB' does not exist on type 'AB'. Property 'notInB' does not exist on type 'B'. -tests/cases/compiler/unionPropertyExistence.ts(29,5): error TS2339: Property 'notInB' does not exist on type 'ABC'. +tests/cases/compiler/unionPropertyExistence.ts(37,5): error TS2339: Property 'notInB' does not exist on type 'ABC'. Property 'notInB' does not exist on type 'B'. -tests/cases/compiler/unionPropertyExistence.ts(32,5): error TS2339: Property 'inNone' does not exist on type 'ABC'. +tests/cases/compiler/unionPropertyExistence.ts(40,5): error TS2339: Property 'inNone' does not exist on type 'ABC'. Property 'inNone' does not exist on type 'A'. -==== tests/cases/compiler/unionPropertyExistence.ts (5 errors) ==== +==== tests/cases/compiler/unionPropertyExistence.ts (8 errors) ==== interface A { inAll: string; notInB: string; @@ -34,6 +40,23 @@ tests/cases/compiler/unionPropertyExistence.ts(32,5): error TS2339: Property 'in var ab: AB; var abc: ABC; + declare const x: "foo" | "bar"; + declare const bFoo: B | "foo"; + + x.nope(); + ~~~~ +!!! error TS2339: Property 'nope' does not exist on type '"foo" | "bar"'. +!!! error TS2339: Property 'nope' does not exist on type '"foo"'. + bFoo.onlyInB; + ~~~~~~~ +!!! error TS2339: Property 'onlyInB' does not exist on type 'B | "foo"'. +!!! error TS2339: Property 'onlyInB' does not exist on type '"foo"'. + x.length; // Ok + bFoo.length; + ~~~~~~ +!!! error TS2339: Property 'length' does not exist on type 'B | "foo"'. +!!! error TS2339: Property 'length' does not exist on type 'B'. + ab.onlyInB; ~~~~~~~ !!! error TS2339: Property 'onlyInB' does not exist on type 'AB'. @@ -57,4 +80,5 @@ tests/cases/compiler/unionPropertyExistence.ts(32,5): error TS2339: Property 'in abc.inNone; ~~~~~~ !!! error TS2339: Property 'inNone' does not exist on type 'ABC'. -!!! error TS2339: Property 'inNone' does not exist on type 'A'. \ No newline at end of file +!!! error TS2339: Property 'inNone' does not exist on type 'A'. + \ No newline at end of file diff --git a/tests/baselines/reference/unionPropertyExistence.js b/tests/baselines/reference/unionPropertyExistence.js index 22931f151f5..80174a3d363 100644 --- a/tests/baselines/reference/unionPropertyExistence.js +++ b/tests/baselines/reference/unionPropertyExistence.js @@ -22,6 +22,14 @@ type ABC = C | AB; var ab: AB; var abc: ABC; +declare const x: "foo" | "bar"; +declare const bFoo: B | "foo"; + +x.nope(); +bFoo.onlyInB; +x.length; // Ok +bFoo.length; + ab.onlyInB; ab.notInC; // Ok @@ -30,11 +38,16 @@ ab.notInB; abc.notInB; abc.inAll; // Ok -abc.inNone; +abc.inNone; + //// [unionPropertyExistence.js] var ab; var abc; +x.nope(); +bFoo.onlyInB; +x.length; // Ok +bFoo.length; ab.onlyInB; ab.notInC; // Ok abc.notInC; diff --git a/tests/cases/compiler/unionPropertyExistence.ts b/tests/cases/compiler/unionPropertyExistence.ts index d0bee2fb829..65937088898 100644 --- a/tests/cases/compiler/unionPropertyExistence.ts +++ b/tests/cases/compiler/unionPropertyExistence.ts @@ -21,6 +21,14 @@ type ABC = C | AB; var ab: AB; var abc: ABC; +declare const x: "foo" | "bar"; +declare const bFoo: B | "foo"; + +x.nope(); +bFoo.onlyInB; +x.length; // Ok +bFoo.length; + ab.onlyInB; ab.notInC; // Ok @@ -29,4 +37,4 @@ ab.notInB; abc.notInB; abc.inAll; // Ok -abc.inNone; \ No newline at end of file +abc.inNone; From 5e4465acd6f12958f7a8ad573cdc73c0ba0fe4cc Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 29 Aug 2016 07:28:14 -0700 Subject: [PATCH 293/508] Treat variable declaration as top-level if it has an important child. --- src/services/navigationBar.ts | 1 + ...BarAnonymousClassAndFunctionExpressions.ts | 11 +++++ ...FunctionIndirectlyInVariableDeclaration.ts | 46 +++++++++++++++++++ 3 files changed, 58 insertions(+) create mode 100644 tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index dda9ef485d2..83c08538249 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -466,6 +466,7 @@ namespace ts.NavigationBar { case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: + case SyntaxKind.VariableDeclaration: return hasSomeImportantChild(item); case SyntaxKind.ArrowFunction: diff --git a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts index 8ede0f07ea0..30e96739ab0 100644 --- a/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts +++ b/tests/cases/fourslash/navigationBarAnonymousClassAndFunctionExpressions.ts @@ -90,6 +90,17 @@ verify.navigationBar([ ], "indent": 2 }, + { + "text": "y", + "kind": "const", + "childItems": [ + { + "text": "foo", + "kind": "function" + } + ], + "indent": 2 + }, { "text": "", "kind": "function", diff --git a/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts b/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts new file mode 100644 index 00000000000..f14419a121a --- /dev/null +++ b/tests/cases/fourslash/navigationBarFunctionIndirectlyInVariableDeclaration.ts @@ -0,0 +1,46 @@ +/// + +////var a = { +//// propA: function() {} +////}; +////var b; +////b = { +//// propB: function() {} +////}; + +verify.navigationBar([ + { + "text": "", + "kind": "script", + "childItems": [ + { + "text": "a", + "kind": "var" + }, + { + "text": "b", + "kind": "var" + }, + { + "text": "propB", + "kind": "function" + } + ] + }, + { + "text": "a", + "kind": "var", + "childItems": [ + { + "text": "propA", + "kind": "function" + } + ], + "indent": 1 + }, + { + "text": "propB", + "kind": "function", + "indent": 1 + } +]); From 4514f8fde52f1d58722e961339ceec43cf3e853d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 29 Aug 2016 10:14:59 -0700 Subject: [PATCH 294/508] Make goto-definition go to a signature declaration if possible --- src/harness/fourslash.ts | 6 +- src/services/services.ts | 58 +++++++++++++++---- .../goToDefinitionConstructorOverloads.ts | 4 +- .../goToDefinitionFunctionOverloads.ts | 4 +- .../goToDefinitionMethodOverloads.ts | 22 +++---- tests/cases/fourslash/goToDefinition_super.ts | 33 +++++++++++ 6 files changed, 98 insertions(+), 29 deletions(-) create mode 100644 tests/cases/fourslash/goToDefinition_super.ts diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 63731417f48..408c52ef5f5 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1546,7 +1546,7 @@ namespace FourSlash { public goToDefinition(definitionIndex: number) { const definitions = this.languageService.getDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { - this.raiseError("goToDefinition failed - expected to at least one definition location but got 0"); + this.raiseError("goToDefinition failed - expected to find at least one definition location but got 0"); } if (definitionIndex >= definitions.length) { @@ -1561,7 +1561,7 @@ namespace FourSlash { public goToTypeDefinition(definitionIndex: number) { const definitions = this.languageService.getTypeDefinitionAtPosition(this.activeFile.fileName, this.currentCaretPosition); if (!definitions || !definitions.length) { - this.raiseError("goToTypeDefinition failed - expected to at least one definition location but got 0"); + this.raiseError("goToTypeDefinition failed - expected to find at least one definition location but got 0"); } if (definitionIndex >= definitions.length) { @@ -1582,7 +1582,7 @@ namespace FourSlash { this.raiseError(`goToDefinition - expected to 0 definition locations but got ${definitions.length}`); } else if (!foundDefinitions && !negative) { - this.raiseError("goToDefinition - expected to at least one definition location but got 0"); + this.raiseError("goToDefinition - expected to find at least one definition location but got 0"); } } diff --git a/src/services/services.ts b/src/services/services.ts index a55f2cf61b0..29cbcfd59d5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2788,18 +2788,37 @@ namespace ts { return node && node.parent && node.parent.kind === SyntaxKind.PropertyAccessExpression && (node.parent).name === node; } + function climbPastPropertyAccess(node: Node) { + return isRightSideOfPropertyAccess(node) ? node.parent : node; + } + function isCallExpressionTarget(node: Node): boolean { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; - } - return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; + return !!getCallOrNewExpressionWorker(node, SyntaxKind.CallExpression); } function isNewExpressionTarget(node: Node): boolean { - if (isRightSideOfPropertyAccess(node)) { - node = node.parent; + return !!getCallOrNewExpressionWorker(node, SyntaxKind.NewExpression); + } + + function getCallOrNewExpressionTargetingNode(node: Node): CallExpression | NewExpression | undefined { + return getCallOrNewExpressionWorker(node, SyntaxKind.CallExpression) || getCallOrNewExpressionWorker(node, SyntaxKind.NewExpression); + } + + function tryGetCalledDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined { + const callOrNewExpression = getCallOrNewExpressionTargetingNode(node); + if (callOrNewExpression) { + const signature = typeChecker.getResolvedSignature(callOrNewExpression); + return signature.declaration; } - return node && node.parent && node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node; + } + + function getCallOrNewExpressionWorker(node: Node, kind: SyntaxKind): Node | undefined { + const target = climbPastPropertyAccess(node); + return target && + target.parent && + target.parent.kind === kind && + (target.parent).expression === target && + target.parent; } function isNameOfModuleDeclaration(node: Node) { @@ -5068,14 +5087,25 @@ namespace ts { }; } + function getSymbolInfo(typeChecker: TypeChecker, symbol: Symbol, node: Node) { + return { + symbolName: typeChecker.symbolToString(symbol), // Do not get scoped name, just the name of the symbol + symbolKind: getSymbolKind(symbol, node), + containerName: symbol.parent ? typeChecker.symbolToString(symbol.parent, node) : "" + }; + } + + function getDefinitionFromSignatureDeclaration(decl: SignatureDeclaration): DefinitionInfo { + const typeChecker = program.getTypeChecker(); + const { symbolName, symbolKind, containerName } = getSymbolInfo(typeChecker, decl.symbol, decl); + return createDefinitionInfo(decl, symbolKind, symbolName, containerName); + } + function getDefinitionFromSymbol(symbol: Symbol, node: Node): DefinitionInfo[] { const typeChecker = program.getTypeChecker(); const result: DefinitionInfo[] = []; const declarations = symbol.getDeclarations(); - const symbolName = typeChecker.symbolToString(symbol); // Do not get scoped name, just the name of the symbol - const symbolKind = getSymbolKind(symbol, node); - const containerSymbol = symbol.parent; - const containerName = containerSymbol ? typeChecker.symbolToString(containerSymbol, node) : ""; + const { symbolName, symbolKind, containerName } = getSymbolInfo(typeChecker, symbol, node); if (!tryAddConstructSignature(symbol, node, symbolKind, symbolName, containerName, result) && !tryAddCallSignature(symbol, node, symbolKind, symbolName, containerName, result)) { @@ -5201,6 +5231,12 @@ namespace ts { } const typeChecker = program.getTypeChecker(); + + const calledDeclaration = tryGetCalledDeclaration(typeChecker, node); + if (calledDeclaration) { + return [getDefinitionFromSignatureDeclaration(calledDeclaration)]; + } + let symbol = typeChecker.getSymbolAtLocation(node); // Could not find a symbol e.g. node is string or number keyword, diff --git a/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts b/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts index a1fda8886db..d52243a6465 100644 --- a/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionConstructorOverloads.ts @@ -11,11 +11,11 @@ goTo.marker('constructorOverloadReference1'); goTo.definition(); -verify.caretAtMarker('constructorDefinition'); +verify.caretAtMarker('constructorOverload1'); goTo.marker('constructorOverloadReference2'); goTo.definition(); -verify.caretAtMarker('constructorDefinition'); +verify.caretAtMarker('constructorOverload2'); goTo.marker('constructorOverload1'); goTo.definition(); diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts index 488d788073a..fb690607f1a 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts @@ -9,11 +9,11 @@ goTo.marker('functionOverloadReference1'); goTo.definition(); -verify.caretAtMarker('functionOverloadDefinition'); +verify.caretAtMarker('functionOverload1'); goTo.marker('functionOverloadReference2'); goTo.definition(); -verify.caretAtMarker('functionOverloadDefinition'); +verify.caretAtMarker('functionOverload2'); goTo.marker('functionOverload'); goTo.definition(); diff --git a/tests/cases/fourslash/goToDefinitionMethodOverloads.ts b/tests/cases/fourslash/goToDefinitionMethodOverloads.ts index 6d74881c2af..7b4bd0630d9 100644 --- a/tests/cases/fourslash/goToDefinitionMethodOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionMethodOverloads.ts @@ -1,11 +1,11 @@ /// ////class MethodOverload { -//// static me/*staticMethodOverload1*/thod(); -//// static me/*staticMethodOverload2*/thod(foo: string); -/////*staticMethodDefinition*/static method(foo?: any) { } -//// public met/*instanceMethodOverload1*/hod(): any; -//// public met/*instanceMethodOverload2*/hod(foo: string); +//// /*staticMethodOverload1*/static /*staticMethodOverload1Name*/method(); +//// /*staticMethodOverload2*/static method(foo: string); +//// /*staticMethodDefinition*/static method(foo?: any) { } +//// /*instanceMethodOverload1*/public /*instanceMethodOverload1Name*/method(): any; +//// /*instanceMethodOverload2*/public method(foo: string); /////*instanceMethodDefinition*/public method(foo?: any) { return "foo" } ////} @@ -20,25 +20,25 @@ goTo.marker('staticMethodReference1'); goTo.definition(); -verify.caretAtMarker('staticMethodDefinition'); +verify.caretAtMarker('staticMethodOverload1'); goTo.marker('staticMethodReference2'); goTo.definition(); -verify.caretAtMarker('staticMethodDefinition'); +verify.caretAtMarker('staticMethodOverload2'); goTo.marker('instanceMethodReference1'); goTo.definition(); -verify.caretAtMarker('instanceMethodDefinition'); +verify.caretAtMarker('instanceMethodOverload1'); goTo.marker('instanceMethodReference2'); goTo.definition(); -verify.caretAtMarker('instanceMethodDefinition'); +verify.caretAtMarker('instanceMethodOverload2'); -goTo.marker('staticMethodOverload1'); +goTo.marker('staticMethodOverload1Name'); goTo.definition(); verify.caretAtMarker('staticMethodDefinition'); -goTo.marker('instanceMethodOverload1'); +goTo.marker('instanceMethodOverload1Name'); goTo.definition(); verify.caretAtMarker('instanceMethodDefinition'); diff --git a/tests/cases/fourslash/goToDefinition_super.ts b/tests/cases/fourslash/goToDefinition_super.ts new file mode 100644 index 00000000000..576d3535af0 --- /dev/null +++ b/tests/cases/fourslash/goToDefinition_super.ts @@ -0,0 +1,33 @@ +/// + +////class A { +//// /*ctr*/constructor() {} +//// x() {} +////} +/////*B*/class B extends A {} +////class C extends B { +//// constructor() { +//// /*super*/super(); +//// } +//// method() { +//// /*superExpression*/super.x(); +//// } +////} +////class D { +//// constructor() { +//// /*superBroken*/super(); +//// } +////} + +// Super in call position goes to constructor. +goTo.marker("super"); +goTo.definition(); +verify.caretAtMarker("ctr"); + +// Super in any other position goes to the superclass. +goTo.marker("superExpression"); +goTo.definition(); +verify.caretAtMarker("B"); + +goTo.marker("superBroken"); +verify.definitionCountIs(0); From 051c7b0217e85228342d6c1b974735e2978b0689 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 29 Aug 2016 15:46:26 -0700 Subject: [PATCH 295/508] Refine the search set instead of filtering to implementations --- src/compiler/checker.ts | 3 +- src/compiler/types.ts | 1 - src/services/services.ts | 274 ++++++------------ .../goToImplementationInterfaceMethod_05.ts | 2 +- .../goToImplementationInterfaceMethod_06.ts | 2 +- 5 files changed, 91 insertions(+), 191 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index f7ce30fe4f3..193deded4c5 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -103,8 +103,7 @@ namespace ts { getJsxElementAttributesType, getJsxIntrinsicTagNames, - isOptionalParameter, - isTypeAssignableTo + isOptionalParameter }; const tupleTypes = createMap(); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index adfde2d0605..a61d4a360b3 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -1889,7 +1889,6 @@ namespace ts { getJsxElementAttributesType(elementNode: JsxOpeningLikeElement): Type; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; - isTypeAssignableTo(source: Type, target: Type): boolean; // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; diff --git a/src/services/services.ts b/src/services/services.ts index 6f682822bba..914ae98746a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6272,10 +6272,6 @@ namespace ts { } } - if (implementations) { - return filterToImplementations(node, symbol, result, indexToSymbol); - } - return result; function getDefinition(symbol: Symbol): DefinitionInfo { @@ -6546,6 +6542,20 @@ namespace ts { const start = findInComments ? container.getFullStart() : container.getStart(); const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd()); + // If we are just looking for implementations and this is a property access expression, we need to get the + // symbol of the local type of the symbol the property is being accessed on. This is because our search + // symbol may have a different parent symbol if the local type's symbol does not declare the property + // being accessed (i.e. it is declared in some parent class or interface) + let parentSymbol: Symbol = undefined; + let inheritanceCache: Map = undefined; + if (implementations && searchLocation.parent && searchLocation.parent.kind === SyntaxKind.PropertyAccessExpression && searchLocation === (searchLocation.parent).name) { + const localParentType = typeChecker.getTypeAtLocation((searchLocation.parent).expression); + if (localParentType && localParentType.symbol && localParentType.symbol.getFlags() & (SymbolFlags.Interface | SymbolFlags.Class) && localParentType.symbol.parent !== searchSymbol.parent) { + parentSymbol = localParentType.symbol; + inheritanceCache = createMap(); + } + } + if (possiblePositions.length) { // Build the set of symbols to search for, initially it has only the current symbol const searchSymbols = populateSearchSymbolSet(searchSymbol, searchLocation); @@ -6554,7 +6564,7 @@ namespace ts { cancellationToken.throwIfCancellationRequested(); const referenceLocation = getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { + if (!implementations && !isValidReferencePosition(referenceLocation, searchText)) { // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. @@ -6586,11 +6596,15 @@ namespace ts { if (referenceSymbol) { const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation); + const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, parentSymbol, inheritanceCache); if (relatedSymbol) { - const referencedSymbol = getReferencedSymbol(relatedSymbol); - referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation)); + const referenceEntry = implementations ? getImplementationReferenceEntryForNode(referenceLocation) : getReferenceEntryFromNode(referenceLocation); + + if (referenceEntry) { + const referencedSymbol = getReferencedSymbol(relatedSymbol); + referencedSymbol.references.push(referenceEntry); + } } /* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment * has two meaning : property name and property value. Therefore when we do findAllReference at the position where @@ -6599,8 +6613,11 @@ namespace ts { * position of property accessing, the referenceEntry of such position will be handled in the first case. */ else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) { - const referencedSymbol = getReferencedSymbol(shorthandValueSymbol); - referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name)); + const referenceEntry = implementations ? getImplementationReferenceEntryForNode(referenceSymbolDeclaration.name) : getReferenceEntryFromNode(referenceSymbolDeclaration.name); + if (referenceEntry) { + const referencedSymbol = getReferencedSymbol(shorthandValueSymbol); + referencedSymbol.references.push(referenceEntry); + } } } }); @@ -6634,141 +6651,10 @@ namespace ts { } } - function filterToImplementations(node: Node, searchSymbol: Symbol, refs: ReferencedSymbol[], indexToSymbol: {[index: number]: Symbol}): ReferencedSymbol[] { - if (isPropertyAccessExpression(node.parent) && node.parent.name === node) { - const type = typeChecker.getTypeAtLocation(node.parent.expression); - - if (type.getFlags() & TypeFlags.Class) { - // The search results in refs will contain all implementations of the property. This includes - // all implementations in classes that parentSymbol extends from and sibling implementations - // (i.e. implementations in classes with common ancestors that declare the property). We need to - // filter the results to only the implementation used by parentSymbol's class and any implementations - // in any sub-classes - return filterToClassMemberImplementations(node.parent, searchSymbol, refs, indexToSymbol); - } - else if (type.getFlags() & (TypeFlags.UnionOrIntersection | TypeFlags.Interface)) { - // If parentSymbol did not declare the property being accessed, then the search results - // in refs will also contain references to the interfaces that parentSymbol inherits from. - // We need to filter out any implementations of those parent interfaces in addition to filtering out the - // non-implementation references - return filterReferenceEntries(refs, (entry) => { - const impl = getImplementationFromEntry(entry); - if (impl) { - const entryNode = getTokenAtPosition(getValidSourceFile(entry.fileName), entry.textSpan.start); - const element = getContainingObjectLiteralElement(entryNode); - if (element && element.parent && element.parent.kind === SyntaxKind.ObjectLiteralExpression) { - const objType = getDeclaredTypeOfObjectLiteralExpression(element.parent); - - if (objType && typeChecker.isTypeAssignableTo(objType, type)) { - return impl; - } - } - else { - const defClass = getContainingClass(entryNode); - if (defClass) { - const classType = typeChecker.getTypeAtLocation(defClass); - if (typeChecker.isTypeAssignableTo(classType, type)) { - return impl; - } - } - } - } - }); - } - } - - return filterReferenceEntries(refs, getImplementationFromEntry); - } - - function getDeclaredTypeOfObjectLiteralExpression(node: Node): Type { - if (node && node.parent) { - if (node.parent.kind === SyntaxKind.ParenthesizedExpression) { - return getDeclaredTypeOfObjectLiteralExpression(node.parent); - } - - if (isVariableLike(node.parent) && node.parent.type) { - return typeChecker.getTypeAtLocation(node.parent.type); - } - else if (node.parent.kind === SyntaxKind.ReturnStatement) { - const containerSig = typeChecker.getSignatureFromDeclaration(getContainingFunction(node)); - return typeChecker.getReturnTypeOfSignature(containerSig); - } - else if (node.parent.kind === SyntaxKind.TypeAssertionExpression) { - return typeChecker.getTypeAtLocation((node.parent).type); - } - } - return undefined; - } - - function filterReferenceEntries(refs: ReferencedSymbol[], filterer: (x: ReferenceEntry) => ReferenceEntry): ReferencedSymbol[] { - const result: ReferencedSymbol[] = []; - forEach(refs, (ref) => { - const filtered: ReferenceEntry[] = []; - forEach(ref.references, (entry) => { - const filteredEntry = filterer(entry); - if (filteredEntry) { - filtered.push(filteredEntry); - } - }); - if (filtered.length) { - result.push({ definition: ref.definition, references: filtered }); - } - }); - return result; - } - - function filterToClassMemberImplementations(parent: PropertyAccessExpression, searchSymbol: Symbol, refs: ReferencedSymbol[], indexToSymbol: {[index: number]: Symbol}): ReferencedSymbol[] { - // Need to find out what class this member is being accessed on - const type = typeChecker.getTypeAtLocation(parent.expression); - const classHierarchy: Symbol[] = getClassHierarchy(searchSymbol.parent); - - let lowest: ReferencedSymbol[]; - let lowestRank: number; - - // Filter down the references to those that refer to implementations of the symbol. That is, implementations - // from subclasses of the parent class and the lowest implementation in the parent class' class hierarchy - forEach(refs, (refSymbol, index) => { - const actual = indexToSymbol[index]; - - // We only care about implementations in classes in the hierarchy - if (actual.parent.getFlags() & SymbolFlags.Interface) { - return; - } - const rank = classHierarchy.indexOf(actual.parent); - - // No need to check anything past the lowest we have found so far - if (lowest && rank > lowestRank) { - return; - } - - const implementations: ReferenceEntry[] = []; - forEach(refSymbol.references, (entry) => { - const impl = getImplementationFromEntry(entry, type, classHierarchy); - if (impl) { - implementations.push(impl); - } - }); - if (implementations.length) { - if (!lowest || rank < lowestRank) { - lowest = [{ definition: refSymbol.definition, references: implementations }]; - lowestRank = rank; - } - else if (rank === lowestRank) { - lowest.push({ definition: refSymbol.definition, references: implementations }); - } - } - }); - - return lowest; - } - - function getImplementationFromEntry(entry: ReferenceEntry, base?: Type, hierarchy?: Symbol[]): ReferenceEntry { - const sourceFile = getValidSourceFile(entry.fileName); - const refNode = getTouchingPropertyName(sourceFile, entry.textSpan.start); - + function getImplementationReferenceEntryForNode(refNode: Node): ReferenceEntry { // Check to make sure this reference is either part of a sub class or a class that we explicitly // inherit from in the class hierarchy - if (isMemberOfSubOrParentClass(refNode, base, hierarchy) && refNode.kind === SyntaxKind.Identifier) { + if (refNode.kind === SyntaxKind.Identifier) { // Check if we found a function/propertyAssignment/method with an implementation or initializer if (isIdentifierOfImplementation(refNode)) { return getReferenceEntryFromNode(refNode.parent); @@ -6805,25 +6691,6 @@ namespace ts { } } - function isMemberOfSubOrParentClass(reference: Node, base: Type, hierarchy: Symbol[]) { - if (!base || !hierarchy) { - return true; - } - const referenceSymbol = typeChecker.getSymbolAtLocation(reference); - if (referenceSymbol && referenceSymbol.parent) { - if (hierarchy.indexOf(referenceSymbol.parent) !== -1) { - return true; - } - - const referenceParentDeclarations = referenceSymbol.parent.getDeclarations(); - if (referenceParentDeclarations.length) { - const referenceParentType = typeChecker.getTypeAtLocation(referenceParentDeclarations[0]); - return typeChecker.isTypeAssignableTo(referenceParentType, base); - } - } - return false; - } - function getContainingTypeReference(node: Node): Node { if (node) { if (node.kind === SyntaxKind.TypeReference) { @@ -6867,32 +6734,66 @@ namespace ts { node.kind === SyntaxKind.ClassExpression; } - function getClassHierarchy(symbol: Symbol) { - const classes: Symbol[] = []; - getClassHierarchyRecursive(symbol, classes, createMap()); - return classes; + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * This also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol names to booleans indicating previous results + */ + function inheritsFrom(child: Symbol, parent: Symbol, cachedResults: Map = createMap()): boolean { + const parentIsInterface = parent.getFlags() & SymbolFlags.Interface; + return searchHierarchy(child, cachedResults); - function getClassHierarchyRecursive(symbol: Symbol, result: Symbol[], previousIterationSymbolsCache: SymbolTable) { - if (hasProperty(previousIterationSymbolsCache, symbol.name)) { - return; + function searchHierarchy(symbol: Symbol, cachedResults: Map): boolean { + if (symbol === parent) { + return true; + } + else if (symbol.name in cachedResults) { + return cachedResults[symbol.name]; } - previousIterationSymbolsCache[symbol.name] = symbol; - if (result.indexOf(symbol) !== -1) { - return; - } - result.push(symbol); - forEach(symbol.getDeclarations(), (decl) => { - if (isClassLike(decl)) { - const heritage = getClassExtendsHeritageClauseElement(decl); - if (heritage) { - const type = typeChecker.getTypeAtLocation(heritage); - if (type && type.symbol) { - getClassHierarchyRecursive(type.symbol, result, previousIterationSymbolsCache); + cachedResults[symbol.name] = false; + + const inherits = forEach(symbol.getDeclarations(), (declaration) => { + if (isClassLike(declaration)) { + if (parentIsInterface) { + const interfaceReferences = getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (const typeReference of interfaceReferences) { + if (searchTypeReference(typeReference, cachedResults)) { + return true; + } + } } } + return searchTypeReference(getClassExtendsHeritageClauseElement(declaration), cachedResults); } + else if (declaration.kind === SyntaxKind.InterfaceDeclaration) { + if (parentIsInterface) { + return forEach(getInterfaceBaseTypeNodes(declaration), base => searchTypeReference(base, cachedResults)); + } + } + return false; }); + + cachedResults[symbol.name] = inherits; + return inherits; + } + + function searchTypeReference(typeReference: ExpressionWithTypeArguments, cachedResults: Map) { + if (typeReference) { + const type = typeChecker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol, cachedResults); + } + } + return false; } } @@ -7176,7 +7077,7 @@ namespace ts { } // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); } }); @@ -7243,7 +7144,7 @@ namespace ts { } } - function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node): Symbol { + function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, parentSymbol: Symbol, inheritanceCache: Map): Symbol { if (searchSymbols.indexOf(referenceSymbol) >= 0) { return referenceSymbol; } @@ -7252,7 +7153,7 @@ namespace ts { // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation); + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, parentSymbol, inheritanceCache); } // If the reference location is in an object literal, try to get the contextual type for the @@ -7295,8 +7196,9 @@ namespace ts { } // Finally, try all properties with the same name in any type the containing type extended or implemented, and - // see if any is in the list - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface) && (!parentSymbol || inheritsFrom(rootSymbol.parent, parentSymbol, inheritanceCache))) { const result: Symbol[] = []; getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts index 43079b20dcc..5e8bd76a072 100644 --- a/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_05.ts @@ -15,7 +15,7 @@ //// } //// //// class OtherBar extends SuperBar { -//// [|hello() {}|] // This could be considered a false positive because it does not extend Bar. Returned because it shares a common ancestor and is structurally equivalent +//// hello() {} //// hello2() {} //// hello3() {} //// } diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts index 175b5bd50fc..b7f275e6c07 100644 --- a/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_06.ts @@ -28,7 +28,7 @@ //// }; //// //// class FooLike implements SuperFoo { -//// [|hello() {}|] // This case could be considered a false positive. It does not explicitly implement Foo but does implement it structurally and it shares a common ancestor +//// hello() {} //// someOtherFunction() {} //// } //// From d8ff546512f3c27384a70239d73fc6be3d5dccbc Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Mon, 29 Aug 2016 17:18:04 -0700 Subject: [PATCH 296/508] Remove handling for multiple inheritance for config files --- src/compiler/commandLineParser.ts | 11 +---- .../unittests/configurationExtension.ts | 47 +------------------ 2 files changed, 3 insertions(+), 55 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 559ec8da2f4..7acf6eb9018 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -822,17 +822,8 @@ namespace ts { if (typeof json["extends"] === "string") { [include, exclude, files, baseOptions] = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]); } - else if (typeof json["extends"] === "object" && json["extends"].length) { - for (const name of json["extends"]) { - const [tempinclude, tempexclude, tempfiles, tempBase]: [string[], string[], string[], CompilerOptions] = (tryExtendsName(name) || [include, exclude, files, baseOptions]); - include = tempinclude || include; - exclude = tempexclude || exclude; - files = tempfiles || files; - baseOptions = assign({}, baseOptions, tempBase); - } - } else { - errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string or string[]")); + errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); } if (include && !json["include"]) { json["include"] = include; diff --git a/src/harness/unittests/configurationExtension.ts b/src/harness/unittests/configurationExtension.ts index 21584d4b67d..4537dc77576 100644 --- a/src/harness/unittests/configurationExtension.ts +++ b/src/harness/unittests/configurationExtension.ts @@ -15,18 +15,6 @@ namespace ts { "compilerOptions": { "strictNullChecks": false } -}`, - "/dev/tsconfig.tests.json": `{ - "extends": ["./configs/tests", "./tsconfig"], - "compilerOptions": { - "module": "commonjs" - } -}`, - "/dev/tsconfig.tests.browser.json": `{ - "extends": ["./configs/tests", "./tsconfig"], - "compilerOptions": { - "module": "amd" - } }`, "/dev/configs/base.json": `{ "compilerOptions": { @@ -75,12 +63,6 @@ namespace ts { }`, "/dev/failure2.json": `{ "excludes": ["*.js"] -}`, - "/dev/multi.json": `{ - "extends": ["./configs/first", "./configs/second"], - "compilerOptions": { - "allowJs": false - } }`, "/dev/configs/first.json": `{ "extends": "./base", @@ -168,31 +150,6 @@ namespace ts { combinePaths(basePath, "supplemental.ts"), ]); - testSuccess("can resolve an extension with a multiple base extensions that overrides options", "tsconfig.tests.json", { - allowJs: true, - noImplicitAny: true, - strictNullChecks: true, - preserveConstEnums: true, - removeComments: false, - sourceMap: true, - module: ts.ModuleKind.CommonJS, - }, [ - combinePaths(basePath, "main.ts"), - combinePaths(basePath, "supplemental.ts"), - combinePaths(basePath, "tests/unit/spec.ts"), - combinePaths(basePath, "tests/utils.ts"), - ]); - - testSuccess("can resolve a diamond dependency graph", "multi.json", { - allowJs: false, - noImplicitAny: true, - strictNullChecks: true, - module: ts.ModuleKind.AMD, - }, [ - combinePaths(basePath, "configs/../main.ts"), // Probably should consider resolving these kinds of paths when they appear - combinePaths(basePath, "supplemental.ts"), - ]); - testFailure("can report errors on circular imports", "circular.json", [ { code: 18000, @@ -213,10 +170,10 @@ namespace ts { messageText: `Unknown option 'excludes'. Did you mean 'exclude'?` }]); - testFailure("can error when 'extends' is neither a string nor a string[]", "extends.json", [{ + testFailure("can error when 'extends' is not a string", "extends.json", [{ code: 5024, category: DiagnosticCategory.Error, - messageText: `Compiler option 'extends' requires a value of type string or string[].` + messageText: `Compiler option 'extends' requires a value of type string.` }]); testFailure("can error when 'extends' is neither relative nor rooted.", "extends2.json", [{ From 115141cb50c878f4a2d43939252c4e15bd3d85d0 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Mon, 29 Aug 2016 18:09:16 -0700 Subject: [PATCH 297/508] Also check inheritance for union and intersection types --- src/services/services.ts | 58 +++++++++++++++---- .../goToImplementationInterfaceMethod_10.ts | 29 +++++++--- .../goToImplementationInterfaceMethod_11.ts | 48 ++++----------- .../goToImplementationInterfaceMethod_12.ts | 12 ---- 4 files changed, 80 insertions(+), 67 deletions(-) delete mode 100644 tests/cases/fourslash/goToImplementationInterfaceMethod_12.ts diff --git a/src/services/services.ts b/src/services/services.ts index 914ae98746a..511d76d30f7 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1844,6 +1844,13 @@ namespace ts { owners: string[]; } + // Internal interface used for tracking state in find all references when checking + // the inheritance hierarchy of property access expressions + interface SymbolInheritanceState { + symbol: Symbol; + cachedInheritanceResults: Map; + } + export interface DisplayPartsSymbolWriter extends SymbolWriter { displayParts(): SymbolDisplayPart[]; } @@ -6546,13 +6553,17 @@ namespace ts { // symbol of the local type of the symbol the property is being accessed on. This is because our search // symbol may have a different parent symbol if the local type's symbol does not declare the property // being accessed (i.e. it is declared in some parent class or interface) - let parentSymbol: Symbol = undefined; - let inheritanceCache: Map = undefined; - if (implementations && searchLocation.parent && searchLocation.parent.kind === SyntaxKind.PropertyAccessExpression && searchLocation === (searchLocation.parent).name) { + let parentSymbols: SymbolInheritanceState[] = undefined; + + if (implementations && isRightSideOfPropertyAccess(searchLocation)) { const localParentType = typeChecker.getTypeAtLocation((searchLocation.parent).expression); - if (localParentType && localParentType.symbol && localParentType.symbol.getFlags() & (SymbolFlags.Interface | SymbolFlags.Class) && localParentType.symbol.parent !== searchSymbol.parent) { - parentSymbol = localParentType.symbol; - inheritanceCache = createMap(); + if (localParentType) { + if (localParentType.symbol && isClassOrInterfaceReference(localParentType.symbol) && localParentType.symbol.parent !== searchSymbol.parent) { + parentSymbols = [createSymbolInheritanceState(localParentType.symbol)]; + } + else if (localParentType.getFlags() & TypeFlags.UnionOrIntersection) { + parentSymbols = map(getSymbolsForComponentTypes(localParentType), createSymbolInheritanceState); + } } } @@ -6596,7 +6607,7 @@ namespace ts { if (referenceSymbol) { const referenceSymbolDeclaration = referenceSymbol.valueDeclaration; const shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, parentSymbol, inheritanceCache); + const relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, parentSymbols); if (relatedSymbol) { const referenceEntry = implementations ? getImplementationReferenceEntryForNode(referenceLocation) : getReferenceEntryFromNode(referenceLocation); @@ -6691,6 +6702,18 @@ namespace ts { } } + function getSymbolsForComponentTypes(type: UnionOrIntersectionType, result: Symbol[] = []): Symbol[] { + for (const componentType of type.types) { + if (componentType.symbol && componentType.symbol.getFlags() & (SymbolFlags.Class | SymbolFlags.Interface)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & TypeFlags.UnionOrIntersection) { + getSymbolsForComponentTypes(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node: Node): Node { if (node) { if (node.kind === SyntaxKind.TypeReference) { @@ -6786,7 +6809,7 @@ namespace ts { return inherits; } - function searchTypeReference(typeReference: ExpressionWithTypeArguments, cachedResults: Map) { + function searchTypeReference(typeReference: ExpressionWithTypeArguments, cachedResults: Map): boolean { if (typeReference) { const type = typeChecker.getTypeAtLocation(typeReference); if (type && type.symbol) { @@ -6797,6 +6820,13 @@ namespace ts { } } + function createSymbolInheritanceState(symbol: Symbol): SymbolInheritanceState { + return { + symbol, + cachedInheritanceResults: createMap() + }; + } + function getReferencesForSuperKeyword(superKeyword: Node): ReferencedSymbol[] { let searchSpaceNode = getSuperContainer(superKeyword, /*stopOnFunctions*/ false); if (!searchSpaceNode) { @@ -7144,7 +7174,7 @@ namespace ts { } } - function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, parentSymbol: Symbol, inheritanceCache: Map): Symbol { + function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, parentSymbols: SymbolInheritanceState[]): Symbol { if (searchSymbols.indexOf(referenceSymbol) >= 0) { return referenceSymbol; } @@ -7153,7 +7183,7 @@ namespace ts { // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. const aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation); if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, parentSymbol, inheritanceCache); + return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, parentSymbols); } // If the reference location is in an object literal, try to get the contextual type for the @@ -7198,7 +7228,13 @@ namespace ts { // Finally, try all properties with the same name in any type the containing type extended or implemented, and // see if any is in the list. If we were passed a parent symbol, only include types that are subtypes of the // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface) && (!parentSymbol || inheritsFrom(rootSymbol.parent, parentSymbol, inheritanceCache))) { + if (rootSymbol.parent && rootSymbol.parent.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { + if (parentSymbols) { + if (!forEach(parentSymbols, ({symbol, cachedInheritanceResults}) => inheritsFrom(rootSymbol.parent, symbol, cachedInheritanceResults))) { + return undefined; + } + } + const result: Symbol[] = []; getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ createMap()); return forEach(result, s => searchSymbols.indexOf(s) >= 0 ? s : undefined); diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts index eed8c418043..76d4e750ad9 100644 --- a/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_10.ts @@ -1,9 +1,12 @@ /// -// Should handle intersection types +// Should handle union and intersection types -//// interface Foo { +//// interface BaseFoo { //// hello(): void; +//// } +//// +//// interface Foo extends BaseFoo { //// aloha(): void; //// } //// @@ -13,12 +16,16 @@ //// } //// //// class FooImpl implements Foo { -//// hello() {/**FooImpl*/} +//// [|hello() {/**FooImpl*/}|] //// aloha() {} //// } //// +//// class BaseFooImpl implements BaseFoo { +//// hello() {/**BaseFooImpl*/} // Should not show up +//// } +//// //// class BarImpl implements Bar { -//// hello() {/**BarImpl*/} +//// [|hello() {/**BarImpl*/}|] //// goodbye() {} //// } //// @@ -28,9 +35,15 @@ //// goodbye() {} //// } //// -//// function someFunction(x: Foo & Bar) { -//// x.he/*function_call*/llo(); +//// function someFunction(x: Foo | Bar) { +//// x.he/*function_call0*/llo(); +//// } +//// +//// function anotherFunction(x: Foo & Bar) { +//// x.he/*function_call1*/llo(); //// } -goTo.marker("function_call"); -verify.allRangesAppearInImplementationList(); +for (var i = 0; i < 2; i++) { + goTo.marker("function_call" + i); + verify.allRangesAppearInImplementationList(); +} diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts index 7cf0533de5f..7d948006fb3 100644 --- a/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts +++ b/tests/cases/fourslash/goToImplementationInterfaceMethod_11.ts @@ -1,36 +1,12 @@ -/// - -// Should handle union types - -//// interface Foo { -//// hello(): void; -//// aloha(): void; -//// } -//// -//// interface Bar { -//// hello(): void; -//// goodbye(): void; -//// } -//// -//// class FooImpl implements Foo { -//// [|hello() {/**FooImpl*/}|] -//// aloha() {} -//// } -//// -//// class BarImpl implements Bar { -//// [|hello() {/**BarImpl*/}|] -//// goodbye() {} -//// } -//// -//// class FooAndBarImpl implements Foo, Bar { -//// [|hello() {/**FooAndBarImpl*/}|] -//// aloha() {} -//// goodbye() {} -//// } -//// -//// function someFunction(x: Foo | Bar) { -//// x.he/*function_call*/llo(); -//// } - -goTo.marker("function_call"); -verify.allRangesAppearInImplementationList(); +/// + +// Should handle members of object literals in type assertion expressions + +//// interface Foo { +//// hel/*reference*/lo(): void; +//// } +//// +//// var x = { [|hello: () => {}|] }; +//// var y = (((({ [|hello: () => {}|] })))); +goTo.marker("reference"); +verify.allRangesAppearInImplementationList(); \ No newline at end of file diff --git a/tests/cases/fourslash/goToImplementationInterfaceMethod_12.ts b/tests/cases/fourslash/goToImplementationInterfaceMethod_12.ts deleted file mode 100644 index 7d948006fb3..00000000000 --- a/tests/cases/fourslash/goToImplementationInterfaceMethod_12.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -// Should handle members of object literals in type assertion expressions - -//// interface Foo { -//// hel/*reference*/lo(): void; -//// } -//// -//// var x = { [|hello: () => {}|] }; -//// var y = (((({ [|hello: () => {}|] })))); -goTo.marker("reference"); -verify.allRangesAppearInImplementationList(); \ No newline at end of file From 59774733d6d70ec0a249993310a78f448c3ae026 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 30 Aug 2016 06:39:13 -0700 Subject: [PATCH 298/508] Support decorators and templates --- src/compiler/utilities.ts | 12 +++++++ src/services/services.ts | 35 ++++++++----------- .../goToDeclarationDecoratorOverloads.ts | 22 ++++++++++++ .../goToDefinitionFunctionOverloads.ts | 9 +++-- .../goToDefinitionTaggedTemplateOverloads.ts | 16 +++++++++ 5 files changed, 71 insertions(+), 23 deletions(-) create mode 100644 tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts create mode 100644 tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0c026fc6b6d..af156c8f5f9 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1035,6 +1035,18 @@ namespace ts { return undefined; } + export function isCallLikeExpression(node: Node): node is CallLikeExpression { + switch (node.kind) { + case SyntaxKind.CallExpression: + case SyntaxKind.NewExpression: + case SyntaxKind.TaggedTemplateExpression: + case SyntaxKind.Decorator: + return true; + default: + return false; + } + } + export function getInvokedExpression(node: CallLikeExpression): Expression { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; diff --git a/src/services/services.ts b/src/services/services.ts index 29cbcfd59d5..437289e376c 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2793,32 +2793,25 @@ namespace ts { } function isCallExpressionTarget(node: Node): boolean { - return !!getCallOrNewExpressionWorker(node, SyntaxKind.CallExpression); + node = climbPastPropertyAccess(node); + return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; } function isNewExpressionTarget(node: Node): boolean { - return !!getCallOrNewExpressionWorker(node, SyntaxKind.NewExpression); + node = climbPastPropertyAccess(node); + return node && node.parent && node.parent.kind === SyntaxKind.NewExpression && (node.parent).expression === node; } - function getCallOrNewExpressionTargetingNode(node: Node): CallExpression | NewExpression | undefined { - return getCallOrNewExpressionWorker(node, SyntaxKind.CallExpression) || getCallOrNewExpressionWorker(node, SyntaxKind.NewExpression); - } - - function tryGetCalledDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined { - const callOrNewExpression = getCallOrNewExpressionTargetingNode(node); - if (callOrNewExpression) { - const signature = typeChecker.getResolvedSignature(callOrNewExpression); - return signature.declaration; - } - } - - function getCallOrNewExpressionWorker(node: Node, kind: SyntaxKind): Node | undefined { + /** Returns a CallLikeExpression where `node` is the target being invoked. */ + function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined { const target = climbPastPropertyAccess(node); - return target && - target.parent && - target.parent.kind === kind && - (target.parent).expression === target && - target.parent; + const callLike = target.parent; + return isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike; + } + + function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined { + const callLike = getAncestorCallLikeExpression(node); + return callLike && typeChecker.getResolvedSignature(callLike).declaration; } function isNameOfModuleDeclaration(node: Node) { @@ -5232,7 +5225,7 @@ namespace ts { const typeChecker = program.getTypeChecker(); - const calledDeclaration = tryGetCalledDeclaration(typeChecker, node); + const calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); if (calledDeclaration) { return [getDefinitionFromSignatureDeclaration(calledDeclaration)]; } diff --git a/tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts b/tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts new file mode 100644 index 00000000000..ce012d53aba --- /dev/null +++ b/tests/cases/fourslash/goToDeclarationDecoratorOverloads.ts @@ -0,0 +1,22 @@ +// @Target: ES6 +// @experimentaldecorators: true + +////async function f() {} +//// +/////*defDecString*/function dec(target: any, propertyKey: string): void; +/////*defDecSymbol*/function dec(target: any, propertyKey: symbol): void; +////function dec(target: any, propertyKey: string | symbol) {} +//// +////declare const s: symbol; +////class C { +//// @/*useDecString*/dec f() {} +//// @/*useDecSymbol*/dec [s]() {} +////} + +goTo.marker("useDecString"); +goTo.definition(); +verify.caretAtMarker("defDecString"); + +goTo.marker("useDecSymbol"); +goTo.definition(); +verify.caretAtMarker("defDecSymbol"); diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts index fb690607f1a..4d1c09efd7a 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloads.ts @@ -1,11 +1,12 @@ /// -/////*functionOverload1*/function /*functionOverload*/functionOverload(); +/////*functionOverload1*/function /*functionOverload*/functionOverload(value: number); /////*functionOverload2*/function functionOverload(value: string); /////*functionOverloadDefinition*/function functionOverload() {} //// -/////*functionOverloadReference1*/functionOverload(); +/////*functionOverloadReference1*/functionOverload(123); /////*functionOverloadReference2*/functionOverload("123"); +/////*brokenOverload*/functionOverload({}); goTo.marker('functionOverloadReference1'); goTo.definition(); @@ -15,6 +16,10 @@ goTo.marker('functionOverloadReference2'); goTo.definition(); verify.caretAtMarker('functionOverload2'); +goTo.marker('brokenOverload'); +goTo.definition(); +verify.caretAtMarker('functionOverload1'); + goTo.marker('functionOverload'); goTo.definition(); verify.caretAtMarker('functionOverloadDefinition'); diff --git a/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts b/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts new file mode 100644 index 00000000000..54a2039b0a1 --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionTaggedTemplateOverloads.ts @@ -0,0 +1,16 @@ +/// + +/////*defFNumber*/function f(strs: TemplateStringsArray, x: number): void; +/////*defFBool*/function f(strs: TemplateStringsArray, x: boolean): void; +////function f(strs: TemplateStringsArray, x: number | boolean) {} +//// +/////*useFNumber*/f`${0}`; +/////*useFBool*/f`${false}`; + +goTo.marker("useFNumber"); +goTo.definition(); +verify.caretAtMarker("defFNumber"); + +goTo.marker("useFBool"); +goTo.definition(); +verify.caretAtMarker("defFBool"); From efc7e9db6f3c7e74d6aa974888a084dd7f6bc42b Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 30 Aug 2016 06:51:52 -0700 Subject: [PATCH 299/508] Climb past multiple property accesses if necessary --- src/services/services.ts | 6 +++++- ...initionOverloadsInMultiplePropertyAccesses.ts | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts diff --git a/src/services/services.ts b/src/services/services.ts index 437289e376c..084d372da1a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2792,6 +2792,10 @@ namespace ts { return isRightSideOfPropertyAccess(node) ? node.parent : node; } + function climbPastManyPropertyAccesses(node: Node): Node { + return isRightSideOfPropertyAccess(node) ? climbPastManyPropertyAccesses(node.parent) : node; + } + function isCallExpressionTarget(node: Node): boolean { node = climbPastPropertyAccess(node); return node && node.parent && node.parent.kind === SyntaxKind.CallExpression && (node.parent).expression === node; @@ -2804,7 +2808,7 @@ namespace ts { /** Returns a CallLikeExpression where `node` is the target being invoked. */ function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined { - const target = climbPastPropertyAccess(node); + const target = climbPastManyPropertyAccesses(node); const callLike = target.parent; return isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike; } diff --git a/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts b/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts new file mode 100644 index 00000000000..de15c633e5f --- /dev/null +++ b/tests/cases/fourslash/goToDefinitionOverloadsInMultiplePropertyAccesses.ts @@ -0,0 +1,16 @@ +/// + +// Test that we can climb past more than one property access to reach a call expression. + +////namespace A { +//// export namespace B { +//// export function f(value: number): void; +//// /*1*/export function f(value: string): void; +//// export function f(value: number | string) {} +//// } +////} +////A.B./*2*/f(""); + +goTo.marker("2"); +goTo.definition(); +verify.caretAtMarker("1"); From d47b3e22e568bdf37c5ed0544713658723e2be8e Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 30 Aug 2016 07:09:18 -0700 Subject: [PATCH 300/508] Remove useless inserts that used to be required to trigger checks --- tests/cases/fourslash/cloduleAsBaseClass.ts | 3 --- tests/cases/fourslash/cloduleAsBaseClass2.ts | 3 --- tests/cases/fourslash/cloduleTypeOf1.ts | 4 ---- tests/cases/fourslash/cloduleWithRecursiveReference.ts | 3 --- tests/cases/fourslash/commentsClass.ts | 3 --- tests/cases/fourslash/commentsExternalModules.ts | 3 --- tests/cases/fourslash/commentsMultiModuleMultiFile.ts | 2 -- tests/cases/fourslash/commentsMultiModuleSingleFile.ts | 3 --- tests/cases/fourslash/completionListAtEOF.ts | 3 --- tests/cases/fourslash/completionListCladule.ts | 3 --- tests/cases/fourslash/completionListErrorRecovery.ts | 3 --- tests/cases/fourslash/completionListErrorRecovery2.ts | 3 --- tests/cases/fourslash/contextualTyping.ts | 3 --- tests/cases/fourslash/extendInterfaceOverloadedMethod.ts | 3 --- tests/cases/fourslash/funduleWithRecursiveReference.ts | 3 --- tests/cases/fourslash/genericCombinators1.ts | 3 --- tests/cases/fourslash/genericCombinators2.ts | 3 --- .../cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts | 3 --- tests/cases/fourslash/goToDefinitionPartialImplementation.ts | 3 --- .../fourslash/mergedDeclarationsWithExportAssignment1.ts | 3 --- tests/cases/fourslash/quickInfoInFunctionTypeReference.ts | 3 --- .../fourslash/quickInfoOnConstructorWithGenericParameter.ts | 3 --- tests/cases/fourslash/signatureHelpForSuperCalls1.ts | 3 --- tests/cases/fourslash/signatureHelpSimpleSuperCall.ts | 3 --- 24 files changed, 72 deletions(-) diff --git a/tests/cases/fourslash/cloduleAsBaseClass.ts b/tests/cases/fourslash/cloduleAsBaseClass.ts index 19bd3bb53e3..89f7b8ce8a7 100644 --- a/tests/cases/fourslash/cloduleAsBaseClass.ts +++ b/tests/cases/fourslash/cloduleAsBaseClass.ts @@ -23,9 +23,6 @@ ////d./*1*/ ////D./*2*/ -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('1'); verify.completionListContains('foo'); verify.completionListContains('foo2'); diff --git a/tests/cases/fourslash/cloduleAsBaseClass2.ts b/tests/cases/fourslash/cloduleAsBaseClass2.ts index 310ae72d664..995348fc7d1 100644 --- a/tests/cases/fourslash/cloduleAsBaseClass2.ts +++ b/tests/cases/fourslash/cloduleAsBaseClass2.ts @@ -28,9 +28,6 @@ ////d./*1*/ ////D./*2*/ -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('1'); verify.completionListContains('foo'); verify.completionListContains('foo2'); diff --git a/tests/cases/fourslash/cloduleTypeOf1.ts b/tests/cases/fourslash/cloduleTypeOf1.ts index f34bb04c075..16f49a6ddb3 100644 --- a/tests/cases/fourslash/cloduleTypeOf1.ts +++ b/tests/cases/fourslash/cloduleTypeOf1.ts @@ -14,10 +14,6 @@ //// } ////} -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - - goTo.marker('1'); verify.completionListContains('f'); verify.completionListContains('foo'); diff --git a/tests/cases/fourslash/cloduleWithRecursiveReference.ts b/tests/cases/fourslash/cloduleWithRecursiveReference.ts index 069049907ff..0a22bf7af42 100644 --- a/tests/cases/fourslash/cloduleWithRecursiveReference.ts +++ b/tests/cases/fourslash/cloduleWithRecursiveReference.ts @@ -9,9 +9,6 @@ //// } ////} -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker(); verify.quickInfoIs('var M.C.C: typeof M.C'); verify.numberOfErrorsInCurrentFile(0); \ No newline at end of file diff --git a/tests/cases/fourslash/commentsClass.ts b/tests/cases/fourslash/commentsClass.ts index b9a446efe6e..fb42c01f4c9 100644 --- a/tests/cases/fourslash/commentsClass.ts +++ b/tests/cases/fourslash/commentsClass.ts @@ -58,9 +58,6 @@ ////} ////var myVar = new m.m2.c/*33*/1(); -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('1'); verify.quickInfoIs("class c2", "This is class c2 without constuctor"); diff --git a/tests/cases/fourslash/commentsExternalModules.ts b/tests/cases/fourslash/commentsExternalModules.ts index c4bba7c444f..c7212fbea61 100644 --- a/tests/cases/fourslash/commentsExternalModules.ts +++ b/tests/cases/fourslash/commentsExternalModules.ts @@ -31,9 +31,6 @@ /////*10*/extMod./*11*/m1./*12*/fooExp/*13q*/ort(/*13*/); ////var new/*14*/Var = new extMod.m1.m2./*15*/c(); -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.file("commentsExternalModules_file0.ts"); goTo.marker('1'); verify.quickInfoIs("namespace m1", "Namespace comment"); diff --git a/tests/cases/fourslash/commentsMultiModuleMultiFile.ts b/tests/cases/fourslash/commentsMultiModuleMultiFile.ts index 9516ddc9abb..2a9e01e42d9 100644 --- a/tests/cases/fourslash/commentsMultiModuleMultiFile.ts +++ b/tests/cases/fourslash/commentsMultiModuleMultiFile.ts @@ -26,8 +26,6 @@ ////} ////new /*7*/mu/*8*/ltiM.d(); -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); goTo.marker('1'); verify.completionListContains("multiM", "namespace multiM", "this is multi declare namespace\nthi is multi namespace 2\nthis is multi namespace 3 comment"); diff --git a/tests/cases/fourslash/commentsMultiModuleSingleFile.ts b/tests/cases/fourslash/commentsMultiModuleSingleFile.ts index c2bd677ce9a..0393338b26c 100644 --- a/tests/cases/fourslash/commentsMultiModuleSingleFile.ts +++ b/tests/cases/fourslash/commentsMultiModuleSingleFile.ts @@ -16,9 +16,6 @@ ////new /*1*/mu/*4*/ltiM.b(); ////new mu/*5*/ltiM.c(); -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('1'); verify.completionListContains("multiM", "namespace multiM", "this is multi declare namespace\nthi is multi namespace 2"); diff --git a/tests/cases/fourslash/completionListAtEOF.ts b/tests/cases/fourslash/completionListAtEOF.ts index 0f73d15075a..e1b210281cb 100644 --- a/tests/cases/fourslash/completionListAtEOF.ts +++ b/tests/cases/fourslash/completionListAtEOF.ts @@ -2,9 +2,6 @@ ////var a; -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.eof(); verify.completionListContains("a"); diff --git a/tests/cases/fourslash/completionListCladule.ts b/tests/cases/fourslash/completionListCladule.ts index 79c2e8aea6d..d1819e6d187 100644 --- a/tests/cases/fourslash/completionListCladule.ts +++ b/tests/cases/fourslash/completionListCladule.ts @@ -12,9 +12,6 @@ ////var f = new Foo(); ////f/*c3*/; -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker("c1"); edit.insert("."); verify.memberListContains("x"); diff --git a/tests/cases/fourslash/completionListErrorRecovery.ts b/tests/cases/fourslash/completionListErrorRecovery.ts index 7a7b9f81ca1..3e90ff4f22a 100644 --- a/tests/cases/fourslash/completionListErrorRecovery.ts +++ b/tests/cases/fourslash/completionListErrorRecovery.ts @@ -5,9 +5,6 @@ ////Foo./**/; /////*1*/var bar; -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker(); verify.memberListContains("fun"); verify.not.errorExistsAfterMarker("1"); \ No newline at end of file diff --git a/tests/cases/fourslash/completionListErrorRecovery2.ts b/tests/cases/fourslash/completionListErrorRecovery2.ts index 8a368ba4466..9d5ddfdb145 100644 --- a/tests/cases/fourslash/completionListErrorRecovery2.ts +++ b/tests/cases/fourslash/completionListErrorRecovery2.ts @@ -4,9 +4,6 @@ ////var baz = Foo/**/; /////*1*/baz.concat("y"); -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker(); edit.insert(".b"); verify.not.errorExistsAfterMarker("1"); diff --git a/tests/cases/fourslash/contextualTyping.ts b/tests/cases/fourslash/contextualTyping.ts index 6861ca84915..ecd12739271 100644 --- a/tests/cases/fourslash/contextualTyping.ts +++ b/tests/cases/fourslash/contextualTyping.ts @@ -194,9 +194,6 @@ //// } ////}; -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('1'); verify.quickInfoIs("(property) C1T5.foo: (i: number, s: string) => number"); goTo.marker('2'); diff --git a/tests/cases/fourslash/extendInterfaceOverloadedMethod.ts b/tests/cases/fourslash/extendInterfaceOverloadedMethod.ts index 43a476303f6..332f4e0e5c7 100644 --- a/tests/cases/fourslash/extendInterfaceOverloadedMethod.ts +++ b/tests/cases/fourslash/extendInterfaceOverloadedMethod.ts @@ -11,9 +11,6 @@ ////var b: B; ////var /**/x = b.foo2().foo(5).foo(); // 'x' is of type 'void' -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker(); verify.quickInfoIs('var x: void'); verify.numberOfErrorsInCurrentFile(0); diff --git a/tests/cases/fourslash/funduleWithRecursiveReference.ts b/tests/cases/fourslash/funduleWithRecursiveReference.ts index c93d2cc0e1a..5af02f60dd4 100644 --- a/tests/cases/fourslash/funduleWithRecursiveReference.ts +++ b/tests/cases/fourslash/funduleWithRecursiveReference.ts @@ -7,9 +7,6 @@ //// } ////} -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker(); verify.quickInfoIs('var M.C.C: typeof M.C'); verify.numberOfErrorsInCurrentFile(0); \ No newline at end of file diff --git a/tests/cases/fourslash/genericCombinators1.ts b/tests/cases/fourslash/genericCombinators1.ts index 40f524c9dba..04f64cdcd8c 100644 --- a/tests/cases/fourslash/genericCombinators1.ts +++ b/tests/cases/fourslash/genericCombinators1.ts @@ -50,9 +50,6 @@ ////var /*23*/r8a = _.map(c5, (/*8*/x) => { return x.foo() }); -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('1'); verify.quickInfoIs('(parameter) x: number'); goTo.marker('2'); diff --git a/tests/cases/fourslash/genericCombinators2.ts b/tests/cases/fourslash/genericCombinators2.ts index bcd96dcd1c6..af7f621bc12 100644 --- a/tests/cases/fourslash/genericCombinators2.ts +++ b/tests/cases/fourslash/genericCombinators2.ts @@ -56,9 +56,6 @@ //// ////var /*23*/r8a = _.map(c5, (/*8a*/x,/*8b*/y) => { return y.foo() }); -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('2a'); verify.quickInfoIs('(parameter) x: Collection'); goTo.marker('2b'); diff --git a/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts b/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts index f368120922d..d5f5a374c39 100644 --- a/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts +++ b/tests/cases/fourslash/goToDefinitionFunctionOverloadsInClass.ts @@ -11,9 +11,6 @@ //// constructor() { } ////} -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('staticFunctionOverload'); goTo.definition(); verify.caretAtMarker('staticFunctionOverloadDefinition'); diff --git a/tests/cases/fourslash/goToDefinitionPartialImplementation.ts b/tests/cases/fourslash/goToDefinitionPartialImplementation.ts index eaf75f9a90b..81e417b6c0f 100644 --- a/tests/cases/fourslash/goToDefinitionPartialImplementation.ts +++ b/tests/cases/fourslash/goToDefinitionPartialImplementation.ts @@ -16,9 +16,6 @@ //// var x: /*Part2Use*/IA; ////} -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('Part2Use'); goTo.definition(); verify.caretAtMarker('Part1Definition'); diff --git a/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts b/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts index 791f519aa28..b3d80b5b588 100644 --- a/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts +++ b/tests/cases/fourslash/mergedDeclarationsWithExportAssignment1.ts @@ -15,9 +15,6 @@ ////var /*3*/z = new /*2*/Foo(); ////var /*5*/r2 = Foo./*4*/x; -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('1'); verify.quickInfoIs("import Foo = require('./mergedDeclarationsWithExportAssignment1_file0')"); diff --git a/tests/cases/fourslash/quickInfoInFunctionTypeReference.ts b/tests/cases/fourslash/quickInfoInFunctionTypeReference.ts index e8430d3fabe..180590ef4d0 100644 --- a/tests/cases/fourslash/quickInfoInFunctionTypeReference.ts +++ b/tests/cases/fourslash/quickInfoInFunctionTypeReference.ts @@ -4,9 +4,6 @@ ////} ////var x = <{ (fn: (va/*2*/riable2: string) => void, a: string): void; }> () => { }; -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker("1"); verify.quickInfoIs("(parameter) variable1: string", undefined); diff --git a/tests/cases/fourslash/quickInfoOnConstructorWithGenericParameter.ts b/tests/cases/fourslash/quickInfoOnConstructorWithGenericParameter.ts index d2ec8ca4f14..2adc8cf336f 100644 --- a/tests/cases/fourslash/quickInfoOnConstructorWithGenericParameter.ts +++ b/tests/cases/fourslash/quickInfoOnConstructorWithGenericParameter.ts @@ -16,9 +16,6 @@ ////} ////var x = new /*2*/B(/*1*/ -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker("1"); verify.currentSignatureHelpIs("B(a: Foo, b: number): B"); edit.insert("null,"); diff --git a/tests/cases/fourslash/signatureHelpForSuperCalls1.ts b/tests/cases/fourslash/signatureHelpForSuperCalls1.ts index 58e083ea2ed..6857cf76ead 100644 --- a/tests/cases/fourslash/signatureHelpForSuperCalls1.ts +++ b/tests/cases/fourslash/signatureHelpForSuperCalls1.ts @@ -17,9 +17,6 @@ //// } ////} -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('1'); verify.signatureHelpPresent(); verify.currentSignatureHelpIs('B(): B'); diff --git a/tests/cases/fourslash/signatureHelpSimpleSuperCall.ts b/tests/cases/fourslash/signatureHelpSimpleSuperCall.ts index ff8913a6b04..01d140f29ea 100644 --- a/tests/cases/fourslash/signatureHelpSimpleSuperCall.ts +++ b/tests/cases/fourslash/signatureHelpSimpleSuperCall.ts @@ -10,9 +10,6 @@ //// } ////} -// this line triggers a semantic/syntactic error check, remove line when 788570 is fixed -edit.insert(''); - goTo.marker('superCall'); verify.signatureHelpCountIs(1); verify.currentSignatureHelpIs("SuperCallBase(b: boolean): SuperCallBase"); From f0a532dac9fdc53e2b4af8f493be6fc47ee47a03 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Tue, 30 Aug 2016 07:45:51 -0700 Subject: [PATCH 301/508] Improve tests --- ...outSlash.js => importWithTrailingSlash.js} | 2 +- ...race.json => importWithTrailingSlash.json} | 0 ...ymbols => importWithTrailingSlash.symbols} | 0 .../importWithTrailingSlash.trace.json | 28 +++++++++++++++++++ ...sh.types => importWithTrailingSlash.types} | 0 ...portWithTrailingSlash_noResolve.errors.txt | 9 ++++++ .../importWithTrailingSlash_noResolve.js | 7 +++++ ...portWithTrailingSlash_noResolve.trace.json | 10 +++++++ ...outSlash.ts => importWithTrailingSlash.ts} | 0 .../importWithTrailingSlash_noResolve.ts | 5 ++++ 10 files changed, 60 insertions(+), 1 deletion(-) rename tests/baselines/reference/{relativeModuleWithoutSlash.js => importWithTrailingSlash.js} (87%) rename tests/baselines/reference/{relativeModuleWithoutSlash.trace.json => importWithTrailingSlash.json} (100%) rename tests/baselines/reference/{relativeModuleWithoutSlash.symbols => importWithTrailingSlash.symbols} (100%) create mode 100644 tests/baselines/reference/importWithTrailingSlash.trace.json rename tests/baselines/reference/{relativeModuleWithoutSlash.types => importWithTrailingSlash.types} (100%) create mode 100644 tests/baselines/reference/importWithTrailingSlash_noResolve.errors.txt create mode 100644 tests/baselines/reference/importWithTrailingSlash_noResolve.js create mode 100644 tests/baselines/reference/importWithTrailingSlash_noResolve.trace.json rename tests/cases/compiler/{relativeModuleWithoutSlash.ts => importWithTrailingSlash.ts} (100%) create mode 100644 tests/cases/compiler/importWithTrailingSlash_noResolve.ts diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.js b/tests/baselines/reference/importWithTrailingSlash.js similarity index 87% rename from tests/baselines/reference/relativeModuleWithoutSlash.js rename to tests/baselines/reference/importWithTrailingSlash.js index e52d0cd19ed..7118dd95bb8 100644 --- a/tests/baselines/reference/relativeModuleWithoutSlash.js +++ b/tests/baselines/reference/importWithTrailingSlash.js @@ -1,4 +1,4 @@ -//// [tests/cases/compiler/relativeModuleWithoutSlash.ts] //// +//// [tests/cases/compiler/importWithTrailingSlash.ts] //// //// [a.ts] diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.trace.json b/tests/baselines/reference/importWithTrailingSlash.json similarity index 100% rename from tests/baselines/reference/relativeModuleWithoutSlash.trace.json rename to tests/baselines/reference/importWithTrailingSlash.json diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.symbols b/tests/baselines/reference/importWithTrailingSlash.symbols similarity index 100% rename from tests/baselines/reference/relativeModuleWithoutSlash.symbols rename to tests/baselines/reference/importWithTrailingSlash.symbols diff --git a/tests/baselines/reference/importWithTrailingSlash.trace.json b/tests/baselines/reference/importWithTrailingSlash.trace.json new file mode 100644 index 00000000000..3c99d4eb6a0 --- /dev/null +++ b/tests/baselines/reference/importWithTrailingSlash.trace.json @@ -0,0 +1,28 @@ +[ + "======== Resolving module '.' from '/a/test.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module as file / folder, candidate module location '/a'.", + "File '/a.ts' exist - use it as a name resolution result.", + "Resolving real path for '/a.ts', result '/a.ts'", + "======== Module name '.' was successfully resolved to '/a.ts'. ========", + "======== Resolving module './' from '/a/test.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module as file / folder, candidate module location '/a/'.", + "File '/a/package.json' does not exist.", + "File '/a/index.ts' exist - use it as a name resolution result.", + "Resolving real path for '/a/index.ts', result '/a/index.ts'", + "======== Module name './' was successfully resolved to '/a/index.ts'. ========", + "======== Resolving module '..' from '/a/b/test.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module as file / folder, candidate module location '/a'.", + "File '/a.ts' exist - use it as a name resolution result.", + "Resolving real path for '/a.ts', result '/a.ts'", + "======== Module name '..' was successfully resolved to '/a.ts'. ========", + "======== Resolving module '../' from '/a/b/test.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module as file / folder, candidate module location '/a/'.", + "File '/a/package.json' does not exist.", + "File '/a/index.ts' exist - use it as a name resolution result.", + "Resolving real path for '/a/index.ts', result '/a/index.ts'", + "======== Module name '../' was successfully resolved to '/a/index.ts'. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.types b/tests/baselines/reference/importWithTrailingSlash.types similarity index 100% rename from tests/baselines/reference/relativeModuleWithoutSlash.types rename to tests/baselines/reference/importWithTrailingSlash.types diff --git a/tests/baselines/reference/importWithTrailingSlash_noResolve.errors.txt b/tests/baselines/reference/importWithTrailingSlash_noResolve.errors.txt new file mode 100644 index 00000000000..780e1d2f1bc --- /dev/null +++ b/tests/baselines/reference/importWithTrailingSlash_noResolve.errors.txt @@ -0,0 +1,9 @@ +/a.ts(2,17): error TS2307: Cannot find module './foo/'. + + +==== /a.ts (1 errors) ==== + + import foo from "./foo/"; + ~~~~~~~~ +!!! error TS2307: Cannot find module './foo/'. + \ No newline at end of file diff --git a/tests/baselines/reference/importWithTrailingSlash_noResolve.js b/tests/baselines/reference/importWithTrailingSlash_noResolve.js new file mode 100644 index 00000000000..b523c76af3b --- /dev/null +++ b/tests/baselines/reference/importWithTrailingSlash_noResolve.js @@ -0,0 +1,7 @@ +//// [a.ts] + +import foo from "./foo/"; + + +//// [a.js] +"use strict"; diff --git a/tests/baselines/reference/importWithTrailingSlash_noResolve.trace.json b/tests/baselines/reference/importWithTrailingSlash_noResolve.trace.json new file mode 100644 index 00000000000..e010603106f --- /dev/null +++ b/tests/baselines/reference/importWithTrailingSlash_noResolve.trace.json @@ -0,0 +1,10 @@ +[ + "======== Resolving module './foo/' from '/a.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module as file / folder, candidate module location '/foo/'.", + "File '/foo/package.json' does not exist.", + "File '/foo/index.ts' does not exist.", + "File '/foo/index.tsx' does not exist.", + "File '/foo/index.d.ts' does not exist.", + "======== Module name './foo/' was not resolved. ========" +] \ No newline at end of file diff --git a/tests/cases/compiler/relativeModuleWithoutSlash.ts b/tests/cases/compiler/importWithTrailingSlash.ts similarity index 100% rename from tests/cases/compiler/relativeModuleWithoutSlash.ts rename to tests/cases/compiler/importWithTrailingSlash.ts diff --git a/tests/cases/compiler/importWithTrailingSlash_noResolve.ts b/tests/cases/compiler/importWithTrailingSlash_noResolve.ts new file mode 100644 index 00000000000..95541adfb11 --- /dev/null +++ b/tests/cases/compiler/importWithTrailingSlash_noResolve.ts @@ -0,0 +1,5 @@ +// @traceResolution: true +// @moduleResolution: node + +// @Filename: /a.ts +import foo from "./foo/"; From 0b9573118454ab2420abc168405be1a78b482b57 Mon Sep 17 00:00:00 2001 From: Yui Date: Tue, 30 Aug 2016 16:07:36 -0700 Subject: [PATCH 302/508] Fix 10408 : Better error message for set/get with noImplicitAny error (#10597) * Giving more explicit error message when there is no-implicit-any on get/set accessor * Update error message number * Add new test and baselines * Address PR: assert that getter must existed * Address PR: undo renumbering of error messages --- src/compiler/checker.ts | 8 +++- src/compiler/diagnosticMessages.json | 14 +++--- ...AndSetAccessorWithAnyReturnType.errors.txt | 4 +- ...noImplicitAnyMissingGetAccessor.errors.txt | 27 ++++++++++++ .../noImplicitAnyMissingGetAccessor.js | 44 +++++++++++++++++++ ...noImplicitAnyMissingSetAccessor.errors.txt | 17 +++++++ .../noImplicitAnyMissingSetAccessor.js | 43 ++++++++++++++++++ .../noImplicitAnyMissingGetAccessor.ts | 14 ++++++ .../noImplicitAnyMissingSetAccessor.ts | 13 ++++++ 9 files changed, 176 insertions(+), 8 deletions(-) create mode 100644 tests/baselines/reference/noImplicitAnyMissingGetAccessor.errors.txt create mode 100644 tests/baselines/reference/noImplicitAnyMissingGetAccessor.js create mode 100644 tests/baselines/reference/noImplicitAnyMissingSetAccessor.errors.txt create mode 100644 tests/baselines/reference/noImplicitAnyMissingSetAccessor.js create mode 100644 tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts create mode 100644 tests/cases/compiler/noImplicitAnyMissingSetAccessor.ts diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index a98c72c9e10..863c9e7c37a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3346,7 +3346,13 @@ namespace ts { // Otherwise, fall back to 'any'. else { if (compilerOptions.noImplicitAny) { - error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_type_annotation, symbolToString(symbol)); + if (setter) { + error(setter, Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); + } + else { + Debug.assert(!!getter, "there must existed getter as we are current checking either setter or getter in this function"); + error(getter, Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol)); + } } type = anyType; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b8978b32571..e6bf1d5a170 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -2871,11 +2871,7 @@ "Element implicitly has an 'any' type because index expression is not of type 'number'.": { "category": "Error", "code": 7015 - }, - "Property '{0}' implicitly has type 'any', because its 'set' accessor lacks a type annotation.": { - "category": "Error", - "code": 7016 - }, + }, "Index signature of object type implicitly has an 'any' type.": { "category": "Error", "code": 7017 @@ -2932,6 +2928,14 @@ "category": "Error", "code": 7031 }, + "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation.": { + "category": "Error", + "code": 7032 + }, + "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation.": { + "category": "Error", + "code": 7033 + }, "You cannot rename this element.": { "category": "Error", "code": 8000 diff --git a/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt b/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt index 460ff97b10e..1e2de97aae0 100644 --- a/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt +++ b/tests/baselines/reference/implicitAnyGetAndSetAccessorWithAnyReturnType.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(3,5): erro tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(4,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation. +tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,16): error TS7032: Property 'haveOnlySet' implicitly has type 'any', because its set accessor lacks a parameter type annotation. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(15,28): error TS7006: Parameter 'newXValue' implicitly has an 'any' type. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): error TS7010: 'haveOnlyGet', which lacks return-type annotation, implicitly has an 'any' return type. @@ -33,7 +33,7 @@ tests/cases/compiler/implicitAnyGetAndSetAccessorWithAnyReturnType.ts(20,16): er ~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~~~~~~~~~ -!!! error TS7016: Property 'haveOnlySet' implicitly has type 'any', because its 'set' accessor lacks a type annotation. +!!! error TS7032: Property 'haveOnlySet' implicitly has type 'any', because its set accessor lacks a parameter type annotation. ~~~~~~~~~ !!! error TS7006: Parameter 'newXValue' implicitly has an 'any' type. } diff --git a/tests/baselines/reference/noImplicitAnyMissingGetAccessor.errors.txt b/tests/baselines/reference/noImplicitAnyMissingGetAccessor.errors.txt new file mode 100644 index 00000000000..ef2a273711f --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyMissingGetAccessor.errors.txt @@ -0,0 +1,27 @@ +tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts(4,25): error TS7032: Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation. +tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts(4,33): error TS7006: Parameter 'str' implicitly has an 'any' type. +tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts(9,16): error TS7032: Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation. +tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts(9,24): error TS7006: Parameter 'str' implicitly has an 'any' type. + + +==== tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts (4 errors) ==== + + abstract class Parent + { + public abstract set message(str); + ~~~~~~~ +!!! error TS7032: Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation. + ~~~ +!!! error TS7006: Parameter 'str' implicitly has an 'any' type. + } + + class Child extends Parent { + _x: any; + public set message(str) { + ~~~~~~~ +!!! error TS7032: Property 'message' implicitly has type 'any', because its set accessor lacks a parameter type annotation. + ~~~ +!!! error TS7006: Parameter 'str' implicitly has an 'any' type. + this._x = str; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js b/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js new file mode 100644 index 00000000000..38a2a731af4 --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyMissingGetAccessor.js @@ -0,0 +1,44 @@ +//// [noImplicitAnyMissingGetAccessor.ts] + +abstract class Parent +{ + public abstract set message(str); +} + +class Child extends Parent { + _x: any; + public set message(str) { + this._x = str; + } +} + +//// [noImplicitAnyMissingGetAccessor.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var Parent = (function () { + function Parent() { + } + Object.defineProperty(Parent.prototype, "message", { + set: function (str) { }, + enumerable: true, + configurable: true + }); + return Parent; +}()); +var Child = (function (_super) { + __extends(Child, _super); + function Child() { + _super.apply(this, arguments); + } + Object.defineProperty(Child.prototype, "message", { + set: function (str) { + this._x = str; + }, + enumerable: true, + configurable: true + }); + return Child; +}(Parent)); diff --git a/tests/baselines/reference/noImplicitAnyMissingSetAccessor.errors.txt b/tests/baselines/reference/noImplicitAnyMissingSetAccessor.errors.txt new file mode 100644 index 00000000000..ba104209189 --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyMissingSetAccessor.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/noImplicitAnyMissingSetAccessor.ts(4,25): error TS7033: Property 'message' implicitly has type 'any', because its get accessor lacks a return type annotation. + + +==== tests/cases/compiler/noImplicitAnyMissingSetAccessor.ts (1 errors) ==== + + abstract class Parent + { + public abstract get message(); + ~~~~~~~ +!!! error TS7033: Property 'message' implicitly has type 'any', because its get accessor lacks a return type annotation. + } + + class Child extends Parent { + public get message() { + return ""; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js b/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js new file mode 100644 index 00000000000..d4e0d17186d --- /dev/null +++ b/tests/baselines/reference/noImplicitAnyMissingSetAccessor.js @@ -0,0 +1,43 @@ +//// [noImplicitAnyMissingSetAccessor.ts] + +abstract class Parent +{ + public abstract get message(); +} + +class Child extends Parent { + public get message() { + return ""; + } +} + +//// [noImplicitAnyMissingSetAccessor.js] +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var Parent = (function () { + function Parent() { + } + Object.defineProperty(Parent.prototype, "message", { + get: function () { }, + enumerable: true, + configurable: true + }); + return Parent; +}()); +var Child = (function (_super) { + __extends(Child, _super); + function Child() { + _super.apply(this, arguments); + } + Object.defineProperty(Child.prototype, "message", { + get: function () { + return ""; + }, + enumerable: true, + configurable: true + }); + return Child; +}(Parent)); diff --git a/tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts b/tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts new file mode 100644 index 00000000000..d6c7b012cf9 --- /dev/null +++ b/tests/cases/compiler/noImplicitAnyMissingGetAccessor.ts @@ -0,0 +1,14 @@ +// @noImplicitAny : true +// @target: es5 + +abstract class Parent +{ + public abstract set message(str); +} + +class Child extends Parent { + _x: any; + public set message(str) { + this._x = str; + } +} \ No newline at end of file diff --git a/tests/cases/compiler/noImplicitAnyMissingSetAccessor.ts b/tests/cases/compiler/noImplicitAnyMissingSetAccessor.ts new file mode 100644 index 00000000000..ae18faf1f6f --- /dev/null +++ b/tests/cases/compiler/noImplicitAnyMissingSetAccessor.ts @@ -0,0 +1,13 @@ +// @noImplicitAny: true +// @target: es5 + +abstract class Parent +{ + public abstract get message(); +} + +class Child extends Parent { + public get message() { + return ""; + } +} \ No newline at end of file From 707d61d7fe953b04b3ad117294a33135573ced3a Mon Sep 17 00:00:00 2001 From: Yui Date: Wed, 31 Aug 2016 13:53:14 -0700 Subject: [PATCH 303/508] Fix RWC Runner to report both .types and .symbols errors (#10513) * Correctly append .types or .symbols when calling from rwc runner * Report both errors from generating .types or .symbols * Address PR --- src/harness/harness.ts | 25 +++++++++++++++++++------ src/harness/rwcRunner.ts | 3 ++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/harness/harness.ts b/src/harness/harness.ts index 9e27f500b80..ac0de944213 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1370,23 +1370,31 @@ namespace Harness { // Produce baselines. The first gives the types for all expressions. // The second gives symbols for all identifiers. - let e1: Error, e2: Error; + let typesError: Error, symbolsError: Error; try { checkBaseLines(/*isSymbolBaseLine*/ false); } catch (e) { - e1 = e; + typesError = e; } try { checkBaseLines(/*isSymbolBaseLine*/ true); } catch (e) { - e2 = e; + symbolsError = e; } - if (e1 || e2) { - throw e1 || e2; + if (typesError && symbolsError) { + throw new Error(typesError.message + ts.sys.newLine + symbolsError.message); + } + + if (typesError) { + throw typesError; + } + + if (symbolsError) { + throw symbolsError; } return; @@ -1396,7 +1404,12 @@ namespace Harness { const fullExtension = isSymbolBaseLine ? ".symbols" : ".types"; - Harness.Baseline.runBaseline(baselinePath.replace(/\.tsx?/, fullExtension), () => fullBaseLine, opts); + // When calling this function from rwc-runner, the baselinePath will have no extension. + // As rwc test- file is stored in json which ".json" will get stripped off. + // When calling this function from compiler-runner, the baselinePath will then has either ".ts" or ".tsx" extension + const outputFileName = ts.endsWith(baselinePath, ".ts") || ts.endsWith(baselinePath, ".tsx") ? + baselinePath.replace(/\.tsx?/, fullExtension) : baselinePath.concat(fullExtension); + Harness.Baseline.runBaseline(outputFileName, () => fullBaseLine, opts); } function generateBaseLine(typeWriterResults: ts.Map, isSymbolBaseline: boolean): string { diff --git a/src/harness/rwcRunner.ts b/src/harness/rwcRunner.ts index ba1ab71ec19..fff0d6bfb49 100644 --- a/src/harness/rwcRunner.ts +++ b/src/harness/rwcRunner.ts @@ -223,7 +223,8 @@ namespace RWC { }); it("has the expected types", () => { - Harness.Compiler.doTypeAndSymbolBaseline(`${baseName}.types`, compilerResult, inputFiles + // We don't need to pass the extension here because "doTypeAndSymbolBaseline" will append appropriate extension of ".types" or ".symbols" + Harness.Compiler.doTypeAndSymbolBaseline(baseName, compilerResult, inputFiles .concat(otherFiles) .filter(file => !!compilerResult.program.getSourceFile(file.unitName)) .filter(e => !Harness.isDefaultLibraryFile(e.unitName)), baselineOpts); From b9b79af1b7f93411786849ee53f7cca0b0ab260a Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 31 Aug 2016 18:11:47 -0700 Subject: [PATCH 304/508] Recombining import completions and regular completion APIs --- src/harness/fourslash.ts | 8 +- src/harness/harnessLanguageService.ts | 3 - src/server/client.ts | 28 ++----- src/server/protocol.d.ts | 20 ++--- src/server/session.ts | 13 ++- src/services/services.ts | 109 ++++++++++++-------------- src/services/shims.ts | 8 -- 7 files changed, 77 insertions(+), 112 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 86317faa174..2b4373d79fa 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -780,10 +780,10 @@ namespace FourSlash { if (ranges && ranges.length > rangeIndex) { const range = ranges[rangeIndex]; - const start = completions.textSpan.start; - const end = start + completions.textSpan.length; + const start = completion.replacementSpan.start; + const end = start + completion.replacementSpan.length; if (range.start !== start || range.end !== end) { - this.raiseError(`Expected completion span for '${symbol}', ${stringify(completions.textSpan)}, to cover range ${stringify(range)}`); + this.raiseError(`Expected completion span for '${symbol}', ${stringify(completion.replacementSpan)}, to cover range ${stringify(range)}`); } } else { @@ -892,7 +892,7 @@ namespace FourSlash { } private getImportModuleCompletionListAtCaret() { - return this.languageService.getImportModuleCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition); + return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition); } private getCompletionEntryDetails(entryName: string) { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 880a103a202..fba1b87610b 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -405,9 +405,6 @@ namespace Harness.LanguageService { getCompletionsAtPosition(fileName: string, position: number): ts.CompletionInfo { return unwrapJSONCallResult(this.shim.getCompletionsAtPosition(fileName, position)); } - getImportModuleCompletionsAtPosition(fileName: string, position: number): ts.ImportCompletionInfo { - return unwrapJSONCallResult(this.shim.getImportModuleCompletionsAtPosition(fileName, position)); - } getCompletionEntryDetails(fileName: string, position: number, entryName: string): ts.CompletionEntryDetails { return unwrapJSONCallResult(this.shim.getCompletionEntryDetails(fileName, position, entryName)); } diff --git a/src/server/client.ts b/src/server/client.ts index deb7f53801f..d5aed77bd1f 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -216,28 +216,16 @@ namespace ts.server { return { isMemberCompletion: false, isNewIdentifierLocation: false, - entries: response.body - }; - } + entries: response.body.map(({ name, kind, kindModifiers, sortText, replacementSpan }) => { - getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionInfo { - const lineOffset = this.positionToOneBasedLineOffset(fileName, position); - const args: protocol.CompletionsRequestArgs = { - file: fileName, - line: lineOffset.line, - offset: lineOffset.offset, - prefix: undefined - }; + let convertedSpan: TextSpan; + if (replacementSpan) { + convertedSpan = createTextSpanFromBounds(this.lineOffsetToPosition(fileName, replacementSpan.start), + this.lineOffsetToPosition(fileName, replacementSpan.end)); + } - const request = this.processRequest(CommandNames.ImportModuleCompletions, args); - const response = this.processResponse(request); - - const startPosition = this.lineOffsetToPosition(fileName, response.span.start); - const endPosition = this.lineOffsetToPosition(fileName, response.span.end); - - return { - textSpan: ts.createTextSpanFromBounds(startPosition, endPosition), - entries: response.body + return { name, kind, kindModifiers, sortText, replacementSpan: convertedSpan }; + }) }; } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index 20670ae0245..2f71c3d5b74 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -717,16 +717,6 @@ declare namespace ts.server.protocol { arguments: CompletionsRequestArgs; } - /** - * Import Module Completions request; value of command field is - * "importModuleCompletions". Given a file location (file, line, - * col) return the possible completions for external module - * specifiers or paths given that position refers to a module - * import declaration, require call, or triple slash reference. - */ - export interface ImportModuleCompletionsRequest extends FileLocationRequest { - } - /** * Arguments for completion details request. */ @@ -783,6 +773,11 @@ declare namespace ts.server.protocol { * is often the same as the name but may be different in certain circumstances. */ sortText: string; + /** + * An optional span that indicates the text to be replaced by this completion item. If present, + * this span should be used instead of the default one. + */ + replacementSpan?: TextSpan; } /** @@ -816,11 +811,6 @@ declare namespace ts.server.protocol { body?: CompletionEntry[]; } - export interface ImportModuleCompletionsResponse extends Response { - span: TextSpan; - body?: ImportCompletionEntry[]; - } - export interface CompletionDetailsResponse extends Response { body?: CompletionEntryDetails[]; } diff --git a/src/server/session.ts b/src/server/session.ts index c771d100229..5af4203311a 100644 --- a/src/server/session.ts +++ b/src/server/session.ts @@ -103,7 +103,6 @@ namespace ts.server { export const Change = "change"; export const Close = "close"; export const Completions = "completions"; - export const ImportModuleCompletions = "importModuleCompletions"; export const CompletionDetails = "completionEntryDetails"; export const Configure = "configure"; export const Definition = "definition"; @@ -773,7 +772,17 @@ namespace ts.server { return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => { if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) { - result.push(entry); + const { name, kind, kindModifiers, sortText, replacementSpan } = entry; + + let convertedSpan: protocol.TextSpan = undefined; + if (replacementSpan) { + convertedSpan = { + start: compilerService.host.positionToLineOffset(fileName, replacementSpan.start), + end: compilerService.host.positionToLineOffset(fileName, replacementSpan.start + replacementSpan.length) + }; + } + + result.push({ name, kind, kindModifiers, sortText, replacementSpan: convertedSpan }); } return result; }, []).sort((a, b) => a.name.localeCompare(b.name)); diff --git a/src/services/services.ts b/src/services/services.ts index 519a5abe8cf..66e450bf830 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1159,7 +1159,7 @@ namespace ts { useCaseSensitiveFileNames?(): boolean; /* - * LS host can optionally implement these methods to support getImportModuleCompletionsAtPosition. + * LS host can optionally implement these methods to support completions for module specifiers. * Without these methods, only completions for ambient modules will be provided. */ readDirectory?(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[]; @@ -1211,7 +1211,6 @@ namespace ts { getEncodedSemanticClassifications(fileName: string, span: TextSpan): Classifications; getCompletionsAtPosition(fileName: string, position: number): CompletionInfo; - getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionInfo; getCompletionEntryDetails(fileName: string, position: number, entryName: string): CompletionEntryDetails; getQuickInfoAtPosition(fileName: string, position: number): QuickInfo; @@ -1482,17 +1481,7 @@ namespace ts { kind: string; // see ScriptElementKind kindModifiers: string; // see ScriptElementKindModifier, comma separated sortText: string; - } - - export interface ImportCompletionInfo { - textSpan: TextSpan; - entries: ImportCompletionEntry[]; - } - - export interface ImportCompletionEntry { - name: string; - kind: string; // see ScriptElementKind - sortText: string; + replacementSpan?: TextSpan; } export interface CompletionEntryDetails { @@ -4247,6 +4236,11 @@ namespace ts { const sourceFile = getValidSourceFile(fileName); + const importCompletionInfo = getImportModuleCompletionsAtPosition(fileName, position); + if (importCompletionInfo && importCompletionInfo.entries.length !== 0) { + return importCompletionInfo; + } + if (isInString(sourceFile, position)) { return getStringLiteralCompletionEntries(sourceFile, position); } @@ -4510,7 +4504,7 @@ namespace ts { } } - function getImportModuleCompletionsAtPosition(fileName: string, position: number): ImportCompletionInfo { + function getImportModuleCompletionsAtPosition(fileName: string, position: number): CompletionInfo { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); @@ -4526,8 +4520,9 @@ namespace ts { if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { // Get all known external module names or complete a path to a module return { - entries: getStringLiteralCompletionEntriesFromModuleNames(node), - textSpan: getDirectoryFragmentTextSpan((node).text, node.getStart() + 1) + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: getStringLiteralCompletionEntriesFromModuleNames(node) }; } } @@ -4539,20 +4534,22 @@ namespace ts { const scriptPath = node.getSourceFile().path; const scriptDirectory = getDirectoryPath(scriptPath); + + const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { const compilerOptions = program.getCompilerOptions(); if (compilerOptions.rootDirs) { return getCompletionEntriesForDirectoryFragmentWithRootDirs( - compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, scriptPath); + compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span, scriptPath); } else { return getCompletionEntriesForDirectoryFragment( - literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, scriptPath); + literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span, scriptPath); } } else { // Check for node modules - return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory); + return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); } } @@ -4577,21 +4574,21 @@ namespace ts { return deduplicate(map(rootDirs, rootDirectory => combinePaths(rootDirectory, relativeDirectory))); } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, exclude?: string): ImportCompletionEntry[] { + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs: string[], fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string): CompletionEntry[] { const basePath = program.getCompilerOptions().project || host.getCurrentDirectory(); const ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); const baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - const result: ImportCompletionEntry[] = []; + const result: CompletionEntry[] = []; for (const baseDirectory of baseDirectories) { - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, exclude, result); + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, exclude, result); } return result; } - function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, exclude?: string, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { + function getCompletionEntriesForDirectoryFragment(fragment: string, scriptPath: string, extensions: string[], includeExtensions: boolean, span: TextSpan, exclude?: string, result: CompletionEntry[] = []): CompletionEntry[] { fragment = getDirectoryPath(fragment); if (!fragment) { fragment = "./"; @@ -4623,11 +4620,7 @@ namespace ts { } for (const foundFile in foundFiles) { - result.push({ - name: foundFile, - kind: ScriptElementKind.scriptElement, - sortText: foundFile - }); + result.push(createCompletionEntryForModule(foundFile, ScriptElementKind.scriptElement, span)); } } @@ -4637,11 +4630,7 @@ namespace ts { for (const directory of directories) { const directoryName = getBaseFileName(normalizePath(directory)); - result.push({ - name: directoryName, - kind: ScriptElementKind.directory, - sortText: directoryName - }); + result.push(createCompletionEntryForModule(directoryName, ScriptElementKind.directory, span)); } } } @@ -4656,17 +4645,17 @@ namespace ts { * Modules from node_modules (i.e. those listed in package.json) * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions */ - function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string): ImportCompletionEntry[] { + function getCompletionEntriesForNonRelativeModules(fragment: string, scriptPath: string, span: TextSpan): CompletionEntry[] { const options = program.getCompilerOptions(); const { baseUrl, paths } = options; - let result: ImportCompletionEntry[]; + let result: CompletionEntry[]; if (baseUrl) { const fileExtensions = getSupportedExtensions(options); const projectDir = options.project || host.getCurrentDirectory(); const absolute = isRootedDiskPath(baseUrl) ? baseUrl : combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false); + result = getCompletionEntriesForDirectoryFragment(fragment, normalizePath(absolute), fileExtensions, /*includeExtensions*/false, span); if (paths) { for (const path in paths) { @@ -4675,7 +4664,7 @@ namespace ts { if (paths[path]) { for (const pattern of paths[path]) { for (const match of getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions)) { - result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName)); + result.push(createCompletionEntryForModule(match, ScriptElementKind.externalModuleName, span)); } } } @@ -4683,7 +4672,7 @@ namespace ts { else if (startsWith(path, fragment)) { const entry = paths[path] && paths[path].length === 1 && paths[path][0]; if (entry) { - result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName)); + result.push(createCompletionEntryForModule(path, ScriptElementKind.externalModuleName, span)); } } } @@ -4694,10 +4683,10 @@ namespace ts { result = []; } - getCompletionEntriesFromTypings(host, options, scriptPath, result); + getCompletionEntriesFromTypings(host, options, scriptPath, span, result); for (const moduleName of enumeratePotentialNonRelativeModules(fragment, scriptPath, options)) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); } return result; @@ -4792,7 +4781,7 @@ namespace ts { return deduplicate(nonRelativeModules); } - function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number): ImportCompletionInfo { + function getTripleSlashReferenceCompletion(sourceFile: SourceFile, position: number): CompletionInfo { const token = getTokenAtPosition(sourceFile, position); if (!token) { return undefined; @@ -4818,38 +4807,39 @@ namespace ts { const toComplete = match[3]; const scriptPath = getDirectoryPath(sourceFile.path); + let entries: CompletionEntry[]; if (kind === "path") { // Give completions for a relative path - const textSpan: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - return { - entries: getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, sourceFile.path), - textSpan - }; + const span: TextSpan = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/true, span, sourceFile.path); } else { // Give completions based on the typings available - const textSpan: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - return { - entries: getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath), - textSpan - }; + const span: TextSpan = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + entries = getCompletionEntriesFromTypings(host, program.getCompilerOptions(), scriptPath, span); } + + return { + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries + }; } return undefined; } - function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, result: ImportCompletionEntry[] = []): ImportCompletionEntry[] { + function getCompletionEntriesFromTypings(host: LanguageServiceHost, options: CompilerOptions, scriptPath: string, span: TextSpan, result: CompletionEntry[] = []): CompletionEntry[] { // Check for typings specified in compiler options if (options.types) { for (const moduleName of options.types) { - result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName)); + result.push(createCompletionEntryForModule(moduleName, ScriptElementKind.externalModuleName, span)); } } else if (host.getDirectories) { const typeRoots = getEffectiveTypeRoots(options, host.getCurrentDirectory()); for (const root of typeRoots) { - getCompletionEntriesFromDirectories(host, options, root, result); + getCompletionEntriesFromDirectories(host, options, root, span, result); } } @@ -4857,18 +4847,18 @@ namespace ts { // Also get all @types typings installed in visible node_modules directories for (const package of findPackageJsons(scriptPath)) { const typesDir = combinePaths(getDirectoryPath(package), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, options, typesDir, result); + getCompletionEntriesFromDirectories(host, options, typesDir, span, result); } } return result; } - function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, result: ImportCompletionEntry[]) { + function getCompletionEntriesFromDirectories(host: LanguageServiceHost, options: CompilerOptions, directory: string, span: TextSpan, result: CompletionEntry[]) { if (host.getDirectories && directoryProbablyExists(directory, host)) { for (let typeDirectory of host.getDirectories(directory)) { typeDirectory = normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName)); + result.push(createCompletionEntryForModule(getBaseFileName(typeDirectory), ScriptElementKind.externalModuleName, span)); } } } @@ -4948,8 +4938,8 @@ namespace ts { } } - function createCompletionEntryForModule(name: string, kind: string): ImportCompletionEntry { - return { name, kind, sortText: name }; + function createCompletionEntryForModule(name: string, kind: string, replacementSpan: TextSpan): CompletionEntry { + return { name, kind, kindModifiers: ScriptElementKindModifier.none, sortText: name, replacementSpan }; } // Replace everything after the last directory seperator that appears @@ -8783,7 +8773,6 @@ namespace ts { getEncodedSyntacticClassifications, getEncodedSemanticClassifications, getCompletionsAtPosition, - getImportModuleCompletionsAtPosition, getCompletionEntryDetails, getSignatureHelpItems, getQuickInfoAtPosition, diff --git a/src/services/shims.ts b/src/services/shims.ts index 90d29dfa654..41b366e0857 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -140,7 +140,6 @@ namespace ts { getEncodedSemanticClassifications(fileName: string, start: number, length: number): string; getCompletionsAtPosition(fileName: string, position: number): string; - getImportModuleCompletionsAtPosition(fileName: string, position: number): string; getCompletionEntryDetails(fileName: string, position: number, entryName: string): string; getQuickInfoAtPosition(fileName: string, position: number): string; @@ -886,13 +885,6 @@ namespace ts { ); } - getImportModuleCompletionsAtPosition(fileName: string, position: number): string { - return this.forwardJSONCall( - `getImportModuleCompletionsAtPosition('${fileName}', ${position})`, - () => this.languageService.getImportModuleCompletionsAtPosition(fileName, position) - ); - } - /** Get a string based representation of a completion list entry details */ public getCompletionEntryDetails(fileName: string, position: number, entryName: string) { return this.forwardJSONCall( From 7261866c6cb8a312d2598a1abcd3d39f10ccbb81 Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Wed, 31 Aug 2016 19:20:15 -0700 Subject: [PATCH 305/508] Cleaning up the completion code and tests --- src/harness/fourslash.ts | 154 ++++++------------ src/services/services.ts | 52 +++--- .../completionForStringLiteralImport1.ts | 8 +- .../completionForStringLiteralImport2.ts | 8 +- ...etionForStringLiteralNonrelativeImport1.ts | 22 +-- ...tionForStringLiteralNonrelativeImport10.ts | 4 +- ...tionForStringLiteralNonrelativeImport11.ts | 8 +- ...tionForStringLiteralNonrelativeImport12.ts | 10 +- ...etionForStringLiteralNonrelativeImport2.ts | 6 +- ...etionForStringLiteralNonrelativeImport3.ts | 8 +- ...etionForStringLiteralNonrelativeImport4.ts | 8 +- ...etionForStringLiteralNonrelativeImport5.ts | 12 +- ...etionForStringLiteralNonrelativeImport7.ts | 6 +- ...etionForStringLiteralNonrelativeImport8.ts | 6 +- ...etionForStringLiteralNonrelativeImport9.ts | 6 +- ...rStringLiteralNonrelativeImportTypings1.ts | 8 +- ...rStringLiteralNonrelativeImportTypings2.ts | 6 +- ...rStringLiteralNonrelativeImportTypings3.ts | 6 +- ...mpletionForStringLiteralRelativeImport1.ts | 28 ++-- ...mpletionForStringLiteralRelativeImport2.ts | 28 ++-- ...mpletionForStringLiteralRelativeImport3.ts | 20 +-- ...mpletionForStringLiteralRelativeImport4.ts | 10 +- .../completionForTripleSlashReference1.ts | 24 +-- .../completionForTripleSlashReference2.ts | 12 +- .../completionForTripleSlashReference3.ts | 20 +-- .../completionForTripleSlashReference4.ts | 4 +- tests/cases/fourslash/fourslash.ts | 5 +- 27 files changed, 206 insertions(+), 283 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 2b4373d79fa..41471ed9a03 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -598,38 +598,6 @@ namespace FourSlash { } } - public verifyImportModuleCompletionListItemsCountIsGreaterThan(count: number, negative: boolean) { - const completions = this.getImportModuleCompletionListAtCaret(); - const itemsCount = completions.entries.length; - - if (negative) { - if (itemsCount > count) { - this.raiseError(`Expected import module completion list items count to not be greater than ${count}, but is actually ${itemsCount}`); - } - } - else { - if (itemsCount <= count) { - this.raiseError(`Expected import module completion list items count to be greater than ${count}, but is actually ${itemsCount}`); - } - } - } - - public verifyImportModuleCompletionListIsEmpty(negative: boolean) { - const completions = this.getImportModuleCompletionListAtCaret(); - if ((!completions || completions.entries.length === 0) && negative) { - this.raiseError("Completion list is empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition); - } - else if (completions && completions.entries.length !== 0 && !negative) { - let errorMsg = "\n" + "Completion List contains: [" + completions.entries[0].name; - for (let i = 1; i < completions.entries.length; i++) { - errorMsg += ", " + completions.entries[i].name; - } - errorMsg += "]\n"; - - this.raiseError("Completion list is not empty at caret at position " + this.activeFile.fileName + " " + this.currentCaretPosition + errorMsg); - } - } - public verifyCompletionListStartsWithItemsInOrder(items: string[]): void { if (items.length === 0) { return; @@ -701,10 +669,10 @@ namespace FourSlash { } } - public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string) { + public verifyCompletionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { const completions = this.getCompletionListAtCaret(); if (completions) { - this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind); + this.assertItemInCompletionList(completions.entries, symbol, text, documentation, kind, spanIndex); } else { this.raiseError(`No completions at position '${this.currentCaretPosition}' when looking for '${symbol}'.`); @@ -720,25 +688,32 @@ namespace FourSlash { * @param expectedText the text associated with the symbol * @param expectedDocumentation the documentation text associated with the symbol * @param expectedKind the kind of symbol (see ScriptElementKind) + * @param spanIndex the index of the range that the completion item's replacement text span should match */ - public verifyCompletionListDoesNotContain(symbol: string, expectedText?: string, expectedDocumentation?: string, expectedKind?: string) { + public verifyCompletionListDoesNotContain(symbol: string, expectedText?: string, expectedDocumentation?: string, expectedKind?: string, spanIndex?: number) { const that = this; + let replacementSpan: ts.TextSpan; + if (spanIndex !== undefined) { + replacementSpan = this.getTextSpanForRangeAtIndex(spanIndex); + } + function filterByTextOrDocumentation(entry: ts.CompletionEntry) { const details = that.getCompletionEntryDetails(entry.name); const documentation = ts.displayPartsToString(details.documentation); const text = ts.displayPartsToString(details.displayParts); - if (expectedText && expectedDocumentation) { - return (documentation === expectedDocumentation && text === expectedText) ? true : false; + + // If any of the expected values are undefined, assume that users don't + // care about them. + if (replacementSpan && !TestState.textSpansEqual(replacementSpan, entry.replacementSpan)) { + return false; } - else if (expectedText && !expectedDocumentation) { - return text === expectedText ? true : false; + else if (expectedText && text !== expectedText) { + return false; } - else if (expectedDocumentation && !expectedText) { - return documentation === expectedDocumentation ? true : false; + else if (expectedDocumentation && documentation !== expectedDocumentation) { + return false; } - // Because expectedText and expectedDocumentation are undefined, we assume that - // users don"t care to compare them so we will treat that entry as if the entry has matching text and documentation - // and keep it in the list of filtered entry. + return true; } @@ -762,49 +737,15 @@ namespace FourSlash { if (expectedKind) { error += "Expected kind: " + expectedKind + " to equal: " + filterCompletions[0].kind + "."; } + if (replacementSpan) { + const spanText = filterCompletions[0].replacementSpan ? stringify(filterCompletions[0].replacementSpan) : undefined; + error += "Expected replacement span: " + stringify(replacementSpan) + " to equal: " + spanText + "."; + } this.raiseError(error); } } } - public verifyImportModuleCompletionListContains(symbol: string, rangeIndex?: number) { - const completions = this.getImportModuleCompletionListAtCaret(); - if (completions) { - const completion = ts.forEach(completions.entries, completion => completion.name === symbol ? completion : undefined); - if (!completion) { - const itemsString = completions.entries.map(item => item.name).join(",\n"); - this.raiseError(`Expected "${symbol}" to be in list [${itemsString}]`); - } - else if (rangeIndex !== undefined) { - const ranges = this.getRanges(); - if (ranges && ranges.length > rangeIndex) { - const range = ranges[rangeIndex]; - - const start = completion.replacementSpan.start; - const end = start + completion.replacementSpan.length; - if (range.start !== start || range.end !== end) { - this.raiseError(`Expected completion span for '${symbol}', ${stringify(completion.replacementSpan)}, to cover range ${stringify(range)}`); - } - } - else { - this.raiseError(`Expected completion span for '${symbol}' to cover range at index ${rangeIndex}, but no range was found at that index`); - } - } - } - else { - this.raiseError(`No import module completions at position '${this.currentCaretPosition}' when looking for '${symbol}'.`); - } - } - - public verifyImportModuleCompletionListDoesNotContain(symbol: string) { - const completions = this.getImportModuleCompletionListAtCaret(); - if (completions) { - if (ts.forEach(completions.entries, completion => completion.name === symbol)) { - this.raiseError(`Import module completion list did contain ${symbol}`); - } - } - } - public verifyCompletionEntryDetails(entryName: string, expectedText: string, expectedDocumentation?: string, kind?: string) { const details = this.getCompletionEntryDetails(entryName); @@ -891,10 +832,6 @@ namespace FourSlash { return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition); } - private getImportModuleCompletionListAtCaret() { - return this.languageService.getCompletionsAtPosition(this.activeFile.fileName, this.currentCaretPosition); - } - private getCompletionEntryDetails(entryName: string) { return this.languageService.getCompletionEntryDetails(this.activeFile.fileName, this.currentCaretPosition, entryName); } @@ -2241,7 +2178,7 @@ namespace FourSlash { return text.substring(startPos, endPos); } - private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string) { + private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { for (let i = 0; i < items.length; i++) { const item = items[i]; if (item.name === name) { @@ -2260,6 +2197,11 @@ namespace FourSlash { assert.equal(item.kind, kind, this.assertionMessageAtLastKnownMarker("completion item kind for " + name)); } + if (spanIndex !== undefined) { + const span = this.getTextSpanForRangeAtIndex(spanIndex); + assert.isTrue(TestState.textSpansEqual(span, item.replacementSpan), this.assertionMessageAtLastKnownMarker(stringify(span) + " does not equal " + stringify(item.replacementSpan) + " replacement span for " + name)); + } + return; } } @@ -2316,6 +2258,17 @@ namespace FourSlash { return `line ${(pos.line + 1)}, col ${pos.character}`; } + private getTextSpanForRangeAtIndex(index: number): ts.TextSpan { + const ranges = this.getRanges(); + if (ranges && ranges.length > index) { + const range = ranges[index]; + return { start: range.start, length: range.end - range.start }; + } + else { + this.raiseError("Supplied span index: " + index + " does not exist in range list of size: " + (ranges ? 0 : ranges.length)); + } + } + public getMarkerByName(markerName: string) { const markerPos = this.testData.markerPositions[markerName]; if (markerPos === undefined) { @@ -2339,6 +2292,10 @@ namespace FourSlash { public resetCancelled(): void { this.cancellationToken.resetCancelled(); } + + private static textSpansEqual(a: ts.TextSpan, b: ts.TextSpan) { + return a && b && a.start === b.start && a.length === b.length; + } } export function runFourSlashTest(basePath: string, testType: FourSlashTestType, fileName: string) { @@ -2909,12 +2866,12 @@ namespace FourSlashInterface { // Verifies the completion list contains the specified symbol. The // completion list is brought up if necessary - public completionListContains(symbol: string, text?: string, documentation?: string, kind?: string) { + public completionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) { if (this.negative) { - this.state.verifyCompletionListDoesNotContain(symbol, text, documentation, kind); + this.state.verifyCompletionListDoesNotContain(symbol, text, documentation, kind, spanIndex); } else { - this.state.verifyCompletionListContains(symbol, text, documentation, kind); + this.state.verifyCompletionListContains(symbol, text, documentation, kind, spanIndex); } } @@ -2924,23 +2881,6 @@ namespace FourSlashInterface { this.state.verifyCompletionListItemsCountIsGreaterThan(count, this.negative); } - public importModuleCompletionListContains(symbol: string, rangeIndex?: number): void { - if (this.negative) { - this.state.verifyImportModuleCompletionListDoesNotContain(symbol); - } - else { - this.state.verifyImportModuleCompletionListContains(symbol, rangeIndex); - } - } - - public importModuleCompletionListItemsCountIsGreaterThan(count: number): void { - this.state.verifyImportModuleCompletionListItemsCountIsGreaterThan(count, this.negative); - } - - public importModuleCompletionListIsEmpty(): void { - this.state.verifyImportModuleCompletionListIsEmpty(this.negative); - } - public assertHasRanges(ranges: FourSlash.Range[]) { assert(ranges.length !== 0, "Array of ranges is expected to be non-empty"); } diff --git a/src/services/services.ts b/src/services/services.ts index 66e450bf830..0bbaa9b5c3e 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -4236,9 +4236,8 @@ namespace ts { const sourceFile = getValidSourceFile(fileName); - const importCompletionInfo = getImportModuleCompletionsAtPosition(fileName, position); - if (importCompletionInfo && importCompletionInfo.entries.length !== 0) { - return importCompletionInfo; + if (isInReferenceComment(sourceFile, position)) { + return getTripleSlashReferenceCompletion(sourceFile, position); } if (isInString(sourceFile, position)) { @@ -4410,6 +4409,13 @@ namespace ts { // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent); } + else if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { + // Get all known external module names or complete a path to a module + // i.e. import * as ns from "/*completion position*/"; + // import x = require("/*completion position*/"); + // var y = require("/*completion position*/"); + return getStringLiteralCompletionEntriesFromModuleNames(node); + } else { const argumentInfo = SignatureHelp.getContainingArgumentInfo(node, position, sourceFile); if (argumentInfo) { @@ -4502,55 +4508,35 @@ namespace ts { } } } - } - function getImportModuleCompletionsAtPosition(fileName: string, position: number): CompletionInfo { - synchronizeHostData(); - - const sourceFile = getValidSourceFile(fileName); - if (isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position); - } - else if (isInString(sourceFile, position)) { - const node = findPrecedingToken(position, sourceFile); - if (!node || node.kind !== SyntaxKind.StringLiteral) { - return undefined; - } - - if (node.parent.kind === SyntaxKind.ImportDeclaration || isExpressionOfExternalModuleImportEqualsDeclaration(node) || isRequireCall(node.parent, false)) { - // Get all known external module names or complete a path to a module - return { - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: getStringLiteralCompletionEntriesFromModuleNames(node) - }; - } - } - - return undefined; - - function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral) { + function getStringLiteralCompletionEntriesFromModuleNames(node: StringLiteral): CompletionInfo { const literalValue = normalizeSlashes(node.text); const scriptPath = node.getSourceFile().path; const scriptDirectory = getDirectoryPath(scriptPath); const span = getDirectoryFragmentTextSpan((node).text, node.getStart() + 1); + let entries: CompletionEntry[]; if (isPathRelativeToScript(literalValue) || isRootedDiskPath(literalValue)) { const compilerOptions = program.getCompilerOptions(); if (compilerOptions.rootDirs) { - return getCompletionEntriesForDirectoryFragmentWithRootDirs( + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs( compilerOptions.rootDirs, literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span, scriptPath); } else { - return getCompletionEntriesForDirectoryFragment( + entries = getCompletionEntriesForDirectoryFragment( literalValue, scriptDirectory, getSupportedExtensions(program.getCompilerOptions()), /*includeExtensions*/false, span, scriptPath); } } else { // Check for node modules - return getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span); } + return { + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries + }; } /** diff --git a/tests/cases/fourslash/completionForStringLiteralImport1.ts b/tests/cases/fourslash/completionForStringLiteralImport1.ts index 482726f6305..4cdee889538 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport1.ts @@ -21,13 +21,13 @@ //// export var x = 9; goTo.marker("0"); -verify.importModuleCompletionListContains("someFile1", 0); +verify.completionListContains("someFile1", undefined, undefined, undefined, 0); goTo.marker("1"); -verify.importModuleCompletionListContains("someFile2", 1); +verify.completionListContains("someFile2", undefined, undefined, undefined, 1); goTo.marker("2"); -verify.importModuleCompletionListContains("some-module", 2); +verify.completionListContains("some-module", undefined, undefined, undefined, 2); goTo.marker("3"); -verify.importModuleCompletionListContains("fourslash", 3); \ No newline at end of file +verify.completionListContains("fourslash", undefined, undefined, undefined, 3); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralImport2.ts b/tests/cases/fourslash/completionForStringLiteralImport2.ts index 43896f1f392..25de3d2240a 100644 --- a/tests/cases/fourslash/completionForStringLiteralImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralImport2.ts @@ -21,13 +21,13 @@ //// export var x = 9; goTo.marker("0"); -verify.importModuleCompletionListContains("someFile.ts", 0); +verify.completionListContains("someFile.ts", undefined, undefined, undefined, 0); goTo.marker("1"); -verify.importModuleCompletionListContains("some-module", 1); +verify.completionListContains("some-module", undefined, undefined, undefined, 1); goTo.marker("2"); -verify.importModuleCompletionListContains("someOtherFile.ts", 2); +verify.completionListContains("someOtherFile.ts", undefined, undefined, undefined, 2); goTo.marker("3"); -verify.importModuleCompletionListContains("some-module", 3); \ No newline at end of file +verify.completionListContains("some-module", undefined, undefined, undefined, 3); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts index d6f38431ce1..c0e5ebbcd90 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport1.ts @@ -45,19 +45,19 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("fake-module"); - verify.importModuleCompletionListContains("fake-module-dev"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("fake-module"); + verify.completionListContains("fake-module-dev"); + verify.not.completionListItemsCountIsGreaterThan(2); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("index"); - verify.importModuleCompletionListContains("ts"); - verify.importModuleCompletionListContains("dts"); - verify.importModuleCompletionListContains("tsx"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); + verify.completionListContains("index"); + verify.completionListContains("ts"); + verify.completionListContains("dts"); + verify.completionListContains("tsx"); + verify.not.completionListItemsCountIsGreaterThan(4); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("fake-module"); - verify.importModuleCompletionListContains("fake-module-dev"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("fake-module"); + verify.completionListContains("fake-module-dev"); + verify.not.completionListItemsCountIsGreaterThan(2); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts index aa9fd976644..24a323bc6e5 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport10.ts @@ -28,8 +28,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListIsEmpty(); + verify.completionListIsEmpty(); goTo.marker(kind + "1"); - verify.importModuleCompletionListIsEmpty(); + verify.completionListIsEmpty(); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts index 70d39182a8a..7b81c4da106 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport11.ts @@ -28,11 +28,11 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("module"); + verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("index"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("index"); + verify.not.completionListItemsCountIsGreaterThan(1); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts index 92db8d5a50e..ed202d68ec1 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport12.ts @@ -20,9 +20,9 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module"); - verify.importModuleCompletionListContains("dev-module"); - verify.importModuleCompletionListContains("optional-module"); - verify.importModuleCompletionListContains("peer-module"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); + verify.completionListContains("module"); + verify.completionListContains("dev-module"); + verify.completionListContains("optional-module"); + verify.completionListContains("peer-module"); + verify.not.completionListItemsCountIsGreaterThan(4); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts index bc2529e86f9..bac5c54ff23 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport2.ts @@ -31,7 +31,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("repeated"); - verify.importModuleCompletionListContains("other"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("repeated"); + verify.completionListContains("other"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts index 9b1fd451185..d2103f6f10c 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport3.ts @@ -31,8 +31,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("ts"); - verify.importModuleCompletionListContains("tsx"); - verify.importModuleCompletionListContains("dts"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("ts"); + verify.completionListContains("tsx"); + verify.completionListContains("dts"); + verify.not.completionListItemsCountIsGreaterThan(3); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts index b9be9f90213..b95fd96f380 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport4.ts @@ -27,8 +27,8 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("fake-module"); - verify.importModuleCompletionListContains("fake-module2"); - verify.importModuleCompletionListContains("fake-module3"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("fake-module"); + verify.completionListContains("fake-module2"); + verify.completionListContains("fake-module3"); + verify.not.completionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts index 4afa5854bf8..c8c9a18ff85 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport5.ts @@ -26,14 +26,14 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("ambientModule"); - verify.importModuleCompletionListContains("otherAmbientModule"); - verify.importModuleCompletionListContains("otherOtherAmbientModule"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("ambientModule"); + verify.completionListContains("otherAmbientModule"); + verify.completionListContains("otherOtherAmbientModule"); + verify.not.completionListItemsCountIsGreaterThan(3); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("ambientModule"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("ambientModule"); + verify.not.completionListItemsCountIsGreaterThan(1); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts index eca5a3e5412..57ba6e440cf 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport7.ts @@ -24,7 +24,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module"); - verify.importModuleCompletionListContains("module-from-node"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("module"); + verify.completionListContains("module-from-node"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts index 54893991432..603e8d1104d 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport8.ts @@ -45,11 +45,11 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("0test"); + verify.completionListContains("0test"); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("1test"); + verify.completionListContains("1test"); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("2test"); + verify.completionListContains("2test"); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts index bcdb731d1f1..8703c608462 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImport9.ts @@ -30,7 +30,7 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module1"); - verify.importModuleCompletionListContains("module2"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("module1"); + verify.completionListContains("module2"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts index 9cf2af9c875..687103629e2 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings1.ts @@ -28,8 +28,8 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module-x"); - verify.importModuleCompletionListContains("module-y"); - verify.importModuleCompletionListContains("module-z"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("module-x"); + verify.completionListContains("module-y"); + verify.completionListContains("module-z"); + verify.not.completionListItemsCountIsGreaterThan(3); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts index 1452c6c1c61..12a4fcf243f 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings2.ts @@ -26,7 +26,7 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module-x"); - verify.importModuleCompletionListContains("module-z"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("module-x"); + verify.completionListContains("module-z"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts index f4a4dbaaa99..14cf71ad0dc 100644 --- a/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts +++ b/tests/cases/fourslash/completionForStringLiteralNonrelativeImportTypings3.ts @@ -22,7 +22,7 @@ const kinds = ["types_ref", "import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module-x"); - verify.importModuleCompletionListContains("module-y"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("module-x"); + verify.completionListContains("module-y"); + verify.not.completionListItemsCountIsGreaterThan(2); } diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts index 909e2c6b14d..3ba82fb0acf 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport1.ts @@ -47,24 +47,24 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListIsEmpty(); + verify.completionListIsEmpty(); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("folder"); - verify.importModuleCompletionListContains("parentTest"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("e1"); + verify.completionListContains("folder"); + verify.completionListContains("parentTest"); + verify.not.completionListItemsCountIsGreaterThan(5); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("f3"); - verify.importModuleCompletionListContains("h1"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); + verify.completionListContains("f3"); + verify.completionListContains("h1"); + verify.not.completionListItemsCountIsGreaterThan(2); goTo.marker(kind + "3"); - verify.importModuleCompletionListContains("f4"); - verify.importModuleCompletionListContains("g1"); - verify.importModuleCompletionListContains("sub"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(3); + verify.completionListContains("f4"); + verify.completionListContains("g1"); + verify.completionListContains("sub"); + verify.not.completionListItemsCountIsGreaterThan(3); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts index 8c8cb405cd3..18a80ab3481 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport2.ts @@ -34,20 +34,20 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("f3"); - verify.importModuleCompletionListContains("f4"); - verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("e2"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("f3"); + verify.completionListContains("f4"); + verify.completionListContains("e1"); + verify.completionListContains("e2"); + verify.not.completionListItemsCountIsGreaterThan(6); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("f3"); - verify.importModuleCompletionListContains("f4"); - verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("e2"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(6); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("f3"); + verify.completionListContains("f4"); + verify.completionListContains("e1"); + verify.completionListContains("e2"); + verify.not.completionListItemsCountIsGreaterThan(6); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts index 82c3ea7d1e4..915cebdf6e7 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport3.ts @@ -34,18 +34,18 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("fourslash"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("fourslash"); + verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker(kind + "1"); - verify.importModuleCompletionListContains("fourslash"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); + verify.completionListContains("fourslash"); + verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker(kind + "2"); - verify.importModuleCompletionListContains("f1"); - verify.importModuleCompletionListContains("f2"); - verify.importModuleCompletionListContains("e1"); - verify.importModuleCompletionListContains("folder"); - verify.importModuleCompletionListContains("tests"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); + verify.completionListContains("f1"); + verify.completionListContains("f2"); + verify.completionListContains("e1"); + verify.completionListContains("folder"); + verify.completionListContains("tests"); + verify.not.completionListItemsCountIsGreaterThan(5); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts index ba9f95a08c2..b9750de9c17 100644 --- a/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts +++ b/tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts @@ -42,11 +42,11 @@ const kinds = ["import_as", "import_equals", "require"]; for (const kind of kinds) { goTo.marker(kind + "0"); - verify.importModuleCompletionListContains("module0"); - verify.importModuleCompletionListContains("module1"); - verify.importModuleCompletionListContains("module2"); - verify.importModuleCompletionListContains("more"); + verify.completionListContains("module0"); + verify.completionListContains("module1"); + verify.completionListContains("module2"); + verify.completionListContains("more"); // Should not contain itself - verify.not.importModuleCompletionListItemsCountIsGreaterThan(4); + verify.not.completionListItemsCountIsGreaterThan(4); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference1.ts b/tests/cases/fourslash/completionForTripleSlashReference1.ts index f8ea7fc4d44..2ce4de2e72e 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference1.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference1.ts @@ -32,20 +32,20 @@ for (let i = 0; i < 5; i++) { goTo.marker("" + i); - verify.importModuleCompletionListContains("f1.ts"); - verify.importModuleCompletionListContains("f1.d.ts"); - verify.importModuleCompletionListContains("f2.tsx"); - verify.importModuleCompletionListContains("e1.ts"); - verify.importModuleCompletionListContains("parentTest"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); + verify.completionListContains("f1.ts"); + verify.completionListContains("f1.d.ts"); + verify.completionListContains("f2.tsx"); + verify.completionListContains("e1.ts"); + verify.completionListContains("parentTest"); + verify.not.completionListItemsCountIsGreaterThan(5); } goTo.marker("5"); -verify.importModuleCompletionListContains("g1.ts"); -verify.importModuleCompletionListContains("sub"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); +verify.completionListContains("g1.ts"); +verify.completionListContains("sub"); +verify.not.completionListItemsCountIsGreaterThan(2); goTo.marker("6"); -verify.importModuleCompletionListContains("g1.ts"); -verify.importModuleCompletionListContains("sub"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(2); \ No newline at end of file +verify.completionListContains("g1.ts"); +verify.completionListContains("sub"); +verify.not.completionListItemsCountIsGreaterThan(2); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference2.ts b/tests/cases/fourslash/completionForTripleSlashReference2.ts index 0530e5e4093..e6553ce8e73 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference2.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference2.ts @@ -24,10 +24,10 @@ for (let i = 0; i < 5; i++) { goTo.marker("" + i); - verify.importModuleCompletionListContains("f1.ts"); - verify.importModuleCompletionListContains("f1.js"); - verify.importModuleCompletionListContains("f1.d.ts"); - verify.importModuleCompletionListContains("f2.tsx"); - verify.importModuleCompletionListContains("f4.jsx"); - verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); + verify.completionListContains("f1.ts"); + verify.completionListContains("f1.js"); + verify.completionListContains("f1.d.ts"); + verify.completionListContains("f2.tsx"); + verify.completionListContains("f4.jsx"); + verify.not.completionListItemsCountIsGreaterThan(5); } \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference3.ts b/tests/cases/fourslash/completionForTripleSlashReference3.ts index d27d0e658c2..798e556be58 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference3.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference3.ts @@ -27,17 +27,17 @@ //// /*e2*/ goTo.marker("0"); -verify.importModuleCompletionListContains("fourslash"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); +verify.completionListContains("fourslash"); +verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker("1"); -verify.importModuleCompletionListContains("fourslash"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); +verify.completionListContains("fourslash"); +verify.not.completionListItemsCountIsGreaterThan(1); goTo.marker("2"); -verify.importModuleCompletionListContains("f1.ts"); -verify.importModuleCompletionListContains("f2.tsx"); -verify.importModuleCompletionListContains("e1.ts"); -verify.importModuleCompletionListContains("folder"); -verify.importModuleCompletionListContains("tests"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(5); \ No newline at end of file +verify.completionListContains("f1.ts"); +verify.completionListContains("f2.tsx"); +verify.completionListContains("e1.ts"); +verify.completionListContains("folder"); +verify.completionListContains("tests"); +verify.not.completionListItemsCountIsGreaterThan(5); \ No newline at end of file diff --git a/tests/cases/fourslash/completionForTripleSlashReference4.ts b/tests/cases/fourslash/completionForTripleSlashReference4.ts index 9cedf4932b2..2eb58646675 100644 --- a/tests/cases/fourslash/completionForTripleSlashReference4.ts +++ b/tests/cases/fourslash/completionForTripleSlashReference4.ts @@ -38,6 +38,6 @@ goTo.marker("0"); -verify.importModuleCompletionListContains("module0.ts"); +verify.completionListContains("module0.ts"); -verify.not.importModuleCompletionListItemsCountIsGreaterThan(1); \ No newline at end of file +verify.not.completionListItemsCountIsGreaterThan(1); \ No newline at end of file diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index 948477b78dd..525fcc608f5 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -121,13 +121,10 @@ declare namespace FourSlashInterface { constructor(negative?: boolean); memberListContains(symbol: string, text?: string, documenation?: string, kind?: string): void; memberListCount(expectedCount: number): void; - completionListContains(symbol: string, text?: string, documentation?: string, kind?: string): void; + completionListContains(symbol: string, text?: string, documentation?: string, kind?: string, spanIndex?: number): void; completionListItemsCountIsGreaterThan(count: number): void; completionListIsEmpty(): void; completionListAllowsNewIdentifier(): void; - importModuleCompletionListContains(symbol: string, rangeIndex?: number): void; - importModuleCompletionListItemsCountIsGreaterThan(count: number): void; - importModuleCompletionListIsEmpty(): void; memberListIsEmpty(): void; signatureHelpPresent(): void; errorExistsBetweenMarkers(startMarker: string, endMarker: string): void; From ec7e8585a9e7f2a60c3b9cfbcacd787b3e49d8ff Mon Sep 17 00:00:00 2001 From: Rostislav Galimsky Date: Thu, 1 Sep 2016 13:12:05 +0300 Subject: [PATCH 306/508] fix issue --- .../testCode/testCode/formatting/classes.ts | 79 ------------ .../testCode/formatting/classesBaseline.ts | 79 ------------ .../testCode/formatting/colonAndQMark.ts | 4 - .../formatting/colonAndQMarkBaseline.ts | 4 - .../formatting/documentReadyFunction.ts | 3 - .../documentReadyFunctionBaseLine.ts | 3 - .../testCode/formatting/emptyBlock.ts | 1 - .../testCode/formatting/emptyBlockBaseline.ts | 1 - .../formatting/emptyInterfaceLiteral.ts | 10 -- .../emptyInterfaceLiteralBaseLine.ts | 10 -- .../testCode/formatting/fatArrowFunctions.ts | 112 ------------------ .../formatting/fatArrowFunctionsBaseline.ts | 112 ------------------ .../formatting/formatDebuggerStatement.ts | 2 - .../formatDebuggerStatementBaseline.ts | 2 - .../formatvariableDeclarationList.ts | 13 -- .../formatvariableDeclarationListBaseline.ts | 13 -- .../testCode/formatting/implicitModule.ts | 3 - .../formatting/implicitModuleBaseline.ts | 3 - .../testCode/formatting/importDeclaration.ts | 6 - .../formatting/importDeclarationBaseline.ts | 6 - .../testCode/testCode/formatting/main.ts | 95 --------------- .../testCode/formatting/mainBaseline.ts | 98 --------------- .../testCode/formatting/moduleIndentation.ts | 3 - .../formatting/moduleIndentationBaseline.ts | 3 - .../testCode/testCode/formatting/modules.ts | 76 ------------ .../testCode/formatting/modulesBaseline.ts | 76 ------------ .../testCode/formatting/objectLiteral.ts | 27 ----- .../formatting/objectLiteralBaseline.ts | 31 ----- .../testCode/formatting/onClosingBracket.ts | 32 ----- .../formatting/onClosingBracketBaseLine.ts | 28 ----- .../testCode/formatting/onSemiColon.ts | 1 - .../formatting/onSemiColonBaseline.ts | 1 - .../formatting/spaceAfterConstructor.ts | 1 - .../spaceAfterConstructorBaseline.ts | 1 - .../testCode/formatting/tabAfterCloseCurly.ts | 10 -- .../formatting/tabAfterCloseCurlyBaseline.ts | 9 -- .../formatting/typescriptConstructs.ts | 65 ---------- .../typescriptConstructsBaseline.ts | 58 --------- .../testCode/testCode/formatting/various.ts | 17 --- .../testCode/formatting/variousBaseline.ts | 17 --- .../testCode/formatting/withStatement.ts | 9 -- .../formatting/withStatementBaseline.ts | 6 - 42 files changed, 1130 deletions(-) delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/classes.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/classesBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/colonAndQMark.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/colonAndQMarkBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/documentReadyFunction.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/documentReadyFunctionBaseLine.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyBlock.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyBlockBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyInterfaceLiteral.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyInterfaceLiteralBaseLine.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/fatArrowFunctions.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/fatArrowFunctionsBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/formatDebuggerStatement.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/formatDebuggerStatementBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/formatvariableDeclarationList.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/formatvariableDeclarationListBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/implicitModule.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/implicitModuleBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/importDeclaration.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/importDeclarationBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/main.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/mainBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/moduleIndentation.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/moduleIndentationBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/modules.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/modulesBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/objectLiteral.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/objectLiteralBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/onClosingBracket.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/onClosingBracketBaseLine.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/onSemiColon.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/onSemiColonBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/spaceAfterConstructor.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/spaceAfterConstructorBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/tabAfterCloseCurly.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/tabAfterCloseCurlyBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/typescriptConstructs.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/typescriptConstructsBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/various.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/variousBaseline.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/withStatement.ts delete mode 100644 src/harness/unittests/services/formatting/testCode/testCode/formatting/withStatementBaseline.ts diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/classes.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/classes.ts deleted file mode 100644 index e779f69810f..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/classes.ts +++ /dev/null @@ -1,79 +0,0 @@ - class a { - constructor ( n : number ) ; - constructor ( s : string ) ; - constructor ( ns : any ) { - - } - - public pgF ( ) { } ; - - public pv ; - public get d ( ) { - return 30 ; - } - public set d ( ) { - } - - public static get p2 ( ) { - return { x : 30 , y : 40 } ; - } - - private static d2 ( ) { - } - private static get p3 ( ) { - return "string" ; - } - private pv3 ; - - private foo ( n : number ) : string ; - private foo ( s : string ) : string ; - private foo ( ns : any ) { - return ns.toString ( ) ; - } -} - - class b extends a { -} - - class m1b { - -} - - interface m1ib { - - } - class c extends m1b { -} - - class ib2 implements m1ib { -} - - declare class aAmbient { - constructor ( n : number ) ; - constructor ( s : string ) ; - public pgF ( ) : void ; - public pv ; - public d : number ; - static p2 : { x : number ; y : number ; } ; - static d2 ( ) ; - static p3 ; - private pv3 ; - private foo ( s ) ; -} - - class d { - private foo ( n : number ) : string ; - private foo ( ns : any ) { - return ns.toString ( ) ; - } - private foo ( s : string ) : string ; -} - - class e { - private foo ( ns : any ) { - return ns.toString ( ) ; - } - private foo ( s : string ) : string ; - private foo ( n : number ) : string ; -} - diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/classesBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/classesBaseline.ts deleted file mode 100644 index e7e69b44125..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/classesBaseline.ts +++ /dev/null @@ -1,79 +0,0 @@ -class a { - constructor(n: number); - constructor(s: string); - constructor(ns: any) { - - } - - public pgF() { }; - - public pv; - public get d() { - return 30; - } - public set d() { - } - - public static get p2() { - return { x: 30, y: 40 }; - } - - private static d2() { - } - private static get p3() { - return "string"; - } - private pv3; - - private foo(n: number): string; - private foo(s: string): string; - private foo(ns: any) { - return ns.toString(); - } -} - -class b extends a { -} - -class m1b { - -} - -interface m1ib { - -} -class c extends m1b { -} - -class ib2 implements m1ib { -} - -declare class aAmbient { - constructor(n: number); - constructor(s: string); - public pgF(): void; - public pv; - public d: number; - static p2: { x: number; y: number; }; - static d2(); - static p3; - private pv3; - private foo(s); -} - -class d { - private foo(n: number): string; - private foo(ns: any) { - return ns.toString(); - } - private foo(s: string): string; -} - -class e { - private foo(ns: any) { - return ns.toString(); - } - private foo(s: string): string; - private foo(n: number): string; -} - diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/colonAndQMark.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/colonAndQMark.ts deleted file mode 100644 index 5562e142046..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/colonAndQMark.ts +++ /dev/null @@ -1,4 +0,0 @@ -class foo { - constructor (n?: number, m? = 5, o?: string = "") { } - x:number = 1?2:3; -} diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/colonAndQMarkBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/colonAndQMarkBaseline.ts deleted file mode 100644 index 52bbe56251d..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/colonAndQMarkBaseline.ts +++ /dev/null @@ -1,4 +0,0 @@ -class foo { - constructor(n?: number, m? = 5, o?: string = "") { } - x: number = 1 ? 2 : 3; -} diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/documentReadyFunction.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/documentReadyFunction.ts deleted file mode 100644 index 35daa4d895c..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/documentReadyFunction.ts +++ /dev/null @@ -1,3 +0,0 @@ -$ ( document ) . ready ( function ( ) { - alert ( 'i am ready' ) ; - } ); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/documentReadyFunctionBaseLine.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/documentReadyFunctionBaseLine.ts deleted file mode 100644 index 838ef682207..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/documentReadyFunctionBaseLine.ts +++ /dev/null @@ -1,3 +0,0 @@ -$(document).ready(function() { - alert('i am ready'); -}); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyBlock.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyBlock.ts deleted file mode 100644 index 9e26dfeeb6e..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyBlock.ts +++ /dev/null @@ -1 +0,0 @@ -{} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyBlockBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyBlockBaseline.ts deleted file mode 100644 index 6f31cf5a2e6..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyBlockBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -{ } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyInterfaceLiteral.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyInterfaceLiteral.ts deleted file mode 100644 index 1feec453d03..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyInterfaceLiteral.ts +++ /dev/null @@ -1,10 +0,0 @@ - function foo ( x : { } ) { } - -foo ( { } ) ; - - - - interface bar { - x : { } ; - y : ( ) => { } ; - } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyInterfaceLiteralBaseLine.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyInterfaceLiteralBaseLine.ts deleted file mode 100644 index 04f3c0bc9b9..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/emptyInterfaceLiteralBaseLine.ts +++ /dev/null @@ -1,10 +0,0 @@ -function foo(x: {}) { } - -foo({}); - - - -interface bar { - x: {}; - y: () => {}; -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/fatArrowFunctions.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/fatArrowFunctions.ts deleted file mode 100644 index ebbf54557fa..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/fatArrowFunctions.ts +++ /dev/null @@ -1,112 +0,0 @@ -// valid - ( ) => 1 ; - ( arg ) => 2 ; - arg => 2 ; - ( arg = 1 ) => 3 ; - ( arg ? ) => 4 ; - ( arg : number ) => 5 ; - ( arg : number = 0 ) => 6 ; - ( arg ? : number ) => 7 ; - ( ... arg : number [ ] ) => 8 ; - ( arg1 , arg2 ) => 12 ; - ( arg1 = 1 , arg2 =3 ) => 13 ; - ( arg1 ? , arg2 ? ) => 14 ; - ( arg1 : number , arg2 : number ) => 15 ; - ( arg1 : number = 0 , arg2 : number = 1 ) => 16 ; - ( arg1 ? : number , arg2 ? : number ) => 17 ; - ( arg1 , ... arg2 : number [ ] ) => 18 ; - ( arg1 , arg2 ? : number ) => 19 ; - -// in paren - ( ( ) => 21 ) ; - ( ( arg ) => 22 ) ; - ( ( arg = 1 ) => 23 ) ; - ( ( arg ? ) => 24 ) ; - ( ( arg : number ) => 25 ) ; - ( ( arg : number = 0 ) => 26 ) ; - ( ( arg ? : number ) => 27 ) ; - ( ( ... arg : number [ ] ) => 28 ) ; - -// in multiple paren - ( ( ( ( ( arg ) => { return 32 ; } ) ) ) ) ; - -// in ternary exression - false ? ( ) => 41 : null ; - false ? ( arg ) => 42 : null ; - false ? ( arg = 1 ) => 43 : null ; - false ? ( arg ? ) => 44 : null ; - false ? ( arg : number ) => 45 : null ; - false ? ( arg ? : number ) => 46 : null ; - false ? ( arg ? : number = 0 ) => 47 : null ; - false ? ( ... arg : number [ ] ) => 48 : null ; - -// in ternary exression within paren - false ? ( ( ) => 51 ) : null ; - false ? ( ( arg ) => 52 ) : null ; - false ? ( ( arg = 1 ) => 53 ) : null ; - false ? ( ( arg ? ) => 54 ) : null ; - false ? ( ( arg : number ) => 55 ) : null ; - false ? ( ( arg ? : number ) => 56 ) : null ; - false ? ( ( arg ? : number = 0 ) => 57 ) : null ; - false ? ( ( ... arg : number [ ] ) => 58 ) : null ; - -// ternary exression's else clause - false ? null : ( ) => 61 ; - false ? null : ( arg ) => 62 ; - false ? null : ( arg = 1 ) => 63 ; - false ? null : ( arg ? ) => 64 ; - false ? null : ( arg : number ) => 65 ; - false ? null : ( arg ? : number ) => 66 ; - false ? null : ( arg ? : number = 0 ) => 67 ; - false ? null : ( ... arg : number [ ] ) => 68 ; - - -// nested ternary expressions - ( a ? ) => { return a ; } ? ( b ? ) => { return b ; } : ( c ? ) => { return c ; } ; - -//multiple levels - ( a ? ) => { return a ; } ? ( b ) => ( c ) => 81 : ( c ) => ( d ) => 82 ; - - -// In Expressions - ( ( arg ) => 90 ) instanceof Function ; - ( ( arg = 1 ) => 91 ) instanceof Function ; - ( ( arg ? ) => 92 ) instanceof Function ; - ( ( arg : number ) => 93 ) instanceof Function ; - ( ( arg : number = 1 ) => 94 ) instanceof Function ; - ( ( arg ? : number ) => 95 ) instanceof Function ; - ( ( ... arg : number [ ] ) => 96 ) instanceof Function ; - -'' + ( arg ) => 100 ; - ( ( arg ) => 0 ) + '' + ( arg ) => 101 ; - ( ( arg = 1 ) => 0 ) + '' + ( arg = 2 ) => 102 ; - ( ( arg ? ) => 0 ) + '' + ( arg ? ) => 103 ; - ( ( arg : number ) => 0 ) + '' + ( arg : number ) => 104 ; - ( ( arg : number = 1 ) => 0 ) + '' + ( arg : number = 2 ) => 105 ; - ( ( arg ? : number = 1 ) => 0 ) + '' + ( arg ? : number = 2 ) => 106 ; - ( ( ... arg : number [ ] ) => 0 ) + '' + ( ... arg : number [ ] ) => 107 ; - ( ( arg1 , arg2 ? ) => 0 ) + '' + ( arg1 , arg2 ? ) => 108 ; - ( ( arg1 , ... arg2 : number [ ] ) => 0 ) + '' + ( arg1 , ... arg2 : number [ ] ) => 108 ; - - -// Function Parameters -function foo ( ... arg : any [ ] ) { } - -foo ( - ( a ) => 110 , - ( ( a ) => 111 ) , - ( a ) => { - return 112 ; - } , - ( a ? ) => 113 , - ( a , b ? ) => 114 , - ( a : number ) => 115 , - ( a : number = 0 ) => 116 , - ( a = 0 ) => 117 , - ( a ? : number = 0 ) => 118 , - ( a ? , b ? : number = 0 ) => 118 , - ( ... a : number [ ] ) => 119 , - ( a , b ? = 0 , ... c : number [ ] ) => 120 , - ( a ) => ( b ) => ( c ) => 121 , - false ? ( a ) => 0 : ( b ) => 122 - ) ; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/fatArrowFunctionsBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/fatArrowFunctionsBaseline.ts deleted file mode 100644 index 7a1ef86f5af..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/fatArrowFunctionsBaseline.ts +++ /dev/null @@ -1,112 +0,0 @@ -// valid -() => 1; -(arg) => 2; -arg => 2; -(arg = 1) => 3; -(arg?) => 4; -(arg: number) => 5; -(arg: number = 0) => 6; -(arg?: number) => 7; -(...arg: number[]) => 8; -(arg1, arg2) => 12; -(arg1 = 1, arg2 = 3) => 13; -(arg1?, arg2?) => 14; -(arg1: number, arg2: number) => 15; -(arg1: number = 0, arg2: number = 1) => 16; -(arg1?: number, arg2?: number) => 17; -(arg1, ...arg2: number[]) => 18; -(arg1, arg2?: number) => 19; - -// in paren -(() => 21); -((arg) => 22); -((arg = 1) => 23); -((arg?) => 24); -((arg: number) => 25); -((arg: number = 0) => 26); -((arg?: number) => 27); -((...arg: number[]) => 28); - -// in multiple paren -(((((arg) => { return 32; })))); - -// in ternary exression -false ? () => 41 : null; -false ? (arg) => 42 : null; -false ? (arg = 1) => 43 : null; -false ? (arg?) => 44 : null; -false ? (arg: number) => 45 : null; -false ? (arg?: number) => 46 : null; -false ? (arg?: number = 0) => 47 : null; -false ? (...arg: number[]) => 48 : null; - -// in ternary exression within paren -false ? (() => 51) : null; -false ? ((arg) => 52) : null; -false ? ((arg = 1) => 53) : null; -false ? ((arg?) => 54) : null; -false ? ((arg: number) => 55) : null; -false ? ((arg?: number) => 56) : null; -false ? ((arg?: number = 0) => 57) : null; -false ? ((...arg: number[]) => 58) : null; - -// ternary exression's else clause -false ? null : () => 61; -false ? null : (arg) => 62; -false ? null : (arg = 1) => 63; -false ? null : (arg?) => 64; -false ? null : (arg: number) => 65; -false ? null : (arg?: number) => 66; -false ? null : (arg?: number = 0) => 67; -false ? null : (...arg: number[]) => 68; - - -// nested ternary expressions -(a?) => { return a; } ? (b?) => { return b; } : (c?) => { return c; }; - -//multiple levels -(a?) => { return a; } ? (b) => (c) => 81 : (c) => (d) => 82; - - -// In Expressions -((arg) => 90) instanceof Function; -((arg = 1) => 91) instanceof Function; -((arg?) => 92) instanceof Function; -((arg: number) => 93) instanceof Function; -((arg: number = 1) => 94) instanceof Function; -((arg?: number) => 95) instanceof Function; -((...arg: number[]) => 96) instanceof Function; - -'' + (arg) => 100; -((arg) => 0) + '' + (arg) => 101; -((arg = 1) => 0) + '' + (arg = 2) => 102; -((arg?) => 0) + '' + (arg?) => 103; -((arg: number) => 0) + '' + (arg: number) => 104; -((arg: number = 1) => 0) + '' + (arg: number = 2) => 105; -((arg?: number = 1) => 0) + '' + (arg?: number = 2) => 106; -((...arg: number[]) => 0) + '' + (...arg: number[]) => 107; -((arg1, arg2?) => 0) + '' + (arg1, arg2?) => 108; -((arg1, ...arg2: number[]) => 0) + '' + (arg1, ...arg2: number[]) => 108; - - -// Function Parameters -function foo(...arg: any[]) { } - -foo( - (a) => 110, - ((a) => 111), - (a) => { - return 112; - }, - (a?) => 113, - (a, b?) => 114, - (a: number) => 115, - (a: number = 0) => 116, - (a = 0) => 117, - (a?: number = 0) => 118, - (a?, b?: number = 0) => 118, - (...a: number[]) => 119, - (a, b? = 0, ...c: number[]) => 120, - (a) => (b) => (c) => 121, - false ? (a) => 0 : (b) => 122 - ); \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatDebuggerStatement.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatDebuggerStatement.ts deleted file mode 100644 index 314cd416a81..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatDebuggerStatement.ts +++ /dev/null @@ -1,2 +0,0 @@ -if(false){debugger;} - if ( false ) { debugger ; } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatDebuggerStatementBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatDebuggerStatementBaseline.ts deleted file mode 100644 index c03acf91ecf..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatDebuggerStatementBaseline.ts +++ /dev/null @@ -1,2 +0,0 @@ -if (false) { debugger; } -if (false) { debugger; } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatvariableDeclarationList.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatvariableDeclarationList.ts deleted file mode 100644 index 956309d2c4d..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatvariableDeclarationList.ts +++ /dev/null @@ -1,13 +0,0 @@ -var fun1 = function ( ) { - var x = 'foo' , - z = 'bar' ; - return x ; -}, - -fun2 = ( function ( f ) { - var fun = function ( ) { - console . log ( f ( ) ) ; - }, - x = 'Foo' ; - return fun ; -} ( fun1 ) ) ; diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatvariableDeclarationListBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatvariableDeclarationListBaseline.ts deleted file mode 100644 index f1d32283fd7..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/formatvariableDeclarationListBaseline.ts +++ /dev/null @@ -1,13 +0,0 @@ -var fun1 = function() { - var x = 'foo', - z = 'bar'; - return x; -}, - -fun2 = (function(f) { - var fun = function() { - console.log(f()); - }, - x = 'Foo'; - return fun; -} (fun1)); diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/implicitModule.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/implicitModule.ts deleted file mode 100644 index 352a252593b..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/implicitModule.ts +++ /dev/null @@ -1,3 +0,0 @@ - export class A { - - } diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/implicitModuleBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/implicitModuleBaseline.ts deleted file mode 100644 index df93540466f..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/implicitModuleBaseline.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class A { - -} diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/importDeclaration.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/importDeclaration.ts deleted file mode 100644 index afd010fe8b7..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/importDeclaration.ts +++ /dev/null @@ -1,6 +0,0 @@ -module Foo { -} - -import bar = Foo; - -import bar2=Foo; diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/importDeclarationBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/importDeclarationBaseline.ts deleted file mode 100644 index d0a4e190d95..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/importDeclarationBaseline.ts +++ /dev/null @@ -1,6 +0,0 @@ -module Foo { -} - -import bar = Foo; - -import bar2 = Foo; diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/main.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/main.ts deleted file mode 100644 index 7640013af8b..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/main.ts +++ /dev/null @@ -1,95 +0,0 @@ - -var a;var c , b;var $d -var $e -var f -a++;b++; - -function f ( ) { - for (i = 0; i < 10; i++) { - k = abc + 123 ^ d; - a = XYZ[m (a[b[c][d]])]; - break; - - switch ( variable){ - case 1: abc += 425; -break; -case 404 : a [x--/2]%=3 ; - break ; - case vari : v[--x ] *=++y*( m + n / k[z]); - for (a in b){ - for (a = 0; a < 10; ++a) { - a++;--a; - if (a == b) { - a++;b--; - } -else -if (a == c){ -++a; -(--c)+=d; -$c = $a + --$b; -} -if (a == b) -if (a != b) { - if (a !== b) - if (a === b) - --a; - else - --a; - else { - a--;++b; -a++ - } - } - } - for (x in y) { -m-=m; -k=1+2+3+4; -} -} - break; - - } - } - var a ={b:function(){}}; - return {a:1,b:2} -} - -var z = 1; - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) -for (k = 0; k < 10; ++k) { -z++; -} - -for (k = 0; k < 10; k += 2) { -z++; -} - - $(document).ready (); - - - function pageLoad() { - $('#TextBox1' ) . unbind ( ) ; -$('#TextBox1' ) . datepicker ( ) ; -} - - function pageLoad ( ) { - var webclass=[ - { 'student' : - { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' } - } , -{ 'student': -{'id':'2','name':'Adam Davidson','legacySkill':'Cobol,MainFrame'} -} , - { 'student': -{ 'id':'3','name':'Charles Boyer' ,'legacySkill':'HTML, XML'} -} - ]; - -$create(Sys.UI.DataView,{data:webclass},null,null,$get('SList')); - -} - -$( document ).ready(function(){ -alert('hello'); - } ) ; diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/mainBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/mainBaseline.ts deleted file mode 100644 index 30756f547ca..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/mainBaseline.ts +++ /dev/null @@ -1,98 +0,0 @@ - -var a; var c, b; var $d -var $e -var f -a++; b++; - -function f() { - for (i = 0; i < 10; i++) { - k = abc + 123 ^ d; - a = XYZ[m(a[b[c][d]])]; - break; - - switch (variable) { - case 1: abc += 425; - break; - case 404: a[x-- / 2] %= 3; - break; - case vari: v[--x] *= ++y * (m + n / k[z]); - for (a in b) { - for (a = 0; a < 10; ++a) { - a++; --a; - if (a == b) { - a++; b--; - } - else - if (a == c) { - ++a; - (--c) += d; - $c = $a + --$b; - } - if (a == b) - if (a != b) { - if (a !== b) - if (a === b) - --a; - else - --a; - else { - a--; ++b; - a++ - } - } - } - for (x in y) { - m -= m; - k = 1 + 2 + 3 + 4; - } - } - break; - - } - } - var a = { b: function() { } }; - return { a: 1, b: 2 } -} - -var z = 1; -for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - for (k = 0; k < 10; ++k) { - z++; - } - -for (k = 0; k < 10; k += 2) { - z++; -} - -$(document).ready(); - - -function pageLoad() { - $('#TextBox1').unbind(); - $('#TextBox1').datepicker(); -} - -function pageLoad() { - var webclass = [ - { - 'student': - { 'id': '1', 'name': 'Linda Jones', 'legacySkill': 'Access, VB 5.0' } - }, -{ - 'student': - { 'id': '2', 'name': 'Adam Davidson', 'legacySkill': 'Cobol,MainFrame' } -}, - { - 'student': - { 'id': '3', 'name': 'Charles Boyer', 'legacySkill': 'HTML, XML' } - } - ]; - - $create(Sys.UI.DataView, { data: webclass }, null, null, $get('SList')); - -} - -$(document).ready(function() { - alert('hello'); -}); diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/moduleIndentation.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/moduleIndentation.ts deleted file mode 100644 index 3030a36630a..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/moduleIndentation.ts +++ /dev/null @@ -1,3 +0,0 @@ - module Foo { - export module A . B . C { } - } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/moduleIndentationBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/moduleIndentationBaseline.ts deleted file mode 100644 index 0013b367dcf..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/moduleIndentationBaseline.ts +++ /dev/null @@ -1,3 +0,0 @@ -module Foo { - export module A.B.C { } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/modules.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/modules.ts deleted file mode 100644 index 5ce0d19b632..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/modules.ts +++ /dev/null @@ -1,76 +0,0 @@ - module mod1 { - export class b { - } - class d { - } - - - export interface ib { - } -} - - module m2 { - - export module m3 { - export class c extends mod1.b { - } - export class ib2 implements mod1.ib { - } - } -} - - class c extends mod1.b { -} - - class ib2 implements mod1.ib { -} - - declare export module "m4" { - export class d { - } ; - var x : d ; - export function foo ( ) : d ; -} - - import m4 = module ( "m4" ) ; - export var x4 = m4.x ; - export var d4 = m4.d ; - export var f4 = m4.foo ( ) ; - - export module m1 { - declare export module "m2" { - export class d { - } ; - var x: d ; - export function foo ( ) : d ; - } - import m2 = module ( "m2" ) ; - import m3 = module ( "m4" ) ; - - export var x2 = m2.x ; - export var d2 = m2.d ; - export var f2 = m2.foo ( ) ; - - export var x3 = m3.x ; - export var d3 = m3.d ; - export var f3 = m3.foo ( ) ; -} - - export var x2 = m1.m2.x ; - export var d2 = m1.m2.d ; - export var f2 = m1.m2.foo ( ) ; - - export var x3 = m1.m3.x ; - export var d3 = m1.m3.d ; - export var f3 = m1.m3.foo ( ) ; - - export module m5 { - export var x2 = m1.m2.x ; - export var d2 = m1.m2.d ; - export var f2 = m1.m2.foo ( ) ; - - export var x3 = m1.m3.x ; - export var d3 = m1.m3.d ; - export var f3 = m1.m3.foo ( ) ; -} - diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/modulesBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/modulesBaseline.ts deleted file mode 100644 index e6f62024fe6..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/modulesBaseline.ts +++ /dev/null @@ -1,76 +0,0 @@ -module mod1 { - export class b { - } - class d { - } - - - export interface ib { - } -} - -module m2 { - - export module m3 { - export class c extends mod1.b { - } - export class ib2 implements mod1.ib { - } - } -} - -class c extends mod1.b { -} - -class ib2 implements mod1.ib { -} - -declare export module "m4" { - export class d { - }; - var x: d; - export function foo(): d; -} - -import m4 = module("m4"); -export var x4 = m4.x; -export var d4 = m4.d; -export var f4 = m4.foo(); - -export module m1 { - declare export module "m2" { - export class d { - }; - var x: d; - export function foo(): d; - } - import m2 = module("m2"); - import m3 = module("m4"); - - export var x2 = m2.x; - export var d2 = m2.d; - export var f2 = m2.foo(); - - export var x3 = m3.x; - export var d3 = m3.d; - export var f3 = m3.foo(); -} - -export var x2 = m1.m2.x; -export var d2 = m1.m2.d; -export var f2 = m1.m2.foo(); - -export var x3 = m1.m3.x; -export var d3 = m1.m3.d; -export var f3 = m1.m3.foo(); - -export module m5 { - export var x2 = m1.m2.x; - export var d2 = m1.m2.d; - export var f2 = m1.m2.foo(); - - export var x3 = m1.m3.x; - export var d3 = m1.m3.d; - export var f3 = m1.m3.foo(); -} - diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/objectLiteral.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/objectLiteral.ts deleted file mode 100644 index dbecc4d4fec..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/objectLiteral.ts +++ /dev/null @@ -1,27 +0,0 @@ -var x = {foo: 1, -bar: "tt", -boo: 1 + 5}; - -var x2 = {foo: 1, -bar: "tt",boo:1+5}; - -function Foo() { -var typeICalc = { -clear: { -"()": [1, 2, 3] -} -} -} - -// Rule for object literal members for the "value" of the memebr to follow the indent -// of the member, i.e. the relative position of the value is maintained when the member -// is indented. -var x2 = { - foo: -3, - 'bar': - { a: 1, b : 2} -}; - -var x={ }; -var y = {}; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/objectLiteralBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/objectLiteralBaseline.ts deleted file mode 100644 index 3a7fa63d927..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/objectLiteralBaseline.ts +++ /dev/null @@ -1,31 +0,0 @@ -var x = { - foo: 1, - bar: "tt", - boo: 1 + 5 -}; - -var x2 = { - foo: 1, - bar: "tt", boo: 1 + 5 -}; - -function Foo() { - var typeICalc = { - clear: { - "()": [1, 2, 3] - } - } -} - -// Rule for object literal members for the "value" of the memebr to follow the indent -// of the member, i.e. the relative position of the value is maintained when the member -// is indented. -var x2 = { - foo: - 3, - 'bar': - { a: 1, b: 2 } -}; - -var x = {}; -var y = {}; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/onClosingBracket.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/onClosingBracket.ts deleted file mode 100644 index 0161f04308d..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/onClosingBracket.ts +++ /dev/null @@ -1,32 +0,0 @@ -function f( ) { -var x = 3; - var z = 2 ; - a = z ++ - 2 * x ; - for ( ; ; ) { - a+=(g +g)*a%t; - b -- ; -} - - switch ( a ) - { - case 1 : { - a ++ ; - b--; - if(a===a) - return; - else - { - for(a in b) - if(a!=a) - { - for(a in b) - { -a++; - } - } - } - } - default: - break; - } -} diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/onClosingBracketBaseLine.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/onClosingBracketBaseLine.ts deleted file mode 100644 index 051a4ebd13a..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/onClosingBracketBaseLine.ts +++ /dev/null @@ -1,28 +0,0 @@ -function f() { - var x = 3; - var z = 2; - a = z++ - 2 * x; - for (; ;) { - a += (g + g) * a % t; - b--; - } - - switch (a) { - case 1: { - a++; - b--; - if (a === a) - return; - else { - for (a in b) - if (a != a) { - for (a in b) { - a++; - } - } - } - } - default: - break; - } -} diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/onSemiColon.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/onSemiColon.ts deleted file mode 100644 index 3b5b5456a6f..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/onSemiColon.ts +++ /dev/null @@ -1 +0,0 @@ -var a=b+c^d-e*++f; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/onSemiColonBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/onSemiColonBaseline.ts deleted file mode 100644 index 2ba96e4f88a..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/onSemiColonBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -var a = b + c ^ d - e * ++f; \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/spaceAfterConstructor.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/spaceAfterConstructor.ts deleted file mode 100644 index 7d98d5a8f43..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/spaceAfterConstructor.ts +++ /dev/null @@ -1 +0,0 @@ -class test { constructor () { } } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/spaceAfterConstructorBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/spaceAfterConstructorBaseline.ts deleted file mode 100644 index bc124d41baf..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/spaceAfterConstructorBaseline.ts +++ /dev/null @@ -1 +0,0 @@ -class test { constructor() { } } \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/tabAfterCloseCurly.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/tabAfterCloseCurly.ts deleted file mode 100644 index ec093e0e376..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/tabAfterCloseCurly.ts +++ /dev/null @@ -1,10 +0,0 @@ -module Tools { - export enum NodeType { - Error, - Comment, - } - export enum foob - { - Blah=1, Bleah=2 - } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/tabAfterCloseCurlyBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/tabAfterCloseCurlyBaseline.ts deleted file mode 100644 index d0a3db2d51a..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/tabAfterCloseCurlyBaseline.ts +++ /dev/null @@ -1,9 +0,0 @@ -module Tools { - export enum NodeType { - Error, - Comment, - } - export enum foob { - Blah = 1, Bleah = 2 - } -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/typescriptConstructs.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/typescriptConstructs.ts deleted file mode 100644 index 43ef3710ef1..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/typescriptConstructs.ts +++ /dev/null @@ -1,65 +0,0 @@ - module MyModule - { - module A.B.C { -module F { -} - } -interface Blah -{ -boo: string; -} - - class Foo - { - -} - -class Foo2 { -public foo():number { -return 5 * 6; -} -public foo2() { -if (1 === 2) - - -{ -var y : number= 76; -return y; -} - - while (2 == 3) { - if ( y == null ) { - -} - } -} - -public foo3() { -if (1 === 2) - -//comment preventing line merging -{ -var y = 76; -return y; -} - -} - } - } - -function foo(a:number, b:number):number -{ -return 0; -} - -function bar(a:number, b:number) :number[] { -return []; -} - -module BugFix3 { -declare var f: { - (): any; - (x: number): string; - foo: number; -}; -} diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/typescriptConstructsBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/typescriptConstructsBaseline.ts deleted file mode 100644 index 929334e4730..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/typescriptConstructsBaseline.ts +++ /dev/null @@ -1,58 +0,0 @@ -module MyModule { - module A.B.C { - module F { - } - } - interface Blah { - boo: string; - } - - class Foo { - - } - - class Foo2 { - public foo(): number { - return 5 * 6; - } - public foo2() { - if (1 === 2) { - var y: number = 76; - return y; - } - - while (2 == 3) { - if (y == null) { - - } - } - } - - public foo3() { - if (1 === 2) - - //comment preventing line merging - { - var y = 76; - return y; - } - - } - } -} - -function foo(a: number, b: number): number { - return 0; -} - -function bar(a: number, b: number): number[] { - return []; -} - -module BugFix3 { - declare var f: { - (): any; - (x: number): string; - foo: number; - }; -} diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/various.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/various.ts deleted file mode 100644 index bd814c2348e..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/various.ts +++ /dev/null @@ -1,17 +0,0 @@ -function f(a,b,c,d){ -for(var i=0;i<10;i++){ -var a=0; -var b=a+a+a*a%a/2-1; -b+=a; -++b; -f(a,b,c,d); -if(1===1){ -var m=function(e,f){ -return e^f; -} -} -} -} - -for (var i = 0 ; i < this.foo(); i++) { -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/variousBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/variousBaseline.ts deleted file mode 100644 index a4b5ceeb1c2..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/variousBaseline.ts +++ /dev/null @@ -1,17 +0,0 @@ -function f(a, b, c, d) { - for (var i = 0; i < 10; i++) { - var a = 0; - var b = a + a + a * a % a / 2 - 1; - b += a; - ++b; - f(a, b, c, d); - if (1 === 1) { - var m = function(e, f) { - return e ^ f; - } - } - } -} - -for (var i = 0 ; i < this.foo(); i++) { -} \ No newline at end of file diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/withStatement.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/withStatement.ts deleted file mode 100644 index 66ec4bf546f..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/withStatement.ts +++ /dev/null @@ -1,9 +0,0 @@ -with (foo.bar) - - { - - } - -with (bar.blah) -{ -} diff --git a/src/harness/unittests/services/formatting/testCode/testCode/formatting/withStatementBaseline.ts b/src/harness/unittests/services/formatting/testCode/testCode/formatting/withStatementBaseline.ts deleted file mode 100644 index f81378d7f82..00000000000 --- a/src/harness/unittests/services/formatting/testCode/testCode/formatting/withStatementBaseline.ts +++ /dev/null @@ -1,6 +0,0 @@ -with (foo.bar) { - -} - -with (bar.blah) { -} From b96f6cd84ca1f920c2c44b899d49d45b24c71be1 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 1 Sep 2016 06:47:18 -0700 Subject: [PATCH 307/508] Union type instead of best common supertype for multiple return statements --- src/compiler/checker.ts | 16 ++-------------- src/compiler/diagnosticMessages.json | 8 -------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index b59e4eae607..e49ab907d71 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -12477,20 +12477,8 @@ namespace ts { return isAsync ? createPromiseReturnType(func, voidType) : voidType; } } - // When yield/return statements are contextually typed we allow the return type to be a union type. - // Otherwise we require the yield/return expressions to have a best common supertype. - type = contextualSignature ? getUnionType(types, /*subtypeReduction*/ true) : getCommonSupertype(types); - if (!type) { - if (funcIsGenerator) { - error(func, Diagnostics.No_best_common_type_exists_among_yield_expressions); - return createIterableIteratorType(unknownType); - } - else { - error(func, Diagnostics.No_best_common_type_exists_among_return_expressions); - // Defer to unioning the return types so we get a) downstream errors earlier and b) better Salsa experience - return isAsync ? createPromiseReturnType(func, getUnionType(types, /*subtypeReduction*/ true)) : getUnionType(types, /*subtypeReduction*/ true); - } - } + // Return a union of the return expression types. + type = getUnionType(types, /*subtypeReduction*/ true); if (funcIsGenerator) { type = createIterableIteratorType(type); diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index b8978b32571..33cd602e5a7 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -1067,10 +1067,6 @@ "category": "Error", "code": 2353 }, - "No best common type exists among return expressions.": { - "category": "Error", - "code": 2354 - }, "A function whose declared type is neither 'void' nor 'any' must return a value.": { "category": "Error", "code": 2355 @@ -1635,10 +1631,6 @@ "category": "Error", "code": 2503 }, - "No best common type exists among yield expressions.": { - "category": "Error", - "code": 2504 - }, "A generator cannot have a 'void' type annotation.": { "category": "Error", "code": 2505 From b5c2d5b111e16849d724718216f8ea88dc70db0d Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 1 Sep 2016 06:47:29 -0700 Subject: [PATCH 308/508] Accept new baselines --- .../bestCommonTypeReturnStatement.types | 2 +- .../functionImplementationErrors.errors.txt | 32 +--- ...ionWithMultipleReturnStatements.errors.txt | 85 --------- ...nctionWithMultipleReturnStatements.symbols | 103 ++++++++++ ...functionWithMultipleReturnStatements.types | 128 +++++++++++++ ...onWithMultipleReturnStatements2.errors.txt | 101 ---------- ...ctionWithMultipleReturnStatements2.symbols | 142 ++++++++++++++ ...unctionWithMultipleReturnStatements2.types | 176 ++++++++++++++++++ .../functionWithNoBestCommonType1.errors.txt | 14 -- .../functionWithNoBestCommonType1.symbols | 13 ++ .../functionWithNoBestCommonType1.types | 16 ++ .../functionWithNoBestCommonType2.errors.txt | 14 -- .../functionWithNoBestCommonType2.symbols | 14 ++ .../functionWithNoBestCommonType2.types | 18 ++ .../reference/generatorTypeCheck22.errors.txt | 16 -- .../reference/generatorTypeCheck22.symbols | 30 +++ .../reference/generatorTypeCheck22.types | 42 +++++ .../reference/generatorTypeCheck23.errors.txt | 17 -- .../reference/generatorTypeCheck23.symbols | 33 ++++ .../reference/generatorTypeCheck23.types | 47 +++++ .../reference/generatorTypeCheck24.errors.txt | 17 -- .../reference/generatorTypeCheck24.symbols | 33 ++++ .../reference/generatorTypeCheck24.types | 48 +++++ .../reference/generatorTypeCheck52.errors.txt | 12 -- .../reference/generatorTypeCheck52.symbols | 18 ++ .../reference/generatorTypeCheck52.types | 22 +++ .../reference/generatorTypeCheck53.errors.txt | 12 -- .../reference/generatorTypeCheck53.symbols | 18 ++ .../reference/generatorTypeCheck53.types | 23 +++ .../reference/generatorTypeCheck54.errors.txt | 12 -- .../reference/generatorTypeCheck54.symbols | 18 ++ .../reference/generatorTypeCheck54.types | 24 +++ ...edFunctionReturnTypeIsEmptyType.errors.txt | 16 -- ...erredFunctionReturnTypeIsEmptyType.symbols | 13 ++ ...nferredFunctionReturnTypeIsEmptyType.types | 17 ++ .../stringLiteralTypesOverloads02.errors.txt | 57 ------ .../stringLiteralTypesOverloads02.symbols | 140 ++++++++++++++ .../stringLiteralTypesOverloads02.types | 170 +++++++++++++++++ .../typeGuardsInIfStatement.errors.txt | 11 +- 39 files changed, 1309 insertions(+), 415 deletions(-) delete mode 100644 tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt create mode 100644 tests/baselines/reference/functionWithMultipleReturnStatements.symbols create mode 100644 tests/baselines/reference/functionWithMultipleReturnStatements.types delete mode 100644 tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt create mode 100644 tests/baselines/reference/functionWithMultipleReturnStatements2.symbols create mode 100644 tests/baselines/reference/functionWithMultipleReturnStatements2.types delete mode 100644 tests/baselines/reference/functionWithNoBestCommonType1.errors.txt create mode 100644 tests/baselines/reference/functionWithNoBestCommonType1.symbols create mode 100644 tests/baselines/reference/functionWithNoBestCommonType1.types delete mode 100644 tests/baselines/reference/functionWithNoBestCommonType2.errors.txt create mode 100644 tests/baselines/reference/functionWithNoBestCommonType2.symbols create mode 100644 tests/baselines/reference/functionWithNoBestCommonType2.types delete mode 100644 tests/baselines/reference/generatorTypeCheck22.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck22.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck22.types delete mode 100644 tests/baselines/reference/generatorTypeCheck23.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck23.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck23.types delete mode 100644 tests/baselines/reference/generatorTypeCheck24.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck24.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck24.types delete mode 100644 tests/baselines/reference/generatorTypeCheck52.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck52.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck52.types delete mode 100644 tests/baselines/reference/generatorTypeCheck53.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck53.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck53.types delete mode 100644 tests/baselines/reference/generatorTypeCheck54.errors.txt create mode 100644 tests/baselines/reference/generatorTypeCheck54.symbols create mode 100644 tests/baselines/reference/generatorTypeCheck54.types delete mode 100644 tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt create mode 100644 tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.symbols create mode 100644 tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.types delete mode 100644 tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads02.symbols create mode 100644 tests/baselines/reference/stringLiteralTypesOverloads02.types diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.types b/tests/baselines/reference/bestCommonTypeReturnStatement.types index 31f72ab93b4..a8b435c8a27 100644 --- a/tests/baselines/reference/bestCommonTypeReturnStatement.types +++ b/tests/baselines/reference/bestCommonTypeReturnStatement.types @@ -15,7 +15,7 @@ interface IPromise { } function f() { ->f : () => IPromise +>f : () => IPromise if (true) return b(); >true : boolean diff --git a/tests/baselines/reference/functionImplementationErrors.errors.txt b/tests/baselines/reference/functionImplementationErrors.errors.txt index dc5ad5a2747..224ebc7c08e 100644 --- a/tests/baselines/reference/functionImplementationErrors.errors.txt +++ b/tests/baselines/reference/functionImplementationErrors.errors.txt @@ -1,44 +1,26 @@ -tests/cases/conformance/functions/functionImplementationErrors.ts(3,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(7,19): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(11,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(17,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/functions/functionImplementationErrors.ts(26,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/conformance/functions/functionImplementationErrors.ts(31,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. tests/cases/conformance/functions/functionImplementationErrors.ts(36,17): error TS2373: Initializer of parameter 'n' cannot reference identifier 'm' declared after it. -tests/cases/conformance/functions/functionImplementationErrors.ts(50,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(54,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(58,11): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(62,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(66,11): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/functions/functionImplementationErrors.ts(70,11): error TS2354: No best common type exists among return expressions. -==== tests/cases/conformance/functions/functionImplementationErrors.ts (13 errors) ==== +==== tests/cases/conformance/functions/functionImplementationErrors.ts (3 errors) ==== // FunctionExpression with no return type annotation with multiple return statements with unrelated types var f1 = function () { - ~~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. return ''; return 3; }; var f2 = function x() { - ~ -!!! error TS2354: No best common type exists among return expressions. return ''; return 3; }; var f3 = () => { - ~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. return ''; return 3; }; // FunctionExpression with no return type annotation with return branch of number[] and other of string[] var f4 = function () { - ~~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. if (true) { return ['']; } else { @@ -78,38 +60,26 @@ tests/cases/conformance/functions/functionImplementationErrors.ts(70,11): error class Derived1 extends Base { private m; } class Derived2 extends Base { private n; } function f8() { - ~~ -!!! error TS2354: No best common type exists among return expressions. return new Derived1(); return new Derived2(); } var f9 = function () { - ~~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. return new Derived1(); return new Derived2(); }; var f10 = () => { - ~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. return new Derived1(); return new Derived2(); }; function f11() { - ~~~ -!!! error TS2354: No best common type exists among return expressions. return new Base(); return new AnotherClass(); } var f12 = function () { - ~~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. return new Base(); return new AnotherClass(); }; var f13 = () => { - ~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. return new Base(); return new AnotherClass(); }; diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt b/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt deleted file mode 100644 index cc10d4c782c..00000000000 --- a/tests/baselines/reference/functionWithMultipleReturnStatements.errors.txt +++ /dev/null @@ -1,85 +0,0 @@ -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(5,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(13,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(23,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(32,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(44,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts(49,10): error TS2354: No best common type exists among return expressions. - - -==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts (6 errors) ==== - - // return type of a function with multiple returns is the BCT of each return statement - // it is an error if there is no single BCT, these are error cases - - function f1() { - ~~ -!!! error TS2354: No best common type exists among return expressions. - if (true) { - return 1; - } else { - return ''; - } - } - - function f2() { - ~~ -!!! error TS2354: No best common type exists among return expressions. - if (true) { - return 1; - } else if (false) { - return 2; - } else { - return ''; - } - } - - function f3() { - ~~ -!!! error TS2354: No best common type exists among return expressions. - try { - return 1; - } - catch (e) { - return ''; - } - } - - function f4() { - ~~ -!!! error TS2354: No best common type exists among return expressions. - try { - return 1; - } - catch (e) { - - } - finally { - return ''; - } - } - - function f5() { - ~~ -!!! error TS2354: No best common type exists among return expressions. - return 1; - return ''; - } - - function f6(x: T, y:U) { - ~~ -!!! error TS2354: No best common type exists among return expressions. - if (true) { - return x; - } else { - return y; - } - } - - function f8(x: T, y: U) { - if (true) { - return x; - } else { - return y; - } - } - \ No newline at end of file diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements.symbols b/tests/baselines/reference/functionWithMultipleReturnStatements.symbols new file mode 100644 index 00000000000..a33db459640 --- /dev/null +++ b/tests/baselines/reference/functionWithMultipleReturnStatements.symbols @@ -0,0 +1,103 @@ +=== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts === + +// return type of a function with multiple returns is the BCT of each return statement +// it is an error if there is no single BCT, these are error cases + +function f1() { +>f1 : Symbol(f1, Decl(functionWithMultipleReturnStatements.ts, 0, 0)) + + if (true) { + return 1; + } else { + return ''; + } +} + +function f2() { +>f2 : Symbol(f2, Decl(functionWithMultipleReturnStatements.ts, 10, 1)) + + if (true) { + return 1; + } else if (false) { + return 2; + } else { + return ''; + } +} + +function f3() { +>f3 : Symbol(f3, Decl(functionWithMultipleReturnStatements.ts, 20, 1)) + + try { + return 1; + } + catch (e) { +>e : Symbol(e, Decl(functionWithMultipleReturnStatements.ts, 26, 11)) + + return ''; + } +} + +function f4() { +>f4 : Symbol(f4, Decl(functionWithMultipleReturnStatements.ts, 29, 1)) + + try { + return 1; + } + catch (e) { +>e : Symbol(e, Decl(functionWithMultipleReturnStatements.ts, 35, 11)) + + } + finally { + return ''; + } +} + +function f5() { +>f5 : Symbol(f5, Decl(functionWithMultipleReturnStatements.ts, 41, 1)) + + return 1; + return ''; +} + +function f6(x: T, y:U) { +>f6 : Symbol(f6, Decl(functionWithMultipleReturnStatements.ts, 46, 1)) +>T : Symbol(T, Decl(functionWithMultipleReturnStatements.ts, 48, 12)) +>U : Symbol(U, Decl(functionWithMultipleReturnStatements.ts, 48, 14)) +>x : Symbol(x, Decl(functionWithMultipleReturnStatements.ts, 48, 18)) +>T : Symbol(T, Decl(functionWithMultipleReturnStatements.ts, 48, 12)) +>y : Symbol(y, Decl(functionWithMultipleReturnStatements.ts, 48, 23)) +>U : Symbol(U, Decl(functionWithMultipleReturnStatements.ts, 48, 14)) + + if (true) { + return x; +>x : Symbol(x, Decl(functionWithMultipleReturnStatements.ts, 48, 18)) + + } else { + return y; +>y : Symbol(y, Decl(functionWithMultipleReturnStatements.ts, 48, 23)) + } +} + +function f8(x: T, y: U) { +>f8 : Symbol(f8, Decl(functionWithMultipleReturnStatements.ts, 54, 1)) +>T : Symbol(T, Decl(functionWithMultipleReturnStatements.ts, 56, 12)) +>U : Symbol(U, Decl(functionWithMultipleReturnStatements.ts, 56, 24)) +>U : Symbol(U, Decl(functionWithMultipleReturnStatements.ts, 56, 24)) +>V : Symbol(V, Decl(functionWithMultipleReturnStatements.ts, 56, 37)) +>V : Symbol(V, Decl(functionWithMultipleReturnStatements.ts, 56, 37)) +>x : Symbol(x, Decl(functionWithMultipleReturnStatements.ts, 56, 41)) +>T : Symbol(T, Decl(functionWithMultipleReturnStatements.ts, 56, 12)) +>y : Symbol(y, Decl(functionWithMultipleReturnStatements.ts, 56, 46)) +>U : Symbol(U, Decl(functionWithMultipleReturnStatements.ts, 56, 24)) + + if (true) { + return x; +>x : Symbol(x, Decl(functionWithMultipleReturnStatements.ts, 56, 41)) + + } else { + return y; +>y : Symbol(y, Decl(functionWithMultipleReturnStatements.ts, 56, 46)) + } +} + diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements.types b/tests/baselines/reference/functionWithMultipleReturnStatements.types new file mode 100644 index 00000000000..63cbe235c38 --- /dev/null +++ b/tests/baselines/reference/functionWithMultipleReturnStatements.types @@ -0,0 +1,128 @@ +=== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements.ts === + +// return type of a function with multiple returns is the BCT of each return statement +// it is an error if there is no single BCT, these are error cases + +function f1() { +>f1 : () => string | number + + if (true) { +>true : boolean + + return 1; +>1 : number + + } else { + return ''; +>'' : string + } +} + +function f2() { +>f2 : () => string | number + + if (true) { +>true : boolean + + return 1; +>1 : number + + } else if (false) { +>false : boolean + + return 2; +>2 : number + + } else { + return ''; +>'' : string + } +} + +function f3() { +>f3 : () => string | number + + try { + return 1; +>1 : number + } + catch (e) { +>e : any + + return ''; +>'' : string + } +} + +function f4() { +>f4 : () => string | number + + try { + return 1; +>1 : number + } + catch (e) { +>e : any + + } + finally { + return ''; +>'' : string + } +} + +function f5() { +>f5 : () => string | number + + return 1; +>1 : number + + return ''; +>'' : string +} + +function f6(x: T, y:U) { +>f6 : (x: T, y: U) => T | U +>T : T +>U : U +>x : T +>T : T +>y : U +>U : U + + if (true) { +>true : boolean + + return x; +>x : T + + } else { + return y; +>y : U + } +} + +function f8(x: T, y: U) { +>f8 : (x: T, y: U) => U +>T : T +>U : U +>U : U +>V : V +>V : V +>x : T +>T : T +>y : U +>U : U + + if (true) { +>true : boolean + + return x; +>x : T + + } else { + return y; +>y : U + } +} + diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt b/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt deleted file mode 100644 index 0399c7a79a6..00000000000 --- a/tests/baselines/reference/functionWithMultipleReturnStatements2.errors.txt +++ /dev/null @@ -1,101 +0,0 @@ -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(59,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts(68,10): error TS2354: No best common type exists among return expressions. - - -==== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts (2 errors) ==== - - // return type of a function with multiple returns is the BCT of each return statement - // no errors expected here - - function f1() { - if (true) { - return 1; - } else { - return null; - } - } - - function f2() { - if (true) { - return 1; - } else if (false) { - return null; - } else { - return 2; - } - } - - function f4() { - try { - return 1; - } - catch (e) { - return undefined; - } - finally { - return 1; - } - } - - function f5() { - return 1; - return new Object(); - } - - function f6(x: T) { - if (true) { - return x; - } else { - return null; - } - } - - //function f7(x: T, y: U) { - // if (true) { - // return x; - // } else { - // return y; - // } - //} - - var a: { x: number; y?: number }; - var b: { x: number; z?: number }; - // returns typeof a - function f9() { - ~~ -!!! error TS2354: No best common type exists among return expressions. - if (true) { - return a; - } else { - return b; - } - } - - // returns typeof b - function f10() { - ~~~ -!!! error TS2354: No best common type exists among return expressions. - if (true) { - return b; - } else { - return a; - } - } - - // returns number => void - function f11() { - if (true) { - return (x: number) => { } - } else { - return (x: Object) => { } - } - } - - // returns Object => void - function f12() { - if (true) { - return (x: Object) => { } - } else { - return (x: number) => { } - } - } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.symbols b/tests/baselines/reference/functionWithMultipleReturnStatements2.symbols new file mode 100644 index 00000000000..39cad6bc414 --- /dev/null +++ b/tests/baselines/reference/functionWithMultipleReturnStatements2.symbols @@ -0,0 +1,142 @@ +=== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts === + +// return type of a function with multiple returns is the BCT of each return statement +// no errors expected here + +function f1() { +>f1 : Symbol(f1, Decl(functionWithMultipleReturnStatements2.ts, 0, 0)) + + if (true) { + return 1; + } else { + return null; + } +} + +function f2() { +>f2 : Symbol(f2, Decl(functionWithMultipleReturnStatements2.ts, 10, 1)) + + if (true) { + return 1; + } else if (false) { + return null; + } else { + return 2; + } +} + +function f4() { +>f4 : Symbol(f4, Decl(functionWithMultipleReturnStatements2.ts, 20, 1)) + + try { + return 1; + } + catch (e) { +>e : Symbol(e, Decl(functionWithMultipleReturnStatements2.ts, 26, 11)) + + return undefined; +>undefined : Symbol(undefined) + } + finally { + return 1; + } +} + +function f5() { +>f5 : Symbol(f5, Decl(functionWithMultipleReturnStatements2.ts, 32, 1)) + + return 1; + return new Object(); +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +} + +function f6(x: T) { +>f6 : Symbol(f6, Decl(functionWithMultipleReturnStatements2.ts, 37, 1)) +>T : Symbol(T, Decl(functionWithMultipleReturnStatements2.ts, 39, 12)) +>x : Symbol(x, Decl(functionWithMultipleReturnStatements2.ts, 39, 15)) +>T : Symbol(T, Decl(functionWithMultipleReturnStatements2.ts, 39, 12)) + + if (true) { + return x; +>x : Symbol(x, Decl(functionWithMultipleReturnStatements2.ts, 39, 15)) + + } else { + return null; + } +} + +//function f7(x: T, y: U) { +// if (true) { +// return x; +// } else { +// return y; +// } +//} + +var a: { x: number; y?: number }; +>a : Symbol(a, Decl(functionWithMultipleReturnStatements2.ts, 55, 3)) +>x : Symbol(x, Decl(functionWithMultipleReturnStatements2.ts, 55, 8)) +>y : Symbol(y, Decl(functionWithMultipleReturnStatements2.ts, 55, 19)) + +var b: { x: number; z?: number }; +>b : Symbol(b, Decl(functionWithMultipleReturnStatements2.ts, 56, 3)) +>x : Symbol(x, Decl(functionWithMultipleReturnStatements2.ts, 56, 8)) +>z : Symbol(z, Decl(functionWithMultipleReturnStatements2.ts, 56, 19)) + +// returns typeof a +function f9() { +>f9 : Symbol(f9, Decl(functionWithMultipleReturnStatements2.ts, 56, 33)) + + if (true) { + return a; +>a : Symbol(a, Decl(functionWithMultipleReturnStatements2.ts, 55, 3)) + + } else { + return b; +>b : Symbol(b, Decl(functionWithMultipleReturnStatements2.ts, 56, 3)) + } +} + +// returns typeof b +function f10() { +>f10 : Symbol(f10, Decl(functionWithMultipleReturnStatements2.ts, 64, 1)) + + if (true) { + return b; +>b : Symbol(b, Decl(functionWithMultipleReturnStatements2.ts, 56, 3)) + + } else { + return a; +>a : Symbol(a, Decl(functionWithMultipleReturnStatements2.ts, 55, 3)) + } +} + +// returns number => void +function f11() { +>f11 : Symbol(f11, Decl(functionWithMultipleReturnStatements2.ts, 73, 1)) + + if (true) { + return (x: number) => { } +>x : Symbol(x, Decl(functionWithMultipleReturnStatements2.ts, 78, 16)) + + } else { + return (x: Object) => { } +>x : Symbol(x, Decl(functionWithMultipleReturnStatements2.ts, 80, 16)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + } +} + +// returns Object => void +function f12() { +>f12 : Symbol(f12, Decl(functionWithMultipleReturnStatements2.ts, 82, 1)) + + if (true) { + return (x: Object) => { } +>x : Symbol(x, Decl(functionWithMultipleReturnStatements2.ts, 87, 16)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) + + } else { + return (x: number) => { } +>x : Symbol(x, Decl(functionWithMultipleReturnStatements2.ts, 89, 16)) + } +} diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.types b/tests/baselines/reference/functionWithMultipleReturnStatements2.types new file mode 100644 index 00000000000..7700329971a --- /dev/null +++ b/tests/baselines/reference/functionWithMultipleReturnStatements2.types @@ -0,0 +1,176 @@ +=== tests/cases/conformance/types/typeRelationships/bestCommonType/functionWithMultipleReturnStatements2.ts === + +// return type of a function with multiple returns is the BCT of each return statement +// no errors expected here + +function f1() { +>f1 : () => number + + if (true) { +>true : boolean + + return 1; +>1 : number + + } else { + return null; +>null : null + } +} + +function f2() { +>f2 : () => number + + if (true) { +>true : boolean + + return 1; +>1 : number + + } else if (false) { +>false : boolean + + return null; +>null : null + + } else { + return 2; +>2 : number + } +} + +function f4() { +>f4 : () => number + + try { + return 1; +>1 : number + } + catch (e) { +>e : any + + return undefined; +>undefined : undefined + } + finally { + return 1; +>1 : number + } +} + +function f5() { +>f5 : () => Object + + return 1; +>1 : number + + return new Object(); +>new Object() : Object +>Object : ObjectConstructor +} + +function f6(x: T) { +>f6 : (x: T) => T +>T : T +>x : T +>T : T + + if (true) { +>true : boolean + + return x; +>x : T + + } else { + return null; +>null : null + } +} + +//function f7(x: T, y: U) { +// if (true) { +// return x; +// } else { +// return y; +// } +//} + +var a: { x: number; y?: number }; +>a : { x: number; y?: number; } +>x : number +>y : number + +var b: { x: number; z?: number }; +>b : { x: number; z?: number; } +>x : number +>z : number + +// returns typeof a +function f9() { +>f9 : () => { x: number; y?: number; } | { x: number; z?: number; } + + if (true) { +>true : boolean + + return a; +>a : { x: number; y?: number; } + + } else { + return b; +>b : { x: number; z?: number; } + } +} + +// returns typeof b +function f10() { +>f10 : () => { x: number; y?: number; } | { x: number; z?: number; } + + if (true) { +>true : boolean + + return b; +>b : { x: number; z?: number; } + + } else { + return a; +>a : { x: number; y?: number; } + } +} + +// returns number => void +function f11() { +>f11 : () => (x: number) => void + + if (true) { +>true : boolean + + return (x: number) => { } +>(x: number) => { } : (x: number) => void +>x : number + + } else { + return (x: Object) => { } +>(x: Object) => { } : (x: Object) => void +>x : Object +>Object : Object + } +} + +// returns Object => void +function f12() { +>f12 : () => (x: Object) => void + + if (true) { +>true : boolean + + return (x: Object) => { } +>(x: Object) => { } : (x: Object) => void +>x : Object +>Object : Object + + } else { + return (x: number) => { } +>(x: number) => { } : (x: number) => void +>x : number + } +} diff --git a/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt b/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt deleted file mode 100644 index 86234b7dd81..00000000000 --- a/tests/baselines/reference/functionWithNoBestCommonType1.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/compiler/functionWithNoBestCommonType1.ts(2,10): error TS2354: No best common type exists among return expressions. - - -==== tests/cases/compiler/functionWithNoBestCommonType1.ts (1 errors) ==== - - function foo() { - ~~~ -!!! error TS2354: No best common type exists among return expressions. - return true; - return bar(); - } - - function bar(): void { - } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithNoBestCommonType1.symbols b/tests/baselines/reference/functionWithNoBestCommonType1.symbols new file mode 100644 index 00000000000..826b23f1b48 --- /dev/null +++ b/tests/baselines/reference/functionWithNoBestCommonType1.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/functionWithNoBestCommonType1.ts === + +function foo() { +>foo : Symbol(foo, Decl(functionWithNoBestCommonType1.ts, 0, 0)) + + return true; + return bar(); +>bar : Symbol(bar, Decl(functionWithNoBestCommonType1.ts, 4, 1)) +} + +function bar(): void { +>bar : Symbol(bar, Decl(functionWithNoBestCommonType1.ts, 4, 1)) +} diff --git a/tests/baselines/reference/functionWithNoBestCommonType1.types b/tests/baselines/reference/functionWithNoBestCommonType1.types new file mode 100644 index 00000000000..801c25d239f --- /dev/null +++ b/tests/baselines/reference/functionWithNoBestCommonType1.types @@ -0,0 +1,16 @@ +=== tests/cases/compiler/functionWithNoBestCommonType1.ts === + +function foo() { +>foo : () => boolean | void + + return true; +>true : boolean + + return bar(); +>bar() : void +>bar : () => void +} + +function bar(): void { +>bar : () => void +} diff --git a/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt b/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt deleted file mode 100644 index 6ce898e447c..00000000000 --- a/tests/baselines/reference/functionWithNoBestCommonType2.errors.txt +++ /dev/null @@ -1,14 +0,0 @@ -tests/cases/compiler/functionWithNoBestCommonType2.ts(2,9): error TS2354: No best common type exists among return expressions. - - -==== tests/cases/compiler/functionWithNoBestCommonType2.ts (1 errors) ==== - - var v = function () { - ~~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. - return true; - return bar(); - }; - - function bar(): void { - } \ No newline at end of file diff --git a/tests/baselines/reference/functionWithNoBestCommonType2.symbols b/tests/baselines/reference/functionWithNoBestCommonType2.symbols new file mode 100644 index 00000000000..f32f86e67a9 --- /dev/null +++ b/tests/baselines/reference/functionWithNoBestCommonType2.symbols @@ -0,0 +1,14 @@ +=== tests/cases/compiler/functionWithNoBestCommonType2.ts === + +var v = function () { +>v : Symbol(v, Decl(functionWithNoBestCommonType2.ts, 1, 3)) + + return true; + return bar(); +>bar : Symbol(bar, Decl(functionWithNoBestCommonType2.ts, 4, 2)) + +}; + +function bar(): void { +>bar : Symbol(bar, Decl(functionWithNoBestCommonType2.ts, 4, 2)) +} diff --git a/tests/baselines/reference/functionWithNoBestCommonType2.types b/tests/baselines/reference/functionWithNoBestCommonType2.types new file mode 100644 index 00000000000..cae5f1dbb64 --- /dev/null +++ b/tests/baselines/reference/functionWithNoBestCommonType2.types @@ -0,0 +1,18 @@ +=== tests/cases/compiler/functionWithNoBestCommonType2.ts === + +var v = function () { +>v : () => boolean | void +>function () { return true; return bar();} : () => boolean | void + + return true; +>true : boolean + + return bar(); +>bar() : void +>bar : () => void + +}; + +function bar(): void { +>bar : () => void +} diff --git a/tests/baselines/reference/generatorTypeCheck22.errors.txt b/tests/baselines/reference/generatorTypeCheck22.errors.txt deleted file mode 100644 index ab2b3de4f42..00000000000 --- a/tests/baselines/reference/generatorTypeCheck22.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts(4,11): error TS2504: No best common type exists among yield expressions. - - -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts (1 errors) ==== - class Foo { x: number } - class Bar extends Foo { y: string } - class Baz { z: number } - function* g3() { - ~~ -!!! error TS2504: No best common type exists among yield expressions. - yield; - yield new Bar; - yield new Baz; - yield *[new Bar]; - yield *[new Baz]; - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck22.symbols b/tests/baselines/reference/generatorTypeCheck22.symbols new file mode 100644 index 00000000000..ae3bdac88f3 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck22.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck22.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(generatorTypeCheck22.ts, 0, 11)) + +class Bar extends Foo { y: string } +>Bar : Symbol(Bar, Decl(generatorTypeCheck22.ts, 0, 23)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck22.ts, 0, 0)) +>y : Symbol(Bar.y, Decl(generatorTypeCheck22.ts, 1, 23)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck22.ts, 1, 35)) +>z : Symbol(Baz.z, Decl(generatorTypeCheck22.ts, 2, 11)) + +function* g3() { +>g3 : Symbol(g3, Decl(generatorTypeCheck22.ts, 2, 23)) + + yield; + yield new Bar; +>Bar : Symbol(Bar, Decl(generatorTypeCheck22.ts, 0, 23)) + + yield new Baz; +>Baz : Symbol(Baz, Decl(generatorTypeCheck22.ts, 1, 35)) + + yield *[new Bar]; +>Bar : Symbol(Bar, Decl(generatorTypeCheck22.ts, 0, 23)) + + yield *[new Baz]; +>Baz : Symbol(Baz, Decl(generatorTypeCheck22.ts, 1, 35)) +} diff --git a/tests/baselines/reference/generatorTypeCheck22.types b/tests/baselines/reference/generatorTypeCheck22.types new file mode 100644 index 00000000000..e46e73874e6 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck22.types @@ -0,0 +1,42 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck22.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Bar extends Foo { y: string } +>Bar : Bar +>Foo : Foo +>y : string + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g3() { +>g3 : () => IterableIterator + + yield; +>yield : any + + yield new Bar; +>yield new Bar : any +>new Bar : Bar +>Bar : typeof Bar + + yield new Baz; +>yield new Baz : any +>new Baz : Baz +>Baz : typeof Baz + + yield *[new Bar]; +>yield *[new Bar] : any +>[new Bar] : Bar[] +>new Bar : Bar +>Bar : typeof Bar + + yield *[new Baz]; +>yield *[new Baz] : any +>[new Baz] : Baz[] +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/generatorTypeCheck23.errors.txt b/tests/baselines/reference/generatorTypeCheck23.errors.txt deleted file mode 100644 index 9e85117a0a8..00000000000 --- a/tests/baselines/reference/generatorTypeCheck23.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts(4,11): error TS2504: No best common type exists among yield expressions. - - -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts (1 errors) ==== - class Foo { x: number } - class Bar extends Foo { y: string } - class Baz { z: number } - function* g3() { - ~~ -!!! error TS2504: No best common type exists among yield expressions. - yield; - yield new Foo; - yield new Bar; - yield new Baz; - yield *[new Bar]; - yield *[new Baz]; - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck23.symbols b/tests/baselines/reference/generatorTypeCheck23.symbols new file mode 100644 index 00000000000..507906f500b --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck23.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck23.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(generatorTypeCheck23.ts, 0, 11)) + +class Bar extends Foo { y: string } +>Bar : Symbol(Bar, Decl(generatorTypeCheck23.ts, 0, 23)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck23.ts, 0, 0)) +>y : Symbol(Bar.y, Decl(generatorTypeCheck23.ts, 1, 23)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck23.ts, 1, 35)) +>z : Symbol(Baz.z, Decl(generatorTypeCheck23.ts, 2, 11)) + +function* g3() { +>g3 : Symbol(g3, Decl(generatorTypeCheck23.ts, 2, 23)) + + yield; + yield new Foo; +>Foo : Symbol(Foo, Decl(generatorTypeCheck23.ts, 0, 0)) + + yield new Bar; +>Bar : Symbol(Bar, Decl(generatorTypeCheck23.ts, 0, 23)) + + yield new Baz; +>Baz : Symbol(Baz, Decl(generatorTypeCheck23.ts, 1, 35)) + + yield *[new Bar]; +>Bar : Symbol(Bar, Decl(generatorTypeCheck23.ts, 0, 23)) + + yield *[new Baz]; +>Baz : Symbol(Baz, Decl(generatorTypeCheck23.ts, 1, 35)) +} diff --git a/tests/baselines/reference/generatorTypeCheck23.types b/tests/baselines/reference/generatorTypeCheck23.types new file mode 100644 index 00000000000..1d5d294503a --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck23.types @@ -0,0 +1,47 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck23.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Bar extends Foo { y: string } +>Bar : Bar +>Foo : Foo +>y : string + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g3() { +>g3 : () => IterableIterator + + yield; +>yield : any + + yield new Foo; +>yield new Foo : any +>new Foo : Foo +>Foo : typeof Foo + + yield new Bar; +>yield new Bar : any +>new Bar : Bar +>Bar : typeof Bar + + yield new Baz; +>yield new Baz : any +>new Baz : Baz +>Baz : typeof Baz + + yield *[new Bar]; +>yield *[new Bar] : any +>[new Bar] : Bar[] +>new Bar : Bar +>Bar : typeof Bar + + yield *[new Baz]; +>yield *[new Baz] : any +>[new Baz] : Baz[] +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/generatorTypeCheck24.errors.txt b/tests/baselines/reference/generatorTypeCheck24.errors.txt deleted file mode 100644 index b4ca13c14c2..00000000000 --- a/tests/baselines/reference/generatorTypeCheck24.errors.txt +++ /dev/null @@ -1,17 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts(4,11): error TS2504: No best common type exists among yield expressions. - - -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts (1 errors) ==== - class Foo { x: number } - class Bar extends Foo { y: string } - class Baz { z: number } - function* g3() { - ~~ -!!! error TS2504: No best common type exists among yield expressions. - yield; - yield * [new Foo]; - yield new Bar; - yield new Baz; - yield *[new Bar]; - yield *[new Baz]; - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck24.symbols b/tests/baselines/reference/generatorTypeCheck24.symbols new file mode 100644 index 00000000000..b0bc5307b89 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck24.symbols @@ -0,0 +1,33 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck24.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(generatorTypeCheck24.ts, 0, 11)) + +class Bar extends Foo { y: string } +>Bar : Symbol(Bar, Decl(generatorTypeCheck24.ts, 0, 23)) +>Foo : Symbol(Foo, Decl(generatorTypeCheck24.ts, 0, 0)) +>y : Symbol(Bar.y, Decl(generatorTypeCheck24.ts, 1, 23)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck24.ts, 1, 35)) +>z : Symbol(Baz.z, Decl(generatorTypeCheck24.ts, 2, 11)) + +function* g3() { +>g3 : Symbol(g3, Decl(generatorTypeCheck24.ts, 2, 23)) + + yield; + yield * [new Foo]; +>Foo : Symbol(Foo, Decl(generatorTypeCheck24.ts, 0, 0)) + + yield new Bar; +>Bar : Symbol(Bar, Decl(generatorTypeCheck24.ts, 0, 23)) + + yield new Baz; +>Baz : Symbol(Baz, Decl(generatorTypeCheck24.ts, 1, 35)) + + yield *[new Bar]; +>Bar : Symbol(Bar, Decl(generatorTypeCheck24.ts, 0, 23)) + + yield *[new Baz]; +>Baz : Symbol(Baz, Decl(generatorTypeCheck24.ts, 1, 35)) +} diff --git a/tests/baselines/reference/generatorTypeCheck24.types b/tests/baselines/reference/generatorTypeCheck24.types new file mode 100644 index 00000000000..e3c369bfce1 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck24.types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck24.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Bar extends Foo { y: string } +>Bar : Bar +>Foo : Foo +>y : string + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g3() { +>g3 : () => IterableIterator + + yield; +>yield : any + + yield * [new Foo]; +>yield * [new Foo] : any +>[new Foo] : Foo[] +>new Foo : Foo +>Foo : typeof Foo + + yield new Bar; +>yield new Bar : any +>new Bar : Bar +>Bar : typeof Bar + + yield new Baz; +>yield new Baz : any +>new Baz : Baz +>Baz : typeof Baz + + yield *[new Bar]; +>yield *[new Bar] : any +>[new Bar] : Bar[] +>new Bar : Bar +>Bar : typeof Bar + + yield *[new Baz]; +>yield *[new Baz] : any +>[new Baz] : Baz[] +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/generatorTypeCheck52.errors.txt b/tests/baselines/reference/generatorTypeCheck52.errors.txt deleted file mode 100644 index 8dc280bb8c9..00000000000 --- a/tests/baselines/reference/generatorTypeCheck52.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck52.ts(3,11): error TS2504: No best common type exists among yield expressions. - - -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck52.ts (1 errors) ==== - class Foo { x: number } - class Baz { z: number } - function* g() { - ~ -!!! error TS2504: No best common type exists among yield expressions. - yield new Foo; - yield new Baz; - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck52.symbols b/tests/baselines/reference/generatorTypeCheck52.symbols new file mode 100644 index 00000000000..64c29f98438 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck52.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck52.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck52.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(generatorTypeCheck52.ts, 0, 11)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck52.ts, 0, 23)) +>z : Symbol(Baz.z, Decl(generatorTypeCheck52.ts, 1, 11)) + +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck52.ts, 1, 23)) + + yield new Foo; +>Foo : Symbol(Foo, Decl(generatorTypeCheck52.ts, 0, 0)) + + yield new Baz; +>Baz : Symbol(Baz, Decl(generatorTypeCheck52.ts, 0, 23)) +} diff --git a/tests/baselines/reference/generatorTypeCheck52.types b/tests/baselines/reference/generatorTypeCheck52.types new file mode 100644 index 00000000000..97ac442aa0e --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck52.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck52.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g() { +>g : () => IterableIterator + + yield new Foo; +>yield new Foo : any +>new Foo : Foo +>Foo : typeof Foo + + yield new Baz; +>yield new Baz : any +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/generatorTypeCheck53.errors.txt b/tests/baselines/reference/generatorTypeCheck53.errors.txt deleted file mode 100644 index ee3512f34c5..00000000000 --- a/tests/baselines/reference/generatorTypeCheck53.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck53.ts(3,11): error TS2504: No best common type exists among yield expressions. - - -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck53.ts (1 errors) ==== - class Foo { x: number } - class Baz { z: number } - function* g() { - ~ -!!! error TS2504: No best common type exists among yield expressions. - yield new Foo; - yield* [new Baz]; - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck53.symbols b/tests/baselines/reference/generatorTypeCheck53.symbols new file mode 100644 index 00000000000..ce573dbf422 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck53.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck53.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck53.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(generatorTypeCheck53.ts, 0, 11)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck53.ts, 0, 23)) +>z : Symbol(Baz.z, Decl(generatorTypeCheck53.ts, 1, 11)) + +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck53.ts, 1, 23)) + + yield new Foo; +>Foo : Symbol(Foo, Decl(generatorTypeCheck53.ts, 0, 0)) + + yield* [new Baz]; +>Baz : Symbol(Baz, Decl(generatorTypeCheck53.ts, 0, 23)) +} diff --git a/tests/baselines/reference/generatorTypeCheck53.types b/tests/baselines/reference/generatorTypeCheck53.types new file mode 100644 index 00000000000..b91974e9807 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck53.types @@ -0,0 +1,23 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck53.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g() { +>g : () => IterableIterator + + yield new Foo; +>yield new Foo : any +>new Foo : Foo +>Foo : typeof Foo + + yield* [new Baz]; +>yield* [new Baz] : any +>[new Baz] : Baz[] +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/generatorTypeCheck54.errors.txt b/tests/baselines/reference/generatorTypeCheck54.errors.txt deleted file mode 100644 index de22dbfc6e8..00000000000 --- a/tests/baselines/reference/generatorTypeCheck54.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck54.ts(3,11): error TS2504: No best common type exists among yield expressions. - - -==== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck54.ts (1 errors) ==== - class Foo { x: number } - class Baz { z: number } - function* g() { - ~ -!!! error TS2504: No best common type exists among yield expressions. - yield* [new Foo]; - yield* [new Baz]; - } \ No newline at end of file diff --git a/tests/baselines/reference/generatorTypeCheck54.symbols b/tests/baselines/reference/generatorTypeCheck54.symbols new file mode 100644 index 00000000000..f6230b634f1 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck54.symbols @@ -0,0 +1,18 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck54.ts === +class Foo { x: number } +>Foo : Symbol(Foo, Decl(generatorTypeCheck54.ts, 0, 0)) +>x : Symbol(Foo.x, Decl(generatorTypeCheck54.ts, 0, 11)) + +class Baz { z: number } +>Baz : Symbol(Baz, Decl(generatorTypeCheck54.ts, 0, 23)) +>z : Symbol(Baz.z, Decl(generatorTypeCheck54.ts, 1, 11)) + +function* g() { +>g : Symbol(g, Decl(generatorTypeCheck54.ts, 1, 23)) + + yield* [new Foo]; +>Foo : Symbol(Foo, Decl(generatorTypeCheck54.ts, 0, 0)) + + yield* [new Baz]; +>Baz : Symbol(Baz, Decl(generatorTypeCheck54.ts, 0, 23)) +} diff --git a/tests/baselines/reference/generatorTypeCheck54.types b/tests/baselines/reference/generatorTypeCheck54.types new file mode 100644 index 00000000000..1cdbde67498 --- /dev/null +++ b/tests/baselines/reference/generatorTypeCheck54.types @@ -0,0 +1,24 @@ +=== tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck54.ts === +class Foo { x: number } +>Foo : Foo +>x : number + +class Baz { z: number } +>Baz : Baz +>z : number + +function* g() { +>g : () => IterableIterator + + yield* [new Foo]; +>yield* [new Foo] : any +>[new Foo] : Foo[] +>new Foo : Foo +>Foo : typeof Foo + + yield* [new Baz]; +>yield* [new Baz] : any +>[new Baz] : Baz[] +>new Baz : Baz +>Baz : typeof Baz +} diff --git a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt deleted file mode 100644 index bab58d0e4cf..00000000000 --- a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.errors.txt +++ /dev/null @@ -1,16 +0,0 @@ -tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts(2,10): error TS2354: No best common type exists among return expressions. - - -==== tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts (1 errors) ==== - - function foo() { - ~~~ -!!! error TS2354: No best common type exists among return expressions. - if (true) { - return 42; - } - else { - return "42"; - } - }; - \ No newline at end of file diff --git a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.symbols b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.symbols new file mode 100644 index 00000000000..059a992c3f3 --- /dev/null +++ b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.symbols @@ -0,0 +1,13 @@ +=== tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts === + +function foo() { +>foo : Symbol(foo, Decl(inferredFunctionReturnTypeIsEmptyType.ts, 0, 0)) + + if (true) { + return 42; + } + else { + return "42"; + } +}; + diff --git a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.types b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.types new file mode 100644 index 00000000000..9c1d4aa31b0 --- /dev/null +++ b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.types @@ -0,0 +1,17 @@ +=== tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts === + +function foo() { +>foo : () => string | number + + if (true) { +>true : boolean + + return 42; +>42 : number + } + else { + return "42"; +>"42" : string + } +}; + diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt b/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt deleted file mode 100644 index 995cf687b70..00000000000 --- a/tests/baselines/reference/stringLiteralTypesOverloads02.errors.txt +++ /dev/null @@ -1,57 +0,0 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts(9,10): error TS2354: No best common type exists among return expressions. - - -==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts (1 errors) ==== - - function getFalsyPrimitive(x: "string"): string; - function getFalsyPrimitive(x: "number"): number; - function getFalsyPrimitive(x: "boolean"): boolean; - function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; - function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; - function getFalsyPrimitive(x: "number" | "string"): number | string; - function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; - function getFalsyPrimitive(x: string) { - ~~~~~~~~~~~~~~~~~ -!!! error TS2354: No best common type exists among return expressions. - if (x === "string") { - return ""; - } - if (x === "number") { - return 0; - } - if (x === "boolean") { - return false; - } - - // Should be unreachable. - throw "Invalid value"; - } - - namespace Consts1 { - const EMPTY_STRING = getFalsyPrimitive("string"); - const ZERO = getFalsyPrimitive('number'); - const FALSE = getFalsyPrimitive("boolean"); - } - - const string: "string" = "string" - const number: "number" = "number" - const boolean: "boolean" = "boolean" - - const stringOrNumber = string || number; - const stringOrBoolean = string || boolean; - const booleanOrNumber = number || boolean; - const stringOrBooleanOrNumber = stringOrBoolean || number; - - namespace Consts2 { - const EMPTY_STRING = getFalsyPrimitive(string); - const ZERO = getFalsyPrimitive(number); - const FALSE = getFalsyPrimitive(boolean); - - const a = getFalsyPrimitive(stringOrNumber); - const b = getFalsyPrimitive(stringOrBoolean); - const c = getFalsyPrimitive(booleanOrNumber); - const d = getFalsyPrimitive(stringOrBooleanOrNumber); - } - - - \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.symbols b/tests/baselines/reference/stringLiteralTypesOverloads02.symbols new file mode 100644 index 00000000000..7c95a42b10f --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.symbols @@ -0,0 +1,140 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts === + +function getFalsyPrimitive(x: "string"): string; +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 1, 27)) + +function getFalsyPrimitive(x: "number"): number; +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 2, 27)) + +function getFalsyPrimitive(x: "boolean"): boolean; +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 3, 27)) + +function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 4, 27)) + +function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 5, 27)) + +function getFalsyPrimitive(x: "number" | "string"): number | string; +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 6, 27)) + +function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 7, 27)) + +function getFalsyPrimitive(x: string) { +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 8, 27)) + + if (x === "string") { +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 8, 27)) + + return ""; + } + if (x === "number") { +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 8, 27)) + + return 0; + } + if (x === "boolean") { +>x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 8, 27)) + + return false; + } + + // Should be unreachable. + throw "Invalid value"; +} + +namespace Consts1 { +>Consts1 : Symbol(Consts1, Decl(stringLiteralTypesOverloads02.ts, 21, 1)) + + const EMPTY_STRING = getFalsyPrimitive("string"); +>EMPTY_STRING : Symbol(EMPTY_STRING, Decl(stringLiteralTypesOverloads02.ts, 24, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) + + const ZERO = getFalsyPrimitive('number'); +>ZERO : Symbol(ZERO, Decl(stringLiteralTypesOverloads02.ts, 25, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) + + const FALSE = getFalsyPrimitive("boolean"); +>FALSE : Symbol(FALSE, Decl(stringLiteralTypesOverloads02.ts, 26, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +} + +const string: "string" = "string" +>string : Symbol(string, Decl(stringLiteralTypesOverloads02.ts, 29, 5)) + +const number: "number" = "number" +>number : Symbol(number, Decl(stringLiteralTypesOverloads02.ts, 30, 5)) + +const boolean: "boolean" = "boolean" +>boolean : Symbol(boolean, Decl(stringLiteralTypesOverloads02.ts, 31, 5)) + +const stringOrNumber = string || number; +>stringOrNumber : Symbol(stringOrNumber, Decl(stringLiteralTypesOverloads02.ts, 33, 5)) +>string : Symbol(string, Decl(stringLiteralTypesOverloads02.ts, 29, 5)) +>number : Symbol(number, Decl(stringLiteralTypesOverloads02.ts, 30, 5)) + +const stringOrBoolean = string || boolean; +>stringOrBoolean : Symbol(stringOrBoolean, Decl(stringLiteralTypesOverloads02.ts, 34, 5)) +>string : Symbol(string, Decl(stringLiteralTypesOverloads02.ts, 29, 5)) +>boolean : Symbol(boolean, Decl(stringLiteralTypesOverloads02.ts, 31, 5)) + +const booleanOrNumber = number || boolean; +>booleanOrNumber : Symbol(booleanOrNumber, Decl(stringLiteralTypesOverloads02.ts, 35, 5)) +>number : Symbol(number, Decl(stringLiteralTypesOverloads02.ts, 30, 5)) +>boolean : Symbol(boolean, Decl(stringLiteralTypesOverloads02.ts, 31, 5)) + +const stringOrBooleanOrNumber = stringOrBoolean || number; +>stringOrBooleanOrNumber : Symbol(stringOrBooleanOrNumber, Decl(stringLiteralTypesOverloads02.ts, 36, 5)) +>stringOrBoolean : Symbol(stringOrBoolean, Decl(stringLiteralTypesOverloads02.ts, 34, 5)) +>number : Symbol(number, Decl(stringLiteralTypesOverloads02.ts, 30, 5)) + +namespace Consts2 { +>Consts2 : Symbol(Consts2, Decl(stringLiteralTypesOverloads02.ts, 36, 58)) + + const EMPTY_STRING = getFalsyPrimitive(string); +>EMPTY_STRING : Symbol(EMPTY_STRING, Decl(stringLiteralTypesOverloads02.ts, 39, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>string : Symbol(string, Decl(stringLiteralTypesOverloads02.ts, 29, 5)) + + const ZERO = getFalsyPrimitive(number); +>ZERO : Symbol(ZERO, Decl(stringLiteralTypesOverloads02.ts, 40, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>number : Symbol(number, Decl(stringLiteralTypesOverloads02.ts, 30, 5)) + + const FALSE = getFalsyPrimitive(boolean); +>FALSE : Symbol(FALSE, Decl(stringLiteralTypesOverloads02.ts, 41, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>boolean : Symbol(boolean, Decl(stringLiteralTypesOverloads02.ts, 31, 5)) + + const a = getFalsyPrimitive(stringOrNumber); +>a : Symbol(a, Decl(stringLiteralTypesOverloads02.ts, 43, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>stringOrNumber : Symbol(stringOrNumber, Decl(stringLiteralTypesOverloads02.ts, 33, 5)) + + const b = getFalsyPrimitive(stringOrBoolean); +>b : Symbol(b, Decl(stringLiteralTypesOverloads02.ts, 44, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>stringOrBoolean : Symbol(stringOrBoolean, Decl(stringLiteralTypesOverloads02.ts, 34, 5)) + + const c = getFalsyPrimitive(booleanOrNumber); +>c : Symbol(c, Decl(stringLiteralTypesOverloads02.ts, 45, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>booleanOrNumber : Symbol(booleanOrNumber, Decl(stringLiteralTypesOverloads02.ts, 35, 5)) + + const d = getFalsyPrimitive(stringOrBooleanOrNumber); +>d : Symbol(d, Decl(stringLiteralTypesOverloads02.ts, 46, 9)) +>getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) +>stringOrBooleanOrNumber : Symbol(stringOrBooleanOrNumber, Decl(stringLiteralTypesOverloads02.ts, 36, 5)) +} + + + diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.types b/tests/baselines/reference/stringLiteralTypesOverloads02.types new file mode 100644 index 00000000000..91eaea1dca3 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.types @@ -0,0 +1,170 @@ +=== tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts === + +function getFalsyPrimitive(x: "string"): string; +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>x : "string" + +function getFalsyPrimitive(x: "number"): number; +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>x : "number" + +function getFalsyPrimitive(x: "boolean"): boolean; +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>x : "boolean" + +function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>x : "string" | "boolean" + +function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>x : "number" | "boolean" + +function getFalsyPrimitive(x: "number" | "string"): number | string; +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>x : "string" | "number" + +function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>x : "string" | "number" | "boolean" + +function getFalsyPrimitive(x: string) { +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>x : string + + if (x === "string") { +>x === "string" : boolean +>x : string +>"string" : "string" + + return ""; +>"" : string + } + if (x === "number") { +>x === "number" : boolean +>x : string +>"number" : "number" + + return 0; +>0 : number + } + if (x === "boolean") { +>x === "boolean" : boolean +>x : string +>"boolean" : "boolean" + + return false; +>false : boolean + } + + // Should be unreachable. + throw "Invalid value"; +>"Invalid value" : string +} + +namespace Consts1 { +>Consts1 : typeof Consts1 + + const EMPTY_STRING = getFalsyPrimitive("string"); +>EMPTY_STRING : string +>getFalsyPrimitive("string") : string +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>"string" : "string" + + const ZERO = getFalsyPrimitive('number'); +>ZERO : number +>getFalsyPrimitive('number') : number +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>'number' : "number" + + const FALSE = getFalsyPrimitive("boolean"); +>FALSE : boolean +>getFalsyPrimitive("boolean") : boolean +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>"boolean" : "boolean" +} + +const string: "string" = "string" +>string : "string" +>"string" : "string" + +const number: "number" = "number" +>number : "number" +>"number" : "number" + +const boolean: "boolean" = "boolean" +>boolean : "boolean" +>"boolean" : "boolean" + +const stringOrNumber = string || number; +>stringOrNumber : "string" | "number" +>string || number : "string" | "number" +>string : "string" +>number : "number" + +const stringOrBoolean = string || boolean; +>stringOrBoolean : "string" | "boolean" +>string || boolean : "string" | "boolean" +>string : "string" +>boolean : "boolean" + +const booleanOrNumber = number || boolean; +>booleanOrNumber : "number" | "boolean" +>number || boolean : "number" | "boolean" +>number : "number" +>boolean : "boolean" + +const stringOrBooleanOrNumber = stringOrBoolean || number; +>stringOrBooleanOrNumber : "string" | "number" | "boolean" +>stringOrBoolean || number : "string" | "number" | "boolean" +>stringOrBoolean : "string" | "boolean" +>number : "number" + +namespace Consts2 { +>Consts2 : typeof Consts2 + + const EMPTY_STRING = getFalsyPrimitive(string); +>EMPTY_STRING : string +>getFalsyPrimitive(string) : string +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>string : "string" + + const ZERO = getFalsyPrimitive(number); +>ZERO : number +>getFalsyPrimitive(number) : number +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>number : "number" + + const FALSE = getFalsyPrimitive(boolean); +>FALSE : boolean +>getFalsyPrimitive(boolean) : boolean +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>boolean : "boolean" + + const a = getFalsyPrimitive(stringOrNumber); +>a : string | number +>getFalsyPrimitive(stringOrNumber) : string | number +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>stringOrNumber : "string" | "number" + + const b = getFalsyPrimitive(stringOrBoolean); +>b : string | boolean +>getFalsyPrimitive(stringOrBoolean) : string | boolean +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>stringOrBoolean : "string" | "boolean" + + const c = getFalsyPrimitive(booleanOrNumber); +>c : number | boolean +>getFalsyPrimitive(booleanOrNumber) : number | boolean +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>booleanOrNumber : "number" | "boolean" + + const d = getFalsyPrimitive(stringOrBooleanOrNumber); +>d : string | number | boolean +>getFalsyPrimitive(stringOrBooleanOrNumber) : string | number | boolean +>getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } +>stringOrBooleanOrNumber : "string" | "number" | "boolean" +} + + + diff --git a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt index cd9ae40932a..ac8dfb07887 100644 --- a/tests/baselines/reference/typeGuardsInIfStatement.errors.txt +++ b/tests/baselines/reference/typeGuardsInIfStatement.errors.txt @@ -1,10 +1,7 @@ -tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(22,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(31,10): error TS2354: No best common type exists among return expressions. -tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(49,10): error TS2354: No best common type exists among return expressions. tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,17): error TS2339: Property 'toString' does not exist on type 'never'. -==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (4 errors) ==== +==== tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts (1 errors) ==== // In the true branch statement of an 'if' statement, // the type of a variable or parameter is narrowed by any type guard in the 'if' condition when true. // In the false branch statement of an 'if' statement, @@ -27,8 +24,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,17 } } function foo3(x: number | string) { - ~~~~ -!!! error TS2354: No best common type exists among return expressions. if (typeof x === "string") { x = "Hello"; return x; // string @@ -38,8 +33,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,17 } } function foo4(x: number | string) { - ~~~~ -!!! error TS2354: No best common type exists among return expressions. if (typeof x === "string") { return x; // string } @@ -58,8 +51,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsInIfStatement.ts(139,17 } } function foo6(x: number | string) { - ~~~~ -!!! error TS2354: No best common type exists among return expressions. if (typeof x === "string") { x = 10; return x; // number From a8063dfb68677214941a666c9b33cf4389f6bc23 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 1 Sep 2016 07:04:01 -0700 Subject: [PATCH 309/508] Always use literal types for literals --- src/compiler/checker.ts | 132 ++++++++++++++++------------------------ 1 file changed, 51 insertions(+), 81 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e49ab907d71..9eef1e81d33 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3085,7 +3085,9 @@ namespace ts { // Use the type of the initializer expression if one is present if (declaration.initializer) { - return addOptionality(checkExpressionCached(declaration.initializer), /*optional*/ declaration.questionToken && includeOptionality); + const exprType = checkExpressionCached(declaration.initializer); + const type = getCombinedNodeFlags(declaration) & NodeFlags.Const ? exprType : getBaseTypeOfLiteralType(exprType); + return addOptionality(type, /*optional*/ declaration.questionToken && includeOptionality); } // If it is a short-hand property assignment, use the type of the identifier @@ -3384,7 +3386,7 @@ namespace ts { function getTypeOfEnumMember(symbol: Symbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { - links.type = getDeclaredTypeOfEnum(getParentOfSymbol(symbol)); + links.type = getDeclaredTypeOfEnumMember(symbol); } return links.type; } @@ -7201,18 +7203,18 @@ namespace ts { return (type.flags & (TypeFlags.Literal | TypeFlags.Undefined | TypeFlags.Null)) !== 0; } - function isUnitUnionType(type: Type): boolean { + function isLiteralType(type: Type): boolean { return type.flags & TypeFlags.Boolean ? true : type.flags & TypeFlags.Union ? type.flags & TypeFlags.Enum ? true : !forEach((type).types, t => !isUnitType(t)) : isUnitType(type); } - function getBaseTypeOfUnitType(type: Type): Type { + function getBaseTypeOfLiteralType(type: Type): Type { return type.flags & TypeFlags.StringLiteral ? stringType : type.flags & TypeFlags.NumberLiteral ? numberType : type.flags & TypeFlags.BooleanLiteral ? booleanType : type.flags & TypeFlags.EnumLiteral ? (type).baseType : - type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(map((type).types, getBaseTypeOfUnitType)) : + type.flags & TypeFlags.Union && !(type.flags & TypeFlags.Enum) ? getUnionType(map((type).types, getBaseTypeOfLiteralType)) : type; } @@ -7576,8 +7578,9 @@ namespace ts { const candidates = inferiority ? inferences.secondary || (inferences.secondary = []) : inferences.primary || (inferences.primary = []); - if (!contains(candidates, source)) { - candidates.push(source); + const widened = isUnitType(source) ? getBaseTypeOfLiteralType(source): source; + if (!contains(candidates, widened)) { + candidates.push(widened); } } return; @@ -7904,7 +7907,7 @@ namespace ts { if (prop && prop.flags & SymbolFlags.SyntheticProperty) { if ((prop).isDiscriminantProperty === undefined) { (prop).isDiscriminantProperty = !(prop).hasCommonType && - isUnitUnionType(getTypeOfSymbol(prop)); + isLiteralType(getTypeOfSymbol(prop)); } return (prop).isDiscriminantProperty; } @@ -9757,6 +9760,7 @@ namespace ts { case SyntaxKind.BinaryExpression: return getContextualTypeForBinaryOperand(node); case SyntaxKind.PropertyAssignment: + case SyntaxKind.ShorthandPropertyAssignment: return getContextualTypeForObjectLiteralElement(parent); case SyntaxKind.ArrayLiteralExpression: return getContextualTypeForElementExpression(node); @@ -9776,31 +9780,6 @@ namespace ts { return undefined; } - function isLiteralTypeLocation(node: Node): boolean { - const parent = node.parent; - switch (parent.kind) { - case SyntaxKind.BinaryExpression: - switch ((parent).operatorToken.kind) { - case SyntaxKind.EqualsEqualsEqualsToken: - case SyntaxKind.ExclamationEqualsEqualsToken: - case SyntaxKind.EqualsEqualsToken: - case SyntaxKind.ExclamationEqualsToken: - return true; - } - break; - case SyntaxKind.ConditionalExpression: - return (node === (parent).whenTrue || - node === (parent).whenFalse) && - isLiteralTypeLocation(parent); - case SyntaxKind.ParenthesizedExpression: - return isLiteralTypeLocation(parent); - case SyntaxKind.CaseClause: - case SyntaxKind.LiteralType: - return true; - } - return false; - } - // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type: Type): Signature { @@ -9937,7 +9916,7 @@ namespace ts { } } else { - const type = checkExpression(e, contextualMapper); + const type = checkExpressionForMutableLocation(e, contextualMapper); elementTypes.push(type); } hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression; @@ -10077,7 +10056,7 @@ namespace ts { } else { Debug.assert(memberDecl.kind === SyntaxKind.ShorthandPropertyAssignment); - type = checkExpression((memberDecl).name, contextualMapper); + type = checkExpressionForMutableLocation((memberDecl).name, contextualMapper); } typeFlags |= type.flags; const prop = createSymbol(SymbolFlags.Property | SymbolFlags.Transient | member.flags, member.name); @@ -10799,9 +10778,6 @@ namespace ts { } let propType = getTypeOfSymbol(prop); - if (prop.flags & SymbolFlags.EnumMember && isLiteralContextForType(node, propType)) { - propType = getDeclaredTypeOfSymbol(prop); - } // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, @@ -12479,6 +12455,9 @@ namespace ts { } // Return a union of the return expression types. type = getUnionType(types, /*subtypeReduction*/ true); + if (isUnitType(type)) { + type = getBaseTypeOfLiteralType(type); + } if (funcIsGenerator) { type = createIterableIteratorType(type); @@ -12522,7 +12501,7 @@ namespace ts { return false; } const type = checkExpression(node.expression); - if (!isUnitUnionType(type)) { + if (!isLiteralType(type)) { return false; } const switchTypes = getSwitchClauseTypes(node); @@ -12865,7 +12844,7 @@ namespace ts { function checkPrefixUnaryExpression(node: PrefixUnaryExpression): Type { const operandType = checkExpression(node.operand); - if (node.operator === SyntaxKind.MinusToken && node.operand.kind === SyntaxKind.NumericLiteral && isLiteralContextForType(node, numberType)) { + if (node.operator === SyntaxKind.MinusToken && node.operand.kind === SyntaxKind.NumericLiteral) { return getLiteralTypeForText(TypeFlags.NumberLiteral, "" + -(node.operand).text); } switch (node.operator) { @@ -13265,11 +13244,11 @@ namespace ts { case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: case SyntaxKind.ExclamationEqualsEqualsToken: - const leftIsUnit = isUnitUnionType(leftType); - const rightIsUnit = isUnitUnionType(rightType); + const leftIsUnit = isLiteralType(leftType); + const rightIsUnit = isLiteralType(rightType); if (!leftIsUnit || !rightIsUnit) { - leftType = leftIsUnit ? getBaseTypeOfUnitType(leftType) : leftType; - rightType = rightIsUnit ? getBaseTypeOfUnitType(rightType) : rightType; + leftType = leftIsUnit ? getBaseTypeOfLiteralType(leftType) : leftType; + rightType = rightIsUnit ? getBaseTypeOfLiteralType(rightType) : rightType; } if (!isTypeEqualityComparableTo(leftType, rightType) && !isTypeEqualityComparableTo(rightType, leftType)) { reportOperatorError(); @@ -13281,7 +13260,7 @@ namespace ts { return checkInExpression(left, right, leftType, rightType); case SyntaxKind.AmpersandAmpersandToken: return getTypeFacts(leftType) & TypeFacts.Truthy ? - includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfUnitType(rightType))) : + includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; case SyntaxKind.BarBarToken: return getTypeFacts(leftType) & TypeFacts.Falsy ? @@ -13429,50 +13408,18 @@ namespace ts { return false; } - function isLiteralContextForType(node: Expression, type: Type) { - if (isLiteralTypeLocation(node)) { - return true; - } - let contextualType = getContextualType(node); - if (contextualType) { - if (contextualType.flags & TypeFlags.TypeParameter) { - const apparentType = getApparentTypeOfTypeParameter(contextualType); - // If the type parameter is constrained to the base primitive type we're checking for, - // consider this a literal context. For example, given a type parameter 'T extends string', - // this causes us to infer string literal types for T. - if (type === apparentType) { - return true; - } - contextualType = apparentType; - } - if (type.flags & TypeFlags.String) { - return maybeTypeOfKind(contextualType, TypeFlags.StringLiteral); - } - if (type.flags & TypeFlags.Number) { - return maybeTypeOfKind(contextualType, (TypeFlags.NumberLiteral | TypeFlags.EnumLiteral)); - } - if (type.flags & TypeFlags.Boolean) { - return maybeTypeOfKind(contextualType, TypeFlags.BooleanLiteral); - } - if (type.flags & TypeFlags.Enum) { - return typeContainsLiteralFromEnum(contextualType, type); - } - } - return false; - } - function checkLiteralExpression(node: Expression): Type { if (node.kind === SyntaxKind.NumericLiteral) { checkGrammarNumericLiteral(node); } switch (node.kind) { case SyntaxKind.StringLiteral: - return isLiteralContextForType(node, stringType) ? getLiteralTypeForText(TypeFlags.StringLiteral, (node).text) : stringType; + return getLiteralTypeForText(TypeFlags.StringLiteral, (node).text); case SyntaxKind.NumericLiteral: - return isLiteralContextForType(node, numberType) ? getLiteralTypeForText(TypeFlags.NumberLiteral, (node).text) : numberType; + return getLiteralTypeForText(TypeFlags.NumberLiteral, (node).text); case SyntaxKind.TrueKeyword: case SyntaxKind.FalseKeyword: - return isLiteralContextForType(node, booleanType) ? node.kind === SyntaxKind.TrueKeyword ? trueType : falseType : booleanType; + return node.kind === SyntaxKind.TrueKeyword ? trueType : falseType; } } @@ -13511,6 +13458,29 @@ namespace ts { return links.resolvedType; } + function hasLiteralContextualType(node: Expression) { + let contextualType = getContextualType(node); + if (contextualType) { + if (contextualType.flags & TypeFlags.TypeParameter) { + const apparentType = getApparentTypeOfTypeParameter(contextualType); + // If the type parameter is constrained to the base primitive type we're checking for, + // consider this a literal context. For example, given a type parameter 'T extends string', + // this causes us to infer string literal types for T. + if (apparentType.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) { + return true; + } + contextualType = apparentType; + } + return maybeTypeOfKind(contextualType, TypeFlags.Literal); + } + return false; + } + + function checkExpressionForMutableLocation(node: Expression, contextualMapper?: TypeMapper): Type { + const type = checkExpression(node, contextualMapper); + return hasLiteralContextualType(node) ? type : getBaseTypeOfLiteralType(type); + } + function checkPropertyAssignment(node: PropertyAssignment, contextualMapper?: TypeMapper): Type { // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including @@ -13519,7 +13489,7 @@ namespace ts { checkComputedPropertyName(node.name); } - return checkExpression((node).initializer, contextualMapper); + return checkExpressionForMutableLocation((node).initializer, contextualMapper); } function checkObjectLiteralMethod(node: MethodDeclaration, contextualMapper?: TypeMapper): Type { From e8e7ec6c626505ef77b77edbccef786cce918f73 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 1 Sep 2016 07:23:43 -0700 Subject: [PATCH 310/508] Remember to check for existence of `target.parent` --- src/services/services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/services.ts b/src/services/services.ts index 084d372da1a..e7fb0d9bcc5 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2810,7 +2810,7 @@ namespace ts { function getAncestorCallLikeExpression(node: Node): CallLikeExpression | undefined { const target = climbPastManyPropertyAccesses(node); const callLike = target.parent; - return isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike; + return callLike && isCallLikeExpression(callLike) && getInvokedExpression(callLike) === target && callLike; } function tryGetSignatureDeclaration(typeChecker: TypeChecker, node: Node): SignatureDeclaration | undefined { From 65d1079f8f10ae2b070fe5a54b942f8afc045ee5 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 1 Sep 2016 09:15:59 -0700 Subject: [PATCH 311/508] Replace services' jsdoc parser with parsers' Also modify scanner's definition of leading vs trailing comments, with associated changes to emitter and emit baselines (the last is in a separate commit). --- src/compiler/binder.ts | 6 +- src/compiler/checker.ts | 3 +- src/compiler/emitter.ts | 82 ++- src/compiler/parser.ts | 411 ++++++++++----- src/compiler/scanner.ts | 67 ++- src/compiler/types.ts | 12 +- src/compiler/utilities.ts | 162 ++++-- src/harness/unittests/jsDocParsing.ts | 728 +++++++++++++++++--------- src/services/services.ts | 404 ++------------ src/services/utilities.ts | 10 +- 10 files changed, 1053 insertions(+), 832 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d8017d601ad..d28df13655f 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -262,7 +262,7 @@ namespace ts { Debug.assert(node.parent.kind === SyntaxKind.JSDocFunctionType); let functionType = node.parent; let index = indexOf(functionType.parameters, node); - return "p" + index; + return "arg" + index; case SyntaxKind.JSDocTypedefTag: const parentNode = node.parent && node.parent.parent; let nameFromParentNode: string; @@ -517,9 +517,7 @@ namespace ts { // because the scope of JsDocComment should not be affected by whether the current node is a // container or not. if (isInJavaScriptFile(node) && node.jsDocComments) { - for (const jsDocComment of node.jsDocComments) { - bind(jsDocComment); - } + forEach(node.jsDocComments, bind); } if (checkUnreachable(node)) { forEachChild(node, bind); diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 863c9e7c37a..b6209043262 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5629,12 +5629,13 @@ namespace ts { case SyntaxKind.JSDocThisType: case SyntaxKind.JSDocOptionalType: return getTypeFromTypeNode((node).type); + case SyntaxKind.JSDocRecordType: + return getTypeFromTypeNode((node as JSDocRecordType).literal); case SyntaxKind.FunctionType: case SyntaxKind.ConstructorType: case SyntaxKind.TypeLiteral: case SyntaxKind.JSDocTypeLiteral: case SyntaxKind.JSDocFunctionType: - case SyntaxKind.JSDocRecordType: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node, aliasSymbol, aliasTypeArguments); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index f02cf266744..ce8d8e44d39 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -851,7 +851,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } } - function emitLinePreservingList(parent: Node, nodes: NodeArray, allowTrailingComma: boolean, spacesBetweenBraces: boolean) { + function emitLinePreservingList(parent: Node, nodes: NodeArray, allowTrailingComma: boolean, spacesBetweenBraces: boolean, commentsBeforePunctuation: boolean) { Debug.assert(nodes.length > 0); increaseIndent(); @@ -877,6 +877,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } emit(nodes[i]); + if (commentsBeforePunctuation) { + emitLeadingCommentsAtEnd(nodes[i]); + } } if (nodes.hasTrailingComma && allowTrailingComma) { @@ -895,7 +898,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } } - function emitList(nodes: TNode[], start: number, count: number, multiLine: boolean, trailingComma: boolean, leadingComma?: boolean, noTrailingNewLine?: boolean, emitNode?: (node: TNode) => void): number { + function emitList(nodes: TNode[], start: number, count: number, multiLine: boolean, trailingComma: boolean, leadingComma?: boolean, noTrailingNewLine?: boolean, commentsBeforePunctuation?: boolean, emitNode?: (node: TNode) => void): number { if (!emitNode) { emitNode = emit; } @@ -913,13 +916,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } } const node = nodes[start + i]; - // This emitting is to make sure we emit following comment properly - // ...(x, /*comment1*/ y)... - // ^ => node.pos - // "comment1" is not considered leading comment for "y" but rather - // considered as trailing comment of the previous node. - emitTrailingCommentsOfPosition(node.pos); emitNode(node); + if (commentsBeforePunctuation) { + emitLeadingCommentsAtEnd(nodes[i]); + } leadingComma = true; } if (trailingComma) { @@ -1897,7 +1897,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } else if (languageVersion >= ScriptTarget.ES6 || !forEach(elements, isSpreadElementExpression)) { write("["); - emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces*/ false); + emitLinePreservingList(node, node.elements, elements.hasTrailingComma, /*spacesBetweenBraces*/ false, /*commentsBeforePunctuation*/ true); write("]"); } else { @@ -1921,7 +1921,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge // then try to preserve the original shape of the object literal. // Otherwise just try to preserve the formatting. if (numElements === properties.length) { - emitLinePreservingList(node, properties, /*allowTrailingComma*/ languageVersion >= ScriptTarget.ES5, /*spacesBetweenBraces*/ true); + emitLinePreservingList(node, properties, /*allowTrailingComma*/ languageVersion >= ScriptTarget.ES5, /*spacesBetweenBraces*/ true, /*commentsBeforePunctuation*/ true); } else { const multiLine = node.multiLine; @@ -2166,14 +2166,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function emitPropertyAssignment(node: PropertyDeclaration) { emit(node.name); write(": "); - // This is to ensure that we emit comment in the following case: - // For example: - // obj = { - // id: /*comment1*/ ()=>void - // } - // "comment1" is not considered to be leading comment for node.initializer - // but rather a trailing comment on the previous node. - emitTrailingCommentsOfPosition(node.initializer.pos); emit(node.initializer); } @@ -2285,6 +2277,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } emit(node.expression); + emitLeadingCommentsAtEnd(node.expression); const dotRangeStart = nodeIsSynthesized(node.expression) ? -1 : node.expression.end; const dotRangeEnd = nodeIsSynthesized(node.expression) ? -1 : skipTrivia(currentText, node.expression.end) + 1; const dotToken = { pos: dotRangeStart, end: dotRangeEnd }; @@ -2501,13 +2494,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge emitThis(expression); if (node.arguments.length) { write(", "); + emitTrailingCommentsOfPosition(node.arguments.pos); emitCommaList(node.arguments); + emitLeadingCommentsAtEnd(node.arguments); } write(")"); } else { write("("); + emitTrailingCommentsOfPosition(node.arguments.pos); emitCommaList(node.arguments); + emitLeadingCommentsAtEnd(node.arguments); write(")"); } } @@ -2608,6 +2605,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge write("("); emit(node.expression); + emitLeadingCommentsAtEnd(node.expression); write(")"); } @@ -2886,6 +2884,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } else { emit(node.left); + emitLeadingCommentsAtEnd(node.left); // Add indentation before emit the operator if the operator is on different line // For example: // 3 @@ -3898,6 +3897,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge } emitNodeWithCommentsAndWithoutSourcemap(node.name); emitEnd(node.name); + emitLeadingCommentsAtEnd(node.name); } function createVoidZero(): Expression { @@ -4040,6 +4040,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge emit(name); } + emitLeadingCommentsAtEnd(name); write(" = "); emit(value); }); @@ -4591,6 +4592,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge emitStart(restParam); write("var "); emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + emitLeadingCommentsAtEnd(restParam.name); write(" = [];"); emitEnd(restParam); emitTrailingComments(restParam); @@ -4612,6 +4614,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge writeLine(); emitStart(restParam); emitNodeWithCommentsAndWithoutSourcemap(restParam.name); + emitLeadingCommentsAtEnd(restParam.name); write("[" + tempName + " - " + restIndex + "] = arguments[" + tempName + "];"); emitEnd(restParam); decreaseIndent(); @@ -4633,6 +4636,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge function emitDeclarationName(node: Declaration) { if (node.name) { emitNodeWithCommentsAndWithoutSourcemap(node.name); + emitLeadingCommentsAtEnd(node.name); } else { write(getGeneratedNameForNode(node)); @@ -4660,6 +4664,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge const { kind, parent } = node; if (kind !== SyntaxKind.MethodDeclaration && kind !== SyntaxKind.MethodSignature && + kind !== SyntaxKind.ArrowFunction && parent && parent.kind !== SyntaxKind.PropertyAssignment && parent.kind !== SyntaxKind.CallExpression && @@ -4734,7 +4739,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge const parameters = node.parameters; const skipCount = node.parameters.length && (node.parameters[0].name).originalKeywordKind === SyntaxKind.ThisKeyword ? 1 : 0; const omitCount = languageVersion < ScriptTarget.ES6 && hasDeclaredRestParameter(node) ? 1 : 0; - emitList(parameters, skipCount, parameters.length - omitCount - skipCount, /*multiLine*/ false, /*trailingComma*/ false); + emitTrailingCommentsOfPosition(node.parameters.pos); + emitList(parameters, skipCount, parameters.length - omitCount - skipCount, /*multiLine*/ false, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ false, /*commentsBeforePunctuation*/ true); + if ((parameters.length - omitCount - skipCount) <= 0) { + emitLeadingCommentsAtEnd(node.parameters); + } } write(")"); decreaseIndent(); @@ -5791,7 +5800,7 @@ const _super = (function (geti, seti) { writeLine(); const decoratorCount = decorators ? decorators.length : 0; - let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, + let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, /*commentsBeforePunctuation*/ false, decorator => emit(decorator.expression)); if (firstParameterDecorator) { argumentsWritten += emitDecoratorsOfParameters(constructor, /*leadingComma*/ argumentsWritten > 0); @@ -5891,7 +5900,7 @@ const _super = (function (geti, seti) { writeLine(); const decoratorCount = decorators ? decorators.length : 0; - let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, + let argumentsWritten = emitList(decorators, 0, decoratorCount, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ false, /*noTrailingNewLine*/ true, /*commentsBeforePunctuation*/ false, decorator => emit(decorator.expression)); if (firstParameterDecorator) { @@ -5933,7 +5942,7 @@ const _super = (function (geti, seti) { for (const parameter of node.parameters) { if (nodeIsDecorated(parameter)) { const decorators = parameter.decorators; - argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, decorator => { + argumentsWritten += emitList(decorators, 0, decorators.length, /*multiLine*/ true, /*trailingComma*/ false, /*leadingComma*/ leadingComma, /*noTrailingNewLine*/ true, /*commentsBeforePunctuation*/ false, decorator => { write(`__param(${parameterIndex}, `); emit(decorator.expression); write(")"); @@ -6347,6 +6356,7 @@ const _super = (function (geti, seti) { emitExpressionForPropertyName(node.name); emitEnd(node); write(";"); + emitLeadingCommentsAtEnd(node.name); } function writeEnumMemberDeclarationValue(member: EnumMember) { @@ -8288,7 +8298,11 @@ const _super = (function (geti, seti) { emitNewLineBeforeLeadingComments(currentLineMap, writer, node, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); + // However, a leading mid-line comment of the end of file token is emitted with spaces before, + // as if it were a trailing comment of the previous token + const commentStartsInMidLine = leadingComments && leadingComments.length && leadingComments[0].pos - 1 > 0 && currentText.charCodeAt(leadingComments[0].pos - 1) !== 10; + const isEndOfFile = node.kind === SyntaxKind.EndOfFileToken && commentStartsInMidLine; + emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ !isEndOfFile, newLine, writeComment); } function emitTrailingComments(node: Node) { @@ -8305,8 +8319,11 @@ const _super = (function (geti, seti) { /** * Emit trailing comments at the position. The term trailing comment is used here to describe following comment: - * x, /comment1/ y - * ^ => pos; the function will emit "comment1" in the emitJS + * x, /*comment1* / // comment2 + * ^ => pos; the function will emit "comment1" and "comment2" in the emitJS + * However, + * x /*comment1* /, y + * 'comment1' is actually a leading comment of ',' and needs to be emitted using emitLeadingCommentsAtEnd */ function emitTrailingCommentsOfPosition(pos: number) { if (compilerOptions.removeComments) { @@ -8319,7 +8336,18 @@ const _super = (function (geti, seti) { emitComments(currentText, currentLineMap, writer, trailingComments, /*trailingSeparator*/ true, newLine, writeComment); } - function emitLeadingCommentsOfPositionWorker(pos: number) { + /** + * Emit leading comments for the token after the current token. + * This is only needed for punctuation tokens. For example, in + * x /*comment1* /, y + * 'comment1' is a leading comment of ',' but needs to be emitted + * from x because there is no token for ','. + */ + function emitLeadingCommentsAtEnd(node: Node | NodeArray) { + emitLeadingCommentsOfPositionWorker(node.end, /*trailingSeparator*/ false); + } + + function emitLeadingCommentsOfPositionWorker(pos: number, trailingSeparator = true) { if (compilerOptions.removeComments) { return; } @@ -8337,7 +8365,7 @@ const _super = (function (geti, seti) { emitNewLineBeforeLeadingComments(currentLineMap, writer, { pos: pos, end: pos }, leadingComments); // Leading comments are emitted at /*leading comment1 */space/*leading comment*/space - emitComments(currentText, currentLineMap, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment); + emitComments(currentText, currentLineMap, writer, leadingComments, trailingSeparator, newLine, writeComment); } function emitDetachedCommentsAndUpdateCommentsInfo(node: TextRange) { diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index b28f13e438f..342b711a5a6 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -378,7 +378,7 @@ namespace ts { case SyntaxKind.JSDocNullableType: return visitNode(cbNode, (node).type); case SyntaxKind.JSDocRecordType: - return visitNodes(cbNodes, (node).members); + return visitNode(cbNode, (node).literal); case SyntaxKind.JSDocTypeReference: return visitNode(cbNode, (node).name) || visitNodes(cbNodes, (node).typeArguments); @@ -397,7 +397,7 @@ namespace ts { return visitNode(cbNode, (node).name) || visitNode(cbNode, (node).type); case SyntaxKind.JSDocComment: - return visitNodes(cbNodes, (node).tags); + return visitNodes(cbNodes, (node).tags); case SyntaxKind.JSDocParameterTag: return visitNode(cbNode, (node).preParameterName) || visitNode(cbNode, (node).typeExpression) || @@ -450,10 +450,10 @@ namespace ts { /* @internal */ export function parseIsolatedJSDocComment(content: string, start?: number, length?: number) { const result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length); - if (result && result.jsDocComment) { + if (result && result.jsDoc) { // because the jsDocComment was parsed out of the source file, it might // not be covered by the fixupParentReferences. - Parser.fixupParentReferences(result.jsDocComment); + Parser.fixupParentReferences(result.jsDoc); } return result; @@ -652,20 +652,18 @@ namespace ts { function addJSDocComment(node: T): T { - if (contextFlags & NodeFlags.JavaScriptFile) { - const comments = getLeadingCommentRangesOfNode(node, sourceFile); - if (comments) { - for (const comment of comments) { - const jsDocComment = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); - if (!jsDocComment) { - continue; - } - - if (!node.jsDocComments) { - node.jsDocComments = []; - } - node.jsDocComments.push(jsDocComment); + const comments = getLeadingCommentRangesOfNode(node, sourceFile); + if (comments) { + for (const comment of comments) { + const jsDoc = JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); + if (!jsDoc) { + continue; } + + if (!node.jsDocComments) { + node.jsDocComments = []; + } + node.jsDocComments.push(jsDoc); } } @@ -2201,7 +2199,7 @@ namespace ts { } fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function isIndexSignature(): boolean { @@ -2291,7 +2289,7 @@ namespace ts { // [Yield] nor [Await] fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); - return finishNode(method); + return addJSDocComment(finishNode(method)); } else { const property = createNode(SyntaxKind.PropertySignature, fullStart); @@ -2308,7 +2306,7 @@ namespace ts { } parseTypeMemberSemicolon(); - return finishNode(property); + return addJSDocComment(finishNode(property)); } } @@ -2897,7 +2895,7 @@ namespace ts { node.equalsGreaterThanToken = parseExpectedToken(SyntaxKind.EqualsGreaterThanToken, /*reportAtCurrentPosition*/ false, Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function tryParseParenthesizedArrowFunctionExpression(): Expression { @@ -2930,7 +2928,7 @@ namespace ts { ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); - return finishNode(arrowFunction); + return addJSDocComment(finishNode(arrowFunction)); } // True -> We definitely expect a parenthesized arrow function here. @@ -4114,7 +4112,7 @@ namespace ts { function tryParseAccessorDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): AccessorDeclaration { if (parseContextualModifier(SyntaxKind.GetKeyword)) { - return addJSDocComment(parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers)); + return parseAccessorDeclaration(SyntaxKind.GetAccessor, fullStart, decorators, modifiers); } else if (parseContextualModifier(SyntaxKind.SetKeyword)) { return parseAccessorDeclaration(SyntaxKind.SetAccessor, fullStart, decorators, modifiers); @@ -4993,7 +4991,7 @@ namespace ts { : doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.DisallowInContext, parseNonParameterInitializer); parseSemicolon(); - return finishNode(property); + return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ClassElement { @@ -5022,7 +5020,7 @@ namespace ts { node.name = parsePropertyName(); fillSignature(SyntaxKind.ColonToken, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken: SyntaxKind) { @@ -5265,7 +5263,7 @@ namespace ts { node.members = createMissingList(); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseNameOfClassDeclarationOrExpression(): Identifier { @@ -5333,7 +5331,7 @@ namespace ts { node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(/*isClassHeritageClause*/ false); node.members = parseObjectTypeMembers(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): TypeAliasDeclaration { @@ -5357,7 +5355,7 @@ namespace ts { const node = createNode(SyntaxKind.EnumMember, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): EnumDeclaration { @@ -5373,7 +5371,7 @@ namespace ts { else { node.members = createMissingList(); } - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseModuleBlock(): ModuleBlock { @@ -5400,7 +5398,7 @@ namespace ts { node.body = parseOptional(SyntaxKind.DotToken) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.Export | namespaceFlag) : parseModuleBlock(); - return finishNode(node); + return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart: number, decorators: NodeArray, modifiers: ModifiersArray): ModuleDeclaration { @@ -5489,7 +5487,7 @@ namespace ts { parseExpected(SyntaxKind.EqualsToken); importEqualsDeclaration.moduleReference = parseModuleReference(); parseSemicolon(); - return finishNode(importEqualsDeclaration); + return addJSDocComment(finishNode(importEqualsDeclaration)); } } @@ -5810,6 +5808,7 @@ namespace ts { export function parseJSDocTypeExpressionForTests(content: string, start: number, length: number) { initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS); + sourceFile = createSourceFile("file.js", ScriptTarget.Latest, ScriptKind.JS); scanner.setText(content, start, length); currentToken = scanner.scan(); const jsDocTypeExpression = parseJSDocTypeExpression(); @@ -6028,22 +6027,7 @@ namespace ts { function parseJSDocRecordType(): JSDocRecordType { const result = createNode(SyntaxKind.JSDocRecordType); - nextToken(); - result.members = parseDelimitedList(ParsingContext.JSDocRecordMembers, parseJSDocRecordMember); - checkForTrailingComma(result.members); - parseExpected(SyntaxKind.CloseBraceToken); - return finishNode(result); - } - - function parseJSDocRecordMember(): JSDocRecordMember { - const result = createNode(SyntaxKind.JSDocRecordMember); - result.name = parseSimplePropertyName(); - - if (token() === SyntaxKind.ColonToken) { - nextToken(); - result.type = parseJSDocType(); - } - + result.literal = parseTypeLiteral(); return finishNode(result); } @@ -6143,14 +6127,14 @@ namespace ts { export function parseIsolatedJSDocComment(content: string, start: number, length: number) { initializeState("file.js", content, ScriptTarget.Latest, /*_syntaxCursor:*/ undefined, ScriptKind.JS); sourceFile = { languageVariant: LanguageVariant.Standard, text: content }; - const jsDocComment = parseJSDocCommentWorker(start, length); + const jsDoc = parseJSDocCommentWorker(start, length); const diagnostics = parseDiagnostics; clearState(); - return jsDocComment ? { jsDocComment, diagnostics } : undefined; + return jsDoc ? { jsDoc, diagnostics } : undefined; } - export function parseJSDocComment(parent: Node, start: number, length: number): JSDocComment { + export function parseJSDocComment(parent: Node, start: number, length: number): JSDoc { const saveToken = currentToken; const saveParseDiagnosticsLength = parseDiagnostics.length; const saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode; @@ -6167,7 +6151,7 @@ namespace ts { return comment; } - export function parseJSDocCommentWorker(start: number, length: number): JSDocComment { + export function parseJSDocCommentWorker(start: number, length: number): JSDoc { const content = sourceText; start = start || 0; const end = length === undefined ? content.length : start + length; @@ -6178,76 +6162,145 @@ namespace ts { Debug.assert(end <= content.length); let tags: NodeArray; - let result: JSDocComment; + const comments: string[] = []; + let result: JSDoc; // Check for /** (JSDoc opening part) - if (content.charCodeAt(start) === CharacterCodes.slash && - content.charCodeAt(start + 1) === CharacterCodes.asterisk && - content.charCodeAt(start + 2) === CharacterCodes.asterisk && - content.charCodeAt(start + 3) !== CharacterCodes.asterisk) { + if (!isJsDocStart(content, start)) { + return result; + } + // + 3 for leading /**, - 5 in total for /** */ + scanner.scanRange(start + 3, length - 5, () => { + // Initially we can parse out a tag. We also have seen a starting asterisk. + // This is so that /** * @type */ doesn't parse. + let canParseTag = true; + let seenAsterisk = true; + let advanceToken = true; + let margin: number | undefined = undefined; + let indent = start - Math.max(content.lastIndexOf("\n", start), 0) + 4; + let text: string; - // + 3 for leading /**, - 5 in total for /** */ - scanner.scanRange(start + 3, length - 5, () => { - // Initially we can parse out a tag. We also have seen a starting asterisk. - // This is so that /** * @type */ doesn't parse. - let canParseTag = true; - let seenAsterisk = true; - + nextJSDocToken(); + while (token() === SyntaxKind.WhitespaceTrivia) { nextJSDocToken(); - while (token() !== SyntaxKind.EndOfFileToken) { - switch (token()) { - case SyntaxKind.AtToken: - if (canParseTag) { - parseTag(); - } - // This will take us to the end of the line, so it's OK to parse a tag on the next pass through the loop + } + if (token() === SyntaxKind.NewLineTrivia) { + canParseTag = true; + seenAsterisk = false; + nextJSDocToken(); + } + while (token() !== SyntaxKind.EndOfFileToken) { + switch (token()) { + case SyntaxKind.AtToken: + if (canParseTag) { + removeTrailingNewlines(comments); + parseTag(indent); + // This will take us past the end of the line, so it's OK to parse a tag on the next pass through the loop + // NOTE: According to usejsdoc.org, a tag goes to end of line, except the last tag. But real-world comments may break this rule. seenAsterisk = false; - break; + advanceToken = false; + margin = undefined; + } + else { + comments.push(scanner.getTokenText()); + } + indent++; + break; - case SyntaxKind.NewLineTrivia: - // After a line break, we can parse a tag, and we haven't seen an asterisk on the next line yet - canParseTag = true; - seenAsterisk = false; - break; + case SyntaxKind.NewLineTrivia: + // After a line break, we can parse a tag, and we haven't seen an asterisk on the next line yet + comments.push(scanner.getTokenText()); + canParseTag = true; + seenAsterisk = false; + indent = 0; + break; - case SyntaxKind.AsteriskToken: - if (seenAsterisk) { - // If we've already seen an asterisk, then we can no longer parse a tag on this line - canParseTag = false; - } - // Ignore the first asterisk on a line - seenAsterisk = true; - break; - - case SyntaxKind.Identifier: - // Anything else is doc comment text. We can't do anything with it. Because it - // wasn't a tag, we can no longer parse a tag on this line until we hit the next - // line break. + case SyntaxKind.AsteriskToken: + text = scanner.getTokenText(); + if (seenAsterisk) { + // If we've already seen an asterisk, then we can no longer parse a tag on this line canParseTag = false; - break; + comments.push(text); + if (!margin) { + margin = indent; + } + } + // Ignore the first asterisk on a line + seenAsterisk = true; + indent += text.length; + break; - case SyntaxKind.EndOfFileToken: - break; - } + case SyntaxKind.Identifier: + // Anything else is doc comment text. We just save it. Because it + // wasn't a tag, we can no longer parse a tag on this line until we hit the next + // line break. + text = scanner.getTokenText(); + comments.push(text); + if (!margin) { + margin = indent; + } + canParseTag = false; + indent += text.length; + break; + + case SyntaxKind.WhitespaceTrivia: + // only collect whitespace if we *know* that we're just looking at comments, not a possible jsdoc tag + text = scanner.getTokenText(); + if (!canParseTag || margin !== undefined && indent + text.length > margin) { + comments.push(text.slice(margin - indent - 1)); + } + indent += text.length; + break; + + case SyntaxKind.EndOfFileToken: + break; + + default: + text = scanner.getTokenText(); + comments.push(text); + indent += text.length; + break; + } + if (advanceToken) { nextJSDocToken(); } + else { + advanceToken = true; + } + } + removeLeadingNewlines(comments); + removeTrailingNewlines(comments); + result = createJSDocComment(); - result = createJSDocComment(); - - }); - } + }); return result; - function createJSDocComment(): JSDocComment { - if (!tags) { - return undefined; + function removeLeadingNewlines(comments: string[]) { + while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) { + comments.shift(); } + } - const result = createNode(SyntaxKind.JSDocComment, start); + function removeTrailingNewlines(comments: string[]) { + while (comments.length && (comments[comments.length - 1] === "\n" || comments[comments.length - 1] === "\r")) { + comments.pop(); + } + } + + function isJsDocStart(content: string, start: number) { + return content.charCodeAt(start) === CharacterCodes.slash && + content.charCodeAt(start + 1) === CharacterCodes.asterisk && + content.charCodeAt(start + 2) === CharacterCodes.asterisk && + content.charCodeAt(start + 3) !== CharacterCodes.asterisk; + } + + function createJSDocComment(): JSDoc { + const result = createNode(SyntaxKind.JSDocComment, start); result.tags = tags; + result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); } @@ -6257,78 +6310,158 @@ namespace ts { } } - function parseTag(): void { + function parseTag(indent: number) { Debug.assert(token() === SyntaxKind.AtToken); const atToken = createNode(SyntaxKind.AtToken, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); const tagName = parseJSDocIdentifierName(); + skipWhitespace(); if (!tagName) { return; } - const tag = handleTag(atToken, tagName) || handleUnknownTag(atToken, tagName); - addTag(tag); - } - - function handleTag(atToken: Node, tagName: Identifier): JSDocTag { + let tag: JSDocTag; if (tagName) { switch (tagName.text) { case "param": - return handleParamTag(atToken, tagName); + tag = parseParamTag(atToken, tagName); + break; case "return": case "returns": - return handleReturnTag(atToken, tagName); + tag = parseReturnTag(atToken, tagName); + break; case "template": - return handleTemplateTag(atToken, tagName); + tag = parseTemplateTag(atToken, tagName); + break; case "type": - return handleTypeTag(atToken, tagName); + tag = parseTypeTag(atToken, tagName); + break; case "typedef": - return handleTypedefTag(atToken, tagName); + tag = parseTypedefTag(atToken, tagName); + break; + default: + tag = parseUnknownTag(atToken, tagName); + break; + } + } + else { + tag = parseUnknownTag(atToken, tagName); + } + + if (!tag) { + // a badly malformed tag should not be added to the list of tags + return; + } + addTag(tag, parseTagComments(indent + tag.end - tag.pos)); + } + + function parseTagComments(indent: number) { + const comments: string[] = []; + let savingComments = false; + let seenAsterisk = true; + let done = false; + let margin: number | undefined; + let text: string; + function pushComment(text: string) { + if (!margin) { + margin = indent; + } + comments.push(text); + indent += text.length; + } + while (!done && token() !== SyntaxKind.EndOfFileToken) { + text = scanner.getTokenText(); + switch (token()) { + case SyntaxKind.NewLineTrivia: + if (seenAsterisk) { + savingComments = false; + seenAsterisk = false; + comments.push(text); + } + indent = 0; + break; + case SyntaxKind.AtToken: + done = true; + break; + case SyntaxKind.WhitespaceTrivia: + if (savingComments && seenAsterisk) { + pushComment(text); + } + else { + // if the whitespace crosses the margin, take only the whitespace that passes the margin + if (margin !== undefined && indent + text.length > margin) { + comments.push(text.slice(margin - indent - 1)); + } + indent += text.length; + } + break; + case SyntaxKind.AsteriskToken: + if (!seenAsterisk) { + // leading asterisks start recording on the *next* (non-whitespace) token + savingComments = false; + indent += text.length; + } + // FALLTHROUGH to gather comments + default: + if (seenAsterisk) { + savingComments = true; // leading identifiers start recording as well + pushComment(text); + } + seenAsterisk = true; + break; + } + if (!done) { + nextJSDocToken(); } } - return undefined; + removeLeadingNewlines(comments); + removeTrailingNewlines(comments); + return comments; } - function handleUnknownTag(atToken: Node, tagName: Identifier) { + function parseUnknownTag(atToken: Node, tagName: Identifier) { const result = createNode(SyntaxKind.JSDocTag, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); } - function addTag(tag: JSDocTag): void { - if (tag) { - if (!tags) { - tags = >[]; - tags.pos = tag.pos; - } + function addTag(tag: JSDocTag, comments: string[]): void { + tag.comment = comments.join(""); - tags.push(tag); - tags.end = tag.end; + if (!tags) { + tags = >[]; + tags.pos = tag.pos; } + + tags.push(tag); + tags.end = tag.end; } function tryParseTypeExpression(): JSDocTypeExpression { - if (token() !== SyntaxKind.OpenBraceToken) { - return undefined; - } + return tryParse(() => { + skipWhitespace(); + if (token() !== SyntaxKind.OpenBraceToken) { + return undefined; + } - const typeExpression = parseJSDocTypeExpression(); - return typeExpression; + return parseJSDocTypeExpression(); + }); } - function handleParamTag(atToken: Node, tagName: Identifier) { + function parseParamTag(atToken: Node, tagName: Identifier) { let typeExpression = tryParseTypeExpression(); - skipWhitespace(); + let name: Identifier; let isBracketed: boolean; // Looking for something like '[foo]' or 'foo' if (parseOptionalToken(SyntaxKind.OpenBracketToken)) { name = parseJSDocIdentifierName(); + skipWhitespace(); isBracketed = true; // May have an optional default, e.g. '[foo = 42]' @@ -6365,11 +6498,12 @@ namespace ts { result.preParameterName = preName; result.typeExpression = typeExpression; result.postParameterName = postName; + result.parameterName = postName || preName; result.isBracketed = isBracketed; return finishNode(result); } - function handleReturnTag(atToken: Node, tagName: Identifier): JSDocReturnTag { + function parseReturnTag(atToken: Node, tagName: Identifier): JSDocReturnTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocReturnTag)) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } @@ -6381,7 +6515,7 @@ namespace ts { return finishNode(result); } - function handleTypeTag(atToken: Node, tagName: Identifier): JSDocTypeTag { + function parseTypeTag(atToken: Node, tagName: Identifier): JSDocTypeTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocTypeTag)) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } @@ -6393,10 +6527,11 @@ namespace ts { return finishNode(result); } - function handlePropertyTag(atToken: Node, tagName: Identifier): JSDocPropertyTag { + function parsePropertyTag(atToken: Node, tagName: Identifier): JSDocPropertyTag { const typeExpression = tryParseTypeExpression(); skipWhitespace(); const name = parseJSDocIdentifierName(); + skipWhitespace(); if (!name) { parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, Diagnostics.Identifier_expected); return undefined; @@ -6410,7 +6545,7 @@ namespace ts { return finishNode(result); } - function handleTypedefTag(atToken: Node, tagName: Identifier): JSDocTypedefTag { + function parseTypedefTag(atToken: Node, tagName: Identifier): JSDocTypedefTag { const typeExpression = tryParseTypeExpression(); skipWhitespace(); @@ -6419,6 +6554,7 @@ namespace ts { typedefTag.tagName = tagName; typedefTag.name = parseJSDocIdentifierName(); typedefTag.typeExpression = typeExpression; + skipWhitespace(); if (typeExpression) { if (typeExpression.type.kind === SyntaxKind.JSDocTypeReference) { @@ -6488,6 +6624,7 @@ namespace ts { nextJSDocToken(); const tagName = parseJSDocIdentifierName(); + skipWhitespace(); if (!tagName) { return false; } @@ -6498,21 +6635,21 @@ namespace ts { // already has a @type tag, terminate the parent tag now. return false; } - parentTag.jsDocTypeTag = handleTypeTag(atToken, tagName); + parentTag.jsDocTypeTag = parseTypeTag(atToken, tagName); return true; case "prop": case "property": if (!parentTag.jsDocPropertyTags) { parentTag.jsDocPropertyTags = >[]; } - const propertyTag = handlePropertyTag(atToken, tagName); + const propertyTag = parsePropertyTag(atToken, tagName); parentTag.jsDocPropertyTags.push(propertyTag); return true; } return false; } - function handleTemplateTag(atToken: Node, tagName: Identifier): JSDocTemplateTag { + function parseTemplateTag(atToken: Node, tagName: Identifier): JSDocTemplateTag { if (forEach(tags, t => t.kind === SyntaxKind.JSDocTemplateTag)) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, Diagnostics._0_tag_already_specified, tagName.text); } @@ -6523,6 +6660,7 @@ namespace ts { while (true) { const name = parseJSDocIdentifierName(); + skipWhitespace(); if (!name) { parseErrorAtPosition(scanner.getStartPos(), 0, Diagnostics.Identifier_expected); return undefined; @@ -6536,6 +6674,7 @@ namespace ts { if (token() === SyntaxKind.CommaToken) { nextJSDocToken(); + skipWhitespace(); } else { break; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index c1431ca23ed..d8cfc39db87 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -599,10 +599,11 @@ namespace ts { * If false, whitespace is skipped until the first line break and comments between that location * and the next token are returned. * If true, comments occurring between the given position and the next line break are returned. + * If there is no line break, then no comments are returned. */ function getCommentRanges(text: string, pos: number, trailing: boolean): CommentRange[] { let result: CommentRange[]; - let collecting = trailing || pos === 0; + let needToSkipTrailingComment = pos > 0; while (pos < text.length) { const ch = text.charCodeAt(pos); switch (ch) { @@ -615,7 +616,11 @@ namespace ts { if (trailing) { return result; } - collecting = true; + else if (needToSkipTrailingComment) { + // skip the first line if not trailing (it'll be part of the trailing comment). + needToSkipTrailingComment = false; + result = undefined; + } if (result && result.length) { lastOrUndefined(result).hasTrailingNewLine = true; } @@ -651,11 +656,13 @@ namespace ts { pos++; } } - if (collecting) { + + // if we are at the end of the file, don't add trailing comments. + // end-of-file comments are added as leading comment of the end-of-file token. + if (pos < text.length || !trailing) { if (!result) { result = []; } - result.push({ pos: startPos, end: pos, hasTrailingNewLine, kind }); } continue; @@ -671,10 +678,10 @@ namespace ts { } break; } - return result; + return !trailing ? result : undefined; } - return result; + return !trailing ? result : undefined; } export function getLeadingCommentRanges(text: string, pos: number): CommentRange[] { @@ -1689,40 +1696,46 @@ namespace ts { } startPos = pos; - - // Eat leading whitespace - let ch = text.charCodeAt(pos); - while (pos < end) { - ch = text.charCodeAt(pos); - if (isWhiteSpaceSingleLine(ch)) { - pos++; - } - else { - break; - } - } tokenPos = pos; + const ch = text.charCodeAt(pos); switch (ch) { + case CharacterCodes.tab: + case CharacterCodes.verticalTab: + case CharacterCodes.formFeed: + case CharacterCodes.space: + while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) { + pos++; + } + return token = SyntaxKind.WhitespaceTrivia; case CharacterCodes.at: - return pos += 1, token = SyntaxKind.AtToken; + pos++; + return token = SyntaxKind.AtToken; case CharacterCodes.lineFeed: case CharacterCodes.carriageReturn: - return pos += 1, token = SyntaxKind.NewLineTrivia; + pos++; + return token = SyntaxKind.NewLineTrivia; case CharacterCodes.asterisk: - return pos += 1, token = SyntaxKind.AsteriskToken; + pos++; + return token = SyntaxKind.AsteriskToken; case CharacterCodes.openBrace: - return pos += 1, token = SyntaxKind.OpenBraceToken; + pos++; + return token = SyntaxKind.OpenBraceToken; case CharacterCodes.closeBrace: - return pos += 1, token = SyntaxKind.CloseBraceToken; + pos++; + return token = SyntaxKind.CloseBraceToken; case CharacterCodes.openBracket: - return pos += 1, token = SyntaxKind.OpenBracketToken; + pos++; + return token = SyntaxKind.OpenBracketToken; case CharacterCodes.closeBracket: - return pos += 1, token = SyntaxKind.CloseBracketToken; + pos++; + return token = SyntaxKind.CloseBracketToken; case CharacterCodes.equals: - return pos += 1, token = SyntaxKind.EqualsToken; + pos++; + return token = SyntaxKind.EqualsToken; case CharacterCodes.comma: - return pos += 1, token = SyntaxKind.CommaToken; + pos++; + return token = SyntaxKind.CommaToken; } if (isIdentifierStart(ch, ScriptTarget.Latest)) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 50beef52bf8..2ee28d501a9 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -464,7 +464,7 @@ namespace ts { modifiers?: ModifiersArray; // Array of modifiers /* @internal */ id?: number; // Unique id (used to look up NodeLinks) parent?: Node; // Parent node (initialized by binding - /* @internal */ jsDocComments?: JSDocComment[]; // JSDoc for the node, if it has any. Only for .js files. + /* @internal */ jsDocComments?: JSDoc[]; // JSDoc for the node, if it has any. Only for .js files. /* @internal */ symbol?: Symbol; // Symbol declared by node (initialized by binding) /* @internal */ locals?: SymbolTable; // Locals associated with node (initialized by binding) /* @internal */ nextContainer?: Node; // Next container in declaration order (initialized by binding) @@ -1471,7 +1471,7 @@ namespace ts { // @kind(SyntaxKind.JSDocRecordType) export interface JSDocRecordType extends JSDocType, TypeLiteralNode { - members: NodeArray; + literal: TypeLiteralNode; } // @kind(SyntaxKind.JSDocTypeReference) @@ -1519,14 +1519,16 @@ namespace ts { } // @kind(SyntaxKind.JSDocComment) - export interface JSDocComment extends Node { + export interface JSDoc extends Node { tags: NodeArray; + comment: string | undefined; } // @kind(SyntaxKind.JSDocTag) export interface JSDocTag extends Node { atToken: Node; tagName: Identifier; + comment: string | undefined; } // @kind(SyntaxKind.JSDocTemplateTag) @@ -1565,9 +1567,13 @@ namespace ts { // @kind(SyntaxKind.JSDocParameterTag) export interface JSDocParameterTag extends JSDocTag { + /** the parameter name, if provided *before* the type (TypeScript-style) */ preParameterName?: Identifier; typeExpression?: JSDocTypeExpression; + /** the parameter name, if provided *after* the type (JSDoc-standard) */ postParameterName?: Identifier; + /** the parameter name, regardless of the location it was provided */ + parameterName: Identifier; isBracketed: boolean; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 0c026fc6b6d..52683f0e74b 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -596,13 +596,7 @@ namespace ts { } export function getJsDocCommentsFromText(node: Node, text: string) { - const commentRanges = (node.kind === SyntaxKind.Parameter || - node.kind === SyntaxKind.TypeParameter || - node.kind === SyntaxKind.FunctionExpression || - node.kind === SyntaxKind.ArrowFunction) ? - concatenate(getTrailingCommentRanges(text, node.pos), getLeadingCommentRanges(text, node.pos)) : - getLeadingCommentRangesOfNodeFromText(node, text); - return filter(commentRanges, isJsDocComment); + return filter(getLeadingCommentRanges(text, node.pos), isJsDocComment); function isJsDocComment(comment: CommentRange) { // True if the comment starts with '/**' but not if it is '/**/' @@ -1356,39 +1350,75 @@ namespace ts { return undefined; } - const jsDocComments = getJSDocComments(node, checkParentVariableStatement); - if (!jsDocComments) { + const jsDocTags = getJSDocTags(node, checkParentVariableStatement); + if (!jsDocTags) { return undefined; } - for (const jsDocComment of jsDocComments) { - for (const tag of jsDocComment.tags) { - if (tag.kind === kind) { - return tag; - } + for (const tag of jsDocTags) { + if (tag.kind === kind) { + return tag; } } } - function getJSDocComments(node: Node, checkParentVariableStatement: boolean): JSDocComment[] { - if (node.jsDocComments) { - return node.jsDocComments; + function append(previous: T[] | undefined, additional: T[] | undefined): T[] | undefined { + if (additional) { + if (!previous) { + previous = []; + } + for (const x of additional) { + previous.push(x); + } } - // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. - // /** - // * @param {number} name - // * @returns {number} - // */ - // var x = function(name) { return name.length; } - if (checkParentVariableStatement) { - const isInitializerOfVariableDeclarationInStatement = - node.parent.kind === SyntaxKind.VariableDeclaration && - (node.parent).initializer === node && - node.parent.parent.parent.kind === SyntaxKind.VariableStatement; + return previous; + } - const variableStatementNode = isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : undefined; + export function getJSDocComments(node: Node, checkParentVariableStatement: boolean): string[] { + return getJSDocs(node, checkParentVariableStatement, docs => map(docs, doc => doc.comment), tags => map(tags, tag => tag.comment)); + } + + function getJSDocTags(node: Node, checkParentVariableStatement: boolean): JSDocTag[] { + return getJSDocs(node, checkParentVariableStatement, docs => { + let result: JSDocTag[] = []; + for (const doc of docs) { + if (doc.tags) { + result.push(...doc.tags); + } + } + return result; + }, tags => tags); + } + + function getJSDocs(node: Node, checkParentVariableStatement: boolean, getDocs: (docs: JSDoc[]) => T[], getTags: (tags: JSDocTag[]) => T[]): T[] { + // TODO: Get rid of getJsDocComments and friends (note the lowercase 's' in Js) + // TODO: A lot of this work should be cached, maybe. I guess it's only used in services right now... + let result: T[] = undefined; + // prepend documentation from parent sources + if (checkParentVariableStatement) { + // Try to recognize this pattern when node is initializer of variable declaration and JSDoc comments are on containing variable statement. + // /** + // * @param {number} name + // * @returns {number} + // */ + // var x = function(name) { return name.length; } + const isInitializerOfVariableDeclarationInStatement = + isVariableLike(node.parent) && + (node.parent).initializer === node && + node.parent.parent.parent.kind === SyntaxKind.VariableStatement; + const isVariableOfVariableDeclarationStatement = isVariableLike(node) && + node.parent.parent.kind === SyntaxKind.VariableStatement; + + const variableStatementNode = + isInitializerOfVariableDeclarationInStatement ? node.parent.parent.parent : + isVariableOfVariableDeclarationStatement ? node.parent.parent : + undefined; if (variableStatementNode) { - return variableStatementNode.jsDocComments; + result = append(result, getJSDocs(variableStatementNode, checkParentVariableStatement, getDocs, getTags)); + } + if (node.kind === SyntaxKind.ModuleDeclaration && + node.parent && node.parent.kind === SyntaxKind.ModuleDeclaration) { + result = append(result, getJSDocs(node.parent, checkParentVariableStatement, getDocs, getTags)); } // Also recognize when the node is the RHS of an assignment expression @@ -1399,16 +1429,62 @@ namespace ts { (parent as BinaryExpression).operatorToken.kind === SyntaxKind.EqualsToken && parent.parent.kind === SyntaxKind.ExpressionStatement; if (isSourceOfAssignmentExpressionStatement) { - return parent.parent.jsDocComments; + result = append(result, getJSDocs(parent.parent, checkParentVariableStatement, getDocs, getTags)); } const isPropertyAssignmentExpression = parent && parent.kind === SyntaxKind.PropertyAssignment; if (isPropertyAssignmentExpression) { - return parent.jsDocComments; + result = append(result, getJSDocs(parent, checkParentVariableStatement, getDocs, getTags)); + } + + // Pull parameter comments from declaring function as well + if (node.kind === SyntaxKind.Parameter) { + const paramTags = getJSDocParameterTag(node as ParameterDeclaration, checkParentVariableStatement); + if (paramTags) { + result = append(result, getTags(paramTags)); + } } } - return undefined; + if (isVariableLike(node) && node.initializer) { + result = append(result, getJSDocs(node.initializer, /*checkParentVariableStatement*/ false, getDocs, getTags)); + } + + if (node.jsDocComments) { + if (result) { + result = append(result, getDocs(node.jsDocComments)); + } + else { + return getDocs(node.jsDocComments); + } + } + + return result; + } + + function getJSDocParameterTag(param: ParameterDeclaration, checkParentVariableStatement: boolean): JSDocTag[] { + const func = param.parent as FunctionLikeDeclaration; + const tags = getJSDocTags(func, checkParentVariableStatement); + if (!param.name) { + // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification + const i = func.parameters.indexOf(param); + const paramTags = filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag); + if (paramTags && 0 <= i && i < paramTags.length) { + return [paramTags[i]]; + } + } + else if (param.name.kind === SyntaxKind.Identifier) { + const name = (param.name as Identifier).text; + const paramTags = filter(tags, tag => tag.kind === SyntaxKind.JSDocParameterTag && (tag as JSDocParameterTag).parameterName.text === name); + if (paramTags) { + return paramTags; + } + } + else { + // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines + // But multi-line object types aren't supported yet either + return undefined; + } } export function getJSDocTypeTag(node: Node): JSDocTypeTag { @@ -1429,17 +1505,15 @@ namespace ts { // annotation. const parameterName = (parameter.name).text; - const jsDocComments = getJSDocComments(parameter.parent, /*checkParentVariableStatement*/ true); - if (jsDocComments) { - for (const jsDocComment of jsDocComments) { - for (const tag of jsDocComment.tags) { - if (tag.kind === SyntaxKind.JSDocParameterTag) { - const parameterTag = tag; - const name = parameterTag.preParameterName || parameterTag.postParameterName; - if (name.text === parameterName) { - return parameterTag; - } - } + const jsDocTags = getJSDocTags(parameter.parent, /*checkParentVariableStatement*/ true); + if (!jsDocTags) { + return undefined; + } + for (const tag of jsDocTags) { + if (tag.kind === SyntaxKind.JSDocParameterTag) { + const parameterTag = tag; + if (parameterTag.parameterName.text === parameterName) { + return parameterTag; } } } diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index a9987ef3176..e688dc20750 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -6,11 +6,11 @@ namespace ts { describe("TypeExpressions", () => { function parsesCorrectly(content: string, expected: string) { const typeAndDiagnostics = ts.parseJSDocTypeExpressionForTests(content); - assert.isTrue(typeAndDiagnostics && typeAndDiagnostics.diagnostics.length === 0); + assert.isTrue(typeAndDiagnostics && typeAndDiagnostics.diagnostics.length === 0, "no errors issued"); const result = Utils.sourceFileToJSON(typeAndDiagnostics.jsDocTypeExpression.type); - assert.equal(result, expected); + assert.equal(result, expected, "result === expected"); } function parsesIncorrectly(content: string) { @@ -99,10 +99,15 @@ namespace ts { "kind": "JSDocRecordType", "pos": 1, "end": 3, - "members": { - "length": 0, - "pos": 2, - "end": 2 + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 3, + "members": { + "length": 0, + "pos": 2, + "end": 2 + } } }`); }); @@ -113,21 +118,26 @@ namespace ts { "kind": "JSDocRecordType", "pos": 1, "end": 6, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 5, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 6, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, "end": 5, - "text": "foo" - } - }, - "length": 1, - "pos": 2, - "end": 5 + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + } + }, + "length": 1, + "pos": 2, + "end": 5 + } } }`); }); @@ -138,26 +148,31 @@ namespace ts { "kind": "JSDocRecordType", "pos": 1, "end": 14, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 13, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 14, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" + "end": 13, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + }, + "type": { + "kind": "NumberKeyword", + "pos": 6, + "end": 13 + } }, - "type": { - "kind": "NumberKeyword", - "pos": 6, - "end": 13 - } - }, - "length": 1, - "pos": 2, - "end": 13 + "length": 1, + "pos": 2, + "end": 13 + } } }`); }); @@ -168,32 +183,37 @@ namespace ts { "kind": "JSDocRecordType", "pos": 1, "end": 11, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 5, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 11, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" - } - }, - "1": { - "kind": "JSDocRecordMember", - "pos": 6, - "end": 10, - "name": { - "kind": "Identifier", + "end": 6, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + } + }, + "1": { + "kind": "PropertySignature", "pos": 6, "end": 10, - "text": "bar" - } - }, - "length": 2, - "pos": 2, - "end": 10 + "name": { + "kind": "Identifier", + "pos": 6, + "end": 10, + "text": "bar" + } + }, + "length": 2, + "pos": 2, + "end": 10 + } } }`); }); @@ -204,37 +224,42 @@ namespace ts { "kind": "JSDocRecordType", "pos": 1, "end": 19, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 13, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 19, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" + "end": 14, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + }, + "type": { + "kind": "NumberKeyword", + "pos": 6, + "end": 13 + } }, - "type": { - "kind": "NumberKeyword", - "pos": 6, - "end": 13 - } - }, - "1": { - "kind": "JSDocRecordMember", - "pos": 14, - "end": 18, - "name": { - "kind": "Identifier", + "1": { + "kind": "PropertySignature", "pos": 14, "end": 18, - "text": "bar" - } - }, - "length": 2, - "pos": 2, - "end": 18 + "name": { + "kind": "Identifier", + "pos": 14, + "end": 18, + "text": "bar" + } + }, + "length": 2, + "pos": 2, + "end": 18 + } } }`); }); @@ -245,37 +270,42 @@ namespace ts { "kind": "JSDocRecordType", "pos": 1, "end": 19, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 5, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 19, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" - } - }, - "1": { - "kind": "JSDocRecordMember", - "pos": 6, - "end": 18, - "name": { - "kind": "Identifier", - "pos": 6, - "end": 10, - "text": "bar" + "end": 6, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + } }, - "type": { - "kind": "NumberKeyword", - "pos": 11, - "end": 18 - } - }, - "length": 2, - "pos": 2, - "end": 18 + "1": { + "kind": "PropertySignature", + "pos": 6, + "end": 18, + "name": { + "kind": "Identifier", + "pos": 6, + "end": 10, + "text": "bar" + }, + "type": { + "kind": "NumberKeyword", + "pos": 11, + "end": 18 + } + }, + "length": 2, + "pos": 2, + "end": 18 + } } }`); }); @@ -286,42 +316,47 @@ namespace ts { "kind": "JSDocRecordType", "pos": 1, "end": 27, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 13, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 27, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, - "end": 5, - "text": "foo" + "end": 14, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + }, + "type": { + "kind": "NumberKeyword", + "pos": 6, + "end": 13 + } }, - "type": { - "kind": "NumberKeyword", - "pos": 6, - "end": 13 - } - }, - "1": { - "kind": "JSDocRecordMember", - "pos": 14, - "end": 26, - "name": { - "kind": "Identifier", + "1": { + "kind": "PropertySignature", "pos": 14, - "end": 18, - "text": "bar" + "end": 26, + "name": { + "kind": "Identifier", + "pos": 14, + "end": 18, + "text": "bar" + }, + "type": { + "kind": "NumberKeyword", + "pos": 19, + "end": 26 + } }, - "type": { - "kind": "NumberKeyword", - "pos": 19, - "end": 26 - } - }, - "length": 2, - "pos": 2, - "end": 26 + "length": 2, + "pos": 2, + "end": 26 + } } }`); }); @@ -332,22 +367,128 @@ namespace ts { "kind": "JSDocRecordType", "pos": 1, "end": 11, - "members": { - "0": { - "kind": "JSDocRecordMember", - "pos": 2, - "end": 10, - "name": { - "kind": "Identifier", + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 11, + "members": { + "0": { + "kind": "PropertySignature", "pos": 2, "end": 10, - "originalKeywordKind": "FunctionKeyword", - "text": "function" - } - }, - "length": 1, - "pos": 2, - "end": 10 + "name": { + "kind": "Identifier", + "pos": 2, + "end": 10, + "originalKeywordKind": "FunctionKeyword", + "text": "function" + } + }, + "length": 1, + "pos": 2, + "end": 10 + } + } +}`); + }); + + it("trailingCommaInRecordType", () => { + parsesCorrectly("{{a,}}", `{ + "kind": "JSDocRecordType", + "pos": 1, + "end": 5, + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 5, + "members": { + "0": { + "kind": "PropertySignature", + "pos": 2, + "end": 4, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 3, + "text": "a" + } + }, + "length": 1, + "pos": 2, + "end": 4 + } + } +}`); + }); + + it("callSignatureInRecordType", () => { + parsesCorrectly("{{(): number}}", `{ + "kind": "JSDocRecordType", + "pos": 1, + "end": 13, + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 13, + "members": { + "0": { + "kind": "CallSignature", + "pos": 2, + "end": 12, + "parameters": { + "length": 0, + "pos": 3, + "end": 3 + }, + "type": { + "kind": "NumberKeyword", + "pos": 5, + "end": 12 + } + }, + "length": 1, + "pos": 2, + "end": 12 + } + } +}`); + }); + + it("methodInRecordType", () => { + parsesCorrectly("{{foo(): number}}", `{ + "kind": "JSDocRecordType", + "pos": 1, + "end": 16, + "literal": { + "kind": "TypeLiteral", + "pos": 1, + "end": 16, + "members": { + "0": { + "kind": "MethodSignature", + "pos": 2, + "end": 15, + "name": { + "kind": "Identifier", + "pos": 2, + "end": 5, + "text": "foo" + }, + "parameters": { + "length": 0, + "pos": 6, + "end": 6 + }, + "type": { + "kind": "NumberKeyword", + "pos": 8, + "end": 15 + } + }, + "length": 1, + "pos": 2, + "end": 15 + } } }`); }); @@ -872,17 +1013,14 @@ namespace ts { } }`); }); - }); + + }); describe("parsesIncorrectly", () => { it("emptyType", () => { parsesIncorrectly("{}"); }); - it("trailingCommaInRecordType", () => { - parsesIncorrectly("{{a,}}"); - }); - it("unionTypeWithTrailingBar", () => { parsesIncorrectly("{(a|)}"); }); @@ -947,14 +1085,6 @@ namespace ts { parsesIncorrectly("{function(a: number)}"); }); - it("callSignatureInRecordType", () => { - parsesIncorrectly("{{(): number}}"); - }); - - it("methodInRecordType", () => { - parsesIncorrectly("{{foo(): number}}"); - }); - it("tupleTypeWithComma", () => { parsesIncorrectly( "{[,]}"); }); @@ -979,7 +1109,7 @@ namespace ts { Debug.fail("Comment has at least one diagnostic: " + comment.diagnostics[0].messageText); } - const result = toJsonString(comment.jsDocComment); + const result = toJsonString(comment.jsDoc); const expectedString = typeof expected === "string" ? expected @@ -990,7 +1120,7 @@ namespace ts { const chai = require("chai"); chai.config.showDiff = true; // Use deep equal to compare key value data instead of the two objects - chai.expect(JSON.parse(result)).deep.equal(JSON.parse(expectedString)); + chai.expect(JSON.parse(expectedString)).deep.equal(JSON.parse(result)); } else { assert.equal(result, expectedString); @@ -1028,10 +1158,6 @@ namespace ts { parsesIncorrectly("/*** */"); }); - it("asteriskAfterPreamble", () => { - parsesIncorrectly("/** * @type {number} */"); - }); - it("multipleTypes", () => { parsesIncorrectly( `/** @@ -1091,6 +1217,7 @@ namespace ts { "0": { "kind": "JSDocTypeTag", "pos": 8, + "comment": "", "end": 22, "atToken": { "kind": "AtToken", @@ -1112,7 +1239,8 @@ namespace ts { "pos": 15, "end": 21 } - } + }, + "comment": "" }, "length": 1, "pos": 8, @@ -1121,6 +1249,15 @@ namespace ts { }`); }); + it("asteriskAfterPreamble", () => { + parsesCorrectly("/** * @type {number} */", `{ + "comment": "* @type {number} ", + "end": 23, + "kind": "JSDocComment", + "pos": 0 +}`); + }); + it("noType", () => { parsesCorrectly( `/** @@ -1133,8 +1270,9 @@ namespace ts { "tags": { "0": { "kind": "JSDocTypeTag", + "comment": "", "pos": 8, - "end": 13, + "end": 14, "atToken": { "kind": "AtToken", "pos": 8, @@ -1149,7 +1287,7 @@ namespace ts { }, "length": 1, "pos": 8, - "end": 13 + "end": 14 } }`); }); @@ -1166,8 +1304,9 @@ namespace ts { "tags": { "0": { "kind": "JSDocReturnTag", + "comment": "", "pos": 8, - "end": 15, + "end": 16, "atToken": { "kind": "AtToken", "pos": 8, @@ -1182,7 +1321,7 @@ namespace ts { }, "length": 1, "pos": 8, - "end": 15 + "end": 16 } }`); }); @@ -1199,6 +1338,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocTypeTag", + "comment": "", "pos": 8, "end": 22, "atToken": { @@ -1242,6 +1382,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocTypeTag", + "comment": "", "pos": 8, "end": 22, "atToken": { @@ -1285,6 +1426,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocReturnTag", + "comment": "", "pos": 8, "end": 24, "atToken": { @@ -1328,6 +1470,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocReturnTag", + "comment": "Description text follows", "pos": 8, "end": 24, "atToken": { @@ -1371,6 +1514,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocReturnTag", + "comment": "", "pos": 8, "end": 25, "atToken": { @@ -1414,6 +1558,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "", "pos": 8, "end": 29, "atToken": { @@ -1442,6 +1587,12 @@ namespace ts { "pos": 24, "end": 29, "text": "name1" + }, + "parameterName": { + "kind": "Identifier", + "pos": 24, + "end": 29, + "text": "name1" } }, "length": 1, @@ -1464,6 +1615,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "", "pos": 8, "end": 29, "atToken": { @@ -1492,10 +1644,17 @@ namespace ts { "pos": 24, "end": 29, "text": "name1" + }, + "parameterName": { + "kind": "Identifier", + "pos": 24, + "end": 29, + "text": "name1" } }, "1": { "kind": "JSDocParameterTag", + "comment": "", "pos": 34, "end": 55, "atToken": { @@ -1524,6 +1683,12 @@ namespace ts { "pos": 50, "end": 55, "text": "name2" + }, + "parameterName": { + "kind": "Identifier", + "pos": 50, + "end": 55, + "text": "name2" } }, "length": 2, @@ -1545,6 +1710,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "Description text follows", "pos": 8, "end": 29, "atToken": { @@ -1573,6 +1739,12 @@ namespace ts { "pos": 24, "end": 29, "text": "name1" + }, + "parameterName": { + "kind": "Identifier", + "pos": 24, + "end": 29, + "text": "name1" } }, "length": 1, @@ -1594,6 +1766,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "Description text follows", "pos": 8, "end": 31, "atToken": { @@ -1623,6 +1796,12 @@ namespace ts { "end": 30, "text": "name1" }, + "parameterName": { + "kind": "Identifier", + "pos": 25, + "end": 30, + "text": "name1" + }, "isBracketed": true }, "length": 1, @@ -1644,6 +1823,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "Description text follows", "pos": 8, "end": 36, "atToken": { @@ -1673,6 +1853,12 @@ namespace ts { "end": 31, "text": "name1" }, + "parameterName": { + "kind": "Identifier", + "pos": 26, + "end": 31, + "text": "name1" + }, "isBracketed": true }, "length": 1, @@ -1694,6 +1880,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "", "pos": 8, "end": 29, "atToken": { @@ -1722,11 +1909,56 @@ namespace ts { "pos": 24, "end": 29, "text": "name1" + }, + "parameterName": { + "kind": "Identifier", + "pos": 24, + "end": 29, + "text": "name1" } }, - "length": 1, - "pos": 8, - "end": 29 + "1": { + "atToken": { + "end": 31, + "kind": "AtToken", + "pos": 30 + }, + "comment": "", + "end": 51, + "kind": "JSDocParameterTag", + "parameterName": { + "end": 51, + "kind": "Identifier", + "pos": 46, + "text": "name2" + }, + "pos": 30, + "postParameterName": { + "end": 51, + "kind": "Identifier", + "pos": 46, + "text": "name2" + }, + "tagName": { + "end": 36, + "kind": "Identifier", + "pos": 31, + "text": "param" + }, + "typeExpression": { + "end": 45, + "kind": "JSDocTypeExpression", + "pos": 37, + "type": { + "end": 44, + "kind": "NumberKeyword", + "pos": 38 + } + } + }, + "end": 51, + "length": 2, + "pos": 8 } }`); }); @@ -1743,6 +1975,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "", "pos": 8, "end": 29, "atToken": { @@ -1762,6 +1995,12 @@ namespace ts { "end": 20, "text": "name1" }, + "parameterName": { + "kind": "Identifier", + "pos": 15, + "end": 20, + "text": "name1" + }, "typeExpression": { "kind": "JSDocTypeExpression", "pos": 21, @@ -1792,6 +2031,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "Description", "pos": 8, "end": 29, "atToken": { @@ -1811,6 +2051,12 @@ namespace ts { "end": 20, "text": "name1" }, + "parameterName": { + "kind": "Identifier", + "pos": 15, + "end": 20, + "text": "name1" + }, "typeExpression": { "kind": "JSDocTypeExpression", "pos": 21, @@ -1841,8 +2087,9 @@ namespace ts { "tags": { "0": { "kind": "JSDocTemplateTag", + "comment": "", "pos": 8, - "end": 19, + "end": 20, "atToken": { "kind": "AtToken", "pos": 8, @@ -1858,7 +2105,7 @@ namespace ts { "0": { "kind": "TypeParameter", "pos": 18, - "end": 19, + "end": 20, "name": { "kind": "Identifier", "pos": 18, @@ -1867,13 +2114,13 @@ namespace ts { } }, "length": 1, - "pos": 17, - "end": 19 + "pos": 18, + "end": 20 } }, "length": 1, "pos": 8, - "end": 19 + "end": 20 } }`); }); @@ -1890,8 +2137,9 @@ namespace ts { "tags": { "0": { "kind": "JSDocTemplateTag", + "comment": "", "pos": 8, - "end": 21, + "end": 22, "atToken": { "kind": "AtToken", "pos": 8, @@ -1918,7 +2166,7 @@ namespace ts { "1": { "kind": "TypeParameter", "pos": 20, - "end": 21, + "end": 22, "name": { "kind": "Identifier", "pos": 20, @@ -1927,13 +2175,13 @@ namespace ts { } }, "length": 2, - "pos": 17, - "end": 21 + "pos": 18, + "end": 22 } }, "length": 1, "pos": 8, - "end": 21 + "end": 22 } }`); }); @@ -1950,8 +2198,9 @@ namespace ts { "tags": { "0": { "kind": "JSDocTemplateTag", + "comment": "", "pos": 8, - "end": 22, + "end": 23, "atToken": { "kind": "AtToken", "pos": 8, @@ -1967,7 +2216,7 @@ namespace ts { "0": { "kind": "TypeParameter", "pos": 18, - "end": 19, + "end": 20, "name": { "kind": "Identifier", "pos": 18, @@ -1978,7 +2227,7 @@ namespace ts { "1": { "kind": "TypeParameter", "pos": 21, - "end": 22, + "end": 23, "name": { "kind": "Identifier", "pos": 21, @@ -1987,13 +2236,13 @@ namespace ts { } }, "length": 2, - "pos": 17, - "end": 22 + "pos": 18, + "end": 23 } }, "length": 1, "pos": 8, - "end": 22 + "end": 23 } }`); }); @@ -2010,8 +2259,9 @@ namespace ts { "tags": { "0": { "kind": "JSDocTemplateTag", + "comment": "", "pos": 8, - "end": 22, + "end": 23, "atToken": { "kind": "AtToken", "pos": 8, @@ -2038,7 +2288,7 @@ namespace ts { "1": { "kind": "TypeParameter", "pos": 21, - "end": 22, + "end": 23, "name": { "kind": "Identifier", "pos": 21, @@ -2047,13 +2297,13 @@ namespace ts { } }, "length": 2, - "pos": 17, - "end": 22 + "pos": 18, + "end": 23 } }, "length": 1, "pos": 8, - "end": 22 + "end": 23 } }`); }); @@ -2070,8 +2320,9 @@ namespace ts { "tags": { "0": { "kind": "JSDocTemplateTag", + "comment": "", "pos": 8, - "end": 23, + "end": 24, "atToken": { "kind": "AtToken", "pos": 8, @@ -2087,7 +2338,7 @@ namespace ts { "0": { "kind": "TypeParameter", "pos": 18, - "end": 19, + "end": 20, "name": { "kind": "Identifier", "pos": 18, @@ -2098,7 +2349,7 @@ namespace ts { "1": { "kind": "TypeParameter", "pos": 22, - "end": 23, + "end": 24, "name": { "kind": "Identifier", "pos": 22, @@ -2107,13 +2358,13 @@ namespace ts { } }, "length": 2, - "pos": 17, - "end": 23 + "pos": 18, + "end": 24 } }, "length": 1, "pos": 8, - "end": 23 + "end": 24 } }`); }); @@ -2130,8 +2381,9 @@ namespace ts { "tags": { "0": { "kind": "JSDocTemplateTag", + "comment": "Description of type parameters.", "pos": 8, - "end": 23, + "end": 24, "atToken": { "kind": "AtToken", "pos": 8, @@ -2147,7 +2399,7 @@ namespace ts { "0": { "kind": "TypeParameter", "pos": 18, - "end": 19, + "end": 20, "name": { "kind": "Identifier", "pos": 18, @@ -2158,7 +2410,7 @@ namespace ts { "1": { "kind": "TypeParameter", "pos": 22, - "end": 23, + "end": 24, "name": { "kind": "Identifier", "pos": 22, @@ -2167,13 +2419,13 @@ namespace ts { } }, "length": 2, - "pos": 17, - "end": 23 + "pos": 18, + "end": 24 } }, "length": 1, "pos": 8, - "end": 23 + "end": 24 } }`); }); @@ -2190,6 +2442,7 @@ namespace ts { "tags": { "0": { "kind": "JSDocParameterTag", + "comment": "", "pos": 8, "end": 18, "atToken": { @@ -2203,6 +2456,12 @@ namespace ts { "end": 14, "text": "param" }, + "parameterName": { + "kind": "Identifier", + "pos": 15, + "end": 18, + "text": "foo" + }, "preParameterName": { "kind": "Identifier", "pos": 15, @@ -2236,17 +2495,18 @@ namespace ts { "kind": "AtToken", "pos": 8 }, - "end": 97, + "comment": "", + "end": 98, "jsDocTypeLiteral": { - "end": 97, + "end": 98, "jsDocPropertyTags": [ { "atToken": { "end": 48, "kind": "AtToken", - "pos": 46 + "pos": 47 }, - "end": 69, + "end": 72, "kind": "JSDocPropertyTag", "name": { "end": 69, @@ -2254,7 +2514,7 @@ namespace ts { "pos": 66, "text": "age" }, - "pos": 46, + "pos": 47, "tagName": { "end": 56, "kind": "Identifier", @@ -2276,9 +2536,9 @@ namespace ts { "atToken": { "end": 75, "kind": "AtToken", - "pos": 73 + "pos": 74 }, - "end": 97, + "end": 98, "kind": "JSDocPropertyTag", "name": { "end": 97, @@ -2286,7 +2546,7 @@ namespace ts { "pos": 93, "text": "name" }, - "pos": 73, + "pos": 74, "tagName": { "end": 83, "kind": "Identifier", @@ -2309,11 +2569,11 @@ namespace ts { "atToken": { "end": 29, "kind": "AtToken", - "pos": 27 + "pos": 28 }, "end": 42, "kind": "JSDocTypeTag", - "pos": 27, + "pos": 28, "tagName": { "end": 33, "kind": "Identifier", @@ -2338,7 +2598,7 @@ namespace ts { } }, "kind": "JSDocTypeLiteral", - "pos": 23 + "pos": 26 }, "kind": "JSDocTypedefTag", "name": { @@ -2355,7 +2615,7 @@ namespace ts { "text": "typedef" } }, - "end": 97, + "end": 98, "length": 1, "pos": 8 } diff --git a/src/services/services.ts b/src/services/services.ts index c19eb487d75..812ae0643d8 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -194,7 +194,7 @@ namespace ts { public end: number; public flags: NodeFlags; public parent: Node; - public jsDocComments: JSDocComment[]; + public jsDocComments: JSDoc[]; private _children: Node[]; constructor(kind: SyntaxKind, pos: number, end: number) { @@ -355,7 +355,7 @@ namespace ts { public end: number; public flags: NodeFlags; public parent: Node; - public jsDocComments: JSDocComment[]; + public jsDocComments: JSDoc[]; public __tokenTag: any; constructor(pos: number, end: number) { @@ -474,349 +474,48 @@ namespace ts { } function getJsDocCommentsFromDeclarations(declarations: Declaration[], name: string, canUseParsedParamTagComments: boolean) { + // Only collect doc comments from duplicate declarations once: + // In case of a union property there might be same declaration multiple times + // which only varies in type parameter + // Eg. const a: Array | Array; a.length + // The property length will have two declarations of property length coming + // from Array - Array and Array const documentationComment = []; - const docComments = getJsDocCommentsSeparatedByNewLines(); - ts.forEach(docComments, docComment => { - if (documentationComment.length) { - documentationComment.push(lineBreakPart()); + forEachUnique(declarations, declaration => { + const comments = getJSDocComments(declaration, /*checkParentVariableStatement*/ true); + if (!comments) { + return; + } + for (const comment of comments) { + if (comment) { + if (documentationComment.length) { + documentationComment.push(lineBreakPart()); + } + documentationComment.push(textPart(comment)); + } } - documentationComment.push(docComment); }); return documentationComment; + } - function getJsDocCommentsSeparatedByNewLines() { - const paramTag = "@param"; - const jsDocCommentParts: SymbolDisplayPart[] = []; - - ts.forEach(declarations, (declaration, indexOfDeclaration) => { - // Make sure we are collecting doc comment from declaration once, - // In case of union property there might be same declaration multiple times - // which only varies in type parameter - // Eg. const a: Array | Array; a.length - // The property length will have two declarations of property length coming - // from Array - Array and Array - if (indexOf(declarations, declaration) === indexOfDeclaration) { - const sourceFileOfDeclaration = getSourceFileOfNode(declaration); - // If it is parameter - try and get the jsDoc comment with @param tag from function declaration's jsDoc comments - if (canUseParsedParamTagComments && declaration.kind === SyntaxKind.Parameter) { - if ((declaration.parent.kind === SyntaxKind.FunctionExpression || declaration.parent.kind === SyntaxKind.ArrowFunction) && - declaration.parent.parent.kind === SyntaxKind.VariableDeclaration) { - addCommentParts(declaration.parent.parent.parent, sourceFileOfDeclaration, getCleanedParamJsDocComment); - } - addCommentParts(declaration.parent, sourceFileOfDeclaration, getCleanedParamJsDocComment); - } - - // If this is left side of dotted module declaration, there is no doc comments associated with this node - if (declaration.kind === SyntaxKind.ModuleDeclaration && (declaration).body && (declaration).body.kind === SyntaxKind.ModuleDeclaration) { - return; - } - - if ((declaration.kind === SyntaxKind.FunctionExpression || declaration.kind === SyntaxKind.ArrowFunction) && - declaration.parent.kind === SyntaxKind.VariableDeclaration) { - addCommentParts(declaration.parent.parent, sourceFileOfDeclaration, getCleanedJsDocComment); - } - - // If this is dotted module name, get the doc comments from the parent - while (declaration.kind === SyntaxKind.ModuleDeclaration && declaration.parent.kind === SyntaxKind.ModuleDeclaration) { - declaration = declaration.parent; - } - addCommentParts(declaration.kind === SyntaxKind.VariableDeclaration ? declaration.parent.parent : declaration, - sourceFileOfDeclaration, - getCleanedJsDocComment); - - if (declaration.kind === SyntaxKind.VariableDeclaration) { - const init = (declaration as VariableDeclaration).initializer; - if (init && (init.kind === SyntaxKind.FunctionExpression || init.kind === SyntaxKind.ArrowFunction)) { - // Get the cleaned js doc comment text from the initializer - addCommentParts(init, sourceFileOfDeclaration, getCleanedJsDocComment); - } - } - } - }); - - return jsDocCommentParts; - - function addCommentParts(commented: Node, - sourceFileOfDeclaration: SourceFile, - getCommentPart: (pos: number, end: number, file: SourceFile) => SymbolDisplayPart[]): void { - const ranges = getJsDocCommentTextRange(commented, sourceFileOfDeclaration); - // Get the cleaned js doc comment text from the declaration - ts.forEach(ranges, jsDocCommentTextRange => { - const cleanedComment = getCommentPart(jsDocCommentTextRange.pos, jsDocCommentTextRange.end, sourceFileOfDeclaration); - if (cleanedComment) { - addRange(jsDocCommentParts, cleanedComment); - } - }); - } - - function getJsDocCommentTextRange(node: Node, sourceFile: SourceFile): TextRange[] { - return ts.map(getJsDocComments(node, sourceFile), - jsDocComment => { - return { - pos: jsDocComment.pos + "/*".length, // Consume /* from the comment - end: jsDocComment.end - "*/".length // Trim off comment end indicator - }; - }); - } - - function consumeWhiteSpacesOnTheLine(pos: number, end: number, sourceFile: SourceFile, maxSpacesToRemove?: number) { - if (maxSpacesToRemove !== undefined) { - end = Math.min(end, pos + maxSpacesToRemove); - } - - for (; pos < end; pos++) { - const ch = sourceFile.text.charCodeAt(pos); - if (!isWhiteSpaceSingleLine(ch)) { - return pos; - } - } - - return end; - } - - function consumeLineBreaks(pos: number, end: number, sourceFile: SourceFile) { - while (pos < end && isLineBreak(sourceFile.text.charCodeAt(pos))) { - pos++; - } - - return pos; - } - - function isName(pos: number, end: number, sourceFile: SourceFile, name: string) { - return pos + name.length < end && - sourceFile.text.substr(pos, name.length) === name && - isWhiteSpace(sourceFile.text.charCodeAt(pos + name.length)); - } - - function isParamTag(pos: number, end: number, sourceFile: SourceFile) { - // If it is @param tag - return isName(pos, end, sourceFile, paramTag); - } - - function pushDocCommentLineText(docComments: SymbolDisplayPart[], text: string, blankLineCount: number) { - // Add the empty lines in between texts - while (blankLineCount) { - blankLineCount--; - docComments.push(textPart("")); - } - - docComments.push(textPart(text)); - } - - function getCleanedJsDocComment(pos: number, end: number, sourceFile: SourceFile) { - let spacesToRemoveAfterAsterisk: number; - const docComments: SymbolDisplayPart[] = []; - let blankLineCount = 0; - let isInParamTag = false; - - while (pos < end) { - let docCommentTextOfLine = ""; - // First consume leading white space - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile); - - // If the comment starts with '*' consume the spaces on this line - if (pos < end && sourceFile.text.charCodeAt(pos) === CharacterCodes.asterisk) { - const lineStartPos = pos + 1; - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, spacesToRemoveAfterAsterisk); - - // Set the spaces to remove after asterisk as margin if not already set - if (spacesToRemoveAfterAsterisk === undefined && pos < end && !isLineBreak(sourceFile.text.charCodeAt(pos))) { - spacesToRemoveAfterAsterisk = pos - lineStartPos; - } - } - else if (spacesToRemoveAfterAsterisk === undefined) { - spacesToRemoveAfterAsterisk = 0; - } - - // Analyze text on this line - while (pos < end && !isLineBreak(sourceFile.text.charCodeAt(pos))) { - const ch = sourceFile.text.charAt(pos); - if (ch === "@") { - // If it is @param tag - if (isParamTag(pos, end, sourceFile)) { - isInParamTag = true; - pos += paramTag.length; - continue; - } - else { - isInParamTag = false; - } - } - - // Add the ch to doc text if we arent in param tag - if (!isInParamTag) { - docCommentTextOfLine += ch; - } - - // Scan next character - pos++; - } - - // Continue with next line - pos = consumeLineBreaks(pos, end, sourceFile); - if (docCommentTextOfLine) { - pushDocCommentLineText(docComments, docCommentTextOfLine, blankLineCount); - blankLineCount = 0; - } - else if (!isInParamTag && docComments.length) { - // This is blank line when there is text already parsed - blankLineCount++; - } - } - - return docComments; - } - - function getCleanedParamJsDocComment(pos: number, end: number, sourceFile: SourceFile) { - let paramHelpStringMargin: number; - const paramDocComments: SymbolDisplayPart[] = []; - while (pos < end) { - if (isParamTag(pos, end, sourceFile)) { - let blankLineCount = 0; - let recordedParamTag = false; - // Consume leading spaces - pos = consumeWhiteSpaces(pos + paramTag.length); - if (pos >= end) { - break; - } - - // Ignore type expression - if (sourceFile.text.charCodeAt(pos) === CharacterCodes.openBrace) { - pos++; - for (let curlies = 1; pos < end; pos++) { - const charCode = sourceFile.text.charCodeAt(pos); - - // { character means we need to find another } to match the found one - if (charCode === CharacterCodes.openBrace) { - curlies++; - continue; - } - - // } char - if (charCode === CharacterCodes.closeBrace) { - curlies--; - if (curlies === 0) { - // We do not have any more } to match the type expression is ignored completely - pos++; - break; - } - else { - // there are more { to be matched with } - continue; - } - } - - // Found start of another tag - if (charCode === CharacterCodes.at) { - break; - } - } - - // Consume white spaces - pos = consumeWhiteSpaces(pos); - if (pos >= end) { - break; - } - } - - // Parameter name - if (isName(pos, end, sourceFile, name)) { - // Found the parameter we are looking for consume white spaces - pos = consumeWhiteSpaces(pos + name.length); - if (pos >= end) { - break; - } - - let paramHelpString = ""; - const firstLineParamHelpStringPos = pos; - while (pos < end) { - const ch = sourceFile.text.charCodeAt(pos); - - // at line break, set this comment line text and go to next line - if (isLineBreak(ch)) { - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - paramHelpString = ""; - blankLineCount = 0; - recordedParamTag = true; - } - else if (recordedParamTag) { - blankLineCount++; - } - - // Get the pos after cleaning start of the line - setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos); - continue; - } - - // Done scanning param help string - next tag found - if (ch === CharacterCodes.at) { - break; - } - - paramHelpString += sourceFile.text.charAt(pos); - - // Go to next character - pos++; - } - - // If there is param help text, add it top the doc comments - if (paramHelpString) { - pushDocCommentLineText(paramDocComments, paramHelpString, blankLineCount); - } - paramHelpStringMargin = undefined; - } - - // If this is the start of another tag, continue with the loop in search of param tag with symbol name - if (sourceFile.text.charCodeAt(pos) === CharacterCodes.at) { - continue; - } - } - - // Next character - pos++; - } - - return paramDocComments; - - function consumeWhiteSpaces(pos: number) { - while (pos < end && isWhiteSpaceSingleLine(sourceFile.text.charCodeAt(pos))) { - pos++; - } - - return pos; - } - - function setPosForParamHelpStringOnNextLine(firstLineParamHelpStringPos: number) { - // Get the pos after consuming line breaks - pos = consumeLineBreaks(pos, end, sourceFile); - if (pos >= end) { - return; - } - - if (paramHelpStringMargin === undefined) { - paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character; - } - - // Now consume white spaces max - const startOfLinePos = pos; - pos = consumeWhiteSpacesOnTheLine(pos, end, sourceFile, paramHelpStringMargin); - if (pos >= end) { - return; - } - - const consumedSpaces = pos - startOfLinePos; - if (consumedSpaces < paramHelpStringMargin) { - const ch = sourceFile.text.charCodeAt(pos); - if (ch === CharacterCodes.asterisk) { - // Consume more spaces after asterisk - pos = consumeWhiteSpacesOnTheLine(pos + 1, end, sourceFile, paramHelpStringMargin - consumedSpaces - 1); - } + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ + export function forEachUnique(array: T[], callback: (element: T, index: number) => U): U { + if (array) { + for (let i = 0, len = array.length; i < len; i++) { + if (indexOf(array, array[i]) === i) { + const result = callback(array[i], i); + if (result) { + return result; } } } } + return undefined; } class TypeObject implements Type { @@ -7498,9 +7197,9 @@ namespace ts { // See if this is a doc comment. If so, we'll classify certain portions of it // specially. const docCommentAndDiagnostics = parseIsolatedJSDocComment(sourceFile.text, start, width); - if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDocComment) { - docCommentAndDiagnostics.jsDocComment.parent = token; - classifyJSDocComment(docCommentAndDiagnostics.jsDocComment); + if (docCommentAndDiagnostics && docCommentAndDiagnostics.jsDoc) { + docCommentAndDiagnostics.jsDoc.parent = token; + classifyJSDocComment(docCommentAndDiagnostics.jsDoc); return; } } @@ -7513,22 +7212,22 @@ namespace ts { pushClassification(start, width, ClassificationType.comment); } - function classifyJSDocComment(docComment: JSDocComment) { + function classifyJSDocComment(docComment: JSDoc) { let pos = docComment.pos; + if (docComment.tags) { + for (const tag of docComment.tags) { + // As we walk through each tag, classify the portion of text from the end of + // the last tag (or the start of the entire doc comment) as 'comment'. + if (tag.pos !== pos) { + pushCommentRange(pos, tag.pos - pos); + } - for (const tag of docComment.tags) { - // As we walk through each tag, classify the portion of text from the end of - // the last tag (or the start of the entire doc comment) as 'comment'. - if (tag.pos !== pos) { - pushCommentRange(pos, tag.pos - pos); - } + pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, ClassificationType.punctuation); + pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, ClassificationType.docCommentTagName); - pushClassification(tag.atToken.pos, tag.atToken.end - tag.atToken.pos, ClassificationType.punctuation); - pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, ClassificationType.docCommentTagName); + pos = tag.tagName.end; - pos = tag.tagName.end; - - switch (tag.kind) { + switch (tag.kind) { case SyntaxKind.JSDocParameterTag: processJSDocParameterTag(tag); break; @@ -7541,9 +7240,10 @@ namespace ts { case SyntaxKind.JSDocReturnTag: processElement((tag).typeExpression); break; - } + } - pos = tag.end; + pos = tag.end; + } } if (pos !== docComment.end) { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 9b3469643ba..4ceecb4bf50 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -569,9 +569,11 @@ namespace ts { if (node) { if (node.jsDocComments) { for (const jsDocComment of node.jsDocComments) { - for (const tag of jsDocComment.tags) { - if (tag.pos <= position && position <= tag.end) { - return tag; + if (jsDocComment.tags) { + for (const tag of jsDocComment.tags) { + if (tag.pos <= position && position <= tag.end) { + return tag; + } } } } @@ -946,4 +948,4 @@ namespace ts { } return { configJsonObject, diagnostics }; } -} \ No newline at end of file +} From 22ba111e661879978b990645d6267fc4180ea1da Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 1 Sep 2016 09:25:20 -0700 Subject: [PATCH 312/508] Search for `node_modules` in parent directories when getting type roots. --- src/compiler/program.ts | 33 +++++++++++++--- ...peRootsFromNodeModulesInParentDirectory.js | 17 ++++++++ ...tsFromNodeModulesInParentDirectory.symbols | 14 +++++++ ...romNodeModulesInParentDirectory.trace.json | 39 +++++++++++++++++++ ...ootsFromNodeModulesInParentDirectory.types | 14 +++++++ ...peRootsFromNodeModulesInParentDirectory.ts | 15 +++++++ 6 files changed, 126 insertions(+), 6 deletions(-) create mode 100644 tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.js create mode 100644 tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.symbols create mode 100644 tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json create mode 100644 tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types create mode 100644 tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 49f61981d72..7a4adf9ff08 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -8,8 +8,6 @@ namespace ts { const emptyArray: any[] = []; - const defaultTypeRoots = ["node_modules/@types"]; - export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean): string { while (true) { const fileName = combinePaths(searchPath, "tsconfig.json"); @@ -168,7 +166,7 @@ namespace ts { const typeReferenceExtensions = [".d.ts"]; - function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost) { + function getEffectiveTypeRoots(options: CompilerOptions, host: ModuleResolutionHost): string[] | undefined { if (options.typeRoots) { return options.typeRoots; } @@ -181,10 +179,33 @@ namespace ts { currentDirectory = host.getCurrentDirectory(); } - if (!currentDirectory) { - return undefined; + return currentDirectory && getDefaultTypeRoots(currentDirectory, host); + } + + function getDefaultTypeRoots(currentDirectory: string, host: ModuleResolutionHost): string[] | undefined { + const nodeModules = getNearestNodeModules(currentDirectory, host); + return nodeModules && [combinePaths(nodeModules, "@types")]; + } + + function getNearestNodeModules(currentDirectory: string, host: ModuleResolutionHost): string | undefined { + if (!host.directoryExists) { + return combinePaths(currentDirectory, "node_modules"); + // And if it doesn't exist, tough. + } + + while (true) { + const nodeModules = combinePaths(currentDirectory, "node_modules"); + if (host.directoryExists(nodeModules)) { + return nodeModules; + } + else { + const parent = getDirectoryPath(currentDirectory); + if (parent === currentDirectory) { + return undefined; + } + currentDirectory = parent; + } } - return map(defaultTypeRoots, d => combinePaths(currentDirectory, d)); } /** diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.js b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.js new file mode 100644 index 00000000000..9e93755d1f0 --- /dev/null +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.js @@ -0,0 +1,17 @@ +//// [tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts] //// + +//// [index.d.ts] + +declare module "xyz" { + export const x: number; +} + +//// [a.ts] +import { x } from "xyz"; +x; + + +//// [a.js] +"use strict"; +var xyz_1 = require("xyz"); +xyz_1.x; diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.symbols b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.symbols new file mode 100644 index 00000000000..10cbdaa3c53 --- /dev/null +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.symbols @@ -0,0 +1,14 @@ +=== /src/a.ts === +import { x } from "xyz"; +>x : Symbol(x, Decl(a.ts, 0, 8)) + +x; +>x : Symbol(x, Decl(a.ts, 0, 8)) + +=== /node_modules/@types/foo/index.d.ts === + +declare module "xyz" { + export const x: number; +>x : Symbol(x, Decl(index.d.ts, 2, 16)) +} + diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json new file mode 100644 index 00000000000..7782ffc4ebf --- /dev/null +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.trace.json @@ -0,0 +1,39 @@ +[ + "======== Resolving module 'xyz' from '/src/a.ts'. ========", + "Module resolution kind is not specified, using 'NodeJs'.", + "Loading module 'xyz' from 'node_modules' folder.", + "File '/src/node_modules/xyz.ts' does not exist.", + "File '/src/node_modules/xyz.tsx' does not exist.", + "File '/src/node_modules/xyz.d.ts' does not exist.", + "File '/src/node_modules/xyz/package.json' does not exist.", + "File '/src/node_modules/xyz/index.ts' does not exist.", + "File '/src/node_modules/xyz/index.tsx' does not exist.", + "File '/src/node_modules/xyz/index.d.ts' does not exist.", + "File '/src/node_modules/@types/xyz.ts' does not exist.", + "File '/src/node_modules/@types/xyz.tsx' does not exist.", + "File '/src/node_modules/@types/xyz.d.ts' does not exist.", + "File '/src/node_modules/@types/xyz/package.json' does not exist.", + "File '/src/node_modules/@types/xyz/index.ts' does not exist.", + "File '/src/node_modules/@types/xyz/index.tsx' does not exist.", + "File '/src/node_modules/@types/xyz/index.d.ts' does not exist.", + "File '/node_modules/xyz.ts' does not exist.", + "File '/node_modules/xyz.tsx' does not exist.", + "File '/node_modules/xyz.d.ts' does not exist.", + "File '/node_modules/xyz/package.json' does not exist.", + "File '/node_modules/xyz/index.ts' does not exist.", + "File '/node_modules/xyz/index.tsx' does not exist.", + "File '/node_modules/xyz/index.d.ts' does not exist.", + "File '/node_modules/@types/xyz.ts' does not exist.", + "File '/node_modules/@types/xyz.tsx' does not exist.", + "File '/node_modules/@types/xyz.d.ts' does not exist.", + "File '/node_modules/@types/xyz/package.json' does not exist.", + "File '/node_modules/@types/xyz/index.ts' does not exist.", + "File '/node_modules/@types/xyz/index.tsx' does not exist.", + "File '/node_modules/@types/xyz/index.d.ts' does not exist.", + "======== Module name 'xyz' was not resolved. ========", + "======== Resolving type reference directive 'foo', containing file '/src/__inferred type names__.ts', root directory '/node_modules/@types'. ========", + "Resolving with primary search path '/node_modules/@types'", + "File '/node_modules/@types/foo/package.json' does not exist.", + "File '/node_modules/@types/foo/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'foo' was successfully resolved to '/node_modules/@types/foo/index.d.ts', primary: true. ========" +] \ No newline at end of file diff --git a/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types new file mode 100644 index 00000000000..532a05fcb87 --- /dev/null +++ b/tests/baselines/reference/typeRootsFromNodeModulesInParentDirectory.types @@ -0,0 +1,14 @@ +=== /src/a.ts === +import { x } from "xyz"; +>x : number + +x; +>x : number + +=== /node_modules/@types/foo/index.d.ts === + +declare module "xyz" { + export const x: number; +>x : number +} + diff --git a/tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts b/tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts new file mode 100644 index 00000000000..59b7d6a3188 --- /dev/null +++ b/tests/cases/compiler/typeRootsFromNodeModulesInParentDirectory.ts @@ -0,0 +1,15 @@ +// @noImplicitReferences: true +// @traceResolution: true +// @currentDirectory: /src + +// @Filename: /node_modules/@types/foo/index.d.ts +declare module "xyz" { + export const x: number; +} + +// @Filename: /src/a.ts +import { x } from "xyz"; +x; + +// @Filename: /src/tsconfig.json +{} From b14d7c7ebb1aeee3074fa0c9ee2d42b0d964232e Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 1 Sep 2016 09:25:49 -0700 Subject: [PATCH 313/508] Add more jsdoc tests --- tests/cases/conformance/jsdoc/returns.ts | 9 ++++++++ .../fourslash/jsDocFunctionSignatures10.ts | 15 +++++++++++++ .../fourslash/jsDocFunctionSignatures11.ts | 9 ++++++++ .../fourslash/jsDocFunctionSignatures12.ts | 13 +++++++++++ .../fourslash/jsDocFunctionSignatures2.ts | 2 +- .../fourslash/jsDocFunctionSignatures5.ts | 18 +++++++++++++++ .../fourslash/jsDocFunctionSignatures6.ts | 19 ++++++++++++++++ .../fourslash/jsDocFunctionSignatures7.ts | 16 ++++++++++++++ .../fourslash/jsDocFunctionSignatures8.ts | 16 ++++++++++++++ .../fourslash/jsDocFunctionSignatures9.ts | 22 +++++++++++++++++++ tests/cases/fourslash/jsdocReturnsTag.ts | 17 ++++++++++++++ 11 files changed, 155 insertions(+), 1 deletion(-) create mode 100644 tests/cases/conformance/jsdoc/returns.ts create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures10.ts create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures11.ts create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures12.ts create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures5.ts create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures6.ts create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures7.ts create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures8.ts create mode 100644 tests/cases/fourslash/jsDocFunctionSignatures9.ts create mode 100644 tests/cases/fourslash/jsdocReturnsTag.ts diff --git a/tests/cases/conformance/jsdoc/returns.ts b/tests/cases/conformance/jsdoc/returns.ts new file mode 100644 index 00000000000..72cb4a6cb67 --- /dev/null +++ b/tests/cases/conformance/jsdoc/returns.ts @@ -0,0 +1,9 @@ +// @allowJs: true +// @filename: returns.js +// @out: dummy.js +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return ""; +} diff --git a/tests/cases/fourslash/jsDocFunctionSignatures10.ts b/tests/cases/fourslash/jsDocFunctionSignatures10.ts new file mode 100644 index 00000000000..60810c46e70 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures10.ts @@ -0,0 +1,15 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * Do some foo things +//// * @template T A Foolish template +//// * @param {T} x a parameter +//// */ +////function foo(x) { +////} +//// +////fo/**/o() + +goTo.marker(); +verify.quickInfoIs("function foo(x: T): void", "Do some foo things"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures11.ts b/tests/cases/fourslash/jsDocFunctionSignatures11.ts new file mode 100644 index 00000000000..26b2cda6d2a --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures11.ts @@ -0,0 +1,9 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @type {{ [name: string]: string; }} variables +//// */ +////const vari/**/ables = {}; +goTo.marker(); +verify.quickInfoIs("const variables: {\n [name: string]: string;\n}"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures12.ts b/tests/cases/fourslash/jsDocFunctionSignatures12.ts new file mode 100644 index 00000000000..29a8ac4caeb --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures12.ts @@ -0,0 +1,13 @@ + +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {{ stringProp: string, +//// * numProp: number }} o +//// */ +////function f1(o) { +//// o/**/; +////} +goTo.marker(); +verify.quickInfoIs("(parameter) o: any"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures2.ts b/tests/cases/fourslash/jsDocFunctionSignatures2.ts index 174ea7d6560..e6430cba5bd 100644 --- a/tests/cases/fourslash/jsDocFunctionSignatures2.ts +++ b/tests/cases/fourslash/jsDocFunctionSignatures2.ts @@ -9,4 +9,4 @@ //// f6('', /**/false) goTo.marker(); -verify.currentSignatureHelpIs('f6(p0: string, p1?: boolean): number') +verify.currentSignatureHelpIs('f6(arg0: string, arg1?: boolean): number') diff --git a/tests/cases/fourslash/jsDocFunctionSignatures5.ts b/tests/cases/fourslash/jsDocFunctionSignatures5.ts new file mode 100644 index 00000000000..08d0da990bc --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures5.ts @@ -0,0 +1,18 @@ +/// +// @allowJs: true +// @Filename: Foo.js + +/////** +//// * Filters a path based on a regexp or glob pattern. +//// * @param {String} basePath The base path where the search will be performed. +//// * @param {String} pattern A string defining a regexp of a glob pattern. +//// * @param {String} type The search pattern type, can be a regexp or a glob. +//// * @param {Object} options A object containing options to the search. +//// * @return {Array} A list containing the filtered paths. +//// */ +////function pathFilter(basePath, pattern, type, options){ +//////... +////} +////pathFilter(/**/'foo', 'bar', 'baz', {}); +goTo.marker(); +verify.currentSignatureHelpDocCommentIs("Filters a path based on a regexp or glob pattern."); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures6.ts b/tests/cases/fourslash/jsDocFunctionSignatures6.ts new file mode 100644 index 00000000000..10b290d6d02 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures6.ts @@ -0,0 +1,19 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {string} p1 - A string param +//// * @param {string?} p2 - An optional param +//// * @param {string} [p3] - Another optional param +//// * @param {string} [p4="test"] - An optional param with a default value +//// */ +////function f1(p1, p2, p3, p4){} +////f1(/*1*/'foo', /*2*/'bar', /*3*/'baz', /*4*/'qux'); +goTo.marker('1'); +verify.currentParameterHelpArgumentDocCommentIs("- A string param"); +goTo.marker('2'); +verify.currentParameterHelpArgumentDocCommentIs("- An optional param "); +goTo.marker('3'); +verify.currentParameterHelpArgumentDocCommentIs("- Another optional param"); +goTo.marker('4'); +verify.currentParameterHelpArgumentDocCommentIs("- An optional param with a default value"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures7.ts b/tests/cases/fourslash/jsDocFunctionSignatures7.ts new file mode 100644 index 00000000000..6bbb8a34dcc --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures7.ts @@ -0,0 +1,16 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * @param {string} p0 +//// * @param {string} [p1] +//// */ +////function Test(p0, p1) { +//// this.P0 = p0; +//// this.P1 = p1; +////} +//// +//// +////var /**/test = new Test(""); +goTo.marker(); +verify.quickInfoIs('var test: {\n P0: string;\n P1: string;\n}'); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures8.ts b/tests/cases/fourslash/jsDocFunctionSignatures8.ts new file mode 100644 index 00000000000..3dbe38e34df --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures8.ts @@ -0,0 +1,16 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** +//// * Represents a person +//// * @constructor +//// * @param {string} name The name of the person +//// * @param {number} age The age of the person +//// */ +////function Person(name, age) { +//// this.name = name; +//// this.age = age; +////} +////var p = new Pers/**/on(); +goTo.marker(); +verify.quickInfoIs("function Person(name: string, age: number): void", "Represents a person"); diff --git a/tests/cases/fourslash/jsDocFunctionSignatures9.ts b/tests/cases/fourslash/jsDocFunctionSignatures9.ts new file mode 100644 index 00000000000..26361bfe106 --- /dev/null +++ b/tests/cases/fourslash/jsDocFunctionSignatures9.ts @@ -0,0 +1,22 @@ +/// +// @allowJs: true +// @Filename: Foo.js +/////** first line of the comment +//// +////third line */ +////function foo() {} +////foo/**/(); +goTo.marker(); +verify.verifyQuickInfoDisplayParts('function', + '', + { start: 63, length: 3 }, + [{"text": "function", "kind": "keyword"}, + {"text": " ", "kind": "space"}, + {"text": "foo", "kind": "functionName"}, + {"text": "(", "kind": "punctuation"}, + {"text": ")", "kind": "punctuation"}, + {"text": ":", "kind": "punctuation"}, + {"text": " ", "kind": "space"}, + {"text": "void", "kind": "keyword"} + ], + [{"text": "first line of the comment\n\nthird line ", "kind": "text"}]); diff --git a/tests/cases/fourslash/jsdocReturnsTag.ts b/tests/cases/fourslash/jsdocReturnsTag.ts new file mode 100644 index 00000000000..9203bd9e036 --- /dev/null +++ b/tests/cases/fourslash/jsdocReturnsTag.ts @@ -0,0 +1,17 @@ +/// +// @allowJs: true +// @Filename: dummy.js +/////** +//// * Find an item +//// * @template T +//// * @param {T[]} l +//// * @param {T} x +//// * @returns {?T} The names of the found item(s). +//// */ +////function find(l, x) { +////} +////find(''/**/); + +goTo.marker(); +verify.currentSignatureHelpIs("find(l: T[], x: T): T") +// There currently isn't a way to display the return tag comment From 2b9624672df3027af28f96741025ec3c3906d82c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 1 Sep 2016 09:26:44 -0700 Subject: [PATCH 314/508] Update/add baselines for jsdoc/emitter changes --- .../reference/arrowFunctionErrorSpan.js | 4 +- .../reference/augmentExportEquals1.js | 4 +- .../reference/augmentExportEquals1_1.js | 4 +- .../reference/augmentExportEquals2.js | 4 +- .../reference/augmentExportEquals2_1.js | 4 +- .../augmentedTypesExternalModule1.js | 2 +- ...ScopedFunctionDeclarationInStrictModule.js | 2 +- tests/baselines/reference/callOverloads1.js | 2 +- tests/baselines/reference/callOverloads2.js | 2 +- tests/baselines/reference/callOverloads3.js | 2 +- tests/baselines/reference/callOverloads4.js | 2 +- tests/baselines/reference/callOverloads5.js | 2 +- .../reference/collisionArgumentsFunction.js | 1 + .../collisionRestParameterFunction.js | 1 + .../collisionThisExpressionAndParameter.js | 1 + .../reference/commentInEmptyParameterList1.js | 2 +- ...mentOnParenthesizedExpressionOpenParen1.js | 2 +- .../commentsArgumentsOfCallExpression2.js | 2 +- tests/baselines/reference/commentsFunction.js | 4 +- tests/baselines/reference/commentsVarDecl.js | 6 +- .../reference/computedPropertyNames48_ES5.js | 4 +- .../reference/constructorOverloads1.js | 4 +- .../reference/constructorOverloads2.js | 4 +- .../reference/constructorOverloads3.js | 2 +- .../contextuallyTypingRestParameters.js | 4 +- .../declFileObjectLiteralWithAccessors.js | 4 +- .../declFileObjectLiteralWithOnlyGetter.js | 4 +- .../declFileObjectLiteralWithOnlySetter.js | 4 +- tests/baselines/reference/errorSupression1.js | 2 +- .../es6ImportDefaultBindingWithExport.js | 2 +- .../reference/es6ImportNameSpaceImportDts.js | 1 + .../es6ImportNameSpaceImportNoNamedExports.js | 1 + .../es6ImportNamedImportIdentifiersParsing.js | 1 + .../reference/es6modulekindWithES5Target10.js | 1 + ...rtSpecifierReferencingOuterDeclaration4.js | 1 + .../baselines/reference/genericConstraint3.js | 1 + ...ersAndIndexSignaturesFromDifferentBases.js | 1 + ...rsAndIndexSignaturesFromDifferentBases2.js | 1 + ...tedStringIndexersFromDifferentBaseTypes.js | 1 + ...edStringIndexersFromDifferentBaseTypes2.js | 1 + .../reference/jsxInvalidEsprimaTestSuite.js | 4 +- .../nonConflictingRecursiveBaseTypeMembers.js | 1 + .../objectTypesWithOptionalProperties2.js | 3 +- ...parseRegularExpressionMixedWithComments.js | 6 +- .../parserGreaterThanTokenAmbiguity10.js | 1 + .../parserGreaterThanTokenAmbiguity13.js | 2 +- .../parserGreaterThanTokenAmbiguity15.js | 1 + .../parserGreaterThanTokenAmbiguity18.js | 2 +- .../parserGreaterThanTokenAmbiguity20.js | 1 + .../parserGreaterThanTokenAmbiguity3.js | 2 +- .../parserGreaterThanTokenAmbiguity5.js | 1 + .../parserGreaterThanTokenAmbiguity8.js | 2 +- .../reference/parserSkippedTokens5.js | 2 +- .../reference/parserSkippedTokens7.js | 1 + .../reference/parserSkippedTokens8.js | 2 +- .../reference/parserSkippedTokens9.js | 1 + ...siveExportAssignmentAndFindAliasedType1.js | 2 +- ...siveExportAssignmentAndFindAliasedType2.js | 2 +- ...siveExportAssignmentAndFindAliasedType3.js | 2 +- ...siveExportAssignmentAndFindAliasedType4.js | 2 +- ...siveExportAssignmentAndFindAliasedType5.js | 2 +- ...siveExportAssignmentAndFindAliasedType6.js | 2 +- ...siveExportAssignmentAndFindAliasedType7.js | 2 +- tests/baselines/reference/returns.js | 16 ++++ tests/baselines/reference/returns.symbols | 10 +++ tests/baselines/reference/returns.types | 11 +++ .../thisInInvalidContextsExternalModule.js | 2 +- tests/baselines/reference/tsxParseTests2.js | 2 +- .../typeAliasDoesntMakeModuleInstantiated.js | 1 + tests/cases/fourslash/commentsClassMembers.ts | 89 +++++++++---------- .../cases/fourslash/commentsCommentParsing.ts | 54 +++++------ .../fourslash/commentsFunctionExpression.ts | 12 +-- .../fourslash/commentsLinePreservation.ts | 10 +-- tests/cases/fourslash/commentsModules.ts | 26 +++--- .../fourslash/getJavaScriptQuickInfo1.ts | 2 +- .../fourslash/getJavaScriptQuickInfo7.ts | 2 +- 76 files changed, 219 insertions(+), 161 deletions(-) create mode 100644 tests/baselines/reference/returns.js create mode 100644 tests/baselines/reference/returns.symbols create mode 100644 tests/baselines/reference/returns.types diff --git a/tests/baselines/reference/arrowFunctionErrorSpan.js b/tests/baselines/reference/arrowFunctionErrorSpan.js index 2557113e89b..3ead7ed3b31 100644 --- a/tests/baselines/reference/arrowFunctionErrorSpan.js +++ b/tests/baselines/reference/arrowFunctionErrorSpan.js @@ -83,7 +83,9 @@ f(// comment 1 // comment 2 function () { // comment 4 -}); +} + // comment 5 +); // body is not a block f(function (_) { return 1 + 2; }); diff --git a/tests/baselines/reference/augmentExportEquals1.js b/tests/baselines/reference/augmentExportEquals1.js index 98322c01a34..6f7aab92692 100644 --- a/tests/baselines/reference/augmentExportEquals1.js +++ b/tests/baselines/reference/augmentExportEquals1.js @@ -32,5 +32,5 @@ define(["require", "exports"], function (require, exports) { //// [file3.js] define(["require", "exports", "./file2"], function (require, exports) { "use strict"; - var a; // should not work -}); + var a; +}); // should not work diff --git a/tests/baselines/reference/augmentExportEquals1_1.js b/tests/baselines/reference/augmentExportEquals1_1.js index 08f032ff33f..70239663441 100644 --- a/tests/baselines/reference/augmentExportEquals1_1.js +++ b/tests/baselines/reference/augmentExportEquals1_1.js @@ -29,5 +29,5 @@ define(["require", "exports"], function (require, exports) { //// [file3.js] define(["require", "exports", "file2"], function (require, exports) { "use strict"; - var a; // should not work -}); + var a; +}); // should not work diff --git a/tests/baselines/reference/augmentExportEquals2.js b/tests/baselines/reference/augmentExportEquals2.js index fc373173e3c..b444c16b6fc 100644 --- a/tests/baselines/reference/augmentExportEquals2.js +++ b/tests/baselines/reference/augmentExportEquals2.js @@ -31,5 +31,5 @@ define(["require", "exports"], function (require, exports) { //// [file3.js] define(["require", "exports", "./file2"], function (require, exports) { "use strict"; - var a; // should not work -}); + var a; +}); // should not work diff --git a/tests/baselines/reference/augmentExportEquals2_1.js b/tests/baselines/reference/augmentExportEquals2_1.js index 9046157bb26..afa78d1d981 100644 --- a/tests/baselines/reference/augmentExportEquals2_1.js +++ b/tests/baselines/reference/augmentExportEquals2_1.js @@ -29,5 +29,5 @@ define(["require", "exports"], function (require, exports) { //// [file3.js] define(["require", "exports", "file2"], function (require, exports) { "use strict"; - var a; // should not work -}); + var a; +}); // should not work diff --git a/tests/baselines/reference/augmentedTypesExternalModule1.js b/tests/baselines/reference/augmentedTypesExternalModule1.js index 65525e8187e..01358a9e4af 100644 --- a/tests/baselines/reference/augmentedTypesExternalModule1.js +++ b/tests/baselines/reference/augmentedTypesExternalModule1.js @@ -13,4 +13,4 @@ define(["require", "exports"], function (require, exports) { c5.prototype.foo = function () { }; return c5; }()); -}); +}); // should be ok everywhere diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.js b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.js index d1a8091871c..6d460158478 100644 --- a/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.js +++ b/tests/baselines/reference/blockScopedFunctionDeclarationInStrictModule.js @@ -14,4 +14,4 @@ define(["require", "exports"], function (require, exports) { foo(); // ok } return foo; -}); +}); // not ok diff --git a/tests/baselines/reference/callOverloads1.js b/tests/baselines/reference/callOverloads1.js index 756a9099e44..d441deb41d7 100644 --- a/tests/baselines/reference/callOverloads1.js +++ b/tests/baselines/reference/callOverloads1.js @@ -22,7 +22,7 @@ var Foo = (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); } - Foo.prototype.bar1 = function () { }; + Foo.prototype.bar1 = function () { /*WScript.Echo("bar1");*/ }; return Foo; }()); function F1(a) { return a; } diff --git a/tests/baselines/reference/callOverloads2.js b/tests/baselines/reference/callOverloads2.js index b890ee8bde9..8db26c3b771 100644 --- a/tests/baselines/reference/callOverloads2.js +++ b/tests/baselines/reference/callOverloads2.js @@ -30,7 +30,7 @@ var Foo = (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); } - Foo.prototype.bar1 = function () { }; + Foo.prototype.bar1 = function () { /*WScript.Echo("bar1");*/ }; return Foo; }()); function F1(s) { return s; } // error diff --git a/tests/baselines/reference/callOverloads3.js b/tests/baselines/reference/callOverloads3.js index e5d678543c6..ee49f4b3297 100644 --- a/tests/baselines/reference/callOverloads3.js +++ b/tests/baselines/reference/callOverloads3.js @@ -23,7 +23,7 @@ var Foo = (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); } - Foo.prototype.bar1 = function () { }; + Foo.prototype.bar1 = function () { /*WScript.Echo("bar1");*/ }; return Foo; }()); //class Foo(s: String); diff --git a/tests/baselines/reference/callOverloads4.js b/tests/baselines/reference/callOverloads4.js index dfb274dfb6e..fa7a51ae8d1 100644 --- a/tests/baselines/reference/callOverloads4.js +++ b/tests/baselines/reference/callOverloads4.js @@ -23,7 +23,7 @@ var Foo = (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); } - Foo.prototype.bar1 = function () { }; + Foo.prototype.bar1 = function () { /*WScript.Echo("bar1");*/ }; return Foo; }()); var f1 = new Foo("hey"); diff --git a/tests/baselines/reference/callOverloads5.js b/tests/baselines/reference/callOverloads5.js index cf159d309b0..d95485f85d7 100644 --- a/tests/baselines/reference/callOverloads5.js +++ b/tests/baselines/reference/callOverloads5.js @@ -24,7 +24,7 @@ var Foo = (function () { function Foo(x) { // WScript.Echo("Constructor function has executed"); } - Foo.prototype.bar1 = function (a) { }; + Foo.prototype.bar1 = function (a) { /*WScript.Echo(a);*/ }; return Foo; }()); //class Foo(s: String); diff --git a/tests/baselines/reference/collisionArgumentsFunction.js b/tests/baselines/reference/collisionArgumentsFunction.js index 9ce4a5ab0e2..d59efc116ee 100644 --- a/tests/baselines/reference/collisionArgumentsFunction.js +++ b/tests/baselines/reference/collisionArgumentsFunction.js @@ -90,3 +90,4 @@ function f42(i) { function f4NoError(arguments) { var arguments; // No error } + // no codegen no error diff --git a/tests/baselines/reference/collisionRestParameterFunction.js b/tests/baselines/reference/collisionRestParameterFunction.js index 8660e8f5db0..a9e3f510fa1 100644 --- a/tests/baselines/reference/collisionRestParameterFunction.js +++ b/tests/baselines/reference/collisionRestParameterFunction.js @@ -63,3 +63,4 @@ function f4(_i) { } function f4NoError(_i) { } + // no codegen no error diff --git a/tests/baselines/reference/collisionThisExpressionAndParameter.js b/tests/baselines/reference/collisionThisExpressionAndParameter.js index bc15e4b56b5..a445c35295b 100644 --- a/tests/baselines/reference/collisionThisExpressionAndParameter.js +++ b/tests/baselines/reference/collisionThisExpressionAndParameter.js @@ -167,3 +167,4 @@ function f3(_this) { var _this = this; (function (x) { console.log(_this.x); }); } + // no code gen - no error diff --git a/tests/baselines/reference/commentInEmptyParameterList1.js b/tests/baselines/reference/commentInEmptyParameterList1.js index 8f4e13d82d6..09b34f93536 100644 --- a/tests/baselines/reference/commentInEmptyParameterList1.js +++ b/tests/baselines/reference/commentInEmptyParameterList1.js @@ -3,5 +3,5 @@ function foo(/** nothing */) { } //// [commentInEmptyParameterList1.js] -function foo() { +function foo( /** nothing */) { } diff --git a/tests/baselines/reference/commentOnParenthesizedExpressionOpenParen1.js b/tests/baselines/reference/commentOnParenthesizedExpressionOpenParen1.js index d014043dfe0..7a7c25a9b4c 100644 --- a/tests/baselines/reference/commentOnParenthesizedExpressionOpenParen1.js +++ b/tests/baselines/reference/commentOnParenthesizedExpressionOpenParen1.js @@ -7,4 +7,4 @@ var f: () => any; //// [commentOnParenthesizedExpressionOpenParen1.js] var j; var f; -(j = f()); +(/* Preserve */ j = f()); diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression2.js b/tests/baselines/reference/commentsArgumentsOfCallExpression2.js index a7065410ff4..f89e67ef3d8 100644 --- a/tests/baselines/reference/commentsArgumentsOfCallExpression2.js +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression2.js @@ -14,7 +14,7 @@ foo( function foo(/*c1*/ x, /*d1*/ y, /*e1*/ w) { } var a, b; foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); -foo(/*c3*/ function () { }, /*d2*/ function () { }, /*e2*/ a + b); +foo(/*c3*/ function () { }, /*d2*/ function () { }, /*e2*/ a + /*e3*/ b); foo(/*c3*/ function () { }, /*d3*/ function () { }, /*e3*/ (a + b)); foo( /*c4*/ function () { }, diff --git a/tests/baselines/reference/commentsFunction.js b/tests/baselines/reference/commentsFunction.js index 0ffb2714108..86978d7bdf7 100644 --- a/tests/baselines/reference/commentsFunction.js +++ b/tests/baselines/reference/commentsFunction.js @@ -74,8 +74,8 @@ var fooFunc = function FooFunctionValue(/** fooFunctionValue param */ b) { return b; }; /// lamdaFoo var comment -var lambdaFoo = function (/**param a*/ a, /**param b*/ b) { return a + b; }; -var lambddaNoVarComment = function (/**param a*/ a, /**param b*/ b) { return a * b; }; +var lambdaFoo = /** this is lambda comment*/ function (/**param a*/ a, /**param b*/ b) { return a + b; }; +var lambddaNoVarComment = /** this is lambda multiplication*/ function (/**param a*/ a, /**param b*/ b) { return a * b; }; lambdaFoo(10, 20); lambddaNoVarComment(10, 20); function blah(a /* multiline trailing comment diff --git a/tests/baselines/reference/commentsVarDecl.js b/tests/baselines/reference/commentsVarDecl.js index 5ff2a3c1c6a..e9b6776a6d9 100644 --- a/tests/baselines/reference/commentsVarDecl.js +++ b/tests/baselines/reference/commentsVarDecl.js @@ -64,13 +64,13 @@ x = myVariable; /** jsdocstyle comment - only this comment should be in .d.ts file*/ var n = 30; /** var deckaration with comment on type as well*/ -var y = 20; +var y = /** value comment */ 20; /// var deckaration with comment on type as well var yy = /// value comment 20; /** comment2 */ -var z = function (x, y) { return x + y; }; +var z = /** lambda comment */ function (x, y) { return x + y; }; var z2; var x2 = z2; var n4; @@ -98,6 +98,6 @@ declare var y: number; declare var yy: number; /** comment2 */ declare var z: (x: number, y: number) => number; -declare var z2: (x: number) => string; +declare var z2: /** type comment*/ (x: number) => string; declare var x2: (x: number) => string; declare var n4: (x: number) => string; diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.js b/tests/baselines/reference/computedPropertyNames48_ES5.js index 15123a98f30..f2610b7272a 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.js +++ b/tests/baselines/reference/computedPropertyNames48_ES5.js @@ -34,5 +34,5 @@ extractIndexer((_b = {}, extractIndexer((_c = {}, _c["" || 0] = "", _c -)); // Should return any (widened form of undefined) -var _a, _b, _c; +)); +var _a, _b, _c; // Should return any (widened form of undefined) diff --git a/tests/baselines/reference/constructorOverloads1.js b/tests/baselines/reference/constructorOverloads1.js index 47906974f6e..d62cb9530c5 100644 --- a/tests/baselines/reference/constructorOverloads1.js +++ b/tests/baselines/reference/constructorOverloads1.js @@ -25,8 +25,8 @@ f1.bar2(); var Foo = (function () { function Foo(x) { } - Foo.prototype.bar1 = function () { }; - Foo.prototype.bar2 = function () { }; + Foo.prototype.bar1 = function () { /*WScript.Echo("bar1");*/ }; + Foo.prototype.bar2 = function () { /*WScript.Echo("bar1");*/ }; return Foo; }()); var f1 = new Foo("hey"); diff --git a/tests/baselines/reference/constructorOverloads2.js b/tests/baselines/reference/constructorOverloads2.js index 76481ec1bc6..e8d11af4056 100644 --- a/tests/baselines/reference/constructorOverloads2.js +++ b/tests/baselines/reference/constructorOverloads2.js @@ -34,7 +34,7 @@ var __extends = (this && this.__extends) || function (d, b) { var FooBase = (function () { function FooBase(x) { } - FooBase.prototype.bar1 = function () { }; + FooBase.prototype.bar1 = function () { /*WScript.Echo("base bar1");*/ }; return FooBase; }()); var Foo = (function (_super) { @@ -42,7 +42,7 @@ var Foo = (function (_super) { function Foo(x, y) { _super.call(this, x); } - Foo.prototype.bar1 = function () { }; + Foo.prototype.bar1 = function () { /*WScript.Echo("bar1");*/ }; return Foo; }(FooBase)); var f1 = new Foo("hey"); diff --git a/tests/baselines/reference/constructorOverloads3.js b/tests/baselines/reference/constructorOverloads3.js index 61f0d50db03..7cc27fd5b42 100644 --- a/tests/baselines/reference/constructorOverloads3.js +++ b/tests/baselines/reference/constructorOverloads3.js @@ -32,7 +32,7 @@ var Foo = (function (_super) { __extends(Foo, _super); function Foo(x, y) { } - Foo.prototype.bar1 = function () { }; + Foo.prototype.bar1 = function () { /*WScript.Echo("Yo");*/ }; return Foo; }(FooBase)); var f1 = new Foo("hey"); diff --git a/tests/baselines/reference/contextuallyTypingRestParameters.js b/tests/baselines/reference/contextuallyTypingRestParameters.js index 17561f5d7fc..48589ade408 100644 --- a/tests/baselines/reference/contextuallyTypingRestParameters.js +++ b/tests/baselines/reference/contextuallyTypingRestParameters.js @@ -9,9 +9,9 @@ var x: (...y: string[]) => void = function (.../*3*/y) { //// [contextuallyTypingRestParameters.js] var x = function () { - var y = []; + var /*3*/ y = []; for (var _i = 0; _i < arguments.length; _i++) { - y[_i - 0] = arguments[_i]; + /*3*/ y[_i - 0] = arguments[_i]; } var t = y; var x2 = t; // This should be error diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.js b/tests/baselines/reference/declFileObjectLiteralWithAccessors.js index 7886736f7e4..adc185e269f 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.js +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.js @@ -12,7 +12,7 @@ var /*2*/x = point.x; point./*3*/x = 30; //// [declFileObjectLiteralWithAccessors.js] -function makePoint(x) { +function /*1*/ makePoint(x) { return { b: 10, get x() { return x; }, @@ -22,7 +22,7 @@ function makePoint(x) { ; var /*4*/ point = makePoint(2); var /*2*/ x = point.x; -point.x = 30; +point./*3*/ x = 30; //// [declFileObjectLiteralWithAccessors.d.ts] diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js b/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js index eb440c028d5..96b4de87bef 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.js @@ -10,14 +10,14 @@ var /*2*/x = point./*3*/x; //// [declFileObjectLiteralWithOnlyGetter.js] -function makePoint(x) { +function /*1*/ makePoint(x) { return { get x() { return x; }, }; } ; var /*4*/ point = makePoint(2); -var /*2*/ x = point.x; +var /*2*/ x = point./*3*/ x; //// [declFileObjectLiteralWithOnlyGetter.d.ts] diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js index f7a48fe810c..44b28a9bdb2 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.js @@ -10,7 +10,7 @@ var /*3*/point = makePoint(2); point./*2*/x = 30; //// [declFileObjectLiteralWithOnlySetter.js] -function makePoint(x) { +function /*1*/ makePoint(x) { return { b: 10, set x(a) { this.b = a; } @@ -18,7 +18,7 @@ function makePoint(x) { } ; var /*3*/ point = makePoint(2); -point.x = 30; +point./*2*/ x = 30; //// [declFileObjectLiteralWithOnlySetter.d.ts] diff --git a/tests/baselines/reference/errorSupression1.js b/tests/baselines/reference/errorSupression1.js index 77545131ce3..285aa525b5f 100644 --- a/tests/baselines/reference/errorSupression1.js +++ b/tests/baselines/reference/errorSupression1.js @@ -18,4 +18,4 @@ var Foo = (function () { var baz = Foo.b; // Foo.b won't bind. baz.concat("y"); -// So we don't want an error on 'concat'. + // So we don't want an error on 'concat'. diff --git a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js index cc90d280914..1e6f49e2414 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingWithExport.js +++ b/tests/baselines/reference/es6ImportDefaultBindingWithExport.js @@ -21,7 +21,7 @@ define(["require", "exports"], function (require, exports) { define(["require", "exports", "server"], function (require, exports, server_1) { "use strict"; exports.x = server_1.default; -}); +}); // non referenced //// [server.d.ts] diff --git a/tests/baselines/reference/es6ImportNameSpaceImportDts.js b/tests/baselines/reference/es6ImportNameSpaceImportDts.js index cf66c08331e..0b522776c4b 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportDts.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportDts.js @@ -22,6 +22,7 @@ exports.c = c; "use strict"; var nameSpaceBinding = require("./server"); exports.x = new nameSpaceBinding.c(); + // unreferenced //// [server.d.ts] diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js index 8ece816fd3b..79c588dc277 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.js @@ -14,3 +14,4 @@ var a = 10; module.exports = a; //// [es6ImportNameSpaceImportNoNamedExports_1.js] "use strict"; + // error diff --git a/tests/baselines/reference/es6ImportNamedImportIdentifiersParsing.js b/tests/baselines/reference/es6ImportNamedImportIdentifiersParsing.js index 8db7fcd6f9c..a9a843f3cc9 100644 --- a/tests/baselines/reference/es6ImportNamedImportIdentifiersParsing.js +++ b/tests/baselines/reference/es6ImportNamedImportIdentifiersParsing.js @@ -7,3 +7,4 @@ import { default as yield } from "somemodule"; // no error import { default as default } from "somemodule"; // default as is ok, error of default binding name //// [es6ImportNamedImportIdentifiersParsing.js] + // default as is ok, error of default binding name diff --git a/tests/baselines/reference/es6modulekindWithES5Target10.js b/tests/baselines/reference/es6modulekindWithES5Target10.js index b8a66241780..015a64c3bc0 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target10.js +++ b/tests/baselines/reference/es6modulekindWithES5Target10.js @@ -8,3 +8,4 @@ namespace N { export = N; // Error //// [es6modulekindWithES5Target10.js] + // Error diff --git a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js index 1badf469996..1b8e4dd5c4b 100644 --- a/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js +++ b/tests/baselines/reference/exportSpecifierReferencingOuterDeclaration4.js @@ -12,3 +12,4 @@ export declare function bar(): X.bar; // error //// [exportSpecifierReferencingOuterDeclaration2_A.js] //// [exportSpecifierReferencingOuterDeclaration2_B.js] "use strict"; + // error diff --git a/tests/baselines/reference/genericConstraint3.js b/tests/baselines/reference/genericConstraint3.js index 59548c4f4d7..657600ba41a 100644 --- a/tests/baselines/reference/genericConstraint3.js +++ b/tests/baselines/reference/genericConstraint3.js @@ -4,3 +4,4 @@ interface A> { x: U; } interface B extends A<{}, { x: {} }> { } // Should not produce an error //// [genericConstraint3.js] + // Should not produce an error diff --git a/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases.js b/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases.js index f4ea5f07eb9..26ef7ca7759 100644 --- a/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases.js +++ b/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases.js @@ -28,3 +28,4 @@ interface G extends A, B, C, E { } // should only report one error interface H extends A, F { } // Should report no error at all because error is internal to F //// [inheritedMembersAndIndexSignaturesFromDifferentBases.js] + // Should report no error at all because error is internal to F diff --git a/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases2.js b/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases2.js index 8a3b2f8d032..9291ab53c1c 100644 --- a/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases2.js +++ b/tests/baselines/reference/inheritedMembersAndIndexSignaturesFromDifferentBases2.js @@ -10,3 +10,4 @@ interface B { interface C extends B, A { } // Should succeed //// [inheritedMembersAndIndexSignaturesFromDifferentBases2.js] + // Should succeed diff --git a/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes.js b/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes.js index 1645dd10a55..c7a008f01fb 100644 --- a/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes.js +++ b/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes.js @@ -29,3 +29,4 @@ interface D2 { interface E2 extends A2, D2 { } // error //// [inheritedStringIndexersFromDifferentBaseTypes.js] + // error diff --git a/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes2.js b/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes2.js index aa837b5cf2e..0580b145901 100644 --- a/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes2.js +++ b/tests/baselines/reference/inheritedStringIndexersFromDifferentBaseTypes2.js @@ -25,3 +25,4 @@ interface F extends A, D { } // ok because we overrode D's number index signature //// [inheritedStringIndexersFromDifferentBaseTypes2.js] + // ok because we overrode D's number index signature diff --git a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js index 7f01666bd78..85d0d3687be 100644 --- a/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js +++ b/tests/baselines/reference/jsxInvalidEsprimaTestSuite.js @@ -62,7 +62,7 @@ a['foo'] > ;
; ; var x =
one
two
;; -var x =
one
/* intervening comment */ /* intervening comment */
two
;; +var x =
one
/* intervening comment */ /* intervening comment */
two
;;
{"str"}}; id="b" />;
>; @@ -76,4 +76,4 @@ var x =
one
/* intervening comment */ /* intervening comment */
; ; }; - /*hai*//*hai*/asdf/>;; +/*hai*/ /*hai*/asdf/>;; diff --git a/tests/baselines/reference/nonConflictingRecursiveBaseTypeMembers.js b/tests/baselines/reference/nonConflictingRecursiveBaseTypeMembers.js index 6e77029fa94..9663da873b8 100644 --- a/tests/baselines/reference/nonConflictingRecursiveBaseTypeMembers.js +++ b/tests/baselines/reference/nonConflictingRecursiveBaseTypeMembers.js @@ -10,3 +10,4 @@ interface B { interface C extends A, B { } // Should not be an error //// [nonConflictingRecursiveBaseTypeMembers.js] + // Should not be an error diff --git a/tests/baselines/reference/objectTypesWithOptionalProperties2.js b/tests/baselines/reference/objectTypesWithOptionalProperties2.js index eabb1a153a6..28470e04983 100644 --- a/tests/baselines/reference/objectTypesWithOptionalProperties2.js +++ b/tests/baselines/reference/objectTypesWithOptionalProperties2.js @@ -42,6 +42,5 @@ var C2 = (function () { return C2; }()); var b = { - x: function () { }, 1: // error - // error + x: function () { }, 1: // error }; diff --git a/tests/baselines/reference/parseRegularExpressionMixedWithComments.js b/tests/baselines/reference/parseRegularExpressionMixedWithComments.js index 78752a77f75..0ef42cf2ce1 100644 --- a/tests/baselines/reference/parseRegularExpressionMixedWithComments.js +++ b/tests/baselines/reference/parseRegularExpressionMixedWithComments.js @@ -8,7 +8,7 @@ var regex5 = /**// asdf/**/ /; //// [parseRegularExpressionMixedWithComments.js] var regex1 = / asdf /; -var regex2 = / asdf /; +var regex2 = /**/ / asdf /; var regex3 = 1; -var regex4 = Math.pow(/ /, /asdf /); -var regex5 = Math.pow(/ asdf/, / /); +var regex4 = /**/ Math.pow(/ /, /asdf /); +var regex5 = /**/ Math.pow(/ asdf/, / /); diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity10.js b/tests/baselines/reference/parserGreaterThanTokenAmbiguity10.js index 862722b1a73..eb76d7e0d7c 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity10.js +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity10.js @@ -6,5 +6,6 @@ //// [parserGreaterThanTokenAmbiguity10.js] 1 + // before >>> 2; diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity13.js b/tests/baselines/reference/parserGreaterThanTokenAmbiguity13.js index 49130a9dd13..5be4da1c04e 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity13.js +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity13.js @@ -2,5 +2,5 @@ 1 >>/**/= 2; //// [parserGreaterThanTokenAmbiguity13.js] -1 >> ; /**/ +1 >> /**/ ; 2; diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity15.js b/tests/baselines/reference/parserGreaterThanTokenAmbiguity15.js index b6f905e12e7..8fadea77fdc 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity15.js +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity15.js @@ -6,5 +6,6 @@ //// [parserGreaterThanTokenAmbiguity15.js] 1 + // before >>= 2; diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity18.js b/tests/baselines/reference/parserGreaterThanTokenAmbiguity18.js index 71527689b2c..4cf227f2748 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity18.js +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity18.js @@ -2,5 +2,5 @@ 1 >>>/**/= 2; //// [parserGreaterThanTokenAmbiguity18.js] -1 >>> ; /**/ +1 >>> /**/ ; 2; diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity20.js b/tests/baselines/reference/parserGreaterThanTokenAmbiguity20.js index 01d1d6401f2..ab86deeb0d2 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity20.js +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity20.js @@ -6,5 +6,6 @@ //// [parserGreaterThanTokenAmbiguity20.js] 1 + // Before >>>= 2; diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.js b/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.js index 79f8c139260..f692d1a6324 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.js +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.js @@ -2,4 +2,4 @@ 1 >/**/> 2; //// [parserGreaterThanTokenAmbiguity3.js] -1 > /**/ > 2; +1 > /**/ /**/ > 2; diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity5.js b/tests/baselines/reference/parserGreaterThanTokenAmbiguity5.js index c65b76f504a..24aa9e5316a 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity5.js +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity5.js @@ -6,5 +6,6 @@ //// [parserGreaterThanTokenAmbiguity5.js] 1 + // before >> 2; diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity8.js b/tests/baselines/reference/parserGreaterThanTokenAmbiguity8.js index 0006c03219a..d8ea6134a58 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity8.js +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity8.js @@ -2,4 +2,4 @@ 1 >>/**/> 2; //// [parserGreaterThanTokenAmbiguity8.js] -1 >> /**/ > 2; +1 >> /**/ /**/ > 2; diff --git a/tests/baselines/reference/parserSkippedTokens5.js b/tests/baselines/reference/parserSkippedTokens5.js index 359a98a5969..665db1ef70d 100644 --- a/tests/baselines/reference/parserSkippedTokens5.js +++ b/tests/baselines/reference/parserSkippedTokens5.js @@ -2,4 +2,4 @@ \ /*foo*/ ; //// [parserSkippedTokens5.js] -; +/*foo*/ ; diff --git a/tests/baselines/reference/parserSkippedTokens7.js b/tests/baselines/reference/parserSkippedTokens7.js index 2115614ea1f..b3aa40d9057 100644 --- a/tests/baselines/reference/parserSkippedTokens7.js +++ b/tests/baselines/reference/parserSkippedTokens7.js @@ -2,3 +2,4 @@ /*foo*/ \ /*bar*/ //// [parserSkippedTokens7.js] + /*bar*/ diff --git a/tests/baselines/reference/parserSkippedTokens8.js b/tests/baselines/reference/parserSkippedTokens8.js index c9f00f4b85b..d8433bbd34c 100644 --- a/tests/baselines/reference/parserSkippedTokens8.js +++ b/tests/baselines/reference/parserSkippedTokens8.js @@ -3,4 +3,4 @@ /*foo*/ \ /*bar*/ //// [parserSkippedTokens8.js] -; +; /*bar*/ diff --git a/tests/baselines/reference/parserSkippedTokens9.js b/tests/baselines/reference/parserSkippedTokens9.js index d693b99b2ea..cabf3a48e56 100644 --- a/tests/baselines/reference/parserSkippedTokens9.js +++ b/tests/baselines/reference/parserSkippedTokens9.js @@ -4,3 +4,4 @@ //// [parserSkippedTokens9.js] ; // existing trivia + /*bar*/ diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.js index d759bc2f296..96fff1f8f33 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType1.js @@ -29,4 +29,4 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType1_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; -}); +}); // This should result in type ClassB diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.js index 7704b38f68d..e8262c86b4f 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType2.js @@ -33,4 +33,4 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType2_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; -}); +}); // This should result in type ClassB diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.js index a46be3bdafc..39303b463ba 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType3.js @@ -37,4 +37,4 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType3_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; -}); +}); // This should result in type ClassB diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType4.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType4.js index 8ccd6ecf560..80a4408b10d 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType4.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType4.js @@ -31,4 +31,4 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType4_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; -}); +}); // This should result in type ClassB diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType5.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType5.js index 4602ed554e5..69f6ff07bd8 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType5.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType5.js @@ -40,4 +40,4 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType5_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; -}); +}); // This should result in type ClassB diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType6.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType6.js index d3487519218..277a8a168da 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType6.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType6.js @@ -49,4 +49,4 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType6_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; -}); +}); // This should result in type ClassB diff --git a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.js b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.js index 9a29c2bf949..fcab82802b2 100644 --- a/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.js +++ b/tests/baselines/reference/recursiveExportAssignmentAndFindAliasedType7.js @@ -51,4 +51,4 @@ define(["require", "exports"], function (require, exports) { //// [recursiveExportAssignmentAndFindAliasedType7_moduleA.js] define(["require", "exports"], function (require, exports) { "use strict"; -}); +}); // This should result in type ClassB diff --git a/tests/baselines/reference/returns.js b/tests/baselines/reference/returns.js new file mode 100644 index 00000000000..67390dea72a --- /dev/null +++ b/tests/baselines/reference/returns.js @@ -0,0 +1,16 @@ +//// [returns.js] +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return ""; +} + + +//// [dummy.js] +/** + * @returns {string} This comment is not currently exposed + */ +function f() { + return ""; +} diff --git a/tests/baselines/reference/returns.symbols b/tests/baselines/reference/returns.symbols new file mode 100644 index 00000000000..e0f0d4dac96 --- /dev/null +++ b/tests/baselines/reference/returns.symbols @@ -0,0 +1,10 @@ +=== tests/cases/conformance/jsdoc/returns.js === +/** + * @returns {string} This comment is not currently exposed + */ +function f() { +>f : Symbol(f, Decl(returns.js, 0, 0)) + + return ""; +} + diff --git a/tests/baselines/reference/returns.types b/tests/baselines/reference/returns.types new file mode 100644 index 00000000000..c1bb1637c45 --- /dev/null +++ b/tests/baselines/reference/returns.types @@ -0,0 +1,11 @@ +=== tests/cases/conformance/jsdoc/returns.js === +/** + * @returns {string} This comment is not currently exposed + */ +function f() { +>f : () => string + + return ""; +>"" : string +} + diff --git a/tests/baselines/reference/thisInInvalidContextsExternalModule.js b/tests/baselines/reference/thisInInvalidContextsExternalModule.js index 2e7e6d8b47c..00553a3fbba 100644 --- a/tests/baselines/reference/thisInInvalidContextsExternalModule.js +++ b/tests/baselines/reference/thisInInvalidContextsExternalModule.js @@ -107,4 +107,4 @@ var SomeEnum; SomeEnum[SomeEnum["A"] = this] = "A"; SomeEnum[SomeEnum["B"] = this.spaaaace] = "B"; // Also should not be allowed })(SomeEnum || (SomeEnum = {})); -module.exports = this; +module.exports = this; // Should be an error diff --git a/tests/baselines/reference/tsxParseTests2.js b/tests/baselines/reference/tsxParseTests2.js index b0cf54f8d1f..c09e9d2c3cb 100644 --- a/tests/baselines/reference/tsxParseTests2.js +++ b/tests/baselines/reference/tsxParseTests2.js @@ -8,4 +8,4 @@ var x =
; //// [file.jsx] -var x =
; +var x =
; diff --git a/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.js b/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.js index 861e20cb0d1..af2287ef27f 100644 --- a/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.js +++ b/tests/baselines/reference/typeAliasDoesntMakeModuleInstantiated.js @@ -11,3 +11,4 @@ declare module m { declare var m: m.IStatic; // Should be ok to have var 'm' as module is non instantiated //// [typeAliasDoesntMakeModuleInstantiated.js] + // Should be ok to have var 'm' as module is non instantiated diff --git a/tests/cases/fourslash/commentsClassMembers.ts b/tests/cases/fourslash/commentsClassMembers.ts index d719253a57b..481baee28af 100644 --- a/tests/cases/fourslash/commentsClassMembers.ts +++ b/tests/cases/fourslash/commentsClassMembers.ts @@ -8,11 +8,11 @@ //// public p/*3*/2(/** number to add*/b: number) { //// return this./*4*/p1 + /*5*/b; //// } -//// /** getter property*/ +//// /** getter property 1*/ //// public get p/*6*/3() { //// return this./*7*/p/*8q*/2(/*8*/this./*9*/p1); //// } -//// /** setter property*/ +//// /** setter property 1*/ //// public set p/*10*/3(/** this is value*/value: number) { //// this./*11*/p1 = this./*12*/p/*13q*/2(/*13*/value); //// } @@ -22,11 +22,11 @@ //// private p/*15*/p2(/** number to add*/b: number) { //// return this./*16*/p1 + /*17*/b; //// } -//// /** getter property*/ +//// /** getter property 2*/ //// private get p/*18*/p3() { //// return this./*19*/p/*20q*/p2(/*20*/this./*21*/pp1); //// } -//// /** setter property*/ +//// /** setter property 2*/ //// private set p/*22*/p3( /** this is value*/value: number) { //// this./*23*/pp1 = this./*24*/p/*25q*/p2(/*25*/value); //// } @@ -43,7 +43,7 @@ //// static get s/*32*/3() { //// return /*33*/c1./*34*/s/*35q*/2(/*35*/c1./*36*/s1); //// } -//// /** setter property*/ +//// /** setter property 3*/ //// static set s/*37*/3( /** this is value*/value: number) { //// /*38*/c1./*39*/s1 = /*40*/c1./*41*/s/*42q*/2(/*42*/value); //// } @@ -131,7 +131,6 @@ //// th/*116*/is./*114*/a = /*115*/a + 2 + bb/*117*/bb; //// } ////} - goTo.marker('1'); verify.quickInfoIs("class c1", "This is comment for c1"); @@ -144,10 +143,10 @@ verify.quickInfoIs("(method) c1.p2(b: number): number", "sum with property"); goTo.marker('4'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -159,15 +158,15 @@ goTo.marker('5'); verify.completionListContains("b", "(parameter) b: number", "number to add"); goTo.marker('6'); -verify.quickInfoIs("(property) c1.p3: number", "getter property\nsetter property"); +verify.quickInfoIs("(property) c1.p3: number", "getter property 1\nsetter property 1"); goTo.marker('7'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -184,10 +183,10 @@ verify.quickInfoIs("(method) c1.p2(b: number): number", "sum with property"); goTo.marker('9'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -196,15 +195,15 @@ verify.memberListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", "") verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); goTo.marker('10'); -verify.quickInfoIs("(property) c1.p3: number", "getter property\nsetter property"); +verify.quickInfoIs("(property) c1.p3: number", "getter property 1\nsetter property 1"); goTo.marker('11'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -215,10 +214,10 @@ verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); goTo.marker('12'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -242,10 +241,10 @@ verify.quickInfoIs("(method) c1.pp2(b: number): number", "sum with property"); goTo.marker('16'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -257,15 +256,15 @@ goTo.marker('17'); verify.completionListContains("b", "(parameter) b: number", "number to add"); goTo.marker('18'); -verify.quickInfoIs("(property) c1.pp3: number", "getter property\nsetter property"); +verify.quickInfoIs("(property) c1.pp3: number", "getter property 2\nsetter property 2"); goTo.marker('19'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -282,10 +281,10 @@ verify.quickInfoIs("(method) c1.pp2(b: number): number", "sum with property"); goTo.marker('21'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -294,15 +293,15 @@ verify.memberListContains("nc_pp2", "(method) c1.nc_pp2(b: number): number", "") verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); goTo.marker('22'); -verify.quickInfoIs("(property) c1.pp3: number", "getter property\nsetter property"); +verify.quickInfoIs("(property) c1.pp3: number", "getter property 2\nsetter property 2"); goTo.marker('23'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -313,10 +312,10 @@ verify.memberListContains("nc_pp3", "(property) c1.nc_pp3: number", ""); goTo.marker('24'); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("pp1", "(property) c1.pp1: number", "pp1 is property of c1"); verify.memberListContains("pp2", "(method) c1.pp2(b: number): number", "sum with property"); -verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property\nsetter property"); +verify.memberListContains("pp3", "(property) c1.pp3: number", "getter property 2\nsetter property 2"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -346,7 +345,7 @@ verify.completionListContains("c1", "class c1", "This is comment for c1"); goTo.marker('30'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -355,7 +354,7 @@ goTo.marker('31'); verify.completionListContains("b", "(parameter) b: number", "number to add"); goTo.marker('32'); -verify.quickInfoIs("(property) c1.s3: number", "static getter property\nsetter property"); +verify.quickInfoIs("(property) c1.s3: number", "static getter property\nsetter property 3"); goTo.marker('33'); verify.completionListContains("c1", "class c1", "This is comment for c1"); @@ -363,7 +362,7 @@ verify.completionListContains("c1", "class c1", "This is comment for c1"); goTo.marker('34'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -378,13 +377,13 @@ verify.quickInfoIs("(method) c1.s2(b: number): number", "static sum with propert goTo.marker('36'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); goTo.marker('37'); -verify.quickInfoIs("(property) c1.s3: number", "static getter property\nsetter property"); +verify.quickInfoIs("(property) c1.s3: number", "static getter property\nsetter property 3"); goTo.marker('38'); verify.completionListContains("c1", "class c1", "This is comment for c1"); @@ -392,7 +391,7 @@ verify.completionListContains("c1", "class c1", "This is comment for c1"); goTo.marker('39'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -403,7 +402,7 @@ verify.completionListContains("c1", "class c1", "This is comment for c1"); goTo.marker('41'); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -514,7 +513,7 @@ goTo.marker('67'); verify.quickInfoIs("(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p1", "(property) c1.p1: number", "p1 is property of c1"); verify.memberListContains("p2", "(method) c1.p2(b: number): number", "sum with property"); -verify.memberListContains("p3", "(property) c1.p3: number", "getter property\nsetter property"); +verify.memberListContains("p3", "(property) c1.p3: number", "getter property 1\nsetter property 1"); verify.memberListContains("nc_p1", "(property) c1.nc_p1: number", ""); verify.memberListContains("nc_p2", "(method) c1.nc_p2(b: number): number", ""); verify.memberListContains("nc_p3", "(property) c1.nc_p3: number", ""); @@ -537,9 +536,9 @@ verify.quickInfoIs("(method) c1.p2(b: number): number", "sum with property"); goTo.marker('72'); verify.quickInfoIs("var i1_prop: number", ""); goTo.marker('73'); -verify.quickInfoIs("(property) c1.p3: number", "getter property\nsetter property"); +verify.quickInfoIs("(property) c1.p3: number", "getter property 1\nsetter property 1"); goTo.marker('74'); -verify.quickInfoIs("(property) c1.p3: number", "getter property\nsetter property"); +verify.quickInfoIs("(property) c1.p3: number", "getter property 1\nsetter property 1"); goTo.marker('75'); verify.quickInfoIs("var i1_prop: number", ""); @@ -584,7 +583,7 @@ goTo.marker('88'); verify.quickInfoIs("(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s1", "(property) c1.s1: number", "s1 is static property of c1"); verify.memberListContains("s2", "(method) c1.s2(b: number): number", "static sum with property"); -verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property"); +verify.memberListContains("s3", "(property) c1.s3: number", "static getter property\nsetter property 3"); verify.memberListContains("nc_s1", "(property) c1.nc_s1: number", ""); verify.memberListContains("nc_s2", "(method) c1.nc_s2(b: number): number", ""); verify.memberListContains("nc_s3", "(property) c1.nc_s3: number", ""); @@ -607,9 +606,9 @@ verify.quickInfoIs("(method) c1.s2(b: number): number", "static sum with propert goTo.marker('93'); verify.quickInfoIs("var i1_s_prop: number", ""); goTo.marker('94'); -verify.quickInfoIs("(property) c1.s3: number", "static getter property\nsetter property"); +verify.quickInfoIs("(property) c1.s3: number", "static getter property\nsetter property 3"); goTo.marker('95'); -verify.quickInfoIs("(property) c1.s3: number", "static getter property\nsetter property"); +verify.quickInfoIs("(property) c1.s3: number", "static getter property\nsetter property 3"); goTo.marker('96'); verify.quickInfoIs("var i1_s_prop: number", ""); @@ -686,8 +685,8 @@ goTo.marker('113'); verify.quickInfoIs("(property) cProperties.nc_p1: number", ""); goTo.marker('114'); -verify.memberListContains("a", "(property) cWithConstructorProperty.a: number", "more info about a"); -verify.quickInfoIs("(property) cWithConstructorProperty.a: number", "more info about a"); +verify.memberListContains("a", "(property) cWithConstructorProperty.a: number", "this is first parameter a\nmore info about a"); +verify.quickInfoIs("(property) cWithConstructorProperty.a: number", "this is first parameter a\nmore info about a"); goTo.marker('115'); verify.completionListContains("a", "(parameter) a: number", "this is first parameter a\nmore info about a"); diff --git a/tests/cases/fourslash/commentsCommentParsing.ts b/tests/cases/fourslash/commentsCommentParsing.ts index f209f573e2f..a0a86cbc75c 100644 --- a/tests/cases/fourslash/commentsCommentParsing.ts +++ b/tests/cases/fourslash/commentsCommentParsing.ts @@ -48,7 +48,7 @@ ////} ////jsDocMi/*7q*/xedComments2(/*7*/); //// -/////** jsdoc comment */ /*** another jsDocComment*/ +/////** jsdoc comment */ /*** malformed jsDocComment*/ /////// Triple slash comment ////function jsDocMixedComments3() { ////} @@ -238,9 +238,9 @@ goTo.marker('7q'); verify.quickInfoIs("function jsDocMixedComments2(): void", "jsdoc comment \nanother jsDocComment"); goTo.marker('8'); -verify.currentSignatureHelpDocCommentIs("jsdoc comment \n* another jsDocComment"); +verify.currentSignatureHelpDocCommentIs("jsdoc comment "); goTo.marker('8q'); -verify.quickInfoIs("function jsDocMixedComments3(): void", "jsdoc comment \n* another jsDocComment"); +verify.quickInfoIs("function jsDocMixedComments3(): void", "jsdoc comment "); goTo.marker('9'); verify.currentSignatureHelpDocCommentIs("jsdoc comment \nanother jsDocComment"); @@ -295,33 +295,33 @@ verify.completionListContains("a", "(parameter) a: number", "first number"); verify.completionListContains("b", "(parameter) b: number", "second number"); goTo.marker('19'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); verify.currentParameterHelpArgumentDocCommentIs("first number"); goTo.marker('19q'); -verify.quickInfoIs("function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "This is multiplication function\n@anotherTag\n@anotherTag"); +verify.quickInfoIs("function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "This is multiplication function"); goTo.marker('19aq'); verify.quickInfoIs("(parameter) a: number", "first number"); goTo.marker('20'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); verify.currentParameterHelpArgumentDocCommentIs(""); goTo.marker('20aq'); verify.quickInfoIs("(parameter) b: number", ""); goTo.marker('21'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); -verify.currentParameterHelpArgumentDocCommentIs("{"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); +verify.currentParameterHelpArgumentDocCommentIs(""); goTo.marker('21aq'); -verify.quickInfoIs("(parameter) c: number", "{"); +verify.quickInfoIs("(parameter) c: number", ""); goTo.marker('22'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); verify.currentParameterHelpArgumentDocCommentIs(""); goTo.marker('22aq'); verify.quickInfoIs("(parameter) d: any", ""); goTo.marker('23'); -verify.currentSignatureHelpDocCommentIs("This is multiplication function\n@anotherTag\n@anotherTag"); +verify.currentSignatureHelpDocCommentIs("This is multiplication function"); verify.currentParameterHelpArgumentDocCommentIs("LastParam "); goTo.marker('23aq'); verify.quickInfoIs("(parameter) e: any", "LastParam "); @@ -347,65 +347,65 @@ goTo.marker('26aq'); verify.quickInfoIs("(parameter) b: string", ""); goTo.marker('27'); -verify.completionListContains("multiply", "function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "This is multiplication function\n@anotherTag\n@anotherTag"); +verify.completionListContains("multiply", "function multiply(a: number, b: number, c?: number, d?: any, e?: any): void", "This is multiplication function"); verify.completionListContains("f1", "function f1(a: number): any (+1 overload)", "fn f1 with number"); goTo.marker('28'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{()=>string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs(""); goTo.marker('28q'); -verify.quickInfoIs("function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", "This is subtract function"); +verify.quickInfoIs("function subtract(a: number, b: number, c?: () => string, d?: () => string, e?: () => string, f?: () => string): void", "This is subtract function{()=>string; } } f this is optional param f"); goTo.marker('28aq'); verify.quickInfoIs("(parameter) a: number", ""); goTo.marker('29'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{()=>string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs("this is about b"); goTo.marker('29aq'); verify.quickInfoIs("(parameter) b: number", "this is about b"); goTo.marker('30'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{()=>string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs("this is optional param c"); goTo.marker('30aq'); verify.quickInfoIs("(parameter) c: () => string", "this is optional param c"); goTo.marker('31'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); -verify.currentParameterHelpArgumentDocCommentIs(""); +verify.currentSignatureHelpDocCommentIs("This is subtract function{()=>string; } } f this is optional param f"); +verify.currentParameterHelpArgumentDocCommentIs("this is optional param d"); goTo.marker('31aq'); -verify.quickInfoIs("(parameter) d: () => string", ""); +verify.quickInfoIs("(parameter) d: () => string", "this is optional param d"); goTo.marker('32'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{()=>string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs("this is optional param e"); goTo.marker('32aq'); verify.quickInfoIs("(parameter) e: () => string", "this is optional param e"); goTo.marker('33'); -verify.currentSignatureHelpDocCommentIs("This is subtract function"); +verify.currentSignatureHelpDocCommentIs("This is subtract function{()=>string; } } f this is optional param f"); verify.currentParameterHelpArgumentDocCommentIs(""); goTo.marker('33aq'); verify.quickInfoIs("(parameter) f: () => string", ""); goTo.marker('34'); -verify.currentSignatureHelpDocCommentIs("this is square function\n@paramTag { number } a this is input number of paramTag\n@returnType { number } it is return type"); +verify.currentSignatureHelpDocCommentIs("this is square function"); verify.currentParameterHelpArgumentDocCommentIs("this is input number"); goTo.marker('34q'); -verify.quickInfoIs("function square(a: number): number", "this is square function\n@paramTag { number } a this is input number of paramTag\n@returnType { number } it is return type"); +verify.quickInfoIs("function square(a: number): number", "this is square function"); goTo.marker('34aq'); verify.quickInfoIs("(parameter) a: number", "this is input number"); goTo.marker('35'); -verify.currentSignatureHelpDocCommentIs("this is divide function\n@paramTag { number } g this is optional param g"); +verify.currentSignatureHelpDocCommentIs("this is divide function"); verify.currentParameterHelpArgumentDocCommentIs("this is a"); goTo.marker('35q'); -verify.quickInfoIs("function divide(a: number, b: number): void", "this is divide function\n@paramTag { number } g this is optional param g"); +verify.quickInfoIs("function divide(a: number, b: number): void", "this is divide function"); goTo.marker('35aq'); verify.quickInfoIs("(parameter) a: number", "this is a"); goTo.marker('36'); -verify.currentSignatureHelpDocCommentIs("this is divide function\n@paramTag { number } g this is optional param g"); +verify.currentSignatureHelpDocCommentIs("this is divide function"); verify.currentParameterHelpArgumentDocCommentIs("this is b"); goTo.marker('36aq'); verify.quickInfoIs("(parameter) b: number", "this is b"); @@ -492,4 +492,4 @@ goTo.marker('49aq'); verify.quickInfoIs("(parameter) c: any", "this is info about b\nnot aligned text about parameter will eat only one space"); goTo.marker('50'); -verify.quickInfoIs("class NoQuickInfoClass", ""); \ No newline at end of file +verify.quickInfoIs("class NoQuickInfoClass", ""); diff --git a/tests/cases/fourslash/commentsFunctionExpression.ts b/tests/cases/fourslash/commentsFunctionExpression.ts index 048efa3c9c1..f22c49764dd 100644 --- a/tests/cases/fourslash/commentsFunctionExpression.ts +++ b/tests/cases/fourslash/commentsFunctionExpression.ts @@ -64,25 +64,25 @@ verify.quickInfoIs('function anotherFunc(a: number): string', ''); goTo.marker('8'); verify.quickInfoIs('(local var) lambdaVar: (b: string) => string', 'documentation\ninner docs '); goTo.marker('9'); -verify.quickInfoIs('(parameter) b: string', '{string} inner parameter '); +verify.quickInfoIs('(parameter) b: string', 'inner parameter '); goTo.marker('10'); verify.quickInfoIs('(local var) localVar: string', ''); goTo.marker('11'); verify.quickInfoIs('(local var) localVar: string', ''); goTo.marker('12'); -verify.quickInfoIs('(parameter) b: string', '{string} inner parameter '); +verify.quickInfoIs('(parameter) b: string', 'inner parameter '); goTo.marker('13'); verify.quickInfoIs('(local var) lambdaVar: (b: string) => string', 'documentation\ninner docs '); goTo.marker('14'); -verify.quickInfoIs("var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +verify.quickInfoIs("var assigned: (s: string) => number", "On variable\nSummary on expression"); goTo.marker('15'); verify.completionListContains('s', '(parameter) s: string', "the first parameter!\nparam on expression\nOn parameter "); goTo.marker('16'); -verify.quickInfoIs("var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +verify.quickInfoIs("var assigned: (s: string) => number", "On variable\nSummary on expression"); goTo.marker('17'); -verify.completionListContains("assigned", "var assigned: (s: string) => number", "On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +verify.completionListContains("assigned", "var assigned: (s: string) => number", "On variable\nSummary on expression"); goTo.marker('18'); -verify.currentSignatureHelpDocCommentIs("On variable\n@returns the parameter's length\nSummary on expression\n@returns return on expression"); +verify.currentSignatureHelpDocCommentIs("On variable\nSummary on expression"); verify.currentParameterHelpArgumentDocCommentIs("the first parameter!\nparam on expression\nOn parameter "); diff --git a/tests/cases/fourslash/commentsLinePreservation.ts b/tests/cases/fourslash/commentsLinePreservation.ts index 012272d7544..a1b574ea33b 100644 --- a/tests/cases/fourslash/commentsLinePreservation.ts +++ b/tests/cases/fourslash/commentsLinePreservation.ts @@ -116,7 +116,7 @@ goTo.marker('c'); verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n\nThis is fourth Line"); goTo.marker('d'); -verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line"); +verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line"); goTo.marker('1'); verify.quickInfoIs(undefined, ""); @@ -126,17 +126,17 @@ goTo.marker('2'); verify.quickInfoIs(undefined, ""); goTo.marker('f'); -verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line"); +verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line"); goTo.marker('3'); verify.quickInfoIs(undefined, "first line of param\n\nparam information third line"); goTo.marker('g'); -verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line"); +verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line"); goTo.marker('4'); verify.quickInfoIs(undefined, "param information first line"); goTo.marker('h'); -verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@random tag This should be third line"); +verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line"); goTo.marker('5'); verify.quickInfoIs(undefined, "param information first line\n\nparam information third line"); @@ -151,7 +151,7 @@ goTo.marker('7'); verify.quickInfoIs(undefined, "param information first line\n\nparam information third line"); goTo.marker('k'); -verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line\n@randomtag \n\n random information first line\n\n random information third line"); +verify.quickInfoIs(undefined, "This is firstLine\nThis is second Line"); goTo.marker('8'); verify.quickInfoIs(undefined, "hello "); diff --git a/tests/cases/fourslash/commentsModules.ts b/tests/cases/fourslash/commentsModules.ts index 9415c1bc85e..a501e561606 100644 --- a/tests/cases/fourslash/commentsModules.ts +++ b/tests/cases/fourslash/commentsModules.ts @@ -129,8 +129,8 @@ verify.memberListContains("c", "constructor m1.m2.c(): m1.m2.c", ""); verify.memberListContains("i", "var m1.m2.i: m1.m2.c", "i"); goTo.marker('9'); -verify.completionListContains("m2", "namespace m2", ""); -verify.quickInfoIs("namespace m2", ""); +verify.completionListContains("m2", "namespace m2", "namespace comment of m2.m3"); +verify.quickInfoIs("namespace m2", "namespace comment of m2.m3"); goTo.marker('10'); verify.memberListContains("m3", "namespace m2.m3"); @@ -141,12 +141,12 @@ verify.quickInfoIs("constructor m2.m3.c(): m2.m3.c", ""); verify.memberListContains("c", "constructor m2.m3.c(): m2.m3.c", ""); goTo.marker('12'); -verify.completionListContains("m3", "namespace m3", ""); -verify.quickInfoIs("namespace m3", ""); +verify.completionListContains("m3", "namespace m3", "namespace comment of m3.m4.m5"); +verify.quickInfoIs("namespace m3", "namespace comment of m3.m4.m5"); goTo.marker('13'); -verify.memberListContains("m4", "namespace m3.m4", ""); -verify.quickInfoIs("namespace m3.m4", ""); +verify.memberListContains("m4", "namespace m3.m4", "namespace comment of m3.m4.m5"); +verify.quickInfoIs("namespace m3.m4", "namespace comment of m3.m4.m5"); goTo.marker('14'); verify.memberListContains("m5", "namespace m3.m4.m5"); @@ -157,12 +157,12 @@ verify.quickInfoIs("constructor m3.m4.m5.c(): m3.m4.m5.c", ""); verify.memberListContains("c", "constructor m3.m4.m5.c(): m3.m4.m5.c", ""); goTo.marker('16'); -verify.completionListContains("m4", "namespace m4", ""); -verify.quickInfoIs("namespace m4", ""); +verify.completionListContains("m4", "namespace m4", "namespace comment of m4.m5.m6"); +verify.quickInfoIs("namespace m4", "namespace comment of m4.m5.m6"); goTo.marker('17'); -verify.memberListContains("m5", "namespace m4.m5", ""); -verify.quickInfoIs("namespace m4.m5", ""); +verify.memberListContains("m5", "namespace m4.m5", "namespace comment of m4.m5.m6"); +verify.quickInfoIs("namespace m4.m5", "namespace comment of m4.m5.m6"); goTo.marker('18'); verify.memberListContains("m6", "namespace m4.m5.m6"); @@ -178,11 +178,11 @@ verify.quickInfoIs("constructor m4.m5.m6.m7.c(): m4.m5.m6.m7.c", ""); goTo.marker('21'); verify.completionListContains("m5", "namespace m5"); -verify.quickInfoIs("namespace m5", ""); +verify.quickInfoIs("namespace m5", "namespace comment of m5.m6.m7"); goTo.marker('22'); verify.memberListContains("m6", "namespace m5.m6"); -verify.quickInfoIs("namespace m5.m6", ""); +verify.quickInfoIs("namespace m5.m6", "namespace comment of m5.m6.m7"); goTo.marker('23'); verify.memberListContains("m7", "namespace m5.m6.m7"); @@ -248,4 +248,4 @@ goTo.marker('39'); verify.quickInfoIs("(method) complexM.m2.c.foo2(): complexM.m1.c", ""); goTo.marker('40'); -verify.quickInfoIs("(method) complexM.m1.c.foo(): number", ""); \ No newline at end of file +verify.quickInfoIs("(method) complexM.m1.c.foo(): number", ""); diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo1.ts b/tests/cases/fourslash/getJavaScriptQuickInfo1.ts index 71072f1699a..f10068eb612 100644 --- a/tests/cases/fourslash/getJavaScriptQuickInfo1.ts +++ b/tests/cases/fourslash/getJavaScriptQuickInfo1.ts @@ -6,4 +6,4 @@ ////var /**/v; goTo.marker(); -verify.quickInfoIs('var v: new (p1: number) => string'); \ No newline at end of file +verify.quickInfoIs('var v: new (arg1: number) => string'); diff --git a/tests/cases/fourslash/getJavaScriptQuickInfo7.ts b/tests/cases/fourslash/getJavaScriptQuickInfo7.ts index 7b8d967d190..d9f66a97eb8 100644 --- a/tests/cases/fourslash/getJavaScriptQuickInfo7.ts +++ b/tests/cases/fourslash/getJavaScriptQuickInfo7.ts @@ -19,4 +19,4 @@ goTo.marker(); verify.quickInfoExists(); verify.quickInfoIs('function a1(p: any): number', - 'This is a very cool function that is very nice.\n@returns something'); + 'This is a very cool function that is very nice.'); From 275a4bd4f3df74441b9cd56ac212fd37fb35f3b6 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders Date: Thu, 1 Sep 2016 10:05:56 -0700 Subject: [PATCH 315/508] Use enum for parser state instead of 2 booleans Plus cleanup some lint --- src/compiler/parser.ts | 30 ++++++++++++++++-------------- src/compiler/utilities.ts | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 342b711a5a6..445af2243df 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6151,6 +6151,12 @@ namespace ts { return comment; } + const enum TagState { + BeginningOfLine, + SawAsterisk, + SavingComments + } + export function parseJSDocCommentWorker(start: number, length: number): JSDoc { const content = sourceText; start = start || 0; @@ -6359,8 +6365,7 @@ namespace ts { function parseTagComments(indent: number) { const comments: string[] = []; - let savingComments = false; - let seenAsterisk = true; + let state = TagState.SawAsterisk; let done = false; let margin: number | undefined; let text: string; @@ -6375,9 +6380,8 @@ namespace ts { text = scanner.getTokenText(); switch (token()) { case SyntaxKind.NewLineTrivia: - if (seenAsterisk) { - savingComments = false; - seenAsterisk = false; + if (state >= TagState.SawAsterisk) { + state = TagState.BeginningOfLine; comments.push(text); } indent = 0; @@ -6386,7 +6390,7 @@ namespace ts { done = true; break; case SyntaxKind.WhitespaceTrivia: - if (savingComments && seenAsterisk) { + if (state === TagState.SavingComments) { pushComment(text); } else { @@ -6398,18 +6402,16 @@ namespace ts { } break; case SyntaxKind.AsteriskToken: - if (!seenAsterisk) { + if (state === TagState.BeginningOfLine) { // leading asterisks start recording on the *next* (non-whitespace) token - savingComments = false; + state = TagState.SawAsterisk; indent += text.length; + break; } - // FALLTHROUGH to gather comments + // FALLTHROUGH otherwise to record the * as a comment default: - if (seenAsterisk) { - savingComments = true; // leading identifiers start recording as well - pushComment(text); - } - seenAsterisk = true; + state = TagState.SavingComments; // leading identifiers start recording as well + pushComment(text); break; } if (!done) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 52683f0e74b..5e556278866 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1380,7 +1380,7 @@ namespace ts { function getJSDocTags(node: Node, checkParentVariableStatement: boolean): JSDocTag[] { return getJSDocs(node, checkParentVariableStatement, docs => { - let result: JSDocTag[] = []; + const result: JSDocTag[] = []; for (const doc of docs) { if (doc.tags) { result.push(...doc.tags); From c5c6acf8831f6fdf866c95880df889223addb579 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 1 Sep 2016 10:42:32 -0700 Subject: [PATCH 316/508] Update test baselines: We no longer search in node_modules/@types if it does not exist. --- tests/baselines/reference/library-reference-11.trace.json | 6 ++---- tests/baselines/reference/library-reference-12.trace.json | 6 ++---- tests/baselines/reference/library-reference-7.trace.json | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/tests/baselines/reference/library-reference-11.trace.json b/tests/baselines/reference/library-reference-11.trace.json index 365fe3ce72d..e0af1e39c5a 100644 --- a/tests/baselines/reference/library-reference-11.trace.json +++ b/tests/baselines/reference/library-reference-11.trace.json @@ -1,8 +1,6 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========", - "Resolving with primary search path '/node_modules/@types'", - "File '/node_modules/@types/jquery/package.json' does not exist.", - "File '/node_modules/@types/jquery/index.d.ts' does not exist.", + "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========", + "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'", "File '/a/b/node_modules/jquery.ts' does not exist.", "File '/a/b/node_modules/jquery.d.ts' does not exist.", diff --git a/tests/baselines/reference/library-reference-12.trace.json b/tests/baselines/reference/library-reference-12.trace.json index 84144f82729..2cdf1f5f20a 100644 --- a/tests/baselines/reference/library-reference-12.trace.json +++ b/tests/baselines/reference/library-reference-12.trace.json @@ -1,8 +1,6 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory '/node_modules/@types'. ========", - "Resolving with primary search path '/node_modules/@types'", - "File '/node_modules/@types/jquery/package.json' does not exist.", - "File '/node_modules/@types/jquery/index.d.ts' does not exist.", + "======== Resolving type reference directive 'jquery', containing file '/a/b/consumer.ts', root directory not set. ========", + "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/a/b'", "File '/a/b/node_modules/jquery.ts' does not exist.", "File '/a/b/node_modules/jquery.d.ts' does not exist.", diff --git a/tests/baselines/reference/library-reference-7.trace.json b/tests/baselines/reference/library-reference-7.trace.json index b681ea312a8..419fe6d055d 100644 --- a/tests/baselines/reference/library-reference-7.trace.json +++ b/tests/baselines/reference/library-reference-7.trace.json @@ -1,8 +1,6 @@ [ - "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory '/node_modules/@types'. ========", - "Resolving with primary search path '/node_modules/@types'", - "File '/node_modules/@types/jquery/package.json' does not exist.", - "File '/node_modules/@types/jquery/index.d.ts' does not exist.", + "======== Resolving type reference directive 'jquery', containing file '/src/consumer.ts', root directory not set. ========", + "Root directory cannot be determined, skipping primary search paths.", "Looking up in 'node_modules' folder, initial location '/src'", "File '/src/node_modules/jquery.ts' does not exist.", "File '/src/node_modules/jquery.d.ts' does not exist.", From 87e93a19a33e18b3ce163e034037f1184084401d Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 1 Sep 2016 11:56:00 -0700 Subject: [PATCH 317/508] Fix remaining call to use `unorderedRemoveItem` --- src/server/server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/server.ts b/src/server/server.ts index b0f852b14f1..04936e6721a 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -267,7 +267,7 @@ namespace ts.server { } function removeFile(file: WatchedFile) { - removeItem(file, watchedFiles); + unorderedRemoveItem(file, watchedFiles); } return { From d7b6cc89b5bac9294f06a91dc88674888f51f3d6 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 1 Sep 2016 12:40:31 -0700 Subject: [PATCH 318/508] Respond to PR comments --- src/compiler/checker.ts | 2 +- src/compiler/core.ts | 4 ++-- src/compiler/sys.ts | 2 +- src/compiler/tsc.ts | 2 +- src/harness/harness.ts | 2 +- src/harness/unittests/tsserverProjectSystem.ts | 6 +++--- src/server/editorServices.ts | 12 ++++++------ src/server/server.ts | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0aabf861c3e..e4ac83fd65a 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5372,7 +5372,7 @@ namespace ts { while (i > 0) { i--; if (isSubtypeOfAny(types[i], types)) { - removeItemAtPreservingOrder(types, i); + orderedRemoveItemAt(types, i); } } } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index b09288e63de..9a951243e0b 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -1501,7 +1501,7 @@ namespace ts { } /** Remove an item from an array, moving everything to its right one space left. */ - export function removeItemAtPreservingOrder(array: T[], index: number): void { + export function orderedRemoveItemAt(array: T[], index: number): void { // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. for (let i = index; i < array.length - 1; i++) { array[i] = array[i + 1]; @@ -1516,7 +1516,7 @@ namespace ts { } /** Remove the *first* occurrence of `item` from the array. */ - export function unorderedRemoveItem(item: T, array: T[]): void { + export function unorderedRemoveItem(array: T[], item: T): void { unorderedRemoveFirstItemWhere(array, element => element === item); } diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 966a282ae62..118186bf52a 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -285,7 +285,7 @@ namespace ts { function removeFileWatcherCallback(filePath: string, callback: FileWatcherCallback) { const callbacks = fileWatcherCallbacks[filePath]; if (callbacks) { - unorderedRemoveItem(callback, callbacks); + unorderedRemoveItem(callbacks, callback); if (callbacks.length === 0) { delete fileWatcherCallbacks[filePath]; } diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index a0a647d4fda..6192e5db05e 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -489,7 +489,7 @@ namespace ts { sourceFile.fileWatcher.close(); sourceFile.fileWatcher = undefined; if (removed) { - unorderedRemoveItem(sourceFile.fileName, rootFileNames); + unorderedRemoveItem(rootFileNames, sourceFile.fileName); } startTimerForRecompilation(); } diff --git a/src/harness/harness.ts b/src/harness/harness.ts index fc734a0ccee..a07547d23b1 100644 --- a/src/harness/harness.ts +++ b/src/harness/harness.ts @@ -1772,7 +1772,7 @@ namespace Harness { tsConfig.options.configFilePath = data.name; // delete entry from the list - ts.removeItemAtPreservingOrder(testUnitData, i); + ts.orderedRemoveItemAt(testUnitData, i); break; } diff --git a/src/harness/unittests/tsserverProjectSystem.ts b/src/harness/unittests/tsserverProjectSystem.ts index f839aaabc1d..6814305e6ca 100644 --- a/src/harness/unittests/tsserverProjectSystem.ts +++ b/src/harness/unittests/tsserverProjectSystem.ts @@ -205,7 +205,7 @@ namespace ts { referenceCount: 0, directoryName, close: () => { - unorderedRemoveItem(cbWithRecursive, callbacks); + unorderedRemoveItem(callbacks, cbWithRecursive); if (!callbacks.length) { delete this.watchedDirectories[path]; } @@ -239,7 +239,7 @@ namespace ts { callbacks.push(callback); return { close: () => { - unorderedRemoveItem(callback, callbacks); + unorderedRemoveItem(callbacks, callback); if (!callbacks.length) { delete this.watchedFiles[path]; } @@ -254,7 +254,7 @@ namespace ts { }; readonly clearTimeout = (timeoutId: any): void => { if (typeof timeoutId === "number") { - unorderedRemoveItemAt(this.callbackQueue, timeoutId); + orderedRemoveItemAt(this.callbackQueue, timeoutId); } }; diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index ea66345cec9..8381f16fa87 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -275,7 +275,7 @@ namespace ts.server { removeRoot(info: ScriptInfo) { if (this.filenameToScript.contains(info.path)) { this.filenameToScript.remove(info.path); - unorderedRemoveItem(info, this.roots); + unorderedRemoveItem(this.roots, info); this.resolvedModuleNames.remove(info.path); this.resolvedTypeReferenceDirectives.remove(info.path); } @@ -870,7 +870,7 @@ namespace ts.server { project.directoryWatcher.close(); forEachProperty(project.directoriesWatchedForWildcards, watcher => { watcher.close(); }); delete project.directoriesWatchedForWildcards; - unorderedRemoveItem(project, this.configuredProjects); + unorderedRemoveItem(this.configuredProjects, project); } else { for (const directory of project.directoriesWatchedForTsconfig) { @@ -882,7 +882,7 @@ namespace ts.server { delete project.projectService.directoryWatchersForTsconfig[directory]; } } - unorderedRemoveItem(project, this.inferredProjects); + unorderedRemoveItem(this.inferredProjects, project); } const fileNames = project.getFileNames(); @@ -1007,7 +1007,7 @@ namespace ts.server { } } else { - unorderedRemoveItem(info, this.openFilesReferenced); + unorderedRemoveItem(this.openFilesReferenced, info); } info.close(); } @@ -1514,13 +1514,13 @@ namespace ts.server { // openFileRoots or openFileReferenced. if (info.isOpen) { if (this.openFileRoots.indexOf(info) >= 0) { - unorderedRemoveItem(info, this.openFileRoots); + unorderedRemoveItem(this.openFileRoots, info); if (info.defaultProject && !info.defaultProject.isConfiguredProject()) { this.removeProject(info.defaultProject); } } if (this.openFilesReferenced.indexOf(info) >= 0) { - unorderedRemoveItem(info, this.openFilesReferenced); + unorderedRemoveItem(this.openFilesReferenced, info); } this.openFileRootsConfigured.push(info); info.defaultProject = project; diff --git a/src/server/server.ts b/src/server/server.ts index 04936e6721a..2ce817fafa7 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -267,7 +267,7 @@ namespace ts.server { } function removeFile(file: WatchedFile) { - unorderedRemoveItem(file, watchedFiles); + unorderedRemoveItem(watchedFiles, file); } return { From 3eadbf6c962427a7761252bcbad353a23e3ba543 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 1 Sep 2016 12:44:54 -0700 Subject: [PATCH 319/508] Rename function --- src/services/services.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index e7fb0d9bcc5..83a21926599 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -5092,7 +5092,7 @@ namespace ts { }; } - function getDefinitionFromSignatureDeclaration(decl: SignatureDeclaration): DefinitionInfo { + function createDefinitionFromSignatureDeclaration(decl: SignatureDeclaration): DefinitionInfo { const typeChecker = program.getTypeChecker(); const { symbolName, symbolKind, containerName } = getSymbolInfo(typeChecker, decl.symbol, decl); return createDefinitionInfo(decl, symbolKind, symbolName, containerName); @@ -5231,7 +5231,7 @@ namespace ts { const calledDeclaration = tryGetSignatureDeclaration(typeChecker, node); if (calledDeclaration) { - return [getDefinitionFromSignatureDeclaration(calledDeclaration)]; + return [createDefinitionFromSignatureDeclaration(calledDeclaration)]; } let symbol = typeChecker.getSymbolAtLocation(node); From 28239f2e165d2705e7dd13f93caf2a35e0a9232a Mon Sep 17 00:00:00 2001 From: Richard Knoll Date: Thu, 1 Sep 2016 12:57:23 -0700 Subject: [PATCH 320/508] Do not exclude outDir if exclude is given --- src/compiler/commandLineParser.ts | 11 +++-- src/harness/unittests/matchFiles.ts | 64 +++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 6 deletions(-) diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index e1175c42438..3596233ed14 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -852,14 +852,13 @@ namespace ts { errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); } else { - // By default, exclude common package folders + // By default, exclude common package folders and the outDir excludeSpecs = ["node_modules", "bower_components", "jspm_packages"]; - } - // Always exclude the output directory unless explicitly included - const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; - if (outDir) { - excludeSpecs.push(outDir); + const outDir = json["compilerOptions"] && json["compilerOptions"]["outDir"]; + if (outDir) { + excludeSpecs.push(outDir); + } } if (fileNames === undefined && includeSpecs === undefined) { diff --git a/src/harness/unittests/matchFiles.ts b/src/harness/unittests/matchFiles.ts index 6b499e56989..018314c8a7c 100644 --- a/src/harness/unittests/matchFiles.ts +++ b/src/harness/unittests/matchFiles.ts @@ -1020,6 +1020,70 @@ namespace ts { assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); assert.deepEqual(actual.errors, expected.errors); }); + it("exclude outDir by default", () => { + const json = { + compilerOptions: { + outDir: "./x" + } + }; + const expected: ts.ParsedCommandLine = { + options: { + outDir: "./x" + }, + errors: [], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/b.ts", + "c:/dev/c.d.ts", + "c:/dev/z/a.ts", + "c:/dev/z/aba.ts", + "c:/dev/z/abz.ts", + "c:/dev/z/b.ts", + "c:/dev/z/bba.ts", + "c:/dev/z/bbz.ts", + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); + it("should not exclude outDir if exclude is given", () => { + const json = { + compilerOptions: { + outDir: "./x" + }, + exclude: [ + "z" + ] + }; + const expected: ts.ParsedCommandLine = { + options: { + outDir: "./x" + }, + errors: [], + fileNames: [ + "c:/dev/a.ts", + "c:/dev/b.ts", + "c:/dev/c.d.ts", + "c:/dev/x/a.ts", + "c:/dev/x/aa.ts", + "c:/dev/x/b.ts", + "c:/dev/x/y/a.ts", + "c:/dev/x/y/b.ts", + ], + wildcardDirectories: { + "c:/dev": ts.WatchDirectoryFlags.Recursive + } + }; + const actual = ts.parseJsonConfigFileContent(json, caseInsensitiveHost, caseInsensitiveBasePath); + assert.deepEqual(actual.fileNames, expected.fileNames); + assert.deepEqual(actual.wildcardDirectories, expected.wildcardDirectories); + assert.deepEqual(actual.errors, expected.errors); + }); describe("with trailing recursive directory", () => { it("in includes", () => { const json = { From ab753652facf8a3a620b609159329cc5772db434 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Thu, 1 Sep 2016 13:02:47 -0700 Subject: [PATCH 321/508] Respond to PR comments --- src/services/services.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index 7e9a356e738..c97455c3244 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -2797,7 +2797,7 @@ namespace ts { } /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ - function tryGetClassExtendingIdentifier(node: Node): ClassLikeDeclaration | undefined { + function tryGetClassByExtendingIdentifier(node: Node): ClassLikeDeclaration | undefined { return tryGetClassExtendingExpressionWithTypeArguments(climbPastPropertyAccess(node).parent); } @@ -6506,7 +6506,7 @@ namespace ts { } else { // If this class appears in `extends C`, then the extending class' "super" calls are references. - const classExtending = tryGetClassExtendingIdentifier(referenceLocation); + const classExtending = tryGetClassByExtendingIdentifier(referenceLocation); if (classExtending && isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation) === searchSymbol) { addReferences(superConstructorAccesses(classExtending)); } @@ -6538,7 +6538,7 @@ namespace ts { if (decl && decl.kind === SyntaxKind.MethodDeclaration) { const body = (decl).body; if (body) { - forEachDescendant(body, SyntaxKind.ThisKeyword, thisKeyword => { + forEachDescendantOfKind(body, SyntaxKind.ThisKeyword, thisKeyword => { if (isNewExpressionTarget(thisKeyword)) { result.push(thisKeyword); } @@ -6563,7 +6563,7 @@ namespace ts { Debug.assert(decl.kind === SyntaxKind.Constructor); const body = (decl).body; if (body) { - forEachDescendant(body, SyntaxKind.SuperKeyword, node => { + forEachDescendantOfKind(body, SyntaxKind.SuperKeyword, node => { if (isCallExpressionTarget(node)) { result.push(node); } @@ -6956,7 +6956,7 @@ namespace ts { function getRelatedSymbol(searchSymbols: Symbol[], referenceSymbol: Symbol, referenceLocation: Node, searchLocationIsConstructor: boolean): Symbol | undefined { if (contains(searchSymbols, referenceSymbol)) { // If we are searching for constructor uses, they must be 'new' expressions. - return !(searchLocationIsConstructor && !isNewExpressionTarget(referenceLocation)) && referenceSymbol; + return (!searchLocationIsConstructor || isNewExpressionTarget(referenceLocation)) && referenceSymbol; } // If the reference symbol is an alias, check if what it is aliasing is one of the search @@ -8487,12 +8487,12 @@ namespace ts { }; } - function forEachDescendant(node: Node, kind: SyntaxKind, action: (node: Node) => void) { + function forEachDescendantOfKind(node: Node, kind: SyntaxKind, action: (node: Node) => void) { forEachChild(node, child => { if (child.kind === kind) { action(child); } - forEachDescendant(child, kind, action); + forEachDescendantOfKind(child, kind, action); }); } From f8d6e26d4d5cde32b6834d69c11a989ec2af238a Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 1 Sep 2016 13:57:52 -0700 Subject: [PATCH 322/508] Add tests and Update baselines (#10616) Update tests and baselines Update tests and baselines Update tests for downlevel emit Add tests and update baselines Add tests and baselines Update baselines Update baselines --- .../classExpressionWithStaticProperties1.js | 7 ++- ...assExpressionWithStaticProperties1.symbols | 20 ++++++- ...classExpressionWithStaticProperties1.types | 19 +++++- .../classExpressionWithStaticProperties2.js | 13 ++++- ...assExpressionWithStaticProperties2.symbols | 25 +++++++- ...classExpressionWithStaticProperties2.types | 27 ++++++++- .../classExpressionWithStaticProperties3.js | 29 ++++++++++ ...assExpressionWithStaticProperties3.symbols | 42 ++++++++++++++ ...classExpressionWithStaticProperties3.types | 58 +++++++++++++++++++ .../classExpressionWithStaticProperties1.ts | 6 +- .../classExpressionWithStaticProperties2.ts | 10 +++- .../classExpressionWithStaticProperties3.ts | 11 ++++ 12 files changed, 253 insertions(+), 14 deletions(-) create mode 100644 tests/baselines/reference/classExpressionWithStaticProperties3.js create mode 100644 tests/baselines/reference/classExpressionWithStaticProperties3.symbols create mode 100644 tests/baselines/reference/classExpressionWithStaticProperties3.types create mode 100644 tests/cases/compiler/classExpressionWithStaticProperties3.ts diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.js b/tests/baselines/reference/classExpressionWithStaticProperties1.js index 23d18d76766..205f59367cc 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.js @@ -1,5 +1,9 @@ //// [classExpressionWithStaticProperties1.ts] -var v = class C { static a = 1; static b = 2 }; +var v = class C { + static a = 1; + static b = 2; + static c = C.a + C.b; +}; //// [classExpressionWithStaticProperties1.js] var v = (_a = (function () { @@ -9,5 +13,6 @@ var v = (_a = (function () { }()), _a.a = 1, _a.b = 2, + _a.c = _a.a + _a.b, _a); var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.symbols b/tests/baselines/reference/classExpressionWithStaticProperties1.symbols index d4c811daebe..f8b3c270ea9 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.symbols +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.symbols @@ -1,7 +1,21 @@ === tests/cases/compiler/classExpressionWithStaticProperties1.ts === -var v = class C { static a = 1; static b = 2 }; +var v = class C { >v : Symbol(v, Decl(classExpressionWithStaticProperties1.ts, 0, 3)) >C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7)) ->a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) ->b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 0, 31)) + static a = 1; +>a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) + + static b = 2; +>b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17)) + + static c = C.a + C.b; +>c : Symbol(C.c, Decl(classExpressionWithStaticProperties1.ts, 2, 17)) +>C.a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7)) +>a : Symbol(C.a, Decl(classExpressionWithStaticProperties1.ts, 0, 17)) +>C.b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties1.ts, 0, 7)) +>b : Symbol(C.b, Decl(classExpressionWithStaticProperties1.ts, 1, 17)) + +}; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.types b/tests/baselines/reference/classExpressionWithStaticProperties1.types index b014f78abf7..168bb028474 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.types @@ -1,10 +1,25 @@ === tests/cases/compiler/classExpressionWithStaticProperties1.ts === -var v = class C { static a = 1; static b = 2 }; +var v = class C { >v : typeof C ->class C { static a = 1; static b = 2 } : typeof C +>class C { static a = 1; static b = 2; static c = C.a + C.b;} : typeof C >C : typeof C + + static a = 1; >a : number >1 : number + + static b = 2; >b : number >2 : number + static c = C.a + C.b; +>c : number +>C.a + C.b : number +>C.a : number +>C : typeof C +>a : number +>C.b : number +>C : typeof C +>b : number + +}; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.js b/tests/baselines/reference/classExpressionWithStaticProperties2.js index b9fc0345591..eb1c2da2e21 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.js +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.js @@ -1,5 +1,12 @@ //// [classExpressionWithStaticProperties2.ts] -var v = class C { static a = 1; static b }; +var v = class C { + static a = 1; + static b + static c = { + x: "hi" + } + static d = C.c.x + " world"; + }; //// [classExpressionWithStaticProperties2.js] var v = (_a = (function () { @@ -8,5 +15,9 @@ var v = (_a = (function () { return C; }()), _a.a = 1, + _a.c = { + x: "hi" + }, + _a.d = _a.c.x + " world", _a); var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.symbols b/tests/baselines/reference/classExpressionWithStaticProperties2.symbols index 480123a1c3b..981e1e258c7 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.symbols +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.symbols @@ -1,7 +1,26 @@ === tests/cases/compiler/classExpressionWithStaticProperties2.ts === -var v = class C { static a = 1; static b }; +var v = class C { >v : Symbol(v, Decl(classExpressionWithStaticProperties2.ts, 0, 3)) >C : Symbol(C, Decl(classExpressionWithStaticProperties2.ts, 0, 7)) ->a : Symbol(C.a, Decl(classExpressionWithStaticProperties2.ts, 0, 17)) ->b : Symbol(C.b, Decl(classExpressionWithStaticProperties2.ts, 0, 31)) + static a = 1; +>a : Symbol(C.a, Decl(classExpressionWithStaticProperties2.ts, 0, 17)) + + static b +>b : Symbol(C.b, Decl(classExpressionWithStaticProperties2.ts, 1, 17)) + + static c = { +>c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12)) + + x: "hi" +>x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16)) + } + static d = C.c.x + " world"; +>d : Symbol(C.d, Decl(classExpressionWithStaticProperties2.ts, 5, 5)) +>C.c.x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16)) +>C.c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties2.ts, 0, 7)) +>c : Symbol(C.c, Decl(classExpressionWithStaticProperties2.ts, 2, 12)) +>x : Symbol(x, Decl(classExpressionWithStaticProperties2.ts, 3, 16)) + + }; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.types b/tests/baselines/reference/classExpressionWithStaticProperties2.types index 9bfd6732350..221b4794111 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.types @@ -1,9 +1,32 @@ === tests/cases/compiler/classExpressionWithStaticProperties2.ts === -var v = class C { static a = 1; static b }; +var v = class C { >v : typeof C ->class C { static a = 1; static b } : typeof C +>class C { static a = 1; static b static c = { x: "hi" } static d = C.c.x + " world"; } : typeof C >C : typeof C + + static a = 1; >a : number >1 : number + + static b >b : any + static c = { +>c : { x: string; } +>{ x: "hi" } : { x: string; } + + x: "hi" +>x : string +>"hi" : string + } + static d = C.c.x + " world"; +>d : string +>C.c.x + " world" : string +>C.c.x : string +>C.c : { x: string; } +>C : typeof C +>c : { x: string; } +>x : string +>" world" : string + + }; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.js b/tests/baselines/reference/classExpressionWithStaticProperties3.js new file mode 100644 index 00000000000..7bec5fca167 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.js @@ -0,0 +1,29 @@ +//// [classExpressionWithStaticProperties3.ts] + +declare var console: any; +const arr: {y(): number}[] = []; +for (let i = 0; i < 3; i++) { + arr.push(class C { + static x = i; + static y = () => C.x * 2; + }); +} +arr.forEach(C => console.log(C.y())); + +//// [classExpressionWithStaticProperties3.js] +var arr = []; +var _loop_1 = function (i) { + arr.push((_a = (function () { + function C() { + } + return C; + }()), + _a.x = i, + _a.y = function () { return _a.x * 2; }, + _a)); +}; +for (var i = 0; i < 3; i++) { + _loop_1(i); +} +arr.forEach(function (C) { return console.log(C.y()); }); +var _a; diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.symbols b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols new file mode 100644 index 00000000000..ff9b7b0d311 --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.symbols @@ -0,0 +1,42 @@ +=== tests/cases/compiler/classExpressionWithStaticProperties3.ts === + +declare var console: any; +>console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 1, 11)) + +const arr: {y(): number}[] = []; +>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5)) +>y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12)) + +for (let i = 0; i < 3; i++) { +>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8)) +>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8)) +>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8)) + + arr.push(class C { +>arr.push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5)) +>push : Symbol(Array.push, Decl(lib.d.ts, --, --)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 4, 13)) + + static x = i; +>x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22)) +>i : Symbol(i, Decl(classExpressionWithStaticProperties3.ts, 3, 8)) + + static y = () => C.x * 2; +>y : Symbol(C.y, Decl(classExpressionWithStaticProperties3.ts, 5, 21)) +>C.x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 4, 13)) +>x : Symbol(C.x, Decl(classExpressionWithStaticProperties3.ts, 4, 22)) + + }); +} +arr.forEach(C => console.log(C.y())); +>arr.forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>arr : Symbol(arr, Decl(classExpressionWithStaticProperties3.ts, 2, 5)) +>forEach : Symbol(Array.forEach, Decl(lib.d.ts, --, --)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 9, 12)) +>console : Symbol(console, Decl(classExpressionWithStaticProperties3.ts, 1, 11)) +>C.y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12)) +>C : Symbol(C, Decl(classExpressionWithStaticProperties3.ts, 9, 12)) +>y : Symbol(y, Decl(classExpressionWithStaticProperties3.ts, 2, 12)) + diff --git a/tests/baselines/reference/classExpressionWithStaticProperties3.types b/tests/baselines/reference/classExpressionWithStaticProperties3.types new file mode 100644 index 00000000000..c6ff6d1b56b --- /dev/null +++ b/tests/baselines/reference/classExpressionWithStaticProperties3.types @@ -0,0 +1,58 @@ +=== tests/cases/compiler/classExpressionWithStaticProperties3.ts === + +declare var console: any; +>console : any + +const arr: {y(): number}[] = []; +>arr : { y(): number; }[] +>y : () => number +>[] : undefined[] + +for (let i = 0; i < 3; i++) { +>i : number +>0 : number +>i < 3 : boolean +>i : number +>3 : number +>i++ : number +>i : number + + arr.push(class C { +>arr.push(class C { static x = i; static y = () => C.x * 2; }) : number +>arr.push : (...items: { y(): number; }[]) => number +>arr : { y(): number; }[] +>push : (...items: { y(): number; }[]) => number +>class C { static x = i; static y = () => C.x * 2; } : typeof C +>C : typeof C + + static x = i; +>x : number +>i : number + + static y = () => C.x * 2; +>y : () => number +>() => C.x * 2 : () => number +>C.x * 2 : number +>C.x : number +>C : typeof C +>x : number +>2 : number + + }); +} +arr.forEach(C => console.log(C.y())); +>arr.forEach(C => console.log(C.y())) : void +>arr.forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>arr : { y(): number; }[] +>forEach : (callbackfn: (value: { y(): number; }, index: number, array: { y(): number; }[]) => void, thisArg?: any) => void +>C => console.log(C.y()) : (C: { y(): number; }) => any +>C : { y(): number; } +>console.log(C.y()) : any +>console.log : any +>console : any +>log : any +>C.y() : number +>C.y : () => number +>C : { y(): number; } +>y : () => number + diff --git a/tests/cases/compiler/classExpressionWithStaticProperties1.ts b/tests/cases/compiler/classExpressionWithStaticProperties1.ts index 19fe035e6a7..79c669c32a9 100644 --- a/tests/cases/compiler/classExpressionWithStaticProperties1.ts +++ b/tests/cases/compiler/classExpressionWithStaticProperties1.ts @@ -1 +1,5 @@ -var v = class C { static a = 1; static b = 2 }; \ No newline at end of file +var v = class C { + static a = 1; + static b = 2; + static c = C.a + C.b; +}; \ No newline at end of file diff --git a/tests/cases/compiler/classExpressionWithStaticProperties2.ts b/tests/cases/compiler/classExpressionWithStaticProperties2.ts index f7b9606b6e0..353926e7abd 100644 --- a/tests/cases/compiler/classExpressionWithStaticProperties2.ts +++ b/tests/cases/compiler/classExpressionWithStaticProperties2.ts @@ -1 +1,9 @@ -var v = class C { static a = 1; static b }; \ No newline at end of file +//@target: es5 +var v = class C { + static a = 1; + static b + static c = { + x: "hi" + } + static d = C.c.x + " world"; + }; \ No newline at end of file diff --git a/tests/cases/compiler/classExpressionWithStaticProperties3.ts b/tests/cases/compiler/classExpressionWithStaticProperties3.ts new file mode 100644 index 00000000000..7c733c458be --- /dev/null +++ b/tests/cases/compiler/classExpressionWithStaticProperties3.ts @@ -0,0 +1,11 @@ +//@target: es5 + +declare var console: any; +const arr: {y(): number}[] = []; +for (let i = 0; i < 3; i++) { + arr.push(class C { + static x = i; + static y = () => C.x * 2; + }); +} +arr.forEach(C => console.log(C.y())); \ No newline at end of file From 153666f9087f26ea24b51aad191000e51810ab97 Mon Sep 17 00:00:00 2001 From: Yui Date: Thu, 1 Sep 2016 13:58:09 -0700 Subject: [PATCH 323/508] Add tests for export incorrectly emit twice for decorated class declaration (#8343) (#10651) * Add tests and update baselines * Update baselines --- .../reference/decoratorOnClassConstructor3.js | 58 +++++++++++++++++++ .../decoratorOnClassConstructor3.symbols | 32 ++++++++++ .../decoratorOnClassConstructor3.types | 33 +++++++++++ .../decoratorOnClassConstructor3.ts | 18 ++++++ 4 files changed, 141 insertions(+) create mode 100644 tests/baselines/reference/decoratorOnClassConstructor3.js create mode 100644 tests/baselines/reference/decoratorOnClassConstructor3.symbols create mode 100644 tests/baselines/reference/decoratorOnClassConstructor3.types create mode 100644 tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor3.ts diff --git a/tests/baselines/reference/decoratorOnClassConstructor3.js b/tests/baselines/reference/decoratorOnClassConstructor3.js new file mode 100644 index 00000000000..66946fab8bd --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructor3.js @@ -0,0 +1,58 @@ +//// [tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor3.ts] //// + +//// [0.ts] + +export class base { } +export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { } + +//// [2.ts] +import {base} from "./0" +import {foo} from "./0" + +/* Comment on the Class Declaration */ +export class C extends base{ + constructor(@foo prop: any) { + super(); + } +} + +//// [0.js] +"use strict"; +var base = (function () { + function base() { + } + return base; +}()); +exports.base = base; +function foo(target, propertyKey, parameterIndex) { } +exports.foo = foo; +//// [2.js] +"use strict"; +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __param = (this && this.__param) || function (paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +}; +var _0_1 = require("./0"); +var _0_2 = require("./0"); +/* Comment on the Class Declaration */ +var C = (function (_super) { + __extends(C, _super); + function C(prop) { + _super.call(this); + } + return C; +}(_0_1.base)); +C = __decorate([ + __param(0, _0_2.foo) +], C); +exports.C = C; diff --git a/tests/baselines/reference/decoratorOnClassConstructor3.symbols b/tests/baselines/reference/decoratorOnClassConstructor3.symbols new file mode 100644 index 00000000000..12c20c9a8cc --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructor3.symbols @@ -0,0 +1,32 @@ +=== tests/cases/conformance/decorators/class/constructor/0.ts === + +export class base { } +>base : Symbol(base, Decl(0.ts, 0, 0)) + +export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { } +>foo : Symbol(foo, Decl(0.ts, 1, 21)) +>target : Symbol(target, Decl(0.ts, 2, 20)) +>Object : Symbol(Object, Decl(lib.d.ts, --, --), Decl(lib.d.ts, --, --)) +>propertyKey : Symbol(propertyKey, Decl(0.ts, 2, 35)) +>parameterIndex : Symbol(parameterIndex, Decl(0.ts, 2, 65)) + +=== tests/cases/conformance/decorators/class/constructor/2.ts === +import {base} from "./0" +>base : Symbol(base, Decl(2.ts, 0, 8)) + +import {foo} from "./0" +>foo : Symbol(foo, Decl(2.ts, 1, 8)) + +/* Comment on the Class Declaration */ +export class C extends base{ +>C : Symbol(C, Decl(2.ts, 1, 23)) +>base : Symbol(base, Decl(2.ts, 0, 8)) + + constructor(@foo prop: any) { +>foo : Symbol(foo, Decl(2.ts, 1, 8)) +>prop : Symbol(prop, Decl(2.ts, 5, 16)) + + super(); +>super : Symbol(base, Decl(0.ts, 0, 0)) + } +} diff --git a/tests/baselines/reference/decoratorOnClassConstructor3.types b/tests/baselines/reference/decoratorOnClassConstructor3.types new file mode 100644 index 00000000000..dc1e22c1688 --- /dev/null +++ b/tests/baselines/reference/decoratorOnClassConstructor3.types @@ -0,0 +1,33 @@ +=== tests/cases/conformance/decorators/class/constructor/0.ts === + +export class base { } +>base : base + +export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { } +>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void +>target : Object +>Object : Object +>propertyKey : string | symbol +>parameterIndex : number + +=== tests/cases/conformance/decorators/class/constructor/2.ts === +import {base} from "./0" +>base : typeof base + +import {foo} from "./0" +>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void + +/* Comment on the Class Declaration */ +export class C extends base{ +>C : C +>base : base + + constructor(@foo prop: any) { +>foo : (target: Object, propertyKey: string | symbol, parameterIndex: number) => void +>prop : any + + super(); +>super() : void +>super : typeof base + } +} diff --git a/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor3.ts b/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor3.ts new file mode 100644 index 00000000000..ca89b65a7ac --- /dev/null +++ b/tests/cases/conformance/decorators/class/constructor/decoratorOnClassConstructor3.ts @@ -0,0 +1,18 @@ +// @target: es5 +// @module: commonjs +// @experimentaldecorators: true + +// @Filename: 0.ts +export class base { } +export function foo(target: Object, propertyKey: string | symbol, parameterIndex: number) { } + +// @Filename: 2.ts +import {base} from "./0" +import {foo} from "./0" + +/* Comment on the Class Declaration */ +export class C extends base{ + constructor(@foo prop: any) { + super(); + } +} \ No newline at end of file From adc015dc5ea1be3b60c1394044e46c8d73c406ad Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 1 Sep 2016 14:21:58 -0700 Subject: [PATCH 324/508] Always keep literal types and widen when inferred as types for mutable locations --- src/compiler/binder.ts | 13 +++++++++++++ src/compiler/checker.ts | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index d8017d601ad..d9e4c7212e1 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -568,6 +568,9 @@ namespace ts { case SyntaxKind.PrefixUnaryExpression: bindPrefixUnaryExpressionFlow(node); break; + case SyntaxKind.PostfixUnaryExpression: + bindPostfixUnaryExpressionFlow(node); + break; case SyntaxKind.BinaryExpression: bindBinaryExpressionFlow(node); break; @@ -1083,6 +1086,16 @@ namespace ts { } else { forEachChild(node, bind); + if (node.operator === SyntaxKind.PlusEqualsToken || node.operator === SyntaxKind.MinusMinusToken) { + bindAssignmentTargetFlow(node.operand); + } + } + } + + function bindPostfixUnaryExpressionFlow(node: PostfixUnaryExpression) { + forEachChild(node, bind); + if (node.operator === SyntaxKind.PlusPlusToken || node.operator === SyntaxKind.MinusMinusToken) { + bindAssignmentTargetFlow(node.operand); } } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 9eef1e81d33..ac8a41d43af 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2914,7 +2914,7 @@ namespace ts { // undefined or any type of the parent. if (!parentType || isTypeAny(parentType)) { if (declaration.initializer) { - return checkExpressionCached(declaration.initializer); + return getBaseTypeOfLiteralType(checkExpressionCached(declaration.initializer)); } return parentType; } @@ -3109,7 +3109,7 @@ namespace ts { // pattern. Otherwise, it is the type any. function getTypeFromBindingElement(element: BindingElement, includePatternInType?: boolean, reportErrors?: boolean): Type { if (element.initializer) { - return checkExpressionCached(element.initializer); + return getBaseTypeOfLiteralType(checkExpressionCached(element.initializer)); } if (isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); @@ -7218,6 +7218,10 @@ namespace ts { type; } + function getBaseTypeIfUnitType(type: Type): Type { + return isUnitType(type) ? getBaseTypeOfLiteralType(type) : type; + } + /** * Check if a Type was written as a tuple type literal. * Prefer using isTupleLikeType() unless the use of `elementTypes` is required. @@ -7504,6 +7508,11 @@ namespace ts { return type.couldContainTypeParameters; } + function hasPrimitiveConstraint(type: TypeParameter): boolean { + const constraint = getConstraintOfTypeParameter(type); + return constraint && (constraint.flags & (TypeFlags.String | TypeFlags.Number | TypeFlags.Boolean | TypeFlags.Enum)) !== 0; + } + function inferTypes(context: InferenceContext, source: Type, target: Type) { let sourceStack: Type[]; let targetStack: Type[]; @@ -7578,7 +7587,8 @@ namespace ts { const candidates = inferiority ? inferences.secondary || (inferences.secondary = []) : inferences.primary || (inferences.primary = []); - const widened = isUnitType(source) ? getBaseTypeOfLiteralType(source): source; + // Infer base primitive type for unit types. + const widened = isUnitType(source) && !hasPrimitiveConstraint(target) ? getBaseTypeOfLiteralType(source) : source; if (!contains(candidates, widened)) { candidates.push(widened); } @@ -8310,7 +8320,8 @@ namespace ts { // Assignments only narrow the computed type if the declared type is a union type. Thus, we // only need to evaluate the assigned type if the declared type is a union type. if (isMatchingReference(reference, node)) { - return declaredType.flags & TypeFlags.Union ? + const isIncrementOrDecrement = node.parent.kind === SyntaxKind.PrefixUnaryExpression || node.parent.kind === SyntaxKind.PostfixUnaryExpression; + return declaredType.flags & TypeFlags.Union && !isIncrementOrDecrement ? getAssignmentReducedType(declaredType, getInitialOrAssignedType(node)) : declaredType; } @@ -9402,14 +9413,14 @@ namespace ts { if (parameter.dotDotDotToken) { const restTypes: Type[] = []; for (let i = indexOfParameter; i < iife.arguments.length; i++) { - restTypes.push(getTypeOfExpression(iife.arguments[i])); + restTypes.push(getBaseTypeOfLiteralType(checkExpression(iife.arguments[i]))); } return createArrayType(getUnionType(restTypes)); } const links = getNodeLinks(iife); const cached = links.resolvedSignature; links.resolvedSignature = anySignature; - const type = checkExpression(iife.arguments[indexOfParameter]); + const type = getBaseTypeOfLiteralType(checkExpression(iife.arguments[indexOfParameter])); links.resolvedSignature = cached; return type; } @@ -12263,7 +12274,7 @@ namespace ts { } function checkAssertion(node: AssertionExpression) { - const exprType = getRegularTypeOfObjectLiteral(checkExpression(node.expression)); + const exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(checkExpression(node.expression))); checkSourceElement(node.type); const targetType = getTypeFromTypeNode(node.type); @@ -12455,9 +12466,6 @@ namespace ts { } // Return a union of the return expression types. type = getUnionType(types, /*subtypeReduction*/ true); - if (isUnitType(type)) { - type = getBaseTypeOfLiteralType(type); - } if (funcIsGenerator) { type = createIterableIteratorType(type); @@ -12465,6 +12473,9 @@ namespace ts { } if (!contextualSignature) { reportErrorsFromWidening(func, type); + if (isUnitType(type)) { + type = getBaseTypeOfLiteralType(type); + } } const widenedType = getWidenedType(type); @@ -13244,11 +13255,11 @@ namespace ts { case SyntaxKind.ExclamationEqualsToken: case SyntaxKind.EqualsEqualsEqualsToken: case SyntaxKind.ExclamationEqualsEqualsToken: - const leftIsUnit = isLiteralType(leftType); - const rightIsUnit = isLiteralType(rightType); - if (!leftIsUnit || !rightIsUnit) { - leftType = leftIsUnit ? getBaseTypeOfLiteralType(leftType) : leftType; - rightType = rightIsUnit ? getBaseTypeOfLiteralType(rightType) : rightType; + const leftIsLiteral = isLiteralType(leftType); + const rightIsLiteral = isLiteralType(rightType); + if (!leftIsLiteral || !rightIsLiteral) { + leftType = leftIsLiteral ? getBaseTypeOfLiteralType(leftType) : leftType; + rightType = rightIsLiteral ? getBaseTypeOfLiteralType(rightType) : rightType; } if (!isTypeEqualityComparableTo(leftType, rightType) && !isTypeEqualityComparableTo(rightType, leftType)) { reportOperatorError(); From 44e1096ea92211a4c919cd021ea5dbf7d83909e3 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 1 Sep 2016 14:22:18 -0700 Subject: [PATCH 325/508] Update tests --- .../types/stringLiteral/stringLiteralTypesOverloads02.ts | 8 ++++---- .../types/stringLiteral/stringLiteralTypesOverloads04.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts index 5801aa50076..9e142702026 100644 --- a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads02.ts @@ -7,7 +7,7 @@ function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; function getFalsyPrimitive(x: "number" | "string"): number | string; function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; -function getFalsyPrimitive(x: string) { +function getFalsyPrimitive(x: string): string | number | boolean { if (x === "string") { return ""; } @@ -28,9 +28,9 @@ namespace Consts1 { const FALSE = getFalsyPrimitive("boolean"); } -const string: "string" = "string" -const number: "number" = "number" -const boolean: "boolean" = "boolean" +const string = "string" +const number = "number" +const boolean = "boolean" const stringOrNumber = string || number; const stringOrBoolean = string || boolean; diff --git a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads04.ts b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads04.ts index 8bc2a0c94b8..58317a95fab 100644 --- a/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads04.ts +++ b/tests/cases/conformance/types/stringLiteral/stringLiteralTypesOverloads04.ts @@ -3,6 +3,6 @@ declare function f(x: (p: "foo" | "bar") => "foo"); f(y => { - let z = y = "foo"; + const z = y = "foo"; return z; }) \ No newline at end of file From 33b81095a6081c1165edef12c1aa85cfc616c355 Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Thu, 1 Sep 2016 14:25:44 -0700 Subject: [PATCH 326/508] Accept new baselines (huge!) --- ...eAndAmbientWithSameNameAndCommonRoot.types | 4 +- ...mbientClassWithSameNameAndCommonRoot.types | 4 +- ...FunctionWithTheSameNameAndCommonRoot.types | 4 +- ...AndNonExportedFunctionThatShareAName.types | 12 +- ...iableAndNonExportedVarThatShareAName.types | 12 +- ...thInvalidConstOnPropertyDeclaration2.types | 2 +- .../reference/ES3For-ofTypeCheck2.types | 2 +- tests/baselines/reference/ES5For-of10.types | 2 +- tests/baselines/reference/ES5For-of13.types | 6 +- tests/baselines/reference/ES5For-of24.types | 8 +- tests/baselines/reference/ES5For-of25.types | 6 +- tests/baselines/reference/ES5For-of3.types | 6 +- .../reference/ES5For-of30.errors.txt | 8 +- tests/baselines/reference/ES5For-of9.types | 2 +- .../reference/ES5For-ofTypeCheck1.types | 2 +- .../reference/ES5For-ofTypeCheck12.errors.txt | 4 +- .../reference/ES5For-ofTypeCheck2.types | 2 +- .../reference/ES5For-ofTypeCheck3.types | 4 +- tests/baselines/reference/ES5for-of32.types | 14 +- ...umAndModuleWithSameNameAndCommonRoot.types | 12 +- ...ExtendsInterfaceWithInaccessibleType.types | 2 +- ...assHeritageListMemberTypeAnnotations.types | 10 +- ...essibleTypeInTypeParameterConstraint.types | 10 +- ...esInParameterAndReturnTypeAnnotation.types | 4 +- ...ssibleTypesInParameterTypeAnnotation.types | 4 +- ...ccessibleTypesInReturnTypeAnnotation.types | 4 +- ...assHeritageListMemberTypeAnnotations.types | 10 +- ...essibleTypeInTypeParameterConstraint.types | 10 +- ...hAccessibleTypesOnItsExportedMembers.types | 8 +- ...cessibleTypesInMemberTypeAnnotations.types | 12 +- ...leWithAccessibleTypeInTypeAnnotation.types | 4 +- ...WithInaccessibleTypeInTypeAnnotation.types | 10 +- ...leWithSameNameAndDifferentCommonRoot.types | 8 +- ...duleAndEnumWithSameNameAndCommonRoot.types | 12 +- ...AndNonExportedLocalVarsOfTheSameName.types | 10 +- ...ithTheSameNameAndDifferentCommonRoot.types | 4 +- ...ulesWithTheSameNameAndSameCommonRoot.types | 8 +- .../reference/TypeGuardWithEnumUnion.types | 6 +- .../reference/VariableDeclaration10_es6.types | 2 +- .../reference/VariableDeclaration3_es6.types | 4 +- .../reference/VariableDeclaration5_es6.types | 2 +- .../reference/VariableDeclaration8_es6.types | 2 +- .../abstractIdentifierNameStrict.types | 6 +- .../reference/abstractProperty.types | 6 +- .../accessOverriddenBaseClassMember1.types | 6 +- .../baselines/reference/accessorWithES5.types | 4 +- ...rs_spec_section-4.5_error-cases.errors.txt | 16 +- ...ddMoreCallSignaturesToBaseSignature2.types | 2 +- .../additionOperatorWithAnyAndEveryType.types | 16 +- ...tionOperatorWithInvalidOperands.errors.txt | 24 +- ...WithNullValueAndInvalidOperator.errors.txt | 4 +- ...peratorWithNullValueAndValidOperator.types | 30 +- .../additionOperatorWithNumberAndEnum.types | 40 +- ...ditionOperatorWithStringAndEveryType.types | 16 +- ...ndefinedValueAndInvalidOperands.errors.txt | 4 +- ...orWithUndefinedValueAndValidOperator.types | 30 +- .../reference/aliasAssignments.errors.txt | 4 +- .../reference/ambientDeclarations.types | 4 +- .../reference/ambientEnumDeclaration1.types | 14 +- .../ambientEnumElementInitializer1.types | 2 +- .../ambientEnumElementInitializer2.types | 4 +- .../ambientEnumElementInitializer3.types | 2 +- .../ambientEnumElementInitializer4.types | 2 +- .../ambientEnumElementInitializer5.types | 4 +- .../ambientEnumElementInitializer6.types | 2 +- .../baselines/reference/ambientModules.types | 4 +- .../ambiguousCallsWhereReturnTypesAgree.types | 2 +- .../amdImportAsPrimaryExpression.types | 6 +- .../amdImportNotAsPrimaryExpression.types | 10 +- .../baselines/reference/amdModuleName1.types | 4 +- tests/baselines/reference/anonterface.types | 4 +- .../reference/anyAsFunctionCall.types | 2 +- .../anyAsReturnTypeForNewOnCall.types | 4 +- .../anyAssignabilityInInheritance.types | 4 +- .../reference/anyAssignableToEveryType2.types | 4 +- tests/baselines/reference/anyPlusAny1.types | 4 +- .../reference/anyPropertyAccess.types | 8 +- tests/baselines/reference/argsInScope.types | 8 +- tests/baselines/reference/arguments.types | 2 +- ...indsToFunctionScopeArgumentList.errors.txt | 4 +- .../reference/arithAssignTyping.errors.txt | 4 +- .../arithmeticOperatorWithAnyAndNumber.types | 120 +-- .../arithmeticOperatorWithEnum.types | 364 ++++----- .../arithmeticOperatorWithEnumUnion.types | 368 ++++----- ...peratorWithNullValueAndValidOperands.types | 124 +-- ...orWithUndefinedValueAndValidOperands.types | 124 +-- tests/baselines/reference/arrayAugment.types | 4 +- .../reference/arrayBestCommonTypes.types | 236 +++--- ...rrayBindingPatternOmittedExpressions.types | 4 +- tests/baselines/reference/arrayConcat2.types | 8 +- .../baselines/reference/arrayConcatMap.types | 4 +- .../reference/arrayConstructors1.types | 20 +- tests/baselines/reference/arrayFilter.types | 4 +- tests/baselines/reference/arrayLiteral.types | 16 +- tests/baselines/reference/arrayLiteral1.types | 4 +- tests/baselines/reference/arrayLiteral2.types | 4 +- .../reference/arrayLiteralComments.types | 14 +- .../arrayLiteralContextualType.types | 8 +- .../arrayLiteralInNonVarArgParameter.types | 4 +- .../reference/arrayLiteralSpread.types | 42 +- ...ayLiteralWithMultipleBestCommonTypes.types | 16 +- .../reference/arrayLiterals2ES5.types | 62 +- .../reference/arrayLiterals2ES6.types | 62 +- .../reference/arrayLiterals3.errors.txt | 8 +- .../reference/arrayOfFunctionTypes3.types | 16 +- tests/baselines/reference/arrayconcat.types | 10 +- .../reference/arrowFunctionExpressions.types | 38 +- .../arrowFunctionInExpressionStatement1.types | 2 +- .../arrowFunctionInExpressionStatement2.types | 2 +- .../arrowFunctionWithObjectLiteralBody5.types | 16 +- .../arrowFunctionWithObjectLiteralBody6.types | 16 +- .../baselines/reference/asOpEmitParens.types | 4 +- tests/baselines/reference/asOperator1.types | 8 +- tests/baselines/reference/asOperator3.types | 20 +- tests/baselines/reference/asOperatorASI.types | 4 +- tests/baselines/reference/asiArith.types | 8 +- tests/baselines/reference/asiBreak.types | 2 +- tests/baselines/reference/asiContinue.types | 2 +- .../baselines/reference/asiInES6Classes.types | 4 +- ...entsParsingAsAmbientExternalModule01.types | 2 +- ...entsParsingAsAmbientExternalModule02.types | 2 +- .../asiPreventsParsingAsNamespace04.types | 2 +- .../asiPreventsParsingAsNamespace05.types | 4 +- tests/baselines/reference/assign1.types | 4 +- .../reference/assignEveryTypeToAny.types | 24 +- .../baselines/reference/assignToFn.errors.txt | 4 +- .../reference/assignmentCompat1.errors.txt | 8 +- .../reference/assignmentCompatBug2.errors.txt | 24 +- .../reference/assignmentCompatForEnums.types | 6 +- ...ignmentCompatWithCallSignatures.errors.txt | 16 +- ...ignaturesWithOptionalParameters.errors.txt | 8 +- ...allSignaturesWithRestParameters.errors.txt | 36 +- .../assignmentCompatWithObjectMembers.types | 4 +- .../assignmentCompatWithObjectMembers2.types | 4 +- .../assignmentCompatWithObjectMembers3.types | 4 +- ...tCompatWithObjectMembersNumericNames.types | 4 +- .../reference/assignmentCompatability1.types | 2 +- .../reference/assignmentCompatability10.types | 4 +- .../reference/assignmentCompatability2.types | 2 +- .../reference/assignmentCompatability3.types | 4 +- .../reference/assignmentCompatability36.types | 2 +- .../reference/assignmentCompatability4.types | 2 +- .../reference/assignmentCompatability5.types | 4 +- .../reference/assignmentCompatability6.types | 2 +- .../reference/assignmentCompatability7.types | 4 +- .../reference/assignmentCompatability8.types | 4 +- .../reference/assignmentCompatability9.types | 2 +- ...ember-off-of-function-interface.errors.txt | 16 +- ...ember-off-of-function-interface.errors.txt | 16 +- .../reference/assignmentLHSIsReference.types | 4 +- .../assignmentNonObjectTypeConstraints.types | 6 +- .../assignmentStricterConstraints.types | 4 +- ...nmentToParenthesizedIdentifiers.errors.txt | 48 +- .../reference/assignmentTypeNarrowing.types | 24 +- .../reference/asyncFunctionReturnType.types | 6 +- .../reference/asyncMethodWithSuper_es6.types | 12 +- .../reference/augmentExportEquals3.types | 6 +- .../reference/augmentExportEquals3_1.types | 4 +- .../reference/augmentExportEquals4.types | 6 +- .../reference/augmentExportEquals4_1.types | 4 +- .../reference/augmentExportEquals6.types | 4 +- ...entedTypeBracketAccessIndexSignature.types | 4 +- ...mentedTypeBracketNamedPropertyAccess.types | 8 +- .../reference/augmentedTypesClass3.types | 4 +- .../augmentedTypesExternalModule1.types | 2 +- .../reference/augmentedTypesModules3b.types | 8 +- .../reference/augmentedTypesModules4.types | 6 +- .../reference/autonumberingInEnums.types | 6 +- tests/baselines/reference/avoid.types | 2 +- .../awaitBinaryExpression1_es6.types | 4 +- .../awaitBinaryExpression2_es6.types | 4 +- .../awaitBinaryExpression3_es6.types | 4 +- .../awaitBinaryExpression4_es6.types | 4 +- .../awaitBinaryExpression5_es6.types | 4 +- .../reference/awaitCallExpression1_es6.types | 4 +- .../reference/awaitCallExpression2_es6.types | 4 +- .../reference/awaitCallExpression3_es6.types | 4 +- .../reference/awaitCallExpression4_es6.types | 4 +- .../reference/awaitCallExpression5_es6.types | 4 +- .../reference/awaitCallExpression6_es6.types | 4 +- .../reference/awaitCallExpression7_es6.types | 4 +- .../reference/awaitCallExpression8_es6.types | 4 +- .../reference/await_unaryExpression_es6.types | 16 +- .../await_unaryExpression_es6_1.types | 20 +- .../await_unaryExpression_es6_2.types | 12 +- .../baselines/reference/baseCheck.errors.txt | 4 +- .../baseIndexSignatureResolution.types | 2 +- .../baselines/reference/bestChoiceType.types | 6 +- ...stCommonTypeOfConditionalExpressions.types | 28 +- ...tCommonTypeOfConditionalExpressions2.types | 16 +- .../reference/bestCommonTypeOfTuple.types | 16 +- .../reference/bestCommonTypeOfTuple2.types | 14 +- .../bestCommonTypeReturnStatement.types | 2 +- .../reference/binaryArithmatic1.types | 2 +- .../reference/binaryArithmatic2.types | 2 +- .../reference/binaryIntegerLiteral.types | 56 +- .../reference/binaryIntegerLiteralES6.types | 56 +- .../binopAssignmentShouldHaveType.types | 6 +- .../bitwiseNotOperatorWithBooleanType.types | 16 +- .../bitwiseNotOperatorWithEnumType.types | 36 +- .../bitwiseNotOperatorWithNumberType.types | 18 +- .../bitwiseNotOperatorWithStringType.types | 20 +- ...blockScopedBindingsReassignedInLoop1.types | 6 +- ...blockScopedBindingsReassignedInLoop2.types | 32 +- ...blockScopedBindingsReassignedInLoop3.types | 48 +- ...blockScopedBindingsReassignedInLoop4.types | 10 +- ...blockScopedBindingsReassignedInLoop5.types | 8 +- ...blockScopedBindingsReassignedInLoop6.types | 16 +- .../blockScopedFunctionDeclarationES5.types | 2 +- .../blockScopedFunctionDeclarationES6.types | 2 +- tests/baselines/reference/bom-utf16be.types | 2 +- tests/baselines/reference/bom-utf16le.types | 2 +- tests/baselines/reference/bom-utf8.types | 2 +- .../reference/booleanAssignment.errors.txt | 8 +- .../reference/booleanLiteralTypes1.types | 22 +- .../reference/booleanLiteralTypes2.types | 26 +- .../reference/booleanPropertyAccess.types | 8 +- .../breakInIterationOrSwitchStatement1.types | 2 +- .../breakInIterationOrSwitchStatement2.types | 2 +- tests/baselines/reference/breakTarget2.types | 2 +- tests/baselines/reference/breakTarget3.types | 2 +- tests/baselines/reference/breakTarget4.types | 2 +- ...meterConstrainedToOuterTypeParameter.types | 2 +- ...GenericFunctionWithZeroTypeArguments.types | 14 +- ...OptionalParameterAndInitializer.errors.txt | 4 +- ...allSignatureWithoutAnnotationsOrBody.types | 2 +- ...WithoutReturnTypeAnnotationInference.types | 42 +- ...dBeResolvedBeforeSpecialization.errors.txt | 4 +- ...uresThatDifferOnlyByReturnType2.errors.txt | 4 +- ...callSignaturesWithOptionalParameters.types | 34 +- ...allSignaturesWithOptionalParameters2.types | 52 +- .../baselines/reference/callWithSpread.types | 94 +-- .../reference/callWithSpreadES6.types | 94 +-- .../capturedLetConstInLoop1.errors.txt | 128 ++++ .../reference/capturedLetConstInLoop10.types | 12 +- .../capturedLetConstInLoop10_ES6.types | 12 +- .../reference/capturedLetConstInLoop11.types | 10 +- .../capturedLetConstInLoop11_ES6.types | 10 +- .../reference/capturedLetConstInLoop12.types | 16 +- .../capturedLetConstInLoop1_ES6.errors.txt | 128 ++++ .../capturedLetConstInLoop2.errors.txt | 191 +++++ .../capturedLetConstInLoop2_ES6.errors.txt | 190 +++++ .../capturedLetConstInLoop3.errors.txt | 232 ++++++ .../capturedLetConstInLoop3_ES6.errors.txt | 233 ++++++ .../capturedLetConstInLoop4.errors.txt | 158 ++++ .../capturedLetConstInLoop4_ES6.errors.txt | 158 ++++ .../capturedLetConstInLoop5.errors.txt | 300 ++++++++ .../capturedLetConstInLoop5_ES6.errors.txt | 301 ++++++++ .../capturedLetConstInLoop6.errors.txt | 265 +++++++ .../capturedLetConstInLoop6_ES6.errors.txt | 265 +++++++ .../capturedLetConstInLoop7.errors.txt | 414 ++++++++++ .../capturedLetConstInLoop7_ES6.errors.txt | 414 ++++++++++ .../capturedLetConstInLoop8.errors.txt | 186 +++++ .../capturedLetConstInLoop8_ES6.errors.txt | 186 +++++ .../reference/capturedLetConstInLoop9.types | 22 +- .../capturedLetConstInLoop9_ES6.types | 22 +- .../capturedParametersInInitializers1.types | 6 +- .../reference/castExpressionParentheses.types | 42 +- tests/baselines/reference/castOfAwait.types | 22 +- tests/baselines/reference/castTest.types | 10 +- ...onstrainedToOtherTypeParameter2.errors.txt | 12 +- .../checkSuperCallBeforeThisAccessing1.types | 4 +- .../checkSuperCallBeforeThisAccessing3.types | 4 +- .../checkSuperCallBeforeThisAccessing4.types | 4 +- .../circularObjectLiteralAccessors.types | 2 +- .../reference/classAbstractAsIdentifier.types | 2 +- ...ssignabilityConstructorFunction.errors.txt | 4 +- .../classAppearsToHaveMembersOfObject.types | 2 +- ...rationMergedInModuleWithContinuation.types | 2 +- .../classDoesNotDependOnBaseTypes.types | 8 +- .../reference/classExpression5.types | 2 +- ...classExpressionWithStaticProperties1.types | 4 +- ...classExpressionWithStaticProperties2.types | 2 +- ...ssExpressionWithStaticPropertiesES61.types | 6 +- ...ssExpressionWithStaticPropertiesES62.types | 6 +- ...ssExpressionWithStaticPropertiesES63.types | 6 +- ...ssExpressionWithStaticPropertiesES64.types | 2 +- .../reference/classExtendingClass.types | 4 +- .../classExtendingNonConstructor.errors.txt | 16 +- .../reference/classImplementsClass3.types | 4 +- .../classMemberInitializerScoping.errors.txt | 4 +- .../classStaticPropertyTypeGuard.types | 4 +- .../reference/classWithEmptyBody.types | 14 +- ...lyPublicMembersEquivalentToInterface.types | 2 +- ...yPublicMembersEquivalentToInterface2.types | 2 +- .../classWithProtectedProperty.types | 12 +- .../reference/classWithPublicProperty.types | 12 +- tests/baselines/reference/classdecl.types | 8 +- .../cloduleAcrossModuleDefinitions.types | 2 +- tests/baselines/reference/cloduleTest1.types | 4 +- ...CodeGenModuleWithConstructorChildren.types | 4 +- ...ionCodeGenModuleWithFunctionChildren.types | 2 +- ...isionCodeGenModuleWithMemberVariable.types | 2 +- ...isionCodeGenModuleWithMethodChildren.types | 2 +- ...isionCodeGenModuleWithModuleChildren.types | 4 +- ...sionCodeGenModuleWithModuleReopening.types | 2 +- ...llisionExportsRequireAndAmbientClass.types | 2 +- ...sionExportsRequireAndAmbientFunction.types | 2 +- ...equireAndAmbientFunctionInGlobalFile.types | 2 +- ...lisionExportsRequireAndAmbientModule.types | 4 +- ...collisionExportsRequireAndAmbientVar.types | 4 +- ...xportsRequireAndFunctionInGlobalFile.types | 12 +- ...collisionRestParameterArrowFunctions.types | 8 +- ...llisionRestParameterClassConstructor.types | 12 +- .../collisionRestParameterClassMethod.types | 8 +- .../collisionRestParameterFunction.types | 8 +- ...sionRestParameterFunctionExpressions.types | 8 +- ...llisionRestParameterUnderscoreIUsage.types | 2 +- .../baselines/reference/commaOperator1.types | 34 +- .../commaOperatorOtherValidOperation.types | 8 +- ...ommaOperatorWithSecondOperandAnyType.types | 28 +- ...OperatorWithSecondOperandBooleanType.types | 56 +- ...aOperatorWithSecondOperandNumberType.types | 56 +- ...aOperatorWithSecondOperandObjectType.types | 12 +- ...aOperatorWithSecondOperandStringType.types | 36 +- .../commaOperatorsMultipleOperators.types | 22 +- .../commentBeforeStaticMethod1.types | 2 +- .../reference/commentEmitAtEndOfFile1.types | 2 +- .../reference/commentOnAmbientVariable2.types | 6 +- .../commentOnExpressionStatement1.types | 4 +- .../reference/commentOnIfStatement1.types | 2 +- .../commentOnSimpleArrowFunctionBody1.types | 2 +- .../commentsAfterFunctionExpression1.types | 6 +- .../commentsArgumentsOfCallExpression1.types | 2 +- .../commentsArgumentsOfCallExpression2.types | 8 +- .../commentsBeforeFunctionExpression1.types | 2 +- .../reference/commentsClassMembers.types | 12 +- .../reference/commentsCommentParsing.types | 4 +- tests/baselines/reference/commentsEnums.types | 8 +- .../reference/commentsFunction.types | 16 +- .../reference/commentsInheritance.types | 18 +- .../reference/commentsInterface.types | 28 +- .../reference/commentsOnObjectLiteral3.types | 2 +- .../reference/commentsOnObjectLiteral4.types | 2 +- .../commentsOnPropertyOfObjectLiteral1.types | 2 +- .../commentsOnReturnStatement1.types | 4 +- .../reference/commentsOnStaticMembers.types | 4 +- .../reference/commentsOverloads.types | 54 +- .../commentsPropertySignature1.types | 2 +- .../baselines/reference/commentsVarDecl.types | 16 +- .../commentsVariableStatement1.types | 2 +- .../reference/commentsdoNotEmitComments.types | 12 +- .../reference/commentsemitComments.types | 6 +- .../commonJSImportAsPrimaryExpression.types | 4 +- ...commonJSImportNotAsPrimaryExpression.types | 10 +- .../reference/commonSourceDir5.types | 4 +- .../reference/commonSourceDir6.types | 4 +- ...onOperatorWithIdenticalPrimitiveType.types | 6 +- ...omparisonOperatorWithOneOperandIsAny.types | 6 +- ...mparisonOperatorWithOneOperandIsNull.types | 6 +- ...sonOperatorWithOneOperandIsUndefined.types | 6 +- ...isonOperatorWithSubtypeEnumAndNumber.types | 86 +-- ...ndAdditionAssignmentLHSCanBeAssigned.types | 32 +- ...onAssignmentWithInvalidOperands.errors.txt | 40 +- ...ArithmeticAssignmentLHSCanBeAssigned.types | 6 +- .../compoundAssignmentLHSIsReference.types | 8 +- ...entiationAssignmentLHSCanBeAssigned1.types | 6 +- ...ponentiationAssignmentLHSIsReference.types | 4 +- .../reference/compoundVarDecl1.types | 10 +- ...putedPropertiesInDestructuring1.errors.txt | 4 +- ...dPropertiesInDestructuring1_ES6.errors.txt | 4 +- .../computedPropertiesInDestructuring2.types | 2 +- ...mputedPropertiesInDestructuring2_ES6.types | 2 +- .../computedPropertyNames10_ES5.types | 6 +- .../computedPropertyNames10_ES6.types | 6 +- .../computedPropertyNames11_ES5.types | 18 +- .../computedPropertyNames11_ES6.types | 18 +- .../computedPropertyNames13_ES5.types | 6 +- .../computedPropertyNames13_ES6.types | 6 +- .../computedPropertyNames16_ES5.types | 18 +- .../computedPropertyNames16_ES6.types | 18 +- .../computedPropertyNames18_ES5.types | 2 +- .../computedPropertyNames18_ES6.types | 2 +- .../computedPropertyNames1_ES5.types | 10 +- .../computedPropertyNames1_ES6.types | 10 +- .../computedPropertyNames20_ES5.types | 2 +- .../computedPropertyNames20_ES6.types | 2 +- .../computedPropertyNames22_ES5.types | 2 +- .../computedPropertyNames22_ES6.types | 2 +- .../computedPropertyNames25_ES5.types | 4 +- .../computedPropertyNames25_ES6.types | 4 +- .../computedPropertyNames28_ES5.types | 6 +- .../computedPropertyNames28_ES6.types | 6 +- .../computedPropertyNames29_ES5.types | 2 +- .../computedPropertyNames29_ES6.types | 2 +- .../computedPropertyNames31_ES5.types | 4 +- .../computedPropertyNames31_ES6.types | 4 +- .../computedPropertyNames33_ES5.types | 4 +- .../computedPropertyNames33_ES6.types | 4 +- .../computedPropertyNames37_ES5.types | 4 +- .../computedPropertyNames37_ES6.types | 4 +- .../computedPropertyNames41_ES5.types | 2 +- .../computedPropertyNames41_ES6.types | 2 +- .../computedPropertyNames46_ES5.types | 12 +- .../computedPropertyNames46_ES6.types | 12 +- .../computedPropertyNames47_ES5.types | 2 +- .../computedPropertyNames47_ES6.types | 2 +- .../computedPropertyNames48_ES5.types | 14 +- .../computedPropertyNames48_ES6.types | 14 +- .../computedPropertyNames4_ES5.types | 24 +- .../computedPropertyNames4_ES6.types | 24 +- .../computedPropertyNames7_ES5.types | 2 +- .../computedPropertyNames7_ES6.types | 2 +- ...opertyNamesContextualType10_ES5.errors.txt | 12 +- ...opertyNamesContextualType10_ES6.errors.txt | 12 +- ...utedPropertyNamesContextualType1_ES5.types | 8 +- ...utedPropertyNamesContextualType1_ES6.types | 8 +- ...utedPropertyNamesContextualType2_ES5.types | 4 +- ...utedPropertyNamesContextualType2_ES6.types | 4 +- ...utedPropertyNamesContextualType3_ES5.types | 4 +- ...utedPropertyNamesContextualType3_ES6.types | 4 +- ...utedPropertyNamesContextualType4_ES5.types | 12 +- ...utedPropertyNamesContextualType4_ES6.types | 12 +- ...utedPropertyNamesContextualType5_ES5.types | 8 +- ...utedPropertyNamesContextualType5_ES6.types | 8 +- ...utedPropertyNamesContextualType6_ES5.types | 18 +- ...utedPropertyNamesContextualType6_ES6.types | 18 +- ...utedPropertyNamesContextualType7_ES5.types | 18 +- ...utedPropertyNamesContextualType7_ES6.types | 18 +- ...ropertyNamesContextualType8_ES5.errors.txt | 12 +- ...ropertyNamesContextualType8_ES6.errors.txt | 12 +- ...ropertyNamesContextualType9_ES5.errors.txt | 12 +- ...ropertyNamesContextualType9_ES6.errors.txt | 12 +- ...tedPropertyNamesDeclarationEmit1_ES5.types | 14 +- ...tedPropertyNamesDeclarationEmit1_ES6.types | 14 +- ...tedPropertyNamesDeclarationEmit2_ES5.types | 14 +- ...tedPropertyNamesDeclarationEmit2_ES6.types | 14 +- ...tedPropertyNamesDeclarationEmit5_ES5.types | 20 +- ...tedPropertyNamesDeclarationEmit5_ES6.types | 20 +- .../computedPropertyNamesSourceMap1_ES5.types | 6 +- .../computedPropertyNamesSourceMap1_ES6.types | 6 +- .../computedPropertyNamesSourceMap2_ES5.types | 6 +- .../computedPropertyNamesSourceMap2_ES6.types | 6 +- ...putedPropertyNamesWithStaticProperty.types | 4 +- tests/baselines/reference/concatError.types | 4 +- tests/baselines/reference/concatTuples.types | 12 +- .../conditionalExpression1.errors.txt | 8 +- .../reference/conditionalExpressions2.types | 46 +- ...lOperatorConditionIsBooleanType.errors.txt | 71 ++ ...itionalOperatorConditionIsNumberType.types | 62 +- ...itionalOperatorConditionIsObjectType.types | 24 +- ...onditionalOperatorConditoinIsAnyType.types | 8 +- ...itionalOperatorConditoinIsStringType.types | 40 +- .../conditionalOperatorWithIdenticalBCT.types | 76 +- ...DeclarationShadowedByVarDeclaration2.types | 6 +- ...DeclarationShadowedByVarDeclaration3.types | 4 +- .../constDeclarations-errors.errors.txt | 10 +- .../reference/constDeclarations-es5.types | 12 +- .../constDeclarations-scopes2.errors.txt | 21 + .../reference/constDeclarations.errors.txt | 17 + .../baselines/reference/constDeclarations.js | 4 +- .../baselines/reference/constDeclarations2.js | 4 +- .../reference/constDeclarations2.types | 12 +- tests/baselines/reference/constEnum1.types | 12 +- .../reference/constEnumDeclarations.types | 12 +- .../reference/constEnumExternalModule.types | 2 +- .../constEnumMergingWithValues4.types | 2 +- .../constEnumOnlyModuleMerging.types | 2 +- .../reference/constEnumPropertyAccess1.types | 10 +- .../constEnumPropertyAccess2.errors.txt | 4 +- .../constEnumToStringNoComments.types | 78 +- .../constEnumToStringWithComments.types | 78 +- tests/baselines/reference/constEnums.types | 70 +- .../reference/constIndexedAccess.types | 36 +- ...ructSignaturesWithIdenticalOverloads.types | 24 +- .../constructSignaturesWithOverloads.types | 24 +- ...rFunctionTypeIsAssignableToBaseType2.types | 2 +- ...uctorImplementationWithDefaultValues.types | 2 +- ...mplementationWithDefaultValues2.errors.txt | 8 +- .../reference/constructorOverloads2.types | 4 +- ...ctorParameterShadowsOuterScopes.errors.txt | 4 +- .../constructorReturningAPrimitive.types | 2 +- .../constructorReturnsInvalidType.errors.txt | 4 +- ...rWithAssignableReturnExpression.errors.txt | 4 +- ...torWithIncompleteTypeAnnotation.errors.txt | 17 +- .../contextualSignatureInstantiation.types | 24 +- .../contextualSignatureInstantiation3.types | 6 +- ...meterConstrainedToOuterTypeParameter.types | 2 +- ...tualTypeWithUnionTypeIndexSignatures.types | 4 +- .../contextualTypeWithUnionTypeMembers.types | 36 +- .../reference/contextualTyping1.types | 2 +- .../reference/contextualTyping10.types | 4 +- .../reference/contextualTyping15.types | 2 +- .../reference/contextualTyping16.types | 4 +- .../reference/contextualTyping18.types | 2 +- .../reference/contextualTyping19.types | 6 +- .../reference/contextualTyping23.types | 6 +- .../reference/contextualTyping24.errors.txt | 4 +- .../reference/contextualTyping28.types | 2 +- .../reference/contextualTyping29.types | 4 +- .../reference/contextualTyping3.types | 2 +- .../reference/contextualTyping31.types | 2 +- .../reference/contextualTyping32.types | 4 +- .../reference/contextualTyping34.types | 2 +- .../reference/contextualTyping35.types | 4 +- .../reference/contextualTyping36.types | 2 +- .../reference/contextualTyping37.types | 2 +- .../reference/contextualTyping39.errors.txt | 8 +- .../reference/contextualTyping40.types | 2 +- .../reference/contextualTyping6.types | 4 +- ...textualTypingOfConditionalExpression.types | 4 +- .../contextualTypingOfObjectLiterals.types | 2 +- ...lTypingWithFixedTypeParameters1.errors.txt | 4 +- .../contextuallyTypeCommaOperator01.types | 2 +- .../contextuallyTypeLogicalAnd01.types | 4 +- .../contextuallyTypedBindingInitializer.types | 6 +- ...uallyTypedBindingInitializerNegative.types | 6 +- ...ctionExpressionsAndReturnAnnotations.types | 8 +- .../reference/contextuallyTypedIife.types | 74 +- ...ypedObjectLiteralMethodDeclaration01.types | 24 +- .../contextuallyTypingOrOperator.types | 18 +- .../contextuallyTypingOrOperator2.types | 8 +- .../continueInIterationStatement1.types | 2 +- .../continueInIterationStatement2.types | 2 +- ...oopsWithCapturedBlockScopedBindings1.types | 4 +- tests/baselines/reference/continueLabel.types | 4 +- .../baselines/reference/continueTarget2.types | 2 +- .../baselines/reference/continueTarget3.types | 2 +- .../baselines/reference/continueTarget4.types | 2 +- .../controlFlowAssignmentExpression.types | 8 +- .../controlFlowBinaryAndExpression.types | 26 +- .../controlFlowBinaryOrExpression.types | 26 +- .../reference/controlFlowCaching.types | 96 +-- .../reference/controlFlowCommaOperator.types | 8 +- .../controlFlowConditionalExpression.types | 10 +- .../reference/controlFlowDeleteOperator.types | 10 +- .../controlFlowDestructuringDeclaration.types | 32 +- .../controlFlowDestructuringParameters.types | 2 +- .../controlFlowDoWhileStatement.types | 50 +- .../reference/controlFlowForInStatement.types | 4 +- .../reference/controlFlowForStatement.types | 48 +- .../baselines/reference/controlFlowIIFE.types | 14 +- .../reference/controlFlowIfStatement.types | 28 +- .../reference/controlFlowInstanceof.types | 4 +- .../reference/controlFlowIteration.types | 6 +- .../controlFlowPropertyDeclarations.types | 26 +- .../controlFlowPropertyInitializer.types | 6 +- .../reference/controlFlowWhileStatement.types | 68 +- .../reference/declFileAccessors.types | 28 +- .../reference/declFileConstructors.types | 8 +- .../reference/declFileEnumUsedAsValue.types | 6 +- tests/baselines/reference/declFileEnums.types | 28 +- .../reference/declFileForVarList.types | 8 +- .../reference/declFileFunctions.types | 6 +- .../baselines/reference/declFileMethods.types | 16 +- .../declFileObjectLiteralWithAccessors.types | 8 +- .../declFileObjectLiteralWithOnlyGetter.types | 2 +- .../declFileObjectLiteralWithOnlySetter.types | 8 +- .../reference/declFilePrivateStatic.types | 8 +- .../reference/declFileRegressionTests.types | 4 +- ...tParametersOfFunctionAndFunctionType.types | 2 +- .../declFileTypeAnnotationBuiltInType.types | 10 +- .../declFileTypeAnnotationParenType.types | 8 +- .../reference/declFileTypeofEnum.types | 18 +- .../declFileTypeofInAnonymousType.types | 10 +- tests/baselines/reference/declInput.types | 8 +- tests/baselines/reference/declInput3.types | 8 +- .../declarationEmitDefaultExport3.types | 2 +- .../declarationEmitDefaultExport4.types | 2 +- .../declarationEmitDefaultExport5.types | 4 +- .../declarationEmitDefaultExport8.types | 6 +- ...arationEmitDefaultExportWithTempVarName.js | 2 +- ...efaultExportWithTempVarNameWithBundling.js | 2 +- .../declarationEmitDestructuring3.types | 6 +- .../declarationEmitDestructuring5.types | 10 +- ...rationEmitDestructuringArrayPattern1.types | 22 +- ...rationEmitDestructuringArrayPattern3.types | 4 +- ...rationEmitDestructuringArrayPattern4.types | 48 +- ...rationEmitDestructuringArrayPattern5.types | 20 +- ...itDestructuringObjectLiteralPattern2.types | 14 +- .../declarationEmit_bindingPatterns.types | 2 +- ...larationEmit_classMemberNameConflict.types | 2 +- ...eclarationEmit_classMemberNameConflict2.js | 2 +- ...arationEmit_classMemberNameConflict2.types | 6 +- ...declarationEmit_expressionInExtends2.types | 2 +- .../declarationEmit_invalidReference.types | 2 +- .../declarationEmit_protectedMembers.types | 6 +- .../declarationsAndAssignments.errors.txt | 4 +- ...signmentWithVarFromVariableStatement.types | 2 +- ...orInstantiateModulesInFunctionBodies.types | 2 +- .../decoratorMetadataOnInferredType.types | 2 +- .../reference/decoratorMetadataPromise.types | 2 +- ...decoratorMetadataWithConstructorType.types | 2 +- .../reference/decoratorOnClass5.es6.types | 2 +- .../reference/decoratorOnClass6.es6.types | 2 +- .../reference/decoratorOnClass7.es6.types | 2 +- .../reference/decoratorOnClass8.es6.types | 2 +- .../reference/decoratorOnClassAccessor1.types | 2 +- .../reference/decoratorOnClassAccessor2.types | 2 +- .../reference/decoratorOnClassMethod13.types | 4 +- .../reference/decoratorOnClassMethod4.types | 2 +- .../reference/decoratorOnClassMethod5.types | 2 +- .../reference/decoratorOnClassMethod7.types | 2 +- .../decrementOperatorWithAnyOtherType.types | 14 +- .../decrementOperatorWithNumberType.types | 10 +- ...efaultArgsInFunctionExpressions.errors.txt | 12 +- .../reference/defaultIndexProps1.types | 8 +- .../reference/defaultIndexProps2.types | 12 +- .../deleteOperatorWithBooleanType.types | 16 +- .../deleteOperatorWithEnumType.types | 24 +- .../deleteOperatorWithNumberType.types | 20 +- .../deleteOperatorWithStringType.types | 22 +- ...rivedClassOverridesProtectedMembers2.types | 4 +- .../destructureOptionalParameter.types | 4 +- ...rayBindingPatternAndAssignment2.errors.txt | 8 +- .../destructuringAssignmentWithDefault.types | 2 +- .../destructuringInFunctionType.types | 2 +- ...destructuringInVariableDeclarations1.types | 4 +- ...destructuringInVariableDeclarations2.types | 4 +- ...destructuringInVariableDeclarations3.types | 4 +- ...destructuringInVariableDeclarations4.types | 4 +- ...destructuringInVariableDeclarations5.types | 4 +- ...destructuringInVariableDeclarations6.types | 4 +- ...destructuringInVariableDeclarations7.types | 4 +- ...destructuringInVariableDeclarations8.types | 4 +- ...bjectBindingPatternAndAssignment1ES5.types | 14 +- ...bjectBindingPatternAndAssignment1ES6.types | 14 +- ...estructuringParameterDeclaration3ES5.types | 92 +-- ...estructuringParameterDeclaration3ES6.types | 92 +-- ...tructuringParameterDeclaration4.errors.txt | 4 +- ...structuringParameterProperties2.errors.txt | 8 +- .../destructuringTypeAssertionsES5_5.types | 2 +- ...destructuringVariableDeclaration1ES5.types | 90 +-- ...destructuringVariableDeclaration1ES6.types | 90 +-- ...destructuringWithLiteralInitializers.types | 102 +-- .../destructuringWithNewExpression.types | 2 +- .../destructuringWithNumberLiteral.types | 2 +- .../reference/doNotEmitDetachedComments.types | 2 +- ...DetachedCommentsAtStartOfConstructor.types | 8 +- ...etachedCommentsAtStartOfFunctionBody.types | 8 +- ...achedCommentsAtStartOfLambdaFunction.types | 8 +- ...doNotEmitPinnedCommentNotOnTopOfFile.types | 4 +- ...NotEmitPinnedCommentOnNotEmittedNode.types | 2 +- .../doNotEmitPinnedDetachedComments.types | 4 +- ...denAtObjectLiteralPropertyAssignment.types | 2 +- .../doNotemitTripleSlashComments.types | 6 +- .../reference/doWhileBreakStatements.types | 22 +- .../reference/doWhileContinueStatements.types | 22 +- tests/baselines/reference/doWhileLoop.types | 2 +- .../reference/dottedModuleName2.types | 6 +- .../reference/dottedSymbolResolution1.types | 6 +- .../reference/downlevelLetConst10.types | 2 +- .../reference/downlevelLetConst13.types | 30 +- .../reference/downlevelLetConst14.types | 40 +- .../reference/downlevelLetConst15.types | 60 +- .../reference/downlevelLetConst17.types | 44 +- .../reference/downlevelLetConst3.types | 4 +- .../reference/downlevelLetConst5.types | 2 +- .../reference/downlevelLetConst8.types | 2 +- .../reference/duplicateAnonymousInners1.types | 2 +- .../baselines/reference/duplicateLabel3.types | 4 +- .../baselines/reference/duplicateLabel4.types | 4 +- .../duplicateLocalVariable1.errors.txt | 4 +- .../duplicateLocalVariable2.errors.txt | 4 +- .../reference/duplicateVariablesByScope.types | 22 +- .../dynamicModuleTypecheckError.types | 8 +- .../baselines/reference/dynamicRequire.types | 2 +- .../reference/elidingImportNames.types | 4 +- .../reference/emitArrowFunction.types | 2 +- .../reference/emitArrowFunctionES6.types | 10 +- .../emitArrowFunctionThisCapturing.types | 8 +- .../emitArrowFunctionThisCapturingES6.types | 8 +- ...rrowFunctionWhenUsingArguments01_ES6.types | 12 +- ...rrowFunctionWhenUsingArguments10_ES6.types | 2 +- ...rrowFunctionWhenUsingArguments11_ES6.types | 2 +- ...mitArrowFunctionWhenUsingArguments13.types | 2 +- ...rrowFunctionWhenUsingArguments13_ES6.types | 2 +- ...rrowFunctionWhenUsingArguments14_ES6.types | 2 +- ...rrowFunctionWhenUsingArguments15_ES6.types | 6 +- ...rrowFunctionWhenUsingArguments16_ES6.types | 6 +- ...rrowFunctionWhenUsingArguments17_ES6.types | 6 +- ...rrowFunctionWhenUsingArguments19_ES6.types | 4 +- .../emitClassDeclarationOverloadInES6.types | 2 +- ...ClassDeclarationWithConstructorInES6.types | 8 +- ...itClassDeclarationWithExtensionInES6.types | 6 +- ...lassDeclarationWithGetterSetterInES6.types | 20 +- ...larationWithLiteralPropertyNameInES6.types | 16 +- .../emitClassDeclarationWithMethodInES6.types | 22 +- ...clarationWithPropertyAssignmentInES6.types | 12 +- ...ionWithStaticPropertyAssignmentInES6.types | 6 +- ...ClassDeclarationWithThisKeywordInES6.types | 6 +- ...ntiationAssignmentWithIndexingOnLHS1.types | 42 +- ...ntiationAssignmentWithIndexingOnLHS2.types | 38 +- ...ntiationAssignmentWithIndexingOnLHS3.types | 18 +- ...ntiationAssignmentWithIndexingOnLHS4.types | 20 +- ...ssignmentWithPropertyAccessingOnLHS1.types | 18 +- .../emitCompoundExponentiationOperator1.types | 54 +- .../emitCompoundExponentiationOperator2.types | 84 +- .../emitDefaultParametersFunction.types | 8 +- .../emitDefaultParametersFunctionES6.types | 8 +- ...tDefaultParametersFunctionExpression.types | 18 +- ...faultParametersFunctionExpressionES6.types | 18 +- ...mitDefaultParametersFunctionProperty.types | 8 +- ...DefaultParametersFunctionPropertyES6.types | 8 +- .../emitDefaultParametersMethod.types | 14 +- .../emitDefaultParametersMethodES6.types | 14 +- .../emitExponentiationOperator1.types | 176 ++--- .../emitExponentiationOperator2.types | 134 ++-- .../emitExponentiationOperator3.types | 138 ++-- .../emitExponentiationOperator4.types | 94 +-- ...onentiationOperatorInTempalteString4.types | 4 +- ...ntiationOperatorInTempalteString4ES6.types | 4 +- ...onentiationOperatorInTemplateString1.types | 6 +- ...ntiationOperatorInTemplateString1ES6.types | 6 +- ...onentiationOperatorInTemplateString2.types | 6 +- ...ntiationOperatorInTemplateString2ES6.types | 6 +- ...onentiationOperatorInTemplateString3.types | 6 +- ...ntiationOperatorInTemplateString3ES6.types | 6 +- .../emitMemberAccessExpression.types | 4 +- .../emitPinnedCommentsOnTopOfFile.types | 2 +- .../reference/emitPostComments.types | 2 +- .../baselines/reference/emitPreComments.types | 2 +- ...oreEmitParameterPropertyDeclaration1.types | 6 +- ...EmitParameterPropertyDeclaration1ES6.types | 6 +- ...erCallBeforeEmitPropertyDeclaration1.types | 8 +- ...allBeforeEmitPropertyDeclaration1ES6.types | 6 +- ...tionAndParameterPropertyDeclaration1.types | 8 +- ...nAndParameterPropertyDeclaration1ES6.types | 8 +- ...otEmittedNodeIfRemoveCommentsIsFalse.types | 2 +- .../emptyArrayBindingPatternParameter04.types | 8 +- tests/baselines/reference/emptyIndexer.types | 2 +- .../reference/emptyThenWithoutWarning.types | 4 +- ...ableDeclarationBindingPatterns01_ES5.types | 4 +- ...ableDeclarationBindingPatterns01_ES6.types | 4 +- .../reference/enumAssignmentCompat.errors.txt | 21 +- .../enumAssignmentCompat2.errors.txt | 21 +- .../baselines/reference/enumBasics.errors.txt | 86 +++ .../reference/enumBasics1.errors.txt | 4 +- .../reference/enumCodeGenNewLines1.types | 12 +- .../reference/enumConstantMembers.types | 34 +- .../baselines/reference/enumErrors.errors.txt | 4 +- .../reference/enumExportMergingES6.types | 4 +- tests/baselines/reference/enumIndexer.types | 12 +- .../enumInitializersWithExponents.types | 24 +- .../reference/enumLiteralTypes1.types | 20 +- .../reference/enumLiteralTypes2.types | 20 +- .../reference/enumMapBackIntoItself.types | 14 +- tests/baselines/reference/enumMerging.types | 112 +-- .../reference/enumNegativeLiteral1.types | 10 +- .../baselines/reference/enumNumbering1.types | 4 +- .../baselines/reference/enumOperations.types | 6 +- .../reference/enumPropertyAccess.errors.txt | 4 +- ...ithoutInitializerAfterComputedMember.types | 8 +- .../reference/equalityWithUnionTypes01.types | 4 +- .../reference/es2015modulekind.types | 2 +- .../es2015modulekindWithES6Target.types | 2 +- tests/baselines/reference/es3-amd.types | 2 +- .../reference/es3-declaration-amd.types | 2 +- .../reference/es3-sourcemap-amd.types | 2 +- .../reference/es3defaultAliasIsQuoted.types | 4 +- tests/baselines/reference/es5-amd.types | 2 +- tests/baselines/reference/es5-commonjs.types | 2 +- tests/baselines/reference/es5-commonjs3.types | 2 +- tests/baselines/reference/es5-commonjs4.types | 4 +- tests/baselines/reference/es5-commonjs5.types | 2 +- tests/baselines/reference/es5-commonjs6.types | 2 +- .../reference/es5-declaration-amd.types | 2 +- .../reference/es5-souremap-amd.types | 2 +- tests/baselines/reference/es5-system.types | 2 +- tests/baselines/reference/es5-umd.types | 2 +- tests/baselines/reference/es5-umd2.types | 2 +- tests/baselines/reference/es5-umd3.types | 2 +- tests/baselines/reference/es5-umd4.types | 2 +- .../es5ExportDefaultExpression.types | 4 +- .../reference/es5ModuleWithModuleGenAmd.types | 2 +- .../es5ModuleWithModuleGenCommonjs.types | 2 +- .../es5ModuleWithoutModuleGenTarget.types | 2 +- .../baselines/reference/es5andes6module.types | 2 +- tests/baselines/reference/es6-amd.types | 2 +- .../reference/es6-declaration-amd.types | 2 +- .../reference/es6-sourcemap-amd.types | 2 +- tests/baselines/reference/es6-umd.types | 2 +- tests/baselines/reference/es6-umd2.types | 2 +- .../reference/es6ClassSuperCodegenBug.types | 10 +- tests/baselines/reference/es6ClassTest3.types | 8 +- tests/baselines/reference/es6ClassTest5.types | 2 +- tests/baselines/reference/es6ClassTest8.types | 8 +- tests/baselines/reference/es6ExportAll.types | 4 +- .../reference/es6ExportAllInEs5.types | 4 +- .../baselines/reference/es6ExportClause.types | 4 +- .../reference/es6ExportClauseInEs5.types | 4 +- .../es6ExportClauseWithAssignmentInEs5.types | 18 +- ...s6ExportClauseWithoutModuleSpecifier.types | 4 +- ...ortClauseWithoutModuleSpecifierInEs5.types | 4 +- .../es6ExportDefaultExpression.types | 4 +- .../reference/es6ImportDefaultBinding.types | 2 +- .../es6ImportDefaultBindingAmd.types | 2 +- ...efaultBindingFollowedWithNamedImport.types | 2 +- ...BindingFollowedWithNamespaceBinding1.types | 2 +- ...ngFollowedWithNamespaceBinding1InEs5.types | 2 +- .../reference/es6ImportNameSpaceImport.types | 2 +- .../es6ImportNameSpaceImportAmd.types | 2 +- .../es6ImportNameSpaceImportInEs5.types | 2 +- ...6ImportNameSpaceImportNoNamedExports.types | 2 +- .../reference/es6ImportNamedImport.types | 12 +- .../reference/es6ImportNamedImportAmd.types | 12 +- .../reference/es6ImportNamedImportInEs5.types | 12 +- ...6ImportNamedImportInExportAssignment.types | 2 +- ...6ImportNamedImportWithTypesAndValues.types | 4 +- .../es6ImportWithoutFromClause.types | 2 +- .../es6ImportWithoutFromClauseAmd.types | 8 +- .../es6ImportWithoutFromClauseInEs5.types | 2 +- tests/baselines/reference/es6Module.types | 2 +- .../reference/es6ModuleClassDeclaration.types | 48 +- .../baselines/reference/es6ModuleConst.types | 46 +- .../es6ModuleConstEnumDeclaration.types | 80 +- .../es6ModuleConstEnumDeclaration2.types | 80 +- .../reference/es6ModuleEnumDeclaration.types | 80 +- .../reference/es6ModuleInternalImport.types | 2 +- tests/baselines/reference/es6ModuleLet.types | 2 +- .../es6ModuleModuleDeclaration.types | 24 +- .../es6ModuleVariableStatement.types | 2 +- .../es6ModuleWithModuleGenTargetAmd.types | 2 +- ...es6ModuleWithModuleGenTargetCommonjs.types | 2 +- tests/baselines/reference/es6modulekind.types | 2 +- .../es6modulekindWithES2015Target.types | 2 +- .../es6modulekindWithES5Target.types | 8 +- .../es6modulekindWithES5Target11.types | 4 +- .../es6modulekindWithES5Target2.types | 4 +- .../es6modulekindWithES5Target3.types | 4 +- .../es6modulekindWithES5Target6.types | 4 +- .../es6modulekindWithES5Target7.types | 2 +- .../es6modulekindWithES5Target8.types | 6 +- .../reference/escapedIdentifiers.types | 106 +-- ...capedReservedCompilerNamedIdentifier.types | 30 +- ...veryTypeWithAnnotationAndInitializer.types | 18 +- ...AnnotationAndInvalidInitializer.errors.txt | 24 +- .../reference/everyTypeWithInitializer.types | 12 +- .../excessPropertyErrorsSuppressed.types | 4 +- ...ponentiationOperatorWithAnyAndNumber.types | 12 +- .../exponentiationOperatorWithEnum.types | 40 +- .../exponentiationOperatorWithEnumUnion.types | 44 +- ...peratorWithNullValueAndValidOperands.types | 16 +- ...orWithUndefinedValueAndValidOperands.types | 16 +- .../reference/exportAssignDottedName.types | 2 +- .../exportAssignImportedIdentifier.types | 2 +- .../reference/exportAssignTypes.types | 14 +- .../reference/exportAssignValueAndType.types | 2 +- .../reference/exportAssignmentClass.types | 2 +- ...ssignmentConstrainedGenericType.errors.txt | 4 +- .../reference/exportAssignmentEnum.types | 18 +- .../reference/exportAssignmentFunction.types | 2 +- .../exportAssignmentMergedInterface.types | 8 +- .../exportAssignmentMergedModule.types | 8 +- .../exportAssignmentTopLevelClodule.types | 4 +- .../exportAssignmentTopLevelEnumdule.types | 8 +- .../exportAssignmentTopLevelFundule.types | 4 +- .../exportAssignmentTopLevelIdentifier.types | 2 +- .../reference/exportAssignmentVariable.types | 2 +- tests/baselines/reference/exportCodeGen.types | 16 +- ...onWithModuleSpecifierNameOnNextLine1.types | 2 +- .../exportDefaultAsyncFunction2.types | 4 +- ...ssWithStaticPropertyAssignmentsInES6.types | 2 +- .../reference/exportDefaultProperty.types | 6 +- .../reference/exportEqualNamespaces.types | 2 +- .../baselines/reference/exportEqualsAmd.types | 4 +- .../reference/exportEqualsCommonJs.types | 4 +- .../exportEqualsDefaultProperty.types | 6 +- .../reference/exportEqualsProperty.types | 6 +- .../baselines/reference/exportEqualsUmd.types | 4 +- tests/baselines/reference/exportImport.types | 2 +- .../reference/exportImportAlias.types | 16 +- .../reference/exportImportAndClodule.types | 4 +- .../reference/exportImportMultipleFiles.types | 8 +- .../exportImportNonInstantiatedModule.types | 2 +- .../exportImportNonInstantiatedModule2.types | 2 +- .../reference/exportNonVisibleType.types | 4 +- .../reference/exportPrivateType.types | 2 +- .../reference/exportStarForValues10.types | 4 +- .../reference/exportStarForValues2.types | 4 +- .../reference/exportStarForValues3.types | 8 +- .../reference/exportStarForValues4.types | 4 +- .../reference/exportStarForValues6.types | 2 +- .../reference/exportStarForValues7.types | 4 +- .../reference/exportStarForValues8.types | 8 +- .../reference/exportStarForValues9.types | 4 +- .../exportStarForValuesInSystem.types | 2 +- .../baselines/reference/exportToString.types | 6 +- .../reference/exportVisibility.types | 2 +- .../reference/exportedVariable1.types | 2 +- .../reference/exportsAndImports1-amd.types | 14 +- .../reference/exportsAndImports1-es6.types | 14 +- .../reference/exportsAndImports1.types | 14 +- .../reference/exportsAndImports2-amd.types | 4 +- .../reference/exportsAndImports2-es6.types | 4 +- .../reference/exportsAndImports2.types | 4 +- .../reference/exportsAndImports3-amd.types | 14 +- .../reference/exportsAndImports3-es6.types | 14 +- .../reference/exportsAndImports3.types | 14 +- .../reference/exportsAndImports4-amd.types | 46 +- .../reference/exportsAndImports4-es6.types | 46 +- .../reference/exportsAndImports4.types | 46 +- ...dImportsWithContextualKeywordNames02.types | 2 +- .../exportsAndImportsWithUnderscores2.types | 2 +- .../exportsAndImportsWithUnderscores3.types | 6 +- .../exportsAndImportsWithUnderscores4.types | 14 +- tests/baselines/reference/expr.errors.txt | 16 +- tests/baselines/reference/extBaseClass1.types | 2 +- .../reference/extendBooleanInterface.types | 18 +- .../extendConstructSignatureInInterface.types | 2 +- .../reference/extendNumberInterface.types | 10 +- .../reference/extendStringInterface.types | 10 +- .../extendedInterfaceGenericType.types | 2 +- tests/baselines/reference/externFunc.types | 2 +- .../externalModuleQualification.types | 2 +- ...rnalModuleReferenceDoubleUnderscore1.types | 28 +- .../reference/externalModuleResolution.types | 2 +- .../reference/externalModuleResolution2.types | 2 +- .../reference/fallFromLastCase1.types | 8 +- ...backToBindingPatternForTypeInference.types | 14 +- tests/baselines/reference/fatArrowSelf.types | 2 +- .../reference/fatArrowfunctionAsType.types | 2 +- .../reference/fatarrowfunctions.types | 12 +- ...functionsInFunctionParameterDefaults.types | 2 +- .../fatarrowfunctionsInFunctions.types | 4 +- .../fileReferencesWithNoExtensions.types | 4 +- .../reference/fileWithNextLine1.types | 2 +- .../reference/fileWithNextLine2.types | 2 +- .../fixingTypeParametersRepeatedly1.types | 4 +- tests/baselines/reference/for-of13.types | 2 +- tests/baselines/reference/for-of18.types | 4 +- tests/baselines/reference/for-of19.types | 2 +- tests/baselines/reference/for-of20.types | 2 +- tests/baselines/reference/for-of21.types | 2 +- tests/baselines/reference/for-of22.types | 2 +- tests/baselines/reference/for-of23.types | 6 +- tests/baselines/reference/for-of36.types | 2 +- tests/baselines/reference/for-of37.types | 2 +- tests/baselines/reference/for-of38.types | 2 +- tests/baselines/reference/for-of4.types | 2 +- tests/baselines/reference/for-of40.types | 6 +- tests/baselines/reference/for-of41.types | 4 +- tests/baselines/reference/for-of42.types | 4 +- tests/baselines/reference/for-of43.types | 12 +- tests/baselines/reference/for-of44.types | 12 +- tests/baselines/reference/for-of45.types | 8 +- tests/baselines/reference/for-of46.errors.txt | 8 +- tests/baselines/reference/for-of5.types | 2 +- tests/baselines/reference/for-of50.types | 2 +- tests/baselines/reference/for-of8.types | 2 +- tests/baselines/reference/for-of9.types | 4 +- tests/baselines/reference/forInModule.types | 4 +- tests/baselines/reference/forStatements.types | 18 +- .../forStatementsMultipleValidDecl.types | 26 +- .../reference/fromAsIdentifier2.types | 2 +- tests/baselines/reference/funcdecl.types | 14 +- .../reference/functionAssignment.errors.txt | 4 +- .../reference/functionAssignmentError.types | 8 +- tests/baselines/reference/functionCall1.types | 2 +- .../reference/functionCall10.errors.txt | 8 +- .../reference/functionCall11.errors.txt | 4 +- .../reference/functionCall12.errors.txt | 8 +- .../reference/functionCall13.errors.txt | 4 +- .../reference/functionCall14.errors.txt | 4 +- .../reference/functionCall16.errors.txt | 8 +- .../reference/functionCall17.errors.txt | 12 +- tests/baselines/reference/functionCall2.types | 2 +- tests/baselines/reference/functionCall3.types | 2 +- tests/baselines/reference/functionCall4.types | 2 +- .../reference/functionCall6.errors.txt | 4 +- .../reference/functionCall7.errors.txt | 4 +- .../reference/functionCall8.errors.txt | 4 +- .../reference/functionCall9.errors.txt | 4 +- ...functionConstraintSatisfaction2.errors.txt | 4 +- .../functionExpressionContextualTyping1.types | 30 +- ...tionExpressionContextualTyping2.errors.txt | 12 +- .../reference/functionImplementations.types | 18 +- .../functionInIfStatementInModule.types | 2 +- .../baselines/reference/functionLiteral.types | 2 +- .../reference/functionMergedWithModule.types | 2 +- .../reference/functionOnlyHasThrow.types | 2 +- ...ctionOverloadCompatibilityWithVoid02.types | 2 +- .../reference/functionOverloads.errors.txt | 4 +- .../reference/functionOverloads12.types | 6 +- .../reference/functionOverloads13.types | 2 +- .../reference/functionOverloads14.types | 2 +- .../reference/functionOverloads15.types | 2 +- .../reference/functionOverloads16.types | 2 +- .../reference/functionOverloads2.errors.txt | 4 +- .../reference/functionOverloads21.types | 2 +- .../reference/functionOverloads22.types | 2 +- .../reference/functionOverloads23.types | 2 +- .../reference/functionOverloads25.types | 2 +- .../reference/functionOverloads26.types | 4 +- .../reference/functionOverloads27.errors.txt | 4 +- .../reference/functionOverloads28.types | 2 +- .../reference/functionOverloads30.types | 2 +- .../reference/functionOverloads31.types | 2 +- .../reference/functionOverloads33.types | 2 +- .../reference/functionOverloads35.types | 2 +- .../reference/functionOverloads36.types | 2 +- .../reference/functionOverloads38.types | 2 +- .../reference/functionOverloads39.types | 2 +- .../reference/functionOverloads40.errors.txt | 12 +- .../reference/functionOverloads42.types | 2 +- .../reference/functionOverloads43.types | 4 +- .../reference/functionOverloads44.types | 8 +- .../reference/functionOverloads45.types | 8 +- .../reference/functionOverloads7.types | 4 +- .../reference/functionOverloads8.types | 2 +- .../reference/functionOverloads9.types | 4 +- .../baselines/reference/functionReturn.types | 4 +- tests/baselines/reference/functionType.types | 4 +- ...ithDefaultParameterWithNoStatements1.types | 2 +- ...thDefaultParameterWithNoStatements10.types | 4 +- ...thDefaultParameterWithNoStatements11.types | 4 +- ...thDefaultParameterWithNoStatements13.types | 8 +- ...thDefaultParameterWithNoStatements14.types | 8 +- ...thDefaultParameterWithNoStatements15.types | 8 +- ...ithDefaultParameterWithNoStatements2.types | 2 +- ...ithDefaultParameterWithNoStatements3.types | 4 +- ...ithDefaultParameterWithNoStatements5.types | 4 +- ...ithDefaultParameterWithNoStatements6.types | 4 +- ...ithDefaultParameterWithNoStatements7.types | 4 +- ...functionWithMultipleReturnStatements.types | 42 +- ...unctionWithMultipleReturnStatements2.types | 30 +- .../functionWithNoBestCommonType1.types | 4 +- .../functionWithNoBestCommonType2.types | 6 +- .../functionWithThrowButNoReturn1.types | 2 +- .../functionsInClassExpressions.types | 2 +- ...fFunctionWithoutReturnTypeAnnotation.types | 2 +- .../reference/generatedContextualTyping.types | 72 +- .../baselines/reference/generatorES6_2.types | 4 +- .../baselines/reference/generatorES6_3.types | 6 +- .../baselines/reference/generatorES6_4.types | 8 +- .../baselines/reference/generatorES6_6.types | 2 +- .../reference/generatorTypeCheck11.types | 2 +- .../reference/generatorTypeCheck12.types | 2 +- .../reference/generatorTypeCheck13.types | 4 +- .../reference/generatorTypeCheck14.types | 6 +- .../reference/generatorTypeCheck15.types | 2 +- .../reference/generatorTypeCheck33.types | 8 +- .../reference/generatorTypeCheck34.types | 6 +- .../reference/generatorTypeCheck35.types | 6 +- .../reference/generatorTypeCheck36.types | 2 +- .../reference/generatorTypeCheck37.types | 2 +- .../reference/generatorTypeCheck38.types | 4 +- .../reference/generatorTypeCheck41.types | 6 +- .../reference/generatorTypeCheck42.types | 4 +- .../reference/generatorTypeCheck43.types | 4 +- .../reference/generatorTypeCheck44.types | 6 +- .../reference/generatorTypeCheck45.types | 2 +- .../reference/generatorTypeCheck46.types | 2 +- .../reference/generatorTypeCheck49.types | 4 +- .../genericAndNonGenericOverload1.types | 2 +- ...nericArgumentCallSigAssignmentCompat.types | 6 +- tests/baselines/reference/genericArray1.types | 6 +- .../genericBaseClassLiteralProperty2.types | 2 +- .../genericCallTypeArgumentInference.types | 44 +- .../genericCallWithArrayLiteralArgs.types | 24 +- ...nstraintsTypeArgumentInference2.errors.txt | 4 +- .../genericCallWithFixedArguments.types | 2 +- ...CallWithFunctionTypedArguments5.errors.txt | 16 +- ...lWithGenericSignatureArguments2.errors.txt | 8 +- ...ricCallWithObjectTypeArgsAndIndexers.types | 4 +- ...lWithObjectTypeArgsAndIndexersErrors.types | 6 +- ...thObjectTypeArgsAndInitializers.errors.txt | 4 +- ...lWithObjectTypeArgsAndNumericIndexer.types | 4 +- ...llWithObjectTypeArgsAndStringIndexer.types | 4 +- ...WithOverloadedFunctionTypedArguments.types | 12 +- ...kedInsideItsContainingFunction1.errors.txt | 4 +- .../genericClassExpressionInFunction.types | 12 +- ...assPropertyInheritanceSpecialization.types | 2 +- .../genericClassWithStaticFactory.types | 4 +- .../reference/genericCloduleInModule.types | 2 +- ...genericConstructSignatureInInterface.types | 2 +- ...enericContextualTypingSpecialization.types | 2 +- .../reference/genericFunctions0.types | 2 +- .../reference/genericFunctions1.types | 2 +- ...ericFunctionsWithOptionalParameters3.types | 10 +- .../reference/genericInference1.types | 6 +- .../reference/genericInference2.types | 6 +- .../genericMethodOverspecialization.types | 10 +- .../reference/genericNewInterface.errors.txt | 8 +- .../genericObjectLitReturnType.types | 6 +- ...cRecursiveImplicitConstructorErrors2.types | 4 +- .../reference/genericRestArgs.errors.txt | 8 +- .../genericReversingTypeParameters.types | 4 +- .../genericReversingTypeParameters2.types | 2 +- .../genericStaticAnyTypeFunction.types | 4 +- .../reference/genericTypeAliases.types | 50 +- .../genericTypeArgumentInference1.types | 8 +- .../genericTypeParameterEquivalence2.types | 2 +- ...nericWithIndexerOfTypeParameterType1.types | 2 +- .../genericWithOpenTypeParameters1.errors.txt | 4 +- .../getSetAccessorContextualTyping.errors.txt | 4 +- .../reference/getterSetterNonAccessor.types | 6 +- tests/baselines/reference/global.types | 4 +- .../reference/globalIsContextualKeyword.types | 4 +- .../reference/globalThisCapture.types | 2 +- .../reference/grammarAmbiguities1.errors.txt | 4 +- .../heterogeneousArrayLiterals.types | 58 +- .../reference/hidingCallSignatures.types | 8 +- .../reference/hidingConstructSignatures.types | 8 +- .../reference/hidingIndexSignatures.types | 4 +- .../reference/ifDoWhileStatements.types | 74 +- .../implicitAnyAnyReturningFunction.types | 4 +- .../reference/implicitAnyGenerics.types | 6 +- .../reference/implicitAnyInCatch.types | 2 +- .../reference/implicitIndexSignatures.types | 26 +- .../reference/importAliasIdentifiers.types | 12 +- .../reference/importAliasWithDottedName.types | 4 +- ...mportAndVariableDeclarationConflict2.types | 4 +- .../reference/importImportOnlyModule.types | 6 +- .../reference/importInTypePosition.types | 8 +- .../reference/importStatements.types | 12 +- .../import_reference-exported-alias.types | 2 +- .../import_reference-to-type-alias.types | 2 +- ...ferenecing-aliased-type-throug-array.types | 2 +- .../reference/inOperatorWithFunction.types | 4 +- .../inOperatorWithValidOperands.types | 4 +- .../reference/incompatibleTypes.errors.txt | 8 +- .../incrementOperatorWithAnyOtherType.types | 14 +- .../incrementOperatorWithNumberType.types | 10 +- .../reference/indexClassByNumber.types | 6 +- .../indexIntoArraySubclass.errors.txt | 4 +- tests/baselines/reference/indexIntoEnum.types | 2 +- .../indexSignaturesInferentialTyping.types | 12 +- tests/baselines/reference/indexer.types | 6 +- tests/baselines/reference/indexer3.types | 2 +- tests/baselines/reference/indexerA.types | 6 +- .../reference/indexerWithTuple.types | 54 +- .../reference/indexersInClassType.types | 2 +- ...erParameterWithMethodCallInitializer.types | 4 +- .../reference/inferSecondaryParameter.types | 2 +- .../reference/inferSetterParamType.errors.txt | 4 +- ...gumentsInSignatureWithRestParameters.types | 10 +- .../inferenceFromParameterlessLambda.types | 4 +- .../baselines/reference/inferenceLimit.types | 2 +- ...nferentialTypingObjectLiteralMethod1.types | 2 +- ...nferentialTypingObjectLiteralMethod2.types | 2 +- .../inferentialTypingUsingApparentType3.types | 4 +- .../inferentialTypingWithFunctionType.types | 2 +- .../inferentialTypingWithFunctionType2.types | 8 +- ...erentialTypingWithFunctionTypeNested.types | 2 +- ...ngWithFunctionTypeSyntacticScenarios.types | 20 +- ...inferentialTypingWithFunctionTypeZip.types | 10 +- ...pingWithObjectLiteralProperties.errors.txt | 8 +- ...nferredFunctionReturnTypeIsEmptyType.types | 8 +- ...nheritanceMemberFuncOverridingMethod.types | 4 +- ...nheritanceStaticFuncOverridingMethod.types | 4 +- ...aticFuncOverridingPropertyOfFuncType.types | 2 +- ...eritedConstructorWithRestParams.errors.txt | 8 +- ...ritedConstructorWithRestParams2.errors.txt | 12 +- ...ritedFunctionAssignmentCompatibility.types | 4 +- ...ritedOverloadedSpecializedSignatures.types | 6 +- .../initializePropertiesWithRenamedLet.types | 12 +- .../initializersInAmbientEnums.types | 8 +- .../reference/initializersWidened.types | 10 +- tests/baselines/reference/innerFunc.types | 4 +- .../baselines/reference/innerOverloads.types | 2 +- .../innerTypeCheckOfLambdaArgument.errors.txt | 4 +- .../instanceAndStaticDeclarations1.types | 4 +- .../instanceMemberInitialization.types | 6 +- ...anceofWithStructurallyIdenticalTypes.types | 8 +- ...tantiateContextuallyTypedGenericThis.types | 4 +- .../reference/instantiateCrossFileMerge.types | 2 +- .../reference/instantiatedModule.types | 18 +- tests/baselines/reference/interface0.types | 2 +- .../reference/interfaceClassMerging.types | 8 +- .../reference/interfaceContextualType.types | 6 +- .../interfaceDoesNotDependOnBaseTypes.types | 4 +- .../reference/interfaceSubtyping.types | 2 +- ...OverloadedCallAndConstructSignatures.types | 4 +- .../interfaceWithPropertyOfEveryType.types | 18 +- ...pecializedCallAndConstructSignatures.types | 4 +- ...liasClassInsideLocalModuleWithExport.types | 2 +- ...sClassInsideLocalModuleWithoutExport.types | 2 +- ...sClassInsideTopLevelModuleWithExport.types | 2 +- ...assInsideTopLevelModuleWithoutExport.types | 2 +- .../reference/internalAliasEnum.types | 6 +- ...AliasEnumInsideLocalModuleWithExport.types | 6 +- ...asEnumInsideLocalModuleWithoutExport.types | 6 +- ...asEnumInsideTopLevelModuleWithExport.types | 6 +- ...numInsideTopLevelModuleWithoutExport.types | 6 +- .../reference/internalAliasFunction.types | 2 +- ...sFunctionInsideLocalModuleWithExport.types | 2 +- ...nctionInsideLocalModuleWithoutExport.types | 2 +- ...nctionInsideTopLevelModuleWithExport.types | 2 +- ...ionInsideTopLevelModuleWithoutExport.types | 2 +- .../reference/internalAliasVar.types | 2 +- ...lAliasVarInsideLocalModuleWithExport.types | 2 +- ...iasVarInsideLocalModuleWithoutExport.types | 2 +- ...iasVarInsideTopLevelModuleWithExport.types | 2 +- ...VarInsideTopLevelModuleWithoutExport.types | 2 +- ...lassNotReferencingInstanceNoConflict.types | 2 +- ...duleNotReferencingInstanceNoConflict.types | 2 +- .../intersectionTypeInference1.types | 2 +- .../reference/intersectionTypeMembers.types | 36 +- .../intersectionTypeOverloading.types | 4 +- .../invalidAssignmentsToVoid.errors.txt | 12 +- .../invalidBooleanAssignments.errors.txt | 28 +- .../invalidEnumAssignments.errors.txt | 12 +- .../invalidNumberAssignments.errors.txt | 8 +- tests/baselines/reference/invalidSplice.types | 8 +- .../invalidStringAssignments.errors.txt | 8 +- .../invalidSwitchBreakStatement.errors.txt | 13 + .../invalidSwitchContinueStatement.errors.txt | 5 +- .../reference/invalidUndefinedValues.types | 14 +- .../invalidVoidAssignments.errors.txt | 8 +- .../reference/invalidVoidValues.errors.txt | 12 +- ...onExpressionInFunctionParameter.errors.txt | 4 +- tests/baselines/reference/ipromise2.types | 4 +- tests/baselines/reference/ipromise4.types | 4 +- tests/baselines/reference/isLiteral1.types | 2 +- tests/baselines/reference/isLiteral2.types | 2 +- .../isolatedModulesNonAmbientConstEnum.types | 2 +- .../reference/isolatedModulesSourceMap.types | 2 +- .../reference/iterableArrayPattern1.types | 2 +- .../reference/iterableArrayPattern11.types | 2 +- .../reference/iterableArrayPattern12.types | 2 +- .../reference/iterableArrayPattern13.types | 2 +- .../reference/iterableArrayPattern2.types | 2 +- .../reference/iterableArrayPattern3.types | 2 +- .../reference/iterableArrayPattern30.types | 4 +- .../reference/iterableArrayPattern4.types | 2 +- .../reference/iterableArrayPattern9.types | 2 +- .../reference/iteratorSpreadInArray.types | 2 +- .../reference/iteratorSpreadInArray2.types | 6 +- .../reference/iteratorSpreadInArray3.types | 6 +- .../reference/iteratorSpreadInArray4.types | 6 +- .../reference/iteratorSpreadInArray7.types | 2 +- .../reference/iteratorSpreadInCall11.types | 4 +- .../reference/iteratorSpreadInCall12.types | 6 +- .../reference/iteratorSpreadInCall3.types | 2 +- .../reference/iteratorSpreadInCall5.types | 6 +- .../iteratorsAndStrictNullChecks.types | 14 +- ...sFileCompilationExternalPackageError.types | 10 +- .../jsFileCompilationLetBeingRenamed.types | 4 +- ...ileCompilationRestParamJsDocFunction.types | 12 +- .../jsFileCompilationShortHandProperty.types | 4 +- tests/baselines/reference/jsdocLiteral.types | 2 +- .../baselines/reference/json.stringify.types | 14 +- tests/baselines/reference/jsxHash.types | 6 +- .../reference/jsxPreserveWithJsInput.types | 10 +- .../reference/jsxReactTestSuite.types | 34 +- tests/baselines/reference/keywordField.types | 8 +- tests/baselines/reference/lambdaASIEmit.types | 2 +- .../reference/lambdaExpression.types | 8 +- .../letConstInCaseClauses.errors.txt | 8 +- .../letConstMatchingParameterNames.types | 12 +- .../reference/letDeclarations-access.types | 30 +- .../reference/letDeclarations-es5-1.types | 8 +- .../reference/letDeclarations-es5.types | 12 +- .../baselines/reference/letDeclarations.types | 12 +- .../reference/letDeclarations2.types | 4 +- .../letIdentifierInElementAccess01.types | 8 +- .../reference/letInNonStrictMode.types | 4 +- .../reference/letInVarDeclOfForIn_ES5.types | 12 +- .../reference/letInVarDeclOfForIn_ES6.types | 12 +- .../reference/letInVarDeclOfForOf_ES5.types | 12 +- .../reference/letInVarDeclOfForOf_ES6.types | 12 +- .../reference/library_ArraySlice.types | 6 +- .../library_DatePrototypeProperties.types | 30 +- .../library_ObjectPrototypeProperties.types | 4 +- .../library_RegExpExecArraySlice.types | 6 +- .../reference/library_StringSlice.types | 6 +- tests/baselines/reference/literals1.types | 22 +- .../reference/localClassesInLoop.types | 10 +- .../reference/localClassesInLoop_ES6.types | 10 +- .../localImportNameVsGlobalName.types | 8 +- tests/baselines/reference/localTypes1.types | 70 +- tests/baselines/reference/localTypes2.types | 12 +- tests/baselines/reference/localTypes3.types | 12 +- .../logicalAndOperatorStrictMode.types | 296 +++---- .../logicalAndOperatorWithEveryType.types | 8 +- .../logicalNotOperatorWithBooleanType.types | 16 +- .../logicalNotOperatorWithEnumType.types | 30 +- .../logicalNotOperatorWithNumberType.types | 20 +- .../logicalNotOperatorWithStringType.types | 26 +- .../logicalOrOperatorWithEveryType.types | 22 +- .../logicalOrOperatorWithTypeParameters.types | 2 +- .../matchReturnTypeInAllBranches.errors.txt | 4 +- .../matchingOfObjectLiteralConstraints.types | 4 +- .../reference/maxConstraints.errors.txt | 4 +- .../memberAccessMustUseModuleInstances.types | 2 +- .../memberVariableDeclarations1.types | 2 +- .../mergeWithImportedNamespace.types | 2 +- .../reference/mergedDeclarations1.types | 8 +- .../reference/mergedDeclarations4.types | 2 +- .../mergedInterfacesWithIndexers.types | 6 +- ...duleDeclarationWithSharedExportedVar.types | 2 +- .../methodContainingLocalFunction.types | 2 +- .../missingSemicolonInModuleSpecifier.types | 8 +- ...erOnClassDeclarationMemberInFunction.types | 2 +- ...ierOnClassExpressionMemberInFunction.types | 4 +- ...bolWithOutES6WellknownSymbolLib.errors.txt | 4 +- ...eLibrary_NoErrorDuplicateLibOptions1.types | 32 +- ...eLibrary_NoErrorDuplicateLibOptions2.types | 32 +- ...dularizeLibrary_TargetES5UsingES6Lib.types | 32 +- ...dularizeLibrary_TargetES6UsingES6Lib.types | 22 +- ...izeLibrary_UsingES5LibAndES6ArrayLib.types | 6 +- ...Library_UsingES5LibAndES6FeatureLibs.types | 6 +- ...5LibES6ArrayLibES6WellknownSymbolLib.types | 14 +- .../moduleAugmentationDeclarationEmit1.types | 2 +- .../moduleAugmentationDeclarationEmit2.types | 2 +- ...duleAugmentationExtendAmbientModule1.types | 2 +- ...duleAugmentationExtendAmbientModule2.types | 2 +- .../moduleAugmentationExtendFileModule1.types | 2 +- .../moduleAugmentationExtendFileModule2.types | 2 +- .../reference/moduleAugmentationGlobal1.types | 2 +- .../reference/moduleAugmentationGlobal2.types | 2 +- .../reference/moduleAugmentationGlobal3.types | 2 +- .../moduleAugmentationInAmbientModule5.types | 2 +- .../moduleAugmentationNoNewNames.types | 2 +- .../moduleAugmentationsBundledOutput1.types | 4 +- .../reference/moduleCodeGenTest3.types | 6 +- .../reference/moduleCodeGenTest5.types | 12 +- .../reference/moduleCodegenTest4.types | 8 +- .../reference/moduleIdentifiers.types | 2 +- .../moduleMemberWithoutTypeAnnotation1.types | 2 +- tests/baselines/reference/moduleMerge.types | 4 +- tests/baselines/reference/moduleNoEmit.types | 4 +- .../reference/modulePrologueAMD.types | 2 +- .../reference/modulePrologueCommonjs.types | 2 +- .../reference/modulePrologueES6.types | 2 +- .../reference/modulePrologueSystem.types | 2 +- .../reference/modulePrologueUmd.types | 2 +- .../reference/moduleResolutionNoResolve.types | 2 +- .../moduleResolutionWithExtensions.types | 4 +- ...eSameValueDuplicateExportedBindings1.types | 2 +- ...eSameValueDuplicateExportedBindings2.types | 4 +- tests/baselines/reference/moduleScoping.types | 16 +- ...resNameWithImportDeclarationInsideIt.types | 2 +- ...esNameWithImportDeclarationInsideIt2.types | 2 +- ...esNameWithImportDeclarationInsideIt4.types | 2 +- ...esNameWithImportDeclarationInsideIt6.types | 2 +- .../reference/moduleUnassignedVariable.types | 2 +- .../moduleVariableArrayIndexer.types | 2 +- .../baselines/reference/moduleVariables.types | 6 +- .../reference/moduleVisibilityTest1.types | 40 +- .../moduleWithStatementsOfEveryKind.types | 32 +- tests/baselines/reference/moduledecl.types | 14 +- .../reference/multiModuleClodule1.types | 6 +- .../reference/multiModuleFundule1.types | 6 +- .../reference/multipleDeclarations.types | 16 +- tests/baselines/reference/nameCollision.types | 22 +- ...ameCollisionWithBlockScopedVariable1.types | 2 +- .../nameCollisionsInPropertyAssignments.types | 2 +- .../reference/nameDelimitedBySlashes.types | 4 +- .../reference/nameWithFileExtension.types | 4 +- .../reference/nameWithRelativePaths.types | 6 +- .../namedFunctionExpressionInModule.types | 6 +- .../narrowingByDiscriminantInLoop.types | 4 +- .../reference/narrowingOfDottedNames.types | 4 +- .../negateOperatorWithAnyOtherType.types | 10 +- .../negateOperatorWithBooleanType.types | 16 +- .../negateOperatorWithEnumType.types | 20 +- .../negateOperatorWithNumberType.types | 24 +- .../negateOperatorWithStringType.types | 22 +- tests/baselines/reference/negativeZero.types | 4 +- .../nestedBlockScopedBindings1.types | 16 +- .../nestedBlockScopedBindings10.types | 10 +- .../nestedBlockScopedBindings11.types | 2 +- .../nestedBlockScopedBindings12.types | 10 +- .../nestedBlockScopedBindings2.types | 32 +- .../nestedBlockScopedBindings3.types | 30 +- .../nestedBlockScopedBindings4.types | 24 +- .../nestedBlockScopedBindings6.types | 48 +- .../nestedBlockScopedBindings9.types | 2 +- .../reference/nestedIfStatement.types | 8 +- .../reference/nestedLoopTypeGuards.types | 18 +- tests/baselines/reference/nestedModules.types | 4 +- .../nestedRedeclarationInES6AMD.types | 6 +- tests/baselines/reference/nestedSelf.types | 8 +- tests/baselines/reference/neverType.js | 4 +- tests/baselines/reference/neverType.types | 44 +- .../reference/neverTypeErrors1.errors.txt | 16 +- .../reference/neverTypeErrors2.errors.txt | 16 +- tests/baselines/reference/newArrays.types | 4 +- ...meterConstrainedToOuterTypeParameter.types | 2 +- .../reference/newLineFlagWithCRLF.types | 6 +- .../reference/newLineFlagWithLF.types | 6 +- .../reference/newOperatorConformance.types | 2 +- .../reference/newWithSpreadES5.types | 256 +++---- .../reference/newWithSpreadES6.types | 256 +++---- ...isExpressionAndLocalVarInConstructor.types | 4 +- ...nThisExpressionAndLocalVarInFunction.types | 2 +- ...ionThisExpressionAndLocalVarInLambda.types | 2 +- ...ionThisExpressionAndLocalVarInMethod.types | 6 +- ...nThisExpressionAndLocalVarInProperty.types | 6 +- ...ollisionThisExpressionAndVarInGlobal.types | 2 +- ...isExpressionInFunctionAndVarInGlobal.types | 2 +- .../reference/noEmitOnError.errors.txt | 4 +- .../reference/noErrorTruncation.errors.txt | 4 +- ...licitAnyDestructuringVarDeclaration2.types | 60 +- ...yInContextuallyTypesFunctionParamter.types | 8 +- .../noImplicitAnyIndexingSuppressed.types | 18 +- .../reference/noImplicitReturnsInAsync1.types | 2 +- ...oImplicitReturnsWithProtectedBlocks1.types | 2 +- .../reference/noImplicitUseStrict_amd.types | 2 +- .../noImplicitUseStrict_commonjs.types | 2 +- .../reference/noImplicitUseStrict_es6.types | 2 +- .../noImplicitUseStrict_system.types | 2 +- .../reference/noImplicitUseStrict_umd.types | 2 +- ...noReachabilityErrorsOnEmptyStatement.types | 2 +- .../baselines/reference/nodeResolution1.types | 2 +- .../baselines/reference/nodeResolution4.types | 2 +- .../baselines/reference/nodeResolution6.types | 2 +- .../baselines/reference/nodeResolution8.types | 2 +- .../reference/nonInstantiatedModule.types | 6 +- .../reference/nonIterableRestElement1.types | 4 +- .../reference/nonIterableRestElement2.types | 4 +- tests/baselines/reference/null.types | 8 +- ...ullIsSubtypeOfEverythingButUndefined.types | 116 +-- ...UndefinedTypeGuardIsOrderIndependent.types | 2 +- tests/baselines/reference/numberAsInLHS.types | 6 +- .../reference/numberPropertyAccess.types | 10 +- .../reference/numberToString.errors.txt | 4 +- .../numericIndexExpressions.errors.txt | 16 +- .../reference/numericIndexingResults.types | 72 +- .../reference/numericLiteralTypes1.types | 40 +- .../reference/numericLiteralTypes2.types | 44 +- .../reference/numericMethodName1.types | 2 +- ...ctBindingPatternKeywordIdentifiers05.types | 2 +- ...ctBindingPatternKeywordIdentifiers06.types | 2 +- ...onExpressionInFunctionParameter.errors.txt | 4 +- .../reference/objectLitGetterSetter.types | 14 +- .../baselines/reference/objectLiteral1.types | 4 +- .../baselines/reference/objectLiteral2.types | 4 +- .../objectLiteralArraySpecialization.types | 8 +- .../objectLiteralContextualTyping.types | 12 +- .../reference/objectLiteralErrors.errors.txt | 4 +- .../objectLiteralShorthandProperties.types | 2 +- ...LiteralShorthandPropertiesAssignment.types | 16 +- ...eralShorthandPropertiesAssignmentES6.types | 16 +- .../objectLiteralShorthandPropertiesES6.types | 2 +- ...lShorthandPropertiesFunctionArgument.types | 4 +- .../reference/objectTypePropertyAccess.types | 14 +- ...atureHidingMembersOfExtendedFunction.types | 4 +- ...atureHidingMembersOfExtendedFunction.types | 4 +- .../objectTypeWithNumericProperty.types | 36 +- ...ctTypeWithStringNamedNumericProperty.types | 174 ++--- ...ringNamedPropertyOfIllegalCharacters.types | 38 +- .../reference/objectTypesIdentity.types | 2 +- ...bjectTypesIdentityWithCallSignatures.types | 2 +- ...jectTypesIdentityWithCallSignatures2.types | 2 +- ...thCallSignaturesDifferingParamCounts.types | 2 +- ...ntityWithCallSignaturesWithOverloads.types | 2 +- ...ypesIdentityWithConstructSignatures2.types | 2 +- ...structSignaturesDifferingParamCounts.types | 2 +- ...CallSignaturesDifferingByConstraints.types | 2 +- ...allSignaturesDifferingByConstraints2.types | 2 +- ...allSignaturesDifferingByConstraints3.types | 2 +- ...ructSignaturesDifferingByConstraints.types | 2 +- ...uctSignaturesDifferingByConstraints2.types | 2 +- ...uctSignaturesDifferingByConstraints3.types | 2 +- ...ectTypesIdentityWithNumericIndexers1.types | 2 +- ...ectTypesIdentityWithNumericIndexers3.types | 2 +- .../objectTypesIdentityWithOptionality.types | 2 +- .../objectTypesIdentityWithPrivates.types | 2 +- .../objectTypesIdentityWithPublics.types | 2 +- ...bjectTypesIdentityWithStringIndexers.types | 2 +- .../reference/octalIntegerLiteral.types | 56 +- .../reference/octalIntegerLiteralES6.types | 56 +- .../operatorsAndIntersectionTypes.types | 20 +- .../optionalAccessorsInInterface1.types | 20 +- .../optionalBindingParameters1.errors.txt | 4 +- .../optionalBindingParameters2.errors.txt | 4 +- ...alBindingParametersInOverloads1.errors.txt | 4 +- ...alBindingParametersInOverloads2.errors.txt | 4 +- .../baselines/reference/optionalMethods.types | 18 +- ...optionalParamReferencingOtherParams1.types | 2 +- ...tionalParamterAndVariableDeclaration.types | 2 +- .../optionsInlineSourceMapSourceRoot.types | 2 +- .../optionsSourcemapInlineSources.types | 2 +- ...optionsSourcemapInlineSourcesMapRoot.types | 2 +- ...ionsSourcemapInlineSourcesSourceRoot.types | 2 +- tests/baselines/reference/out-flag.types | 2 +- .../baselines/reference/overload1.errors.txt | 4 +- .../reference/overloadCallTest.types | 6 +- .../overloadOnConstAsTypeAnnotation.types | 4 +- .../overloadOnConstConstraintChecks3.types | 2 +- .../overloadOnConstConstraintChecks4.types | 2 +- .../overloadOnConstInCallback1.types | 6 +- ...rloadOnConstNoAnyImplementation.errors.txt | 4 +- ...loadOnConstNoAnyImplementation2.errors.txt | 12 +- ...verloadOnConstNoStringImplementation.types | 28 +- ...dOnConstNoStringImplementation2.errors.txt | 8 +- .../reference/overloadResolution.errors.txt | 20 +- ...loadResolutionClassConstructors.errors.txt | 20 +- .../overloadResolutionConstructors.errors.txt | 20 +- .../overloadResolutionOverNonCTLambdas.types | 4 +- ...overloadResolutionOverNonCTObjectLit.types | 14 +- .../overloadResolutionTest1.errors.txt | 20 +- .../reference/overloadResolutionWithAny.types | 12 +- .../reference/overloadReturnTypes.types | 2 +- ...lbacksWithDifferingOptionalityOnArgs.types | 8 +- .../overloadsAndTypeArgumentArity.types | 4 +- .../reference/overloadsWithConstraints.types | 2 +- .../parenthesizedContexualTyping1.types | 32 +- .../parenthesizedContexualTyping2.types | 32 +- .../parenthesizedContexualTyping3.types | 14 +- ...ationInStrictModeByDefaultInES6.errors.txt | 4 +- .../baselines/reference/parser509546_2.types | 2 +- tests/baselines/reference/parser630933.types | 2 +- tests/baselines/reference/parser768531.types | 2 +- .../parserAccessibilityAfterStatic3.types | 2 +- .../parserAmbiguityWithBinaryOperator1.types | 2 +- .../parserAmbiguityWithBinaryOperator2.types | 2 +- .../parserAmbiguityWithBinaryOperator3.types | 2 +- .../parserArrayLiteralExpression10.types | 4 +- .../parserArrayLiteralExpression11.types | 4 +- .../parserArrayLiteralExpression12.types | 4 +- .../parserArrayLiteralExpression13.types | 6 +- .../parserArrayLiteralExpression14.types | 12 +- .../parserArrayLiteralExpression15.types | 12 +- .../parserArrayLiteralExpression5.types | 2 +- .../parserArrayLiteralExpression6.types | 2 +- .../parserArrayLiteralExpression7.types | 2 +- .../parserArrayLiteralExpression8.types | 2 +- .../parserArrayLiteralExpression9.types | 4 +- .../reference/parserDoStatement2.types | 4 +- .../reference/parserEmptyStatement1.types | 2 +- tests/baselines/reference/parserEnum1.types | 12 +- tests/baselines/reference/parserEnum2.types | 12 +- .../reference/parserEnumDeclaration1.types | 6 +- .../reference/parserEnumDeclaration3.types | 2 +- .../reference/parserEnumDeclaration5.types | 12 +- .../reference/parserEnumDeclaration6.types | 6 +- ...orRecovery_IncompleteMemberVariable1.types | 8 +- .../parserGreaterThanTokenAmbiguity1.types | 4 +- .../parserGreaterThanTokenAmbiguity10.types | 4 +- ...arserGreaterThanTokenAmbiguity2.errors.txt | 4 +- ...arserGreaterThanTokenAmbiguity3.errors.txt | 4 +- ...arserGreaterThanTokenAmbiguity4.errors.txt | 4 +- .../parserGreaterThanTokenAmbiguity5.types | 4 +- .../parserGreaterThanTokenAmbiguity6.types | 4 +- .../parserInterfaceKeywordInEnum1.types | 2 +- .../parserKeywordsAsIdentifierName1.types | 6 +- tests/baselines/reference/parserModule1.types | 4 +- .../reference/parserModuleDeclaration11.types | 2 +- .../reference/parserObjectLiterals1.types | 4 +- .../reference/parserSbp_7.9_A9_T3.types | 4 +- .../reference/parserStrictMode16.types | 6 +- .../reference/parserStrictMode5.errors.txt | 4 +- .../reference/parserSymbolProperty6.types | 2 +- .../baselines/reference/parserUnicode2.types | 2 +- .../reference/parserVoidExpression1.types | 2 +- ...r_breakInIterationOrSwitchStatement1.types | 2 +- ...r_breakInIterationOrSwitchStatement2.types | 2 +- .../reference/parser_breakTarget2.types | 2 +- .../reference/parser_breakTarget3.types | 2 +- .../reference/parser_breakTarget4.types | 2 +- ...parser_continueInIterationStatement1.types | 2 +- ...parser_continueInIterationStatement2.types | 2 +- .../reference/parser_continueLabel.types | 4 +- .../reference/parser_continueTarget2.types | 2 +- .../reference/parser_continueTarget3.types | 2 +- .../reference/parser_continueTarget4.types | 2 +- .../reference/parser_duplicateLabel3.types | 4 +- .../reference/parser_duplicateLabel4.types | 4 +- ...appingBasedModuleResolution3_classic.types | 4 +- ...thMappingBasedModuleResolution3_node.types | 2 +- ...appingBasedModuleResolution4_classic.types | 4 +- ...thMappingBasedModuleResolution4_node.types | 2 +- ...appingBasedModuleResolution5_classic.types | 8 +- ...thMappingBasedModuleResolution5_node.types | 6 +- .../plusOperatorWithBooleanType.types | 16 +- .../reference/plusOperatorWithEnumType.types | 18 +- .../plusOperatorWithNumberType.types | 20 +- .../plusOperatorWithStringType.types | 22 +- ...ixIncrementAsOperandOfPlusExpression.types | 4 +- ...fixUnaryOperatorsOnExportedVariables.types | 18 +- .../reference/preserveConstEnums.types | 2 +- .../primitiveConstraints2.errors.txt | 4 +- ...ivacyCheckAnonymousFunctionParameter.types | 2 +- ...vacyCheckAnonymousFunctionParameter2.types | 2 +- ...ssignmentOnExportedGenericInterface2.types | 2 +- .../baselines/reference/privateVisibles.types | 2 +- .../amd/nodeModulesImportHigher.errors.txt | 4 +- .../node/nodeModulesImportHigher.errors.txt | 4 +- .../nodeModulesMaxDepthExceeded.errors.txt | 8 +- .../nodeModulesMaxDepthExceeded.errors.txt | 8 +- .../nodeModulesMaxDepthIncreased.errors.txt | 4 +- .../nodeModulesMaxDepthIncreased.errors.txt | 4 +- .../baselines/reference/promiseChaining.types | 4 +- .../reference/promiseChaining1.errors.txt | 8 +- .../reference/promiseChaining2.errors.txt | 8 +- tests/baselines/reference/promiseType.types | 36 +- .../reference/promiseTypeInference.types | 2 +- .../reference/promiseVoidErrorCallback.types | 6 +- .../propagationOfPromiseInitialization.types | 8 +- tests/baselines/reference/properties.types | 2 +- .../baselines/reference/propertyAccess6.types | 4 +- ...AccessOnTypeParameterWithConstraints.types | 8 +- ...ccessOnTypeParameterWithConstraints2.types | 16 +- ...ccessOnTypeParameterWithConstraints3.types | 16 +- ...essOnTypeParameterWithoutConstraints.types | 10 +- .../propertyNamesOfReservedWords.types | 134 ++-- .../propertyNamesWithStringLiteral.types | 4 +- .../protoAsIndexInIndexExpression.types | 6 +- .../baselines/reference/protoInIndexer.types | 2 +- .../prototypeOnConstructorFunctions.types | 4 +- ...tions-entity-names-referencing-a-var.types | 2 +- tests/baselines/reference/qualify.errors.txt | 8 +- .../reference/quotedPropertyName1.types | 2 +- .../reference/quotedPropertyName2.types | 2 +- .../reference/quotedPropertyName3.types | 2 +- .../reference/randomSemicolons1.types | 2 +- .../reachabilityCheckWithEmptyDefault.types | 2 +- .../reference/reactNamespaceJSXEmit.types | 2 +- .../reference/readonlyInDeclarationFile.types | 28 +- .../reference/reboundBaseClassSymbol.types | 2 +- ...nstantiationsWithDefaultConstructors.types | 2 +- .../recursiveComplicatedClasses.types | 2 +- .../recursiveFunctionTypes.errors.txt | 20 +- .../reference/recursiveInference1.types | 8 +- .../reference/recursiveInitializer.types | 4 +- tests/baselines/reference/recursiveMods.types | 2 +- .../regExpWithSlashInCharClass.types | 12 +- .../relativeModuleWithoutSlash.types | 4 +- .../relativePathToDeclarationFile.types | 2 +- .../reference/requireEmitSemicolon.types | 2 +- .../requiredInitializedParameter3.types | 2 +- .../requiredInitializedParameter4.types | 2 +- tests/baselines/reference/reservedWords.types | 18 +- .../restElementWithAssignmentPattern5.types | 4 +- .../restParameterNoTypeAnnotation.types | 2 +- .../reference/returnInConstructor1.errors.txt | 8 +- .../reference/returnStatement1.types | 4 +- .../reference/returnStatements.types | 8 +- ...seInferenceInContextualInstantiation.types | 2 +- .../reversedRecusiveTypeInstantiation.types | 4 +- .../reference/scannerES3NumericLiteral1.types | 2 +- .../reference/scannerES3NumericLiteral2.types | 2 +- .../reference/scannerES3NumericLiteral5.types | 2 +- .../reference/scannerES3NumericLiteral7.types | 2 +- tests/baselines/reference/scannerEnum1.types | 8 +- .../reference/scannerNumericLiteral1.types | 2 +- .../reference/scannerNumericLiteral5.types | 2 +- .../reference/scannerNumericLiteral7.types | 2 +- ...gLiteralWithContainingNullCharacter1.types | Bin 132 -> 132 bytes .../scannerUnicodeEscapeInKeyword1.types | 2 +- .../baselines/reference/selfInCallback.types | 4 +- tests/baselines/reference/selfInLambdas.types | 4 +- tests/baselines/reference/shebang.types | 2 +- ...fExportedEntity01_targetES2015_CommonJS.js | 2 +- ...portedEntity01_targetES2015_CommonJS.types | 6 +- ...ndOfExportedEntity02_targetES5_CommonJS.js | 2 +- ...fExportedEntity02_targetES5_CommonJS.types | 6 +- ...pertyAssignmentsInDestructuring.errors.txt | 24 +- ...yAssignmentsInDestructuring_ES6.errors.txt | 24 +- ...naturesUseJSDocForOptionalParameters.types | 4 +- ...LineCommentInConciseArrowFunctionES3.types | 2 +- .../reference/sourceMap-Comments.types | 2 +- .../sourceMap-FileWithComments.types | 12 +- ...terfacePrecedingVariableDeclaration1.types | 2 +- .../reference/sourceMap-LineBreaks.types | 20 +- .../sourceMap-StringLiteralWithNewLine.types | 4 +- ...oduleWithCommentPrecedingStatement01.types | 2 +- ...ctionWithCommentPrecedingStatement01.types | 2 +- .../reference/sourceMapValidationClass.types | 6 +- ...alidationClassWithDefaultConstructor.types | 4 +- ...tConstructorAndCapturedThisStatement.types | 2 +- ...thDefaultConstructorAndExtendsClause.types | 4 +- .../sourceMapValidationClasses.types | 20 +- .../sourceMapValidationDecorators.types | 24 +- ...nDestructuringForArrayBindingPattern.types | 162 ++-- ...DestructuringForArrayBindingPattern2.types | 258 +++---- ...gForArrayBindingPatternDefaultValues.types | 258 +++---- ...ForArrayBindingPatternDefaultValues2.types | 404 +++++----- ...DestructuringForObjectBindingPattern.types | 78 +- ...estructuringForObjectBindingPattern2.types | 242 +++--- ...ForObjectBindingPatternDefaultValues.types | 150 ++-- ...orObjectBindingPatternDefaultValues2.types | 386 +++++----- ...estructuringForOfArrayBindingPattern.types | 24 +- ...structuringForOfArrayBindingPattern2.types | 24 +- ...orOfArrayBindingPatternDefaultValues.types | 138 ++-- ...rOfArrayBindingPatternDefaultValues2.types | 210 ++--- ...structuringForOfObjectBindingPattern.types | 60 +- ...tructuringForOfObjectBindingPattern2.types | 100 +-- ...rOfObjectBindingPatternDefaultValues.types | 132 ++-- ...OfObjectBindingPatternDefaultValues2.types | 244 +++--- ...gParameterNestedObjectBindingPattern.types | 24 +- ...tedObjectBindingPatternDefaultValues.types | 46 +- ...cturingParameterObjectBindingPattern.types | 18 +- ...terObjectBindingPatternDefaultValues.types | 26 +- ...cturingParametertArrayBindingPattern.types | 30 +- ...turingParametertArrayBindingPattern2.types | 30 +- ...tertArrayBindingPatternDefaultValues.types | 80 +- ...ertArrayBindingPatternDefaultValues2.types | 52 +- ...dationDestructuringVariableStatement.types | 14 +- ...ationDestructuringVariableStatement1.types | 28 +- ...VariableStatementArrayBindingPattern.types | 24 +- ...ariableStatementArrayBindingPattern2.types | 28 +- ...ariableStatementArrayBindingPattern3.types | 72 +- ...ariableStatementArrayBindingPattern4.types | 4 +- ...ariableStatementArrayBindingPattern5.types | 8 +- ...ariableStatementArrayBindingPattern6.types | 6 +- ...ariableStatementArrayBindingPattern7.types | 6 +- ...mentArrayBindingPatternDefaultValues.types | 54 +- ...entArrayBindingPatternDefaultValues2.types | 56 +- ...entArrayBindingPatternDefaultValues3.types | 204 ++--- ...turingVariableStatementDefaultValues.types | 24 +- ...eStatementNestedObjectBindingPattern.types | 18 +- ...bjectBindingPatternWithDefaultValues.types | 46 +- ...riableStatementObjectBindingPattern1.types | 2 +- ...riableStatementObjectBindingPattern2.types | 6 +- ...riableStatementObjectBindingPattern3.types | 4 +- ...riableStatementObjectBindingPattern4.types | 6 +- .../reference/sourceMapValidationDo.types | 6 +- ...urceMapValidationFunctionExpressions.types | 4 +- .../sourceMapValidationFunctions.types | 6 +- .../reference/sourceMapValidationIfElse.types | 4 +- .../sourceMapValidationLabeled.types | 2 +- .../reference/sourceMapValidationModule.types | 4 +- .../reference/sourceMapValidationSwitch.types | 6 +- .../sourceMapValidationTryCatchFinally.types | 14 +- .../sourceMapValidationVariables.types | 6 +- .../reference/sourceMapValidationWhile.types | 2 +- .../sourceMapValidationWithComments.types | 4 +- ...rceMapWithMultipleFilesWithCopyright.types | 4 +- ...ipleFilesWithFileEndingWithInterface.types | 2 +- .../sourcemapValidationDuplicateNames.types | 2 +- .../reference/specializeVarArgs1.types | 2 +- ...edSignatureAsCallbackParameter1.errors.txt | 8 +- ...ymousTypeNotReferencingTypeParameter.types | 56 +- .../baselines/reference/staticFactory1.types | 4 +- .../reference/staticInstanceResolution.types | 2 +- .../reference/staticInstanceResolution2.types | 4 +- .../reference/staticInstanceResolution3.types | 2 +- .../staticMemberAccessOffDerivedType1.types | 2 +- .../staticMemberInitialization.types | 2 +- ...staticMemberWithStringAndNumberNames.types | 16 +- tests/baselines/reference/stradac.types | 2 +- .../strictModeUseContextualKeyword.types | 6 +- .../strictModeWordInExportDeclaration.types | 4 +- .../strictNullChecksNoWidening.types | 2 +- .../reference/strictNullLogicalAndOr.types | 6 +- .../stringHasStringValuedNumericIndexer.types | 4 +- .../baselines/reference/stringIncludes.types | 10 +- .../reference/stringIndexingResults.types | 28 +- .../stringLiteralCheckedInIf01.types | 2 +- .../stringLiteralCheckedInIf02.types | 2 +- .../stringLiteralMatchedInSwitch01.types | 2 +- ...ringLiteralObjectLiteralDeclaration1.types | 2 +- ...ralPropertyNameWithLineContinuation1.types | 6 +- ...lTypesAndLogicalOrExpressions01.errors.txt | 18 + ...ngLiteralTypesAndLogicalOrExpressions01.js | 4 +- .../stringLiteralTypesAndTuples01.js | 2 +- .../stringLiteralTypesAndTuples01.types | 20 +- .../stringLiteralTypesAsTags01.types | 4 +- .../stringLiteralTypesAsTags02.types | 4 +- .../stringLiteralTypesAsTags03.types | 4 +- ...LiteralTypesAsTypeParameterConstraint01.js | 6 +- ...eralTypesAsTypeParameterConstraint01.types | 8 +- ...LiteralTypesAsTypeParameterConstraint02.js | 2 +- ...eralTypesAsTypeParameterConstraint02.types | 2 +- ...tringLiteralTypesInUnionTypes01.errors.txt | 26 + .../stringLiteralTypesInUnionTypes02.types | 10 +- ...tringLiteralTypesInUnionTypes03.errors.txt | 28 + .../stringLiteralTypesInUnionTypes04.types | 16 +- ...gLiteralTypesOverloadAssignability03.types | 4 +- ...gLiteralTypesOverloadAssignability04.types | 4 +- ...gLiteralTypesOverloadAssignability05.types | 4 +- .../stringLiteralTypesOverloads01.types | 6 +- .../stringLiteralTypesOverloads02.js | 8 +- .../stringLiteralTypesOverloads02.symbols | 8 +- .../stringLiteralTypesOverloads02.types | 16 +- .../stringLiteralTypesOverloads04.js | 2 +- .../stringLiteralTypesOverloads04.symbols | 6 +- .../stringLiteralTypesOverloads04.types | 6 +- .../stringLiteralTypesTypePredicates01.types | 8 +- ...ngLiteralTypesWithVariousOperators01.types | 20 +- ...eralTypesWithVariousOperators02.errors.txt | 16 +- ...alsAssertionsInEqualityComparisons01.types | 6 +- ...sertionsInEqualityComparisons02.errors.txt | 8 +- ...gLiteralsWithSwitchStatements03.errors.txt | 15 +- ...gLiteralsWithSwitchStatements04.errors.txt | 28 + ...ingLiteralsWithTypeAssertions01.errors.txt | 25 - ...stringLiteralsWithTypeAssertions01.symbols | 26 + .../stringLiteralsWithTypeAssertions01.types | 35 + .../reference/stringNamedPropertyAccess.types | 12 +- .../reference/stringPropCodeGen.types | 2 +- .../reference/stringPropertyAccess.types | 14 +- .../stringPropertyAccessWithError.errors.txt | 4 +- tests/baselines/reference/structural1.types | 4 +- tests/baselines/reference/styleOptions.types | 4 +- .../reference/subtypeRelationForNever.types | 10 +- tests/baselines/reference/subtypesOfAny.types | 4 +- ...typesOfTypeParameterWithConstraints2.types | 144 ++-- ...typesOfTypeParameterWithConstraints3.types | 12 +- .../reference/subtypingTransitivity.types | 8 +- .../subtypingWithCallSignatures.types | 16 +- .../subtypingWithCallSignatures2.types | 14 +- .../subtypingWithCallSignatures3.types | 10 +- .../subtypingWithCallSignatures4.types | 8 +- .../subtypingWithCallSignaturesA.errors.txt | 8 +- ...ubtypingWithObjectMembersOptionality.types | 4 +- ...btypingWithObjectMembersOptionality3.types | 2 +- ...btypingWithObjectMembersOptionality4.types | 2 +- tests/baselines/reference/super2.types | 10 +- .../superCallArgsMustMatch.errors.txt | 4 +- .../superCallAssignResult.errors.txt | 4 +- tests/baselines/reference/superCalls.types | 8 +- ...InComputedPropertiesOfNestedType_ES5.types | 6 +- ...InComputedPropertiesOfNestedType_ES6.types | 6 +- .../superPropertyAccessNoError.types | 4 +- .../reference/superPropertyAccess_ES6.types | 6 +- .../reference/superSymbolIndexedAccess1.types | 4 +- .../reference/superSymbolIndexedAccess2.types | 2 +- .../reference/superSymbolIndexedAccess5.types | 2 +- .../reference/superSymbolIndexedAccess6.types | 2 +- .../switchAssignmentCompat.errors.txt | 4 +- .../switchBreakStatements.errors.txt | 92 +++ .../reference/switchCases.errors.txt | 11 + ...itchCasesExpressionTypeMismatch.errors.txt | 17 +- .../reference/switchFallThroughs.types | 6 +- .../reference/symbolDeclarationEmit10.types | 2 +- .../reference/symbolDeclarationEmit11.types | 4 +- .../reference/symbolDeclarationEmit13.types | 2 +- .../reference/symbolDeclarationEmit14.types | 4 +- .../reference/symbolDeclarationEmit2.types | 2 +- .../reference/symbolDeclarationEmit4.types | 2 +- .../reference/symbolDeclarationEmit8.types | 2 +- .../baselines/reference/symbolProperty1.types | 4 +- .../reference/symbolProperty18.types | 4 +- .../baselines/reference/symbolProperty2.types | 4 +- .../reference/symbolProperty22.types | 2 +- .../reference/symbolProperty23.types | 2 +- .../reference/symbolProperty26.types | 4 +- .../reference/symbolProperty27.types | 2 +- .../reference/symbolProperty28.types | 2 +- .../baselines/reference/symbolProperty4.types | 4 +- .../reference/symbolProperty40.types | 4 +- .../reference/symbolProperty41.types | 2 +- .../reference/symbolProperty45.types | 4 +- .../reference/symbolProperty46.errors.txt | 4 +- .../reference/symbolProperty47.errors.txt | 8 +- .../baselines/reference/symbolProperty5.types | 4 +- .../reference/symbolProperty55.types | 2 +- .../reference/symbolProperty56.types | 4 +- .../reference/symbolProperty57.types | 4 +- .../baselines/reference/symbolProperty6.types | 4 +- tests/baselines/reference/symbolType11.types | 10 +- .../reference/symbolType12.errors.txt | 4 +- .../reference/symbolType6.errors.txt | 8 +- tests/baselines/reference/systemModule1.types | 2 +- .../baselines/reference/systemModule13.types | 12 +- .../baselines/reference/systemModule15.types | 4 +- .../baselines/reference/systemModule17.types | 4 +- tests/baselines/reference/systemModule4.types | 2 +- tests/baselines/reference/systemModule7.types | 2 +- tests/baselines/reference/systemModule8.types | 54 +- .../systemModuleAmbientDeclarations.types | 4 +- .../reference/systemModuleTargetES6.types | 2 +- .../taggedTemplateContextualTyping1.types | 4 +- .../taggedTemplateContextualTyping2.types | 6 +- ...gedTemplateStringsHexadecimalEscapes.types | 2 +- ...TemplateStringsHexadecimalEscapesES6.types | 2 +- ...ainCharactersThatArePartsOfEscapes02.types | 58 +- ...haractersThatArePartsOfEscapes02_ES6.types | 58 +- ...tringsWithIncompatibleTypedTags.errors.txt | 24 +- ...ngsWithIncompatibleTypedTagsES6.errors.txt | 24 +- ...ingsWithManyCallAndMemberExpressions.types | 6 +- ...sWithManyCallAndMemberExpressionsES6.types | 6 +- ...eStringsWithOverloadResolution1.errors.txt | 4 +- ...ingsWithOverloadResolution1_ES6.errors.txt | 4 +- ...mplateStringsWithOverloadResolution2.types | 8 +- ...teStringsWithOverloadResolution2_ES6.types | 8 +- ...eStringsWithOverloadResolution3.errors.txt | 8 +- ...ingsWithOverloadResolution3_ES6.errors.txt | 8 +- ...edTemplateStringsWithTagNamedDeclare.types | 2 +- ...emplateStringsWithTagNamedDeclareES6.types | 2 +- ...gedTemplateStringsWithTagsTypedAsAny.types | 40 +- ...TemplateStringsWithTagsTypedAsAnyES6.types | 40 +- ...essionsInSubstitutionExpression.errors.txt | 4 +- ...ionsInSubstitutionExpressionES6.errors.txt | 4 +- .../taggedTemplateStringsWithTypedTags.types | 36 +- ...aggedTemplateStringsWithTypedTagsES6.types | 36 +- ...gedTemplateStringsWithUnicodeEscapes.types | 2 +- ...TemplateStringsWithUnicodeEscapesES6.types | 2 +- ...hIncompleteTemplateExpressions3.errors.txt | 4 +- ...hIncompleteTemplateExpressions6.errors.txt | 4 +- .../baselines/reference/targetTypeArgs.types | 14 +- .../reference/targetTypeBaseCalls.errors.txt | 12 +- .../baselines/reference/targetTypeCalls.types | 2 +- .../reference/targetTypeObjectLiteral.types | 10 +- .../targetTypeObjectLiteralToAny.types | 2 +- .../baselines/reference/targetTypeTest2.types | 6 +- .../templateStringBinaryOperations.types | 296 +++---- .../templateStringBinaryOperationsES6.types | 296 +++---- .../reference/templateStringInArray.types | 6 +- .../templateStringInConditional.types | 6 +- .../templateStringInConditionalES6.types | 6 +- .../templateStringInDeleteExpression.types | 2 +- .../templateStringInDeleteExpressionES6.types | 2 +- .../templateStringInEqualityChecks.types | 8 +- .../templateStringInEqualityChecksES6.types | 8 +- .../templateStringInFunctionExpression.types | 4 +- ...emplateStringInFunctionExpressionES6.types | 4 +- .../templateStringInInOperator.types | 6 +- .../templateStringInInOperatorES6.types | 6 +- .../templateStringInIndexExpression.types | 2 +- .../templateStringInIndexExpressionES6.types | 2 +- .../templateStringInParentheses.types | 2 +- .../templateStringInParenthesesES6.types | 2 +- .../templateStringInPropertyAssignment.types | 4 +- ...emplateStringInPropertyAssignmentES6.types | 4 +- .../templateStringInSwitchAndCase.types | 6 +- .../templateStringInSwitchAndCaseES6.types | 6 +- .../templateStringInTypeAssertion.types | 2 +- .../templateStringInTypeAssertionES6.types | 2 +- .../reference/templateStringInTypeOf.types | 2 +- .../reference/templateStringInTypeOfES6.types | 2 +- .../reference/templateStringInUnaryPlus.types | 2 +- .../templateStringInUnaryPlusES6.types | 2 +- .../reference/templateStringInWhile.types | 4 +- .../reference/templateStringInWhileES6.types | 4 +- ...ainCharactersThatArePartsOfEscapes02.types | 58 +- ...haractersThatArePartsOfEscapes02_ES6.types | 58 +- .../templateStringWithEmbeddedAddition.types | 4 +- ...emplateStringWithEmbeddedAdditionES6.types | 4 +- .../templateStringWithEmbeddedArray.types | 6 +- .../templateStringWithEmbeddedArrayES6.types | 6 +- .../templateStringWithEmbeddedComments.types | 4 +- ...emplateStringWithEmbeddedCommentsES6.types | 4 +- ...emplateStringWithEmbeddedConditional.types | 8 +- ...lateStringWithEmbeddedConditionalES6.types | 8 +- .../templateStringWithEmbeddedDivision.types | 4 +- ...emplateStringWithEmbeddedDivisionES6.types | 4 +- ...templateStringWithEmbeddedInOperator.types | 6 +- ...plateStringWithEmbeddedInOperatorES6.types | 6 +- .../templateStringWithEmbeddedModulo.types | 4 +- .../templateStringWithEmbeddedModuloES6.types | 4 +- ...lateStringWithEmbeddedMultiplication.types | 4 +- ...eStringWithEmbeddedMultiplicationES6.types | 4 +- ...emplateStringWithEmbeddedNewOperator.types | 2 +- ...lateStringWithEmbeddedNewOperatorES6.types | 2 +- ...plateStringWithEmbeddedObjectLiteral.types | 4 +- ...teStringWithEmbeddedObjectLiteralES6.types | 4 +- ...lateStringWithEmbeddedTemplateString.types | 4 +- ...eStringWithEmbeddedTemplateStringES6.types | 4 +- ...gWithEmbeddedTypeAssertionOnAddition.types | 4 +- ...thEmbeddedTypeAssertionOnAdditionES6.types | 4 +- ...lateStringWithEmbeddedTypeOfOperator.types | 2 +- ...eStringWithEmbeddedTypeOfOperatorES6.types | 2 +- ...ateStringWithEmbeddedYieldKeywordES6.types | 4 +- ...mplateStringWithEmptyLiteralPortions.types | 40 +- ...ateStringWithEmptyLiteralPortionsES6.types | 40 +- ...StringWithOpenCommentInStringPortion.types | 4 +- ...ingWithOpenCommentInStringPortionES6.types | 4 +- .../templateStringWithPropertyAccess.types | 2 +- .../templateStringWithPropertyAccessES6.types | 2 +- ...essionsInSubstitutionExpression.errors.txt | 4 +- ...ionsInSubstitutionExpressionES6.errors.txt | 4 +- .../ternaryExpressionSourceMap.types | 6 +- tests/baselines/reference/thisBinding2.types | 8 +- tests/baselines/reference/thisCapture1.types | 6 +- .../thisInGenericStaticMembers.types | 4 +- .../reference/thisInInnerFunctions.types | 6 +- tests/baselines/reference/thisInLambda.types | 2 +- .../thisInPropertyBoundDeclarations.types | 4 +- .../reference/thisInStaticMethod1.types | 2 +- .../reference/thisTypeInAccessors.types | 12 +- .../reference/thisTypeInFunctions.types | 86 +-- .../reference/thisTypeInFunctions2.types | 12 +- .../thisTypeInFunctionsNegative.errors.txt | 20 +- .../reference/thisTypeInObjectLiterals.types | 8 +- .../reference/thisTypeInTuples.types | 10 +- .../throwInEnclosingStatements.types | 14 +- .../baselines/reference/throwStatements.types | 34 +- .../reference/toStringOnPrimitives.types | 8 +- tests/baselines/reference/topLevel.types | 24 +- .../reference/topLevelAmbientModule.types | 2 +- .../baselines/reference/topLevelExports.types | 2 +- .../reference/trailingCommasES3.types | 22 +- .../reference/trailingCommasES5.types | 22 +- ...mmasInFunctionParametersAndArguments.types | 10 +- .../reference/tsxAttributeErrors.errors.txt | 8 +- .../tsxAttributeResolution1.errors.txt | 12 +- .../tsxAttributeResolution10.errors.txt | 4 +- .../tsxAttributeResolution14.errors.txt | 8 +- .../tsxAttributeResolution3.errors.txt | 4 +- .../tsxAttributeResolution6.errors.txt | 4 +- .../tsxAttributeResolution7.errors.txt | 4 +- .../tsxAttributeResolution9.errors.txt | 4 +- .../reference/tsxDynamicTagName1.types | 2 +- .../reference/tsxDynamicTagName5.types | 2 +- .../reference/tsxDynamicTagName6.types | 2 +- .../reference/tsxDynamicTagName8.types | 2 +- .../tsxElementResolution12.errors.txt | 4 +- .../reference/tsxElementResolution13.types | 2 +- .../reference/tsxElementResolution14.types | 2 +- .../reference/tsxElementResolution9.types | 2 +- tests/baselines/reference/tsxEmit1.types | 4 +- tests/baselines/reference/tsxEmit3.types | 2 +- .../tsxGenericArrowFunctionParsing.types | 2 +- tests/baselines/reference/tsxReactEmit1.types | 4 +- .../reference/tsxReactEmitNesting.types | 8 +- .../reference/tsxReactEmitWhitespace.types | 2 +- ...tsxStatelessFunctionComponents1.errors.txt | 4 +- tests/baselines/reference/tsxTypeErrors.types | 8 +- .../reference/tupleElementTypes3.types | 2 +- .../reference/tupleElementTypes4.types | 2 +- ...rgedInterfacesWithDifferingOverloads.types | 8 +- ...gedInterfacesWithDifferingOverloads2.types | 10 +- tests/baselines/reference/typeAliases.types | 6 +- ...notationBestCommonTypeInArrayLiteral.types | 16 +- .../reference/typeArgInference.types | 4 +- .../reference/typeArgInferenceWithNull.types | 2 +- ...peArgumentConstraintResolution1.errors.txt | 8 +- .../typeArgumentInferenceApparentType1.types | 2 +- ...entInferenceConstructSignatures.errors.txt | 12 +- .../typeArgumentInferenceErrors.errors.txt | 12 +- ...rgumentInferenceWithClassExpression1.types | 2 +- ...rgumentInferenceWithClassExpression3.types | 2 +- ...rgumentInferenceWithConstraints.errors.txt | 8 +- ...OnFunctionsWithNoTypeParameters.errors.txt | 4 +- ...gumentsWithStringLiteralTypes01.errors.txt | 52 +- .../typeArgumentsWithStringLiteralTypes01.js | 8 +- ...eAssertionToGenericFunctionType.errors.txt | 4 +- ...InsideFunctionExpressionInArray.errors.txt | 4 +- .../reference/typeGuardFunction.types | 2 +- .../typeGuardFunctionErrors.errors.txt | 8 +- .../reference/typeGuardFunctionGenerics.types | 2 +- .../reference/typeGuardNesting.types | 8 +- .../typeGuardOfFormFunctionEquality.types | 14 +- .../reference/typeGuardsAsAssertions.types | 22 +- .../typeGuardsInConditionalExpression.types | 52 +- .../reference/typeGuardsInDoStatement.types | 4 +- ...GuardsInRightOperandOfAndAndOperator.types | 18 +- ...peGuardsInRightOperandOfOrOrOperator.types | 18 +- .../typeGuardsNestedAssignments.types | 6 +- .../reference/typeGuardsOnClassProperty.types | 8 +- ...nstanceOfByConstructorSignature.errors.txt | 4 +- .../typeInferenceFBoundedTypeParams.types | 10 +- .../reference/typeInferenceFixEarly.types | 4 +- .../typeInferenceWithTupleType.types | 24 +- .../baselines/reference/typeName1.errors.txt | 56 +- .../typeOfEnumAndVarRedeclarations.errors.txt | 8 +- .../reference/typeOfOnTypeArg.errors.txt | 4 +- .../baselines/reference/typeOfPrototype.types | 4 +- .../reference/typeOfThisInStaticMembers.types | 8 +- .../typeParameterAndArgumentOfSameName1.types | 2 +- .../typeParameterAsElementType.types | 2 +- ...peParameterAsTypeParameterConstraint.types | 30 +- ...meterAsTypeParameterConstraint2.errors.txt | 4 +- ...sTypeParameterConstraintTransitively.types | 30 +- ...TypeParameterConstraintTransitively2.types | 24 +- .../reference/typeReferenceDirectives7.types | 2 +- .../reference/typeReferenceDirectives8.types | 2 +- tests/baselines/reference/typeVal.types | 6 +- tests/baselines/reference/typedArrays.types | 234 +++--- .../typedGenericPrototypeMember.types | 2 +- tests/baselines/reference/typeofEnum.types | 8 +- .../baselines/reference/typeofInterface.types | 2 +- .../typeofModuleWithoutExports.types | 2 +- .../typeofOperatorWithBooleanType.types | 20 +- .../typeofOperatorWithEnumType.types | 24 +- .../typeofOperatorWithNumberType.types | 24 +- .../reference/typesWithOptionalProperty.types | 12 +- .../typesWithSpecializedCallSignatures.types | 2 +- ...esWithSpecializedConstructSignatures.types | 4 +- .../baselines/reference/typingsLookup4.types | 8 +- .../reference/umd-augmentation-1.types | 8 +- .../reference/umd-augmentation-2.types | 8 +- .../reference/umd-augmentation-3.types | 8 +- .../reference/umd-augmentation-4.types | 8 +- tests/baselines/reference/unaryPlus.types | 18 +- .../reference/uncaughtCompilerError1.types | 18 +- .../undefinedInferentialTyping.types | 2 +- .../undefinedIsSubtypeOfEverything.types | 4 +- .../reference/underscoreMapFirst.types | 4 +- .../baselines/reference/underscoreTest1.types | 724 +++++++++--------- ...nicodeExtendedEscapesInStrings01_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings01_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings02_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings02_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings03_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings03_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings04_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings04_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings05_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings05_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings06_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings06_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings08_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings08_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings09_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings09_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings10_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings10_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings11_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings11_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings13_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings13_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings15_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings15_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings16_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings16_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings18_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings18_ES6.types | 2 +- ...nicodeExtendedEscapesInStrings23_ES5.types | 2 +- ...nicodeExtendedEscapesInStrings23_ES6.types | 2 +- .../reference/unicodeIdentifierNames.types | 2 +- .../unionAndIntersectionInference1.types | 14 +- .../reference/unionThisTypeInFunctions.types | 2 +- .../unionTypeCallSignatures.errors.txt | 32 +- .../reference/unionTypeCallSignatures2.types | 12 +- .../reference/unionTypeCallSignatures3.types | 2 +- .../unionTypeConstructSignatures.errors.txt | 32 +- .../reference/unionTypeFromArrayLiteral.types | 32 +- .../reference/unionTypeIndexSignature.types | 16 +- .../reference/unionTypeInference.types | 24 +- .../untypedArgumentInLambdaExpression.types | 2 +- .../reference/unusedImportDeclaration.types | 6 +- ...unusedLocalsAndParametersTypeAliases.types | 2 +- .../reference/unusedPrivateMembers.types | 4 +- .../reference/unusedSwitchStatment.errors.txt | 11 +- .../useObjectValuesAndEntries1.types | 6 +- .../useObjectValuesAndEntries4.types | 4 +- .../reference/useSharedArrayBuffer1.types | 6 +- .../reference/useSharedArrayBuffer4.types | 8 +- .../reference/useSharedArrayBuffer5.types | 4 +- .../reference/useSharedArrayBuffer6.types | 4 +- .../useStrictLikePrologueString01.types | 4 +- ...oduleWithExportImportInValuePosition.types | 6 +- .../reference/validBooleanAssignments.types | 10 +- .../reference/validEnumAssignments.types | 18 +- .../reference/validNumberAssignments.types | 2 +- .../reference/validStringAssignments.types | 2 +- tests/baselines/reference/varAsID.types | 4 +- .../varInFunctionInVarInitializer.types | 4 +- tests/baselines/reference/vararg.errors.txt | 8 +- tests/baselines/reference/vardecl.types | 38 +- .../reference/variableDeclarator1.types | 2 +- tests/baselines/reference/visSyntax.types | 2 +- .../baselines/reference/voidAsOperator.types | 2 +- .../voidFunctionAssignmentCompat.types | 20 +- tests/baselines/reference/voidOperator1.types | 6 +- .../voidOperatorWithBooleanType.types | 16 +- .../reference/voidOperatorWithEnumType.types | 24 +- .../voidOperatorWithNumberType.types | 20 +- .../voidOperatorWithStringType.types | 22 +- .../reference/whileBreakStatements.types | 22 +- .../reference/widenedTypes.errors.txt | 8 +- .../baselines/reference/wideningTuples1.types | 2 +- .../baselines/reference/wideningTuples2.types | 2 +- .../baselines/reference/wideningTuples4.types | 4 +- .../baselines/reference/wideningTuples6.types | 8 +- .../baselines/reference/withExportDecl.types | 36 +- .../baselines/reference/withImportDecl.types | 20 +- .../wrappedAndRecursiveConstraints2.types | 4 +- .../wrappedAndRecursiveConstraints3.types | 8 +- .../wrappedRecursiveGenericType.errors.txt | 8 +- 2147 files changed, 17895 insertions(+), 13646 deletions(-) create mode 100644 tests/baselines/reference/capturedLetConstInLoop1.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop1_ES6.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop2.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop2_ES6.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop3.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop3_ES6.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop4.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop4_ES6.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop5.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop6.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop7.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop8.errors.txt create mode 100644 tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt create mode 100644 tests/baselines/reference/conditionalOperatorConditionIsBooleanType.errors.txt create mode 100644 tests/baselines/reference/constDeclarations-scopes2.errors.txt create mode 100644 tests/baselines/reference/constDeclarations.errors.txt create mode 100644 tests/baselines/reference/enumBasics.errors.txt create mode 100644 tests/baselines/reference/invalidSwitchBreakStatement.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt create mode 100644 tests/baselines/reference/stringLiteralsWithSwitchStatements04.errors.txt delete mode 100644 tests/baselines/reference/stringLiteralsWithTypeAssertions01.errors.txt create mode 100644 tests/baselines/reference/stringLiteralsWithTypeAssertions01.symbols create mode 100644 tests/baselines/reference/stringLiteralsWithTypeAssertions01.types create mode 100644 tests/baselines/reference/switchBreakStatements.errors.txt create mode 100644 tests/baselines/reference/switchCases.errors.txt diff --git a/tests/baselines/reference/AmbientModuleAndAmbientWithSameNameAndCommonRoot.types b/tests/baselines/reference/AmbientModuleAndAmbientWithSameNameAndCommonRoot.types index fec7593a993..92612490eb4 100644 --- a/tests/baselines/reference/AmbientModuleAndAmbientWithSameNameAndCommonRoot.types +++ b/tests/baselines/reference/AmbientModuleAndAmbientWithSameNameAndCommonRoot.types @@ -56,6 +56,6 @@ var p = new A.Point(0, 0); // unexpected error here, bug 840000 >A.Point : typeof A.Point >A : typeof A >Point : typeof A.Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 diff --git a/tests/baselines/reference/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.types b/tests/baselines/reference/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.types index cd57c0c503d..83359d5ae27 100644 --- a/tests/baselines/reference/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.types +++ b/tests/baselines/reference/AmbientModuleAndNonAmbientClassWithSameNameAndCommonRoot.types @@ -50,6 +50,6 @@ var p = new A.Point(0, 0); // unexpected error here, bug 840000 >A.Point : typeof A.Point >A : typeof A >Point : typeof A.Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 diff --git a/tests/baselines/reference/AmbientModuleAndNonAmbientFunctionWithTheSameNameAndCommonRoot.types b/tests/baselines/reference/AmbientModuleAndNonAmbientFunctionWithTheSameNameAndCommonRoot.types index 035f2a50c37..f8525c4e426 100644 --- a/tests/baselines/reference/AmbientModuleAndNonAmbientFunctionWithTheSameNameAndCommonRoot.types +++ b/tests/baselines/reference/AmbientModuleAndNonAmbientFunctionWithTheSameNameAndCommonRoot.types @@ -15,9 +15,9 @@ function Point() { return { x: 0, y: 0 }; >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } === tests/cases/conformance/internalModules/DeclarationMerging/test.ts === diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.types b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.types index 9d943ab354c..b0685c4f858 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.types +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticFunctionAndNonExportedFunctionThatShareAName.types @@ -11,9 +11,9 @@ class Point { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } module Point { @@ -21,7 +21,7 @@ module Point { function Origin() { return ""; }// not an error, since not exported >Origin : () => string ->"" : string +>"" : "" } @@ -40,9 +40,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } export module Point { @@ -50,6 +50,6 @@ module A { function Origin() { return ""; }// not an error since not exported >Origin : () => string ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.types b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.types index 8f8ffc8839f..7aa32879b7c 100644 --- a/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.types +++ b/tests/baselines/reference/ClassAndModuleThatMergeWithStaticVariableAndNonExportedVarThatShareAName.types @@ -11,9 +11,9 @@ class Point { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } module Point { @@ -21,7 +21,7 @@ module Point { var Origin = ""; // not an error, since not exported >Origin : string ->"" : string +>"" : "" } @@ -40,9 +40,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } export module Point { @@ -50,6 +50,6 @@ module A { var Origin = ""; // not an error since not exported >Origin : string ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.types b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.types index 47139729995..5e6077a0933 100644 --- a/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.types +++ b/tests/baselines/reference/ClassDeclarationWithInvalidConstOnPropertyDeclaration2.types @@ -7,5 +7,5 @@ class C { x = 10; >x : number ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/ES3For-ofTypeCheck2.types b/tests/baselines/reference/ES3For-ofTypeCheck2.types index 81230c9cea4..dd586109498 100644 --- a/tests/baselines/reference/ES3For-ofTypeCheck2.types +++ b/tests/baselines/reference/ES3For-ofTypeCheck2.types @@ -2,5 +2,5 @@ for (var v of [true]) { } >v : boolean >[true] : boolean[] ->true : boolean +>true : true diff --git a/tests/baselines/reference/ES5For-of10.types b/tests/baselines/reference/ES5For-of10.types index d31f8972038..2813e614e54 100644 --- a/tests/baselines/reference/ES5For-of10.types +++ b/tests/baselines/reference/ES5For-of10.types @@ -5,7 +5,7 @@ function foo() { return { x: 0 }; >{ x: 0 } : { x: number; } >x : number ->0 : number +>0 : 0 } for (foo().x of []) { >foo().x : number diff --git a/tests/baselines/reference/ES5For-of13.types b/tests/baselines/reference/ES5For-of13.types index 46125af551e..150517378d8 100644 --- a/tests/baselines/reference/ES5For-of13.types +++ b/tests/baselines/reference/ES5For-of13.types @@ -2,9 +2,9 @@ for (let v of ['a', 'b', 'c']) { >v : string >['a', 'b', 'c'] : string[] ->'a' : string ->'b' : string ->'c' : string +>'a' : "a" +>'b' : "b" +>'c' : "c" var x = v; >x : string diff --git a/tests/baselines/reference/ES5For-of24.types b/tests/baselines/reference/ES5For-of24.types index c0c4666fbf5..aa9aad228e5 100644 --- a/tests/baselines/reference/ES5For-of24.types +++ b/tests/baselines/reference/ES5For-of24.types @@ -2,9 +2,9 @@ var a = [1, 2, 3]; >a : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 for (var v of a) { >v : number @@ -12,5 +12,5 @@ for (var v of a) { let a = 0; >a : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/ES5For-of25.types b/tests/baselines/reference/ES5For-of25.types index 4650e3244d3..0d304512bf3 100644 --- a/tests/baselines/reference/ES5For-of25.types +++ b/tests/baselines/reference/ES5For-of25.types @@ -2,9 +2,9 @@ var a = [1, 2, 3]; >a : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 for (var v of a) { >v : number diff --git a/tests/baselines/reference/ES5For-of3.types b/tests/baselines/reference/ES5For-of3.types index 65267fe3f70..29825c5c32d 100644 --- a/tests/baselines/reference/ES5For-of3.types +++ b/tests/baselines/reference/ES5For-of3.types @@ -2,9 +2,9 @@ for (var v of ['a', 'b', 'c']) >v : string >['a', 'b', 'c'] : string[] ->'a' : string ->'b' : string ->'c' : string +>'a' : "a" +>'b' : "b" +>'c' : "c" var x = v; >x : string diff --git a/tests/baselines/reference/ES5For-of30.errors.txt b/tests/baselines/reference/ES5For-of30.errors.txt index e99b8284bf3..284dd372e5a 100644 --- a/tests/baselines/reference/ES5For-of30.errors.txt +++ b/tests/baselines/reference/ES5For-of30.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type. -tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type '1' is not assignable to type 'string'. +tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type '""' is not assignable to type 'number'. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (3 errors) ==== @@ -10,9 +10,9 @@ tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error ~~~~~~~~~~~~~~~ !!! error TS2461: Type 'string | number' is not an array type. ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '1' is not assignable to type 'string'. ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. a; b; } \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-of9.types b/tests/baselines/reference/ES5For-of9.types index ec41df704c6..6df6e295d75 100644 --- a/tests/baselines/reference/ES5For-of9.types +++ b/tests/baselines/reference/ES5For-of9.types @@ -5,7 +5,7 @@ function foo() { return { x: 0 }; >{ x: 0 } : { x: number; } >x : number ->0 : number +>0 : 0 } for (foo().x of []) { >foo().x : number diff --git a/tests/baselines/reference/ES5For-ofTypeCheck1.types b/tests/baselines/reference/ES5For-ofTypeCheck1.types index 395900d683b..6faba8c23aa 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck1.types +++ b/tests/baselines/reference/ES5For-ofTypeCheck1.types @@ -1,5 +1,5 @@ === tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck1.ts === for (var v of "") { } >v : string ->"" : string +>"" : "" diff --git a/tests/baselines/reference/ES5For-ofTypeCheck12.errors.txt b/tests/baselines/reference/ES5For-ofTypeCheck12.errors.txt index 67af1f4f401..5310d588619 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck12.errors.txt +++ b/tests/baselines/reference/ES5For-ofTypeCheck12.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts(1,17): error TS2495: Type 'number' is not an array type or a string type. +tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts(1,17): error TS2495: Type '0' is not an array type or a string type. ==== tests/cases/conformance/statements/for-ofStatements/ES5For-ofTypeCheck12.ts (1 errors) ==== for (const v of 0) { } ~ -!!! error TS2495: Type 'number' is not an array type or a string type. \ No newline at end of file +!!! error TS2495: Type '0' is not an array type or a string type. \ No newline at end of file diff --git a/tests/baselines/reference/ES5For-ofTypeCheck2.types b/tests/baselines/reference/ES5For-ofTypeCheck2.types index d28a2803216..f6c9b7c8ba4 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck2.types +++ b/tests/baselines/reference/ES5For-ofTypeCheck2.types @@ -2,5 +2,5 @@ for (var v of [true]) { } >v : boolean >[true] : boolean[] ->true : boolean +>true : true diff --git a/tests/baselines/reference/ES5For-ofTypeCheck3.types b/tests/baselines/reference/ES5For-ofTypeCheck3.types index a62dcc94f98..d46cdd0172d 100644 --- a/tests/baselines/reference/ES5For-ofTypeCheck3.types +++ b/tests/baselines/reference/ES5For-ofTypeCheck3.types @@ -2,8 +2,8 @@ var tuple: [string, number] = ["", 0]; >tuple : [string, number] >["", 0] : [string, number] ->"" : string ->0 : number +>"" : "" +>0 : 0 for (var v of tuple) { } >v : string | number diff --git a/tests/baselines/reference/ES5for-of32.types b/tests/baselines/reference/ES5for-of32.types index 034d7a3b1ea..188500c4859 100644 --- a/tests/baselines/reference/ES5for-of32.types +++ b/tests/baselines/reference/ES5for-of32.types @@ -3,13 +3,13 @@ var array = [1,2,3]; >array : number[] >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var sum = 0; >sum : number ->0 : number +>0 : 0 for (let num of array) { >num : number @@ -24,9 +24,9 @@ for (let num of array) { >array = [4,5,6] : number[] >array : number[] >[4,5,6] : number[] ->4 : number ->5 : number ->6 : number +>4 : 4 +>5 : 5 +>6 : 6 } sum += num; diff --git a/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.types b/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.types index 205335c7eb6..d2328929938 100644 --- a/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.types +++ b/tests/baselines/reference/EnumAndModuleWithSameNameAndCommonRoot.types @@ -3,8 +3,8 @@ enum enumdule { >enumdule : enumdule Red, Blue ->Red : enumdule ->Blue : enumdule +>Red : enumdule.Red +>Blue : enumdule.Blue } module enumdule { @@ -25,9 +25,9 @@ var x: enumdule; var x = enumdule.Red; >x : enumdule ->enumdule.Red : enumdule +>enumdule.Red : enumdule.Red >enumdule : typeof enumdule ->Red : enumdule +>Red : enumdule.Red var y: { x: number; y: number }; >y : { x: number; y: number; } @@ -40,6 +40,6 @@ var y = new enumdule.Point(0, 0); >enumdule.Point : typeof enumdule.Point >enumdule : typeof enumdule >Point : typeof enumdule.Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 diff --git a/tests/baselines/reference/ExportClassWhichExtendsInterfaceWithInaccessibleType.types b/tests/baselines/reference/ExportClassWhichExtendsInterfaceWithInaccessibleType.types index e47b38a0b61..04d0259f04e 100644 --- a/tests/baselines/reference/ExportClassWhichExtendsInterfaceWithInaccessibleType.types +++ b/tests/baselines/reference/ExportClassWhichExtendsInterfaceWithInaccessibleType.types @@ -31,7 +31,7 @@ module A { >Point : Point return 1; ->1 : number +>1 : 1 } } } diff --git a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.types b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.types index a5cefcc521e..e832f36e862 100644 --- a/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.types +++ b/tests/baselines/reference/ExportClassWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.types @@ -17,9 +17,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 export class Point3d extends Point { >Point3d : Point3d @@ -34,11 +34,11 @@ module A { >Point3d : Point3d >{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >z : number ->0 : number +>0 : 0 export class Line{ >Line : Line diff --git a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.types b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.types index ba174d9bbba..1a97175a833 100644 --- a/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.types +++ b/tests/baselines/reference/ExportClassWithInaccessibleTypeInTypeParameterConstraint.types @@ -17,9 +17,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 export class Point3d extends Point { >Point3d : Point3d @@ -34,11 +34,11 @@ module A { >Point3d : Point3d >{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >z : number ->0 : number +>0 : 0 export class Line{ >Line : Line diff --git a/tests/baselines/reference/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.types b/tests/baselines/reference/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.types index 60a6e122a78..957c9ce0207 100644 --- a/tests/baselines/reference/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.types +++ b/tests/baselines/reference/ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.types @@ -33,9 +33,9 @@ module A { >Line : typeof Line >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >p : Point } } diff --git a/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.types b/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.types index ba862ad77cf..079b39650d0 100644 --- a/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.types +++ b/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.types @@ -33,9 +33,9 @@ module A { >Line : typeof Line >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >p : Point } } diff --git a/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.types b/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.types index ef72f80ffde..6fcbb786a68 100644 --- a/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.types +++ b/tests/baselines/reference/ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.types @@ -33,9 +33,9 @@ module A { >Line : typeof Line >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >p : Point } } diff --git a/tests/baselines/reference/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.types b/tests/baselines/reference/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.types index b4a331b9140..c7c78424064 100644 --- a/tests/baselines/reference/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.types +++ b/tests/baselines/reference/ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.types @@ -17,9 +17,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 export interface Point3d extends Point { >Point3d : Point3d @@ -34,11 +34,11 @@ module A { >Point3d : Point3d >{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >z : number ->0 : number +>0 : 0 export interface Line{ >Line : Line diff --git a/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.types b/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.types index 366e21b6472..8d07e4a44dd 100644 --- a/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.types +++ b/tests/baselines/reference/ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.types @@ -17,9 +17,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 export interface Point3d extends Point { >Point3d : Point3d @@ -34,11 +34,11 @@ module A { >Point3d : Point3d >{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >z : number ->0 : number +>0 : 0 export interface Line{ >Line : Line diff --git a/tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.types b/tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.types index cd8526242fa..a3ee7c55a4c 100644 --- a/tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.types +++ b/tests/baselines/reference/ExportModuleWithAccessibleTypesOnItsExportedMembers.types @@ -18,8 +18,8 @@ module A { >Point : Point >new Point(0, 0) : Point >Point : typeof Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 export class Line { >Line : Line @@ -42,9 +42,9 @@ module A { >Line : typeof Line >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >p : Point } } diff --git a/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.types b/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.types index e08a4345a95..0ce1b82d67e 100644 --- a/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.types +++ b/tests/baselines/reference/ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInMemberTypeAnnotations.types @@ -15,9 +15,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 export var Unity = { start: new Point(0, 0), end: new Point(1, 0) }; >Unity : { start: Point; end: Point; } @@ -25,12 +25,12 @@ module A { >start : Point >new Point(0, 0) : Point >Point : typeof Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 >end : Point >new Point(1, 0) : Point >Point : typeof Point ->1 : number ->0 : number +>1 : 1 +>0 : 0 } diff --git a/tests/baselines/reference/ExportVariableWithAccessibleTypeInTypeAnnotation.types b/tests/baselines/reference/ExportVariableWithAccessibleTypeInTypeAnnotation.types index faf86ea6982..91504be2c70 100644 --- a/tests/baselines/reference/ExportVariableWithAccessibleTypeInTypeAnnotation.types +++ b/tests/baselines/reference/ExportVariableWithAccessibleTypeInTypeAnnotation.types @@ -18,8 +18,8 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/ExportVariableWithInaccessibleTypeInTypeAnnotation.types b/tests/baselines/reference/ExportVariableWithInaccessibleTypeInTypeAnnotation.types index 4ce1912d441..39bc5fa8af0 100644 --- a/tests/baselines/reference/ExportVariableWithInaccessibleTypeInTypeAnnotation.types +++ b/tests/baselines/reference/ExportVariableWithInaccessibleTypeInTypeAnnotation.types @@ -18,9 +18,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 interface Point3d extends Point { >Point3d : Point3d @@ -36,10 +36,10 @@ module A { >Point3d : Point3d >{ x: 0, y: 0, z: 0 } : { x: number; y: number; z: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >z : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.types b/tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.types index fe976cd0a3b..f070f422a52 100644 --- a/tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.types +++ b/tests/baselines/reference/FunctionAndModuleWithSameNameAndDifferentCommonRoot.types @@ -8,9 +8,9 @@ module A { return { x: 0, y: 0 }; >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } } @@ -25,9 +25,9 @@ module B { >Origin : { x: number; y: number; } >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.types b/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.types index 343b69954b0..f728c41b6a1 100644 --- a/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.types +++ b/tests/baselines/reference/ModuleAndEnumWithSameNameAndCommonRoot.types @@ -15,8 +15,8 @@ enum enumdule { >enumdule : enumdule Red, Blue ->Red : enumdule ->Blue : enumdule +>Red : enumdule.Red +>Blue : enumdule.Blue } var x: enumdule; @@ -25,9 +25,9 @@ var x: enumdule; var x = enumdule.Red; >x : enumdule ->enumdule.Red : enumdule +>enumdule.Red : enumdule.Red >enumdule : typeof enumdule ->Red : enumdule +>Red : enumdule.Red var y: { x: number; y: number }; >y : { x: number; y: number; } @@ -40,6 +40,6 @@ var y = new enumdule.Point(0, 0); >enumdule.Point : typeof enumdule.Point >enumdule : typeof enumdule >Point : typeof enumdule.Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 diff --git a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.types b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.types index af3c0776b56..25a627030c4 100644 --- a/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.types +++ b/tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedAndNonExportedLocalVarsOfTheSameName.types @@ -39,9 +39,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } === tests/cases/conformance/internalModules/DeclarationMerging/part2.ts === @@ -51,7 +51,7 @@ module A { // not a collision, since we don't export var Origin: string = "0,0"; >Origin : string ->"0,0" : string +>"0,0" : "0,0" export module Utils { >Utils : typeof Utils @@ -123,8 +123,8 @@ var p = new A.Utils.Plane(o, { x: 1, y: 1 }); >o : { x: number; y: number; } >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.types b/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.types index e005522ddfc..2d654a580ea 100644 --- a/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.types +++ b/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndDifferentCommonRoot.types @@ -55,9 +55,9 @@ module otherRoot { >Point : Root.A.Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 export module Utils { >Utils : typeof Utils diff --git a/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndSameCommonRoot.types b/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndSameCommonRoot.types index e2dd1f400f4..11cb6e95d28 100644 --- a/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndSameCommonRoot.types +++ b/tests/baselines/reference/TwoInternalModulesWithTheSameNameAndSameCommonRoot.types @@ -45,9 +45,9 @@ module A { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 export module Utils { >Utils : typeof Utils @@ -119,8 +119,8 @@ var p = new A.Utils.Plane(o, { x: 1, y: 1 }); >o : { x: number; y: number; } >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/TypeGuardWithEnumUnion.types b/tests/baselines/reference/TypeGuardWithEnumUnion.types index dee8feae27d..d33411c4c7c 100644 --- a/tests/baselines/reference/TypeGuardWithEnumUnion.types +++ b/tests/baselines/reference/TypeGuardWithEnumUnion.types @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/typeGuards/TypeGuardWithEnumUnion.ts === enum Color { R, G, B } >Color : Color ->R : Color ->G : Color ->B : Color +>R : Color.R +>G : Color.G +>B : Color.B function f1(x: Color | string) { >f1 : (x: string | Color) => void diff --git a/tests/baselines/reference/VariableDeclaration10_es6.types b/tests/baselines/reference/VariableDeclaration10_es6.types index 717de7ed0ff..29056b88ce1 100644 --- a/tests/baselines/reference/VariableDeclaration10_es6.types +++ b/tests/baselines/reference/VariableDeclaration10_es6.types @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/variableDeclarations/VariableDeclaration10_es6.ts === let a: number = 1 >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/VariableDeclaration3_es6.types b/tests/baselines/reference/VariableDeclaration3_es6.types index 1b5bbdb4ea7..5f92a06df11 100644 --- a/tests/baselines/reference/VariableDeclaration3_es6.types +++ b/tests/baselines/reference/VariableDeclaration3_es6.types @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/variableDeclarations/VariableDeclaration3_es6.ts === const a = 1 ->a : number ->1 : number +>a : 1 +>1 : 1 diff --git a/tests/baselines/reference/VariableDeclaration5_es6.types b/tests/baselines/reference/VariableDeclaration5_es6.types index 0dce532be51..c0ed35a43e3 100644 --- a/tests/baselines/reference/VariableDeclaration5_es6.types +++ b/tests/baselines/reference/VariableDeclaration5_es6.types @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/variableDeclarations/VariableDeclaration5_es6.ts === const a: number = 1 >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/VariableDeclaration8_es6.types b/tests/baselines/reference/VariableDeclaration8_es6.types index 24a3cd85383..e31fddbc09f 100644 --- a/tests/baselines/reference/VariableDeclaration8_es6.types +++ b/tests/baselines/reference/VariableDeclaration8_es6.types @@ -1,5 +1,5 @@ === tests/cases/conformance/es6/variableDeclarations/VariableDeclaration8_es6.ts === let a = 1 >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/abstractIdentifierNameStrict.types b/tests/baselines/reference/abstractIdentifierNameStrict.types index 7c79ce58a37..de6b1f458ac 100644 --- a/tests/baselines/reference/abstractIdentifierNameStrict.types +++ b/tests/baselines/reference/abstractIdentifierNameStrict.types @@ -1,15 +1,15 @@ === tests/cases/compiler/abstractIdentifierNameStrict.ts === var abstract = true; >abstract : boolean ->true : boolean +>true : true function foo() { >foo : () => void "use strict"; ->"use strict" : string +>"use strict" : "use strict" var abstract = true; >abstract : boolean ->true : boolean +>true : true } diff --git a/tests/baselines/reference/abstractProperty.types b/tests/baselines/reference/abstractProperty.types index b6aff9356cd..b139a9c1cb7 100644 --- a/tests/baselines/reference/abstractProperty.types +++ b/tests/baselines/reference/abstractProperty.types @@ -40,7 +40,7 @@ class C extends B { get prop() { return "foo"; } >prop : string ->"foo" : string +>"foo" : "foo" set prop(v) { } >prop : string @@ -48,11 +48,11 @@ class C extends B { raw = "edge"; >raw : string ->"edge" : string +>"edge" : "edge" readonly ro = "readonly please"; >ro : string ->"readonly please" : string +>"readonly please" : "readonly please" readonlyProp: string; // don't have to give a value, in fact >readonlyProp : string diff --git a/tests/baselines/reference/accessOverriddenBaseClassMember1.types b/tests/baselines/reference/accessOverriddenBaseClassMember1.types index f444544ea48..f0dad0ccafc 100644 --- a/tests/baselines/reference/accessOverriddenBaseClassMember1.types +++ b/tests/baselines/reference/accessOverriddenBaseClassMember1.types @@ -13,11 +13,11 @@ class Point { >"x=" + this.x + " y=" + this.y : string >"x=" + this.x + " y=" : string >"x=" + this.x : string ->"x=" : string +>"x=" : "x=" >this.x : number >this : this >x : number ->" y=" : string +>" y=" : " y=" >this.y : number >this : this >y : number @@ -48,7 +48,7 @@ class ColoredPoint extends Point { >super.toString : () => string >super : Point >toString : () => string ->" color=" : string +>" color=" : " color=" >this.color : string >this : this >color : string diff --git a/tests/baselines/reference/accessorWithES5.types b/tests/baselines/reference/accessorWithES5.types index 29471548918..4d23f61c0eb 100644 --- a/tests/baselines/reference/accessorWithES5.types +++ b/tests/baselines/reference/accessorWithES5.types @@ -7,7 +7,7 @@ class C { >x : number return 1; ->1 : number +>1 : 1 } } @@ -26,7 +26,7 @@ var x = { get a() { return 1 } >a : number ->1 : number +>1 : 1 } var y = { diff --git a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt index 981cb525625..5393eee87d4 100644 --- a/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt +++ b/tests/baselines/reference/accessors_spec_section-4.5_error-cases.errors.txt @@ -1,14 +1,14 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(2,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(3,55): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(5,54): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(6,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(8,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,52): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(9,52): error TS2322: Type '0' is not assignable to type 'string'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,51): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(11,51): error TS2322: Type '0' is not assignable to type 'string'. tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -21,13 +21,13 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. public get AnnotatedSetter_SetterLast() { return ""; } ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. public set AnnotatedSetter_SetterLast(a: number) { } ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -39,13 +39,13 @@ tests/cases/compiler/accessors_spec_section-4.5_error-cases.ts(12,16): error TS1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '0' is not assignable to type 'string'. public set AnnotatedGetter_GetterLast(aStr) { aStr = 0; } ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. ~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '0' is not assignable to type 'string'. public get AnnotatedGetter_GetterLast(): string { return ""; } ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. diff --git a/tests/baselines/reference/addMoreCallSignaturesToBaseSignature2.types b/tests/baselines/reference/addMoreCallSignaturesToBaseSignature2.types index 98bd1910241..2618f7b3cc7 100644 --- a/tests/baselines/reference/addMoreCallSignaturesToBaseSignature2.types +++ b/tests/baselines/reference/addMoreCallSignaturesToBaseSignature2.types @@ -22,5 +22,5 @@ var kitty = a(1); >kitty : string >a(1) : string >a : Bar ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/additionOperatorWithAnyAndEveryType.types b/tests/baselines/reference/additionOperatorWithAnyAndEveryType.types index 9f1a9f03898..0994360ca10 100644 --- a/tests/baselines/reference/additionOperatorWithAnyAndEveryType.types +++ b/tests/baselines/reference/additionOperatorWithAnyAndEveryType.types @@ -13,9 +13,9 @@ class C { } enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c module M { export var a } >M : typeof M @@ -130,9 +130,9 @@ var r15 = a + E.a; >r15 : any >a + E.a : any >a : any ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var r16 = a + M; >r16 : any @@ -144,13 +144,13 @@ var r17 = a + ''; >r17 : string >a + '' : string >a : any ->'' : string +>'' : "" var r18 = a + 123; >r18 : any >a + 123 : any >a : any ->123 : number +>123 : 123 var r19 = a + { a: '' }; >r19 : any @@ -158,7 +158,7 @@ var r19 = a + { a: '' }; >a : any >{ a: '' } : { a: string; } >a : string ->'' : string +>'' : "" var r20 = a + ((a: string) => { return a }); >r20 : any diff --git a/tests/baselines/reference/additionOperatorWithInvalidOperands.errors.txt b/tests/baselines/reference/additionOperatorWithInvalidOperands.errors.txt index bd71b64b501..124120cef2c 100644 --- a/tests/baselines/reference/additionOperatorWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/additionOperatorWithInvalidOperands.errors.txt @@ -6,17 +6,17 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(25,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'boolean'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(26,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'number'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(27,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(30,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(31,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(32,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(30,11): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'true'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(31,11): error TS2365: Operator '+' cannot be applied to types 'true' and 'false'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(32,11): error TS2365: Operator '+' cannot be applied to types 'true' and '123'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(33,11): error TS2365: Operator '+' cannot be applied to types '{}' and '{}'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(34,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'Number'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(35,11): error TS2365: Operator '+' cannot be applied to types 'number' and '() => void'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(36,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'void'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(37,11): error TS2365: Operator '+' cannot be applied to types 'number' and 'typeof C'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(38,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'C'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(39,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'void'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(40,11): error TS2365: Operator '+' cannot be applied to types 'E' and 'typeof M'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(38,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'C'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(39,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'void'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts(40,11): error TS2365: Operator '+' cannot be applied to types 'E.a' and 'typeof M'. ==== tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithInvalidOperands.ts (19 errors) ==== @@ -67,13 +67,13 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe // other cases var r10 = a + true; ~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. +!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'true'. var r11 = true + false; ~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. +!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'false'. var r12 = true + 123; ~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number'. +!!! error TS2365: Operator '+' cannot be applied to types 'true' and '123'. var r13 = {} + {}; ~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types '{}' and '{}'. @@ -91,10 +91,10 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe !!! error TS2365: Operator '+' cannot be applied to types 'number' and 'typeof C'. var r18 = E.a + new C(); ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'C'. +!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'C'. var r19 = E.a + C.foo(); ~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'void'. +!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'void'. var r20 = E.a + M; ~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'typeof M'. \ No newline at end of file +!!! error TS2365: Operator '+' cannot be applied to types 'E.a' and 'typeof M'. \ No newline at end of file diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt index 566fb241bf8..d18a9a13d8c 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt +++ b/tests/baselines/reference/additionOperatorWithNullValueAndInvalidOperator.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNullValueAndInvalidOperator.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. @@ -47,7 +47,7 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe !!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. var r8 = null + true; ~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. +!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. var r9 = null + { a: '' }; ~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. diff --git a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.types b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.types index f4ea168ee0d..d0feec523b0 100644 --- a/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.types +++ b/tests/baselines/reference/additionOperatorWithNullValueAndValidOperator.types @@ -3,9 +3,9 @@ enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a: any; >a : any @@ -44,7 +44,7 @@ var r4 = null + 1; >r4 : number >null + 1 : number >null : null ->1 : number +>1 : 1 var r5 = null + c; >r5 : number @@ -56,17 +56,17 @@ var r6 = null + E.a; >r6 : number >null + E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var r7 = null + E['a']; >r7 : number >null + E['a'] : number >null : null ->E['a'] : E +>E['a'] : E.a >E : typeof E ->'a' : string +>'a' : "a" var r8 = b + null; >r8 : number @@ -77,7 +77,7 @@ var r8 = b + null; var r9 = 1 + null; >r9 : number >1 + null : number ->1 : number +>1 : 1 >null : null var r10 = c + null @@ -89,17 +89,17 @@ var r10 = c + null var r11 = E.a + null; >r11 : number >E.a + null : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >null : null var r12 = E['a'] + null; >r12 : number >E['a'] + null : number ->E['a'] : E +>E['a'] : E.a >E : typeof E ->'a' : string +>'a' : "a" >null : null // null + string @@ -113,7 +113,7 @@ var r14 = null + ''; >r14 : string >null + '' : string >null : null ->'' : string +>'' : "" var r15 = d + null; >r15 : string @@ -124,6 +124,6 @@ var r15 = d + null; var r16 = '' + null; >r16 : string >'' + null : string ->'' : string +>'' : "" >null : null diff --git a/tests/baselines/reference/additionOperatorWithNumberAndEnum.types b/tests/baselines/reference/additionOperatorWithNumberAndEnum.types index 2b1c2794065..c952fca9064 100644 --- a/tests/baselines/reference/additionOperatorWithNumberAndEnum.types +++ b/tests/baselines/reference/additionOperatorWithNumberAndEnum.types @@ -1,13 +1,13 @@ === tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithNumberAndEnum.ts === enum E { a, b } >E : E ->a : E ->b : E +>a : E.a +>b : E.b enum F { c, d } >F : F ->c : F ->d : F +>c : F.c +>d : F.d var a: number; >a : number @@ -48,46 +48,46 @@ var r4 = b + b; var r5 = 0 + a; >r5 : number >0 + a : number ->0 : number +>0 : 0 >a : number var r6 = E.a + 0; >r6 : number >E.a + 0 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->0 : number +>a : E.a +>0 : 0 var r7 = E.a + E.b; >r7 : number >E.a + E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var r8 = E['a'] + E['b']; >r8 : number >E['a'] + E['b'] : number ->E['a'] : E +>E['a'] : E.a >E : typeof E ->'a' : string ->E['b'] : E +>'a' : "a" +>E['b'] : E.b >E : typeof E ->'b' : string +>'b' : "b" var r9 = E['a'] + F['c']; >r9 : number >E['a'] + F['c'] : number ->E['a'] : E +>E['a'] : E.a >E : typeof E ->'a' : string ->F['c'] : F +>'a' : "a" +>F['c'] : F.c >F : typeof F ->'c' : string +>'c' : "c" var r10 = a + c; >r10 : number diff --git a/tests/baselines/reference/additionOperatorWithStringAndEveryType.types b/tests/baselines/reference/additionOperatorWithStringAndEveryType.types index 5413f5f5bdf..d938da263b7 100644 --- a/tests/baselines/reference/additionOperatorWithStringAndEveryType.types +++ b/tests/baselines/reference/additionOperatorWithStringAndEveryType.types @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithStringAndEveryType.ts === enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a: any; >a : any @@ -129,21 +129,21 @@ var r16 = x + E.a; >r16 : string >x + E.a : string >x : string ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var r17 = x + ''; >r17 : string >x + '' : string >x : string ->'' : string +>'' : "" var r18 = x + 0; >r18 : string >x + 0 : string >x : string ->0 : number +>0 : 0 var r19 = x + { a: '' }; >r19 : string @@ -151,7 +151,7 @@ var r19 = x + { a: '' }; >x : string >{ a: '' } : { a: string; } >a : string ->'' : string +>'' : "" var r20 = x + []; >r20 : string diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt index 36233e9e9fe..d61f101a544 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndInvalidOperands.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(15,10): error TS2365: Operator '+' cannot be applied to types 'Object' and 'Object'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(16,10): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(19,10): error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. -tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. +tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(20,10): error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(21,10): error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(22,11): error TS2365: Operator '+' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOperatorWithUndefinedValueAndInvalidOperands.ts(23,11): error TS2365: Operator '+' cannot be applied to types '() => void' and '() => void'. @@ -47,7 +47,7 @@ tests/cases/conformance/expressions/binaryOperators/additionOperator/additionOpe !!! error TS2365: Operator '+' cannot be applied to types 'Number' and 'Number'. var r8 = undefined + true; ~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'boolean'. +!!! error TS2365: Operator '+' cannot be applied to types 'true' and 'true'. var r9 = undefined + { a: '' }; ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types '{ a: string; }' and '{ a: string; }'. diff --git a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.types b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.types index 16f0a4dfa84..46ba3a147e6 100644 --- a/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.types +++ b/tests/baselines/reference/additionOperatorWithUndefinedValueAndValidOperator.types @@ -3,9 +3,9 @@ enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a: any; >a : any @@ -44,7 +44,7 @@ var r4 = undefined + 1; >r4 : number >undefined + 1 : number >undefined : undefined ->1 : number +>1 : 1 var r5 = undefined + c; >r5 : number @@ -56,17 +56,17 @@ var r6 = undefined + E.a; >r6 : number >undefined + E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var r7 = undefined + E['a']; >r7 : number >undefined + E['a'] : number >undefined : undefined ->E['a'] : E +>E['a'] : E.a >E : typeof E ->'a' : string +>'a' : "a" var r8 = b + undefined; >r8 : number @@ -77,7 +77,7 @@ var r8 = b + undefined; var r9 = 1 + undefined; >r9 : number >1 + undefined : number ->1 : number +>1 : 1 >undefined : undefined var r10 = c + undefined @@ -89,17 +89,17 @@ var r10 = c + undefined var r11 = E.a + undefined; >r11 : number >E.a + undefined : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >undefined : undefined var r12 = E['a'] + undefined; >r12 : number >E['a'] + undefined : number ->E['a'] : E +>E['a'] : E.a >E : typeof E ->'a' : string +>'a' : "a" >undefined : undefined // undefined + string @@ -113,7 +113,7 @@ var r14 = undefined + ''; >r14 : string >undefined + '' : string >undefined : undefined ->'' : string +>'' : "" var r15 = d + undefined; >r15 : string @@ -124,6 +124,6 @@ var r15 = d + undefined; var r16 = '' + undefined; >r16 : string >'' + undefined : string ->'' : string +>'' : "" >undefined : undefined diff --git a/tests/baselines/reference/aliasAssignments.errors.txt b/tests/baselines/reference/aliasAssignments.errors.txt index 18ea36c5d00..463f74e4c49 100644 --- a/tests/baselines/reference/aliasAssignments.errors.txt +++ b/tests/baselines/reference/aliasAssignments.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'. +tests/cases/compiler/aliasAssignments_1.ts(3,1): error TS2322: Type '1' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'. tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"' is not assignable to type 'number'. @@ -7,7 +7,7 @@ tests/cases/compiler/aliasAssignments_1.ts(5,1): error TS2322: Type 'typeof "tes var x = moduleA; x = 1; // Should be error ~ -!!! error TS2322: Type 'number' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'. +!!! error TS2322: Type '1' is not assignable to type 'typeof "tests/cases/compiler/aliasAssignments_moduleA"'. var y = 1; y = moduleA; // should be error ~ diff --git a/tests/baselines/reference/ambientDeclarations.types b/tests/baselines/reference/ambientDeclarations.types index f44d49cfc57..a571eb9fa7b 100644 --- a/tests/baselines/reference/ambientDeclarations.types +++ b/tests/baselines/reference/ambientDeclarations.types @@ -103,14 +103,14 @@ declare enum E2 { a = 1, >a : E2 ->1 : number +>1 : 1 b, >b : E2 c = 2, >c : E2 ->2 : number +>2 : 2 d >d : E2 diff --git a/tests/baselines/reference/ambientEnumDeclaration1.types b/tests/baselines/reference/ambientEnumDeclaration1.types index 3ef30e458da..370d6cd22ae 100644 --- a/tests/baselines/reference/ambientEnumDeclaration1.types +++ b/tests/baselines/reference/ambientEnumDeclaration1.types @@ -6,13 +6,13 @@ declare enum E { a = 10, >a : E ->10 : number +>10 : 10 b = 10 + 1, >b : E >10 + 1 : number ->10 : number ->1 : number +>10 : 10 +>1 : 1 c = b, >c : E @@ -23,13 +23,13 @@ declare enum E { >(c) + 1 : number >(c) : E >c : E ->1 : number +>1 : 1 e = 10 << 2 * 8, >e : E >10 << 2 * 8 : number ->10 : number +>10 : 10 >2 * 8 : number ->2 : number ->8 : number +>2 : 2 +>8 : 8 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer1.types b/tests/baselines/reference/ambientEnumElementInitializer1.types index 97db9f199d3..11ef7449504 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer1.types +++ b/tests/baselines/reference/ambientEnumElementInitializer1.types @@ -4,5 +4,5 @@ declare enum E { e = 3 >e : E ->3 : number +>3 : 3 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer2.types b/tests/baselines/reference/ambientEnumElementInitializer2.types index 7217bc8e6fd..47d85bf3c84 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer2.types +++ b/tests/baselines/reference/ambientEnumElementInitializer2.types @@ -4,6 +4,6 @@ declare enum E { e = -3 // Negative >e : E ->-3 : number ->3 : number +>-3 : -3 +>3 : 3 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer3.types b/tests/baselines/reference/ambientEnumElementInitializer3.types index f3d3b8f3ae2..3c099d00ede 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer3.types +++ b/tests/baselines/reference/ambientEnumElementInitializer3.types @@ -4,5 +4,5 @@ declare enum E { e = 3.3 // Decimal >e : E ->3.3 : number +>3.3 : 3.3 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer4.types b/tests/baselines/reference/ambientEnumElementInitializer4.types index b85649d654d..3bef657f5bb 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer4.types +++ b/tests/baselines/reference/ambientEnumElementInitializer4.types @@ -4,5 +4,5 @@ declare enum E { e = 0xA >e : E ->0xA : number +>0xA : 10 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer5.types b/tests/baselines/reference/ambientEnumElementInitializer5.types index 1c5ea0ecdd3..b3020a6d777 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer5.types +++ b/tests/baselines/reference/ambientEnumElementInitializer5.types @@ -4,6 +4,6 @@ declare enum E { e = -0xA >e : E ->-0xA : number ->0xA : number +>-0xA : -10 +>0xA : 10 } diff --git a/tests/baselines/reference/ambientEnumElementInitializer6.types b/tests/baselines/reference/ambientEnumElementInitializer6.types index 015d3f4e146..f093d0e2dfe 100644 --- a/tests/baselines/reference/ambientEnumElementInitializer6.types +++ b/tests/baselines/reference/ambientEnumElementInitializer6.types @@ -7,6 +7,6 @@ declare module M { e = 3 >e : E ->3 : number +>3 : 3 } } diff --git a/tests/baselines/reference/ambientModules.types b/tests/baselines/reference/ambientModules.types index 15e6d51b457..5a0a8c663ab 100644 --- a/tests/baselines/reference/ambientModules.types +++ b/tests/baselines/reference/ambientModules.types @@ -5,11 +5,11 @@ declare module Foo.Bar { export var foo; }; >foo : any Foo.Bar.foo = 5; ->Foo.Bar.foo = 5 : number +>Foo.Bar.foo = 5 : 5 >Foo.Bar.foo : any >Foo.Bar : typeof Foo.Bar >Foo : typeof Foo >Bar : typeof Foo.Bar >foo : any ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.types b/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.types index 65f26f25770..b3153722ee3 100644 --- a/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.types +++ b/tests/baselines/reference/ambiguousCallsWhereReturnTypesAgree.types @@ -53,7 +53,7 @@ class TestClass2 { >x : any return 0; ->0 : number +>0 : 0 } public foo(x: string): number; diff --git a/tests/baselines/reference/amdImportAsPrimaryExpression.types b/tests/baselines/reference/amdImportAsPrimaryExpression.types index 8f6e509419f..acfe27369f5 100644 --- a/tests/baselines/reference/amdImportAsPrimaryExpression.types +++ b/tests/baselines/reference/amdImportAsPrimaryExpression.types @@ -19,8 +19,8 @@ export enum E1 { >E1 : E1 A,B,C ->A : E1 ->B : E1 ->C : E1 +>A : E1.A +>B : E1.B +>C : E1.C } diff --git a/tests/baselines/reference/amdImportNotAsPrimaryExpression.types b/tests/baselines/reference/amdImportNotAsPrimaryExpression.types index 9d9faf05af8..32e45936f33 100644 --- a/tests/baselines/reference/amdImportNotAsPrimaryExpression.types +++ b/tests/baselines/reference/amdImportNotAsPrimaryExpression.types @@ -49,11 +49,11 @@ export class C1 { m1 = 42; >m1 : number ->42 : number +>42 : 42 static s1 = true; >s1 : boolean ->true : boolean +>true : true } export interface I1 { @@ -81,8 +81,8 @@ export enum E1 { >E1 : E1 A,B,C ->A : E1 ->B : E1 ->C : E1 +>A : E1.A +>B : E1.B +>C : E1.C } diff --git a/tests/baselines/reference/amdModuleName1.types b/tests/baselines/reference/amdModuleName1.types index c0db9c8b1b5..f7384ddf057 100644 --- a/tests/baselines/reference/amdModuleName1.types +++ b/tests/baselines/reference/amdModuleName1.types @@ -8,11 +8,11 @@ class Foo { constructor() { this.x = 5; ->this.x = 5 : number +>this.x = 5 : 5 >this.x : number >this : this >x : number ->5 : number +>5 : 5 } } export = Foo; diff --git a/tests/baselines/reference/anonterface.types b/tests/baselines/reference/anonterface.types index b152ce79a1d..a6c244b2885 100644 --- a/tests/baselines/reference/anonterface.types +++ b/tests/baselines/reference/anonterface.types @@ -34,9 +34,9 @@ c.m(function(n) { return "hello: "+n; },18); >function(n) { return "hello: "+n; } : (n: number) => string >n : number >"hello: "+n : string ->"hello: " : string +>"hello: " : "hello: " >n : number ->18 : number +>18 : 18 diff --git a/tests/baselines/reference/anyAsFunctionCall.types b/tests/baselines/reference/anyAsFunctionCall.types index 340ccac463f..42d0f9fc950 100644 --- a/tests/baselines/reference/anyAsFunctionCall.types +++ b/tests/baselines/reference/anyAsFunctionCall.types @@ -14,7 +14,7 @@ var b = x('hello'); >b : any >x('hello') : any >x : any ->'hello' : string +>'hello' : "hello" var c = x(x); >c : any diff --git a/tests/baselines/reference/anyAsReturnTypeForNewOnCall.types b/tests/baselines/reference/anyAsReturnTypeForNewOnCall.types index bd0d9a9a092..2ae57579835 100644 --- a/tests/baselines/reference/anyAsReturnTypeForNewOnCall.types +++ b/tests/baselines/reference/anyAsReturnTypeForNewOnCall.types @@ -24,8 +24,8 @@ var o = new Point(3, 4); >o : any >new Point(3, 4) : any >Point : (x: any, y: any) => void ->3 : number ->4 : number +>3 : 3 +>4 : 4 var xx = o.x; >xx : any diff --git a/tests/baselines/reference/anyAssignabilityInInheritance.types b/tests/baselines/reference/anyAssignabilityInInheritance.types index b8575e8edb2..925dd5d593e 100644 --- a/tests/baselines/reference/anyAssignabilityInInheritance.types +++ b/tests/baselines/reference/anyAssignabilityInInheritance.types @@ -246,7 +246,7 @@ module f { export var bar = 1; >bar : number ->1 : number +>1 : 1 } declare function foo15(x: typeof f): typeof f; >foo15 : { (x: typeof f): typeof f; (x: any): any; } @@ -273,7 +273,7 @@ module CC { export var bar = 1; >bar : number ->1 : number +>1 : 1 } declare function foo16(x: CC): CC; >foo16 : { (x: CC): CC; (x: any): any; } diff --git a/tests/baselines/reference/anyAssignableToEveryType2.types b/tests/baselines/reference/anyAssignableToEveryType2.types index b3f54211601..564b634cde3 100644 --- a/tests/baselines/reference/anyAssignableToEveryType2.types +++ b/tests/baselines/reference/anyAssignableToEveryType2.types @@ -187,7 +187,7 @@ module f { export var bar = 1; >bar : number ->1 : number +>1 : 1 } interface I15 { >I15 : I15 @@ -210,7 +210,7 @@ module c { export var bar = 1; >bar : number ->1 : number +>1 : 1 } interface I16 { >I16 : I16 diff --git a/tests/baselines/reference/anyPlusAny1.types b/tests/baselines/reference/anyPlusAny1.types index 406d432f06e..f6ca9c4996e 100644 --- a/tests/baselines/reference/anyPlusAny1.types +++ b/tests/baselines/reference/anyPlusAny1.types @@ -3,11 +3,11 @@ var x; >x : any x.name = "hello"; ->x.name = "hello" : string +>x.name = "hello" : "hello" >x.name : any >x : any >name : any ->"hello" : string +>"hello" : "hello" var z = x + x; >z : any diff --git a/tests/baselines/reference/anyPropertyAccess.types b/tests/baselines/reference/anyPropertyAccess.types index 13eec6b53b2..9b9e5ab84ac 100644 --- a/tests/baselines/reference/anyPropertyAccess.types +++ b/tests/baselines/reference/anyPropertyAccess.types @@ -12,14 +12,14 @@ var b = x['foo']; >b : any >x['foo'] : any >x : any ->'foo' : string +>'foo' : "foo" var c = x['fn'](); >c : any >x['fn']() : any >x['fn'] : any >x : any ->'fn' : string +>'fn' : "fn" var d = x.bar.baz; >d : any @@ -34,7 +34,7 @@ var e = x[0].foo; >x[0].foo : any >x[0] : any >x : any ->0 : number +>0 : 0 >foo : any var f = x['0'].bar; @@ -42,6 +42,6 @@ var f = x['0'].bar; >x['0'].bar : any >x['0'] : any >x : any ->'0' : string +>'0' : "0" >bar : any diff --git a/tests/baselines/reference/argsInScope.types b/tests/baselines/reference/argsInScope.types index 745ae249359..dacc66be912 100644 --- a/tests/baselines/reference/argsInScope.types +++ b/tests/baselines/reference/argsInScope.types @@ -10,7 +10,7 @@ class C { for (var i = 0; i < arguments.length; i++) { >i : number ->0 : number +>0 : 0 >i < arguments.length : boolean >i : number >arguments.length : number @@ -34,7 +34,7 @@ c.P(1,2,3); >c.P : (ii: number, j: number, k: number) => void >c : C >P : (ii: number, j: number, k: number) => void ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 diff --git a/tests/baselines/reference/arguments.types b/tests/baselines/reference/arguments.types index 4699d463b34..97a23822b7a 100644 --- a/tests/baselines/reference/arguments.types +++ b/tests/baselines/reference/arguments.types @@ -6,5 +6,5 @@ function f() { >x : any >arguments[12] : any >arguments : IArguments ->12 : number +>12 : 12 } diff --git a/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.errors.txt b/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.errors.txt index 89ef8ded91c..c19f00fa1da 100644 --- a/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.errors.txt +++ b/tests/baselines/reference/argumentsBindsToFunctionScopeArgumentList.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS2322: Type 'number' is not assignable to type 'IArguments'. +tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS2322: Type '10' is not assignable to type 'IArguments'. ==== tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/argumentsBindsToFunctionScopeArgumentList.ts(3,5): error TS function foo(a) { arguments = 10; /// This shouldnt be of type number and result in error. ~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'IArguments'. +!!! error TS2322: Type '10' is not assignable to type 'IArguments'. } \ No newline at end of file diff --git a/tests/baselines/reference/arithAssignTyping.errors.txt b/tests/baselines/reference/arithAssignTyping.errors.txt index c4cd84639a6..10f34e94012 100644 --- a/tests/baselines/reference/arithAssignTyping.errors.txt +++ b/tests/baselines/reference/arithAssignTyping.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/arithAssignTyping.ts(3,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/compiler/arithAssignTyping.ts(4,1): error TS2365: Operator '+=' cannot be applied to types 'typeof f' and 'number'. +tests/cases/compiler/arithAssignTyping.ts(4,1): error TS2365: Operator '+=' cannot be applied to types 'typeof f' and '1'. tests/cases/compiler/arithAssignTyping.ts(5,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/compiler/arithAssignTyping.ts(6,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/compiler/arithAssignTyping.ts(7,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -20,7 +20,7 @@ tests/cases/compiler/arithAssignTyping.ts(14,1): error TS2362: The left-hand sid !!! error TS2364: Invalid left-hand side of assignment expression. f += 1; // error ~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'typeof f' and 'number'. +!!! error TS2365: Operator '+=' cannot be applied to types 'typeof f' and '1'. f -= 1; // error ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/arithmeticOperatorWithAnyAndNumber.types b/tests/baselines/reference/arithmeticOperatorWithAnyAndNumber.types index 8845a52760d..eeaf6a0ab38 100644 --- a/tests/baselines/reference/arithmeticOperatorWithAnyAndNumber.types +++ b/tests/baselines/reference/arithmeticOperatorWithAnyAndNumber.types @@ -22,30 +22,30 @@ var ra3 = a * 0; >ra3 : number >a * 0 : number >a : any ->0 : number +>0 : 0 var ra4 = 0 * a; >ra4 : number >0 * a : number ->0 : number +>0 : 0 >a : any var ra5 = 0 * 0; >ra5 : number >0 * 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var ra6 = b * 0; >ra6 : number >b * 0 : number >b : number ->0 : number +>0 : 0 var ra7 = 0 * b; >ra7 : number >0 * b : number ->0 : number +>0 : 0 >b : number var ra8 = b * b; @@ -71,30 +71,30 @@ var rb3 = a / 0; >rb3 : number >a / 0 : number >a : any ->0 : number +>0 : 0 var rb4 = 0 / a; >rb4 : number >0 / a : number ->0 : number +>0 : 0 >a : any var rb5 = 0 / 0; >rb5 : number >0 / 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var rb6 = b / 0; >rb6 : number >b / 0 : number >b : number ->0 : number +>0 : 0 var rb7 = 0 / b; >rb7 : number >0 / b : number ->0 : number +>0 : 0 >b : number var rb8 = b / b; @@ -120,30 +120,30 @@ var rc3 = a % 0; >rc3 : number >a % 0 : number >a : any ->0 : number +>0 : 0 var rc4 = 0 % a; >rc4 : number >0 % a : number ->0 : number +>0 : 0 >a : any var rc5 = 0 % 0; >rc5 : number >0 % 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var rc6 = b % 0; >rc6 : number >b % 0 : number >b : number ->0 : number +>0 : 0 var rc7 = 0 % b; >rc7 : number >0 % b : number ->0 : number +>0 : 0 >b : number var rc8 = b % b; @@ -169,30 +169,30 @@ var rd3 = a - 0; >rd3 : number >a - 0 : number >a : any ->0 : number +>0 : 0 var rd4 = 0 - a; >rd4 : number >0 - a : number ->0 : number +>0 : 0 >a : any var rd5 = 0 - 0; >rd5 : number >0 - 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var rd6 = b - 0; >rd6 : number >b - 0 : number >b : number ->0 : number +>0 : 0 var rd7 = 0 - b; >rd7 : number >0 - b : number ->0 : number +>0 : 0 >b : number var rd8 = b - b; @@ -218,30 +218,30 @@ var re3 = a << 0; >re3 : number >a << 0 : number >a : any ->0 : number +>0 : 0 var re4 = 0 << a; >re4 : number >0 << a : number ->0 : number +>0 : 0 >a : any var re5 = 0 << 0; >re5 : number >0 << 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var re6 = b << 0; >re6 : number >b << 0 : number >b : number ->0 : number +>0 : 0 var re7 = 0 << b; >re7 : number >0 << b : number ->0 : number +>0 : 0 >b : number var re8 = b << b; @@ -267,30 +267,30 @@ var rf3 = a >> 0; >rf3 : number >a >> 0 : number >a : any ->0 : number +>0 : 0 var rf4 = 0 >> a; >rf4 : number >0 >> a : number ->0 : number +>0 : 0 >a : any var rf5 = 0 >> 0; >rf5 : number >0 >> 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var rf6 = b >> 0; >rf6 : number >b >> 0 : number >b : number ->0 : number +>0 : 0 var rf7 = 0 >> b; >rf7 : number >0 >> b : number ->0 : number +>0 : 0 >b : number var rf8 = b >> b; @@ -316,30 +316,30 @@ var rg3 = a >>> 0; >rg3 : number >a >>> 0 : number >a : any ->0 : number +>0 : 0 var rg4 = 0 >>> a; >rg4 : number >0 >>> a : number ->0 : number +>0 : 0 >a : any var rg5 = 0 >>> 0; >rg5 : number >0 >>> 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var rg6 = b >>> 0; >rg6 : number >b >>> 0 : number >b : number ->0 : number +>0 : 0 var rg7 = 0 >>> b; >rg7 : number >0 >>> b : number ->0 : number +>0 : 0 >b : number var rg8 = b >>> b; @@ -365,30 +365,30 @@ var rh3 = a & 0; >rh3 : number >a & 0 : number >a : any ->0 : number +>0 : 0 var rh4 = 0 & a; >rh4 : number >0 & a : number ->0 : number +>0 : 0 >a : any var rh5 = 0 & 0; >rh5 : number >0 & 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var rh6 = b & 0; >rh6 : number >b & 0 : number >b : number ->0 : number +>0 : 0 var rh7 = 0 & b; >rh7 : number >0 & b : number ->0 : number +>0 : 0 >b : number var rh8 = b & b; @@ -414,30 +414,30 @@ var ri3 = a ^ 0; >ri3 : number >a ^ 0 : number >a : any ->0 : number +>0 : 0 var ri4 = 0 ^ a; >ri4 : number >0 ^ a : number ->0 : number +>0 : 0 >a : any var ri5 = 0 ^ 0; >ri5 : number >0 ^ 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var ri6 = b ^ 0; >ri6 : number >b ^ 0 : number >b : number ->0 : number +>0 : 0 var ri7 = 0 ^ b; >ri7 : number >0 ^ b : number ->0 : number +>0 : 0 >b : number var ri8 = b ^ b; @@ -463,30 +463,30 @@ var rj3 = a | 0; >rj3 : number >a | 0 : number >a : any ->0 : number +>0 : 0 var rj4 = 0 | a; >rj4 : number >0 | a : number ->0 : number +>0 : 0 >a : any var rj5 = 0 | 0; >rj5 : number >0 | 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var rj6 = b | 0; >rj6 : number >b | 0 : number >b : number ->0 : number +>0 : 0 var rj7 = 0 | b; >rj7 : number >0 | b : number ->0 : number +>0 : 0 >b : number var rj8 = b | b; diff --git a/tests/baselines/reference/arithmeticOperatorWithEnum.types b/tests/baselines/reference/arithmeticOperatorWithEnum.types index 3aca5c31798..0f2fbe48feb 100644 --- a/tests/baselines/reference/arithmeticOperatorWithEnum.types +++ b/tests/baselines/reference/arithmeticOperatorWithEnum.types @@ -5,10 +5,10 @@ enum E { >E : E a, ->a : E +>a : E.a b ->b : E +>b : E.b } var a: any; @@ -55,60 +55,60 @@ var ra5 = b * c; var ra6 = E.a * a; >ra6 : number >E.a * a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var ra7 = E.a * b; >ra7 : number >E.a * b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var ra8 = E.a * E.b; >ra8 : number >E.a * E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ra9 = E.a * 1; >ra9 : number >E.a * 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var ra10 = a * E.b; >ra10 : number >a * E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ra11 = b * E.b; >ra11 : number >b * E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ra12 = 1 * E.b; >ra12 : number >1 * E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator / var rb1 = c / a; @@ -144,60 +144,60 @@ var rb5 = b / c; var rb6 = E.a / a; >rb6 : number >E.a / a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rb7 = E.a / b; >rb7 : number >E.a / b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rb8 = E.a / E.b; >rb8 : number >E.a / E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rb9 = E.a / 1; >rb9 : number >E.a / 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rb10 = a / E.b; >rb10 : number >a / E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rb11 = b / E.b; >rb11 : number >b / E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rb12 = 1 / E.b; >rb12 : number >1 / E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator % var rc1 = c % a; @@ -233,60 +233,60 @@ var rc5 = b % c; var rc6 = E.a % a; >rc6 : number >E.a % a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rc7 = E.a % b; >rc7 : number >E.a % b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rc8 = E.a % E.b; >rc8 : number >E.a % E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rc9 = E.a % 1; >rc9 : number >E.a % 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rc10 = a % E.b; >rc10 : number >a % E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rc11 = b % E.b; >rc11 : number >b % E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rc12 = 1 % E.b; >rc12 : number >1 % E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator - var rd1 = c - a; @@ -322,60 +322,60 @@ var rd5 = b - c; var rd6 = E.a - a; >rd6 : number >E.a - a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rd7 = E.a - b; >rd7 : number >E.a - b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rd8 = E.a - E.b; >rd8 : number >E.a - E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rd9 = E.a - 1; >rd9 : number >E.a - 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rd10 = a - E.b; >rd10 : number >a - E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rd11 = b - E.b; >rd11 : number >b - E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rd12 = 1 - E.b; >rd12 : number >1 - E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator << var re1 = c << a; @@ -411,60 +411,60 @@ var re5 = b << c; var re6 = E.a << a; >re6 : number >E.a << a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var re7 = E.a << b; >re7 : number >E.a << b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var re8 = E.a << E.b; >re8 : number >E.a << E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var re9 = E.a << 1; >re9 : number >E.a << 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var re10 = a << E.b; >re10 : number >a << E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var re11 = b << E.b; >re11 : number >b << E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var re12 = 1 << E.b; >re12 : number >1 << E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator >> var rf1 = c >> a; @@ -500,60 +500,60 @@ var rf5 = b >> c; var rf6 = E.a >> a; >rf6 : number >E.a >> a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rf7 = E.a >> b; >rf7 : number >E.a >> b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rf8 = E.a >> E.b; >rf8 : number >E.a >> E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rf9 = E.a >> 1; >rf9 : number >E.a >> 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rf10 = a >> E.b; >rf10 : number >a >> E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rf11 = b >> E.b; >rf11 : number >b >> E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rf12 = 1 >> E.b; >rf12 : number >1 >> E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator >>> var rg1 = c >>> a; @@ -589,60 +589,60 @@ var rg5 = b >>> c; var rg6 = E.a >>> a; >rg6 : number >E.a >>> a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rg7 = E.a >>> b; >rg7 : number >E.a >>> b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rg8 = E.a >>> E.b; >rg8 : number >E.a >>> E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rg9 = E.a >>> 1; >rg9 : number >E.a >>> 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rg10 = a >>> E.b; >rg10 : number >a >>> E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rg11 = b >>> E.b; >rg11 : number >b >>> E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rg12 = 1 >>> E.b; >rg12 : number >1 >>> E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator & var rh1 = c & a; @@ -678,60 +678,60 @@ var rh5 = b & c; var rh6 = E.a & a; >rh6 : number >E.a & a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rh7 = E.a & b; >rh7 : number >E.a & b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rh8 = E.a & E.b; >rh8 : number >E.a & E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rh9 = E.a & 1; >rh9 : number >E.a & 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rh10 = a & E.b; >rh10 : number >a & E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rh11 = b & E.b; >rh11 : number >b & E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rh12 = 1 & E.b; >rh12 : number >1 & E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator ^ var ri1 = c ^ a; @@ -767,60 +767,60 @@ var ri5 = b ^ c; var ri6 = E.a ^ a; >ri6 : number >E.a ^ a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var ri7 = E.a ^ b; >ri7 : number >E.a ^ b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var ri8 = E.a ^ E.b; >ri8 : number >E.a ^ E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ri9 = E.a ^ 1; >ri9 : number >E.a ^ 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var ri10 = a ^ E.b; >ri10 : number >a ^ E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ri11 = b ^ E.b; >ri11 : number >b ^ E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ri12 = 1 ^ E.b; >ri12 : number >1 ^ E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator | var rj1 = c | a; @@ -856,58 +856,58 @@ var rj5 = b | c; var rj6 = E.a | a; >rj6 : number >E.a | a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rj7 = E.a | b; >rj7 : number >E.a | b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rj8 = E.a | E.b; >rj8 : number >E.a | E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rj9 = E.a | 1; >rj9 : number >E.a | 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rj10 = a | E.b; >rj10 : number >a | E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rj11 = b | E.b; >rj11 : number >b | E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rj12 = 1 | E.b; >rj12 : number >1 | E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b diff --git a/tests/baselines/reference/arithmeticOperatorWithEnumUnion.types b/tests/baselines/reference/arithmeticOperatorWithEnumUnion.types index cb9bf3d45b0..379bd6f34b3 100644 --- a/tests/baselines/reference/arithmeticOperatorWithEnumUnion.types +++ b/tests/baselines/reference/arithmeticOperatorWithEnumUnion.types @@ -5,19 +5,19 @@ enum E { >E : E a, ->a : E +>a : E.a b ->b : E +>b : E.b } enum F { >F : F c, ->c : F +>c : F.c d ->d : F +>d : F.d } var a: any; @@ -65,60 +65,60 @@ var ra5 = b * c; var ra6 = E.a * a; >ra6 : number >E.a * a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var ra7 = E.a * b; >ra7 : number >E.a * b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var ra8 = E.a * E.b; >ra8 : number >E.a * E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ra9 = E.a * 1; >ra9 : number >E.a * 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var ra10 = a * E.b; >ra10 : number >a * E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ra11 = b * E.b; >ra11 : number >b * E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ra12 = 1 * E.b; >ra12 : number >1 * E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator / var rb1 = c / a; @@ -154,60 +154,60 @@ var rb5 = b / c; var rb6 = E.a / a; >rb6 : number >E.a / a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rb7 = E.a / b; >rb7 : number >E.a / b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rb8 = E.a / E.b; >rb8 : number >E.a / E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rb9 = E.a / 1; >rb9 : number >E.a / 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rb10 = a / E.b; >rb10 : number >a / E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rb11 = b / E.b; >rb11 : number >b / E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rb12 = 1 / E.b; >rb12 : number >1 / E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator % var rc1 = c % a; @@ -243,60 +243,60 @@ var rc5 = b % c; var rc6 = E.a % a; >rc6 : number >E.a % a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rc7 = E.a % b; >rc7 : number >E.a % b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rc8 = E.a % E.b; >rc8 : number >E.a % E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rc9 = E.a % 1; >rc9 : number >E.a % 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rc10 = a % E.b; >rc10 : number >a % E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rc11 = b % E.b; >rc11 : number >b % E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rc12 = 1 % E.b; >rc12 : number >1 % E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator - var rd1 = c - a; @@ -332,60 +332,60 @@ var rd5 = b - c; var rd6 = E.a - a; >rd6 : number >E.a - a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rd7 = E.a - b; >rd7 : number >E.a - b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rd8 = E.a - E.b; >rd8 : number >E.a - E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rd9 = E.a - 1; >rd9 : number >E.a - 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rd10 = a - E.b; >rd10 : number >a - E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rd11 = b - E.b; >rd11 : number >b - E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rd12 = 1 - E.b; >rd12 : number >1 - E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator << var re1 = c << a; @@ -421,60 +421,60 @@ var re5 = b << c; var re6 = E.a << a; >re6 : number >E.a << a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var re7 = E.a << b; >re7 : number >E.a << b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var re8 = E.a << E.b; >re8 : number >E.a << E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var re9 = E.a << 1; >re9 : number >E.a << 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var re10 = a << E.b; >re10 : number >a << E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var re11 = b << E.b; >re11 : number >b << E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var re12 = 1 << E.b; >re12 : number >1 << E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator >> var rf1 = c >> a; @@ -510,60 +510,60 @@ var rf5 = b >> c; var rf6 = E.a >> a; >rf6 : number >E.a >> a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rf7 = E.a >> b; >rf7 : number >E.a >> b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rf8 = E.a >> E.b; >rf8 : number >E.a >> E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rf9 = E.a >> 1; >rf9 : number >E.a >> 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rf10 = a >> E.b; >rf10 : number >a >> E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rf11 = b >> E.b; >rf11 : number >b >> E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rf12 = 1 >> E.b; >rf12 : number >1 >> E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator >>> var rg1 = c >>> a; @@ -599,60 +599,60 @@ var rg5 = b >>> c; var rg6 = E.a >>> a; >rg6 : number >E.a >>> a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rg7 = E.a >>> b; >rg7 : number >E.a >>> b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rg8 = E.a >>> E.b; >rg8 : number >E.a >>> E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rg9 = E.a >>> 1; >rg9 : number >E.a >>> 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rg10 = a >>> E.b; >rg10 : number >a >>> E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rg11 = b >>> E.b; >rg11 : number >b >>> E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rg12 = 1 >>> E.b; >rg12 : number >1 >>> E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator & var rh1 = c & a; @@ -688,60 +688,60 @@ var rh5 = b & c; var rh6 = E.a & a; >rh6 : number >E.a & a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rh7 = E.a & b; >rh7 : number >E.a & b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rh8 = E.a & E.b; >rh8 : number >E.a & E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rh9 = E.a & 1; >rh9 : number >E.a & 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rh10 = a & E.b; >rh10 : number >a & E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rh11 = b & E.b; >rh11 : number >b & E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rh12 = 1 & E.b; >rh12 : number >1 & E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator ^ var ri1 = c ^ a; @@ -777,60 +777,60 @@ var ri5 = b ^ c; var ri6 = E.a ^ a; >ri6 : number >E.a ^ a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var ri7 = E.a ^ b; >ri7 : number >E.a ^ b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var ri8 = E.a ^ E.b; >ri8 : number >E.a ^ E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ri9 = E.a ^ 1; >ri9 : number >E.a ^ 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var ri10 = a ^ E.b; >ri10 : number >a ^ E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ri11 = b ^ E.b; >ri11 : number >b ^ E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var ri12 = 1 ^ E.b; >ri12 : number >1 ^ E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b // operator | var rj1 = c | a; @@ -866,58 +866,58 @@ var rj5 = b | c; var rj6 = E.a | a; >rj6 : number >E.a | a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var rj7 = E.a | b; >rj7 : number >E.a | b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rj8 = E.a | E.b; >rj8 : number >E.a | E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rj9 = E.a | 1; >rj9 : number >E.a | 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var rj10 = a | E.b; >rj10 : number >a | E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rj11 = b | E.b; >rj11 : number >b | E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var rj12 = 1 | E.b; >rj12 : number >1 | E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b diff --git a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.types b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.types index 521fb4d7313..78e2a5945f0 100644 --- a/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.types +++ b/tests/baselines/reference/arithmeticOperatorWithNullValueAndValidOperands.types @@ -6,10 +6,10 @@ enum E { >E : E a, ->a : E +>a : E.a b ->b : E +>b : E.b } var a: any; @@ -35,15 +35,15 @@ var ra3 = null * 1; >ra3 : number >null * 1 : number >null : null ->1 : number +>1 : 1 var ra4 = null * E.a; >ra4 : number >null * E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var ra5 = a * null; >ra5 : number @@ -60,15 +60,15 @@ var ra6 = b * null; var ra7 = 0 * null; >ra7 : number >0 * null : number ->0 : number +>0 : 0 >null : null var ra8 = E.b * null; >ra8 : number >E.b * null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator / @@ -88,15 +88,15 @@ var rb3 = null / 1; >rb3 : number >null / 1 : number >null : null ->1 : number +>1 : 1 var rb4 = null / E.a; >rb4 : number >null / E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rb5 = a / null; >rb5 : number @@ -113,15 +113,15 @@ var rb6 = b / null; var rb7 = 0 / null; >rb7 : number >0 / null : number ->0 : number +>0 : 0 >null : null var rb8 = E.b / null; >rb8 : number >E.b / null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator % @@ -141,15 +141,15 @@ var rc3 = null % 1; >rc3 : number >null % 1 : number >null : null ->1 : number +>1 : 1 var rc4 = null % E.a; >rc4 : number >null % E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rc5 = a % null; >rc5 : number @@ -166,15 +166,15 @@ var rc6 = b % null; var rc7 = 0 % null; >rc7 : number >0 % null : number ->0 : number +>0 : 0 >null : null var rc8 = E.b % null; >rc8 : number >E.b % null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator - @@ -194,15 +194,15 @@ var rd3 = null - 1; >rd3 : number >null - 1 : number >null : null ->1 : number +>1 : 1 var rd4 = null - E.a; >rd4 : number >null - E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rd5 = a - null; >rd5 : number @@ -219,15 +219,15 @@ var rd6 = b - null; var rd7 = 0 - null; >rd7 : number >0 - null : number ->0 : number +>0 : 0 >null : null var rd8 = E.b - null; >rd8 : number >E.b - null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator << @@ -247,15 +247,15 @@ var re3 = null << 1; >re3 : number >null << 1 : number >null : null ->1 : number +>1 : 1 var re4 = null << E.a; >re4 : number >null << E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var re5 = a << null; >re5 : number @@ -272,15 +272,15 @@ var re6 = b << null; var re7 = 0 << null; >re7 : number >0 << null : number ->0 : number +>0 : 0 >null : null var re8 = E.b << null; >re8 : number >E.b << null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator >> @@ -300,15 +300,15 @@ var rf3 = null >> 1; >rf3 : number >null >> 1 : number >null : null ->1 : number +>1 : 1 var rf4 = null >> E.a; >rf4 : number >null >> E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rf5 = a >> null; >rf5 : number @@ -325,15 +325,15 @@ var rf6 = b >> null; var rf7 = 0 >> null; >rf7 : number >0 >> null : number ->0 : number +>0 : 0 >null : null var rf8 = E.b >> null; >rf8 : number >E.b >> null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator >>> @@ -353,15 +353,15 @@ var rg3 = null >>> 1; >rg3 : number >null >>> 1 : number >null : null ->1 : number +>1 : 1 var rg4 = null >>> E.a; >rg4 : number >null >>> E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rg5 = a >>> null; >rg5 : number @@ -378,15 +378,15 @@ var rg6 = b >>> null; var rg7 = 0 >>> null; >rg7 : number >0 >>> null : number ->0 : number +>0 : 0 >null : null var rg8 = E.b >>> null; >rg8 : number >E.b >>> null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator & @@ -406,15 +406,15 @@ var rh3 = null & 1; >rh3 : number >null & 1 : number >null : null ->1 : number +>1 : 1 var rh4 = null & E.a; >rh4 : number >null & E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rh5 = a & null; >rh5 : number @@ -431,15 +431,15 @@ var rh6 = b & null; var rh7 = 0 & null; >rh7 : number >0 & null : number ->0 : number +>0 : 0 >null : null var rh8 = E.b & null; >rh8 : number >E.b & null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator ^ @@ -459,15 +459,15 @@ var ri3 = null ^ 1; >ri3 : number >null ^ 1 : number >null : null ->1 : number +>1 : 1 var ri4 = null ^ E.a; >ri4 : number >null ^ E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var ri5 = a ^ null; >ri5 : number @@ -484,15 +484,15 @@ var ri6 = b ^ null; var ri7 = 0 ^ null; >ri7 : number >0 ^ null : number ->0 : number +>0 : 0 >null : null var ri8 = E.b ^ null; >ri8 : number >E.b ^ null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null // operator | @@ -512,15 +512,15 @@ var rj3 = null | 1; >rj3 : number >null | 1 : number >null : null ->1 : number +>1 : 1 var rj4 = null | E.a; >rj4 : number >null | E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rj5 = a | null; >rj5 : number @@ -537,14 +537,14 @@ var rj6 = b | null; var rj7 = 0 | null; >rj7 : number >0 | null : number ->0 : number +>0 : 0 >null : null var rj8 = E.b | null; >rj8 : number >E.b | null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null diff --git a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.types b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.types index 77dbe1c1441..2a714a35210 100644 --- a/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.types +++ b/tests/baselines/reference/arithmeticOperatorWithUndefinedValueAndValidOperands.types @@ -6,10 +6,10 @@ enum E { >E : E a, ->a : E +>a : E.a b ->b : E +>b : E.b } var a: any; @@ -35,15 +35,15 @@ var ra3 = undefined * 1; >ra3 : number >undefined * 1 : number >undefined : undefined ->1 : number +>1 : 1 var ra4 = undefined * E.a; >ra4 : number >undefined * E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var ra5 = a * undefined; >ra5 : number @@ -60,15 +60,15 @@ var ra6 = b * undefined; var ra7 = 0 * undefined; >ra7 : number >0 * undefined : number ->0 : number +>0 : 0 >undefined : undefined var ra8 = E.b * undefined; >ra8 : number >E.b * undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator / @@ -88,15 +88,15 @@ var rb3 = undefined / 1; >rb3 : number >undefined / 1 : number >undefined : undefined ->1 : number +>1 : 1 var rb4 = undefined / E.a; >rb4 : number >undefined / E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rb5 = a / undefined; >rb5 : number @@ -113,15 +113,15 @@ var rb6 = b / undefined; var rb7 = 0 / undefined; >rb7 : number >0 / undefined : number ->0 : number +>0 : 0 >undefined : undefined var rb8 = E.b / undefined; >rb8 : number >E.b / undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator % @@ -141,15 +141,15 @@ var rc3 = undefined % 1; >rc3 : number >undefined % 1 : number >undefined : undefined ->1 : number +>1 : 1 var rc4 = undefined % E.a; >rc4 : number >undefined % E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rc5 = a % undefined; >rc5 : number @@ -166,15 +166,15 @@ var rc6 = b % undefined; var rc7 = 0 % undefined; >rc7 : number >0 % undefined : number ->0 : number +>0 : 0 >undefined : undefined var rc8 = E.b % undefined; >rc8 : number >E.b % undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator - @@ -194,15 +194,15 @@ var rd3 = undefined - 1; >rd3 : number >undefined - 1 : number >undefined : undefined ->1 : number +>1 : 1 var rd4 = undefined - E.a; >rd4 : number >undefined - E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rd5 = a - undefined; >rd5 : number @@ -219,15 +219,15 @@ var rd6 = b - undefined; var rd7 = 0 - undefined; >rd7 : number >0 - undefined : number ->0 : number +>0 : 0 >undefined : undefined var rd8 = E.b - undefined; >rd8 : number >E.b - undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator << @@ -247,15 +247,15 @@ var re3 = undefined << 1; >re3 : number >undefined << 1 : number >undefined : undefined ->1 : number +>1 : 1 var re4 = undefined << E.a; >re4 : number >undefined << E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var re5 = a << undefined; >re5 : number @@ -272,15 +272,15 @@ var re6 = b << undefined; var re7 = 0 << undefined; >re7 : number >0 << undefined : number ->0 : number +>0 : 0 >undefined : undefined var re8 = E.b << undefined; >re8 : number >E.b << undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator >> @@ -300,15 +300,15 @@ var rf3 = undefined >> 1; >rf3 : number >undefined >> 1 : number >undefined : undefined ->1 : number +>1 : 1 var rf4 = undefined >> E.a; >rf4 : number >undefined >> E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rf5 = a >> undefined; >rf5 : number @@ -325,15 +325,15 @@ var rf6 = b >> undefined; var rf7 = 0 >> undefined; >rf7 : number >0 >> undefined : number ->0 : number +>0 : 0 >undefined : undefined var rf8 = E.b >> undefined; >rf8 : number >E.b >> undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator >>> @@ -353,15 +353,15 @@ var rg3 = undefined >>> 1; >rg3 : number >undefined >>> 1 : number >undefined : undefined ->1 : number +>1 : 1 var rg4 = undefined >>> E.a; >rg4 : number >undefined >>> E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rg5 = a >>> undefined; >rg5 : number @@ -378,15 +378,15 @@ var rg6 = b >>> undefined; var rg7 = 0 >>> undefined; >rg7 : number >0 >>> undefined : number ->0 : number +>0 : 0 >undefined : undefined var rg8 = E.b >>> undefined; >rg8 : number >E.b >>> undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator & @@ -406,15 +406,15 @@ var rh3 = undefined & 1; >rh3 : number >undefined & 1 : number >undefined : undefined ->1 : number +>1 : 1 var rh4 = undefined & E.a; >rh4 : number >undefined & E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rh5 = a & undefined; >rh5 : number @@ -431,15 +431,15 @@ var rh6 = b & undefined; var rh7 = 0 & undefined; >rh7 : number >0 & undefined : number ->0 : number +>0 : 0 >undefined : undefined var rh8 = E.b & undefined; >rh8 : number >E.b & undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator ^ @@ -459,15 +459,15 @@ var ri3 = undefined ^ 1; >ri3 : number >undefined ^ 1 : number >undefined : undefined ->1 : number +>1 : 1 var ri4 = undefined ^ E.a; >ri4 : number >undefined ^ E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var ri5 = a ^ undefined; >ri5 : number @@ -484,15 +484,15 @@ var ri6 = b ^ undefined; var ri7 = 0 ^ undefined; >ri7 : number >0 ^ undefined : number ->0 : number +>0 : 0 >undefined : undefined var ri8 = E.b ^ undefined; >ri8 : number >E.b ^ undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined // operator | @@ -512,15 +512,15 @@ var rj3 = undefined | 1; >rj3 : number >undefined | 1 : number >undefined : undefined ->1 : number +>1 : 1 var rj4 = undefined | E.a; >rj4 : number >undefined | E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rj5 = a | undefined; >rj5 : number @@ -537,14 +537,14 @@ var rj6 = b | undefined; var rj7 = 0 | undefined; >rj7 : number >0 | undefined : number ->0 : number +>0 : 0 >undefined : undefined var rj8 = E.b | undefined; >rj8 : number >E.b | undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined diff --git a/tests/baselines/reference/arrayAugment.types b/tests/baselines/reference/arrayAugment.types index 042b7265ec8..6d4e5a70a51 100644 --- a/tests/baselines/reference/arrayAugment.types +++ b/tests/baselines/reference/arrayAugment.types @@ -12,7 +12,7 @@ interface Array { var x = ['']; >x : string[] >[''] : string[] ->'' : string +>'' : "" var y = x.split(4); >y : string[][] @@ -20,7 +20,7 @@ var y = x.split(4); >x.split : (parts: number) => string[][] >x : string[] >split : (parts: number) => string[][] ->4 : number +>4 : 4 var y: string[][]; // Expect no error here >y : string[][] diff --git a/tests/baselines/reference/arrayBestCommonTypes.types b/tests/baselines/reference/arrayBestCommonTypes.types index 0b4a871cd40..864b1adfacb 100644 --- a/tests/baselines/reference/arrayBestCommonTypes.types +++ b/tests/baselines/reference/arrayBestCommonTypes.types @@ -40,7 +40,7 @@ module EmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >x : any >y : boolean ->false : boolean +>false : false >null : null public x() { @@ -55,9 +55,9 @@ module EmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[4, 2][0] : number >[4, 2] : number[] ->4 : number ->2 : number ->0 : number +>4 : 4 +>2 : 2 +>0 : 0 (this.voidIfAny([4, 2, undefined][0])); >(this.voidIfAny([4, 2, undefined][0])) : number @@ -68,10 +68,10 @@ module EmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[4, 2, undefined][0] : number >[4, 2, undefined] : number[] ->4 : number ->2 : number +>4 : 4 +>2 : 2 >undefined : undefined ->0 : number +>0 : 0 (this.voidIfAny([undefined, 2, 4][0])); >(this.voidIfAny([undefined, 2, 4][0])) : number @@ -83,9 +83,9 @@ module EmptyTypes { >[undefined, 2, 4][0] : number >[undefined, 2, 4] : number[] >undefined : undefined ->2 : number ->4 : number ->0 : number +>2 : 2 +>4 : 4 +>0 : 0 (this.voidIfAny([null, 2, 4][0])); >(this.voidIfAny([null, 2, 4][0])) : number @@ -97,9 +97,9 @@ module EmptyTypes { >[null, 2, 4][0] : number >[null, 2, 4] : number[] >null : null ->2 : number ->4 : number ->0 : number +>2 : 2 +>4 : 4 +>0 : 0 (this.voidIfAny([2, 4, null][0])); >(this.voidIfAny([2, 4, null][0])) : number @@ -110,10 +110,10 @@ module EmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[2, 4, null][0] : number >[2, 4, null] : number[] ->2 : number ->4 : number +>2 : 2 +>4 : 4 >null : null ->0 : number +>0 : 0 (this.voidIfAny([undefined, 4, null][0])); >(this.voidIfAny([undefined, 4, null][0])) : number @@ -125,9 +125,9 @@ module EmptyTypes { >[undefined, 4, null][0] : number >[undefined, 4, null] : number[] >undefined : undefined ->4 : number +>4 : 4 >null : null ->0 : number +>0 : 0 (this.voidIfAny(['', "q"][0])); >(this.voidIfAny(['', "q"][0])) : number @@ -138,9 +138,9 @@ module EmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >['', "q"][0] : string >['', "q"] : string[] ->'' : string ->"q" : string ->0 : number +>'' : "" +>"q" : "q" +>0 : 0 (this.voidIfAny(['', "q", undefined][0])); >(this.voidIfAny(['', "q", undefined][0])) : number @@ -151,10 +151,10 @@ module EmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >['', "q", undefined][0] : string >['', "q", undefined] : string[] ->'' : string ->"q" : string +>'' : "" +>"q" : "q" >undefined : undefined ->0 : number +>0 : 0 (this.voidIfAny([undefined, "q", ''][0])); >(this.voidIfAny([undefined, "q", ''][0])) : number @@ -166,9 +166,9 @@ module EmptyTypes { >[undefined, "q", ''][0] : string >[undefined, "q", ''] : string[] >undefined : undefined ->"q" : string ->'' : string ->0 : number +>"q" : "q" +>'' : "" +>0 : 0 (this.voidIfAny([null, "q", ''][0])); >(this.voidIfAny([null, "q", ''][0])) : number @@ -180,9 +180,9 @@ module EmptyTypes { >[null, "q", ''][0] : string >[null, "q", ''] : string[] >null : null ->"q" : string ->'' : string ->0 : number +>"q" : "q" +>'' : "" +>0 : 0 (this.voidIfAny(["q", '', null][0])); >(this.voidIfAny(["q", '', null][0])) : number @@ -193,10 +193,10 @@ module EmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >["q", '', null][0] : string >["q", '', null] : string[] ->"q" : string ->'' : string +>"q" : "q" +>'' : "" >null : null ->0 : number +>0 : 0 (this.voidIfAny([undefined, '', null][0])); >(this.voidIfAny([undefined, '', null][0])) : number @@ -208,9 +208,9 @@ module EmptyTypes { >[undefined, '', null][0] : string >[undefined, '', null] : string[] >undefined : undefined ->'' : string +>'' : "" >null : null ->0 : number +>0 : 0 (this.voidIfAny([[3, 4], [null]][0][0])); >(this.voidIfAny([[3, 4], [null]][0][0])) : number @@ -223,12 +223,12 @@ module EmptyTypes { >[[3, 4], [null]][0] : number[] >[[3, 4], [null]] : number[][] >[3, 4] : number[] ->3 : number ->4 : number +>3 : 3 +>4 : 4 >[null] : null[] >null : null ->0 : number ->0 : number +>0 : 0 +>0 : 0 var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; @@ -239,13 +239,13 @@ module EmptyTypes { >[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: derived; }[] >{ x: 7, y: new derived() } : { x: number; y: derived; } >x : number ->7 : number +>7 : 7 >y : derived >new derived() : derived >derived : typeof derived >{ x: 5, y: new base() } : { x: number; y: base; } >x : number ->5 : number +>5 : 5 >y : base >new base() : base >base : typeof base @@ -257,13 +257,13 @@ module EmptyTypes { >base : base >[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: true; y: derived; } | { x: false; y: base; })[] >{ x: true, y: new derived() } : { x: true; y: derived; } ->x : true +>x : boolean >true : true >y : derived >new derived() : derived >derived : typeof derived >{ x: false, y: new base() } : { x: false; y: base; } ->x : false +>x : boolean >false : false >y : base >new base() : base @@ -283,7 +283,7 @@ module EmptyTypes { >base : typeof base >{ x: '', y: new derived() } : { x: string; y: derived; } >x : string ->'' : string +>'' : "" >y : derived >new derived() : derived >derived : typeof derived @@ -298,19 +298,19 @@ module EmptyTypes { >[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number ->0 : number +>0 : 0 >y : string ->'a' : string +>'a' : "a" >{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string ->'a' : string +>'a' : "a" >y : string ->'a' : string +>'a' : "a" >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any >y : string ->'a' : string +>'a' : "a" var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; >a2 : { x: any; y: string; }[] @@ -319,36 +319,36 @@ module EmptyTypes { >x : any >anyObj : any >y : string ->'a' : string +>'a' : "a" >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number ->0 : number +>0 : 0 >y : string ->'a' : string +>'a' : "a" >{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string ->'a' : string +>'a' : "a" >y : string ->'a' : string +>'a' : "a" var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; >a3 : { x: any; y: string; }[] >[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number ->0 : number +>0 : 0 >y : string ->'a' : string +>'a' : "a" >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any >y : string ->'a' : string +>'a' : "a" >{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string ->'a' : string +>'a' : "a" >y : string ->'a' : string +>'a' : "a" var ifaceObj: iface = null; >ifaceObj : iface @@ -443,7 +443,7 @@ module NonEmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >x : any >y : boolean ->false : boolean +>false : false >null : null public x() { @@ -458,9 +458,9 @@ module NonEmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[4, 2][0] : number >[4, 2] : number[] ->4 : number ->2 : number ->0 : number +>4 : 4 +>2 : 2 +>0 : 0 (this.voidIfAny([4, 2, undefined][0])); >(this.voidIfAny([4, 2, undefined][0])) : number @@ -471,10 +471,10 @@ module NonEmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[4, 2, undefined][0] : number >[4, 2, undefined] : number[] ->4 : number ->2 : number +>4 : 4 +>2 : 2 >undefined : undefined ->0 : number +>0 : 0 (this.voidIfAny([undefined, 2, 4][0])); >(this.voidIfAny([undefined, 2, 4][0])) : number @@ -486,9 +486,9 @@ module NonEmptyTypes { >[undefined, 2, 4][0] : number >[undefined, 2, 4] : number[] >undefined : undefined ->2 : number ->4 : number ->0 : number +>2 : 2 +>4 : 4 +>0 : 0 (this.voidIfAny([null, 2, 4][0])); >(this.voidIfAny([null, 2, 4][0])) : number @@ -500,9 +500,9 @@ module NonEmptyTypes { >[null, 2, 4][0] : number >[null, 2, 4] : number[] >null : null ->2 : number ->4 : number ->0 : number +>2 : 2 +>4 : 4 +>0 : 0 (this.voidIfAny([2, 4, null][0])); >(this.voidIfAny([2, 4, null][0])) : number @@ -513,10 +513,10 @@ module NonEmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >[2, 4, null][0] : number >[2, 4, null] : number[] ->2 : number ->4 : number +>2 : 2 +>4 : 4 >null : null ->0 : number +>0 : 0 (this.voidIfAny([undefined, 4, null][0])); >(this.voidIfAny([undefined, 4, null][0])) : number @@ -528,9 +528,9 @@ module NonEmptyTypes { >[undefined, 4, null][0] : number >[undefined, 4, null] : number[] >undefined : undefined ->4 : number +>4 : 4 >null : null ->0 : number +>0 : 0 (this.voidIfAny(['', "q"][0])); >(this.voidIfAny(['', "q"][0])) : number @@ -541,9 +541,9 @@ module NonEmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >['', "q"][0] : string >['', "q"] : string[] ->'' : string ->"q" : string ->0 : number +>'' : "" +>"q" : "q" +>0 : 0 (this.voidIfAny(['', "q", undefined][0])); >(this.voidIfAny(['', "q", undefined][0])) : number @@ -554,10 +554,10 @@ module NonEmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >['', "q", undefined][0] : string >['', "q", undefined] : string[] ->'' : string ->"q" : string +>'' : "" +>"q" : "q" >undefined : undefined ->0 : number +>0 : 0 (this.voidIfAny([undefined, "q", ''][0])); >(this.voidIfAny([undefined, "q", ''][0])) : number @@ -569,9 +569,9 @@ module NonEmptyTypes { >[undefined, "q", ''][0] : string >[undefined, "q", ''] : string[] >undefined : undefined ->"q" : string ->'' : string ->0 : number +>"q" : "q" +>'' : "" +>0 : 0 (this.voidIfAny([null, "q", ''][0])); >(this.voidIfAny([null, "q", ''][0])) : number @@ -583,9 +583,9 @@ module NonEmptyTypes { >[null, "q", ''][0] : string >[null, "q", ''] : string[] >null : null ->"q" : string ->'' : string ->0 : number +>"q" : "q" +>'' : "" +>0 : 0 (this.voidIfAny(["q", '', null][0])); >(this.voidIfAny(["q", '', null][0])) : number @@ -596,10 +596,10 @@ module NonEmptyTypes { >voidIfAny : { (x: boolean, y?: boolean): number; (x: string, y?: boolean): number; (x: number, y?: boolean): number; } >["q", '', null][0] : string >["q", '', null] : string[] ->"q" : string ->'' : string +>"q" : "q" +>'' : "" >null : null ->0 : number +>0 : 0 (this.voidIfAny([undefined, '', null][0])); >(this.voidIfAny([undefined, '', null][0])) : number @@ -611,9 +611,9 @@ module NonEmptyTypes { >[undefined, '', null][0] : string >[undefined, '', null] : string[] >undefined : undefined ->'' : string +>'' : "" >null : null ->0 : number +>0 : 0 (this.voidIfAny([[3, 4], [null]][0][0])); >(this.voidIfAny([[3, 4], [null]][0][0])) : number @@ -626,12 +626,12 @@ module NonEmptyTypes { >[[3, 4], [null]][0] : number[] >[[3, 4], [null]] : number[][] >[3, 4] : number[] ->3 : number ->4 : number +>3 : 3 +>4 : 4 >[null] : null[] >null : null ->0 : number ->0 : number +>0 : 0 +>0 : 0 var t1: { x: number; y: base; }[] = [{ x: 7, y: new derived() }, { x: 5, y: new base() }]; @@ -642,13 +642,13 @@ module NonEmptyTypes { >[{ x: 7, y: new derived() }, { x: 5, y: new base() }] : { x: number; y: base; }[] >{ x: 7, y: new derived() } : { x: number; y: derived; } >x : number ->7 : number +>7 : 7 >y : derived >new derived() : derived >derived : typeof derived >{ x: 5, y: new base() } : { x: number; y: base; } >x : number ->5 : number +>5 : 5 >y : base >new base() : base >base : typeof base @@ -660,13 +660,13 @@ module NonEmptyTypes { >base : base >[{ x: true, y: new derived() }, { x: false, y: new base() }] : ({ x: true; y: derived; } | { x: false; y: base; })[] >{ x: true, y: new derived() } : { x: true; y: derived; } ->x : true +>x : boolean >true : true >y : derived >new derived() : derived >derived : typeof derived >{ x: false, y: new base() } : { x: false; y: base; } ->x : false +>x : boolean >false : false >y : base >new base() : base @@ -686,7 +686,7 @@ module NonEmptyTypes { >base : typeof base >{ x: '', y: new derived() } : { x: string; y: derived; } >x : string ->'' : string +>'' : "" >y : derived >new derived() : derived >derived : typeof derived @@ -701,19 +701,19 @@ module NonEmptyTypes { >[{ x: 0, y: 'a' }, { x: 'a', y: 'a' }, { x: anyObj, y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number ->0 : number +>0 : 0 >y : string ->'a' : string +>'a' : "a" >{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string ->'a' : string +>'a' : "a" >y : string ->'a' : string +>'a' : "a" >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any >y : string ->'a' : string +>'a' : "a" var a2 = [{ x: anyObj, y: 'a' }, { x: 0, y: 'a' }, { x: 'a', y: 'a' }]; >a2 : { x: any; y: string; }[] @@ -722,36 +722,36 @@ module NonEmptyTypes { >x : any >anyObj : any >y : string ->'a' : string +>'a' : "a" >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number ->0 : number +>0 : 0 >y : string ->'a' : string +>'a' : "a" >{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string ->'a' : string +>'a' : "a" >y : string ->'a' : string +>'a' : "a" var a3 = [{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }]; >a3 : { x: any; y: string; }[] >[{ x: 0, y: 'a' }, { x: anyObj, y: 'a' }, { x: 'a', y: 'a' }] : { x: any; y: string; }[] >{ x: 0, y: 'a' } : { x: number; y: string; } >x : number ->0 : number +>0 : 0 >y : string ->'a' : string +>'a' : "a" >{ x: anyObj, y: 'a' } : { x: any; y: string; } >x : any >anyObj : any >y : string ->'a' : string +>'a' : "a" >{ x: 'a', y: 'a' } : { x: string; y: string; } >x : string ->'a' : string +>'a' : "a" >y : string ->'a' : string +>'a' : "a" var ifaceObj: iface = null; >ifaceObj : iface diff --git a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types index 77db8cc250d..38649f2b02d 100644 --- a/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types +++ b/tests/baselines/reference/arrayBindingPatternOmittedExpressions.types @@ -43,12 +43,12 @@ function f([, a, , b, , , , s, , , ] = results) { >a : string >s[1] : string >s : string ->1 : number +>1 : 1 b = s[2]; >b = s[2] : string >b : string >s[2] : string >s : string ->2 : number +>2 : 2 } diff --git a/tests/baselines/reference/arrayConcat2.types b/tests/baselines/reference/arrayConcat2.types index 27fe754c485..7687c5ed8fe 100644 --- a/tests/baselines/reference/arrayConcat2.types +++ b/tests/baselines/reference/arrayConcat2.types @@ -8,15 +8,15 @@ a.concat("hello", 'world'); >a.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; } >a : string[] >concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; } ->"hello" : string ->'world' : string +>"hello" : "hello" +>'world' : "world" a.concat('Hello'); >a.concat('Hello') : string[] >a.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; } >a : string[] >concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; } ->'Hello' : string +>'Hello' : "Hello" var b = new Array(); >b : string[] @@ -28,5 +28,5 @@ b.concat('hello'); >b.concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; } >b : string[] >concat : { (...items: string[][]): string[]; (...items: (string | string[])[]): string[]; } ->'hello' : string +>'hello' : "hello" diff --git a/tests/baselines/reference/arrayConcatMap.types b/tests/baselines/reference/arrayConcatMap.types index 647406ef1c3..89289e58d4e 100644 --- a/tests/baselines/reference/arrayConcatMap.types +++ b/tests/baselines/reference/arrayConcatMap.types @@ -10,11 +10,11 @@ var x = [].concat([{ a: 1 }], [{ a: 2 }]) >[{ a: 1 }] : { a: number; }[] >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 >[{ a: 2 }] : { a: number; }[] >{ a: 2 } : { a: number; } >a : number ->2 : number +>2 : 2 .map(b => b.a); >map : (callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[] diff --git a/tests/baselines/reference/arrayConstructors1.types b/tests/baselines/reference/arrayConstructors1.types index 89807cd0348..c5a49e56f90 100644 --- a/tests/baselines/reference/arrayConstructors1.types +++ b/tests/baselines/reference/arrayConstructors1.types @@ -7,23 +7,23 @@ x = new Array(1); >x : string[] >new Array(1) : any[] >Array : ArrayConstructor ->1 : number +>1 : 1 x = new Array('hi', 'bye'); >x = new Array('hi', 'bye') : string[] >x : string[] >new Array('hi', 'bye') : string[] >Array : ArrayConstructor ->'hi' : string ->'bye' : string +>'hi' : "hi" +>'bye' : "bye" x = new Array('hi', 'bye'); >x = new Array('hi', 'bye') : string[] >x : string[] >new Array('hi', 'bye') : string[] >Array : ArrayConstructor ->'hi' : string ->'bye' : string +>'hi' : "hi" +>'bye' : "bye" var y: number[]; >y : number[] @@ -33,21 +33,21 @@ y = new Array(1); >y : number[] >new Array(1) : any[] >Array : ArrayConstructor ->1 : number +>1 : 1 y = new Array(1,2); >y = new Array(1,2) : number[] >y : number[] >new Array(1,2) : number[] >Array : ArrayConstructor ->1 : number ->2 : number +>1 : 1 +>2 : 2 y = new Array(1, 2); >y = new Array(1, 2) : number[] >y : number[] >new Array(1, 2) : number[] >Array : ArrayConstructor ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/arrayFilter.types b/tests/baselines/reference/arrayFilter.types index f3d6d421744..43ef4161a06 100644 --- a/tests/baselines/reference/arrayFilter.types +++ b/tests/baselines/reference/arrayFilter.types @@ -6,7 +6,7 @@ var foo = [ { name: 'bar' }, >{ name: 'bar' } : { name: string; } >name : string ->'bar' : string +>'bar' : "bar" { name: null }, >{ name: null } : { name: null; } @@ -16,7 +16,7 @@ var foo = [ { name: 'baz' } >{ name: 'baz' } : { name: string; } >name : string ->'baz' : string +>'baz' : "baz" ] diff --git a/tests/baselines/reference/arrayLiteral.types b/tests/baselines/reference/arrayLiteral.types index a7b915de79d..c36cc93c68e 100644 --- a/tests/baselines/reference/arrayLiteral.types +++ b/tests/baselines/reference/arrayLiteral.types @@ -9,18 +9,18 @@ var x = new Array(1); >x : any[] >new Array(1) : any[] >Array : ArrayConstructor ->1 : number +>1 : 1 var y = [1]; >y : number[] >[1] : number[] ->1 : number +>1 : 1 var y = [1, 2]; >y : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var y = new Array(); >y : number[] @@ -35,18 +35,18 @@ var x2: number[] = new Array(1); >x2 : number[] >new Array(1) : any[] >Array : ArrayConstructor ->1 : number +>1 : 1 var y2: number[] = [1]; >y2 : number[] >[1] : number[] ->1 : number +>1 : 1 var y2: number[] = [1, 2]; >y2 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var y2: number[] = new Array(); >y2 : number[] diff --git a/tests/baselines/reference/arrayLiteral1.types b/tests/baselines/reference/arrayLiteral1.types index eb83fa87035..e0ee33c1ef4 100644 --- a/tests/baselines/reference/arrayLiteral1.types +++ b/tests/baselines/reference/arrayLiteral1.types @@ -2,6 +2,6 @@ var v30 = [1, 2]; >v30 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/arrayLiteral2.types b/tests/baselines/reference/arrayLiteral2.types index 1c3c81117d9..5bbc2f4fce8 100644 --- a/tests/baselines/reference/arrayLiteral2.types +++ b/tests/baselines/reference/arrayLiteral2.types @@ -2,7 +2,7 @@ var v30 = [1, 2], v31; >v30 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >v31 : any diff --git a/tests/baselines/reference/arrayLiteralComments.types b/tests/baselines/reference/arrayLiteralComments.types index e1863516792..80199c0f808 100644 --- a/tests/baselines/reference/arrayLiteralComments.types +++ b/tests/baselines/reference/arrayLiteralComments.types @@ -9,28 +9,28 @@ var testArrayWithFunc = [ let x = 1; >x : number ->1 : number +>1 : 1 }, // String comment '1', ->'1' : string +>'1' : "1" // Numeric comment 2, ->2 : number +>2 : 2 // Object comment { a: 1 }, >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 // Array comment [1, 2, 3] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 ] diff --git a/tests/baselines/reference/arrayLiteralContextualType.types b/tests/baselines/reference/arrayLiteralContextualType.types index 0513908929e..f9d65aa2dff 100644 --- a/tests/baselines/reference/arrayLiteralContextualType.types +++ b/tests/baselines/reference/arrayLiteralContextualType.types @@ -11,11 +11,11 @@ class Giraffe { name = "Giraffe"; >name : string ->"Giraffe" : string +>"Giraffe" : "Giraffe" neckLength = "3m"; >neckLength : string ->"3m" : string +>"3m" : "3m" } class Elephant { @@ -23,11 +23,11 @@ class Elephant { name = "Elephant"; >name : string ->"Elephant" : string +>"Elephant" : "Elephant" trunkDiameter = "20cm"; >trunkDiameter : string ->"20cm" : string +>"20cm" : "20cm" } function foo(animals: IAnimal[]) { } diff --git a/tests/baselines/reference/arrayLiteralInNonVarArgParameter.types b/tests/baselines/reference/arrayLiteralInNonVarArgParameter.types index fcbaa22bc6a..4b46e0bf29f 100644 --- a/tests/baselines/reference/arrayLiteralInNonVarArgParameter.types +++ b/tests/baselines/reference/arrayLiteralInNonVarArgParameter.types @@ -8,6 +8,6 @@ panic([], 'one', 'two'); >panic([], 'one', 'two') : void >panic : (val: string[], ...opt: string[]) => void >[] : undefined[] ->'one' : string ->'two' : string +>'one' : "one" +>'two' : "two" diff --git a/tests/baselines/reference/arrayLiteralSpread.types b/tests/baselines/reference/arrayLiteralSpread.types index 7b9a34c0abe..fd6ae243265 100644 --- a/tests/baselines/reference/arrayLiteralSpread.types +++ b/tests/baselines/reference/arrayLiteralSpread.types @@ -5,9 +5,9 @@ function f0() { var a = [1, 2, 3]; >a : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var a1 = [...a]; >a1 : number[] @@ -18,15 +18,15 @@ function f0() { var a2 = [1, ...a]; >a2 : number[] >[1, ...a] : number[] ->1 : number +>1 : 1 >...a : number >a : number[] var a3 = [1, 2, ...a]; >a3 : number[] >[1, 2, ...a] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : number >a : number[] @@ -35,33 +35,33 @@ function f0() { >[...a, 1] : number[] >...a : number >a : number[] ->1 : number +>1 : 1 var a5 = [...a, 1, 2]; >a5 : number[] >[...a, 1, 2] : number[] >...a : number >a : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var a6 = [1, 2, ...a, 1, 2]; >a6 : number[] >[1, 2, ...a, 1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : number >a : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var a7 = [1, ...a, 2, ...a]; >a7 : number[] >[1, ...a, 2, ...a] : number[] ->1 : number +>1 : 1 >...a : number >a : number[] ->2 : number +>2 : 2 >...a : number >a : number[] @@ -82,17 +82,17 @@ function f1() { var a = [1, 2, 3]; >a : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var b = ["hello", ...a, true]; >b : (string | number | boolean)[] >["hello", ...a, true] : (string | number | boolean)[] ->"hello" : string +>"hello" : "hello" >...a : number >a : number[] ->true : boolean +>true : true var b: (string | number | boolean)[]; >b : (string | number | boolean)[] @@ -128,6 +128,6 @@ function f2() { >[...[5]] : number[] >...[5] : number >[5] : number[] ->5 : number +>5 : 5 } diff --git a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types index aad515b62ee..43cbb87e843 100644 --- a/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types +++ b/tests/baselines/reference/arrayLiteralWithMultipleBestCommonTypes.types @@ -41,21 +41,21 @@ var ds = [(x: Object) => 1, (x: string) => 2]; // { (x:Object) => number }[] >(x: Object) => 1 : (x: Object) => number >x : Object >Object : Object ->1 : number +>1 : 1 >(x: string) => 2 : (x: string) => number >x : string ->2 : number +>2 : 2 var es = [(x: string) => 2, (x: Object) => 1]; // { (x:string) => number }[] >es : ((x: string) => number)[] >[(x: string) => 2, (x: Object) => 1] : ((x: string) => number)[] >(x: string) => 2 : (x: string) => number >x : string ->2 : number +>2 : 2 >(x: Object) => 1 : (x: Object) => number >x : Object >Object : Object ->1 : number +>1 : 1 var fs = [(a: { x: number; y?: number }) => 1, (b: { x: number; z?: number }) => 2]; // (a: { x: number; y?: number }) => number[] >fs : (((a: { x: number; y?: number; }) => number) | ((b: { x: number; z?: number; }) => number))[] @@ -64,12 +64,12 @@ var fs = [(a: { x: number; y?: number }) => 1, (b: { x: number; z?: number }) => >a : { x: number; y?: number; } >x : number >y : number ->1 : number +>1 : 1 >(b: { x: number; z?: number }) => 2 : (b: { x: number; z?: number; }) => number >b : { x: number; z?: number; } >x : number >z : number ->2 : number +>2 : 2 var gs = [(b: { x: number; z?: number }) => 2, (a: { x: number; y?: number }) => 1]; // (b: { x: number; z?: number }) => number[] >gs : (((b: { x: number; z?: number; }) => number) | ((a: { x: number; y?: number; }) => number))[] @@ -78,10 +78,10 @@ var gs = [(b: { x: number; z?: number }) => 2, (a: { x: number; y?: number }) => >b : { x: number; z?: number; } >x : number >z : number ->2 : number +>2 : 2 >(a: { x: number; y?: number }) => 1 : (a: { x: number; y?: number; }) => number >a : { x: number; y?: number; } >x : number >y : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/arrayLiterals2ES5.types b/tests/baselines/reference/arrayLiterals2ES5.types index 6eae997f465..c3256db925e 100644 --- a/tests/baselines/reference/arrayLiterals2ES5.types +++ b/tests/baselines/reference/arrayLiterals2ES5.types @@ -13,15 +13,15 @@ var a0 = [,, 2, 3, 4] >[,, 2, 3, 4] : number[] > : undefined > : undefined ->2 : number ->3 : number ->4 : number +>2 : 2 +>3 : 3 +>4 : 4 var a1 = ["hello", "world"] >a1 : string[] >["hello", "world"] : string[] ->"hello" : string ->"world" : string +>"hello" : "hello" +>"world" : "world" var a2 = [, , , ...a0, "hello"]; >a2 : (string | number)[] @@ -31,7 +31,7 @@ var a2 = [, , , ...a0, "hello"]; > : undefined >...a0 : number >a0 : number[] ->"hello" : string +>"hello" : "hello" var a3 = [,, ...a0] >a3 : number[] @@ -45,7 +45,7 @@ var a4 = [() => 1, ]; >a4 : (() => number)[] >[() => 1, ] : (() => number)[] >() => 1 : () => number ->1 : number +>1 : 1 var a5 = [...a0, , ] >a5 : number[] @@ -74,12 +74,12 @@ var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; >b1 : [number[], string[]] >[[1, 2, 3], ["hello", "string"]] : [number[], string[]] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >["hello", "string"] : string[] ->"hello" : string ->"string" : string +>"hello" : "hello" +>"string" : "string" // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), @@ -89,16 +89,16 @@ var [c0, c1] = [1, 2]; // tuple type [number, number] >c0 : number >c1 : number >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] >c2 : number >c3 : number >[1, 2, true] : [number, number, boolean] ->1 : number ->2 : number ->true : boolean +>1 : 1 +>2 : 2 +>true : true // The resulting type an array literal expression is determined as follows: // - the resulting type is an array type with an element type that is the union of the types of the @@ -106,27 +106,27 @@ var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] var temp = ["s", "t", "r"]; >temp : string[] >["s", "t", "r"] : string[] ->"s" : string ->"t" : string ->"r" : string +>"s" : "s" +>"t" : "t" +>"r" : "r" var temp1 = [1, 2, 3]; >temp1 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; >temp2 : [number[], string[]] >[[1, 2, 3], ["hello", "string"]] : [number[], string[]] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >["hello", "string"] : string[] ->"hello" : string ->"string" : string +>"hello" : "hello" +>"string" : "string" var temp3 = [undefined, null, undefined]; >temp3 : any[] @@ -153,8 +153,8 @@ interface myArray2 extends Array { } var d0 = [1, true, ...temp,]; // has type (string|number|boolean)[] >d0 : (string | number | boolean)[] >[1, true, ...temp,] : (string | number | boolean)[] ->1 : number ->true : boolean +>1 : 1 +>true : true >...temp : string >temp : string[] @@ -221,5 +221,5 @@ var d9 = [[...temp1], ...["hello"]]; >temp1 : number[] >...["hello"] : string >["hello"] : string[] ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/arrayLiterals2ES6.types b/tests/baselines/reference/arrayLiterals2ES6.types index f05b0ca9282..57f3f44f62d 100644 --- a/tests/baselines/reference/arrayLiterals2ES6.types +++ b/tests/baselines/reference/arrayLiterals2ES6.types @@ -13,15 +13,15 @@ var a0 = [, , 2, 3, 4] >[, , 2, 3, 4] : number[] > : undefined > : undefined ->2 : number ->3 : number ->4 : number +>2 : 2 +>3 : 3 +>4 : 4 var a1 = ["hello", "world"] >a1 : string[] >["hello", "world"] : string[] ->"hello" : string ->"world" : string +>"hello" : "hello" +>"world" : "world" var a2 = [, , , ...a0, "hello"]; >a2 : (string | number)[] @@ -31,7 +31,7 @@ var a2 = [, , , ...a0, "hello"]; > : undefined >...a0 : number >a0 : number[] ->"hello" : string +>"hello" : "hello" var a3 = [, , ...a0] >a3 : number[] @@ -45,7 +45,7 @@ var a4 = [() => 1, ]; >a4 : (() => number)[] >[() => 1, ] : (() => number)[] >() => 1 : () => number ->1 : number +>1 : 1 var a5 = [...a0, , ] >a5 : number[] @@ -74,12 +74,12 @@ var b1: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; >b1 : [number[], string[]] >[[1, 2, 3], ["hello", "string"]] : [number[], string[]] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >["hello", "string"] : string[] ->"hello" : string ->"string" : string +>"hello" : "hello" +>"string" : "string" // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), @@ -89,16 +89,16 @@ var [c0, c1] = [1, 2]; // tuple type [number, number] >c0 : number >c1 : number >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] >c2 : number >c3 : number >[1, 2, true] : [number, number, boolean] ->1 : number ->2 : number ->true : boolean +>1 : 1 +>2 : 2 +>true : true // The resulting type an array literal expression is determined as follows: // - the resulting type is an array type with an element type that is the union of the types of the @@ -106,27 +106,27 @@ var [c2, c3] = [1, 2, true]; // tuple type [number, number, boolean] var temp = ["s", "t", "r"]; >temp : string[] >["s", "t", "r"] : string[] ->"s" : string ->"t" : string ->"r" : string +>"s" : "s" +>"t" : "t" +>"r" : "r" var temp1 = [1, 2, 3]; >temp1 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var temp2: [number[], string[]] = [[1, 2, 3], ["hello", "string"]]; >temp2 : [number[], string[]] >[[1, 2, 3], ["hello", "string"]] : [number[], string[]] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >["hello", "string"] : string[] ->"hello" : string ->"string" : string +>"hello" : "hello" +>"string" : "string" interface myArray extends Array { } >myArray : myArray @@ -142,8 +142,8 @@ interface myArray2 extends Array { } var d0 = [1, true, ...temp, ]; // has type (string|number|boolean)[] >d0 : (string | number | boolean)[] >[1, true, ...temp, ] : (string | number | boolean)[] ->1 : number ->true : boolean +>1 : 1 +>true : true >...temp : string >temp : string[] @@ -208,5 +208,5 @@ var d9 = [[...temp1], ...["hello"]]; >temp1 : number[] >...["hello"] : string >["hello"] : string[] ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/arrayLiterals3.errors.txt b/tests/baselines/reference/arrayLiterals3.errors.txt index 1f0dd30c09c..3ebf4174f51 100644 --- a/tests/baselines/reference/arrayLiterals3.errors.txt +++ b/tests/baselines/reference/arrayLiterals3.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(10,5): error TS2322: Type 'undefined[]' is not assignable to type '[any, any, any]'. Property '0' is missing in type 'undefined[]'. -tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(11,5): error TS2322: Type '["string", number, boolean]' is not assignable to type '[boolean, string, number]'. + Type '"string"' is not assignable to type 'boolean'. tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(17,5): error TS2322: Type '[number, number, string, boolean]' is not assignable to type '[number, number]'. Types of property 'pop' are incompatible. Type '() => string | number | boolean' is not assignable to type '() => number'. @@ -36,8 +36,8 @@ tests/cases/conformance/expressions/arrayLiterals/arrayLiterals3.ts(34,5): error !!! error TS2322: Property '0' is missing in type 'undefined[]'. var a1: [boolean, string, number] = ["string", 1, true]; // Error ~~ -!!! error TS2322: Type '[string, number, boolean]' is not assignable to type '[boolean, string, number]'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '["string", number, boolean]' is not assignable to type '[boolean, string, number]'. +!!! error TS2322: Type '"string"' is not assignable to type 'boolean'. // The resulting type an array literal expression is determined as follows: // - If the array literal contains no spread elements and is an array assignment pattern in a destructuring assignment (section 4.17.1), diff --git a/tests/baselines/reference/arrayOfFunctionTypes3.types b/tests/baselines/reference/arrayOfFunctionTypes3.types index 0ed92991ed0..124542f5814 100644 --- a/tests/baselines/reference/arrayOfFunctionTypes3.types +++ b/tests/baselines/reference/arrayOfFunctionTypes3.types @@ -5,7 +5,7 @@ var x = [() => 1, () => { }]; >x : (() => void)[] >[() => 1, () => { }] : (() => void)[] >() => 1 : () => number ->1 : number +>1 : 1 >() => { } : () => void var r2 = x[0](); @@ -13,7 +13,7 @@ var r2 = x[0](); >x[0]() : void >x[0] : () => void >x : (() => void)[] ->0 : number +>0 : 0 class C { >C : C @@ -32,7 +32,7 @@ var r3 = new y[0](); >new y[0]() : C >y[0] : typeof C >y : typeof C[] ->0 : number +>0 : 0 var a: { (x: number): number; (x: string): string; }; >a : { (x: number): number; (x: string): string; } @@ -60,19 +60,19 @@ var r4 = z[0]; >r4 : { (x: number): number; (x: any): any; } >z[0] : { (x: number): number; (x: any): any; } >z : { (x: number): number; (x: any): any; }[] ->0 : number +>0 : 0 var r5 = r4(''); // any not string >r5 : any >r4('') : any >r4 : { (x: number): number; (x: any): any; } ->'' : string +>'' : "" var r5b = r4(1); >r5b : number >r4(1) : number >r4 : { (x: number): number; (x: any): any; } ->1 : number +>1 : 1 var a2: { (x: T): number; (x: string): string;}; >a2 : { (x: T): number; (x: string): string; } @@ -106,11 +106,11 @@ var r6 = z2[0]; >r6 : { (x: number): number; (x: T): any; } >z2[0] : { (x: number): number; (x: T): any; } >z2 : { (x: number): number; (x: T): any; }[] ->0 : number +>0 : 0 var r7 = r6(''); // any not string >r7 : any >r6('') : any >r6 : { (x: number): number; (x: T): any; } ->'' : string +>'' : "" diff --git a/tests/baselines/reference/arrayconcat.types b/tests/baselines/reference/arrayconcat.types index 45615cd63b8..27724c63ab1 100644 --- a/tests/baselines/reference/arrayconcat.types +++ b/tests/baselines/reference/arrayconcat.types @@ -46,7 +46,7 @@ class parser { >this : this >options : IOptions[] >sort : (compareFn?: (a: IOptions, b: IOptions) => number) => IOptions[] ->function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } } : (a: IOptions, b: IOptions) => number +>function(a, b) { var aName = a.name.toLowerCase(); var bName = b.name.toLowerCase(); if (aName > bName) { return 1; } else if (aName < bName) { return -1; } else { return 0; } } : (a: IOptions, b: IOptions) => 0 | 1 | -1 >a : IOptions >b : IOptions @@ -74,7 +74,7 @@ class parser { >bName : string return 1; ->1 : number +>1 : 1 } else if (aName < bName) { >aName < bName : boolean @@ -82,12 +82,12 @@ class parser { >bName : string return -1; ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 } else { return 0; ->0 : number +>0 : 0 } }); } diff --git a/tests/baselines/reference/arrowFunctionExpressions.types b/tests/baselines/reference/arrowFunctionExpressions.types index 41344c61cc4..aad43240daa 100644 --- a/tests/baselines/reference/arrowFunctionExpressions.types +++ b/tests/baselines/reference/arrowFunctionExpressions.types @@ -21,13 +21,13 @@ var b = j => { return 0; } >b : (j: any) => number >j => { return 0; } : (j: any) => number >j : any ->0 : number +>0 : 0 var b = (j) => { return 0; } >b : (j: any) => number >(j) => { return 0; } : (j: any) => number >j : any ->0 : number +>0 : 0 // Identifier => AssignmentExpression is equivalent to(Identifier) => AssignmentExpression var c: number; @@ -80,7 +80,7 @@ var p5 = ([a = 1]) => { }; >p5 : ([a]: [number]) => void >([a = 1]) => { } : ([a]: [number]) => void >a : number ->1 : number +>1 : 1 var p6 = ({ a }) => { }; >p6 : ({a}: { a: any; }) => void @@ -97,17 +97,17 @@ var p8 = ({ a = 1 }) => { }; >p8 : ({a}: { a?: number; }) => void >({ a = 1 }) => { } : ({a}: { a?: number; }) => void >a : number ->1 : number +>1 : 1 var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; >p9 : ({a: {b}}: { a?: { b?: number; }; }) => void >({ a: { b = 1 } = { b: 1 } }) => { } : ({a: {b}}: { a?: { b?: number; }; }) => void >a : any >b : number ->1 : number +>1 : 1 >{ b: 1 } : { b?: number; } >b : number ->1 : number +>1 : 1 var p10 = ([{ value, done }]) => { }; >p10 : ([{value, done}]: [{ value: any; done: any; }]) => void @@ -126,7 +126,7 @@ class MyClass { >n : any >n + 1 : any >n : any ->1 : number +>1 : 1 p = (n) => n && this; >p : (n: any) => this @@ -145,7 +145,7 @@ class MyClass { >n : any >n + 1 : any >n : any ->1 : number +>1 : 1 var p = (n) => n && this; >p : (n: any) => this @@ -177,8 +177,8 @@ var e = arrrr()(3)()(4); >arrrr()(3) : () => (n: number) => number >arrrr() : (m: number) => () => (n: number) => number >arrrr : () => (m: number) => () => (n: number) => number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var e: number; >e : number @@ -203,8 +203,8 @@ function someFn() { >arr(3)(4) : number >arr(3) : (p: number) => number >arr : (n: number) => (p: number) => number ->3 : number ->4 : number +>3 : 3 +>4 : 4 >toExponential : (fractionDigits?: number) => string } @@ -217,7 +217,7 @@ function someOtherFn() { >(n: number) => '' + n : (n: number) => string >n : number >'' + n : string ->'' : string +>'' : "" >n : number arr(4).charAt(0); @@ -225,9 +225,9 @@ function someOtherFn() { >arr(4).charAt : (pos: number) => string >arr(4) : string >arr : (n: number) => string ->4 : number +>4 : 4 >charAt : (pos: number) => string ->0 : number +>0 : 0 } // Arrow function used in nested function in function @@ -270,14 +270,14 @@ var f = (n: string) => { return fn(4); >fn(4) : () => string >fn : (x: number) => () => string ->4 : number +>4 : 4 } var g = f('')(); >g : string >f('')() : string >f('') : () => string >f : (n: string) => () => string ->'' : string +>'' : "" var g: string; >g : string @@ -314,7 +314,7 @@ var h = someOuterFn()('')()(); >someOuterFn()('') : () => () => number >someOuterFn() : (n: string) => () => () => number >someOuterFn : () => (n: string) => () => () => number ->'' : string +>'' : "" h.toExponential(); >h.toExponential() : string @@ -348,7 +348,7 @@ function tryCatchFn() { >() => this + '' : () => string >this + '' : string >this : any ->'' : string +>'' : "" } } diff --git a/tests/baselines/reference/arrowFunctionInExpressionStatement1.types b/tests/baselines/reference/arrowFunctionInExpressionStatement1.types index a38a868f85b..c2954cd7bec 100644 --- a/tests/baselines/reference/arrowFunctionInExpressionStatement1.types +++ b/tests/baselines/reference/arrowFunctionInExpressionStatement1.types @@ -1,5 +1,5 @@ === tests/cases/compiler/arrowFunctionInExpressionStatement1.ts === () => 0; >() => 0 : () => number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/arrowFunctionInExpressionStatement2.types b/tests/baselines/reference/arrowFunctionInExpressionStatement2.types index bfbd11e8c08..04db38ac581 100644 --- a/tests/baselines/reference/arrowFunctionInExpressionStatement2.types +++ b/tests/baselines/reference/arrowFunctionInExpressionStatement2.types @@ -4,5 +4,5 @@ module M { () => 0; >() => 0 : () => number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/arrowFunctionWithObjectLiteralBody5.types b/tests/baselines/reference/arrowFunctionWithObjectLiteralBody5.types index 0093ace2d9c..8a006d7f1d4 100644 --- a/tests/baselines/reference/arrowFunctionWithObjectLiteralBody5.types +++ b/tests/baselines/reference/arrowFunctionWithObjectLiteralBody5.types @@ -6,9 +6,9 @@ var a = () => { name: "foo", message: "bar" }; >Error : Error >{ name: "foo", message: "bar" } : { name: string; message: string; } >name : string ->"foo" : string +>"foo" : "foo" >message : string ->"bar" : string +>"bar" : "bar" var b = () => ({ name: "foo", message: "bar" }); >b : () => Error @@ -18,9 +18,9 @@ var b = () => ({ name: "foo", message: "bar" }); >Error : Error >{ name: "foo", message: "bar" } : { name: string; message: string; } >name : string ->"foo" : string +>"foo" : "foo" >message : string ->"bar" : string +>"bar" : "bar" var c = () => ({ name: "foo", message: "bar" }); >c : () => { name: string; message: string; } @@ -28,9 +28,9 @@ var c = () => ({ name: "foo", message: "bar" }); >({ name: "foo", message: "bar" }) : { name: string; message: string; } >{ name: "foo", message: "bar" } : { name: string; message: string; } >name : string ->"foo" : string +>"foo" : "foo" >message : string ->"bar" : string +>"bar" : "bar" var d = () => ((({ name: "foo", message: "bar" }))); >d : () => Error @@ -42,7 +42,7 @@ var d = () => ((({ name: "foo", message: "bar" }))); >({ name: "foo", message: "bar" }) : { name: string; message: string; } >{ name: "foo", message: "bar" } : { name: string; message: string; } >name : string ->"foo" : string +>"foo" : "foo" >message : string ->"bar" : string +>"bar" : "bar" diff --git a/tests/baselines/reference/arrowFunctionWithObjectLiteralBody6.types b/tests/baselines/reference/arrowFunctionWithObjectLiteralBody6.types index 31d2a63fec0..615f19aaf6b 100644 --- a/tests/baselines/reference/arrowFunctionWithObjectLiteralBody6.types +++ b/tests/baselines/reference/arrowFunctionWithObjectLiteralBody6.types @@ -6,9 +6,9 @@ var a = () => { name: "foo", message: "bar" }; >Error : Error >{ name: "foo", message: "bar" } : { name: string; message: string; } >name : string ->"foo" : string +>"foo" : "foo" >message : string ->"bar" : string +>"bar" : "bar" var b = () => ({ name: "foo", message: "bar" }); >b : () => Error @@ -18,9 +18,9 @@ var b = () => ({ name: "foo", message: "bar" }); >Error : Error >{ name: "foo", message: "bar" } : { name: string; message: string; } >name : string ->"foo" : string +>"foo" : "foo" >message : string ->"bar" : string +>"bar" : "bar" var c = () => ({ name: "foo", message: "bar" }); >c : () => { name: string; message: string; } @@ -28,9 +28,9 @@ var c = () => ({ name: "foo", message: "bar" }); >({ name: "foo", message: "bar" }) : { name: string; message: string; } >{ name: "foo", message: "bar" } : { name: string; message: string; } >name : string ->"foo" : string +>"foo" : "foo" >message : string ->"bar" : string +>"bar" : "bar" var d = () => ((({ name: "foo", message: "bar" }))); >d : () => Error @@ -42,7 +42,7 @@ var d = () => ((({ name: "foo", message: "bar" }))); >({ name: "foo", message: "bar" }) : { name: string; message: string; } >{ name: "foo", message: "bar" } : { name: string; message: string; } >name : string ->"foo" : string +>"foo" : "foo" >message : string ->"bar" : string +>"bar" : "bar" diff --git a/tests/baselines/reference/asOpEmitParens.types b/tests/baselines/reference/asOpEmitParens.types index b87d7f4d91f..3204a6e5cac 100644 --- a/tests/baselines/reference/asOpEmitParens.types +++ b/tests/baselines/reference/asOpEmitParens.types @@ -9,8 +9,8 @@ declare var x; >x + 1 as number : number >x + 1 : any >x : any ->1 : number ->3 : number +>1 : 1 +>3 : 3 // Should still emit as x.y (x as any).y; diff --git a/tests/baselines/reference/asOperator1.types b/tests/baselines/reference/asOperator1.types index 3f69871ea09..cf4a0b770be 100644 --- a/tests/baselines/reference/asOperator1.types +++ b/tests/baselines/reference/asOperator1.types @@ -1,7 +1,7 @@ === tests/cases/conformance/expressions/asOperator/asOperator1.ts === var as = 43; >as : number ->43 : number +>43 : 43 var x = undefined as number; >x : number @@ -26,10 +26,10 @@ var z = Date as any as string; var j = 32 as number|string; >j : string | number >32 as number|string : string | number ->32 : number +>32 : 32 j = ''; ->j = '' : string +>j = '' : "" >j : string | number ->'' : string +>'' : "" diff --git a/tests/baselines/reference/asOperator3.types b/tests/baselines/reference/asOperator3.types index 507dfd8b572..a888d70892b 100644 --- a/tests/baselines/reference/asOperator3.types +++ b/tests/baselines/reference/asOperator3.types @@ -8,30 +8,30 @@ var a = `${123 + 456 as number}`; >`${123 + 456 as number}` : string >123 + 456 as number : number >123 + 456 : number ->123 : number ->456 : number +>123 : 123 +>456 : 456 var b = `leading ${123 + 456 as number}`; >b : string >`leading ${123 + 456 as number}` : string >123 + 456 as number : number >123 + 456 : number ->123 : number ->456 : number +>123 : 123 +>456 : 456 var c = `${123 + 456 as number} trailing`; >c : string >`${123 + 456 as number} trailing` : string >123 + 456 as number : number >123 + 456 : number ->123 : number ->456 : number +>123 : 123 +>456 : 456 var d = `Hello ${123} World` as string; >d : string >`Hello ${123} World` as string : string >`Hello ${123} World` : string ->123 : number +>123 : 123 var e = `Hello` as string; >e : string @@ -42,9 +42,9 @@ var f = 1 + `${1} end of string` as string; >f : string >1 + `${1} end of string` as string : string >1 + `${1} end of string` : string ->1 : number +>1 : 1 >`${1} end of string` : string ->1 : number +>1 : 1 var g = tag `Hello ${123} World` as string; >g : string @@ -52,7 +52,7 @@ var g = tag `Hello ${123} World` as string; >tag `Hello ${123} World` : any >tag : (...x: any[]) => any >`Hello ${123} World` : string ->123 : number +>123 : 123 var h = tag `Hello` as string; >h : string diff --git a/tests/baselines/reference/asOperatorASI.types b/tests/baselines/reference/asOperatorASI.types index 61c2d115cf4..e5e1de88c29 100644 --- a/tests/baselines/reference/asOperatorASI.types +++ b/tests/baselines/reference/asOperatorASI.types @@ -9,7 +9,7 @@ declare function as(...args: any[]); // Example 1 var x = 10 >x : number ->10 : number +>10 : 10 as `Hello world`; // should not error >as `Hello world` : any @@ -19,7 +19,7 @@ as `Hello world`; // should not error // Example 2 var y = 20 >y : number ->20 : number +>20 : 20 as(Foo); // should emit >as(Foo) : any diff --git a/tests/baselines/reference/asiArith.types b/tests/baselines/reference/asiArith.types index 13394d2f1c2..b2c7410a403 100644 --- a/tests/baselines/reference/asiArith.types +++ b/tests/baselines/reference/asiArith.types @@ -1,11 +1,11 @@ === tests/cases/compiler/asiArith.ts === var x = 1; >x : number ->1 : number +>1 : 1 var y = 1; >y : number ->1 : number +>1 : 1 var z = >z : number @@ -28,11 +28,11 @@ y var a = 1; >a : number ->1 : number +>1 : 1 var b = 1; >b : number ->1 : number +>1 : 1 var c = >c : number diff --git a/tests/baselines/reference/asiBreak.types b/tests/baselines/reference/asiBreak.types index af3d6a040d5..7e7a8efb71f 100644 --- a/tests/baselines/reference/asiBreak.types +++ b/tests/baselines/reference/asiBreak.types @@ -1,4 +1,4 @@ === tests/cases/compiler/asiBreak.ts === while (true) break ->true : boolean +>true : true diff --git a/tests/baselines/reference/asiContinue.types b/tests/baselines/reference/asiContinue.types index e2eb5ba107d..0de6786fee1 100644 --- a/tests/baselines/reference/asiContinue.types +++ b/tests/baselines/reference/asiContinue.types @@ -1,4 +1,4 @@ === tests/cases/compiler/asiContinue.ts === while (true) continue ->true : boolean +>true : true diff --git a/tests/baselines/reference/asiInES6Classes.types b/tests/baselines/reference/asiInES6Classes.types index 41940a0f477..6a93269497c 100644 --- a/tests/baselines/reference/asiInES6Classes.types +++ b/tests/baselines/reference/asiInES6Classes.types @@ -10,7 +10,7 @@ class Foo { done: false >done : boolean ->false : boolean +>false : false } @@ -20,7 +20,7 @@ class Foo { >bar : () => number return 3; ->3 : number +>3 : 3 } diff --git a/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule01.types b/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule01.types index 3e6aade9a21..744687429ce 100644 --- a/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule01.types +++ b/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule01.types @@ -13,6 +13,6 @@ module // this is the identifier 'module' >module : string "my external module" // this is just a string ->"my external module" : string +>"my external module" : "my external module" { } // this is a block body diff --git a/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule02.types b/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule02.types index 67671853993..ae82f5f68a4 100644 --- a/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule02.types +++ b/tests/baselines/reference/asiPreventsParsingAsAmbientExternalModule02.types @@ -16,7 +16,7 @@ module container { >module : string "my external module" // this is just a string ->"my external module" : string +>"my external module" : "my external module" { } // this is a block body } diff --git a/tests/baselines/reference/asiPreventsParsingAsNamespace04.types b/tests/baselines/reference/asiPreventsParsingAsNamespace04.types index 3fa2a448cf9..7cab2a7be36 100644 --- a/tests/baselines/reference/asiPreventsParsingAsNamespace04.types +++ b/tests/baselines/reference/asiPreventsParsingAsNamespace04.types @@ -2,7 +2,7 @@ let module = 10; >module : number ->10 : number +>10 : 10 module in {} >module in {} : boolean diff --git a/tests/baselines/reference/asiPreventsParsingAsNamespace05.types b/tests/baselines/reference/asiPreventsParsingAsNamespace05.types index 515147c1096..e1492c8c582 100644 --- a/tests/baselines/reference/asiPreventsParsingAsNamespace05.types +++ b/tests/baselines/reference/asiPreventsParsingAsNamespace05.types @@ -2,7 +2,7 @@ let namespace = 10; >namespace : number ->10 : number +>10 : 10 namespace a.b { >a : typeof a @@ -10,7 +10,7 @@ namespace a.b { export let c = 20; >c : number ->20 : number +>20 : 20 } namespace diff --git a/tests/baselines/reference/assign1.types b/tests/baselines/reference/assign1.types index d600c4055af..51d9c72c54e 100644 --- a/tests/baselines/reference/assign1.types +++ b/tests/baselines/reference/assign1.types @@ -17,8 +17,8 @@ module M { >I : I >{salt:2,pepper:0} : { salt: number; pepper: number; } >salt : number ->2 : number +>2 : 2 >pepper : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/assignEveryTypeToAny.types b/tests/baselines/reference/assignEveryTypeToAny.types index dfff671a875..cfc24e1da65 100644 --- a/tests/baselines/reference/assignEveryTypeToAny.types +++ b/tests/baselines/reference/assignEveryTypeToAny.types @@ -5,13 +5,13 @@ var x: any; >x : any x = 1; ->x = 1 : number +>x = 1 : 1 >x : any ->1 : number +>1 : 1 var a = 2; >a : number ->2 : number +>2 : 2 x = a; >x = a : number @@ -19,27 +19,27 @@ x = a; >a : number x = true; ->x = true : boolean +>x = true : true >x : any ->true : boolean +>true : true var b = true; >b : boolean ->true : boolean +>true : true x = b; ->x = b : boolean +>x = b : true >x : any ->b : boolean +>b : true x = ""; ->x = "" : string +>x = "" : "" >x : any ->"" : string +>"" : "" var c = ""; >c : string ->"" : string +>"" : "" x = c; >x = c : string @@ -142,7 +142,7 @@ x = { f() { return 1; } } >x : any >{ f() { return 1; } } : { f(): number; } >f : () => number ->1 : number +>1 : 1 x = { f(x: T) { return x; } } >x = { f(x: T) { return x; } } : { f(x: T): T; } diff --git a/tests/baselines/reference/assignToFn.errors.txt b/tests/baselines/reference/assignToFn.errors.txt index 7f2c7855a35..42a1a129a23 100644 --- a/tests/baselines/reference/assignToFn.errors.txt +++ b/tests/baselines/reference/assignToFn.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/assignToFn.ts(8,5): error TS2322: Type 'string' is not assignable to type '(n: number) => boolean'. +tests/cases/compiler/assignToFn.ts(8,5): error TS2322: Type '"hello"' is not assignable to type '(n: number) => boolean'. ==== tests/cases/compiler/assignToFn.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/compiler/assignToFn.ts(8,5): error TS2322: Type 'string' is not assi x.f="hello"; ~~~ -!!! error TS2322: Type 'string' is not assignable to type '(n: number) => boolean'. +!!! error TS2322: Type '"hello"' is not assignable to type '(n: number) => boolean'. } \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompat1.errors.txt b/tests/baselines/reference/assignmentCompat1.errors.txt index 0936c532ab3..e9fc3bd2f7f 100644 --- a/tests/baselines/reference/assignmentCompat1.errors.txt +++ b/tests/baselines/reference/assignmentCompat1.errors.txt @@ -2,8 +2,8 @@ tests/cases/compiler/assignmentCompat1.ts(4,1): error TS2322: Type '{ [index: st Property 'one' is missing in type '{ [index: string]: any; }'. tests/cases/compiler/assignmentCompat1.ts(6,1): error TS2322: Type '{ [index: number]: any; }' is not assignable to type '{ one: number; }'. Property 'one' is missing in type '{ [index: number]: any; }'. -tests/cases/compiler/assignmentCompat1.ts(8,1): error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'. -tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'. +tests/cases/compiler/assignmentCompat1.ts(8,1): error TS2322: Type '"foo"' is not assignable to type '{ [index: string]: any; }'. +tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'false' is not assignable to type '{ [index: number]: any; }'. ==== tests/cases/compiler/assignmentCompat1.ts (4 errors) ==== @@ -22,10 +22,10 @@ tests/cases/compiler/assignmentCompat1.ts(10,1): error TS2322: Type 'boolean' is z = x; // Ok because index signature type is any y = "foo"; // Error ~ -!!! error TS2322: Type 'string' is not assignable to type '{ [index: string]: any; }'. +!!! error TS2322: Type '"foo"' is not assignable to type '{ [index: string]: any; }'. z = "foo"; // OK, string has numeric indexer z = false; // Error ~ -!!! error TS2322: Type 'boolean' is not assignable to type '{ [index: number]: any; }'. +!!! error TS2322: Type 'false' is not assignable to type '{ [index: number]: any; }'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatBug2.errors.txt b/tests/baselines/reference/assignmentCompatBug2.errors.txt index 29ba96e6586..4acdc0d8663 100644 --- a/tests/baselines/reference/assignmentCompatBug2.errors.txt +++ b/tests/baselines/reference/assignmentCompatBug2.errors.txt @@ -4,12 +4,12 @@ tests/cases/compiler/assignmentCompatBug2.ts(3,8): error TS2322: Type '{ a: numb Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. tests/cases/compiler/assignmentCompatBug2.ts(5,13): error TS2322: Type '{ b: number; a: number; }' is not assignable to type '{ b: number; }'. Object literal may only specify known properties, and 'a' does not exist in type '{ b: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. - Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(20,1): error TS2322: Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. - Property 'g' is missing in type '{ f: (n: number) => number; m: number; }'. -tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. - Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'. +tests/cases/compiler/assignmentCompatBug2.ts(15,1): error TS2322: Type '{ f: (n: number) => 0; g: (s: string) => 0; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. + Property 'm' is missing in type '{ f: (n: number) => 0; g: (s: string) => 0; }'. +tests/cases/compiler/assignmentCompatBug2.ts(20,1): error TS2322: Type '{ f: (n: number) => 0; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. + Property 'g' is missing in type '{ f: (n: number) => 0; m: number; }'. +tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: number) => 0; g: (s: string) => 0; n: number; k: (a: any) => any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. + Property 'm' is missing in type '{ f: (n: number) => 0; g: (s: string) => 0; n: number; k: (a: any) => any; }'. ==== tests/cases/compiler/assignmentCompatBug2.ts (6 errors) ==== @@ -38,16 +38,16 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: b3 = { ~~ -!!! error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. -!!! error TS2322: Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; }'. +!!! error TS2322: Type '{ f: (n: number) => 0; g: (s: string) => 0; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. +!!! error TS2322: Property 'm' is missing in type '{ f: (n: number) => 0; g: (s: string) => 0; }'. f: (n) => { return 0; }, g: (s) => { return 0; }, }; // error b3 = { ~~ -!!! error TS2322: Type '{ f: (n: number) => number; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. -!!! error TS2322: Property 'g' is missing in type '{ f: (n: number) => number; m: number; }'. +!!! error TS2322: Type '{ f: (n: number) => 0; m: number; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. +!!! error TS2322: Property 'g' is missing in type '{ f: (n: number) => 0; m: number; }'. f: (n) => { return 0; }, m: 0, }; // error @@ -62,8 +62,8 @@ tests/cases/compiler/assignmentCompatBug2.ts(33,1): error TS2322: Type '{ f: (n: b3 = { ~~ -!!! error TS2322: Type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. -!!! error TS2322: Property 'm' is missing in type '{ f: (n: number) => number; g: (s: string) => number; n: number; k: (a: any) => any; }'. +!!! error TS2322: Type '{ f: (n: number) => 0; g: (s: string) => 0; n: number; k: (a: any) => any; }' is not assignable to type '{ f(n: number): number; g(s: string): number; m: number; n?: number; k?(a: any): any; }'. +!!! error TS2322: Property 'm' is missing in type '{ f: (n: number) => 0; g: (s: string) => 0; n: number; k: (a: any) => any; }'. f: (n) => { return 0; }, g: (s) => { return 0; }, n: 0, diff --git a/tests/baselines/reference/assignmentCompatForEnums.types b/tests/baselines/reference/assignmentCompatForEnums.types index e8b48bd02bd..dde41372e11 100644 --- a/tests/baselines/reference/assignmentCompatForEnums.types +++ b/tests/baselines/reference/assignmentCompatForEnums.types @@ -1,8 +1,8 @@ === tests/cases/compiler/assignmentCompatForEnums.ts === enum TokenType { One, Two }; >TokenType : TokenType ->One : TokenType ->Two : TokenType +>One : TokenType.One +>Two : TokenType.Two var list = {}; >list : {} @@ -27,7 +27,7 @@ function foo() { >TokenType : TokenType >list['one'] : any >list : {} ->'one' : string +>'one' : "one" } diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures.errors.txt index c5914e59386..6e1db59ea81 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures.errors.txt @@ -4,10 +4,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(36,1): error TS2322: Type '(x: string) => void' is not assignable to type 'T'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(37,1): error TS2322: Type '(x: string) => number' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(37,1): error TS2322: Type '(x: string) => 1' is not assignable to type 'T'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(38,1): error TS2322: Type '(x: string) => string' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(38,1): error TS2322: Type '(x: string) => ""' is not assignable to type 'T'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(39,1): error TS2322: Type 'S2' is not assignable to type '(x: number) => void'. @@ -16,10 +16,10 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(40,1): error TS2322: Type '(x: string) => void' is not assignable to type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(41,1): error TS2322: Type '(x: string) => number' is not assignable to type '(x: number) => void'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(41,1): error TS2322: Type '(x: string) => 1' is not assignable to type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(42,1): error TS2322: Type '(x: string) => string' is not assignable to type '(x: number) => void'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures.ts(42,1): error TS2322: Type '(x: string) => ""' is not assignable to type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. @@ -71,12 +71,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'number' is not assignable to type 'string'. t = (x: string) => 1; ~ -!!! error TS2322: Type '(x: string) => number' is not assignable to type 'T'. +!!! error TS2322: Type '(x: string) => 1' is not assignable to type 'T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. t = function (x: string) { return ''; } ~ -!!! error TS2322: Type '(x: string) => string' is not assignable to type 'T'. +!!! error TS2322: Type '(x: string) => ""' is not assignable to type 'T'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. a = s2; @@ -91,12 +91,12 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme !!! error TS2322: Type 'number' is not assignable to type 'string'. a = (x: string) => 1; ~ -!!! error TS2322: Type '(x: string) => number' is not assignable to type '(x: number) => void'. +!!! error TS2322: Type '(x: string) => 1' is not assignable to type '(x: number) => void'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. a = function (x: string) { return ''; } ~ -!!! error TS2322: Type '(x: string) => string' is not assignable to type '(x: number) => void'. +!!! error TS2322: Type '(x: string) => ""' is not assignable to type '(x: number) => void'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.errors.txt index f89bbfa5798..86e7fee9e3f 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithOptionalParameters.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(16,5): error TS2322: Type '(x: number) => number' is not assignable to type '() => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(16,5): error TS2322: Type '(x: number) => 1' is not assignable to type '() => number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(19,5): error TS2322: Type '(x: number) => number' is not assignable to type '() => number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(20,5): error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '() => number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(22,5): error TS2322: Type '(x: number, y: number) => number' is not assignable to type '() => number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(33,5): error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x?: number) => number'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(39,5): error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x: number) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(39,5): error TS2322: Type '(x: number, y: number) => 1' is not assignable to type '(x: number) => number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithOptionalParameters.ts(45,5): error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x: number) => number'. @@ -25,7 +25,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = (x?: number) => 1; // ok, same number of required params a = (x: number) => 1; // error, too many required params ~ -!!! error TS2322: Type '(x: number) => number' is not assignable to type '() => number'. +!!! error TS2322: Type '(x: number) => 1' is not assignable to type '() => number'. a = b.a; // ok a = b.a2; // ok a = b.a3; // error @@ -58,7 +58,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a3 = (x: number) => 1; // ok, same number of required params a3 = (x: number, y: number) => 1; // error, too many required params ~~ -!!! error TS2322: Type '(x: number, y: number) => number' is not assignable to type '(x: number) => number'. +!!! error TS2322: Type '(x: number, y: number) => 1' is not assignable to type '(x: number) => number'. a3 = b.a; // ok a3 = b.a2; // ok a3 = b.a3; // ok diff --git a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.errors.txt index 6b563ef2631..e56968a5482 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignaturesWithRestParameters.errors.txt @@ -1,28 +1,28 @@ -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(13,5): error TS2322: Type '(...args: string[]) => number' is not assignable to type '(...args: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(13,5): error TS2322: Type '(...args: string[]) => 1' is not assignable to type '(...args: number[]) => number'. Types of parameters 'args' and 'args' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(17,5): error TS2322: Type '(x?: string) => number' is not assignable to type '(...args: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(17,5): error TS2322: Type '(x?: string) => 1' is not assignable to type '(...args: number[]) => number'. Types of parameters 'x' and 'args' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(26,5): error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x: number, ...z: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(26,5): error TS2322: Type '(x: number, ...args: string[]) => 1' is not assignable to type '(x: number, ...z: number[]) => number'. Types of parameters 'args' and 'z' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(35,5): error TS2322: Type '(x: number, y?: number, z?: number) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(35,5): error TS2322: Type '(x: number, y?: number, z?: number) => 1' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. Types of parameters 'y' and 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(36,5): error TS2322: Type '(x: number, ...z: number[]) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(36,5): error TS2322: Type '(x: number, ...z: number[]) => 1' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. Types of parameters 'z' and 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(37,5): error TS2322: Type '(x: string, y?: string, z?: string) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(37,5): error TS2322: Type '(x: string, y?: string, z?: string) => 1' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(41,5): error TS2322: Type '(x?: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(41,5): error TS2322: Type '(x?: number, y?: number) => 1' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. Types of parameters 'y' and 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(43,5): error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(43,5): error TS2322: Type '(x: number, y?: number) => 1' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. Types of parameters 'y' and 'y' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(45,5): error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignaturesWithRestParameters.ts(45,5): error TS2322: Type '(x: number, ...args: string[]) => 1' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. Types of parameters 'args' and 'z' are incompatible. Type 'number' is not assignable to type 'string'. @@ -42,7 +42,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = (...args: number[]) => 1; // ok, same number of required params a = (...args: string[]) => 1; // error, type mismatch ~ -!!! error TS2322: Type '(...args: string[]) => number' is not assignable to type '(...args: number[]) => number'. +!!! error TS2322: Type '(...args: string[]) => 1' is not assignable to type '(...args: number[]) => number'. !!! error TS2322: Types of parameters 'args' and 'args' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. a = (x?: number) => 1; // ok, same number of required params @@ -50,7 +50,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a = (x: number) => 1; // ok, rest param corresponds to infinite number of params a = (x?: string) => 1; // error, incompatible type ~ -!!! error TS2322: Type '(x?: string) => number' is not assignable to type '(...args: number[]) => number'. +!!! error TS2322: Type '(x?: string) => 1' is not assignable to type '(...args: number[]) => number'. !!! error TS2322: Types of parameters 'x' and 'args' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -63,7 +63,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a2 = (x: number, ...args: number[]) => 1; // ok, same number of required params a2 = (x: number, ...args: string[]) => 1; // should be type mismatch error ~~ -!!! error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x: number, ...z: number[]) => number'. +!!! error TS2322: Type '(x: number, ...args: string[]) => 1' is not assignable to type '(x: number, ...z: number[]) => number'. !!! error TS2322: Types of parameters 'args' and 'z' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. a2 = (x: number, y: number) => 1; // ok, rest param corresponds to infinite number of params @@ -76,17 +76,17 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a3 = (x: number, y: string) => 1; // ok, all present params match a3 = (x: number, y?: number, z?: number) => 1; // error ~~ -!!! error TS2322: Type '(x: number, y?: number, z?: number) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. +!!! error TS2322: Type '(x: number, y?: number, z?: number) => 1' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. a3 = (x: number, ...z: number[]) => 1; // error ~~ -!!! error TS2322: Type '(x: number, ...z: number[]) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. +!!! error TS2322: Type '(x: number, ...z: number[]) => 1' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. !!! error TS2322: Types of parameters 'z' and 'y' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. a3 = (x: string, y?: string, z?: string) => 1; // error ~~ -!!! error TS2322: Type '(x: string, y?: string, z?: string) => number' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. +!!! error TS2322: Type '(x: string, y?: string, z?: string) => 1' is not assignable to type '(x: number, y?: string, ...z: number[]) => number'. !!! error TS2322: Types of parameters 'x' and 'x' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -94,18 +94,18 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme a4 = () => 1; // ok, fewer required params a4 = (x?: number, y?: number) => 1; // error, type mismatch ~~ -!!! error TS2322: Type '(x?: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. +!!! error TS2322: Type '(x?: number, y?: number) => 1' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. a4 = (x: number) => 1; // ok, all present params match a4 = (x: number, y?: number) => 1; // error, second param has type mismatch ~~ -!!! error TS2322: Type '(x: number, y?: number) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. +!!! error TS2322: Type '(x: number, y?: number) => 1' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. !!! error TS2322: Type 'string' is not assignable to type 'number'. a4 = (x?: number, y?: string) => 1; // ok, same number of required params with matching types a4 = (x: number, ...args: string[]) => 1; // error, rest params have type mismatch ~~ -!!! error TS2322: Type '(x: number, ...args: string[]) => number' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. +!!! error TS2322: Type '(x: number, ...args: string[]) => 1' is not assignable to type '(x?: number, y?: string, ...z: number[]) => number'. !!! error TS2322: Types of parameters 'args' and 'z' are incompatible. !!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers.types b/tests/baselines/reference/assignmentCompatWithObjectMembers.types index f56b0b1dc74..ced87c605c9 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers.types +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers.types @@ -49,13 +49,13 @@ module SimpleTypes { >a2 : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" var b2 = { foo: '' }; >b2 : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" s = t; >s = t : T diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers2.types b/tests/baselines/reference/assignmentCompatWithObjectMembers2.types index 560644f860e..76316afd3cc 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers2.types +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers2.types @@ -50,13 +50,13 @@ var a2 = { foo: '' }; >a2 : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" var b2 = { foo: '' }; >b2 : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" s = t; >s = t : T diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembers3.types b/tests/baselines/reference/assignmentCompatWithObjectMembers3.types index 3046c2f609d..88eadd4c36a 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembers3.types +++ b/tests/baselines/reference/assignmentCompatWithObjectMembers3.types @@ -53,14 +53,14 @@ var a2: S2 = { foo: '' }; >S2 : S2 >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" var b2: T2 = { foo: '' }; >b2 : T2 >T2 : T2 >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" s = t; >s = t : T diff --git a/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.types b/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.types index 440ef006e0a..0c44316d324 100644 --- a/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.types +++ b/tests/baselines/reference/assignmentCompatWithObjectMembersNumericNames.types @@ -43,12 +43,12 @@ var b: { 1.0: string; baz?: string } var a2 = { 1.0: '' }; >a2 : { 1.0: string; } >{ 1.0: '' } : { 1.0: string; } ->'' : string +>'' : "" var b2 = { 1: '' }; >b2 : { 1: string; } >{ 1: '' } : { 1: string; } ->'' : string +>'' : "" s = t; >s = t : T diff --git a/tests/baselines/reference/assignmentCompatability1.types b/tests/baselines/reference/assignmentCompatability1.types index 66174a4036e..6f47a6e5244 100644 --- a/tests/baselines/reference/assignmentCompatability1.types +++ b/tests/baselines/reference/assignmentCompatability1.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional diff --git a/tests/baselines/reference/assignmentCompatability10.types b/tests/baselines/reference/assignmentCompatability10.types index f4c2bba451d..9784acfdabc 100644 --- a/tests/baselines/reference/assignmentCompatability10.types +++ b/tests/baselines/reference/assignmentCompatability10.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional @@ -34,7 +34,7 @@ module __test2__ { >x4 : classWithPublicAndOptional >new classWithPublicAndOptional(1) : classWithPublicAndOptional >classWithPublicAndOptional : typeof classWithPublicAndOptional ->1 : number +>1 : 1 export var __val__x4 = x4; >__val__x4 : classWithPublicAndOptional diff --git a/tests/baselines/reference/assignmentCompatability2.types b/tests/baselines/reference/assignmentCompatability2.types index f46a81cf51f..58fb86b5c7f 100644 --- a/tests/baselines/reference/assignmentCompatability2.types +++ b/tests/baselines/reference/assignmentCompatability2.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional diff --git a/tests/baselines/reference/assignmentCompatability3.types b/tests/baselines/reference/assignmentCompatability3.types index 67e553235ed..4525500cfec 100644 --- a/tests/baselines/reference/assignmentCompatability3.types +++ b/tests/baselines/reference/assignmentCompatability3.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional @@ -27,7 +27,7 @@ module __test2__ { >obj : { one: number; } >{one: 1} : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj = obj; >__val__obj : { one: number; } diff --git a/tests/baselines/reference/assignmentCompatability36.types b/tests/baselines/reference/assignmentCompatability36.types index b67be38e2b4..59ccc04195f 100644 --- a/tests/baselines/reference/assignmentCompatability36.types +++ b/tests/baselines/reference/assignmentCompatability36.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional diff --git a/tests/baselines/reference/assignmentCompatability4.types b/tests/baselines/reference/assignmentCompatability4.types index 0cafbaa4dd7..bc5e805875c 100644 --- a/tests/baselines/reference/assignmentCompatability4.types +++ b/tests/baselines/reference/assignmentCompatability4.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional diff --git a/tests/baselines/reference/assignmentCompatability5.types b/tests/baselines/reference/assignmentCompatability5.types index 8f8dbb0f649..755ce16ec69 100644 --- a/tests/baselines/reference/assignmentCompatability5.types +++ b/tests/baselines/reference/assignmentCompatability5.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional @@ -32,7 +32,7 @@ module __test2__ { >interfaceOne : interfaceOne >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj1 = obj1; >__val__obj1 : interfaceOne diff --git a/tests/baselines/reference/assignmentCompatability6.types b/tests/baselines/reference/assignmentCompatability6.types index 1191ff8bc26..d437d5a7469 100644 --- a/tests/baselines/reference/assignmentCompatability6.types +++ b/tests/baselines/reference/assignmentCompatability6.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional diff --git a/tests/baselines/reference/assignmentCompatability7.types b/tests/baselines/reference/assignmentCompatability7.types index 77b67514473..3dad9966d83 100644 --- a/tests/baselines/reference/assignmentCompatability7.types +++ b/tests/baselines/reference/assignmentCompatability7.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional @@ -35,7 +35,7 @@ module __test2__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional diff --git a/tests/baselines/reference/assignmentCompatability8.types b/tests/baselines/reference/assignmentCompatability8.types index 554f9b3caed..d4cc5ebc33e 100644 --- a/tests/baselines/reference/assignmentCompatability8.types +++ b/tests/baselines/reference/assignmentCompatability8.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional @@ -31,7 +31,7 @@ module __test2__ { >x1 : classWithPublic >new classWithPublic(1) : classWithPublic >classWithPublic : typeof classWithPublic ->1 : number +>1 : 1 export var __val__x1 = x1; >__val__x1 : classWithPublic diff --git a/tests/baselines/reference/assignmentCompatability9.types b/tests/baselines/reference/assignmentCompatability9.types index d8fe3a764a4..671697f35f7 100644 --- a/tests/baselines/reference/assignmentCompatability9.types +++ b/tests/baselines/reference/assignmentCompatability9.types @@ -14,7 +14,7 @@ module __test1__ { >interfaceWithPublicAndOptional : interfaceWithPublicAndOptional >{ one: 1 } : { one: number; } >one : number ->1 : number +>1 : 1 export var __val__obj4 = obj4; >__val__obj4 : interfaceWithPublicAndOptional diff --git a/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.errors.txt b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.errors.txt index 33a2269f747..e9adcba03b7 100644 --- a/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.errors.txt +++ b/tests/baselines/reference/assignmentCompatability_checking-apply-member-off-of-function-interface.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Applicable'. +tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(10,1): error TS2322: Type '""' is not assignable to type 'Applicable'. tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Applicable'. Property 'apply' is missing in type 'string[]'. -tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Applicable'. +tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(12,1): error TS2322: Type '4' is not assignable to type 'Applicable'. tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Applicable'. Property 'apply' is missing in type '{}'. -tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Applicable'. +tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type '""' is not assignable to parameter of type 'Applicable'. tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(23,4): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'Applicable'. -tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(24,4): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Applicable'. +tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(24,4): error TS2345: Argument of type '4' is not assignable to parameter of type 'Applicable'. tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-function-interface.ts(25,4): error TS2345: Argument of type '{}' is not assignable to parameter of type 'Applicable'. Property 'apply' is missing in type '{}'. @@ -23,14 +23,14 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-functi // Should fail x = ''; ~ -!!! error TS2322: Type 'string' is not assignable to type 'Applicable'. +!!! error TS2322: Type '""' is not assignable to type 'Applicable'. x = ['']; ~ !!! error TS2322: Type 'string[]' is not assignable to type 'Applicable'. !!! error TS2322: Property 'apply' is missing in type 'string[]'. x = 4; ~ -!!! error TS2322: Type 'number' is not assignable to type 'Applicable'. +!!! error TS2322: Type '4' is not assignable to type 'Applicable'. x = {}; ~ !!! error TS2322: Type '{}' is not assignable to type 'Applicable'. @@ -45,13 +45,13 @@ tests/cases/compiler/assignmentCompatability_checking-apply-member-off-of-functi // Should Fail fn(''); ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Applicable'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'Applicable'. fn(['']); ~~~~ !!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'Applicable'. fn(4); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Applicable'. +!!! error TS2345: Argument of type '4' is not assignable to parameter of type 'Applicable'. fn({}); ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'Applicable'. diff --git a/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt index 1651e5082ee..17556302178 100644 --- a/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt +++ b/tests/baselines/reference/assignmentCompatability_checking-call-member-off-of-function-interface.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(10,1): error TS2322: Type 'string' is not assignable to type 'Callable'. +tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(10,1): error TS2322: Type '""' is not assignable to type 'Callable'. tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(11,1): error TS2322: Type 'string[]' is not assignable to type 'Callable'. Property 'call' is missing in type 'string[]'. -tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(12,1): error TS2322: Type 'number' is not assignable to type 'Callable'. +tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(12,1): error TS2322: Type '4' is not assignable to type 'Callable'. tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(13,1): error TS2322: Type '{}' is not assignable to type 'Callable'. Property 'call' is missing in type '{}'. -tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Callable'. +tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(22,4): error TS2345: Argument of type '""' is not assignable to parameter of type 'Callable'. tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(23,4): error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'Callable'. -tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(24,4): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Callable'. +tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(24,4): error TS2345: Argument of type '4' is not assignable to parameter of type 'Callable'. tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-function-interface.ts(25,4): error TS2345: Argument of type '{}' is not assignable to parameter of type 'Callable'. Property 'call' is missing in type '{}'. @@ -23,14 +23,14 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-functio // Should fail x = ''; ~ -!!! error TS2322: Type 'string' is not assignable to type 'Callable'. +!!! error TS2322: Type '""' is not assignable to type 'Callable'. x = ['']; ~ !!! error TS2322: Type 'string[]' is not assignable to type 'Callable'. !!! error TS2322: Property 'call' is missing in type 'string[]'. x = 4; ~ -!!! error TS2322: Type 'number' is not assignable to type 'Callable'. +!!! error TS2322: Type '4' is not assignable to type 'Callable'. x = {}; ~ !!! error TS2322: Type '{}' is not assignable to type 'Callable'. @@ -45,13 +45,13 @@ tests/cases/compiler/assignmentCompatability_checking-call-member-off-of-functio // Should Fail fn(''); ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Callable'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'Callable'. fn(['']); ~~~~ !!! error TS2345: Argument of type 'string[]' is not assignable to parameter of type 'Callable'. fn(4); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Callable'. +!!! error TS2345: Argument of type '4' is not assignable to parameter of type 'Callable'. fn({}); ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'Callable'. diff --git a/tests/baselines/reference/assignmentLHSIsReference.types b/tests/baselines/reference/assignmentLHSIsReference.types index 47204740165..dfb3b236c0a 100644 --- a/tests/baselines/reference/assignmentLHSIsReference.types +++ b/tests/baselines/reference/assignmentLHSIsReference.types @@ -37,7 +37,7 @@ x3['a'] = value; >x3['a'] = value : any >x3['a'] : string >x3 : { a: string; } ->'a' : string +>'a' : "a" >value : any // parentheses, the contained expression is reference @@ -71,6 +71,6 @@ function fn2(x4: number) { >(x3['a']) : string >x3['a'] : string >x3 : { a: string; } ->'a' : string +>'a' : "a" >value : any diff --git a/tests/baselines/reference/assignmentNonObjectTypeConstraints.types b/tests/baselines/reference/assignmentNonObjectTypeConstraints.types index e2c3176940d..2037d058aff 100644 --- a/tests/baselines/reference/assignmentNonObjectTypeConstraints.types +++ b/tests/baselines/reference/assignmentNonObjectTypeConstraints.types @@ -1,9 +1,9 @@ === tests/cases/compiler/assignmentNonObjectTypeConstraints.ts === const enum E { A, B, C } >E : E ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C function foo(x: T) { >foo : (x: T) => void diff --git a/tests/baselines/reference/assignmentStricterConstraints.types b/tests/baselines/reference/assignmentStricterConstraints.types index 3a72d92f51c..c1a7c86c744 100644 --- a/tests/baselines/reference/assignmentStricterConstraints.types +++ b/tests/baselines/reference/assignmentStricterConstraints.types @@ -34,6 +34,6 @@ g = f g(1, "") >g(1, "") : void >g : (x: T, y: S) => void ->1 : number ->"" : string +>1 : 1 +>"" : "" diff --git a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt index a50ffdf72d7..b929704880e 100644 --- a/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt +++ b/tests/baselines/reference/assignmentToParenthesizedIdentifiers.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(5,1): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(13,1): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(14,1): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(15,1): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(4,1): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(5,1): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(13,1): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(14,1): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(15,1): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(17,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(18,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(25,5): error TS2364: Invalid left-hand side of assignment expression. @@ -17,13 +17,13 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize Type 'string' is not assignable to type 'number'. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(37,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(38,1): error TS2364: Invalid left-hand side of assignment expression. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(43,5): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(44,5): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(48,5): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(49,5): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(54,5): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(55,5): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(56,5): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(43,5): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(44,5): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(48,5): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(49,5): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(54,5): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(55,5): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(56,5): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(62,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(63,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesizedIdentifiers.ts(69,1): error TS2364: Invalid left-hand side of assignment expression. @@ -36,10 +36,10 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize (x) = 3; // OK x = ''; // Error ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (x) = ''; // Error ~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. module M { export var y: number; @@ -49,13 +49,13 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize (M.y) = 3; // OK M.y = ''; // Error ~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (M).y = ''; // Error ~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (M.y) = ''; // Error ~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. M = { y: 3 }; // Error ~ @@ -107,32 +107,32 @@ tests/cases/conformance/expressions/valuesAndReferences/assignmentToParenthesize (x) = 3; // OK x = ''; // Error ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (x) = ''; // Error ~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (y).t = 3; // OK (y.t) = 3; // OK (y).t = ''; // Error ~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (y.t) = ''; // Error ~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. y['t'] = 3; // OK (y)['t'] = 3; // OK (y['t']) = 3; // OK y['t'] = ''; // Error ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (y)['t'] = ''; // Error ~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (y['t']) = ''; // Error ~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. } enum E { diff --git a/tests/baselines/reference/assignmentTypeNarrowing.types b/tests/baselines/reference/assignmentTypeNarrowing.types index f46b2a16c3b..8c5fea315ce 100644 --- a/tests/baselines/reference/assignmentTypeNarrowing.types +++ b/tests/baselines/reference/assignmentTypeNarrowing.types @@ -4,9 +4,9 @@ let x: string | number | boolean | RegExp; >RegExp : RegExp x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean | RegExp ->"" : string +>"" : "" x; // string >x : string @@ -24,11 +24,11 @@ x; // boolean [x = ""] = [1]; >[x = ""] = [1] : [number] >[x = ""] : [string] ->x = "" : string +>x = "" : "" >x : string | number | boolean | RegExp ->"" : string +>"" : "" >[1] : [number] ->1 : number +>1 : 1 x; // string | number >x : string | number @@ -39,21 +39,21 @@ x; // string | number >{x} : { x: string | number | boolean | RegExp; } >x : string | number | boolean | RegExp >{x: true} : { x: true; } ->x : true +>x : boolean >true : true x; // boolean >x : true ({y: x} = {y: 1}); ->({y: x} = {y: 1}) : { y: number; } ->{y: x} = {y: 1} : { y: number; } +>({y: x} = {y: 1}) : { y: 1; } +>{y: x} = {y: 1} : { y: 1; } >{y: x} : { y: string | number | boolean | RegExp; } >y : string | number | boolean | RegExp >x : string | number | boolean | RegExp ->{y: 1} : { y: number; } +>{y: 1} : { y: 1; } >y : number ->1 : number +>1 : 1 x; // number >x : number @@ -64,7 +64,7 @@ x; // number >{x = ""} : { x?: string | number | boolean | RegExp; } >x : string | number | boolean | RegExp >{x: true} : { x?: true; } ->x : true +>x : boolean >true : true x; // string | boolean @@ -80,7 +80,7 @@ x; // string | boolean >/a/ : RegExp >{y: 1} : { y?: number; } >y : number ->1 : number +>1 : 1 x; // number | RegExp >x : number | RegExp diff --git a/tests/baselines/reference/asyncFunctionReturnType.types b/tests/baselines/reference/asyncFunctionReturnType.types index f848f7e1546..db9f8e42d52 100644 --- a/tests/baselines/reference/asyncFunctionReturnType.types +++ b/tests/baselines/reference/asyncFunctionReturnType.types @@ -5,8 +5,8 @@ async function fAsync() { // Without explicit type annotation, this is just an array. return [1, true]; >[1, true] : (number | boolean)[] ->1 : number ->true : boolean +>1 : 1 +>true : true } async function fAsyncExplicit(): Promise<[number, boolean]> { @@ -16,7 +16,7 @@ async function fAsyncExplicit(): Promise<[number, boolean]> { // This is contextually typed as a tuple. return [1, true]; >[1, true] : [number, true] ->1 : number +>1 : 1 >true : true } diff --git a/tests/baselines/reference/asyncMethodWithSuper_es6.types b/tests/baselines/reference/asyncMethodWithSuper_es6.types index 04c5b5a9baf..030c9fe4e6a 100644 --- a/tests/baselines/reference/asyncMethodWithSuper_es6.types +++ b/tests/baselines/reference/asyncMethodWithSuper_es6.types @@ -27,7 +27,7 @@ class B extends A { >super["x"]() : void >super["x"] : () => void >super : A ->"x" : string +>"x" : "x" // property access (read) const a = super.x; @@ -41,7 +41,7 @@ class B extends A { >b : () => void >super["x"] : () => void >super : A ->"x" : string +>"x" : "x" } // async method with assignment/destructuring on 'super' requires a binding @@ -64,7 +64,7 @@ class B extends A { >super["x"]() : void >super["x"] : () => void >super : A ->"x" : string +>"x" : "x" // property access (read) const a = super.x; @@ -78,7 +78,7 @@ class B extends A { >b : () => void >super["x"] : () => void >super : A ->"x" : string +>"x" : "x" // property access (assign) super.x = f; @@ -93,7 +93,7 @@ class B extends A { >super["x"] = f : () => void >super["x"] : () => void >super : A ->"x" : string +>"x" : "x" >f : () => void // destructuring assign with property access @@ -116,7 +116,7 @@ class B extends A { >f : () => void >super["x"] : () => void >super : A ->"x" : string +>"x" : "x" >{ f } : { f: () => void; } >f : () => void } diff --git a/tests/baselines/reference/augmentExportEquals3.types b/tests/baselines/reference/augmentExportEquals3.types index 4df7bbc60fa..edcd1820f24 100644 --- a/tests/baselines/reference/augmentExportEquals3.types +++ b/tests/baselines/reference/augmentExportEquals3.types @@ -8,7 +8,7 @@ namespace foo { export var v = 1; >v : number ->1 : number +>1 : 1 } export = foo; >foo : typeof foo @@ -18,11 +18,11 @@ import x = require("./file1"); >x : typeof x x.b = 1; ->x.b = 1 : number +>x.b = 1 : 1 >x.b : number >x : typeof x >b : number ->1 : number +>1 : 1 // OK - './file1' is a namespace declare module "./file1" { diff --git a/tests/baselines/reference/augmentExportEquals3_1.types b/tests/baselines/reference/augmentExportEquals3_1.types index 8a70a6ec0a6..62d08bd2597 100644 --- a/tests/baselines/reference/augmentExportEquals3_1.types +++ b/tests/baselines/reference/augmentExportEquals3_1.types @@ -20,11 +20,11 @@ import x = require("file1"); >x : typeof x x.b = 1; ->x.b = 1 : number +>x.b = 1 : 1 >x.b : number >x : typeof x >b : number ->1 : number +>1 : 1 // OK - './file1' is a namespace declare module "file1" { diff --git a/tests/baselines/reference/augmentExportEquals4.types b/tests/baselines/reference/augmentExportEquals4.types index 3d25ae2decb..e16e3dd19a1 100644 --- a/tests/baselines/reference/augmentExportEquals4.types +++ b/tests/baselines/reference/augmentExportEquals4.types @@ -8,7 +8,7 @@ namespace foo { export var v = 1; >v : number ->1 : number +>1 : 1 } export = foo; >foo : foo @@ -18,11 +18,11 @@ import x = require("./file1"); >x : typeof x x.b = 1; ->x.b = 1 : number +>x.b = 1 : 1 >x.b : number >x : typeof x >b : number ->1 : number +>1 : 1 // OK - './file1' is a namespace declare module "./file1" { diff --git a/tests/baselines/reference/augmentExportEquals4_1.types b/tests/baselines/reference/augmentExportEquals4_1.types index 9f219286000..d6f88c3be8d 100644 --- a/tests/baselines/reference/augmentExportEquals4_1.types +++ b/tests/baselines/reference/augmentExportEquals4_1.types @@ -21,11 +21,11 @@ import x = require("file1"); >x : typeof x x.b = 1; ->x.b = 1 : number +>x.b = 1 : 1 >x.b : number >x : typeof x >b : number ->1 : number +>1 : 1 // OK - './file1' is a namespace declare module "file1" { diff --git a/tests/baselines/reference/augmentExportEquals6.types b/tests/baselines/reference/augmentExportEquals6.types index 1a2b2b22ccb..31a1ea4d86c 100644 --- a/tests/baselines/reference/augmentExportEquals6.types +++ b/tests/baselines/reference/augmentExportEquals6.types @@ -21,13 +21,13 @@ import x = require("./file1"); >x : typeof x x.B.b = 1; ->x.B.b = 1 : number +>x.B.b = 1 : 1 >x.B.b : number >x.B : typeof x.B >x : typeof x >B : typeof x.B >b : number ->1 : number +>1 : 1 // OK - './file1' is a namespace declare module "./file1" { diff --git a/tests/baselines/reference/augmentedTypeBracketAccessIndexSignature.types b/tests/baselines/reference/augmentedTypeBracketAccessIndexSignature.types index 898da985aad..a0951c324f2 100644 --- a/tests/baselines/reference/augmentedTypeBracketAccessIndexSignature.types +++ b/tests/baselines/reference/augmentedTypeBracketAccessIndexSignature.types @@ -27,12 +27,12 @@ var a = {}[0]; // Should be Foo >a : any >{}[0] : any >{} : {} ->0 : number +>0 : 0 var b = (() => { })[0]; // Should be Bar >b : any >(() => { })[0] : any >(() => { }) : () => void >() => { } : () => void ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/augmentedTypeBracketNamedPropertyAccess.types b/tests/baselines/reference/augmentedTypeBracketNamedPropertyAccess.types index c47c98ebc9c..d8388fc81a8 100644 --- a/tests/baselines/reference/augmentedTypeBracketNamedPropertyAccess.types +++ b/tests/baselines/reference/augmentedTypeBracketNamedPropertyAccess.types @@ -23,23 +23,23 @@ var r1 = o['data']; // Should be number >r1 : number >o['data'] : number >o : {} ->'data' : string +>'data' : "data" var r2 = o['functionData']; // Should be any (no property found) >r2 : any >o['functionData'] : any >o : {} ->'functionData' : string +>'functionData' : "functionData" var r3 = f['functionData']; // Should be string >r3 : string >f['functionData'] : string >f : () => void ->'functionData' : string +>'functionData' : "functionData" var r4 = f['data']; // Should be number >r4 : number >f['data'] : number >f : () => void ->'data' : string +>'data' : "data" diff --git a/tests/baselines/reference/augmentedTypesClass3.types b/tests/baselines/reference/augmentedTypesClass3.types index bed118b5978..64e403d2661 100644 --- a/tests/baselines/reference/augmentedTypesClass3.types +++ b/tests/baselines/reference/augmentedTypesClass3.types @@ -14,7 +14,7 @@ class c5a { public foo() { } } module c5a { var y = 2; } // should be ok >c5a : typeof c5a >y : number ->2 : number +>2 : 2 class c5b { public foo() { } } >c5b : c5b @@ -23,7 +23,7 @@ class c5b { public foo() { } } module c5b { export var y = 2; } // should be ok >c5b : typeof c5b >y : number ->2 : number +>2 : 2 //// class then import class c5c { public foo() { } } diff --git a/tests/baselines/reference/augmentedTypesExternalModule1.types b/tests/baselines/reference/augmentedTypesExternalModule1.types index e652ecb08e1..2d3f8394d82 100644 --- a/tests/baselines/reference/augmentedTypesExternalModule1.types +++ b/tests/baselines/reference/augmentedTypesExternalModule1.types @@ -1,7 +1,7 @@ === tests/cases/compiler/augmentedTypesExternalModule1.ts === export var a = 1; >a : number ->1 : number +>1 : 1 class c5 { public foo() { } } >c5 : c5 diff --git a/tests/baselines/reference/augmentedTypesModules3b.types b/tests/baselines/reference/augmentedTypesModules3b.types index 38134c7c1c2..0d1ebe2bb42 100644 --- a/tests/baselines/reference/augmentedTypesModules3b.types +++ b/tests/baselines/reference/augmentedTypesModules3b.types @@ -6,7 +6,7 @@ class m3b { foo() { } } module m3b { var y = 2; } >m3b : typeof m3b >y : number ->2 : number +>2 : 2 class m3c { foo() { } } >m3c : m3c @@ -15,7 +15,7 @@ class m3c { foo() { } } module m3c { export var y = 2; } >m3c : typeof m3c >y : number ->2 : number +>2 : 2 declare class m3d { foo(): void } >m3d : m3d @@ -24,12 +24,12 @@ declare class m3d { foo(): void } module m3d { export var y = 2; } >m3d : typeof m3d >y : number ->2 : number +>2 : 2 module m3e { export var y = 2; } >m3e : typeof m3e >y : number ->2 : number +>2 : 2 declare class m3e { foo(): void } >m3e : m3e diff --git a/tests/baselines/reference/augmentedTypesModules4.types b/tests/baselines/reference/augmentedTypesModules4.types index 15d7c28e1d6..7e47abc41e8 100644 --- a/tests/baselines/reference/augmentedTypesModules4.types +++ b/tests/baselines/reference/augmentedTypesModules4.types @@ -10,7 +10,7 @@ enum m4 { } module m4a { var y = 2; } >m4a : typeof m4a >y : number ->2 : number +>2 : 2 enum m4a { One } >m4a : m4a @@ -19,7 +19,7 @@ enum m4a { One } module m4b { export var y = 2; } >m4b : typeof m4b >y : number ->2 : number +>2 : 2 enum m4b { One } >m4b : m4b @@ -48,7 +48,7 @@ enum m4d { One } module m5 { export var y = 2; } >m5 : typeof m5 >y : number ->2 : number +>2 : 2 module m5 { export interface I { foo(): void } } // should already be reasonably well covered >m5 : typeof m5 diff --git a/tests/baselines/reference/autonumberingInEnums.types b/tests/baselines/reference/autonumberingInEnums.types index 35d5a1505a5..8e3606dd8b3 100644 --- a/tests/baselines/reference/autonumberingInEnums.types +++ b/tests/baselines/reference/autonumberingInEnums.types @@ -3,13 +3,13 @@ enum Foo { >Foo : Foo a = 1 ->a : Foo ->1 : number +>a : Foo.a +>1 : 1 } enum Foo { >Foo : Foo b // should work fine ->b : Foo +>b : Foo.b } diff --git a/tests/baselines/reference/avoid.types b/tests/baselines/reference/avoid.types index 25fe27a2ea0..a4ecdb6f2c6 100644 --- a/tests/baselines/reference/avoid.types +++ b/tests/baselines/reference/avoid.types @@ -4,7 +4,7 @@ function f() { var x=1; >x : number ->1 : number +>1 : 1 } var y=f(); // error void fn diff --git a/tests/baselines/reference/awaitBinaryExpression1_es6.types b/tests/baselines/reference/awaitBinaryExpression1_es6.types index 4718f5f8fe9..7dd9a1a4315 100644 --- a/tests/baselines/reference/awaitBinaryExpression1_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression1_es6.types @@ -11,7 +11,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = await p || a; >b : boolean @@ -21,5 +21,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitBinaryExpression2_es6.types b/tests/baselines/reference/awaitBinaryExpression2_es6.types index 6154377a6f1..d9f3aed7a66 100644 --- a/tests/baselines/reference/awaitBinaryExpression2_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression2_es6.types @@ -11,7 +11,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = await p && a; >b : boolean @@ -21,5 +21,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitBinaryExpression3_es6.types b/tests/baselines/reference/awaitBinaryExpression3_es6.types index 2d5b087d6e3..6b8da1c7c58 100644 --- a/tests/baselines/reference/awaitBinaryExpression3_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression3_es6.types @@ -11,7 +11,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = await p + a; >b : number @@ -21,5 +21,5 @@ async function func(): Promise { >a : number "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitBinaryExpression4_es6.types b/tests/baselines/reference/awaitBinaryExpression4_es6.types index 80135203a82..3106a52b901 100644 --- a/tests/baselines/reference/awaitBinaryExpression4_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression4_es6.types @@ -11,7 +11,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = await p, a; >b : boolean @@ -20,5 +20,5 @@ async function func(): Promise { >a : any "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitBinaryExpression5_es6.types b/tests/baselines/reference/awaitBinaryExpression5_es6.types index 8b76b6f8b88..7d659589950 100644 --- a/tests/baselines/reference/awaitBinaryExpression5_es6.types +++ b/tests/baselines/reference/awaitBinaryExpression5_es6.types @@ -11,7 +11,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var o: { a: boolean; }; >o : { a: boolean; } @@ -26,5 +26,5 @@ async function func(): Promise { >p : Promise "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitCallExpression1_es6.types b/tests/baselines/reference/awaitCallExpression1_es6.types index 334175b7edb..12734d538e0 100644 --- a/tests/baselines/reference/awaitCallExpression1_es6.types +++ b/tests/baselines/reference/awaitCallExpression1_es6.types @@ -39,7 +39,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = fn(a, a, a); >b : void @@ -50,5 +50,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitCallExpression2_es6.types b/tests/baselines/reference/awaitCallExpression2_es6.types index 1617f4a14ff..4791e4e072f 100644 --- a/tests/baselines/reference/awaitCallExpression2_es6.types +++ b/tests/baselines/reference/awaitCallExpression2_es6.types @@ -39,7 +39,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = fn(await p, a, a); >b : void @@ -51,5 +51,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitCallExpression3_es6.types b/tests/baselines/reference/awaitCallExpression3_es6.types index 6304a803f64..defd54e5601 100644 --- a/tests/baselines/reference/awaitCallExpression3_es6.types +++ b/tests/baselines/reference/awaitCallExpression3_es6.types @@ -39,7 +39,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = fn(a, await p, a); >b : void @@ -51,5 +51,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitCallExpression4_es6.types b/tests/baselines/reference/awaitCallExpression4_es6.types index ff5d8f4012b..e0e45fc1ca3 100644 --- a/tests/baselines/reference/awaitCallExpression4_es6.types +++ b/tests/baselines/reference/awaitCallExpression4_es6.types @@ -39,7 +39,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = (await pfn)(a, a, a); >b : void @@ -52,5 +52,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitCallExpression5_es6.types b/tests/baselines/reference/awaitCallExpression5_es6.types index 5074c007743..5d7a85e9845 100644 --- a/tests/baselines/reference/awaitCallExpression5_es6.types +++ b/tests/baselines/reference/awaitCallExpression5_es6.types @@ -39,7 +39,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = o.fn(a, a, a); >b : void @@ -52,5 +52,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitCallExpression6_es6.types b/tests/baselines/reference/awaitCallExpression6_es6.types index 3266733fab0..f7901103c57 100644 --- a/tests/baselines/reference/awaitCallExpression6_es6.types +++ b/tests/baselines/reference/awaitCallExpression6_es6.types @@ -39,7 +39,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = o.fn(await p, a, a); >b : void @@ -53,5 +53,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitCallExpression7_es6.types b/tests/baselines/reference/awaitCallExpression7_es6.types index b1b382f7325..1c321bcb363 100644 --- a/tests/baselines/reference/awaitCallExpression7_es6.types +++ b/tests/baselines/reference/awaitCallExpression7_es6.types @@ -39,7 +39,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = o.fn(a, await p, a); >b : void @@ -53,5 +53,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/awaitCallExpression8_es6.types b/tests/baselines/reference/awaitCallExpression8_es6.types index 76719c09c85..8cc95c375be 100644 --- a/tests/baselines/reference/awaitCallExpression8_es6.types +++ b/tests/baselines/reference/awaitCallExpression8_es6.types @@ -39,7 +39,7 @@ async function func(): Promise { >Promise : Promise "before"; ->"before" : string +>"before" : "before" var b = (await po).fn(a, a, a); >b : void @@ -54,5 +54,5 @@ async function func(): Promise { >a : boolean "after"; ->"after" : string +>"after" : "after" } diff --git a/tests/baselines/reference/await_unaryExpression_es6.types b/tests/baselines/reference/await_unaryExpression_es6.types index 2a4b7354d3e..14b4fbf89ac 100644 --- a/tests/baselines/reference/await_unaryExpression_es6.types +++ b/tests/baselines/reference/await_unaryExpression_es6.types @@ -5,8 +5,8 @@ async function bar() { !await 42; // OK >!await 42 : boolean ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar1() { @@ -14,8 +14,8 @@ async function bar1() { +await 42; // OK >+await 42 : number ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar3() { @@ -23,8 +23,8 @@ async function bar3() { -await 42; // OK >-await 42 : number ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar4() { @@ -32,6 +32,6 @@ async function bar4() { ~await 42; // OK >~await 42 : number ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } diff --git a/tests/baselines/reference/await_unaryExpression_es6_1.types b/tests/baselines/reference/await_unaryExpression_es6_1.types index a5c3740b677..15544420189 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_1.types +++ b/tests/baselines/reference/await_unaryExpression_es6_1.types @@ -5,8 +5,8 @@ async function bar() { !await 42; // OK >!await 42 : boolean ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar1() { @@ -14,8 +14,8 @@ async function bar1() { delete await 42; // OK >delete await 42 : boolean ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar2() { @@ -23,8 +23,8 @@ async function bar2() { delete await 42; // OK >delete await 42 : boolean ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar3() { @@ -32,8 +32,8 @@ async function bar3() { void await 42; >void await 42 : undefined ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar4() { @@ -41,6 +41,6 @@ async function bar4() { +await 42; >+await 42 : number ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } diff --git a/tests/baselines/reference/await_unaryExpression_es6_2.types b/tests/baselines/reference/await_unaryExpression_es6_2.types index b438f063add..6142eec825b 100644 --- a/tests/baselines/reference/await_unaryExpression_es6_2.types +++ b/tests/baselines/reference/await_unaryExpression_es6_2.types @@ -5,8 +5,8 @@ async function bar1() { delete await 42; >delete await 42 : boolean ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar2() { @@ -14,8 +14,8 @@ async function bar2() { delete await 42; >delete await 42 : boolean ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } async function bar3() { @@ -23,6 +23,6 @@ async function bar3() { void await 42; >void await 42 : undefined ->await 42 : number ->42 : number +>await 42 : 42 +>42 : 42 } diff --git a/tests/baselines/reference/baseCheck.errors.txt b/tests/baselines/reference/baseCheck.errors.txt index c31ba95476a..1f267f55301 100644 --- a/tests/baselines/reference/baseCheck.errors.txt +++ b/tests/baselines/reference/baseCheck.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/baseCheck.ts(9,18): error TS2304: Cannot find name 'loc'. tests/cases/compiler/baseCheck.ts(17,53): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/baseCheck.ts(17,59): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/baseCheck.ts(18,62): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. -tests/cases/compiler/baseCheck.ts(19,59): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/compiler/baseCheck.ts(19,59): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. tests/cases/compiler/baseCheck.ts(19,68): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/baseCheck.ts(22,9): error TS2304: Cannot find name 'x'. tests/cases/compiler/baseCheck.ts(23,7): error TS2304: Cannot find name 'x'. @@ -38,7 +38,7 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'. !!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. class F extends C { constructor(public z: number) { super("hello", this.z) } } // first param type ~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'. ~~~~ !!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. diff --git a/tests/baselines/reference/baseIndexSignatureResolution.types b/tests/baselines/reference/baseIndexSignatureResolution.types index 90d143155fb..17fb5cf85de 100644 --- a/tests/baselines/reference/baseIndexSignatureResolution.types +++ b/tests/baselines/reference/baseIndexSignatureResolution.types @@ -37,7 +37,7 @@ var y: Derived = x[0]; >Derived : Derived >x[0] : Derived >x : FooOf ->0 : number +>0 : 0 /* // Note - the equivalent for normal interface methods works fine: diff --git a/tests/baselines/reference/bestChoiceType.types b/tests/baselines/reference/bestChoiceType.types index f88cf64e5a2..b1b4d419756 100644 --- a/tests/baselines/reference/bestChoiceType.types +++ b/tests/baselines/reference/bestChoiceType.types @@ -9,7 +9,7 @@ >''.match(/ /) || [] : RegExpMatchArray >''.match(/ /) : RegExpMatchArray | null >''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } ->'' : string +>'' : "" >match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } >/ / : RegExp >[] : never[] @@ -30,7 +30,7 @@ function f1() { >x : RegExpMatchArray | null >''.match(/ /) : RegExpMatchArray | null >''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } ->'' : string +>'' : "" >match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } >/ / : RegExp @@ -61,7 +61,7 @@ function f2() { >x : RegExpMatchArray | null >''.match(/ /) : RegExpMatchArray | null >''.match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } ->'' : string +>'' : "" >match : { (regexp: string): RegExpMatchArray | null; (regexp: RegExp): RegExpMatchArray | null; } >/ / : RegExp diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types index 2a5ee6a2fe2..f3ea48e637b 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions.types @@ -40,36 +40,36 @@ var derived2: Derived2; var r = true ? 1 : 2; >r : number ->true ? 1 : 2 : number ->true : boolean ->1 : number ->2 : number +>true ? 1 : 2 : 1 | 2 +>true : true +>1 : 1 +>2 : 2 var r3 = true ? 1 : {}; >r3 : {} >true ? 1 : {} : {} ->true : boolean ->1 : number +>true : true +>1 : 1 >{} : {} var r4 = true ? a : b; // typeof a >r4 : { x: number; y?: number; } | { x: number; z?: number; } >true ? a : b : { x: number; y?: number; } | { x: number; z?: number; } ->true : boolean +>true : true >a : { x: number; y?: number; } >b : { x: number; z?: number; } var r5 = true ? b : a; // typeof b >r5 : { x: number; y?: number; } | { x: number; z?: number; } >true ? b : a : { x: number; y?: number; } | { x: number; z?: number; } ->true : boolean +>true : true >b : { x: number; z?: number; } >a : { x: number; y?: number; } var r6 = true ? (x: number) => { } : (x: Object) => { }; // returns number => void >r6 : (x: number) => void >true ? (x: number) => { } : (x: Object) => { } : (x: number) => void ->true : boolean +>true : true >(x: number) => { } : (x: number) => void >x : number >(x: Object) => { } : (x: Object) => void @@ -81,7 +81,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; >x : Object >Object : Object >true ? (x: number) => { } : (x: Object) => { } : (x: number) => void ->true : boolean +>true : true >(x: number) => { } : (x: number) => void >x : number >(x: Object) => { } : (x: Object) => void @@ -91,7 +91,7 @@ var r7: (x: Object) => void = true ? (x: number) => { } : (x: Object) => { }; var r8 = true ? (x: Object) => { } : (x: number) => { }; // returns Object => void >r8 : (x: Object) => void >true ? (x: Object) => { } : (x: number) => { } : (x: Object) => void ->true : boolean +>true : true >(x: Object) => { } : (x: Object) => void >x : Object >Object : Object @@ -102,14 +102,14 @@ var r10: Base = true ? derived : derived2; // no error since we use the contextu >r10 : Base >Base : Base >true ? derived : derived2 : Derived | Derived2 ->true : boolean +>true : true >derived : Derived >derived2 : Derived2 var r11 = true ? base : derived2; >r11 : Base >true ? base : derived2 : Base ->true : boolean +>true : true >base : Base >derived2 : Derived2 @@ -125,7 +125,7 @@ function foo5(t: T, u: U): Object { return true ? t : u; // BCT is Object >true ? t : u : T | U ->true : boolean +>true : true >t : T >u : U } diff --git a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.types b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.types index 833bddd0e7c..ad09c274c9b 100644 --- a/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.types +++ b/tests/baselines/reference/bestCommonTypeOfConditionalExpressions2.types @@ -30,15 +30,15 @@ var derived2: Derived2; var r2 = true ? 1 : ''; >r2 : string | number ->true ? 1 : '' : string | number ->true : boolean ->1 : number ->'' : string +>true ? 1 : '' : "" | 1 +>true : true +>1 : 1 +>'' : "" var r9 = true ? derived : derived2; >r9 : Derived | Derived2 >true ? derived : derived2 : Derived | Derived2 ->true : boolean +>true : true >derived : Derived >derived2 : Derived2 @@ -53,7 +53,7 @@ function foo(t: T, u: U) { return true ? t : u; >true ? t : u : T | U ->true : boolean +>true : true >t : T >u : U } @@ -70,7 +70,7 @@ function foo2(t: T, u: U) { // Error for referencing own type pa return true ? t : u; // Ok because BCT(T, U) = U >true ? t : u : U ->true : boolean +>true : true >t : T >u : U } @@ -89,7 +89,7 @@ function foo3(t: T, u: U) { return true ? t : u; >true ? t : u : U ->true : boolean +>true : true >t : T >u : U } diff --git a/tests/baselines/reference/bestCommonTypeOfTuple.types b/tests/baselines/reference/bestCommonTypeOfTuple.types index 02c504b6ec3..82c96ecb86c 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple.types @@ -2,12 +2,12 @@ function f1(x: number): string { return "foo"; } >f1 : (x: number) => string >x : number ->"foo" : string +>"foo" : "foo" function f2(x: number): number { return 10; } >f2 : (x: number) => number >x : number ->10 : number +>10 : 10 function f3(x: number): boolean { return true; } >f3 : (x: number) => boolean @@ -64,7 +64,7 @@ t3 = [5, undefined]; >t3 = [5, undefined] : [number, undefined] >t3 : [number, any] >[5, undefined] : [number, undefined] ->5 : number +>5 : 5 >undefined : undefined t4 = [E1.one, E2.two, 20]; @@ -77,29 +77,29 @@ t4 = [E1.one, E2.two, 20]; >E2.two : E2 >E2 : typeof E2 >two : E2 ->20 : number +>20 : 20 var e1 = t1[2]; // {} >e1 : ((x: number) => string) | ((x: number) => number) >t1[2] : ((x: number) => string) | ((x: number) => number) >t1 : [(x: number) => string, (x: number) => number] ->2 : number +>2 : 2 var e2 = t2[2]; // {} >e2 : E1 | E2 >t2[2] : E1 | E2 >t2 : [E1, E2] ->2 : number +>2 : 2 var e3 = t3[2]; // any >e3 : any >t3[2] : any >t3 : [number, any] ->2 : number +>2 : 2 var e4 = t4[3]; // number >e4 : number | E1 | E2 >t4[3] : number | E1 | E2 >t4 : [E1, E2, number] ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/bestCommonTypeOfTuple2.types b/tests/baselines/reference/bestCommonTypeOfTuple2.types index 864d3030d88..b64da59d5b0 100644 --- a/tests/baselines/reference/bestCommonTypeOfTuple2.types +++ b/tests/baselines/reference/bestCommonTypeOfTuple2.types @@ -30,14 +30,14 @@ class C1 implements base1 { i = "foo"; c } >C1 : C1 >base1 : base1 >i : string ->"foo" : string +>"foo" : "foo" >c : any class D1 extends C1 { i = "bar"; d } >D1 : D1 >C1 : C1 >i : string ->"bar" : string +>"bar" : "bar" >d : any var t1: [C, base]; @@ -69,29 +69,29 @@ var e11 = t1[4]; // base >e11 : base | C >t1[4] : base | C >t1 : [C, base] ->4 : number +>4 : 4 var e21 = t2[4]; // {} >e21 : C | D >t2[4] : C | D >t2 : [C, D] ->4 : number +>4 : 4 var e31 = t3[4]; // C1 >e31 : C1 | D1 >t3[4] : C1 | D1 >t3 : [C1, D1] ->4 : number +>4 : 4 var e41 = t4[2]; // base1 >e41 : base1 | C1 >t4[2] : base1 | C1 >t4 : [base1, C1] ->2 : number +>2 : 2 var e51 = t5[2]; // {} >e51 : F | C1 >t5[2] : F | C1 >t5 : [C1, F] ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/bestCommonTypeReturnStatement.types b/tests/baselines/reference/bestCommonTypeReturnStatement.types index a8b435c8a27..b327e707350 100644 --- a/tests/baselines/reference/bestCommonTypeReturnStatement.types +++ b/tests/baselines/reference/bestCommonTypeReturnStatement.types @@ -18,7 +18,7 @@ function f() { >f : () => IPromise if (true) return b(); ->true : boolean +>true : true >b() : IPromise >b : () => IPromise diff --git a/tests/baselines/reference/binaryArithmatic1.types b/tests/baselines/reference/binaryArithmatic1.types index 43f4f26de60..3d24fe4b44e 100644 --- a/tests/baselines/reference/binaryArithmatic1.types +++ b/tests/baselines/reference/binaryArithmatic1.types @@ -2,6 +2,6 @@ var v = 4 | null; >v : number >4 | null : number ->4 : number +>4 : 4 >null : null diff --git a/tests/baselines/reference/binaryArithmatic2.types b/tests/baselines/reference/binaryArithmatic2.types index 77cbce5b1e3..1ce8776384c 100644 --- a/tests/baselines/reference/binaryArithmatic2.types +++ b/tests/baselines/reference/binaryArithmatic2.types @@ -2,6 +2,6 @@ var v = 4 | undefined; >v : number >4 | undefined : number ->4 : number +>4 : 4 >undefined : undefined diff --git a/tests/baselines/reference/binaryIntegerLiteral.types b/tests/baselines/reference/binaryIntegerLiteral.types index 4ff3c3c28a3..5cee371fdbe 100644 --- a/tests/baselines/reference/binaryIntegerLiteral.types +++ b/tests/baselines/reference/binaryIntegerLiteral.types @@ -1,26 +1,26 @@ === tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteral.ts === var bin1 = 0b11010; >bin1 : number ->0b11010 : number +>0b11010 : 26 var bin2 = 0B11010; >bin2 : number ->0B11010 : number +>0B11010 : 26 var bin3 = 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin3 : number ->0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111 : number +>0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111 : 9.671406556917009e+24 var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin4 : number ->0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : number +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Infinity var obj1 = { >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } >{ 0b11010: "Hello", a: bin1, bin1, b: 0b11010, 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true,} : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } 0b11010: "Hello", ->"Hello" : string +>"Hello" : "Hello" a: bin1, >a : number @@ -31,10 +31,10 @@ var obj1 = { b: 0b11010, >b : number ->0b11010 : number +>0b11010 : 26 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true, ->true : boolean +>true : true } var obj2 = { @@ -42,7 +42,7 @@ var obj2 = { >{ 0B11010: "World", a: bin2, bin2, b: 0B11010, 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false,} : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } 0B11010: "World", ->"World" : string +>"World" : "World" a: bin2, >a : number @@ -53,100 +53,100 @@ var obj2 = { b: 0B11010, >b : number ->0B11010 : number +>0B11010 : 26 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false, ->false : boolean +>false : false } obj1[0b11010]; // string >obj1[0b11010] : string >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->0b11010 : number +>0b11010 : 26 obj1[26]; // string >obj1[26] : string >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->26 : number +>26 : 26 obj1["26"]; // string >obj1["26"] : string >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"26" : string +>"26" : "26" obj1["0b11010"]; // any >obj1["0b11010"] : any >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"0b11010" : string +>"0b11010" : "0b11010" obj1["a"]; // number >obj1["a"] : number >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"a" : string +>"a" : "a" obj1["b"]; // number >obj1["b"] : number >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"b" : string +>"b" : "b" obj1["bin1"]; // number >obj1["bin1"] : number >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"bin1" : string +>"bin1" : "bin1" obj1["Infinity"]; // boolean >obj1["Infinity"] : boolean >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"Infinity" : string +>"Infinity" : "Infinity" obj2[0B11010]; // string >obj2[0B11010] : string >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->0B11010 : number +>0B11010 : 26 obj2[26]; // string >obj2[26] : string >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->26 : number +>26 : 26 obj2["26"]; // string >obj2["26"] : string >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"26" : string +>"26" : "26" obj2["0B11010"]; // any >obj2["0B11010"] : any >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"0B11010" : string +>"0B11010" : "0B11010" obj2["a"]; // number >obj2["a"] : number >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"a" : string +>"a" : "a" obj2["b"]; // number >obj2["b"] : number >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"b" : string +>"b" : "b" obj2["bin2"]; // number >obj2["bin2"] : number >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"bin2" : string +>"bin2" : "bin2" obj2[9.671406556917009e+24]; // boolean >obj2[9.671406556917009e+24] : boolean >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->9.671406556917009e+24 : number +>9.671406556917009e+24 : 9.671406556917009e+24 obj2["9.671406556917009e+24"]; // boolean >obj2["9.671406556917009e+24"] : boolean >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"9.671406556917009e+24" : string +>"9.671406556917009e+24" : "9.671406556917009e+24" obj2["Infinity"]; // any >obj2["Infinity"] : any >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"Infinity" : string +>"Infinity" : "Infinity" diff --git a/tests/baselines/reference/binaryIntegerLiteralES6.types b/tests/baselines/reference/binaryIntegerLiteralES6.types index 47bfe6f548d..ab28010283b 100644 --- a/tests/baselines/reference/binaryIntegerLiteralES6.types +++ b/tests/baselines/reference/binaryIntegerLiteralES6.types @@ -1,26 +1,26 @@ === tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/binaryIntegerLiteralES6.ts === var bin1 = 0b11010; >bin1 : number ->0b11010 : number +>0b11010 : 26 var bin2 = 0B11010; >bin2 : number ->0B11010 : number +>0B11010 : 26 var bin3 = 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin3 : number ->0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111 : number +>0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111 : 9.671406556917009e+24 var bin4 = 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111; >bin4 : number ->0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : number +>0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111 : Infinity var obj1 = { >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } >{ 0b11010: "Hello", a: bin1, bin1, b: 0b11010, 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true,} : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } 0b11010: "Hello", ->"Hello" : string +>"Hello" : "Hello" a: bin1, >a : number @@ -31,10 +31,10 @@ var obj1 = { b: 0b11010, >b : number ->0b11010 : number +>0b11010 : 26 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: true, ->true : boolean +>true : true } var obj2 = { @@ -42,7 +42,7 @@ var obj2 = { >{ 0B11010: "World", a: bin2, bin2, b: 0B11010, 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false,} : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } 0B11010: "World", ->"World" : string +>"World" : "World" a: bin2, >a : number @@ -53,101 +53,101 @@ var obj2 = { b: 0B11010, >b : number ->0B11010 : number +>0B11010 : 26 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: false, ->false : boolean +>false : false } obj1[0b11010]; // string >obj1[0b11010] : string >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->0b11010 : number +>0b11010 : 26 obj1[26]; // string >obj1[26] : string >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->26 : number +>26 : 26 obj1["26"]; // string >obj1["26"] : string >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"26" : string +>"26" : "26" obj1["0b11010"]; // any >obj1["0b11010"] : any >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"0b11010" : string +>"0b11010" : "0b11010" obj1["a"]; // number >obj1["a"] : number >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"a" : string +>"a" : "a" obj1["b"]; // number >obj1["b"] : number >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"b" : string +>"b" : "b" obj1["bin1"]; // number >obj1["bin1"] : number >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"bin1" : string +>"bin1" : "bin1" obj1["Infinity"]; // boolean >obj1["Infinity"] : boolean >obj1 : { 0b11010: string; a: number; bin1: number; b: number; 0B111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"Infinity" : string +>"Infinity" : "Infinity" obj2[0B11010]; // string >obj2[0B11010] : string >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->0B11010 : number +>0B11010 : 26 obj2[26]; // string >obj2[26] : string >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->26 : number +>26 : 26 obj2["26"]; // string >obj2["26"] : string >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"26" : string +>"26" : "26" obj2["0B11010"]; // any >obj2["0B11010"] : any >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"0B11010" : string +>"0B11010" : "0B11010" obj2["a"]; // number >obj2["a"] : number >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"a" : string +>"a" : "a" obj2["b"]; // number >obj2["b"] : number >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"b" : string +>"b" : "b" obj2["bin2"]; // number >obj2["bin2"] : number >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"bin2" : string +>"bin2" : "bin2" obj2[9.671406556917009e+24]; // boolean >obj2[9.671406556917009e+24] : boolean >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->9.671406556917009e+24 : number +>9.671406556917009e+24 : 9.671406556917009e+24 obj2["9.671406556917009e+24"]; // boolean >obj2["9.671406556917009e+24"] : boolean >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"9.671406556917009e+24" : string +>"9.671406556917009e+24" : "9.671406556917009e+24" obj2["Infinity"]; // any >obj2["Infinity"] : any >obj2 : { 0B11010: string; a: number; bin2: number; b: number; 0B11111111111111111111111111111111111111111111111101001010100000010111110001111111111: boolean; } ->"Infinity" : string +>"Infinity" : "Infinity" diff --git a/tests/baselines/reference/binopAssignmentShouldHaveType.types b/tests/baselines/reference/binopAssignmentShouldHaveType.types index d09138bbb88..7adfb46792e 100644 --- a/tests/baselines/reference/binopAssignmentShouldHaveType.types +++ b/tests/baselines/reference/binopAssignmentShouldHaveType.types @@ -3,7 +3,7 @@ declare var console; >console : any "use strict"; ->"use strict" : string +>"use strict" : "use strict" module Test { >Test : typeof Test @@ -15,7 +15,7 @@ module Test { >getName : () => string return "name"; ->"name" : string +>"name" : "name" } bug() { >bug : () => void @@ -35,7 +35,7 @@ module Test { >this : this >getName : () => string >length : number ->0 : number +>0 : 0 console.log(name); >console.log(name) : any diff --git a/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types b/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types index 34e2b31a7e8..2875a46355c 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types +++ b/tests/baselines/reference/bitwiseNotOperatorWithBooleanType.types @@ -15,7 +15,7 @@ class A { static foo() { return false; } >foo : () => boolean ->false : boolean +>false : false } module M { >M : typeof M @@ -39,16 +39,16 @@ var ResultIsNumber1 = ~BOOLEAN; var ResultIsNumber2 = ~true; >ResultIsNumber2 : number >~true : number ->true : boolean +>true : true var ResultIsNumber3 = ~{ x: true, y: false }; >ResultIsNumber3 : number >~{ x: true, y: false } : number >{ x: true, y: false } : { x: boolean; y: boolean; } >x : boolean ->true : boolean +>true : true >y : boolean ->false : boolean +>false : false // boolean type expressions var ResultIsNumber4 = ~objA.a; @@ -89,7 +89,7 @@ var ResultIsNumber8 = ~~BOOLEAN; // miss assignment operators ~true; >~true : number ->true : boolean +>true : true ~BOOLEAN; >~BOOLEAN : number @@ -101,10 +101,10 @@ var ResultIsNumber8 = ~~BOOLEAN; >foo : () => boolean ~true, false; ->~true, false : boolean +>~true, false : false >~true : number ->true : boolean ->false : boolean +>true : true +>false : false ~objA.a; >~objA.a : number diff --git a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.types b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.types index bb8be9b3f54..03008f67d11 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithEnumType.types +++ b/tests/baselines/reference/bitwiseNotOperatorWithEnumType.types @@ -3,8 +3,8 @@ enum ENUM1 { A, B, "" }; >ENUM1 : ENUM1 ->A : ENUM1 ->B : ENUM1 +>A : ENUM1.A +>B : ENUM1.B // enum type var var ResultIsNumber1 = ~ENUM1; @@ -16,21 +16,21 @@ var ResultIsNumber1 = ~ENUM1; var ResultIsNumber2 = ~ENUM1["A"]; >ResultIsNumber2 : number >~ENUM1["A"] : number ->ENUM1["A"] : ENUM1 +>ENUM1["A"] : ENUM1.A >ENUM1 : typeof ENUM1 ->"A" : string +>"A" : "A" var ResultIsNumber3 = ~(ENUM1.A + ENUM1["B"]); >ResultIsNumber3 : number >~(ENUM1.A + ENUM1["B"]) : number >(ENUM1.A + ENUM1["B"]) : number >ENUM1.A + ENUM1["B"] : number ->ENUM1.A : ENUM1 +>ENUM1.A : ENUM1.A >ENUM1 : typeof ENUM1 ->A : ENUM1 ->ENUM1["B"] : ENUM1 +>A : ENUM1.A +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" // multiple ~ operators var ResultIsNumber4 = ~~~(ENUM1["A"] + ENUM1.B); @@ -40,12 +40,12 @@ var ResultIsNumber4 = ~~~(ENUM1["A"] + ENUM1.B); >~(ENUM1["A"] + ENUM1.B) : number >(ENUM1["A"] + ENUM1.B) : number >ENUM1["A"] + ENUM1.B : number ->ENUM1["A"] : ENUM1 +>ENUM1["A"] : ENUM1.A >ENUM1 : typeof ENUM1 ->"A" : string ->ENUM1.B : ENUM1 +>"A" : "A" +>ENUM1.B : ENUM1.B >ENUM1 : typeof ENUM1 ->B : ENUM1 +>B : ENUM1.B // miss assignment operators ~ENUM1; @@ -54,18 +54,18 @@ var ResultIsNumber4 = ~~~(ENUM1["A"] + ENUM1.B); ~ENUM1["A"]; >~ENUM1["A"] : number ->ENUM1["A"] : ENUM1 +>ENUM1["A"] : ENUM1.A >ENUM1 : typeof ENUM1 ->"A" : string +>"A" : "A" ~ENUM1.A, ~ENUM1["B"]; >~ENUM1.A, ~ENUM1["B"] : number >~ENUM1.A : number ->ENUM1.A : ENUM1 +>ENUM1.A : ENUM1.A >ENUM1 : typeof ENUM1 ->A : ENUM1 +>A : ENUM1.A >~ENUM1["B"] : number ->ENUM1["B"] : ENUM1 +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" diff --git a/tests/baselines/reference/bitwiseNotOperatorWithNumberType.types b/tests/baselines/reference/bitwiseNotOperatorWithNumberType.types index 228bd43e593..8dc3c31867f 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithNumberType.types +++ b/tests/baselines/reference/bitwiseNotOperatorWithNumberType.types @@ -6,12 +6,12 @@ var NUMBER: number; var NUMBER1: number[] = [1, 2]; >NUMBER1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 function foo(): number { return 1; } >foo : () => number ->1 : number +>1 : 1 class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsNumber2 = ~NUMBER1; var ResultIsNumber3 = ~1; >ResultIsNumber3 : number >~1 : number ->1 : number +>1 : 1 var ResultIsNumber4 = ~{ x: 1, y: 2}; >ResultIsNumber4 : number >~{ x: 1, y: 2} : number >{ x: 1, y: 2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 var ResultIsNumber5 = ~{ x: 1, y: (n: number) => { return n; } }; >ResultIsNumber5 : number >~{ x: 1, y: (n: number) => { return n; } } : number >{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; } >x : number ->1 : number +>1 : 1 >y : (n: number) => number >(n: number) => { return n; } : (n: number) => number >n : number @@ -92,7 +92,7 @@ var ResultIsNumber8 = ~NUMBER1[0]; >~NUMBER1[0] : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 var ResultIsNumber9 = ~foo(); >ResultIsNumber9 : number diff --git a/tests/baselines/reference/bitwiseNotOperatorWithStringType.types b/tests/baselines/reference/bitwiseNotOperatorWithStringType.types index 4f1ca481a1f..130b52c8471 100644 --- a/tests/baselines/reference/bitwiseNotOperatorWithStringType.types +++ b/tests/baselines/reference/bitwiseNotOperatorWithStringType.types @@ -6,12 +6,12 @@ var STRING: string; var STRING1: string[] = ["", "abc"]; >STRING1 : string[] >["", "abc"] : string[] ->"" : string ->"abc" : string +>"" : "" +>"abc" : "abc" function foo(): string { return "abc"; } >foo : () => string ->"abc" : string +>"abc" : "abc" class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return ""; } >foo : () => string ->"" : string +>"" : "" } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsNumber2 = ~STRING1; var ResultIsNumber3 = ~""; >ResultIsNumber3 : number >~"" : number ->"" : string +>"" : "" var ResultIsNumber4 = ~{ x: "", y: "" }; >ResultIsNumber4 : number >~{ x: "", y: "" } : number >{ x: "", y: "" } : { x: string; y: string; } >x : string ->"" : string +>"" : "" >y : string ->"" : string +>"" : "" var ResultIsNumber5 = ~{ x: "", y: (s: string) => { return s; } }; >ResultIsNumber5 : number >~{ x: "", y: (s: string) => { return s; } } : number >{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; } >x : string ->"" : string +>"" : "" >y : (s: string) => string >(s: string) => { return s; } : (s: string) => string >s : string @@ -92,7 +92,7 @@ var ResultIsNumber8 = ~STRING1[0]; >~STRING1[0] : number >STRING1[0] : string >STRING1 : string[] ->0 : number +>0 : 0 var ResultIsNumber9 = ~foo(); >ResultIsNumber9 : number @@ -123,7 +123,7 @@ var ResultIsNumber12 = ~STRING.charAt(0); >STRING.charAt : (pos: number) => string >STRING : string >charAt : (pos: number) => string ->0 : number +>0 : 0 // multiple ~ operators var ResultIsNumber13 = ~~STRING; diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types index 7ced53508e6..4824b641841 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop1.types @@ -9,14 +9,14 @@ declare function use(n: number): void; >function () { 'use strict' for (let i = 0; i < 9; ++i) { (() => use(++i))(); }} : () => void 'use strict' ->'use strict' : string +>'use strict' : "use strict" for (let i = 0; i < 9; ++i) { >i : number ->0 : number +>0 : 0 >i < 9 : boolean >i : number ->9 : number +>9 : 9 >++i : number >i : number diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types index 477d36982f4..d1ae4ee20f4 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop2.types @@ -1,9 +1,9 @@ === tests/cases/compiler/blockScopedBindingsReassignedInLoop2.ts === for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -31,17 +31,17 @@ for (let x = 1, y = 2; x < y; ++x, --y) { } else { y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -69,9 +69,9 @@ for (let x = 1, y = 2; x < y; ++x, --y) { } else { y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } @@ -80,9 +80,9 @@ loop: for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -111,9 +111,9 @@ for (let x = 1, y = 2; x < y; ++x, --y) { } else { y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } @@ -122,9 +122,9 @@ loop: for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -153,8 +153,8 @@ for (let x = 1, y = 2; x < y; ++x, --y) { } else { y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types index ee69f9a5a9f..3dab1458b67 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop3.types @@ -2,9 +2,9 @@ for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -33,10 +33,10 @@ for (let x = 1, y = 2; x < y; ++x, --y) { else { for (let a = 1; a < 5; --a) { >a : number ->1 : number +>1 : 1 >a < 5 : boolean >a : number ->5 : number +>5 : 5 >--a : number >a : number @@ -63,18 +63,18 @@ for (let x = 1, y = 2; x < y; ++x, --y) { } y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -103,10 +103,10 @@ for (let x = 1, y = 2; x < y; ++x, --y) { else { for (let a = 1; a < 5; --a) { >a : number ->1 : number +>1 : 1 >a < 5 : boolean >a : number ->5 : number +>5 : 5 >--a : number >a : number @@ -133,9 +133,9 @@ for (let x = 1, y = 2; x < y; ++x, --y) { } y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } @@ -144,9 +144,9 @@ loop2: for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -179,10 +179,10 @@ for (let x = 1, y = 2; x < y; ++x, --y) { for (let a = 1; a < 5; --a) { >a : number ->1 : number +>1 : 1 >a < 5 : boolean >a : number ->5 : number +>5 : 5 >--a : number >a : number @@ -213,9 +213,9 @@ for (let x = 1, y = 2; x < y; ++x, --y) { } y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } @@ -224,9 +224,9 @@ loop2: for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -259,10 +259,10 @@ for (let x = 1, y = 2; x < y; ++x, --y) { for (let a = 1; a < 5; --a) { >a : number ->1 : number +>1 : 1 >a < 5 : boolean >a : number ->5 : number +>5 : 5 >--a : number >a : number @@ -293,9 +293,9 @@ for (let x = 1, y = 2; x < y; ++x, --y) { } y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types index c3576bbccd2..fb0367e8782 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop4.types @@ -4,9 +4,9 @@ function f1() { for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -31,13 +31,13 @@ function f1() { >1 : 1 return 1; ->1 : number +>1 : 1 } else { y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } } } diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types index 47a0fd52891..73d13e76afd 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop5.types @@ -1,9 +1,9 @@ === tests/cases/compiler/blockScopedBindingsReassignedInLoop5.ts === for (let x = 1, y = 2; x < y; ++x, --y) { >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -30,8 +30,8 @@ for (let x = 1, y = 2; x < y; ++x, --y) { break; else y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 } diff --git a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types index c4287869ec0..8936ded6239 100644 --- a/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types +++ b/tests/baselines/reference/blockScopedBindingsReassignedInLoop6.types @@ -6,8 +6,8 @@ function f1() { >x : number >y : number >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >x < y : boolean >x : number >y : number @@ -38,9 +38,9 @@ function f1() { >2 : 2 y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 else return; @@ -59,11 +59,11 @@ function f2() { >[{a: 1, b: {c: 2}}] : [{ a: number; b: { c: number; }; }] >{a: 1, b: {c: 2}} : { a: number; b: { c: number; }; } >a : number ->1 : number +>1 : 1 >b : { c: number; } >{c: 2} : { c: number; } >c : number ->2 : number +>2 : 2 >x < y : boolean >x : number >y : number @@ -94,9 +94,9 @@ function f2() { >2 : 2 y = 5; ->y = 5 : number +>y = 5 : 5 >y : number ->5 : number +>5 : 5 else return; diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationES5.types b/tests/baselines/reference/blockScopedFunctionDeclarationES5.types index b3c4d9b7d73..8dfdd11da43 100644 --- a/tests/baselines/reference/blockScopedFunctionDeclarationES5.types +++ b/tests/baselines/reference/blockScopedFunctionDeclarationES5.types @@ -1,6 +1,6 @@ === tests/cases/compiler/blockScopedFunctionDeclarationES5.ts === if (true) { ->true : boolean +>true : true function foo() { } >foo : () => void diff --git a/tests/baselines/reference/blockScopedFunctionDeclarationES6.types b/tests/baselines/reference/blockScopedFunctionDeclarationES6.types index 7ab74feb0ed..8f87507a5ac 100644 --- a/tests/baselines/reference/blockScopedFunctionDeclarationES6.types +++ b/tests/baselines/reference/blockScopedFunctionDeclarationES6.types @@ -1,6 +1,6 @@ === tests/cases/compiler/blockScopedFunctionDeclarationES6.ts === if (true) { ->true : boolean +>true : true function foo() { } >foo : () => void diff --git a/tests/baselines/reference/bom-utf16be.types b/tests/baselines/reference/bom-utf16be.types index 1787d102245..e13c45ede2f 100644 --- a/tests/baselines/reference/bom-utf16be.types +++ b/tests/baselines/reference/bom-utf16be.types @@ -1,5 +1,5 @@ === tests/cases/compiler/bom-utf16be.ts === var x=10; >x : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/bom-utf16le.types b/tests/baselines/reference/bom-utf16le.types index 865c94eb82d..bb2038bb23d 100644 --- a/tests/baselines/reference/bom-utf16le.types +++ b/tests/baselines/reference/bom-utf16le.types @@ -1,5 +1,5 @@ === tests/cases/compiler/bom-utf16le.ts === var x=10; >x : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/bom-utf8.types b/tests/baselines/reference/bom-utf8.types index d96d0132383..0f2b45b8ea9 100644 --- a/tests/baselines/reference/bom-utf8.types +++ b/tests/baselines/reference/bom-utf8.types @@ -1,5 +1,5 @@ === tests/cases/compiler/bom-utf8.ts === var x=10; >x : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/booleanAssignment.errors.txt b/tests/baselines/reference/booleanAssignment.errors.txt index 15b506d3df4..fc25fd4007f 100644 --- a/tests/baselines/reference/booleanAssignment.errors.txt +++ b/tests/baselines/reference/booleanAssignment.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/booleanAssignment.ts(2,1): error TS2322: Type 'number' is not assignable to type 'Boolean'. -tests/cases/compiler/booleanAssignment.ts(3,1): error TS2322: Type 'string' is not assignable to type 'Boolean'. +tests/cases/compiler/booleanAssignment.ts(2,1): error TS2322: Type '1' is not assignable to type 'Boolean'. +tests/cases/compiler/booleanAssignment.ts(3,1): error TS2322: Type '"a"' is not assignable to type 'Boolean'. tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not assignable to type 'Boolean'. Types of property 'valueOf' are incompatible. Type '() => Object' is not assignable to type '() => boolean'. @@ -10,10 +10,10 @@ tests/cases/compiler/booleanAssignment.ts(4,1): error TS2322: Type '{}' is not a var b = new Boolean(); b = 1; // Error ~ -!!! error TS2322: Type 'number' is not assignable to type 'Boolean'. +!!! error TS2322: Type '1' is not assignable to type 'Boolean'. b = "a"; // Error ~ -!!! error TS2322: Type 'string' is not assignable to type 'Boolean'. +!!! error TS2322: Type '"a"' is not assignable to type 'Boolean'. b = {}; // Error ~ !!! error TS2322: Type '{}' is not assignable to type 'Boolean'. diff --git a/tests/baselines/reference/booleanLiteralTypes1.types b/tests/baselines/reference/booleanLiteralTypes1.types index 704eba4055b..3ea7000e3be 100644 --- a/tests/baselines/reference/booleanLiteralTypes1.types +++ b/tests/baselines/reference/booleanLiteralTypes1.types @@ -84,13 +84,13 @@ function f4(t: true, f: false) { >false : false var x1 = t && f; ->x1 : false +>x1 : boolean >t && f : false >t : true >f : false var x2 = f && t; ->x2 : false +>x2 : boolean >f && t : false >f : false >t : true @@ -102,7 +102,7 @@ function f4(t: true, f: false) { >f : false var x4 = f || t; ->x4 : true +>x4 : boolean >f || t : true >f : false >t : true @@ -113,7 +113,7 @@ function f4(t: true, f: false) { >t : true var x6 = !f; ->x6 : true +>x6 : boolean >!f : true >f : false } @@ -162,11 +162,11 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); >new Error("Unexpected value") : Error >Error : ErrorConstructor ->"Unexpected value" : string +>"Unexpected value" : "Unexpected value" } function f10(x: true | false) { ->f10 : (x: boolean) => string +>f10 : (x: boolean) => "true" | "false" >x : boolean >true : true >false : false @@ -176,16 +176,16 @@ function f10(x: true | false) { case true: return "true"; >true : true ->"true" : string +>"true" : "true" case false: return "false"; >false : false ->"false" : string +>"false" : "false" } } function f11(x: true | false) { ->f11 : (x: boolean) => string +>f11 : (x: boolean) => "true" | "false" >x : boolean >true : true >false : false @@ -195,11 +195,11 @@ function f11(x: true | false) { case true: return "true"; >true : true ->"true" : string +>"true" : "true" case false: return "false"; >false : false ->"false" : string +>"false" : "false" } return assertNever(x); >assertNever(x) : never diff --git a/tests/baselines/reference/booleanLiteralTypes2.types b/tests/baselines/reference/booleanLiteralTypes2.types index 76cca9481d4..e5e4fba7f4f 100644 --- a/tests/baselines/reference/booleanLiteralTypes2.types +++ b/tests/baselines/reference/booleanLiteralTypes2.types @@ -85,36 +85,36 @@ function f4(t: true, f: false) { >false : false var x1 = t && f; ->x1 : false +>x1 : boolean >t && f : false >t : true >f : false var x2 = f && t; ->x2 : false +>x2 : boolean >f && t : false >f : false >t : true var x3 = t || f; ->x3 : true +>x3 : boolean >t || f : true >t : true >f : false var x4 = f || t; ->x4 : true +>x4 : boolean >f || t : true >f : false >t : true var x5 = !t; ->x5 : false +>x5 : boolean >!t : false >t : true var x6 = !f; ->x6 : true +>x6 : boolean >!f : true >f : false } @@ -163,11 +163,11 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); >new Error("Unexpected value") : Error >Error : ErrorConstructor ->"Unexpected value" : string +>"Unexpected value" : "Unexpected value" } function f10(x: true | false) { ->f10 : (x: boolean) => string +>f10 : (x: boolean) => "true" | "false" >x : boolean >true : true >false : false @@ -177,16 +177,16 @@ function f10(x: true | false) { case true: return "true"; >true : true ->"true" : string +>"true" : "true" case false: return "false"; >false : false ->"false" : string +>"false" : "false" } } function f11(x: true | false) { ->f11 : (x: boolean) => string +>f11 : (x: boolean) => "true" | "false" >x : boolean >true : true >false : false @@ -196,11 +196,11 @@ function f11(x: true | false) { case true: return "true"; >true : true ->"true" : string +>"true" : "true" case false: return "false"; >false : false ->"false" : string +>"false" : "false" } return assertNever(x); >assertNever(x) : never diff --git a/tests/baselines/reference/booleanPropertyAccess.types b/tests/baselines/reference/booleanPropertyAccess.types index 2795b36cee5..a0b800b5574 100644 --- a/tests/baselines/reference/booleanPropertyAccess.types +++ b/tests/baselines/reference/booleanPropertyAccess.types @@ -1,19 +1,19 @@ === tests/cases/conformance/types/primitives/boolean/booleanPropertyAccess.ts === var x = true; >x : boolean ->true : boolean +>true : true var a = x.toString(); >a : string >x.toString() : string >x.toString : () => string ->x : boolean +>x : true >toString : () => string var b = x['toString'](); >b : string >x['toString']() : string >x['toString'] : () => string ->x : boolean ->'toString' : string +>x : true +>'toString' : "toString" diff --git a/tests/baselines/reference/breakInIterationOrSwitchStatement1.types b/tests/baselines/reference/breakInIterationOrSwitchStatement1.types index 545a20ecc55..fad31ae3c92 100644 --- a/tests/baselines/reference/breakInIterationOrSwitchStatement1.types +++ b/tests/baselines/reference/breakInIterationOrSwitchStatement1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/breakInIterationOrSwitchStatement1.ts === while (true) { ->true : boolean +>true : true break; } diff --git a/tests/baselines/reference/breakInIterationOrSwitchStatement2.types b/tests/baselines/reference/breakInIterationOrSwitchStatement2.types index 5736be6c923..e954d459f73 100644 --- a/tests/baselines/reference/breakInIterationOrSwitchStatement2.types +++ b/tests/baselines/reference/breakInIterationOrSwitchStatement2.types @@ -3,5 +3,5 @@ do { break; } while (true); ->true : boolean +>true : true diff --git a/tests/baselines/reference/breakTarget2.types b/tests/baselines/reference/breakTarget2.types index 412203accd1..bf465eb568d 100644 --- a/tests/baselines/reference/breakTarget2.types +++ b/tests/baselines/reference/breakTarget2.types @@ -3,7 +3,7 @@ target: >target : any while (true) { ->true : boolean +>true : true break target; >target : any diff --git a/tests/baselines/reference/breakTarget3.types b/tests/baselines/reference/breakTarget3.types index e4b5f8a1c61..6e926768e12 100644 --- a/tests/baselines/reference/breakTarget3.types +++ b/tests/baselines/reference/breakTarget3.types @@ -7,7 +7,7 @@ target2: >target2 : any while (true) { ->true : boolean +>true : true break target1; >target1 : any diff --git a/tests/baselines/reference/breakTarget4.types b/tests/baselines/reference/breakTarget4.types index 8b6ccf600ad..80bee56f9c7 100644 --- a/tests/baselines/reference/breakTarget4.types +++ b/tests/baselines/reference/breakTarget4.types @@ -7,7 +7,7 @@ target2: >target2 : any while (true) { ->true : boolean +>true : true break target2; >target2 : any diff --git a/tests/baselines/reference/callExpressionWithTypeParameterConstrainedToOuterTypeParameter.types b/tests/baselines/reference/callExpressionWithTypeParameterConstrainedToOuterTypeParameter.types index 76b8a513702..69188eacd1a 100644 --- a/tests/baselines/reference/callExpressionWithTypeParameterConstrainedToOuterTypeParameter.types +++ b/tests/baselines/reference/callExpressionWithTypeParameterConstrainedToOuterTypeParameter.types @@ -15,7 +15,7 @@ var i: I; >I : I var y = i(""); // y should be string ->y : "" +>y : string >i("") : "" >i : I >"" : "" diff --git a/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types b/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types index e3bcb35805f..ff4bbae23b7 100644 --- a/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types +++ b/tests/baselines/reference/callGenericFunctionWithZeroTypeArguments.types @@ -13,7 +13,7 @@ var r = f(1); >r : number >f(1) : number >f : (x: T) => T ->1 : number +>1 : 1 var f2 = (x: T): T => { return null; } >f2 : (x: T) => T @@ -28,7 +28,7 @@ var r2 = f2(1); >r2 : number >f2(1) : number >f2 : (x: T) => T ->1 : number +>1 : 1 var f3: { (x: T): T; } >f3 : (x: T) => T @@ -41,7 +41,7 @@ var r3 = f3(1); >r3 : number >f3(1) : number >f3 : (x: T) => T ->1 : number +>1 : 1 class C { >C : C @@ -65,7 +65,7 @@ var r4 = (new C()).f(1); >new C() : C >C : typeof C >f : (x: T) => T ->1 : number +>1 : 1 interface I { >I : I @@ -87,7 +87,7 @@ var r5 = i.f(1); >i.f : (x: T) => T >i : I >f : (x: T) => T ->1 : number +>1 : 1 class C2 { >C2 : C2 @@ -111,7 +111,7 @@ var r6 = (new C2()).f(1); >new C2() : C2<{}> >C2 : typeof C2 >f : (x: {}) => {} ->1 : number +>1 : 1 interface I2 { >I2 : I2 @@ -133,5 +133,5 @@ var r7 = i2.f(1); >i2.f : (x: number) => number >i2 : I2 >f : (x: number) => number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt index 63a63309c31..0b542186c29 100644 --- a/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt +++ b/tests/baselines/reference/callSignatureWithOptionalParameterAndInitializer.errors.txt @@ -12,7 +12,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWith tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(35,9): error TS2371: A parameter initializer is only allowed in a function or constructor implementation. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(44,9): error TS1015: Parameter cannot have question mark and initializer. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS1015: Parameter cannot have question mark and initializer. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(45,32): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWithOptionalParameterAndInitializer.ts(46,9): error TS1015: Parameter cannot have question mark and initializer. @@ -91,7 +91,7 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignatureWith ~ !!! error TS1015: Parameter cannot have question mark and initializer. ~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. b: (x?: any = '') => { } ~ !!! error TS1015: Parameter cannot have question mark and initializer. diff --git a/tests/baselines/reference/callSignatureWithoutAnnotationsOrBody.types b/tests/baselines/reference/callSignatureWithoutAnnotationsOrBody.types index 062961ac093..9fe90ae83c3 100644 --- a/tests/baselines/reference/callSignatureWithoutAnnotationsOrBody.types +++ b/tests/baselines/reference/callSignatureWithoutAnnotationsOrBody.types @@ -9,7 +9,7 @@ var r = foo(1); // void since there's a body >r : void >foo(1) : void >foo : (x: any) => void ->1 : number +>1 : 1 interface I { >I : I diff --git a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types index 689ac62c35b..a714644ac7c 100644 --- a/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types +++ b/tests/baselines/reference/callSignatureWithoutReturnTypeAnnotationInference.types @@ -8,13 +8,13 @@ function foo(x) { >x : any return 1; ->1 : number +>1 : 1 } var r = foo(1); >r : number >foo(1) : number >foo : (x: any) => number ->1 : number +>1 : 1 function foo2(x) { >foo2 : (x: any) => number @@ -29,7 +29,7 @@ var r2 = foo2(1); >r2 : number >foo2(1) : number >foo2 : (x: any) => number ->1 : number +>1 : 1 function foo3() { >foo3 : () => any @@ -56,28 +56,28 @@ var r4 = foo4(1); >r4 : number >foo4(1) : number >foo4 : (x: T) => T ->1 : number +>1 : 1 function foo5(x) { ->foo5 : (x: any) => number +>foo5 : (x: any) => 1 | 2 >x : any if (true) { ->true : boolean +>true : true return 1; ->1 : number +>1 : 1 } else { return 2; ->2 : number +>2 : 2 } } var r5 = foo5(1); >r5 : number ->foo5(1) : number ->foo5 : (x: any) => number ->1 : number +>foo5(1) : 1 | 2 +>foo5 : (x: any) => 1 | 2 +>1 : 1 function foo6(x) { >foo6 : (x: any) => any[] @@ -100,7 +100,7 @@ var r6 = foo6(1); >r6 : any[] >foo6(1) : any[] >foo6 : (x: any) => any[] ->1 : number +>1 : 1 function foo7(x) { >foo7 : (x: any) => string @@ -114,7 +114,7 @@ var r7 = foo7(1); >r7 : string >foo7(1) : string >foo7 : (x: any) => string ->1 : number +>1 : 1 // object types function foo8(x: number) { @@ -130,7 +130,7 @@ var r8 = foo8(1); >r8 : { x: number; } >foo8(1) : { x: number; } >foo8 : (x: number) => { x: number; } ->1 : number +>1 : 1 interface I { >I : I @@ -153,7 +153,7 @@ var r9 = foo9(1); >r9 : I >foo9(1) : I >foo9 : (x: number) => I ->1 : number +>1 : 1 class C { >C : C @@ -176,14 +176,14 @@ var r10 = foo10(1); >r10 : C >foo10(1) : C >foo10 : (x: number) => C ->1 : number +>1 : 1 module M { >M : typeof M export var x = 1; >x : number ->1 : number +>1 : 1 export class C { foo: string } >C : C @@ -230,12 +230,12 @@ var r12 = foo12(); function m1() { return 1; } >m1 : typeof m1 ->1 : number +>1 : 1 module m1 { export var y = 2; } >m1 : typeof m1 >y : number ->2 : number +>2 : 2 function foo13() { >foo13 : () => typeof m1 @@ -262,7 +262,7 @@ module c1 { export var x = 1; >x : number ->1 : number +>1 : 1 } function foo14() { >foo14 : () => typeof c1 @@ -282,7 +282,7 @@ enum e1 { A } module e1 { export var y = 1; } >e1 : typeof e1 >y : number ->1 : number +>1 : 1 function foo15() { >foo15 : () => typeof e1 diff --git a/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.errors.txt b/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.errors.txt index 1c558910a8c..03219e806ef 100644 --- a/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.errors.txt +++ b/tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts(9,10): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts(9,10): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts (1 errors) ==== @@ -12,5 +12,5 @@ tests/cases/compiler/callSignaturesShouldBeResolvedBeforeSpecialization.ts(9,10) test("expects boolean instead of string"); // should not error - "test" should not expect a boolean test(true); // should error - string expected ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.errors.txt b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.errors.txt index 4ff65843eba..87999dec851 100644 --- a/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.errors.txt +++ b/tests/baselines/reference/callSignaturesThatDifferOnlyByReturnType2.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType2.ts(8,11): error TS2320: Interface 'A' cannot simultaneously extend types 'I' and 'I'. Named property 'foo' of types 'I' and 'I' are not identical. -tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType2.ts(13,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType2.ts(13,16): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. ==== tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesThatDifferOnlyByReturnType2.ts (2 errors) ==== @@ -21,5 +21,5 @@ tests/cases/conformance/types/objectTypeLiteral/callSignatures/callSignaturesTha var r = x.foo(1); // no error var r2 = x.foo(''); // error ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/callSignaturesWithOptionalParameters.types b/tests/baselines/reference/callSignaturesWithOptionalParameters.types index 4ade0e8afe4..e01eed3835a 100644 --- a/tests/baselines/reference/callSignaturesWithOptionalParameters.types +++ b/tests/baselines/reference/callSignaturesWithOptionalParameters.types @@ -20,7 +20,7 @@ var f2 = (x: number, y?: number) => { } foo(1); >foo(1) : void >foo : (x?: number) => void ->1 : number +>1 : 1 foo(); >foo() : void @@ -29,7 +29,7 @@ foo(); f(1); >f(1) : void >f : (x?: number) => void ->1 : number +>1 : 1 f(); >f() : void @@ -38,13 +38,13 @@ f(); f2(1); >f2(1) : void >f2 : (x: number, y?: number) => void ->1 : number +>1 : 1 f2(1, 2); >f2(1, 2) : void >f2 : (x: number, y?: number) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 class C { >C : C @@ -69,7 +69,7 @@ c.foo(1); >c.foo : (x?: number) => void >c : C >foo : (x?: number) => void ->1 : number +>1 : 1 interface I { >I : I @@ -94,22 +94,22 @@ i(); i(1); >i(1) : any >i : I ->1 : number +>1 : 1 i.foo(1); >i.foo(1) : any >i.foo : (x: number, y?: number) => any >i : I >foo : (x: number, y?: number) => any ->1 : number +>1 : 1 i.foo(1, 2); >i.foo(1, 2) : any >i.foo : (x: number, y?: number) => any >i : I >foo : (x: number, y?: number) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 var a: { >a : { (x?: number): any; foo(x?: number): any; } @@ -129,7 +129,7 @@ a(); a(1); >a(1) : any >a : { (x?: number): any; foo(x?: number): any; } ->1 : number +>1 : 1 a.foo(); >a.foo() : any @@ -142,7 +142,7 @@ a.foo(1); >a.foo : (x?: number) => any >a : { (x?: number): any; foo(x?: number): any; } >foo : (x?: number) => any ->1 : number +>1 : 1 var b = { >b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } @@ -176,22 +176,22 @@ b.foo(1); >b.foo : (x?: number) => void >b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } >foo : (x?: number) => void ->1 : number +>1 : 1 b.a(1); >b.a(1) : void >b.a : (x: number, y?: number) => void >b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } >a : (x: number, y?: number) => void ->1 : number +>1 : 1 b.a(1, 2); >b.a(1, 2) : void >b.a : (x: number, y?: number) => void >b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } >a : (x: number, y?: number) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 b.b(); >b.b() : void @@ -204,5 +204,5 @@ b.b(1); >b.b : (x?: number) => void >b : { foo(x?: number): void; a: (x: number, y?: number) => void; b: (x?: number) => void; } >b : (x?: number) => void ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/callSignaturesWithOptionalParameters2.types b/tests/baselines/reference/callSignaturesWithOptionalParameters2.types index f726840752e..c800a62d096 100644 --- a/tests/baselines/reference/callSignaturesWithOptionalParameters2.types +++ b/tests/baselines/reference/callSignaturesWithOptionalParameters2.types @@ -12,7 +12,7 @@ function foo(x?: number) { } foo(1); >foo(1) : any >foo : (x?: number) => any ->1 : number +>1 : 1 foo(); >foo() : any @@ -35,13 +35,13 @@ function foo2(x: number, y?: number) { } foo2(1); >foo2(1) : any >foo2 : { (x: number): any; (x: number, y?: number): any; } ->1 : number +>1 : 1 foo2(1, 2); >foo2(1, 2) : any >foo2 : { (x: number): any; (x: number, y?: number): any; } ->1 : number ->2 : number +>1 : 1 +>2 : 2 class C { >C : C @@ -84,22 +84,22 @@ c.foo(1); >c.foo : (x?: number) => any >c : C >foo : (x?: number) => any ->1 : number +>1 : 1 c.foo2(1); >c.foo2(1) : any >c.foo2 : { (x: number): any; (x: number, y?: number): any; } >c : C >foo2 : { (x: number): any; (x: number, y?: number): any; } ->1 : number +>1 : 1 c.foo2(1, 2); >c.foo2(1, 2) : any >c.foo2 : { (x: number): any; (x: number, y?: number): any; } >c : C >foo2 : { (x: number): any; (x: number, y?: number): any; } ->1 : number ->2 : number +>1 : 1 +>2 : 2 interface I { >I : I @@ -134,37 +134,37 @@ i(); i(1); >i(1) : any >i : I ->1 : number +>1 : 1 i(1, 2); >i(1, 2) : any >i : I ->1 : number ->2 : number +>1 : 1 +>2 : 2 i.foo(1); >i.foo(1) : any >i.foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } >i : I >foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } ->1 : number +>1 : 1 i.foo(1, 2); >i.foo(1, 2) : any >i.foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } >i : I >foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } ->1 : number ->2 : number +>1 : 1 +>2 : 2 i.foo(1, 2, 3); >i.foo(1, 2, 3) : any >i.foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } >i : I >foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var a: { >a : { (x?: number): any; (x?: number, y?: number): any; foo(x: number, y?: number): any; foo(x: number, y?: number, z?: number): any; } @@ -195,35 +195,35 @@ a(); a(1); >a(1) : any >a : { (x?: number): any; (x?: number, y?: number): any; foo(x: number, y?: number): any; foo(x: number, y?: number, z?: number): any; } ->1 : number +>1 : 1 a(1, 2); >a(1, 2) : any >a : { (x?: number): any; (x?: number, y?: number): any; foo(x: number, y?: number): any; foo(x: number, y?: number, z?: number): any; } ->1 : number ->2 : number +>1 : 1 +>2 : 2 a.foo(1); >a.foo(1) : any >a.foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } >a : { (x?: number): any; (x?: number, y?: number): any; foo(x: number, y?: number): any; foo(x: number, y?: number, z?: number): any; } >foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } ->1 : number +>1 : 1 a.foo(1, 2); >a.foo(1, 2) : any >a.foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } >a : { (x?: number): any; (x?: number, y?: number): any; foo(x: number, y?: number): any; foo(x: number, y?: number, z?: number): any; } >foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } ->1 : number ->2 : number +>1 : 1 +>2 : 2 a.foo(1, 2, 3); >a.foo(1, 2, 3) : any >a.foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } >a : { (x?: number): any; (x?: number, y?: number): any; foo(x: number, y?: number): any; foo(x: number, y?: number, z?: number): any; } >foo : { (x: number, y?: number): any; (x: number, y?: number, z?: number): any; } ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 diff --git a/tests/baselines/reference/callWithSpread.types b/tests/baselines/reference/callWithSpread.types index bc120dc4043..c9403f1bb69 100644 --- a/tests/baselines/reference/callWithSpread.types +++ b/tests/baselines/reference/callWithSpread.types @@ -33,43 +33,43 @@ var xa: X[]; foo(1, 2, "abc"); >foo(1, 2, "abc") : void >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" foo(1, 2, ...a); >foo(1, 2, ...a) : void >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] foo(1, 2, ...a, "abc"); >foo(1, 2, ...a, "abc") : void >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"abc" : string +>"abc" : "abc" obj.foo(1, 2, "abc"); >obj.foo(1, 2, "abc") : any >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" obj.foo(1, 2, ...a); >obj.foo(1, 2, ...a) : any >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -78,11 +78,11 @@ obj.foo(1, 2, ...a, "abc"); >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"abc" : string +>"abc" : "abc" (obj.foo)(1, 2, "abc"); >(obj.foo)(1, 2, "abc") : any @@ -90,9 +90,9 @@ obj.foo(1, 2, ...a, "abc"); >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" (obj.foo)(1, 2, ...a); >(obj.foo)(1, 2, ...a) : any @@ -100,8 +100,8 @@ obj.foo(1, 2, ...a, "abc"); >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -111,32 +111,32 @@ obj.foo(1, 2, ...a, "abc"); >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"abc" : string +>"abc" : "abc" xa[1].foo(1, 2, "abc"); >xa[1].foo(1, 2, "abc") : any >xa[1].foo : (x: number, y: number, ...z: string[]) => any >xa[1] : X >xa : X[] ->1 : number +>1 : 1 >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" xa[1].foo(1, 2, ...a); >xa[1].foo(1, 2, ...a) : any >xa[1].foo : (x: number, y: number, ...z: string[]) => any >xa[1] : X >xa : X[] ->1 : number +>1 : 1 >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -145,13 +145,13 @@ xa[1].foo(1, 2, ...a, "abc"); >xa[1].foo : (x: number, y: number, ...z: string[]) => any >xa[1] : X >xa : X[] ->1 : number +>1 : 1 >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"abc" : string +>"abc" : "abc" (xa[1].foo)(...[1, 2, "abc"]); >(xa[1].foo)(...[1, 2, "abc"]) : any @@ -161,13 +161,13 @@ xa[1].foo(1, 2, ...a, "abc"); >xa[1].foo : (x: number, y: number, ...z: string[]) => any >xa[1] : X >xa : X[] ->1 : number +>1 : 1 >foo : (x: number, y: number, ...z: string[]) => any >...[1, 2, "abc"] : string | number >[1, 2, "abc"] : (string | number)[] ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" class C { >C : C @@ -211,14 +211,14 @@ class D extends C { super(1, 2); >super(1, 2) : void >super : typeof C ->1 : number ->2 : number +>1 : 1 +>2 : 2 super(1, 2, ...a); >super(1, 2, ...a) : void >super : typeof C ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] } @@ -230,16 +230,16 @@ class D extends C { >super.foo : (x: number, y: number, ...z: string[]) => void >super : C >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 super.foo(1, 2, ...a); >super.foo(1, 2, ...a) : void >super.foo : (x: number, y: number, ...z: string[]) => void >super : C >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] } diff --git a/tests/baselines/reference/callWithSpreadES6.types b/tests/baselines/reference/callWithSpreadES6.types index 99fe1330df9..b25b8dc02b5 100644 --- a/tests/baselines/reference/callWithSpreadES6.types +++ b/tests/baselines/reference/callWithSpreadES6.types @@ -34,43 +34,43 @@ var xa: X[]; foo(1, 2, "abc"); >foo(1, 2, "abc") : void >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" foo(1, 2, ...a); >foo(1, 2, ...a) : void >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] foo(1, 2, ...a, "abc"); >foo(1, 2, ...a, "abc") : void >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"abc" : string +>"abc" : "abc" obj.foo(1, 2, "abc"); >obj.foo(1, 2, "abc") : any >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" obj.foo(1, 2, ...a); >obj.foo(1, 2, ...a) : any >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -79,11 +79,11 @@ obj.foo(1, 2, ...a, "abc"); >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"abc" : string +>"abc" : "abc" (obj.foo)(1, 2, "abc"); >(obj.foo)(1, 2, "abc") : any @@ -91,9 +91,9 @@ obj.foo(1, 2, ...a, "abc"); >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" (obj.foo)(1, 2, ...a); >(obj.foo)(1, 2, ...a) : any @@ -101,8 +101,8 @@ obj.foo(1, 2, ...a, "abc"); >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -112,32 +112,32 @@ obj.foo(1, 2, ...a, "abc"); >obj.foo : (x: number, y: number, ...z: string[]) => any >obj : X >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"abc" : string +>"abc" : "abc" xa[1].foo(1, 2, "abc"); >xa[1].foo(1, 2, "abc") : any >xa[1].foo : (x: number, y: number, ...z: string[]) => any >xa[1] : X >xa : X[] ->1 : number +>1 : 1 >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" xa[1].foo(1, 2, ...a); >xa[1].foo(1, 2, ...a) : any >xa[1].foo : (x: number, y: number, ...z: string[]) => any >xa[1] : X >xa : X[] ->1 : number +>1 : 1 >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -146,13 +146,13 @@ xa[1].foo(1, 2, ...a, "abc"); >xa[1].foo : (x: number, y: number, ...z: string[]) => any >xa[1] : X >xa : X[] ->1 : number +>1 : 1 >foo : (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"abc" : string +>"abc" : "abc" (xa[1].foo)(...[1, 2, "abc"]); >(xa[1].foo)(...[1, 2, "abc"]) : any @@ -162,13 +162,13 @@ xa[1].foo(1, 2, ...a, "abc"); >xa[1].foo : (x: number, y: number, ...z: string[]) => any >xa[1] : X >xa : X[] ->1 : number +>1 : 1 >foo : (x: number, y: number, ...z: string[]) => any >...[1, 2, "abc"] : string | number >[1, 2, "abc"] : (string | number)[] ->1 : number ->2 : number ->"abc" : string +>1 : 1 +>2 : 2 +>"abc" : "abc" class C { >C : C @@ -212,14 +212,14 @@ class D extends C { super(1, 2); >super(1, 2) : void >super : typeof C ->1 : number ->2 : number +>1 : 1 +>2 : 2 super(1, 2, ...a); >super(1, 2, ...a) : void >super : typeof C ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] } @@ -231,16 +231,16 @@ class D extends C { >super.foo : (x: number, y: number, ...z: string[]) => void >super : C >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 super.foo(1, 2, ...a); >super.foo(1, 2, ...a) : void >super.foo : (x: number, y: number, ...z: string[]) => void >super : C >foo : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] } diff --git a/tests/baselines/reference/capturedLetConstInLoop1.errors.txt b/tests/baselines/reference/capturedLetConstInLoop1.errors.txt new file mode 100644 index 00000000000..a10b380bcf9 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop1.errors.txt @@ -0,0 +1,128 @@ +tests/cases/compiler/capturedLetConstInLoop1.ts(69,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop1.ts(86,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop1.ts(92,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop1.ts(109,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop1.ts (4 errors) ==== + //==== let + for (let x in {}) { + (function() { return x}); + (() => x); + } + + for (let x of []) { + (function() { return x}); + (() => x); + } + + for (let x = 0; x < 1; ++x) { + (function() { return x}); + (() => x); + } + + while (1 === 1) { + let x; + (function() { return x}); + (() => x); + } + + do { + let x; + (function() { return x}); + (() => x); + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x}); + (() => x); + } + + for (let x = 0, y = 1; x < 1; ++x) { + (function() { return x + y}); + (() => x + y); + } + + while (1 === 1) { + let x, y; + (function() { return x + y}); + (() => x + y); + } + + do { + let x, y; + (function() { return x + y}); + (() => x + y); + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x + y}); + (() => x + y); + } + + //=========const + for (const x in {}) { + (function() { return x}); + (() => x); + } + + for (const x of []) { + (function() { return x}); + (() => x); + } + + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x}); + (() => x); + } + + while (1 === 1) { + const x = 1; + (function() { return x}); + (() => x); + } + + do { + const x = 1; + (function() { return x}); + (() => x); + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x}); + (() => x); + } + + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x + y}); + (() => x + y); + } + + while (1 === 1) { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + } + + do { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x + y}); + (() => x + y); + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop10.types b/tests/baselines/reference/capturedLetConstInLoop10.types index e4bca4d906a..19f328f72bd 100644 --- a/tests/baselines/reference/capturedLetConstInLoop10.types +++ b/tests/baselines/reference/capturedLetConstInLoop10.types @@ -8,7 +8,7 @@ class A { for (let x of [0]) { >x : number >[0] : number[] ->0 : number +>0 : 0 let f = function() { return x; }; >f : () => number @@ -35,7 +35,7 @@ class A { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 let a = function() { return x; }; >a : () => number @@ -45,7 +45,7 @@ class A { for (let y of [1]) { >y : number >[1] : number[] ->1 : number +>1 : 1 let b = function() { return y; }; >b : () => number @@ -75,7 +75,7 @@ class A { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 let a = function() { return x; }; >a : () => number @@ -93,7 +93,7 @@ class A { for (let y of [1]) { >y : number >[1] : number[] ->1 : number +>1 : 1 let b = function() { return y; }; >b : () => number @@ -127,7 +127,7 @@ class B { for (let x of [0]) { >x : number >[0] : number[] ->0 : number +>0 : 0 let f = () => x; >f : () => number diff --git a/tests/baselines/reference/capturedLetConstInLoop10_ES6.types b/tests/baselines/reference/capturedLetConstInLoop10_ES6.types index 068c124582d..9807d60a1cd 100644 --- a/tests/baselines/reference/capturedLetConstInLoop10_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop10_ES6.types @@ -8,7 +8,7 @@ class A { for (let x of [0]) { >x : number >[0] : number[] ->0 : number +>0 : 0 let f = function() { return x; }; >f : () => number @@ -35,7 +35,7 @@ class A { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 let a = function() { return x; }; >a : () => number @@ -45,7 +45,7 @@ class A { for (let y of [1]) { >y : number >[1] : number[] ->1 : number +>1 : 1 let b = function() { return y; }; >b : () => number @@ -75,7 +75,7 @@ class A { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 let a = function() { return x; }; >a : () => number @@ -93,7 +93,7 @@ class A { for (let y of [1]) { >y : number >[1] : number[] ->1 : number +>1 : 1 let b = function() { return y; }; >b : () => number @@ -127,7 +127,7 @@ class B { for (let x of [0]) { >x : number >[0] : number[] ->0 : number +>0 : 0 let f = () => x; >f : () => number diff --git a/tests/baselines/reference/capturedLetConstInLoop11.types b/tests/baselines/reference/capturedLetConstInLoop11.types index 09fad9f2023..e150744627d 100644 --- a/tests/baselines/reference/capturedLetConstInLoop11.types +++ b/tests/baselines/reference/capturedLetConstInLoop11.types @@ -2,7 +2,7 @@ for (;;) { let x = 1; >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number @@ -14,16 +14,16 @@ function foo() { for (;;) { const a = 0; ->a : number ->0 : number +>a : 0 +>0 : 0 switch(a) { ->a : number +>a : 0 case 0: return () => a; >0 : 0 >() => a : () => number ->a : number +>a : 0 } } } diff --git a/tests/baselines/reference/capturedLetConstInLoop11_ES6.types b/tests/baselines/reference/capturedLetConstInLoop11_ES6.types index d6fd971202c..883be74b66d 100644 --- a/tests/baselines/reference/capturedLetConstInLoop11_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop11_ES6.types @@ -2,7 +2,7 @@ for (;;) { let x = 1; >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number @@ -14,16 +14,16 @@ function foo() { for (;;) { const a = 0; ->a : number ->0 : number +>a : 0 +>0 : 0 switch(a) { ->a : number +>a : 0 case 0: return () => a; >0 : 0 >() => a : () => number ->a : number +>a : 0 } } } diff --git a/tests/baselines/reference/capturedLetConstInLoop12.types b/tests/baselines/reference/capturedLetConstInLoop12.types index aee671b4d36..1e8877fe53a 100644 --- a/tests/baselines/reference/capturedLetConstInLoop12.types +++ b/tests/baselines/reference/capturedLetConstInLoop12.types @@ -5,14 +5,14 @@ >function() { "use strict"; for (let i = 0; i < 4; i++) { (() => [i] = [i + 1])(); }} : () => void "use strict"; ->"use strict" : string +>"use strict" : "use strict" for (let i = 0; i < 4; i++) { >i : number ->0 : number +>0 : 0 >i < 4 : boolean >i : number ->4 : number +>4 : 4 >i++ : number >i : number @@ -26,7 +26,7 @@ >[i + 1] : [number] >i + 1 : number >i : number ->1 : number +>1 : 1 } })(); @@ -36,14 +36,14 @@ >function() { "use strict"; for (let i = 0; i < 4; i++) { (() => ({a:i} = {a:i + 1}))(); }} : () => void "use strict"; ->"use strict" : string +>"use strict" : "use strict" for (let i = 0; i < 4; i++) { >i : number ->0 : number +>0 : 0 >i < 4 : boolean >i : number ->4 : number +>4 : 4 >i++ : number >i : number @@ -60,6 +60,6 @@ >a : number >i + 1 : number >i : number ->1 : number +>1 : 1 } })(); diff --git a/tests/baselines/reference/capturedLetConstInLoop1_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop1_ES6.errors.txt new file mode 100644 index 00000000000..24c5ddf17b6 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop1_ES6.errors.txt @@ -0,0 +1,128 @@ +tests/cases/compiler/capturedLetConstInLoop1_ES6.ts(69,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop1_ES6.ts(86,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop1_ES6.ts(92,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop1_ES6.ts(109,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop1_ES6.ts (4 errors) ==== + //==== let + for (let x in {}) { + (function() { return x}); + (() => x); + } + + for (let x of []) { + (function() { return x}); + (() => x); + } + + for (let x = 0; x < 1; ++x) { + (function() { return x}); + (() => x); + } + + while (1 === 1) { + let x; + (function() { return x}); + (() => x); + } + + do { + let x; + (function() { return x}); + (() => x); + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x}); + (() => x); + } + + for (let x = 0, y = 1; x < 1; ++x) { + (function() { return x + y}); + (() => x + y); + } + + while (1 === 1) { + let x, y; + (function() { return x + y}); + (() => x + y); + } + + do { + let x, y; + (function() { return x + y}); + (() => x + y); + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x + y}); + (() => x + y); + } + + //=========const + for (const x in {}) { + (function() { return x}); + (() => x); + } + + for (const x of []) { + (function() { return x}); + (() => x); + } + + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x}); + (() => x); + } + + while (1 === 1) { + const x = 1; + (function() { return x}); + (() => x); + } + + do { + const x = 1; + (function() { return x}); + (() => x); + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x}); + (() => x); + } + + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x + y}); + (() => x + y); + } + + while (1 === 1) { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + } + + do { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x + y}); + (() => x + y); + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop2.errors.txt b/tests/baselines/reference/capturedLetConstInLoop2.errors.txt new file mode 100644 index 00000000000..9125a87ecfe --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop2.errors.txt @@ -0,0 +1,191 @@ +tests/cases/compiler/capturedLetConstInLoop2.ts(108,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop2.ts(133,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop2.ts(142,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop2.ts(170,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop2.ts (4 errors) ==== + + + // ========let + function foo0(x) { + for (let x of []) { + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo0_1(x) { + for (let x in []) { + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo1(x) { + for (let x = 0; x < 1; ++x) { + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo2(x) { + while (1 === 1) { + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo3(x) { + do { + let x; + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } while (1 === 1) + } + + function foo4(x) { + for (let y = 0; y < 1; ++y) { + let a = arguments.length; + let x = 1; + (function() { return x + a }); + (() => x + a); + } + } + + function foo5(x) { + for (let x = 0, y = 1; x < 1; ++x) { + let a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + + + function foo6(x) { + while (1 === 1) { + let x, y; + let a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + + function foo7(x) { + do { + let x, y; + let a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } while (1 === 1) + } + + + function foo8(x) { + for (let y = 0; y < 1; ++y) { + let x = 1; + let a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + ///=======const + function foo0_c(x) { + for (const x of []) { + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo0_1_c(x) { + for (const x in []) { + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo1_c(x) { + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo2_c(x) { + while (1 === 1) { + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo3_c(x) { + do { + const x = 1; + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } while (1 === 1) + } + + function foo4_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const a = arguments.length; + const x = 1; + (function() { return x + a }); + (() => x + a); + } + } + + function foo5_c(x) { + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + + + function foo6_c(x) { + while (1 === 1) { + const x = 1, y =1 ; + const a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + + function foo7_c(x) { + do { + const x = 1, y = 1; + const a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } while (1 === 1) + } + + + function foo8_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + const a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop2_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop2_ES6.errors.txt new file mode 100644 index 00000000000..d61bf3619c7 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop2_ES6.errors.txt @@ -0,0 +1,190 @@ +tests/cases/compiler/capturedLetConstInLoop2_ES6.ts(107,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop2_ES6.ts(132,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop2_ES6.ts(141,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop2_ES6.ts(169,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop2_ES6.ts (4 errors) ==== + + // ========let + function foo0(x) { + for (let x of []) { + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo0_1(x) { + for (let x in []) { + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo1(x) { + for (let x = 0; x < 1; ++x) { + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo2(x) { + while (1 === 1) { + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo3(x) { + do { + let x; + let a = arguments.length; + (function() { return x + a }); + (() => x + a); + } while (1 === 1) + } + + function foo4(x) { + for (let y = 0; y < 1; ++y) { + let a = arguments.length; + let x = 1; + (function() { return x + a }); + (() => x + a); + } + } + + function foo5(x) { + for (let x = 0, y = 1; x < 1; ++x) { + let a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + + + function foo6(x) { + while (1 === 1) { + let x, y; + let a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + + function foo7(x) { + do { + let x, y; + let a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } while (1 === 1) + } + + + function foo8(x) { + for (let y = 0; y < 1; ++y) { + let x = 1; + let a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + ///=======const + function foo0_c(x) { + for (const x of []) { + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo0_1_c(x) { + for (const x in []) { + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo1_c(x) { + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo2_c(x) { + while (1 === 1) { + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } + } + + function foo3_c(x) { + do { + const x = 1; + const a = arguments.length; + (function() { return x + a }); + (() => x + a); + } while (1 === 1) + } + + function foo4_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const a = arguments.length; + const x = 1; + (function() { return x + a }); + (() => x + a); + } + } + + function foo5_c(x) { + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + + + function foo6_c(x) { + while (1 === 1) { + const x = 1, y =1 ; + const a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } + + function foo7_c(x) { + do { + const x = 1, y = 1; + const a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } while (1 === 1) + } + + + function foo8_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + const a = arguments.length; + (function() { return x + y + a }); + (() => x + y + a); + } + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop3.errors.txt b/tests/baselines/reference/capturedLetConstInLoop3.errors.txt new file mode 100644 index 00000000000..ecc9dbcccc5 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop3.errors.txt @@ -0,0 +1,232 @@ +tests/cases/compiler/capturedLetConstInLoop3.ts(132,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop3.ts(164,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop3.ts(175,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop3.ts(209,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop3.ts (4 errors) ==== + ///=========let + declare function use(a: any); + function foo0(x) { + for (let x of []) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo0_1(x) { + for (let x in []) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo1(x) { + for (let x = 0; x < 1; ++x) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo2(x) { + while (1 === 1) { + let x = 1; + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo3(x) { + do { + let x; + var v; + (function() { return x + v }); + (() => x + v); + } while (1 === 1); + + use(v); + } + + function foo4(x) { + for (let y = 0; y < 1; ++y) { + var v = y; + let x = 1; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo5(x) { + for (let x = 0, y = 1; x < 1; ++x) { + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v); + } + + + function foo6(x) { + while (1 === 1) { + let x, y; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v) + } + + function foo7(x) { + do { + let x, y; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } while (1 === 1); + + use(v); + } + + + function foo8(x) { + for (let y = 0; y < 1; ++y) { + let x = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v); + } + //===const + function foo0_c(x) { + for (const x of []) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo0_1_c(x) { + for (const x in []) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo1_c(x) { + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo2_c(x) { + while (1 === 1) { + const x = 1; + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo3_c(x) { + do { + const x = 1; + var v; + (function() { return x + v }); + (() => x + v); + } while (1 === 1); + + use(v); + } + + function foo4_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = y; + const x = 1; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo5_c(x) { + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v); + } + + + function foo6_c(x) { + while (1 === 1) { + const x = 1, y = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v) + } + + function foo7_c(x) { + do { + const x = 1, y = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } while (1 === 1); + + use(v); + } + + + function foo8_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v); + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop3_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop3_ES6.errors.txt new file mode 100644 index 00000000000..487c47e32a5 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop3_ES6.errors.txt @@ -0,0 +1,233 @@ +tests/cases/compiler/capturedLetConstInLoop3_ES6.ts(133,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop3_ES6.ts(165,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop3_ES6.ts(176,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop3_ES6.ts(210,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop3_ES6.ts (4 errors) ==== + + ///=========let + declare function use(a: any); + function foo0(x) { + for (let x of []) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo0_1(x) { + for (let x in []) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo1(x) { + for (let x = 0; x < 1; ++x) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo2(x) { + while (1 === 1) { + let x = 1; + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo3(x) { + do { + let x; + var v; + (function() { return x + v }); + (() => x + v); + } while (1 === 1); + + use(v); + } + + function foo4(x) { + for (let y = 0; y < 1; ++y) { + var v = y; + let x = 1; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo5(x) { + for (let x = 0, y = 1; x < 1; ++x) { + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v); + } + + + function foo6(x) { + while (1 === 1) { + let x, y; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v) + } + + function foo7(x) { + do { + let x, y; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } while (1 === 1); + + use(v); + } + + + function foo8(x) { + for (let y = 0; y < 1; ++y) { + let x = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v); + } + //===const + function foo0_c(x) { + for (const x of []) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo0_1_c(x) { + for (const x in []) { + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo1_c(x) { + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo2_c(x) { + while (1 === 1) { + const x = 1; + var v = x; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo3_c(x) { + do { + const x = 1; + var v; + (function() { return x + v }); + (() => x + v); + } while (1 === 1); + + use(v); + } + + function foo4_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = y; + const x = 1; + (function() { return x + v }); + (() => x + v); + } + + use(v); + } + + function foo5_c(x) { + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v); + } + + + function foo6_c(x) { + while (1 === 1) { + const x = 1, y = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v) + } + + function foo7_c(x) { + do { + const x = 1, y = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } while (1 === 1); + + use(v); + } + + + function foo8_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + } + + use(v); + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop4.errors.txt b/tests/baselines/reference/capturedLetConstInLoop4.errors.txt new file mode 100644 index 00000000000..000286537b8 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop4.errors.txt @@ -0,0 +1,158 @@ +tests/cases/compiler/capturedLetConstInLoop4.ts(90,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop4.ts(110,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop4.ts(117,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop4.ts(137,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop4.ts (4 errors) ==== + + //======let + export function exportedFoo() { + return v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8; + } + + for (let x of []) { + var v0 = x; + (function() { return x + v0}); + (() => x); + } + + for (let x in []) { + var v00 = x; + (function() { return x + v00}); + (() => x); + } + + for (let x = 0; x < 1; ++x) { + var v1 = x; + (function() { return x + v1}); + (() => x); + } + + while (1 === 1) { + let x; + var v2 = x; + (function() { return x + v2}); + (() => x); + } + + do { + let x; + var v3 = x; + (function() { return x + v3}); + (() => x); + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + var v4 = x; + (function() { return x + v4}); + (() => x); + } + + for (let x = 0, y = 1; x < 1; ++x) { + var v5 = x; + (function() { return x + y + v5}); + (() => x + y); + } + + while (1 === 1) { + let x, y; + var v6 = x; + (function() { return x + y + v6}); + (() => x + y); + } + + do { + let x, y; + var v7 = x; + (function() { return x + y + v7}); + (() => x + y); + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + var v8 = x; + (function() { return x + y + v8}); + (() => x + y); + } + + //======const + export function exportedFoo2() { + return v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c; + } + + for (const x of []) { + var v0_c = x; + (function() { return x + v0_c}); + (() => x); + } + + for (const x in []) { + var v00_c = x; + (function() { return x + v00}); + (() => x); + } + + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v1_c = x; + (function() { return x + v1_c}); + (() => x); + } + + while (1 === 1) { + const x =1; + var v2_c = x; + (function() { return x + v2_c}); + (() => x); + } + + do { + const x = 1; + var v3_c = x; + (function() { return x + v3_c}); + (() => x); + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + var v4_c = x; + (function() { return x + v4_c}); + (() => x); + } + + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v5_c = x; + (function() { return x + y + v5_c}); + (() => x + y); + } + + while (1 === 1) { + const x = 1, y = 1; + var v6_c = x; + (function() { return x + y + v6_c}); + (() => x + y); + } + + do { + const x = 1, y = 1; + var v7_c = x; + (function() { return x + y + v7_c}); + (() => x + y); + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + var v8_c = x; + (function() { return x + y + v8_c}); + (() => x + y); + } + \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop4_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop4_ES6.errors.txt new file mode 100644 index 00000000000..a83bb1d414f --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop4_ES6.errors.txt @@ -0,0 +1,158 @@ +tests/cases/compiler/capturedLetConstInLoop4_ES6.ts(90,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop4_ES6.ts(110,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop4_ES6.ts(117,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop4_ES6.ts(137,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop4_ES6.ts (4 errors) ==== + + //======let + export function exportedFoo() { + return v0 + v00 + v1 + v2 + v3 + v4 + v5 + v6 + v7 + v8; + } + + for (let x of []) { + var v0 = x; + (function() { return x + v0}); + (() => x); + } + + for (let x in []) { + var v00 = x; + (function() { return x + v00}); + (() => x); + } + + for (let x = 0; x < 1; ++x) { + var v1 = x; + (function() { return x + v1}); + (() => x); + } + + while (1 === 1) { + let x; + var v2 = x; + (function() { return x + v2}); + (() => x); + } + + do { + let x; + var v3 = x; + (function() { return x + v3}); + (() => x); + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + var v4 = x; + (function() { return x + v4}); + (() => x); + } + + for (let x = 0, y = 1; x < 1; ++x) { + var v5 = x; + (function() { return x + y + v5}); + (() => x + y); + } + + while (1 === 1) { + let x, y; + var v6 = x; + (function() { return x + y + v6}); + (() => x + y); + } + + do { + let x, y; + var v7 = x; + (function() { return x + y + v7}); + (() => x + y); + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + var v8 = x; + (function() { return x + y + v8}); + (() => x + y); + } + + //======const + export function exportedFoo2() { + return v0_c + v00_c + v1_c + v2_c + v3_c + v4_c + v5_c + v6_c + v7_c + v8_c; + } + + for (const x of []) { + var v0_c = x; + (function() { return x + v0_c}); + (() => x); + } + + for (const x in []) { + var v00_c = x; + (function() { return x + v00}); + (() => x); + } + + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v1_c = x; + (function() { return x + v1_c}); + (() => x); + } + + while (1 === 1) { + const x =1; + var v2_c = x; + (function() { return x + v2_c}); + (() => x); + } + + do { + const x = 1; + var v3_c = x; + (function() { return x + v3_c}); + (() => x); + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + var v4_c = x; + (function() { return x + v4_c}); + (() => x); + } + + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v5_c = x; + (function() { return x + y + v5_c}); + (() => x + y); + } + + while (1 === 1) { + const x = 1, y = 1; + var v6_c = x; + (function() { return x + y + v6_c}); + (() => x + y); + } + + do { + const x = 1, y = 1; + var v7_c = x; + (function() { return x + y + v7_c}); + (() => x + y); + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + var v8_c = x; + (function() { return x + y + v8_c}); + (() => x + y); + } + \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop5.errors.txt b/tests/baselines/reference/capturedLetConstInLoop5.errors.txt new file mode 100644 index 00000000000..b182d8347de --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop5.errors.txt @@ -0,0 +1,300 @@ +tests/cases/compiler/capturedLetConstInLoop5.ts(170,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5.ts(174,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5.ts(211,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5.ts(225,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5.ts(229,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5.ts(268,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop5.ts (6 errors) ==== + declare function use(a: any); + + //====let + function foo0(x) { + for (let x of []) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo00(x) { + for (let x in []) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == "1") { + return; + } + } + + use(v); + } + + function foo1(x) { + for (let x = 0; x < 1; ++x) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo2(x) { + while (1 === 1) { + let x = 1; + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo3(x) { + do { + let x; + var v; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } while (1 === 1) + + use(v); + } + + function foo4(x) { + for (let y = 0; y < 1; ++y) { + var v = y; + let x = 1; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo5(x) { + for (let x = 0, y = 1; x < 1; ++x) { + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } + + use(v); + } + + + function foo6(x) { + while (1 === 1) { + let x, y; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + }; + + use(v) + } + + function foo7(x) { + do { + let x, y; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } while (1 === 1); + + use(v); + } + + + function foo8(x) { + for (let y = 0; y < 1; ++y) { + let x = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } + + use(v); + } + + //====const + function foo0_c(x) { + for (const x of []) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo00_c(x) { + for (const x in []) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == "1") { + return; + } + } + + use(v); + } + + function foo1_c(x) { + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + return; + } + } + + use(v); + } + + function foo2_c(x) { + while (1 === 1) { + const x = 1; + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo3_c(x) { + do { + const x = 1; + var v; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } while (1 === 1) + + use(v); + } + + function foo4_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = y; + let x = 1; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo5_c(x) { + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + return; + } + } + + use(v); + } + + + function foo6_c(x) { + while (1 === 1) { + const x = 1, y = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } + + use(v) + } + + function foo7_c(x) { + do { + const x = 1, y = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } while (1 === 1) + + use(v); + } + + + function foo8_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } + + use(v); + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt new file mode 100644 index 00000000000..05eb0626e2d --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop5_ES6.errors.txt @@ -0,0 +1,301 @@ +tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(171,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(175,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(212,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(226,30): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(230,13): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop5_ES6.ts(269,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop5_ES6.ts (6 errors) ==== + + declare function use(a: any); + + //====let + function foo0(x) { + for (let x of []) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo00(x) { + for (let x in []) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == "1") { + return; + } + } + + use(v); + } + + function foo1(x) { + for (let x = 0; x < 1; ++x) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo2(x) { + while (1 === 1) { + let x = 1; + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo3(x) { + do { + let x; + var v; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } while (1 === 1) + + use(v); + } + + function foo4(x) { + for (let y = 0; y < 1; ++y) { + var v = y; + let x = 1; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo5(x) { + for (let x = 0, y = 1; x < 1; ++x) { + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } + + use(v); + } + + + function foo6(x) { + while (1 === 1) { + let x, y; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + }; + + use(v) + } + + function foo7(x) { + do { + let x, y; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } while (1 === 1); + + use(v); + } + + + function foo8(x) { + for (let y = 0; y < 1; ++y) { + let x = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } + + use(v); + } + + //====const + function foo0_c(x) { + for (const x of []) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo00_c(x) { + for (const x in []) { + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == "1") { + return; + } + } + + use(v); + } + + function foo1_c(x) { + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + return; + } + } + + use(v); + } + + function foo2_c(x) { + while (1 === 1) { + const x = 1; + var v = x; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo3_c(x) { + do { + const x = 1; + var v; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } while (1 === 1) + + use(v); + } + + function foo4_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = y; + let x = 1; + (function() { return x + v }); + (() => x + v); + if (x == 1) { + return; + } + } + + use(v); + } + + function foo5_c(x) { + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + return; + } + } + + use(v); + } + + + function foo6_c(x) { + while (1 === 1) { + const x = 1, y = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } + + use(v) + } + + function foo7_c(x) { + do { + const x = 1, y = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } while (1 === 1) + + use(v); + } + + + function foo8_c(x) { + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + var v = x; + (function() { return x + y + v }); + (() => x + y + v); + if (x == 1) { + return; + } + } + + use(v); + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop6.errors.txt new file mode 100644 index 00000000000..c332c5b7323 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop6.errors.txt @@ -0,0 +1,265 @@ +tests/cases/compiler/capturedLetConstInLoop6.ts(144,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6.ts(147,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6.ts(150,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop6.ts(179,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6.ts(191,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6.ts(194,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6.ts(197,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop6.ts(226,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop6.ts (8 errors) ==== + // ====let + for (let x of []) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + for (let x in []) { + (function() { return x}); + (() => x); + if (x == "1") { + break; + } + if (x == "2") { + continue; + } + } + + + for (let x = 0; x < 1; ++x) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + while (1 === 1) { + let x; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + do { + let x; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + for (let x = 0, y = 1; x < 1; ++x) { + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + while (1 === 1) { + let x, y; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + do { + let x, y; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + // ====const + + for (const x of []) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + for (const x in []) { + (function() { return x}); + (() => x); + if (x == "1") { + break; + } + if (x == "2") { + continue; + } + } + + + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x}); + (() => x); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + } + + while (1 === 1) { + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + do { + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x + y}); + (() => x + y); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + } + + while (1 === 1) { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + do { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt new file mode 100644 index 00000000000..18ecfe7c666 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop6_ES6.errors.txt @@ -0,0 +1,265 @@ +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(144,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(147,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(150,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(179,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(191,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(194,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(197,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop6_ES6.ts(226,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop6_ES6.ts (8 errors) ==== + // ====let + for (let x of []) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + for (let x in []) { + (function() { return x}); + (() => x); + if (x == "1") { + break; + } + if (x == "2") { + continue; + } + } + + + for (let x = 0; x < 1; ++x) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + while (1 === 1) { + let x; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + do { + let x; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + for (let x = 0, y = 1; x < 1; ++x) { + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + while (1 === 1) { + let x, y; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + do { + let x, y; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } while (1 === 1) + + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + // ====const + + for (const x of []) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + for (const x in []) { + (function() { return x}); + (() => x); + if (x == "1") { + break; + } + if (x == "2") { + continue; + } + } + + + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x}); + (() => x); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + } + + while (1 === 1) { + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + do { + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x + y}); + (() => x + y); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + } + + while (1 === 1) { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + do { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } while (1 === 1) + + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 2) { + continue; + } + } + + \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop7.errors.txt b/tests/baselines/reference/capturedLetConstInLoop7.errors.txt new file mode 100644 index 00000000000..29e6fbca6cd --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop7.errors.txt @@ -0,0 +1,414 @@ +tests/cases/compiler/capturedLetConstInLoop7.ts(227,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7.ts(230,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7.ts(233,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7.ts(236,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7.ts(239,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7.ts(283,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7.ts(302,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7.ts(305,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7.ts(308,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7.ts(311,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7.ts(314,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7.ts(359,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop7.ts (12 errors) ==== + //===let + l0: + for (let x of []) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l0; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l0; + } + } + + l00: + for (let x in []) { + (function() { return x}); + (() => x); + if (x == "1") { + break; + } + if (x == "1") { + break l00; + } + if (x == "2") { + continue; + } + if (x == "2") { + continue l00; + } + } + + l1: + for (let x = 0; x < 1; ++x) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l1; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l1; + } + } + + l2: + while (1 === 1) { + let x; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l2; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l2; + } + } + + l3: + do { + let x; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l3; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l3; + } + } while (1 === 1) + + l4: + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l4; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l4; + } + } + + l5: + for (let x = 0, y = 1; x < 1; ++x) { + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l5; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l5; + } + } + + l6: + while (1 === 1) { + let x, y; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l6; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l6; + } + + } + + l7: + do { + let x, y; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l7; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l7; + } + } while (1 === 1) + + l8: + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l8; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l8; + } + } + + //===const + l0_c: + for (const x of []) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l0_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l0_c; + } + } + + l00_c: + for (const x in []) { + (function() { return x}); + (() => x); + if (x == "1") { + break; + } + if (x == "1") { + break l00_c; + } + if (x == "2") { + continue; + } + if (x == "2") { + continue l00_c; + } + } + + l1_c: + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x}); + (() => x); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break l1_c; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l1_c; + } + } + + l2_c: + while (1 === 1) { + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l2_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l2_c; + } + } + + l3_c: + do { + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l3_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l3_c; + } + } while (1 === 1) + + l4_c: + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l4_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l4_c; + } + } + + l5_c: + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x + y}); + (() => x + y); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break l5_c; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l5_c; + } + } + + l6_c: + while (1 === 1) { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l6_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l6_c; + } + + } + + l7_c: + do { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l7_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l7_c; + } + } while (1 === 1) + + l8_c: + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l8_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l8_c; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt new file mode 100644 index 00000000000..a2001dc09b3 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop7_ES6.errors.txt @@ -0,0 +1,414 @@ +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(227,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(230,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(233,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(236,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(239,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(283,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(302,26): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(305,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(308,9): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(311,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(314,9): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop7_ES6.ts(359,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. + + +==== tests/cases/compiler/capturedLetConstInLoop7_ES6.ts (12 errors) ==== + //===let + l0: + for (let x of []) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l0; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l0; + } + } + + l00: + for (let x in []) { + (function() { return x}); + (() => x); + if (x == "1") { + break; + } + if (x == "1") { + break l00; + } + if (x == "2") { + continue; + } + if (x == "2") { + continue l00; + } + } + + l1: + for (let x = 0; x < 1; ++x) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l1; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l1; + } + } + + l2: + while (1 === 1) { + let x; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l2; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l2; + } + } + + l3: + do { + let x; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l3; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l3; + } + } while (1 === 1) + + l4: + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l4; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l4; + } + } + + l5: + for (let x = 0, y = 1; x < 1; ++x) { + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l5; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l5; + } + } + + l6: + while (1 === 1) { + let x, y; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l6; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l6; + } + + } + + l7: + do { + let x, y; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l7; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l7; + } + } while (1 === 1) + + l8: + for (let y = 0; y < 1; ++y) { + let x = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l8; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l8; + } + } + + //===const + l0_c: + for (const x of []) { + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l0_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l0_c; + } + } + + l00_c: + for (const x in []) { + (function() { return x}); + (() => x); + if (x == "1") { + break; + } + if (x == "1") { + break l00_c; + } + if (x == "2") { + continue; + } + if (x == "2") { + continue l00_c; + } + } + + l1_c: + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x}); + (() => x); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break l1_c; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l1_c; + } + } + + l2_c: + while (1 === 1) { + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l2_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l2_c; + } + } + + l3_c: + do { + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l3_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l3_c; + } + } while (1 === 1) + + l4_c: + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x}); + (() => x); + if (x == 1) { + break; + } + if (x == 1) { + break l4_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l4_c; + } + } + + l5_c: + for (const x = 0, y = 1; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x + y}); + (() => x + y); + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break l5_c; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l5_c; + } + } + + l6_c: + while (1 === 1) { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l6_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l6_c; + } + + } + + l7_c: + do { + const x = 1, y = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l7_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l7_c; + } + } while (1 === 1) + + l8_c: + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + const x = 1; + (function() { return x + y}); + (() => x + y); + if (x == 1) { + break; + } + if (x == 1) { + break l8_c; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l8_c; + } + } \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop8.errors.txt b/tests/baselines/reference/capturedLetConstInLoop8.errors.txt new file mode 100644 index 00000000000..c3743feaf90 --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop8.errors.txt @@ -0,0 +1,186 @@ +tests/cases/compiler/capturedLetConstInLoop8.ts(66,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(68,27): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(70,31): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(73,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(76,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(79,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(82,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(86,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8.ts(89,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8.ts(92,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8.ts(95,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8.ts(98,21): error TS2365: Operator '==' cannot be applied to types '0' and '3'. +tests/cases/compiler/capturedLetConstInLoop8.ts(102,17): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(105,17): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8.ts(108,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8.ts(111,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8.ts(114,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8.ts(117,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8.ts(120,17): error TS2365: Operator '==' cannot be applied to types '0' and '3'. + + +==== tests/cases/compiler/capturedLetConstInLoop8.ts (19 errors) ==== + function foo() { + l0: + for (let z = 0; z < 1; ++z) { + l1: + for (let x = 0; x < 1; ++x) { + ll1: + for (let y = 0; y < 1; ++y) { + (function() { return x + y }); + (() => x + y); + if (y == 1) { + break; + } + if (y == 1) { + break l1; + } + if (y == 1) { + break ll1; + } + if (y == 1) { + continue l0; + } + + if (x == 2) { + continue; + } + if (x == 2) { + continue l1; + } + if (x == 2) { + continue ll1; + } + if (x == 2) { + return "123" + } + if (x == 3) { + return; + } + } + if (x == 1) { + break; + } + if (x == 1) { + break l1; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l1; + } + if (x == 2) { + continue l0; + } + if (x == 2) { + return "456"; + } + if (x == 3) { + return; + } + } + } + } + + function foo_c() { + l0: + for (const z = 0; z < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + l1: + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + ll1: + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x + y }); + (() => x + y); + if (y == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (y == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break l1; + } + if (y == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break ll1; + } + if (y == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + continue l0; + } + + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l1; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue ll1; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + return "123" + } + if (x == 3) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '3'. + return; + } + } + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break l1; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l1; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l0; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + return "456"; + } + if (x == 3) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '3'. + return; + } + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt b/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt new file mode 100644 index 00000000000..da6947884fa --- /dev/null +++ b/tests/baselines/reference/capturedLetConstInLoop8_ES6.errors.txt @@ -0,0 +1,186 @@ +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(66,23): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(68,27): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(70,31): error TS2365: Operator '<' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(73,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(76,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(79,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(82,21): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(86,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(89,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(92,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(95,21): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(98,21): error TS2365: Operator '==' cannot be applied to types '0' and '3'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(102,17): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(105,17): error TS2365: Operator '==' cannot be applied to types '0' and '1'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(108,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(111,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(114,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(117,17): error TS2365: Operator '==' cannot be applied to types '0' and '2'. +tests/cases/compiler/capturedLetConstInLoop8_ES6.ts(120,17): error TS2365: Operator '==' cannot be applied to types '0' and '3'. + + +==== tests/cases/compiler/capturedLetConstInLoop8_ES6.ts (19 errors) ==== + function foo() { + l0: + for (let z = 0; z < 1; ++z) { + l1: + for (let x = 0; x < 1; ++x) { + ll1: + for (let y = 0; y < 1; ++y) { + (function() { return x + y }); + (() => x + y); + if (y == 1) { + break; + } + if (y == 1) { + break l1; + } + if (y == 1) { + break ll1; + } + if (y == 1) { + continue l0; + } + + if (x == 2) { + continue; + } + if (x == 2) { + continue l1; + } + if (x == 2) { + continue ll1; + } + if (x == 2) { + return "123" + } + if (x == 3) { + return; + } + } + if (x == 1) { + break; + } + if (x == 1) { + break l1; + } + if (x == 2) { + continue; + } + if (x == 2) { + continue l1; + } + if (x == 2) { + continue l0; + } + if (x == 2) { + return "456"; + } + if (x == 3) { + return; + } + } + } + } + + function foo_c() { + l0: + for (const z = 0; z < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + l1: + for (const x = 0; x < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + ll1: + for (const y = 0; y < 1;) { + ~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. + (function() { return x + y }); + (() => x + y); + if (y == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (y == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break l1; + } + if (y == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break ll1; + } + if (y == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + continue l0; + } + + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l1; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue ll1; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + return "123" + } + if (x == 3) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '3'. + return; + } + } + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break; + } + if (x == 1) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '1'. + break l1; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l1; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + continue l0; + } + if (x == 2) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '2'. + return "456"; + } + if (x == 3) { + ~~~~~~ +!!! error TS2365: Operator '==' cannot be applied to types '0' and '3'. + return; + } + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/capturedLetConstInLoop9.types b/tests/baselines/reference/capturedLetConstInLoop9.types index 9f1bab20148..486697b8d84 100644 --- a/tests/baselines/reference/capturedLetConstInLoop9.types +++ b/tests/baselines/reference/capturedLetConstInLoop9.types @@ -1,10 +1,10 @@ === tests/cases/compiler/capturedLetConstInLoop9.ts === for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -78,7 +78,7 @@ for (let x = 0; x < 1; ++x) { return x + 1; >x + 1 : any >x : any ->1 : number +>1 : 1 } } } @@ -88,7 +88,7 @@ declare function use(a: any); >a : any function foo() { ->foo : () => number +>foo : () => 50 | 100 l0: >l0 : any @@ -125,9 +125,9 @@ function foo() { >[{x:1, y:2}] : [{ x: number; y: number; }] >{x:1, y:2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 if (b === 1) { >b === 1 : boolean @@ -160,7 +160,7 @@ function foo() { } return 50; ->50 : number +>50 : 50 } for (let b of []) { @@ -174,7 +174,7 @@ function foo() { >[{x1:1, y:arguments.length}] : [{ x1: number; y: number; }] >{x1:1, y:arguments.length} : { x1: number; y: number; } >x1 : number ->1 : number +>1 : 1 >y : number >arguments.length : number >arguments : IArguments @@ -202,7 +202,7 @@ function foo() { >b : any return 100; ->100 : number +>100 : 100 } @@ -307,10 +307,10 @@ class C { for (let i = 0; i < 100; i++) { >i : number ->0 : number +>0 : 0 >i < 100 : boolean >i : number ->100 : number +>100 : 100 >i++ : number >i : number diff --git a/tests/baselines/reference/capturedLetConstInLoop9_ES6.types b/tests/baselines/reference/capturedLetConstInLoop9_ES6.types index 8a4adafe340..be4457315ee 100644 --- a/tests/baselines/reference/capturedLetConstInLoop9_ES6.types +++ b/tests/baselines/reference/capturedLetConstInLoop9_ES6.types @@ -2,10 +2,10 @@ for (let x = 0; x < 1; ++x) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 >++x : number >x : number @@ -79,7 +79,7 @@ for (let x = 0; x < 1; ++x) { return x + 1; >x + 1 : any >x : any ->1 : number +>1 : 1 } } } @@ -89,7 +89,7 @@ declare function use(a: any); >a : any function foo() { ->foo : () => number +>foo : () => 50 | 100 l0: >l0 : any @@ -126,9 +126,9 @@ function foo() { >[{x:1, y:2}] : [{ x: number; y: number; }] >{x:1, y:2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 if (b === 1) { >b === 1 : boolean @@ -161,7 +161,7 @@ function foo() { } return 50; ->50 : number +>50 : 50 } for (let b of []) { @@ -175,7 +175,7 @@ function foo() { >[{x1:1, y:arguments.length}] : [{ x1: number; y: number; }] >{x1:1, y:arguments.length} : { x1: number; y: number; } >x1 : number ->1 : number +>1 : 1 >y : number >arguments.length : number >arguments : IArguments @@ -202,7 +202,7 @@ function foo() { >b : any return 100; ->100 : number +>100 : 100 } @@ -307,10 +307,10 @@ class C { for (let i = 0; i < 100; i++) { >i : number ->0 : number +>0 : 0 >i < 100 : boolean >i : number ->100 : number +>100 : 100 >i++ : number >i : number diff --git a/tests/baselines/reference/capturedParametersInInitializers1.types b/tests/baselines/reference/capturedParametersInInitializers1.types index 493c608c145..9e5dee1b82e 100644 --- a/tests/baselines/reference/capturedParametersInInitializers1.types +++ b/tests/baselines/reference/capturedParametersInInitializers1.types @@ -7,7 +7,7 @@ function foo1(y = class {c = x}, x = 1) { >c : number >x : number >x : number ->1 : number +>1 : 1 new y().c; >new y().c : number @@ -24,7 +24,7 @@ function foo2(y = function(x: typeof z) {}, z = 1) { >x : number >z : number >z : number ->1 : number +>1 : 1 } @@ -41,6 +41,6 @@ function foo3(y = { x: a }, z = 1) { >z : number >a : any >z : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/castExpressionParentheses.types b/tests/baselines/reference/castExpressionParentheses.types index cdfbf4f7db2..dafe3377aea 100644 --- a/tests/baselines/reference/castExpressionParentheses.types +++ b/tests/baselines/reference/castExpressionParentheses.types @@ -9,49 +9,49 @@ declare var a; >{a:0} : any >{a:0} : { a: number; } >a : number ->0 : number +>0 : 0 ([1,3,]); >([1,3,]) : any >[1,3,] : any >[1,3,] : number[] ->1 : number ->3 : number +>1 : 1 +>3 : 3 ("string"); >("string") : any >"string" : any ->"string" : string +>"string" : "string" (23.0); >(23.0) : any >23.0 : any ->23.0 : number +>23.0 : 23 (1); >(1) : any >1 : any ->1 : number +>1 : 1 (1.); >(1.) : any >1. : any ->1. : number +>1. : 1 (1.0); >(1.0) : any >1.0 : any ->1.0 : number +>1.0 : 1 (12e+34); >(12e+34) : any >12e+34 : any ->12e+34 : number +>12e+34 : 1.2e+35 (0xff); >(0xff) : any >0xff : any ->0xff : number +>0xff : 255 (/regexp/g); >(/regexp/g) : any @@ -61,12 +61,12 @@ declare var a; (false); >(false) : any >false : any ->false : boolean +>false : false (true); >(true) : any >true : any ->true : boolean +>true : true (null); >(null) : any @@ -106,7 +106,7 @@ declare var a; >a[0] : any >a[0] : any >a : any ->0 : number +>0 : 0 (a.b["0"]); >(a.b["0"]) : any @@ -115,7 +115,7 @@ declare var a; >a.b : any >a : any >b : any ->"0" : string +>"0" : "0" (a()).x; >(a()).x : any @@ -133,42 +133,42 @@ declare var A; >(1).foo : any >(1) : any >1 : any ->1 : number +>1 : 1 >foo : any (1.).foo; >(1.).foo : any >(1.) : any >1. : any ->1. : number +>1. : 1 >foo : any (1.0).foo; >(1.0).foo : any >(1.0) : any >1.0 : any ->1.0 : number +>1.0 : 1 >foo : any (12e+34).foo; >(12e+34).foo : any >(12e+34) : any >12e+34 : any ->12e+34 : number +>12e+34 : 1.2e+35 >foo : any (0xff).foo; >(0xff).foo : any >(0xff) : any >0xff : any ->0xff : number +>0xff : 255 >foo : any ((1.0)); >((1.0)) : any >(1.0) : any ->(1.0) : number ->1.0 : number +>(1.0) : 1 +>1.0 : 1 (new A).foo; >(new A).foo : any diff --git a/tests/baselines/reference/castOfAwait.types b/tests/baselines/reference/castOfAwait.types index ad3597f6c01..30220ca2ab6 100644 --- a/tests/baselines/reference/castOfAwait.types +++ b/tests/baselines/reference/castOfAwait.types @@ -4,18 +4,18 @@ async function f() { await 0; > await 0 : number ->await 0 : number ->0 : number +>await 0 : 0 +>0 : 0 typeof await 0; >typeof await 0 : string ->await 0 : number ->0 : number +>await 0 : 0 +>0 : 0 void await 0; >void await 0 : undefined ->await 0 : number ->0 : number +>await 0 : 0 +>0 : 0 await void typeof void await 0; >await void typeof void await 0 : any @@ -24,12 +24,12 @@ async function f() { >typeof void await 0 : string > void await 0 : number >void await 0 : undefined ->await 0 : number ->0 : number +>await 0 : 0 +>0 : 0 await await 0; ->await await 0 : number ->await 0 : number ->0 : number +>await await 0 : 0 +>await 0 : 0 +>0 : 0 } diff --git a/tests/baselines/reference/castTest.types b/tests/baselines/reference/castTest.types index 03e119d17ed..666b2ccf78e 100644 --- a/tests/baselines/reference/castTest.types +++ b/tests/baselines/reference/castTest.types @@ -2,7 +2,7 @@ var x : any = 0; >x : any ->0 : number +>0 : 0 var z = x; >z : number @@ -18,7 +18,7 @@ var y = x + z; var a = 0; >a : any >0 : any ->0 : number +>0 : 0 var b = true; >b : boolean @@ -28,7 +28,7 @@ var b = true; var s = ""; >s : string >"" : string ->"" : string +>"" : "" var ar = null; >ar : any[] @@ -76,11 +76,11 @@ var p_cast = ({ x: 0, >x : number ->0 : number +>0 : 0 y: 0, >y : number ->0 : number +>0 : 0 add: function(dx, dy) { >add : (dx: number, dy: number) => Point diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt index 8f5924586df..56f4cad5a47 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.errors.txt @@ -2,9 +2,9 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete Type 'T' is not assignable to type 'S'. tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(10,29): error TS2345: Argument of type '(ss: S) => T' is not assignable to parameter of type '(x: S) => S'. Type 'T' is not assignable to type 'S'. -tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(32,9): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(32,9): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(36,9): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts(37,9): error TS2322: Type '""' is not assignable to type 'number'. ==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.ts (5 errors) ==== @@ -47,16 +47,16 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete // Should get an error that we are assigning a string to a number (new Chain2(i)).then(ii => t).then(tt => s).value.x = ""; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. // Staying at T or S should keep the constraint. // Get an error when we assign a string to a number in both cases (new Chain2(i)).then(ii => t).then(tt => t).then(tt => t).then(tt => t).value.x = ""; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. (new Chain2(i)).then(ii => s).then(ss => s).then(ss => s).then(ss => s).value.x = ""; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. return null; } diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types index d734b0c6ad0..85a1af6fbdc 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing1.types @@ -18,11 +18,11 @@ class Derived extends Based { >this : this this.x = 10; ->this.x = 10 : number +>this.x = 10 : 10 >this.x : number >this : this >x : number ->10 : number +>10 : 10 var that = this; >that : this diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types index a26ca2a6d79..60179ec27bf 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing3.types @@ -30,11 +30,11 @@ class Derived extends Based { >super : typeof Based this.x = 10; ->this.x = 10 : number +>this.x = 10 : 10 >this.x : number >this : this >x : number ->10 : number +>10 : 10 var that = this; >that : this diff --git a/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types b/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types index f42a0ac8563..b2bf4824721 100644 --- a/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types +++ b/tests/baselines/reference/checkSuperCallBeforeThisAccessing4.types @@ -43,11 +43,11 @@ class Derived extends Based { >super : typeof Based this.x = 10; ->this.x = 10 : number +>this.x = 10 : 10 >this.x : number >this : this >x : number ->10 : number +>10 : 10 var that = this; >that : this diff --git a/tests/baselines/reference/circularObjectLiteralAccessors.types b/tests/baselines/reference/circularObjectLiteralAccessors.types index 1f01432db5a..e190ea5e6d3 100644 --- a/tests/baselines/reference/circularObjectLiteralAccessors.types +++ b/tests/baselines/reference/circularObjectLiteralAccessors.types @@ -33,6 +33,6 @@ const a = { }, foo: '' >foo : string ->'' : string +>'' : "" }; diff --git a/tests/baselines/reference/classAbstractAsIdentifier.types b/tests/baselines/reference/classAbstractAsIdentifier.types index e2894af804d..63f15dc4a4c 100644 --- a/tests/baselines/reference/classAbstractAsIdentifier.types +++ b/tests/baselines/reference/classAbstractAsIdentifier.types @@ -4,7 +4,7 @@ class abstract { foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } new abstract; diff --git a/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.errors.txt b/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.errors.txt index c6c242396d8..fbcc597409a 100644 --- a/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.errors.txt +++ b/tests/baselines/reference/classAbstractAssignabilityConstructorFunction.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts(7,1): error TS2322: Type 'typeof A' is not assignable to type 'new () => A'. Cannot assign an abstract constructor type to a non-abstract constructor type. -tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts(8,1): error TS2322: Type 'string' is not assignable to type 'new () => A'. +tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts(8,1): error TS2322: Type '"asdf"' is not assignable to type 'new () => A'. ==== tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAssignabilityConstructorFunction.ts (2 errors) ==== @@ -16,4 +16,4 @@ tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbst !!! error TS2322: Cannot assign an abstract constructor type to a non-abstract constructor type. AAA = "asdf"; ~~~ -!!! error TS2322: Type 'string' is not assignable to type 'new () => A'. \ No newline at end of file +!!! error TS2322: Type '"asdf"' is not assignable to type 'new () => A'. \ No newline at end of file diff --git a/tests/baselines/reference/classAppearsToHaveMembersOfObject.types b/tests/baselines/reference/classAppearsToHaveMembersOfObject.types index 65c37e7dfeb..9c87fa18ecd 100644 --- a/tests/baselines/reference/classAppearsToHaveMembersOfObject.types +++ b/tests/baselines/reference/classAppearsToHaveMembersOfObject.types @@ -20,7 +20,7 @@ var r2 = c.hasOwnProperty(''); >c.hasOwnProperty : (v: string) => boolean >c : C >hasOwnProperty : (v: string) => boolean ->'' : string +>'' : "" var o: Object = c; >o : Object diff --git a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types index 11fcac506b6..728a201d79e 100644 --- a/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types +++ b/tests/baselines/reference/classDeclarationMergedInModuleWithContinuation.types @@ -10,7 +10,7 @@ module M { export var v = 0; >v : number ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types index 529be3c6635..5ac20c6e0fa 100644 --- a/tests/baselines/reference/classDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/classDoesNotDependOnBaseTypes.types @@ -10,17 +10,17 @@ if (typeof x !== "string") { >"string" : "string" x[0] = ""; ->x[0] = "" : string +>x[0] = "" : "" >x[0] : StringTree >x : StringTreeCollection ->0 : number ->"" : string +>0 : 0 +>"" : "" x[0] = new StringTreeCollection; >x[0] = new StringTreeCollection : StringTreeCollection >x[0] : StringTree >x : StringTreeCollection ->0 : number +>0 : 0 >new StringTreeCollection : StringTreeCollection >StringTreeCollection : typeof StringTreeCollection } diff --git a/tests/baselines/reference/classExpression5.types b/tests/baselines/reference/classExpression5.types index 25c4b66b8f3..cf207c1cb0b 100644 --- a/tests/baselines/reference/classExpression5.types +++ b/tests/baselines/reference/classExpression5.types @@ -9,7 +9,7 @@ new class { >hi : () => string return "Hi!"; ->"Hi!" : string +>"Hi!" : "Hi!" } }().hi(); >hi : () => string diff --git a/tests/baselines/reference/classExpressionWithStaticProperties1.types b/tests/baselines/reference/classExpressionWithStaticProperties1.types index b014f78abf7..875cb2ae21f 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties1.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties1.types @@ -4,7 +4,7 @@ var v = class C { static a = 1; static b = 2 }; >class C { static a = 1; static b = 2 } : typeof C >C : typeof C >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/classExpressionWithStaticProperties2.types b/tests/baselines/reference/classExpressionWithStaticProperties2.types index 9bfd6732350..7ce74a80bcb 100644 --- a/tests/baselines/reference/classExpressionWithStaticProperties2.types +++ b/tests/baselines/reference/classExpressionWithStaticProperties2.types @@ -4,6 +4,6 @@ var v = class C { static a = 1; static b }; >class C { static a = 1; static b } : typeof C >C : typeof C >a : number ->1 : number +>1 : 1 >b : any diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types index 0ba6ada4131..62f29b64361 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES61.types @@ -6,11 +6,11 @@ var v = class C { static a = 1; >a : number ->1 : number +>1 : 1 static b = 2; >b : number ->2 : number +>2 : 2 static c = C.a + 3; >c : number @@ -18,6 +18,6 @@ var v = class C { >C.a : number >C : typeof C >a : number ->3 : number +>3 : 3 }; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types index 97d6940a3fc..0c448d73ede 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES62.types @@ -6,7 +6,7 @@ var v = class C { static a = 1; >a : number ->1 : number +>1 : 1 static b >b : any @@ -17,7 +17,7 @@ var v = class C { x: "hi" >x : string ->"hi" : string +>"hi" : "hi" } static d = C.c.x + " world"; >d : string @@ -27,6 +27,6 @@ var v = class C { >C : typeof C >c : { x: string; } >x : string ->" world" : string +>" world" : " world" }; diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types index 92f14f3f65f..3bc780785aa 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES63.types @@ -10,10 +10,10 @@ const arr: {y(): number}[] = []; for (let i = 0; i < 3; i++) { >i : number ->0 : number +>0 : 0 >i < 3 : boolean >i : number ->3 : number +>3 : 3 >i++ : number >i : number @@ -36,7 +36,7 @@ for (let i = 0; i < 3; i++) { >C.x : number >C : typeof C >x : number ->2 : number +>2 : 2 }); } diff --git a/tests/baselines/reference/classExpressionWithStaticPropertiesES64.types b/tests/baselines/reference/classExpressionWithStaticPropertiesES64.types index f48ec6fdde6..0f76461bb71 100644 --- a/tests/baselines/reference/classExpressionWithStaticPropertiesES64.types +++ b/tests/baselines/reference/classExpressionWithStaticPropertiesES64.types @@ -3,5 +3,5 @@ >(class { static x = 0; }) : typeof (Anonymous class) >class { static x = 0; } : typeof (Anonymous class) >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/classExtendingClass.types b/tests/baselines/reference/classExtendingClass.types index f91493e97fd..3c03fb1837a 100644 --- a/tests/baselines/reference/classExtendingClass.types +++ b/tests/baselines/reference/classExtendingClass.types @@ -102,7 +102,7 @@ var r7 = d2.thing(''); >d2.thing : (x: string) => void >d2 : D2 >thing : (x: string) => void ->'' : string +>'' : "" var r8 = D2.other(1); >r8 : void @@ -110,5 +110,5 @@ var r8 = D2.other(1); >D2.other : (x: T) => void >D2 : typeof D2 >other : (x: T) => void ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/classExtendingNonConstructor.errors.txt b/tests/baselines/reference/classExtendingNonConstructor.errors.txt index 17b3610d252..b2c5ce4955a 100644 --- a/tests/baselines/reference/classExtendingNonConstructor.errors.txt +++ b/tests/baselines/reference/classExtendingNonConstructor.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(7,18): error TS2507: Type 'undefined' is not a constructor function type. -tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(8,18): error TS2507: Type 'boolean' is not a constructor function type. -tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(9,18): error TS2507: Type 'boolean' is not a constructor function type. -tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(10,18): error TS2507: Type 'number' is not a constructor function type. -tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(11,18): error TS2507: Type 'string' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(8,18): error TS2507: Type 'true' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(9,18): error TS2507: Type 'false' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(10,18): error TS2507: Type '42' is not a constructor function type. +tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(11,18): error TS2507: Type '"hello"' is not a constructor function type. tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(12,18): error TS2507: Type '{}' is not a constructor function type. tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.ts(13,18): error TS2507: Type '() => void' is not a constructor function type. @@ -19,16 +19,16 @@ tests/cases/conformance/classes/classDeclarations/classExtendingNonConstructor.t !!! error TS2507: Type 'undefined' is not a constructor function type. class C2 extends true { } ~~~~ -!!! error TS2507: Type 'boolean' is not a constructor function type. +!!! error TS2507: Type 'true' is not a constructor function type. class C3 extends false { } ~~~~~ -!!! error TS2507: Type 'boolean' is not a constructor function type. +!!! error TS2507: Type 'false' is not a constructor function type. class C4 extends 42 { } ~~ -!!! error TS2507: Type 'number' is not a constructor function type. +!!! error TS2507: Type '42' is not a constructor function type. class C5 extends "hello" { } ~~~~~~~ -!!! error TS2507: Type 'string' is not a constructor function type. +!!! error TS2507: Type '"hello"' is not a constructor function type. class C6 extends x { } ~ !!! error TS2507: Type '{}' is not a constructor function type. diff --git a/tests/baselines/reference/classImplementsClass3.types b/tests/baselines/reference/classImplementsClass3.types index 6f97a96a56e..266ff33e29b 100644 --- a/tests/baselines/reference/classImplementsClass3.types +++ b/tests/baselines/reference/classImplementsClass3.types @@ -2,7 +2,7 @@ class A { foo(): number { return 1; } } >A : A >foo : () => number ->1 : number +>1 : 1 class C implements A { >C : C @@ -12,7 +12,7 @@ class C implements A { >foo : () => number return 1; ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/classMemberInitializerScoping.errors.txt b/tests/baselines/reference/classMemberInitializerScoping.errors.txt index dddc7a82a3f..d6625b3d1f8 100644 --- a/tests/baselines/reference/classMemberInitializerScoping.errors.txt +++ b/tests/baselines/reference/classMemberInitializerScoping.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/classMemberInitializerScoping.ts(3,17): error TS2301: Initializer of instance member variable 'y' cannot reference identifier 'aaa' declared in the constructor. -tests/cases/compiler/classMemberInitializerScoping.ts(6,9): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/classMemberInitializerScoping.ts(6,9): error TS2322: Type '""' is not assignable to type 'number'. ==== tests/cases/compiler/classMemberInitializerScoping.ts (2 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/classMemberInitializerScoping.ts(6,9): error TS2322: Type ' constructor(aaa) { this.y = ''; // was: error, cannot assign string to number ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. } } diff --git a/tests/baselines/reference/classStaticPropertyTypeGuard.types b/tests/baselines/reference/classStaticPropertyTypeGuard.types index f89854c919d..f9bf8b68062 100644 --- a/tests/baselines/reference/classStaticPropertyTypeGuard.types +++ b/tests/baselines/reference/classStaticPropertyTypeGuard.types @@ -22,10 +22,10 @@ class A { >_a : string } return A._a = 'helloworld'; ->A._a = 'helloworld' : string +>A._a = 'helloworld' : "helloworld" >A._a : string | undefined >A : typeof A >_a : string | undefined ->'helloworld' : string +>'helloworld' : "helloworld" } } diff --git a/tests/baselines/reference/classWithEmptyBody.types b/tests/baselines/reference/classWithEmptyBody.types index 1ac111796e8..acb038a72a2 100644 --- a/tests/baselines/reference/classWithEmptyBody.types +++ b/tests/baselines/reference/classWithEmptyBody.types @@ -12,16 +12,16 @@ var o: {} = c; >c : C c = 1; ->c = 1 : number +>c = 1 : 1 >c : C ->1 : number +>1 : 1 c = { foo: '' } >c = { foo: '' } : { foo: string; } >c : C >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" c = () => { } >c = () => { } : () => void @@ -33,7 +33,7 @@ class D { constructor() { return 1; ->1 : number +>1 : 1 } } @@ -46,16 +46,16 @@ var o: {} = d; >d : D d = 1; ->d = 1 : number +>d = 1 : 1 >d : D ->1 : number +>1 : 1 d = { foo: '' } >d = { foo: '' } : { foo: string; } >d : D >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" d = () => { } >d = () => { } : () => void diff --git a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.types b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.types index 94460dfdeaf..272ba94f7f2 100644 --- a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.types +++ b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface.types @@ -14,7 +14,7 @@ class C { public get z() { return 1; } >z : number ->1 : number +>1 : 1 public set z(v) { } >z : number diff --git a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.types b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.types index b359713f292..22440da1768 100644 --- a/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.types +++ b/tests/baselines/reference/classWithOnlyPublicMembersEquivalentToInterface2.types @@ -14,7 +14,7 @@ class C { public get z() { return 1; } >z : number ->1 : number +>1 : 1 public set z(v) { } >z : number diff --git a/tests/baselines/reference/classWithProtectedProperty.types b/tests/baselines/reference/classWithProtectedProperty.types index 1f53ea2aad9..079c749c377 100644 --- a/tests/baselines/reference/classWithProtectedProperty.types +++ b/tests/baselines/reference/classWithProtectedProperty.types @@ -9,32 +9,32 @@ class C { protected a = ''; >a : string ->'' : string +>'' : "" protected b: string = ''; >b : string ->'' : string +>'' : "" protected c() { return '' } >c : () => string ->'' : string +>'' : "" protected d = () => ''; >d : () => string >() => '' : () => string ->'' : string +>'' : "" protected static e; >e : any protected static f() { return '' } >f : () => string ->'' : string +>'' : "" protected static g = () => ''; >g : () => string >() => '' : () => string ->'' : string +>'' : "" } class D extends C { diff --git a/tests/baselines/reference/classWithPublicProperty.types b/tests/baselines/reference/classWithPublicProperty.types index 09d3c0668d1..1ea0c2920e4 100644 --- a/tests/baselines/reference/classWithPublicProperty.types +++ b/tests/baselines/reference/classWithPublicProperty.types @@ -7,32 +7,32 @@ class C { public a = ''; >a : string ->'' : string +>'' : "" public b: string = ''; >b : string ->'' : string +>'' : "" public c() { return '' } >c : () => string ->'' : string +>'' : "" public d = () => ''; >d : () => string >() => '' : () => string ->'' : string +>'' : "" public static e; >e : any public static f() { return '' } >f : () => string ->'' : string +>'' : "" public static g = () => ''; >g : () => string >() => '' : () => string ->'' : string +>'' : "" } // all of these are valid diff --git a/tests/baselines/reference/classdecl.types b/tests/baselines/reference/classdecl.types index 63398736563..82b2bba8bfb 100644 --- a/tests/baselines/reference/classdecl.types +++ b/tests/baselines/reference/classdecl.types @@ -24,7 +24,7 @@ class a { >d : number return 30; ->30 : number +>30 : 30 } public set d(a: number) { >d : number @@ -37,9 +37,9 @@ class a { return { x: 30, y: 40 }; >{ x: 30, y: 40 } : { x: number; y: number; } >x : number ->30 : number +>30 : 30 >y : number ->40 : number +>40 : 40 } private static d2() { @@ -49,7 +49,7 @@ class a { >p3 : string return "string"; ->"string" : string +>"string" : "string" } private pv3; >pv3 : any diff --git a/tests/baselines/reference/cloduleAcrossModuleDefinitions.types b/tests/baselines/reference/cloduleAcrossModuleDefinitions.types index 53ef8392774..2e46dc73e17 100644 --- a/tests/baselines/reference/cloduleAcrossModuleDefinitions.types +++ b/tests/baselines/reference/cloduleAcrossModuleDefinitions.types @@ -21,7 +21,7 @@ module A { export var x = 1; >x : number ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/cloduleTest1.types b/tests/baselines/reference/cloduleTest1.types index 67c1fd6120f..059329a3d8a 100644 --- a/tests/baselines/reference/cloduleTest1.types +++ b/tests/baselines/reference/cloduleTest1.types @@ -30,7 +30,7 @@ >$('.foo').addClass : (className: string) => $ >$('.foo') : $ >$ : typeof $ ->'.foo' : string +>'.foo' : ".foo" >addClass : (className: string) => $ ->'bar' : string +>'bar' : "bar" diff --git a/tests/baselines/reference/collisionCodeGenModuleWithConstructorChildren.types b/tests/baselines/reference/collisionCodeGenModuleWithConstructorChildren.types index 9c6fbac1539..e951a2dbcc6 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithConstructorChildren.types +++ b/tests/baselines/reference/collisionCodeGenModuleWithConstructorChildren.types @@ -4,7 +4,7 @@ module M { export var x = 3; >x : number ->3 : number +>3 : 3 class c { >c : c @@ -40,7 +40,7 @@ module M { constructor() { var M = 10; >M : number ->10 : number +>10 : 10 var p = x; >p : number diff --git a/tests/baselines/reference/collisionCodeGenModuleWithFunctionChildren.types b/tests/baselines/reference/collisionCodeGenModuleWithFunctionChildren.types index 5c99bc7b40b..6879c6bf3d8 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithFunctionChildren.types +++ b/tests/baselines/reference/collisionCodeGenModuleWithFunctionChildren.types @@ -4,7 +4,7 @@ module M { export var x = 3; >x : number ->3 : number +>3 : 3 function fn(M, p = x) { } >fn : (M: any, p?: number) => void diff --git a/tests/baselines/reference/collisionCodeGenModuleWithMemberVariable.types b/tests/baselines/reference/collisionCodeGenModuleWithMemberVariable.types index 651ba5344ad..959a45ab372 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithMemberVariable.types +++ b/tests/baselines/reference/collisionCodeGenModuleWithMemberVariable.types @@ -4,7 +4,7 @@ module m1 { export var m1 = 10; >m1 : number ->10 : number +>10 : 10 var b = m1; >b : number diff --git a/tests/baselines/reference/collisionCodeGenModuleWithMethodChildren.types b/tests/baselines/reference/collisionCodeGenModuleWithMethodChildren.types index e7c6d9021eb..77d813e1081 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithMethodChildren.types +++ b/tests/baselines/reference/collisionCodeGenModuleWithMethodChildren.types @@ -4,7 +4,7 @@ module M { export var x = 3; >x : number ->3 : number +>3 : 3 class c { >c : c diff --git a/tests/baselines/reference/collisionCodeGenModuleWithModuleChildren.types b/tests/baselines/reference/collisionCodeGenModuleWithModuleChildren.types index 4ffaf6dad04..ddf5faee5f0 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithModuleChildren.types +++ b/tests/baselines/reference/collisionCodeGenModuleWithModuleChildren.types @@ -4,14 +4,14 @@ module M { export var x = 3; >x : number ->3 : number +>3 : 3 module m1 { >m1 : typeof m1 var M = 10; >M : number ->10 : number +>10 : 10 var p = x; >p : number diff --git a/tests/baselines/reference/collisionCodeGenModuleWithModuleReopening.types b/tests/baselines/reference/collisionCodeGenModuleWithModuleReopening.types index b71eeb621d0..2f8c05f2357 100644 --- a/tests/baselines/reference/collisionCodeGenModuleWithModuleReopening.types +++ b/tests/baselines/reference/collisionCodeGenModuleWithModuleReopening.types @@ -44,7 +44,7 @@ module m2 { } export var b10 = 10; >b10 : number ->10 : number +>10 : 10 var x = new c1(); >x : c1 diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientClass.types b/tests/baselines/reference/collisionExportsRequireAndAmbientClass.types index 0db9958d533..cdee6af63a9 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientClass.types +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientClass.types @@ -54,5 +54,5 @@ module m4 { } var a = 10; >a : number ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientFunction.types b/tests/baselines/reference/collisionExportsRequireAndAmbientFunction.types index 76210f7dda0..98f2f71c20e 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientFunction.types +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientFunction.types @@ -25,5 +25,5 @@ module m2 { var a = 10; >a : number ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientFunctionInGlobalFile.types b/tests/baselines/reference/collisionExportsRequireAndAmbientFunctionInGlobalFile.types index 9804380fd7a..a2c3e1d8cd3 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientFunctionInGlobalFile.types +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientFunctionInGlobalFile.types @@ -25,5 +25,5 @@ module m4 { var a = 10; >a : number ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientModule.types b/tests/baselines/reference/collisionExportsRequireAndAmbientModule.types index 1c4c56de99c..fbf41e94837 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientModule.types +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientModule.types @@ -84,7 +84,7 @@ module m2 { } var a = 10; >a : number ->10 : number +>10 : 10 } === tests/cases/compiler/collisionExportsRequireAndAmbientModule_globalFile.ts === @@ -158,6 +158,6 @@ module m4 { var a = 10; >a : number ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/collisionExportsRequireAndAmbientVar.types b/tests/baselines/reference/collisionExportsRequireAndAmbientVar.types index 90a9b8968e5..d88a7b5e04e 100644 --- a/tests/baselines/reference/collisionExportsRequireAndAmbientVar.types +++ b/tests/baselines/reference/collisionExportsRequireAndAmbientVar.types @@ -25,7 +25,7 @@ module m2 { var a = 10; >a : number ->10 : number +>10 : 10 } === tests/cases/compiler/collisionExportsRequireAndAmbientVar_globalFile.ts === @@ -55,5 +55,5 @@ module m4 { var a = 10; >a : number ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/collisionExportsRequireAndFunctionInGlobalFile.types b/tests/baselines/reference/collisionExportsRequireAndFunctionInGlobalFile.types index 3cc08359508..8d520ec186a 100644 --- a/tests/baselines/reference/collisionExportsRequireAndFunctionInGlobalFile.types +++ b/tests/baselines/reference/collisionExportsRequireAndFunctionInGlobalFile.types @@ -3,13 +3,13 @@ function exports() { >exports : () => number return 1; ->1 : number +>1 : 1 } function require() { >require : () => string return "require"; ->"require" : string +>"require" : "require" } module m3 { >m3 : typeof m3 @@ -18,13 +18,13 @@ module m3 { >exports : () => number return 1; ->1 : number +>1 : 1 } function require() { >require : () => string return "require"; ->"require" : string +>"require" : "require" } } module m4 { @@ -34,12 +34,12 @@ module m4 { >exports : () => number return 1; ->1 : number +>1 : 1 } export function require() { >require : () => string return "require"; ->"require" : string +>"require" : "require" } } diff --git a/tests/baselines/reference/collisionRestParameterArrowFunctions.types b/tests/baselines/reference/collisionRestParameterArrowFunctions.types index dcd52e5f766..8a2b5316419 100644 --- a/tests/baselines/reference/collisionRestParameterArrowFunctions.types +++ b/tests/baselines/reference/collisionRestParameterArrowFunctions.types @@ -7,7 +7,7 @@ var f1 = (_i: number, ...restParameters) => { //_i is error var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } var f1NoError = (_i: number) => { // no error >f1NoError : (_i: number) => void @@ -16,7 +16,7 @@ var f1NoError = (_i: number) => { // no error var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } var f2 = (...restParameters) => { @@ -26,7 +26,7 @@ var f2 = (...restParameters) => { var _i = 10; // No Error >_i : number ->10 : number +>10 : 10 } var f2NoError = () => { >f2NoError : () => void @@ -34,5 +34,5 @@ var f2NoError = () => { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/collisionRestParameterClassConstructor.types b/tests/baselines/reference/collisionRestParameterClassConstructor.types index f86d6d80d21..08f87481103 100644 --- a/tests/baselines/reference/collisionRestParameterClassConstructor.types +++ b/tests/baselines/reference/collisionRestParameterClassConstructor.types @@ -9,7 +9,7 @@ class c1 { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } } class c1NoError { @@ -20,7 +20,7 @@ class c1NoError { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } } @@ -32,7 +32,7 @@ class c2 { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } } class c2NoError { @@ -41,7 +41,7 @@ class c2NoError { constructor() { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } } @@ -54,7 +54,7 @@ class c3 { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } } class c3NoError { @@ -65,7 +65,7 @@ class c3NoError { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } } diff --git a/tests/baselines/reference/collisionRestParameterClassMethod.types b/tests/baselines/reference/collisionRestParameterClassMethod.types index bc6b09dd795..c5ab80d3bd1 100644 --- a/tests/baselines/reference/collisionRestParameterClassMethod.types +++ b/tests/baselines/reference/collisionRestParameterClassMethod.types @@ -9,7 +9,7 @@ class c1 { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } public fooNoError(_i: number) { // no error >fooNoError : (_i: number) => void @@ -17,7 +17,7 @@ class c1 { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } public f4(_i: number, ...rest); // no codegen no error >f4 : { (_i: number, ...rest: any[]): any; (_i: string, ...rest: any[]): any; } @@ -95,13 +95,13 @@ class c3 { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } public fooNoError() { >fooNoError : () => void var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } } diff --git a/tests/baselines/reference/collisionRestParameterFunction.types b/tests/baselines/reference/collisionRestParameterFunction.types index d988f74c928..3de29038c25 100644 --- a/tests/baselines/reference/collisionRestParameterFunction.types +++ b/tests/baselines/reference/collisionRestParameterFunction.types @@ -7,7 +7,7 @@ function f1(_i: number, ...restParameters) { //_i is error var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } function f1NoError(_i: number) { // no error >f1NoError : (_i: number) => void @@ -15,7 +15,7 @@ function f1NoError(_i: number) { // no error var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } declare function f2(_i: number, ...restParameters); // no error - no code gen @@ -33,14 +33,14 @@ function f3(...restParameters) { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } function f3NoError() { >f3NoError : () => void var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } function f4(_i: number, ...rest); // no codegen no error diff --git a/tests/baselines/reference/collisionRestParameterFunctionExpressions.types b/tests/baselines/reference/collisionRestParameterFunctionExpressions.types index f8ca0c18ed8..c0ee39e81f2 100644 --- a/tests/baselines/reference/collisionRestParameterFunctionExpressions.types +++ b/tests/baselines/reference/collisionRestParameterFunctionExpressions.types @@ -9,7 +9,7 @@ function foo() { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } function f1NoError(_i: number) { // no error >f1NoError : (_i: number) => void @@ -17,7 +17,7 @@ function foo() { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } function f3(...restParameters) { >f3 : (...restParameters: any[]) => void @@ -25,14 +25,14 @@ function foo() { var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } function f3NoError() { >f3NoError : () => void var _i = 10; // no error >_i : number ->10 : number +>10 : 10 } function f4(_i: number, ...rest); // no codegen no error diff --git a/tests/baselines/reference/collisionRestParameterUnderscoreIUsage.types b/tests/baselines/reference/collisionRestParameterUnderscoreIUsage.types index fadc27dfa6c..8245f487915 100644 --- a/tests/baselines/reference/collisionRestParameterUnderscoreIUsage.types +++ b/tests/baselines/reference/collisionRestParameterUnderscoreIUsage.types @@ -6,7 +6,7 @@ declare var console: { log(msg?: string): void; }; var _i = "This is what I'd expect to see"; >_i : string ->"This is what I'd expect to see" : string +>"This is what I'd expect to see" : "This is what I'd expect to see" class Foo { >Foo : Foo diff --git a/tests/baselines/reference/commaOperator1.types b/tests/baselines/reference/commaOperator1.types index 8116fec8328..67011aba4b9 100644 --- a/tests/baselines/reference/commaOperator1.types +++ b/tests/baselines/reference/commaOperator1.types @@ -1,29 +1,29 @@ === tests/cases/compiler/commaOperator1.ts === var v1 = ((1, 2, 3), 4, 5, (6, 7)); >v1 : number ->((1, 2, 3), 4, 5, (6, 7)) : number ->(1, 2, 3), 4, 5, (6, 7) : number ->(1, 2, 3), 4, 5 : number ->(1, 2, 3), 4 : number ->(1, 2, 3) : number ->1, 2, 3 : number ->1, 2 : number ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number ->(6, 7) : number ->6, 7 : number ->6 : number ->7 : number +>((1, 2, 3), 4, 5, (6, 7)) : 7 +>(1, 2, 3), 4, 5, (6, 7) : 7 +>(1, 2, 3), 4, 5 : 5 +>(1, 2, 3), 4 : 4 +>(1, 2, 3) : 3 +>1, 2, 3 : 3 +>1, 2 : 2 +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>(6, 7) : 7 +>6, 7 : 7 +>6 : 6 +>7 : 7 function f1() { >f1 : () => number var a = 1; >a : number ->1 : number +>1 : 1 return a, v1, a; >a, v1, a : number diff --git a/tests/baselines/reference/commaOperatorOtherValidOperation.types b/tests/baselines/reference/commaOperatorOtherValidOperation.types index bc7bdd81157..71fc5853c9a 100644 --- a/tests/baselines/reference/commaOperatorOtherValidOperation.types +++ b/tests/baselines/reference/commaOperatorOtherValidOperation.types @@ -2,9 +2,9 @@ //Comma operator in for loop for (var i = 0, j = 10; i < j; i++, j--) >i : number ->0 : number +>0 : 0 >j : number ->10 : number +>10 : 10 >i < j : boolean >i : number >j : number @@ -31,8 +31,8 @@ var resultIsString = foo(1, "123"); >resultIsString : string >foo(1, "123") : string >foo : (x: number, y: string) => string ->1 : number ->"123" : string +>1 : 1 +>"123" : "123" //TypeParameters function foo1() diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandAnyType.types b/tests/baselines/reference/commaOperatorWithSecondOperandAnyType.types index a8217c2d248..e2535bd17ab 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandAnyType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandAnyType.types @@ -83,7 +83,7 @@ var x: any; 1, ANY; >1, ANY : any ->1 : number +>1 : 1 >ANY : any ++NUMBER, ANY; @@ -94,28 +94,28 @@ var x: any; "string", [null, 1]; >"string", [null, 1] : number[] ->"string" : string +>"string" : "string" >[null, 1] : number[] >null : null ->1 : number +>1 : 1 "string".charAt(0), [null, 1]; >"string".charAt(0), [null, 1] : number[] >"string".charAt(0) : string >"string".charAt : (pos: number) => string ->"string" : string +>"string" : "string" >charAt : (pos: number) => string ->0 : number +>0 : 0 >[null, 1] : number[] >null : null ->1 : number +>1 : 1 true, x("any"); >true, x("any") : any ->true : boolean +>true : true >x("any") : any >x : any ->"any" : string +>"any" : "any" !BOOLEAN, x.doSomeThing(); >!BOOLEAN, x.doSomeThing() : any @@ -130,7 +130,7 @@ var resultIsAny6 = (1, ANY); >resultIsAny6 : any >(1, ANY) : any >1, ANY : any ->1 : number +>1 : 1 >ANY : any var resultIsAny7 = (++NUMBER, ANY); @@ -145,7 +145,7 @@ var resultIsAny8 = ("string", null); >resultIsAny8 : any >("string", null) : null >"string", null : null ->"string" : string +>"string" : "string" >null : null var resultIsAny9 = ("string".charAt(0), undefined); @@ -154,19 +154,19 @@ var resultIsAny9 = ("string".charAt(0), undefined); >"string".charAt(0), undefined : undefined >"string".charAt(0) : string >"string".charAt : (pos: number) => string ->"string" : string +>"string" : "string" >charAt : (pos: number) => string ->0 : number +>0 : 0 >undefined : undefined var resultIsAny10 = (true, x("any")); >resultIsAny10 : any >(true, x("any")) : any >true, x("any") : any ->true : boolean +>true : true >x("any") : any >x : any ->"any" : string +>"any" : "any" var resultIsAny11 = (!BOOLEAN, x.doSomeThing()); >resultIsAny11 : any diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandBooleanType.types b/tests/baselines/reference/commaOperatorWithSecondOperandBooleanType.types index b846d2cd56b..6c791bdee2c 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandBooleanType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandBooleanType.types @@ -91,22 +91,22 @@ ANY = undefined, BOOLEAN; >BOOLEAN : boolean 1, true; ->1, true : boolean ->1 : number ->true : boolean +>1, true : true +>1 : 1 +>true : true ++NUMBER, true; ->++NUMBER, true : boolean +>++NUMBER, true : true >++NUMBER : number >NUMBER : number ->true : boolean +>true : true [1, 2, 3], !BOOLEAN; >[1, 2, 3], !BOOLEAN : boolean >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >!BOOLEAN : boolean >BOOLEAN : boolean @@ -115,22 +115,22 @@ OBJECT = [1, 2, 3], BOOLEAN = false; >OBJECT = [1, 2, 3] : number[] >OBJECT : Object >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >BOOLEAN = false : false >BOOLEAN : boolean >false : false var resultIsBoolean6 = (null, BOOLEAN); ->resultIsBoolean6 : false +>resultIsBoolean6 : boolean >(null, BOOLEAN) : false >null, BOOLEAN : false >null : null >BOOLEAN : false var resultIsBoolean7 = (ANY = undefined, BOOLEAN); ->resultIsBoolean7 : false +>resultIsBoolean7 : boolean >(ANY = undefined, BOOLEAN) : false >ANY = undefined, BOOLEAN : false >ANY = undefined : undefined @@ -140,40 +140,40 @@ var resultIsBoolean7 = (ANY = undefined, BOOLEAN); var resultIsBoolean8 = (1, true); >resultIsBoolean8 : boolean ->(1, true) : boolean ->1, true : boolean ->1 : number ->true : boolean +>(1, true) : true +>1, true : true +>1 : 1 +>true : true var resultIsBoolean9 = (++NUMBER, true); >resultIsBoolean9 : boolean ->(++NUMBER, true) : boolean ->++NUMBER, true : boolean +>(++NUMBER, true) : true +>++NUMBER, true : true >++NUMBER : number >NUMBER : number ->true : boolean +>true : true var resultIsBoolean10 = ([1, 2, 3], !BOOLEAN); ->resultIsBoolean10 : true +>resultIsBoolean10 : boolean >([1, 2, 3], !BOOLEAN) : true >[1, 2, 3], !BOOLEAN : true >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >!BOOLEAN : true >BOOLEAN : false var resultIsBoolean11 = (OBJECT = [1, 2, 3], BOOLEAN = false); ->resultIsBoolean11 : false +>resultIsBoolean11 : boolean >(OBJECT = [1, 2, 3], BOOLEAN = false) : false >OBJECT = [1, 2, 3], BOOLEAN = false : false >OBJECT = [1, 2, 3] : number[] >OBJECT : Object >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >BOOLEAN = false : false >BOOLEAN : boolean >false : false diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandNumberType.types b/tests/baselines/reference/commaOperatorWithSecondOperandNumberType.types index 7706cc55441..2a53a23c4e0 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandNumberType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandNumberType.types @@ -91,33 +91,33 @@ ANY = undefined, NUMBER; >NUMBER : number true, 1; ->true, 1 : number ->true : boolean ->1 : number +>true, 1 : 1 +>true : true +>1 : 1 BOOLEAN = false, 1; ->BOOLEAN = false, 1 : number +>BOOLEAN = false, 1 : 1 >BOOLEAN = false : false >BOOLEAN : boolean >false : false ->1 : number +>1 : 1 "", NUMBER = 1; ->"", NUMBER = 1 : number ->"" : string ->NUMBER = 1 : number +>"", NUMBER = 1 : 1 +>"" : "" +>NUMBER = 1 : 1 >NUMBER : number ->1 : number +>1 : 1 STRING.trim(), NUMBER = 1; ->STRING.trim(), NUMBER = 1 : number +>STRING.trim(), NUMBER = 1 : 1 >STRING.trim() : string >STRING.trim : () => string >STRING : string >trim : () => string ->NUMBER = 1 : number +>NUMBER = 1 : 1 >NUMBER : number ->1 : number +>1 : 1 var resultIsNumber6 = (null, NUMBER); >resultIsNumber6 : number @@ -137,38 +137,38 @@ var resultIsNumber7 = (ANY = undefined, NUMBER); var resultIsNumber8 = (true, 1); >resultIsNumber8 : number ->(true, 1) : number ->true, 1 : number ->true : boolean ->1 : number +>(true, 1) : 1 +>true, 1 : 1 +>true : true +>1 : 1 var resultIsNumber9 = (BOOLEAN = false, 1); >resultIsNumber9 : number ->(BOOLEAN = false, 1) : number ->BOOLEAN = false, 1 : number +>(BOOLEAN = false, 1) : 1 +>BOOLEAN = false, 1 : 1 >BOOLEAN = false : false >BOOLEAN : boolean >false : false ->1 : number +>1 : 1 var resultIsNumber10 = ("", NUMBER = 1); >resultIsNumber10 : number ->("", NUMBER = 1) : number ->"", NUMBER = 1 : number ->"" : string ->NUMBER = 1 : number +>("", NUMBER = 1) : 1 +>"", NUMBER = 1 : 1 +>"" : "" +>NUMBER = 1 : 1 >NUMBER : number ->1 : number +>1 : 1 var resultIsNumber11 = (STRING.trim(), NUMBER = 1); >resultIsNumber11 : number ->(STRING.trim(), NUMBER = 1) : number ->STRING.trim(), NUMBER = 1 : number +>(STRING.trim(), NUMBER = 1) : 1 +>STRING.trim(), NUMBER = 1 : 1 >STRING.trim() : string >STRING.trim : () => string >STRING : string >trim : () => string ->NUMBER = 1 : number +>NUMBER = 1 : 1 >NUMBER : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandObjectType.types b/tests/baselines/reference/commaOperatorWithSecondOperandObjectType.types index 9c948da9699..15d9f074da5 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandObjectType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandObjectType.types @@ -99,7 +99,7 @@ ANY = null, OBJECT true, {} >true, {} : {} ->true : boolean +>true : true >{} : {} !BOOLEAN, [] @@ -110,7 +110,7 @@ true, {} "string", new Date() >"string", new Date() : Date ->"string" : string +>"string" : "string" >new Date() : Date >Date : DateConstructor @@ -143,7 +143,7 @@ var resultIsObject8 = (true, {}); >resultIsObject8 : {} >(true, {}) : {} >true, {} : {} ->true : boolean +>true : true >{} : {} var resultIsObject9 = (!BOOLEAN, { a: 1, b: "s" }); @@ -154,15 +154,15 @@ var resultIsObject9 = (!BOOLEAN, { a: 1, b: "s" }); >BOOLEAN : boolean >{ a: 1, b: "s" } : { a: number; b: string; } >a : number ->1 : number +>1 : 1 >b : string ->"s" : string +>"s" : "s" var resultIsObject10 = ("string", new Date()); >resultIsObject10 : Date >("string", new Date()) : Date >"string", new Date() : Date ->"string" : string +>"string" : "string" >new Date() : Date >Date : DateConstructor diff --git a/tests/baselines/reference/commaOperatorWithSecondOperandStringType.types b/tests/baselines/reference/commaOperatorWithSecondOperandStringType.types index a28202876d2..ca0cb475362 100644 --- a/tests/baselines/reference/commaOperatorWithSecondOperandStringType.types +++ b/tests/baselines/reference/commaOperatorWithSecondOperandStringType.types @@ -95,22 +95,22 @@ ANY = new Date(), STRING; >STRING : string true, ""; ->true, "" : string ->true : boolean ->"" : string +>true, "" : "" +>true : true +>"" : "" BOOLEAN == undefined, ""; ->BOOLEAN == undefined, "" : string +>BOOLEAN == undefined, "" : "" >BOOLEAN == undefined : boolean >BOOLEAN : boolean >undefined : undefined ->"" : string +>"" : "" ["a", "b"], NUMBER.toString(); >["a", "b"], NUMBER.toString() : string >["a", "b"] : string[] ->"a" : string ->"b" : string +>"a" : "a" +>"b" : "b" >NUMBER.toString() : string >NUMBER.toString : (radix?: number) => string >NUMBER : number @@ -124,7 +124,7 @@ OBJECT = new Object, STRING + "string"; >Object : ObjectConstructor >STRING + "string" : string >STRING : string ->"string" : string +>"string" : "string" var resultIsString6 = (null, STRING); >resultIsString6 : string @@ -145,27 +145,27 @@ var resultIsString7 = (ANY = new Date(), STRING); var resultIsString8 = (true, ""); >resultIsString8 : string ->(true, "") : string ->true, "" : string ->true : boolean ->"" : string +>(true, "") : "" +>true, "" : "" +>true : true +>"" : "" var resultIsString9 = (BOOLEAN == undefined, ""); >resultIsString9 : string ->(BOOLEAN == undefined, "") : string ->BOOLEAN == undefined, "" : string +>(BOOLEAN == undefined, "") : "" +>BOOLEAN == undefined, "" : "" >BOOLEAN == undefined : boolean >BOOLEAN : boolean >undefined : undefined ->"" : string +>"" : "" var resultIsString10 = (["a", "b"], NUMBER.toString()); >resultIsString10 : string >(["a", "b"], NUMBER.toString()) : string >["a", "b"], NUMBER.toString() : string >["a", "b"] : string[] ->"a" : string ->"b" : string +>"a" : "a" +>"b" : "b" >NUMBER.toString() : string >NUMBER.toString : (radix?: number) => string >NUMBER : number @@ -179,5 +179,5 @@ var resultIsString11 = (new Object, STRING + "string"); >Object : ObjectConstructor >STRING + "string" : string >STRING : string ->"string" : string +>"string" : "string" diff --git a/tests/baselines/reference/commaOperatorsMultipleOperators.types b/tests/baselines/reference/commaOperatorsMultipleOperators.types index 9a2c7c7e5c5..99796e36cb7 100644 --- a/tests/baselines/reference/commaOperatorsMultipleOperators.types +++ b/tests/baselines/reference/commaOperatorsMultipleOperators.types @@ -99,11 +99,11 @@ var resultIsObject1 = (NUMBER, STRING, OBJECT); //Literal and expression null, true, 1; ->null, true, 1 : number ->null, true : boolean +>null, true, 1 : 1 +>null, true : true >null : null ->true : boolean ->1 : number +>true : true +>1 : 1 ++NUMBER, STRING.charAt(0), new Object(); >++NUMBER, STRING.charAt(0), new Object() : Object @@ -114,18 +114,18 @@ null, true, 1; >STRING.charAt : (pos: number) => string >STRING : string >charAt : (pos: number) => string ->0 : number +>0 : 0 >new Object() : Object >Object : ObjectConstructor var resultIsNumber2 = (null, true, 1); >resultIsNumber2 : number ->(null, true, 1) : number ->null, true, 1 : number ->null, true : boolean +>(null, true, 1) : 1 +>null, true, 1 : 1 +>null, true : true >null : null ->true : boolean ->1 : number +>true : true +>1 : 1 var resultIsObject2 = (++NUMBER, STRING.charAt(0), new Object()); >resultIsObject2 : Object @@ -138,7 +138,7 @@ var resultIsObject2 = (++NUMBER, STRING.charAt(0), new Object()); >STRING.charAt : (pos: number) => string >STRING : string >charAt : (pos: number) => string ->0 : number +>0 : 0 >new Object() : Object >Object : ObjectConstructor diff --git a/tests/baselines/reference/commentBeforeStaticMethod1.types b/tests/baselines/reference/commentBeforeStaticMethod1.types index 1b16709a701..0c9e69ed7a0 100644 --- a/tests/baselines/reference/commentBeforeStaticMethod1.types +++ b/tests/baselines/reference/commentBeforeStaticMethod1.types @@ -9,6 +9,6 @@ class C { >foo : () => string return "bar"; ->"bar" : string +>"bar" : "bar" } } diff --git a/tests/baselines/reference/commentEmitAtEndOfFile1.types b/tests/baselines/reference/commentEmitAtEndOfFile1.types index f96a1069a06..2071e98af8d 100644 --- a/tests/baselines/reference/commentEmitAtEndOfFile1.types +++ b/tests/baselines/reference/commentEmitAtEndOfFile1.types @@ -3,7 +3,7 @@ // test var f = '' >f : string ->'' : string +>'' : "" // test #2 module foo { diff --git a/tests/baselines/reference/commentOnAmbientVariable2.types b/tests/baselines/reference/commentOnAmbientVariable2.types index 28760dca1ec..10e5a442862 100644 --- a/tests/baselines/reference/commentOnAmbientVariable2.types +++ b/tests/baselines/reference/commentOnAmbientVariable2.types @@ -4,12 +4,12 @@ declare var x: number; >x : number x = 2; ->x = 2 : number +>x = 2 : 2 >x : number ->2 : number +>2 : 2 === tests/cases/compiler/commentOnAmbientVariable2_1.ts === var y = 1; >y : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/commentOnExpressionStatement1.types b/tests/baselines/reference/commentOnExpressionStatement1.types index 11d5fe1c6b5..39141c8d52e 100644 --- a/tests/baselines/reference/commentOnExpressionStatement1.types +++ b/tests/baselines/reference/commentOnExpressionStatement1.types @@ -2,6 +2,6 @@ 1 + 1; // Comment. >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/commentOnIfStatement1.types b/tests/baselines/reference/commentOnIfStatement1.types index 7b983156f4d..4f7fcdddd22 100644 --- a/tests/baselines/reference/commentOnIfStatement1.types +++ b/tests/baselines/reference/commentOnIfStatement1.types @@ -2,5 +2,5 @@ // Test if (true) { ->true : boolean +>true : true } diff --git a/tests/baselines/reference/commentOnSimpleArrowFunctionBody1.types b/tests/baselines/reference/commentOnSimpleArrowFunctionBody1.types index 6dd530e438b..b8530468830 100644 --- a/tests/baselines/reference/commentOnSimpleArrowFunctionBody1.types +++ b/tests/baselines/reference/commentOnSimpleArrowFunctionBody1.types @@ -12,5 +12,5 @@ Foo(() => // do something 127); ->127 : number +>127 : 127 diff --git a/tests/baselines/reference/commentsAfterFunctionExpression1.types b/tests/baselines/reference/commentsAfterFunctionExpression1.types index 4a6b12bc210..b5712f1750c 100644 --- a/tests/baselines/reference/commentsAfterFunctionExpression1.types +++ b/tests/baselines/reference/commentsAfterFunctionExpression1.types @@ -7,20 +7,20 @@ var v = { >f : (a: any) => number >a => 0 : (a: any) => number >a : any ->0 : number +>0 : 0 g: (a => 0) /*t2*/, >g : (a: any) => number >(a => 0) : (a: any) => number >a => 0 : (a: any) => number >a : any ->0 : number +>0 : 0 h: (a => 0 /*t3*/) >h : (a: any) => number >(a => 0 /*t3*/) : (a: any) => number >a => 0 : (a: any) => number >a : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression1.types b/tests/baselines/reference/commentsArgumentsOfCallExpression1.types index bcab3e3de36..81425e0dd5f 100644 --- a/tests/baselines/reference/commentsArgumentsOfCallExpression1.types +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression1.types @@ -6,7 +6,7 @@ function foo(/*c1*/ x: any) { } foo(/*c2*/ 1); >foo(/*c2*/ 1) : void >foo : (x: any) => void ->1 : number +>1 : 1 foo(/*c3*/ function () { }); >foo(/*c3*/ function () { }) : void diff --git a/tests/baselines/reference/commentsArgumentsOfCallExpression2.types b/tests/baselines/reference/commentsArgumentsOfCallExpression2.types index f0a10077e66..7ec29aa9124 100644 --- a/tests/baselines/reference/commentsArgumentsOfCallExpression2.types +++ b/tests/baselines/reference/commentsArgumentsOfCallExpression2.types @@ -12,10 +12,10 @@ var a, b: any; foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b); >foo(/*c2*/ 1, /*d2*/ 1 + 2, /*e1*/ a + b) : void >foo : (x: any, y: any, w?: any) => void ->1 : number +>1 : 1 >1 + 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 >a + b : any >a : any >b : any @@ -51,5 +51,5 @@ foo( /*e4*/ /*e5*/ "hello"); ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/commentsBeforeFunctionExpression1.types b/tests/baselines/reference/commentsBeforeFunctionExpression1.types index a057918a74d..7182935f6b3 100644 --- a/tests/baselines/reference/commentsBeforeFunctionExpression1.types +++ b/tests/baselines/reference/commentsBeforeFunctionExpression1.types @@ -7,6 +7,6 @@ var v = { >f : (a: any) => number >(a) => 0 : (a: any) => number >a : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/commentsClassMembers.types b/tests/baselines/reference/commentsClassMembers.types index b599edc0463..3824b8acac0 100644 --- a/tests/baselines/reference/commentsClassMembers.types +++ b/tests/baselines/reference/commentsClassMembers.types @@ -574,7 +574,7 @@ var i1_r = i1.p2(20); >i1.p2 : (b: number) => number >i1 : c1 >p2 : (b: number) => number ->20 : number +>20 : 20 var i1_prop = i1.p3; >i1_prop : number @@ -607,7 +607,7 @@ var i1_ncr = i1.nc_p2(20); >i1.nc_p2 : (b: number) => number >i1 : c1 >nc_p2 : (b: number) => number ->20 : number +>20 : 20 var i1_ncprop = i1.nc_p3; >i1_ncprop : number @@ -640,7 +640,7 @@ var i1_s_r = c1.s2(20); >c1.s2 : (b: number) => number >c1 : typeof c1 >s2 : (b: number) => number ->20 : number +>20 : 20 var i1_s_prop = c1.s3; >i1_s_prop : number @@ -673,7 +673,7 @@ var i1_s_ncr = c1.nc_s2(20); >c1.nc_s2 : (b: number) => number >c1 : typeof c1 >nc_s2 : (b: number) => number ->20 : number +>20 : 20 var i1_s_ncprop = c1.nc_s3; >i1_s_ncprop : number @@ -743,11 +743,11 @@ class cProperties { public x = 10; /*trailing comment for property*/ >x : number ->10 : number +>10 : 10 private y = 10; // trailing comment of // style >y : number ->10 : number +>10 : 10 } var cProperties_i = new cProperties(); >cProperties_i : cProperties diff --git a/tests/baselines/reference/commentsCommentParsing.types b/tests/baselines/reference/commentsCommentParsing.types index a6e24609642..b41822679d8 100644 --- a/tests/baselines/reference/commentsCommentParsing.types +++ b/tests/baselines/reference/commentsCommentParsing.types @@ -151,8 +151,8 @@ function sum(a: number, b: number) { sum(10, 20); >sum(10, 20) : number >sum : (a: number, b: number) => number ->10 : number ->20 : number +>10 : 10 +>20 : 20 /** This is multiplication function*/ /** @param */ diff --git a/tests/baselines/reference/commentsEnums.types b/tests/baselines/reference/commentsEnums.types index ef2c52067d1..71d062f790a 100644 --- a/tests/baselines/reference/commentsEnums.types +++ b/tests/baselines/reference/commentsEnums.types @@ -6,18 +6,18 @@ enum Colors { /** Fancy name for 'blue'*/ Cornflower /* blue */, ->Cornflower : Colors +>Cornflower : Colors.Cornflower /** Fancy name for 'pink'*/ FancyPink ->FancyPink : Colors +>FancyPink : Colors.FancyPink } // trailing comment var x = Colors.Cornflower; >x : Colors ->Colors.Cornflower : Colors +>Colors.Cornflower : Colors.Cornflower >Colors : typeof Colors ->Cornflower : Colors +>Cornflower : Colors.Cornflower x = Colors.FancyPink; >x = Colors.FancyPink : Colors.FancyPink diff --git a/tests/baselines/reference/commentsFunction.types b/tests/baselines/reference/commentsFunction.types index db5e518339d..75a6cb6eaaf 100644 --- a/tests/baselines/reference/commentsFunction.types +++ b/tests/baselines/reference/commentsFunction.types @@ -26,8 +26,8 @@ function fooWithParameters(/** this is comment about a*/a: string, fooWithParameters("a", 10); >fooWithParameters("a", 10) : void >fooWithParameters : (a: string, b: number) => void ->"a" : string ->10 : number +>"a" : "a" +>10 : 10 /** fooFunc * comment @@ -64,14 +64,14 @@ var lambddaNoVarComment = /** this is lambda multiplication*/ (/**param a*/a: nu lambdaFoo(10, 20); >lambdaFoo(10, 20) : number >lambdaFoo : (a: number, b: number) => number ->10 : number ->20 : number +>10 : 10 +>20 : 20 lambddaNoVarComment(10, 20); >lambddaNoVarComment(10, 20) : number >lambddaNoVarComment : (a: number, b: number) => number ->10 : number ->20 : number +>10 : 10 +>20 : 20 function blah(a: string /* multiline trailing comment >blah : (a: string) => void @@ -104,12 +104,12 @@ lambdaFoo = (a, b) => a * b; // This is trailing comment /*leading comment*/() => 0; // Needs to be wrapped in parens to be a valid expression (not declaration) >() => 0 : () => number ->0 : number +>0 : 0 /*leading comment*/(() => 0); //trailing comment >(() => 0) : () => number >() => 0 : () => number ->0 : number +>0 : 0 function blah4(/*1*/a: string/*2*/,/*3*/b: string/*4*/) { >blah4 : (a: string, b: string) => void diff --git a/tests/baselines/reference/commentsInheritance.types b/tests/baselines/reference/commentsInheritance.types index 21dcde99dbf..804da3fd760 100644 --- a/tests/baselines/reference/commentsInheritance.types +++ b/tests/baselines/reference/commentsInheritance.types @@ -122,7 +122,7 @@ class c2 { >c2_prop : number return 10; ->10 : number +>10 : 10 } public c2_nc_p1: number; >c2_nc_p1 : number @@ -134,7 +134,7 @@ class c2 { >c2_nc_prop : number return 10; ->10 : number +>10 : 10 } /** c2 p1*/ public p1: number; @@ -149,7 +149,7 @@ class c2 { >prop : number return 10; ->10 : number +>10 : 10 } public nc_p1: number; >nc_p1 : number @@ -161,7 +161,7 @@ class c2 { >nc_prop : number return 10; ->10 : number +>10 : 10 } /** c2 constructor*/ constructor(a: number) { @@ -183,7 +183,7 @@ class c3 extends c2 { super(10); >super(10) : void >super : typeof c2 ->10 : number +>10 : 10 } /** c3 p1*/ public p1: number; @@ -198,7 +198,7 @@ class c3 extends c2 { >prop : number return 10; ->10 : number +>10 : 10 } public nc_p1: number; >nc_p1 : number @@ -210,14 +210,14 @@ class c3 extends c2 { >nc_prop : number return 10; ->10 : number +>10 : 10 } } var c2_i = new c2(10); >c2_i : c2 >new c2(10) : c2 >c2 : typeof c2 ->10 : number +>10 : 10 var c3_i = new c3(); >c3_i : c3 @@ -238,7 +238,7 @@ var c4_i = new c4(10); >c4_i : c4 >new c4(10) : c4 >c4 : typeof c4 ->10 : number +>10 : 10 interface i2 { >i2 : i2 diff --git a/tests/baselines/reference/commentsInterface.types b/tests/baselines/reference/commentsInterface.types index 13cc2b19f60..97b64d4c605 100644 --- a/tests/baselines/reference/commentsInterface.types +++ b/tests/baselines/reference/commentsInterface.types @@ -86,19 +86,19 @@ var i2_i_foo_r = i2_i.foo(30); >i2_i.foo : (b: number) => string >i2_i : i2 >foo : (b: number) => string ->30 : number +>30 : 30 var i2_i_i2_si = i2_i["hello"]; >i2_i_i2_si : any >i2_i["hello"] : any >i2_i : i2 ->"hello" : string +>"hello" : "hello" var i2_i_i2_ii = i2_i[30]; >i2_i_i2_ii : number >i2_i[30] : number >i2_i : i2 ->30 : number +>30 : 30 var i2_i_n = new i2_i(i1_i); >i2_i_n : any @@ -124,14 +124,14 @@ var i2_i_nc_foo_r = i2_i.nc_foo(30); >i2_i.nc_foo : (b: number) => string >i2_i : i2 >nc_foo : (b: number) => string ->30 : number +>30 : 30 var i2_i_r = i2_i(10, 20); >i2_i_r : number >i2_i(10, 20) : number >i2_i : i2 ->10 : number ->20 : number +>10 : 10 +>20 : 20 var i2_i_fnfoo = i2_i.fnfoo; >i2_i_fnfoo : (b: number) => string @@ -145,7 +145,7 @@ var i2_i_fnfoo_r = i2_i.fnfoo(10); >i2_i.fnfoo : (b: number) => string >i2_i : i2 >fnfoo : (b: number) => string ->10 : number +>10 : 10 var i2_i_nc_fnfoo = i2_i.nc_fnfoo; >i2_i_nc_fnfoo : (b: number) => string @@ -159,7 +159,7 @@ var i2_i_nc_fnfoo_r = i2_i.nc_fnfoo(10); >i2_i.nc_fnfoo : (b: number) => string >i2_i : i2 >nc_fnfoo : (b: number) => string ->10 : number +>10 : 10 interface i3 { >i3 : i3 @@ -203,7 +203,7 @@ i3_i = { >(/**i3_i a*/a: number) => "Hello" + a : (a: number) => string >a : number >"Hello" + a : string ->"Hello" : string +>"Hello" : "Hello" >a : number l: this.f, @@ -219,7 +219,7 @@ i3_i = { >this.f : any >this : any >f : any ->10 : number +>10 : 10 nc_x: this.l(this.x), >nc_x : any @@ -249,26 +249,26 @@ i3_i.f(10); >i3_i.f : (a: number) => string >i3_i : i3 >f : (a: number) => string ->10 : number +>10 : 10 i3_i.l(10); >i3_i.l(10) : string >i3_i.l : (b: number) => string >i3_i : i3 >l : (b: number) => string ->10 : number +>10 : 10 i3_i.nc_f(10); >i3_i.nc_f(10) : string >i3_i.nc_f : (a: number) => string >i3_i : i3 >nc_f : (a: number) => string ->10 : number +>10 : 10 i3_i.nc_l(10); >i3_i.nc_l(10) : string >i3_i.nc_l : (b: number) => string >i3_i : i3 >nc_l : (b: number) => string ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/commentsOnObjectLiteral3.types b/tests/baselines/reference/commentsOnObjectLiteral3.types index a63920fce0f..4053e7e3f89 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral3.types +++ b/tests/baselines/reference/commentsOnObjectLiteral3.types @@ -7,7 +7,7 @@ var v = { //property prop: 1 /* multiple trailing comments */ /*trailing comments*/, >prop : number ->1 : number +>1 : 1 //property func: function () { diff --git a/tests/baselines/reference/commentsOnObjectLiteral4.types b/tests/baselines/reference/commentsOnObjectLiteral4.types index 5d20d4f79cc..097d43cdd6d 100644 --- a/tests/baselines/reference/commentsOnObjectLiteral4.types +++ b/tests/baselines/reference/commentsOnObjectLiteral4.types @@ -11,7 +11,7 @@ var v = { >bar : number return 12; ->12 : number +>12 : 12 } } diff --git a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.types b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.types index 93ce87558d8..538afc61ee1 100644 --- a/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.types +++ b/tests/baselines/reference/commentsOnPropertyOfObjectLiteral1.types @@ -13,7 +13,7 @@ var resolve = { id1: /* c1 */ "hello", >id1 : string ->"hello" : string +>"hello" : "hello" id2: >id2 : (details: any) => any diff --git a/tests/baselines/reference/commentsOnReturnStatement1.types b/tests/baselines/reference/commentsOnReturnStatement1.types index d44c91c0a8c..0188f088c3a 100644 --- a/tests/baselines/reference/commentsOnReturnStatement1.types +++ b/tests/baselines/reference/commentsOnReturnStatement1.types @@ -8,10 +8,10 @@ class DebugClass { // Start Debugger Test Code var i = 0; >i : number ->0 : number +>0 : 0 // End Debugger Test Code return true; ->true : boolean +>true : true } } diff --git a/tests/baselines/reference/commentsOnStaticMembers.types b/tests/baselines/reference/commentsOnStaticMembers.types index 46a1ca211ff..b4fae1094b6 100644 --- a/tests/baselines/reference/commentsOnStaticMembers.types +++ b/tests/baselines/reference/commentsOnStaticMembers.types @@ -8,7 +8,7 @@ class test { */ public static p1: string = ""; >p1 : string ->"" : string +>"" : "" /** * p2 comment does not appear in output @@ -21,7 +21,7 @@ class test { */ private static p3: string = ""; >p3 : string ->"" : string +>"" : "" /** * p4 comment does not appear in output diff --git a/tests/baselines/reference/commentsOverloads.types b/tests/baselines/reference/commentsOverloads.types index 3281ab83ab6..88632e04c6a 100644 --- a/tests/baselines/reference/commentsOverloads.types +++ b/tests/baselines/reference/commentsOverloads.types @@ -13,17 +13,17 @@ function f1(aOrb: any) { >aOrb : any return 10; ->10 : number +>10 : 10 } f1("hello"); >f1("hello") : number >f1 : { (a: number): number; (b: string): number; } ->"hello" : string +>"hello" : "hello" f1(10); >f1(10) : number >f1 : { (a: number): number; (b: string): number; } ->10 : number +>10 : 10 function f2(a: number): number; >f2 : { (a: number): number; (b: string): number; } @@ -40,17 +40,17 @@ function f2(aOrb: any) { >aOrb : any return 10; ->10 : number +>10 : 10 } f2("hello"); >f2("hello") : number >f2 : { (a: number): number; (b: string): number; } ->"hello" : string +>"hello" : "hello" f2(10); >f2(10) : number >f2 : { (a: number): number; (b: string): number; } ->10 : number +>10 : 10 function f3(a: number): number; >f3 : { (a: number): number; (b: string): number; } @@ -65,17 +65,17 @@ function f3(aOrb: any) { >aOrb : any return 10; ->10 : number +>10 : 10 } f3("hello"); >f3("hello") : number >f3 : { (a: number): number; (b: string): number; } ->"hello" : string +>"hello" : "hello" f3(10); >f3(10) : number >f3 : { (a: number): number; (b: string): number; } ->10 : number +>10 : 10 /** this is signature 4 - with number parameter*/ function f4(/**param a*/a: number): number; @@ -92,17 +92,17 @@ function f4(aOrb: any) { >aOrb : any return 10; ->10 : number +>10 : 10 } f4("hello"); >f4("hello") : number >f4 : { (a: number): number; (b: string): number; } ->"hello" : string +>"hello" : "hello" f4(10); >f4(10) : number >f4 : { (a: number): number; (b: string): number; } ->10 : number +>10 : 10 interface i1 { >i1 : i1 @@ -252,7 +252,7 @@ class c { >aorb : any return 10; ->10 : number +>10 : 10 } /** prop2 1*/ public prop2(a: number): number; @@ -268,7 +268,7 @@ class c { >aorb : any return 10; ->10 : number +>10 : 10 } public prop3(a: number): number; >prop3 : { (a: number): number; (b: string): number; } @@ -284,7 +284,7 @@ class c { >aorb : any return 10; ->10 : number +>10 : 10 } /** prop4 1*/ public prop4(a: number): number; @@ -301,7 +301,7 @@ class c { >aorb : any return 10; ->10 : number +>10 : 10 } /** prop5 1*/ public prop5(a: number): number; @@ -319,7 +319,7 @@ class c { >aorb : any return 10; ->10 : number +>10 : 10 } } class c1 { @@ -405,59 +405,59 @@ var c1_i_1 = new c1(10); >c1_i_1 : c1 >new c1(10) : c1 >c1 : typeof c1 ->10 : number +>10 : 10 var c1_i_2 = new c1("hello"); >c1_i_2 : c1 >new c1("hello") : c1 >c1 : typeof c1 ->"hello" : string +>"hello" : "hello" var c2_i_1 = new c2(10); >c2_i_1 : c2 >new c2(10) : c2 >c2 : typeof c2 ->10 : number +>10 : 10 var c2_i_2 = new c2("hello"); >c2_i_2 : c2 >new c2("hello") : c2 >c2 : typeof c2 ->"hello" : string +>"hello" : "hello" var c3_i_1 = new c3(10); >c3_i_1 : c3 >new c3(10) : c3 >c3 : typeof c3 ->10 : number +>10 : 10 var c3_i_2 = new c3("hello"); >c3_i_2 : c3 >new c3("hello") : c3 >c3 : typeof c3 ->"hello" : string +>"hello" : "hello" var c4_i_1 = new c4(10); >c4_i_1 : c4 >new c4(10) : c4 >c4 : typeof c4 ->10 : number +>10 : 10 var c4_i_2 = new c4("hello"); >c4_i_2 : c4 >new c4("hello") : c4 >c4 : typeof c4 ->"hello" : string +>"hello" : "hello" var c5_i_1 = new c5(10); >c5_i_1 : c5 >new c5(10) : c5 >c5 : typeof c5 ->10 : number +>10 : 10 var c5_i_2 = new c5("hello"); >c5_i_2 : c5 >new c5("hello") : c5 >c5 : typeof c5 ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/commentsPropertySignature1.types b/tests/baselines/reference/commentsPropertySignature1.types index 09dad1eaefb..f5fdf48042b 100644 --- a/tests/baselines/reference/commentsPropertySignature1.types +++ b/tests/baselines/reference/commentsPropertySignature1.types @@ -6,7 +6,7 @@ var a = { /** own x*/ x: 0 >x : number ->0 : number +>0 : 0 }; diff --git a/tests/baselines/reference/commentsVarDecl.types b/tests/baselines/reference/commentsVarDecl.types index 033590b3445..1127f5ed3f4 100644 --- a/tests/baselines/reference/commentsVarDecl.types +++ b/tests/baselines/reference/commentsVarDecl.types @@ -3,30 +3,30 @@ /** Variable comments*/ var myVariable = 10; // This trailing Comment1 >myVariable : number ->10 : number +>10 : 10 /** This is another variable comment*/ var anotherVariable = 30; >anotherVariable : number ->30 : number +>30 : 30 // shouldn't appear var aVar = ""; >aVar : string ->"" : string +>"" : "" /** this is multiline comment * All these variables are of number type */ var anotherAnotherVariable = 70; /* these are multiple trailing comments */ /* multiple trailing comments */ >anotherAnotherVariable : number ->70 : number +>70 : 70 /** Triple slash multiline comment*/ /** another line in the comment*/ /** comment line 2*/ var x = 70; /* multiline trailing comment >x : number ->70 : number +>70 : 70 this is multiline trailing comment */ /** Triple slash comment on the assignement shouldnt be in .d.ts file*/ @@ -39,12 +39,12 @@ x = myVariable; /** jsdocstyle comment - only this comment should be in .d.ts file*/ var n = 30; >n : number ->30 : number +>30 : 30 /** var deckaration with comment on type as well*/ var y = /** value comment */ 20; >y : number ->20 : number +>20 : 20 /// var deckaration with comment on type as well var yy = @@ -52,7 +52,7 @@ var yy = /// value comment 20; ->20 : number +>20 : 20 /** comment2 */ var z = /** lambda comment */ (x: number, y: number) => x + y; diff --git a/tests/baselines/reference/commentsVariableStatement1.types b/tests/baselines/reference/commentsVariableStatement1.types index 4bb6753db8a..1684f25c570 100644 --- a/tests/baselines/reference/commentsVariableStatement1.types +++ b/tests/baselines/reference/commentsVariableStatement1.types @@ -3,5 +3,5 @@ /** Comment */ var v = 1; >v : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/commentsdoNotEmitComments.types b/tests/baselines/reference/commentsdoNotEmitComments.types index 465c841e20f..e30555db69a 100644 --- a/tests/baselines/reference/commentsdoNotEmitComments.types +++ b/tests/baselines/reference/commentsdoNotEmitComments.types @@ -3,7 +3,7 @@ /** Variable comments*/ var myVariable = 10; >myVariable : number ->10 : number +>10 : 10 /** function comments*/ function foo(/** parameter comment*/p: number) { @@ -18,7 +18,7 @@ var fooVar: () => void; foo(50); >foo(50) : void >foo : (p: number) => void ->50 : number +>50 : 50 fooVar(); >fooVar() : void @@ -35,7 +35,7 @@ class c { /** property comment */ public b = 10; >b : number ->10 : number +>10 : 10 /** function comment */ public myFoo() { @@ -158,9 +158,9 @@ declare var x; /** const enum member value comment (generated by TS) */ const enum color { red, green, blue } >color : color ->red : color ->green : color ->blue : color +>red : color.red +>green : color.green +>blue : color.blue var shade: color = color.green; >shade : color diff --git a/tests/baselines/reference/commentsemitComments.types b/tests/baselines/reference/commentsemitComments.types index 2594fb53fe9..03bf0912092 100644 --- a/tests/baselines/reference/commentsemitComments.types +++ b/tests/baselines/reference/commentsemitComments.types @@ -3,7 +3,7 @@ /** Variable comments*/ var myVariable = 10; >myVariable : number ->10 : number +>10 : 10 /** function comments*/ function foo(/** parameter comment*/p: number) { @@ -18,7 +18,7 @@ var fooVar: () => void; foo(50); >foo(50) : void >foo : (p: number) => void ->50 : number +>50 : 50 fooVar(); >fooVar() : void @@ -35,7 +35,7 @@ class c { /** property comment */ public b = 10; >b : number ->10 : number +>10 : 10 /** function comment */ public myFoo() { diff --git a/tests/baselines/reference/commonJSImportAsPrimaryExpression.types b/tests/baselines/reference/commonJSImportAsPrimaryExpression.types index 01d96b31fc7..921c659500c 100644 --- a/tests/baselines/reference/commonJSImportAsPrimaryExpression.types +++ b/tests/baselines/reference/commonJSImportAsPrimaryExpression.types @@ -18,10 +18,10 @@ export class C1 { m1 = 42; >m1 : number ->42 : number +>42 : 42 static s1 = true; >s1 : boolean ->true : boolean +>true : true } diff --git a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.types b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.types index 9d9faf05af8..32e45936f33 100644 --- a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.types +++ b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.types @@ -49,11 +49,11 @@ export class C1 { m1 = 42; >m1 : number ->42 : number +>42 : 42 static s1 = true; >s1 : boolean ->true : boolean +>true : true } export interface I1 { @@ -81,8 +81,8 @@ export enum E1 { >E1 : E1 A,B,C ->A : E1 ->B : E1 ->C : E1 +>A : E1.A +>B : E1.B +>C : E1.C } diff --git a/tests/baselines/reference/commonSourceDir5.types b/tests/baselines/reference/commonSourceDir5.types index dd72099d542..f1c3e40e983 100644 --- a/tests/baselines/reference/commonSourceDir5.types +++ b/tests/baselines/reference/commonSourceDir5.types @@ -19,8 +19,8 @@ export var i = Math.sqrt(-1); >Math.sqrt : (x: number) => number >Math : Math >sqrt : (x: number) => number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 export var z = pi * pi; >z : number diff --git a/tests/baselines/reference/commonSourceDir6.types b/tests/baselines/reference/commonSourceDir6.types index e30cdd2deee..890b95048fe 100644 --- a/tests/baselines/reference/commonSourceDir6.types +++ b/tests/baselines/reference/commonSourceDir6.types @@ -18,8 +18,8 @@ export var i = Math.sqrt(-1); >Math.sqrt : (x: number) => number >Math : Math >sqrt : (x: number) => number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 export var z = pi * pi; >z : number diff --git a/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.types b/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.types index a21af43e9c7..b4f1a81bff4 100644 --- a/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.types +++ b/tests/baselines/reference/comparisonOperatorWithIdenticalPrimitiveType.types @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithIdenticalPrimitiveType.ts === enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a: number; >a : number diff --git a/tests/baselines/reference/comparisonOperatorWithOneOperandIsAny.types b/tests/baselines/reference/comparisonOperatorWithOneOperandIsAny.types index e132f03cfa3..9e3c5f59cbf 100644 --- a/tests/baselines/reference/comparisonOperatorWithOneOperandIsAny.types +++ b/tests/baselines/reference/comparisonOperatorWithOneOperandIsAny.types @@ -4,9 +4,9 @@ var x: any; enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c function foo(t: T) { >foo : (t: T) => void diff --git a/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.types b/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.types index 12d9235d44b..e185a1d501b 100644 --- a/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.types +++ b/tests/baselines/reference/comparisonOperatorWithOneOperandIsNull.types @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithOneOperandIsNull.ts === enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c function foo(t: T) { >foo : (t: T) => void diff --git a/tests/baselines/reference/comparisonOperatorWithOneOperandIsUndefined.types b/tests/baselines/reference/comparisonOperatorWithOneOperandIsUndefined.types index b4a70c3e3d6..00f6ca234a2 100644 --- a/tests/baselines/reference/comparisonOperatorWithOneOperandIsUndefined.types +++ b/tests/baselines/reference/comparisonOperatorWithOneOperandIsUndefined.types @@ -5,9 +5,9 @@ var x: typeof undefined; enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c function foo(t: T) { >foo : (t: T) => void diff --git a/tests/baselines/reference/comparisonOperatorWithSubtypeEnumAndNumber.types b/tests/baselines/reference/comparisonOperatorWithSubtypeEnumAndNumber.types index 0f07c158cc4..bf513174ef2 100644 --- a/tests/baselines/reference/comparisonOperatorWithSubtypeEnumAndNumber.types +++ b/tests/baselines/reference/comparisonOperatorWithSubtypeEnumAndNumber.types @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/binaryOperators/comparisonOperator/comparisonOperatorWithSubtypeEnumAndNumber.ts === enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a: E; >a : E @@ -28,34 +28,34 @@ var ra2 = b < a; var ra3 = E.a < b; >ra3 : boolean >E.a < b : boolean ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var ra4 = b < E.a; >ra4 : boolean >b < E.a : boolean >b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var ra5 = E.a < 0; >ra5 : boolean >E.a < 0 : boolean ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->0 : number +>a : E.a +>0 : 0 var ra6 = 0 < E.a; >ra6 : boolean >0 < E.a : boolean ->0 : number ->E.a : E +>0 : 0 +>E.a : E.a >E : typeof E ->a : E +>a : E.a // operator > var rb1 = a > b; @@ -73,34 +73,34 @@ var rb2 = b > a; var rb3 = E.a > b; >rb3 : boolean >E.a > b : boolean ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rb4 = b > E.a; >rb4 : boolean >b > E.a : boolean >b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rb5 = E.a > 0; >rb5 : boolean >E.a > 0 : boolean ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->0 : number +>a : E.a +>0 : 0 var rb6 = 0 > E.a; >rb6 : boolean >0 > E.a : boolean ->0 : number ->E.a : E +>0 : 0 +>E.a : E.a >E : typeof E ->a : E +>a : E.a // operator <= var rc1 = a <= b; @@ -118,34 +118,34 @@ var rc2 = b <= a; var rc3 = E.a <= b; >rc3 : boolean >E.a <= b : boolean ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rc4 = b <= E.a; >rc4 : boolean >b <= E.a : boolean >b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rc5 = E.a <= 0; >rc5 : boolean >E.a <= 0 : boolean ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->0 : number +>a : E.a +>0 : 0 var rc6 = 0 <= E.a; >rc6 : boolean >0 <= E.a : boolean ->0 : number ->E.a : E +>0 : 0 +>E.a : E.a >E : typeof E ->a : E +>a : E.a // operator >= var rd1 = a >= b; @@ -163,34 +163,34 @@ var rd2 = b >= a; var rd3 = E.a >= b; >rd3 : boolean >E.a >= b : boolean ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var rd4 = b >= E.a; >rd4 : boolean >b >= E.a : boolean >b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rd5 = E.a >= 0; >rd5 : boolean >E.a >= 0 : boolean ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->0 : number +>a : E.a +>0 : 0 var rd6 = 0 >= E.a; >rd6 : boolean >0 >= E.a : boolean ->0 : number ->E.a : E +>0 : 0 +>E.a : E.a >E : typeof E ->a : E +>a : E.a // operator == var re1 = a == b; diff --git a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types index 77189e5fee2..64eb0ddfdbb 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types +++ b/tests/baselines/reference/compoundAdditionAssignmentLHSCanBeAssigned.types @@ -1,8 +1,8 @@ === tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentLHSCanBeAssigned.ts === enum E { a, b } >E : E ->a : E ->b : E +>a : E.a +>b : E.b var a: any; >a : any @@ -26,24 +26,24 @@ x1 += b; x1 += true; >x1 += true : any >x1 : any ->true : boolean +>true : true x1 += 0; >x1 += 0 : any >x1 : any ->0 : number +>0 : 0 x1 += ''; >x1 += '' : string >x1 : any ->'' : string +>'' : "" x1 += E.a; >x1 += E.a : any >x1 : any ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a x1 += {}; >x1 += {} : any @@ -76,24 +76,24 @@ x2 += b; x2 += true; >x2 += true : string >x2 : string ->true : boolean +>true : true x2 += 0; >x2 += 0 : string >x2 : string ->0 : number +>0 : 0 x2 += ''; >x2 += '' : string >x2 : string ->'' : string +>'' : "" x2 += E.a; >x2 += E.a : string >x2 : string ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a x2 += {}; >x2 += {} : string @@ -121,14 +121,14 @@ x3 += a; x3 += 0; >x3 += 0 : number >x3 : number ->0 : number +>0 : 0 x3 += E.a; >x3 += E.a : number >x3 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a x3 += null; >x3 += null : number @@ -190,7 +190,7 @@ x6 += a; x6 += ''; >x6 += '' : string >x6 : {} ->'' : string +>'' : "" var x7: void; >x7 : void diff --git a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt index 2bc8a82ed3b..cadc5c945d1 100644 --- a/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt +++ b/tests/baselines/reference/compoundAdditionAssignmentWithInvalidOperands.errors.txt @@ -1,29 +1,29 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(6,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(7,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'true'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(8,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'number'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(8,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '0'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(11,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(12,1): error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'boolean'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(15,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'void'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(16,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'boolean'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(17,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'number'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(18,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'E'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(16,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'true'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(17,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '0'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(18,1): error TS2365: Operator '+=' cannot be applied to types '{}' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(19,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(20,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(21,1): error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(24,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(25,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'boolean'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(26,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'number'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(27,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'E'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(25,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'true'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(26,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '0'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(27,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'E.a'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(28,1): error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(29,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(30,1): error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(33,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(34,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'boolean'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(34,1): error TS2365: Operator '+=' cannot be applied to types 'number' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(35,1): error TS2365: Operator '+=' cannot be applied to types 'number' and '{}'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(38,1): error TS2365: Operator '+=' cannot be applied to types 'E' and 'void'. -tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(39,1): error TS2365: Operator '+=' cannot be applied to types 'E' and 'boolean'. +tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(39,1): error TS2365: Operator '+=' cannot be applied to types 'E' and 'true'. tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmentWithInvalidOperands.ts(40,1): error TS2365: Operator '+=' cannot be applied to types 'E' and '{}'. @@ -41,10 +41,10 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen !!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'true'. x1 += 0; ~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'number'. +!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and '0'. x1 += E.a; ~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E'. +!!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and 'E.a'. x1 += {}; ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'boolean' and '{}'. @@ -61,13 +61,13 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen !!! error TS2365: Operator '+=' cannot be applied to types '{}' and 'void'. x2 += true; ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and 'boolean'. +!!! error TS2365: Operator '+=' cannot be applied to types '{}' and 'true'. x2 += 0; ~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and 'number'. +!!! error TS2365: Operator '+=' cannot be applied to types '{}' and '0'. x2 += E.a; ~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '{}' and 'E'. +!!! error TS2365: Operator '+=' cannot be applied to types '{}' and 'E.a'. x2 += {}; ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types '{}' and '{}'. @@ -84,13 +84,13 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen !!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'void'. x3 += true; ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'boolean'. +!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'true'. x3 += 0; ~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'number'. +!!! error TS2365: Operator '+=' cannot be applied to types 'void' and '0'. x3 += E.a; ~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'E'. +!!! error TS2365: Operator '+=' cannot be applied to types 'void' and 'E.a'. x3 += {}; ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'void' and '{}'. @@ -107,7 +107,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen !!! error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'. x4 += true; ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'number' and 'boolean'. +!!! error TS2365: Operator '+=' cannot be applied to types 'number' and 'true'. x4 += {}; ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'number' and '{}'. @@ -118,7 +118,7 @@ tests/cases/conformance/expressions/assignmentOperator/compoundAdditionAssignmen !!! error TS2365: Operator '+=' cannot be applied to types 'E' and 'void'. x5 += true; ~~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'E' and 'boolean'. +!!! error TS2365: Operator '+=' cannot be applied to types 'E' and 'true'. x5 += {}; ~~~~~~~~ !!! error TS2365: Operator '+=' cannot be applied to types 'E' and '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.types b/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.types index 3b346bac53b..81fff36594e 100644 --- a/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.types +++ b/tests/baselines/reference/compoundArithmeticAssignmentLHSCanBeAssigned.types @@ -1,9 +1,9 @@ === tests/cases/conformance/expressions/assignmentOperator/compoundArithmeticAssignmentLHSCanBeAssigned.ts === enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a: any; >a : any diff --git a/tests/baselines/reference/compoundAssignmentLHSIsReference.types b/tests/baselines/reference/compoundAssignmentLHSIsReference.types index 12c601d377f..4816307f508 100644 --- a/tests/baselines/reference/compoundAssignmentLHSIsReference.types +++ b/tests/baselines/reference/compoundAssignmentLHSIsReference.types @@ -54,14 +54,14 @@ x3['a'] *= value; >x3['a'] *= value : number >x3['a'] : number >x3 : { a: number; } ->'a' : string +>'a' : "a" >value : any x3['a'] += value; >x3['a'] += value : any >x3['a'] : number >x3 : { a: number; } ->'a' : string +>'a' : "a" >value : any // parentheses, the contained expression is reference @@ -115,7 +115,7 @@ function fn2(x4: number) { >(x3['a']) : number >x3['a'] : number >x3 : { a: number; } ->'a' : string +>'a' : "a" >value : any (x3['a']) += value; @@ -123,6 +123,6 @@ function fn2(x4: number) { >(x3['a']) : number >x3['a'] : number >x3 : { a: number; } ->'a' : string +>'a' : "a" >value : any diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.types b/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.types index 060a231da1b..46f9d762ca3 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.types +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSCanBeAssigned1.types @@ -1,9 +1,9 @@ === tests/cases/conformance/es7/exponentiationOperator/compoundExponentiationAssignmentLHSCanBeAssigned1.ts === enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a: any; >a : any diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsReference.types b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsReference.types index 35f42f4fa77..55b90382d7b 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsReference.types +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsReference.types @@ -37,7 +37,7 @@ x3['a'] **= value; >x3['a'] **= value : number >x3['a'] : number >x3 : { a: number; } ->'a' : string +>'a' : "a" >value : any // parentheses, the contained expression is reference @@ -71,6 +71,6 @@ function fn2(x4: number) { >(x3['a']) : number >x3['a'] : number >x3 : { a: number; } ->'a' : string +>'a' : "a" >value : any diff --git a/tests/baselines/reference/compoundVarDecl1.types b/tests/baselines/reference/compoundVarDecl1.types index 40f12ea52c0..08c1716760d 100644 --- a/tests/baselines/reference/compoundVarDecl1.types +++ b/tests/baselines/reference/compoundVarDecl1.types @@ -2,18 +2,18 @@ module Foo { var a = 1, b = 1; a = b + 2; } >Foo : typeof Foo >a : number ->1 : number +>1 : 1 >b : number ->1 : number +>1 : 1 >a = b + 2 : number >a : number >b + 2 : number >b : number ->2 : number +>2 : 2 var foo = 4, bar = 5; >foo : number ->4 : number +>4 : 4 >bar : number ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt b/tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt index dc536e544b2..283f1d439b8 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt +++ b/tests/baselines/reference/computedPropertiesInDestructuring1.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1.ts(20,8): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/compiler/computedPropertiesInDestructuring1.ts(21,12): error TS2339: Property 'toExponential' does not exist on type 'string'. tests/cases/compiler/computedPropertiesInDestructuring1.ts(33,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365: Operator '+' cannot be applied to types 'number' and '{}'. +tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365: Operator '+' cannot be applied to types '1' and '{}'. ==== tests/cases/compiler/computedPropertiesInDestructuring1.ts (4 errors) ==== @@ -46,7 +46,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1.ts(34,5): error TS2365: !!! error TS2349: Cannot invoke an expression whose type lacks a call signature. [{[(1 + {})]: bar4}] = [{bar: "bar"}]; ~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'number' and '{}'. +!!! error TS2365: Operator '+' cannot be applied to types '1' and '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt index 96ab892d1b9..0affcfebb0c 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertiesInDestructuring1_ES6.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(21,8): error TS2349: Cannot invoke an expression whose type lacks a call signature. tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(22,12): error TS2339: Property 'toExponential' does not exist on type 'string'. tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(34,4): error TS2349: Cannot invoke an expression whose type lacks a call signature. -tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS2365: Operator '+' cannot be applied to types 'number' and '{}'. +tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS2365: Operator '+' cannot be applied to types '1' and '{}'. ==== tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts (4 errors) ==== @@ -47,5 +47,5 @@ tests/cases/compiler/computedPropertiesInDestructuring1_ES6.ts(35,5): error TS23 !!! error TS2349: Cannot invoke an expression whose type lacks a call signature. [{[(1 + {})]: bar4}] = [{bar: "bar"}]; ~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'number' and '{}'. +!!! error TS2365: Operator '+' cannot be applied to types '1' and '{}'. \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertiesInDestructuring2.types b/tests/baselines/reference/computedPropertiesInDestructuring2.types index 0fa20662270..137a0793e6d 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring2.types +++ b/tests/baselines/reference/computedPropertiesInDestructuring2.types @@ -2,7 +2,7 @@ let foo2 = () => "bar"; >foo2 : () => string >() => "bar" : () => string ->"bar" : string +>"bar" : "bar" let {[foo2()]: bar3} = {}; >foo2() : string diff --git a/tests/baselines/reference/computedPropertiesInDestructuring2_ES6.types b/tests/baselines/reference/computedPropertiesInDestructuring2_ES6.types index f0d8b1033c8..979689438d2 100644 --- a/tests/baselines/reference/computedPropertiesInDestructuring2_ES6.types +++ b/tests/baselines/reference/computedPropertiesInDestructuring2_ES6.types @@ -3,7 +3,7 @@ let foo2 = () => "bar"; >foo2 : () => string >() => "bar" : () => string ->"bar" : string +>"bar" : "bar" let {[foo2()]: bar3} = {}; >foo2() : string diff --git a/tests/baselines/reference/computedPropertyNames10_ES5.types b/tests/baselines/reference/computedPropertyNames10_ES5.types index b9d999397ab..650890fb10e 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES5.types +++ b/tests/baselines/reference/computedPropertyNames10_ES5.types @@ -33,17 +33,17 @@ var v = { >s : string [""]() { }, ->"" : string +>"" : "" [0]() { }, ->0 : number +>0 : 0 [a]() { }, >a : any [true]() { }, >true : any ->true : boolean +>true : true [`hello bye`]() { }, >`hello bye` : string diff --git a/tests/baselines/reference/computedPropertyNames10_ES6.types b/tests/baselines/reference/computedPropertyNames10_ES6.types index 1883febb39b..2ff86ed9712 100644 --- a/tests/baselines/reference/computedPropertyNames10_ES6.types +++ b/tests/baselines/reference/computedPropertyNames10_ES6.types @@ -33,17 +33,17 @@ var v = { >s : string [""]() { }, ->"" : string +>"" : "" [0]() { }, ->0 : number +>0 : 0 [a]() { }, >a : any [true]() { }, >true : any ->true : boolean +>true : true [`hello bye`]() { }, >`hello bye` : string diff --git a/tests/baselines/reference/computedPropertyNames11_ES5.types b/tests/baselines/reference/computedPropertyNames11_ES5.types index e15b46cc6c1..0787a889f40 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES5.types +++ b/tests/baselines/reference/computedPropertyNames11_ES5.types @@ -14,7 +14,7 @@ var v = { get [s]() { return 0; }, >s : string ->0 : number +>0 : 0 set [n](v) { }, >n : number @@ -24,7 +24,7 @@ var v = { >s + s : string >s : string >s : string ->0 : number +>0 : 0 set [s + n](v) { }, >s + n : string @@ -35,15 +35,15 @@ var v = { get [+s]() { return 0; }, >+s : number >s : string ->0 : number +>0 : 0 set [""](v) { }, ->"" : string +>"" : "" >v : any get [0]() { return 0; }, ->0 : number ->0 : number +>0 : 0 +>0 : 0 set [a](v) { }, >a : any @@ -51,8 +51,8 @@ var v = { get [true]() { return 0; }, >true : any ->true : boolean ->0 : number +>true : true +>0 : 0 set [`hello bye`](v) { }, >`hello bye` : string @@ -61,5 +61,5 @@ var v = { get [`hello ${a} bye`]() { return 0; } >`hello ${a} bye` : string >a : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames11_ES6.types b/tests/baselines/reference/computedPropertyNames11_ES6.types index eb5fc105a7a..4783d07a2af 100644 --- a/tests/baselines/reference/computedPropertyNames11_ES6.types +++ b/tests/baselines/reference/computedPropertyNames11_ES6.types @@ -14,7 +14,7 @@ var v = { get [s]() { return 0; }, >s : string ->0 : number +>0 : 0 set [n](v) { }, >n : number @@ -24,7 +24,7 @@ var v = { >s + s : string >s : string >s : string ->0 : number +>0 : 0 set [s + n](v) { }, >s + n : string @@ -35,15 +35,15 @@ var v = { get [+s]() { return 0; }, >+s : number >s : string ->0 : number +>0 : 0 set [""](v) { }, ->"" : string +>"" : "" >v : any get [0]() { return 0; }, ->0 : number ->0 : number +>0 : 0 +>0 : 0 set [a](v) { }, >a : any @@ -51,8 +51,8 @@ var v = { get [true]() { return 0; }, >true : any ->true : boolean ->0 : number +>true : true +>0 : 0 set [`hello bye`](v) { }, >`hello bye` : string @@ -61,5 +61,5 @@ var v = { get [`hello ${a} bye`]() { return 0; } >`hello ${a} bye` : string >a : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames13_ES5.types b/tests/baselines/reference/computedPropertyNames13_ES5.types index 59694df32a7..2585fe15f94 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES5.types +++ b/tests/baselines/reference/computedPropertyNames13_ES5.types @@ -32,17 +32,17 @@ class C { >s : string static [""]() { } ->"" : string +>"" : "" [0]() { } ->0 : number +>0 : 0 [a]() { } >a : any static [true]() { } >true : any ->true : boolean +>true : true [`hello bye`]() { } >`hello bye` : string diff --git a/tests/baselines/reference/computedPropertyNames13_ES6.types b/tests/baselines/reference/computedPropertyNames13_ES6.types index a2d0f14e72c..61e8cae265c 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES6.types +++ b/tests/baselines/reference/computedPropertyNames13_ES6.types @@ -32,17 +32,17 @@ class C { >s : string static [""]() { } ->"" : string +>"" : "" [0]() { } ->0 : number +>0 : 0 [a]() { } >a : any static [true]() { } >true : any ->true : boolean +>true : true [`hello bye`]() { } >`hello bye` : string diff --git a/tests/baselines/reference/computedPropertyNames16_ES5.types b/tests/baselines/reference/computedPropertyNames16_ES5.types index ab7ea23cffe..5c0fb34bc25 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES5.types +++ b/tests/baselines/reference/computedPropertyNames16_ES5.types @@ -13,7 +13,7 @@ class C { get [s]() { return 0;} >s : string ->0 : number +>0 : 0 set [n](v) { } >n : number @@ -23,7 +23,7 @@ class C { >s + s : string >s : string >s : string ->0 : number +>0 : 0 set [s + n](v) { } >s + n : string @@ -34,15 +34,15 @@ class C { get [+s]() { return 0; } >+s : number >s : string ->0 : number +>0 : 0 static set [""](v) { } ->"" : string +>"" : "" >v : any get [0]() { return 0; } ->0 : number ->0 : number +>0 : 0 +>0 : 0 set [a](v) { } >a : any @@ -50,8 +50,8 @@ class C { static get [true]() { return 0; } >true : any ->true : boolean ->0 : number +>true : true +>0 : 0 set [`hello bye`](v) { } >`hello bye` : string @@ -60,5 +60,5 @@ class C { get [`hello ${a} bye`]() { return 0; } >`hello ${a} bye` : string >a : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames16_ES6.types b/tests/baselines/reference/computedPropertyNames16_ES6.types index c7286e6640e..7ebb2cd0060 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES6.types +++ b/tests/baselines/reference/computedPropertyNames16_ES6.types @@ -13,7 +13,7 @@ class C { get [s]() { return 0;} >s : string ->0 : number +>0 : 0 set [n](v) { } >n : number @@ -23,7 +23,7 @@ class C { >s + s : string >s : string >s : string ->0 : number +>0 : 0 set [s + n](v) { } >s + n : string @@ -34,15 +34,15 @@ class C { get [+s]() { return 0; } >+s : number >s : string ->0 : number +>0 : 0 static set [""](v) { } ->"" : string +>"" : "" >v : any get [0]() { return 0; } ->0 : number ->0 : number +>0 : 0 +>0 : 0 set [a](v) { } >a : any @@ -50,8 +50,8 @@ class C { static get [true]() { return 0; } >true : any ->true : boolean ->0 : number +>true : true +>0 : 0 set [`hello bye`](v) { } >`hello bye` : string @@ -60,5 +60,5 @@ class C { get [`hello ${a} bye`]() { return 0; } >`hello ${a} bye` : string >a : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames18_ES5.types b/tests/baselines/reference/computedPropertyNames18_ES5.types index d6808a8edc0..e9de10f5ace 100644 --- a/tests/baselines/reference/computedPropertyNames18_ES5.types +++ b/tests/baselines/reference/computedPropertyNames18_ES5.types @@ -10,6 +10,6 @@ function foo() { >this.bar : any >this : any >bar : any ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames18_ES6.types b/tests/baselines/reference/computedPropertyNames18_ES6.types index 11d58e48c69..1b376e9a1e3 100644 --- a/tests/baselines/reference/computedPropertyNames18_ES6.types +++ b/tests/baselines/reference/computedPropertyNames18_ES6.types @@ -10,6 +10,6 @@ function foo() { >this.bar : any >this : any >bar : any ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames1_ES5.types b/tests/baselines/reference/computedPropertyNames1_ES5.types index a77895e06d1..d0c11e448bb 100644 --- a/tests/baselines/reference/computedPropertyNames1_ES5.types +++ b/tests/baselines/reference/computedPropertyNames1_ES5.types @@ -5,13 +5,13 @@ var v = { get [0 + 1]() { return 0 }, >0 + 1 : number ->0 : number ->1 : number ->0 : number +>0 : 0 +>1 : 1 +>0 : 0 set [0 + 1](v: string) { } //No error >0 + 1 : number ->0 : number ->1 : number +>0 : 0 +>1 : 1 >v : string } diff --git a/tests/baselines/reference/computedPropertyNames1_ES6.types b/tests/baselines/reference/computedPropertyNames1_ES6.types index 503988b0314..6fddad0067c 100644 --- a/tests/baselines/reference/computedPropertyNames1_ES6.types +++ b/tests/baselines/reference/computedPropertyNames1_ES6.types @@ -5,13 +5,13 @@ var v = { get [0 + 1]() { return 0 }, >0 + 1 : number ->0 : number ->1 : number ->0 : number +>0 : 0 +>1 : 1 +>0 : 0 set [0 + 1](v: string) { } //No error >0 + 1 : number ->0 : number ->1 : number +>0 : 0 +>1 : 1 >v : string } diff --git a/tests/baselines/reference/computedPropertyNames20_ES5.types b/tests/baselines/reference/computedPropertyNames20_ES5.types index 65ee55be379..d685b52ef06 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES5.types +++ b/tests/baselines/reference/computedPropertyNames20_ES5.types @@ -7,5 +7,5 @@ var obj = { >this.bar : any >this : any >bar : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames20_ES6.types b/tests/baselines/reference/computedPropertyNames20_ES6.types index 91e5c8d7843..af475ee66e6 100644 --- a/tests/baselines/reference/computedPropertyNames20_ES6.types +++ b/tests/baselines/reference/computedPropertyNames20_ES6.types @@ -7,5 +7,5 @@ var obj = { >this.bar : any >this : any >bar : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames22_ES5.types b/tests/baselines/reference/computedPropertyNames22_ES5.types index eeec22d2e61..e244d4fb554 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES5.types +++ b/tests/baselines/reference/computedPropertyNames22_ES5.types @@ -17,6 +17,6 @@ class C { }; return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames22_ES6.types b/tests/baselines/reference/computedPropertyNames22_ES6.types index af9ef9d3a31..06329679bfb 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES6.types +++ b/tests/baselines/reference/computedPropertyNames22_ES6.types @@ -17,6 +17,6 @@ class C { }; return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames25_ES5.types b/tests/baselines/reference/computedPropertyNames25_ES5.types index f1acc296709..aed42994255 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES5.types +++ b/tests/baselines/reference/computedPropertyNames25_ES5.types @@ -6,7 +6,7 @@ class Base { >bar : () => number return 0; ->0 : number +>0 : 0 } } class C extends Base { @@ -28,6 +28,6 @@ class C extends Base { }; return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames25_ES6.types b/tests/baselines/reference/computedPropertyNames25_ES6.types index 26c38013906..73a4ca912f9 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES6.types +++ b/tests/baselines/reference/computedPropertyNames25_ES6.types @@ -6,7 +6,7 @@ class Base { >bar : () => number return 0; ->0 : number +>0 : 0 } } class C extends Base { @@ -28,6 +28,6 @@ class C extends Base { }; return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames28_ES5.types b/tests/baselines/reference/computedPropertyNames28_ES5.types index 89a2a7ac017..0d816d980fe 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES5.types +++ b/tests/baselines/reference/computedPropertyNames28_ES5.types @@ -16,11 +16,11 @@ class C extends Base { >{ [(super(), "prop")]() { } } : { [x: string]: () => void; } [(super(), "prop")]() { } ->(super(), "prop") : string ->super(), "prop" : string +>(super(), "prop") : "prop" +>super(), "prop" : "prop" >super() : void >super : typeof Base ->"prop" : string +>"prop" : "prop" }; } diff --git a/tests/baselines/reference/computedPropertyNames28_ES6.types b/tests/baselines/reference/computedPropertyNames28_ES6.types index df020c9a5ff..7c803ec43af 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES6.types +++ b/tests/baselines/reference/computedPropertyNames28_ES6.types @@ -16,11 +16,11 @@ class C extends Base { >{ [(super(), "prop")]() { } } : { [x: string]: () => void; } [(super(), "prop")]() { } ->(super(), "prop") : string ->super(), "prop" : string +>(super(), "prop") : "prop" +>super(), "prop" : "prop" >super() : void >super : typeof Base ->"prop" : string +>"prop" : "prop" }; } diff --git a/tests/baselines/reference/computedPropertyNames29_ES5.types b/tests/baselines/reference/computedPropertyNames29_ES5.types index d2f89ef6b18..3f825c244e0 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES5.types +++ b/tests/baselines/reference/computedPropertyNames29_ES5.types @@ -21,6 +21,6 @@ class C { }; } return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames29_ES6.types b/tests/baselines/reference/computedPropertyNames29_ES6.types index bb324b2b382..a1375622271 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES6.types +++ b/tests/baselines/reference/computedPropertyNames29_ES6.types @@ -21,6 +21,6 @@ class C { }; } return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames31_ES5.types b/tests/baselines/reference/computedPropertyNames31_ES5.types index 832b2bc067a..37661cbec11 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES5.types +++ b/tests/baselines/reference/computedPropertyNames31_ES5.types @@ -6,7 +6,7 @@ class Base { >bar : () => number return 0; ->0 : number +>0 : 0 } } class C extends Base { @@ -32,6 +32,6 @@ class C extends Base { }; } return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames31_ES6.types b/tests/baselines/reference/computedPropertyNames31_ES6.types index 4f59b1e8c6d..dbb4f47662e 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES6.types +++ b/tests/baselines/reference/computedPropertyNames31_ES6.types @@ -6,7 +6,7 @@ class Base { >bar : () => number return 0; ->0 : number +>0 : 0 } } class C extends Base { @@ -32,6 +32,6 @@ class C extends Base { }; } return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames33_ES5.types b/tests/baselines/reference/computedPropertyNames33_ES5.types index 7031981481f..046d4bf96a9 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES5.types +++ b/tests/baselines/reference/computedPropertyNames33_ES5.types @@ -2,7 +2,7 @@ function foo() { return '' } >foo : () => string >T : T ->'' : string +>'' : "" class C { >C : C @@ -22,6 +22,6 @@ class C { }; return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames33_ES6.types b/tests/baselines/reference/computedPropertyNames33_ES6.types index 3c57daf2ace..07cf7c1639f 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES6.types +++ b/tests/baselines/reference/computedPropertyNames33_ES6.types @@ -2,7 +2,7 @@ function foo() { return '' } >foo : () => string >T : T ->'' : string +>'' : "" class C { >C : C @@ -22,6 +22,6 @@ class C { }; return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNames37_ES5.types b/tests/baselines/reference/computedPropertyNames37_ES5.types index 21b68c7c12c..b1ba3a4315e 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES5.types +++ b/tests/baselines/reference/computedPropertyNames37_ES5.types @@ -17,12 +17,12 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : string +>"get1" : "get1" >new Foo : Foo >Foo : typeof Foo set ["set1"](p: Foo2) { } ->"set1" : string +>"set1" : "set1" >p : Foo2 >Foo2 : Foo2 } diff --git a/tests/baselines/reference/computedPropertyNames37_ES6.types b/tests/baselines/reference/computedPropertyNames37_ES6.types index e436a54172b..67c84380e8b 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES6.types +++ b/tests/baselines/reference/computedPropertyNames37_ES6.types @@ -17,12 +17,12 @@ class C { // Computed properties get ["get1"]() { return new Foo } ->"get1" : string +>"get1" : "get1" >new Foo : Foo >Foo : typeof Foo set ["set1"](p: Foo2) { } ->"set1" : string +>"set1" : "set1" >p : Foo2 >Foo2 : Foo2 } diff --git a/tests/baselines/reference/computedPropertyNames41_ES5.types b/tests/baselines/reference/computedPropertyNames41_ES5.types index 5aa7ae44404..0be69bec4a5 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES5.types +++ b/tests/baselines/reference/computedPropertyNames41_ES5.types @@ -17,7 +17,7 @@ class C { // Computed properties static [""]() { return new Foo } ->"" : string +>"" : "" >new Foo : Foo >Foo : typeof Foo } diff --git a/tests/baselines/reference/computedPropertyNames41_ES6.types b/tests/baselines/reference/computedPropertyNames41_ES6.types index 70bfcf12a75..297a41eecec 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES6.types +++ b/tests/baselines/reference/computedPropertyNames41_ES6.types @@ -17,7 +17,7 @@ class C { // Computed properties static [""]() { return new Foo } ->"" : string +>"" : "" >new Foo : Foo >Foo : typeof Foo } diff --git a/tests/baselines/reference/computedPropertyNames46_ES5.types b/tests/baselines/reference/computedPropertyNames46_ES5.types index b8df0d56e13..7ea3ffda244 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES5.types +++ b/tests/baselines/reference/computedPropertyNames46_ES5.types @@ -1,12 +1,12 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames46_ES5.ts === var o = { ->o : { [x: string]: number; } ->{ ["" || 0]: 0} : { [x: string]: number; } +>o : { [x: number]: number; } +>{ ["" || 0]: 0} : { [x: number]: number; } ["" || 0]: 0 ->"" || 0 : string | number ->"" : string ->0 : number ->0 : number +>"" || 0 : 0 +>"" : "" +>0 : 0 +>0 : 0 }; diff --git a/tests/baselines/reference/computedPropertyNames46_ES6.types b/tests/baselines/reference/computedPropertyNames46_ES6.types index a786eca200c..3914f6facef 100644 --- a/tests/baselines/reference/computedPropertyNames46_ES6.types +++ b/tests/baselines/reference/computedPropertyNames46_ES6.types @@ -1,12 +1,12 @@ === tests/cases/conformance/es6/computedProperties/computedPropertyNames46_ES6.ts === var o = { ->o : { [x: string]: number; } ->{ ["" || 0]: 0} : { [x: string]: number; } +>o : { [x: number]: number; } +>{ ["" || 0]: 0} : { [x: number]: number; } ["" || 0]: 0 ->"" || 0 : string | number ->"" : string ->0 : number ->0 : number +>"" || 0 : 0 +>"" : "" +>0 : 0 +>0 : 0 }; diff --git a/tests/baselines/reference/computedPropertyNames47_ES5.types b/tests/baselines/reference/computedPropertyNames47_ES5.types index cdc2c3301f6..19811ae8ec2 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES5.types +++ b/tests/baselines/reference/computedPropertyNames47_ES5.types @@ -19,6 +19,6 @@ var o = { >E2.x : E2 >E2 : typeof E2 >x : E2 ->0 : number +>0 : 0 }; diff --git a/tests/baselines/reference/computedPropertyNames47_ES6.types b/tests/baselines/reference/computedPropertyNames47_ES6.types index a923e934d66..46edecb450a 100644 --- a/tests/baselines/reference/computedPropertyNames47_ES6.types +++ b/tests/baselines/reference/computedPropertyNames47_ES6.types @@ -19,6 +19,6 @@ var o = { >E2.x : E2 >E2 : typeof E2 >x : E2 ->0 : number +>0 : 0 }; diff --git a/tests/baselines/reference/computedPropertyNames48_ES5.types b/tests/baselines/reference/computedPropertyNames48_ES5.types index 12752d8abeb..545dc641434 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES5.types +++ b/tests/baselines/reference/computedPropertyNames48_ES5.types @@ -21,7 +21,7 @@ extractIndexer({ [a]: "" >a : any ->"" : string +>"" : "" }); // Should return string @@ -34,19 +34,19 @@ extractIndexer({ >E.x : E >E : typeof E >x : E ->"" : string +>"" : "" }); // Should return string extractIndexer({ >extractIndexer({ ["" || 0]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ ["" || 0]: ""} : { [x: string]: string; } +>{ ["" || 0]: ""} : { [x: number]: string; } ["" || 0]: "" ->"" || 0 : string | number ->"" : string ->0 : number ->"" : string +>"" || 0 : 0 +>"" : "" +>0 : 0 +>"" : "" }); // Should return any (widened form of undefined) diff --git a/tests/baselines/reference/computedPropertyNames48_ES6.types b/tests/baselines/reference/computedPropertyNames48_ES6.types index 832bc3c7025..0f352b57d24 100644 --- a/tests/baselines/reference/computedPropertyNames48_ES6.types +++ b/tests/baselines/reference/computedPropertyNames48_ES6.types @@ -21,7 +21,7 @@ extractIndexer({ [a]: "" >a : any ->"" : string +>"" : "" }); // Should return string @@ -34,19 +34,19 @@ extractIndexer({ >E.x : E >E : typeof E >x : E ->"" : string +>"" : "" }); // Should return string extractIndexer({ >extractIndexer({ ["" || 0]: ""}) : string >extractIndexer : (p: { [n: number]: T; }) => T ->{ ["" || 0]: ""} : { [x: string]: string; } +>{ ["" || 0]: ""} : { [x: number]: string; } ["" || 0]: "" ->"" || 0 : string | number ->"" : string ->0 : number ->"" : string +>"" || 0 : 0 +>"" : "" +>0 : 0 +>"" : "" }); // Should return any (widened form of undefined) diff --git a/tests/baselines/reference/computedPropertyNames4_ES5.types b/tests/baselines/reference/computedPropertyNames4_ES5.types index a71b3984ec8..64ef5f6a611 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES5.types +++ b/tests/baselines/reference/computedPropertyNames4_ES5.types @@ -14,7 +14,7 @@ var v = { [s]: 0, >s : string ->0 : number +>0 : 0 [n]: n, >n : number @@ -24,13 +24,13 @@ var v = { >s + s : string >s : string >s : string ->1 : number +>1 : 1 [s + n]: 2, >s + n : string >s : string >n : number ->2 : number +>2 : 2 [+s]: s, >+s : number @@ -38,28 +38,28 @@ var v = { >s : string [""]: 0, ->"" : string ->0 : number +>"" : "" +>0 : 0 [0]: 0, ->0 : number ->0 : number +>0 : 0 +>0 : 0 [a]: 1, >a : any ->1 : number +>1 : 1 [true]: 0, >true : any ->true : boolean ->0 : number +>true : true +>0 : 0 [`hello bye`]: 0, >`hello bye` : string ->0 : number +>0 : 0 [`hello ${a} bye`]: 0 >`hello ${a} bye` : string >a : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames4_ES6.types b/tests/baselines/reference/computedPropertyNames4_ES6.types index a4bcc59711c..0c608e21601 100644 --- a/tests/baselines/reference/computedPropertyNames4_ES6.types +++ b/tests/baselines/reference/computedPropertyNames4_ES6.types @@ -14,7 +14,7 @@ var v = { [s]: 0, >s : string ->0 : number +>0 : 0 [n]: n, >n : number @@ -24,13 +24,13 @@ var v = { >s + s : string >s : string >s : string ->1 : number +>1 : 1 [s + n]: 2, >s + n : string >s : string >n : number ->2 : number +>2 : 2 [+s]: s, >+s : number @@ -38,28 +38,28 @@ var v = { >s : string [""]: 0, ->"" : string ->0 : number +>"" : "" +>0 : 0 [0]: 0, ->0 : number ->0 : number +>0 : 0 +>0 : 0 [a]: 1, >a : any ->1 : number +>1 : 1 [true]: 0, >true : any ->true : boolean ->0 : number +>true : true +>0 : 0 [`hello bye`]: 0, >`hello bye` : string ->0 : number +>0 : 0 [`hello ${a} bye`]: 0 >`hello ${a} bye` : string >a : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames7_ES5.types b/tests/baselines/reference/computedPropertyNames7_ES5.types index 3411198b590..fbc070e3951 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES5.types +++ b/tests/baselines/reference/computedPropertyNames7_ES5.types @@ -13,5 +13,5 @@ var v = { >E.member : E >E : typeof E >member : E ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNames7_ES6.types b/tests/baselines/reference/computedPropertyNames7_ES6.types index eb72d546dbc..f8f1dd7f791 100644 --- a/tests/baselines/reference/computedPropertyNames7_ES6.types +++ b/tests/baselines/reference/computedPropertyNames7_ES6.types @@ -13,5 +13,5 @@ var v = { >E.member : E >E : typeof E >member : E ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.errors.txt index 7fa95fe9426..f277df6f4c8 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType10_ES5.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType10_ES5.ts(5,5): error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType10_ES5.ts(5,5): error TS2322: Type '{ [x: number]: "" | 0; }' is not assignable to type 'I'. Index signatures are incompatible. - Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. + Type '"" | 0' is not assignable to type 'boolean'. + Type '""' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType10_ES5.ts (1 errors) ==== @@ -11,10 +11,10 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ -!!! error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: number]: "" | 0; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. [+"foo"]: "", [+"bar"]: 0 } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesContextualType10_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType10_ES6.errors.txt index 116cd1a2531..689ec135d3f 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType10_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType10_ES6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType10_ES6.ts(5,5): error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType10_ES6.ts(5,5): error TS2322: Type '{ [x: number]: "" | 0; }' is not assignable to type 'I'. Index signatures are incompatible. - Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. + Type '"" | 0' is not assignable to type 'boolean'. + Type '""' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType10_ES6.ts (1 errors) ==== @@ -11,10 +11,10 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ -!!! error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: number]: "" | 0; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. [+"foo"]: "", [+"bar"]: 0 } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.types index 09cad594624..05ae43cf69b 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType1_ES5.types @@ -18,8 +18,8 @@ var o: I = { ["" + 0](y) { return y.length; }, >"" + 0 : string ->"" : string ->0 : number +>"" : "" +>0 : 0 >y : string >y.length : number >y : string @@ -27,8 +27,8 @@ var o: I = { ["" + 1]: y => y.length >"" + 1 : string ->"" : string ->1 : number +>"" : "" +>1 : 1 >y => y.length : (y: string) => number >y : string >y.length : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType1_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType1_ES6.types index d9e9970ebec..9caae76eeda 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType1_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType1_ES6.types @@ -18,8 +18,8 @@ var o: I = { ["" + 0](y) { return y.length; }, >"" + 0 : string ->"" : string ->0 : number +>"" : "" +>0 : 0 >y : string >y.length : number >y : string @@ -27,8 +27,8 @@ var o: I = { ["" + 1]: y => y.length >"" + 1 : string ->"" : string ->1 : number +>"" : "" +>1 : 1 >y => y.length : (y: string) => number >y : string >y.length : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.types index 5a5c48f2536..a9ca7b5ac6c 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType2_ES5.types @@ -18,7 +18,7 @@ var o: I = { [+"foo"](y) { return y.length; }, >+"foo" : number ->"foo" : string +>"foo" : "foo" >y : string >y.length : number >y : string @@ -26,7 +26,7 @@ var o: I = { [+"bar"]: y => y.length >+"bar" : number ->"bar" : string +>"bar" : "bar" >y => y.length : (y: string) => number >y : string >y.length : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType2_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType2_ES6.types index 330351790ca..990b22b178f 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType2_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType2_ES6.types @@ -18,7 +18,7 @@ var o: I = { [+"foo"](y) { return y.length; }, >+"foo" : number ->"foo" : string +>"foo" : "foo" >y : string >y.length : number >y : string @@ -26,7 +26,7 @@ var o: I = { [+"bar"]: y => y.length >+"bar" : number ->"bar" : string +>"bar" : "bar" >y => y.length : (y: string) => number >y : string >y.length : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.types index faff27c9154..58c6c3c58f2 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType3_ES5.types @@ -14,7 +14,7 @@ var o: I = { [+"foo"](y) { return y.length; }, >+"foo" : number ->"foo" : string +>"foo" : "foo" >y : string >y.length : number >y : string @@ -22,7 +22,7 @@ var o: I = { [+"bar"]: y => y.length >+"bar" : number ->"bar" : string +>"bar" : "bar" >y => y.length : (y: string) => number >y : string >y.length : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType3_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType3_ES6.types index 18c32957944..89f62c9a02d 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType3_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType3_ES6.types @@ -14,7 +14,7 @@ var o: I = { [+"foo"](y) { return y.length; }, >+"foo" : number ->"foo" : string +>"foo" : "foo" >y : string >y.length : number >y : string @@ -22,7 +22,7 @@ var o: I = { [+"bar"]: y => y.length >+"bar" : number ->"bar" : string +>"bar" : "bar" >y => y.length : (y: string) => number >y : string >y.length : number diff --git a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.types index 6f75f1a3633..1fe66e50ce5 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType4_ES5.types @@ -16,13 +16,13 @@ var o: I = { [""+"foo"]: "", >""+"foo" : string ->"" : string ->"foo" : string ->"" : string +>"" : "" +>"foo" : "foo" +>"" : "" [""+"bar"]: 0 >""+"bar" : string ->"" : string ->"bar" : string ->0 : number +>"" : "" +>"bar" : "bar" +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNamesContextualType4_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType4_ES6.types index 9ee84176237..0a74effe990 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType4_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType4_ES6.types @@ -16,13 +16,13 @@ var o: I = { [""+"foo"]: "", >""+"foo" : string ->"" : string ->"foo" : string ->"" : string +>"" : "" +>"foo" : "foo" +>"" : "" [""+"bar"]: 0 >""+"bar" : string ->"" : string ->"bar" : string ->0 : number +>"" : "" +>"bar" : "bar" +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.types index 38594f756ab..5721a1fcc86 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType5_ES5.types @@ -16,11 +16,11 @@ var o: I = { [+"foo"]: "", >+"foo" : number ->"foo" : string ->"" : string +>"foo" : "foo" +>"" : "" [+"bar"]: 0 >+"bar" : number ->"bar" : string ->0 : number +>"bar" : "bar" +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNamesContextualType5_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType5_ES6.types index a07b2e8cd95..a63da9b633d 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType5_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType5_ES6.types @@ -16,11 +16,11 @@ var o: I = { [+"foo"]: "", >+"foo" : number ->"foo" : string ->"" : string +>"foo" : "foo" +>"" : "" [+"bar"]: 0 >+"bar" : number ->"bar" : string ->0 : number +>"bar" : "bar" +>0 : 0 } diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types index 564689ffdeb..63651072644 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES5.types @@ -19,31 +19,31 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | true | (() => void) | number[]; [x: number]: number | (() => void) | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | 0 | (() => void) | number[]; [x: number]: 0 | (() => void) | number[]; 0: () => void; p: ""; } p: "", >p : string ->"" : string +>"" : "" 0: () => { }, >() => { } : () => void ["hi" + "bye"]: true, >"hi" + "bye" : string ->"hi" : string ->"bye" : string +>"hi" : "hi" +>"bye" : "bye" >true : true [0 + 1]: 0, >0 + 1 : number ->0 : number ->1 : number ->0 : number +>0 : 0 +>1 : 1 +>0 : 0 [+"hi"]: [0] >+"hi" : number ->"hi" : string +>"hi" : "hi" >[0] : number[] ->0 : number +>0 : 0 }); diff --git a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types index a771faba97e..fa34f015a23 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType6_ES6.types @@ -19,31 +19,31 @@ declare function foo(obj: I): T foo({ >foo({ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]}) : string | number | boolean | (() => void) | number[] >foo : (obj: I) => T ->{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: string | number | true | (() => void) | number[]; [x: number]: number | (() => void) | number[]; 0: () => void; p: string; } +>{ p: "", 0: () => { }, ["hi" + "bye"]: true, [0 + 1]: 0, [+"hi"]: [0]} : { [x: string]: true | "" | 0 | (() => void) | number[]; [x: number]: 0 | (() => void) | number[]; 0: () => void; p: ""; } p: "", >p : string ->"" : string +>"" : "" 0: () => { }, >() => { } : () => void ["hi" + "bye"]: true, >"hi" + "bye" : string ->"hi" : string ->"bye" : string +>"hi" : "hi" +>"bye" : "bye" >true : true [0 + 1]: 0, >0 + 1 : number ->0 : number ->1 : number ->0 : number +>0 : 0 +>1 : 1 +>0 : 0 [+"hi"]: [0] >+"hi" : number ->"hi" : string +>"hi" : "hi" >[0] : number[] ->0 : number +>0 : 0 }); diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types index c2099456303..b77a129a0b4 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES5.types @@ -42,21 +42,21 @@ foo({ ["hi" + "bye"]: true, >"hi" + "bye" : string ->"hi" : string ->"bye" : string ->true : boolean +>"hi" : "hi" +>"bye" : "bye" +>true : true [0 + 1]: 0, >0 + 1 : number ->0 : number ->1 : number ->0 : number +>0 : 0 +>1 : 1 +>0 : 0 [+"hi"]: [0] >+"hi" : number ->"hi" : string +>"hi" : "hi" >[0] : number[] ->0 : number +>0 : 0 }); @@ -65,5 +65,5 @@ g({ p: "" }); >g : (obj: J) => T >{ p: "" } : { p: string; } >p : string ->"" : string +>"" : "" diff --git a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types index 6ae7d7eeada..f041b2b4eb4 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesContextualType7_ES6.types @@ -42,21 +42,21 @@ foo({ ["hi" + "bye"]: true, >"hi" + "bye" : string ->"hi" : string ->"bye" : string ->true : boolean +>"hi" : "hi" +>"bye" : "bye" +>true : true [0 + 1]: 0, >0 + 1 : number ->0 : number ->1 : number ->0 : number +>0 : 0 +>1 : 1 +>0 : 0 [+"hi"]: [0] >+"hi" : number ->"hi" : string +>"hi" : "hi" >[0] : number[] ->0 : number +>0 : 0 }); @@ -65,5 +65,5 @@ g({ p: "" }); >g : (obj: J) => T >{ p: "" } : { p: string; } >p : string ->"" : string +>"" : "" diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt index ee36609095a..6bfc98ae6a8 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES5.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(6,5): error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts(6,5): error TS2322: Type '{ [x: string]: "" | 0; }' is not assignable to type 'I'. Index signatures are incompatible. - Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. + Type '"" | 0' is not assignable to type 'boolean'. + Type '""' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES5.ts (1 errors) ==== @@ -12,10 +12,10 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ -!!! error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: string]: "" | 0; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. [""+"foo"]: "", [""+"bar"]: 0 } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt index 1048fd2e119..30f0b6f529e 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType8_ES6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts(6,5): error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts(6,5): error TS2322: Type '{ [x: string]: "" | 0; }' is not assignable to type 'I'. Index signatures are incompatible. - Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. + Type '"" | 0' is not assignable to type 'boolean'. + Type '""' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType8_ES6.ts (1 errors) ==== @@ -12,10 +12,10 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ -!!! error TS2322: Type '{ [x: string]: string | number; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: string]: "" | 0; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. [""+"foo"]: "", [""+"bar"]: 0 } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt index e76b3a704dc..4f94dd3467f 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES5.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES5.ts(6,5): error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES5.ts(6,5): error TS2322: Type '{ [x: number]: "" | 0; }' is not assignable to type 'I'. Index signatures are incompatible. - Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. + Type '"" | 0' is not assignable to type 'boolean'. + Type '""' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES5.ts (1 errors) ==== @@ -12,10 +12,10 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ -!!! error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: number]: "" | 0; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. [+"foo"]: "", [+"bar"]: 0 } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt b/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt index 468ad400c26..5eeccfe7293 100644 --- a/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNamesContextualType9_ES6.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES6.ts(6,5): error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. +tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES6.ts(6,5): error TS2322: Type '{ [x: number]: "" | 0; }' is not assignable to type 'I'. Index signatures are incompatible. - Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. + Type '"" | 0' is not assignable to type 'boolean'. + Type '""' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualType9_ES6.ts (1 errors) ==== @@ -12,10 +12,10 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNamesContextualTy var o: I = { ~ -!!! error TS2322: Type '{ [x: number]: string | number; }' is not assignable to type 'I'. +!!! error TS2322: Type '{ [x: number]: "" | 0; }' is not assignable to type 'I'. !!! error TS2322: Index signatures are incompatible. -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '"" | 0' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. [+"foo"]: "", [+"bar"]: 0 } \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES5.types b/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES5.types index a05d5556495..dd12b763441 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES5.types @@ -4,18 +4,18 @@ class C { ["" + ""]() { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" get ["" + ""]() { return 0; } >"" + "" : string ->"" : string ->"" : string ->0 : number +>"" : "" +>"" : "" +>0 : 0 set ["" + ""](x) { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" >x : any } diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.types b/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.types index 8b635956dcd..2ee96225fb9 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.types @@ -4,18 +4,18 @@ class C { ["" + ""]() { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" get ["" + ""]() { return 0; } >"" + "" : string ->"" : string ->"" : string ->0 : number +>"" : "" +>"" : "" +>0 : 0 set ["" + ""](x) { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" >x : any } diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES5.types b/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES5.types index c49010b2c09..30fc69390e5 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES5.types @@ -4,18 +4,18 @@ class C { static ["" + ""]() { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" static get ["" + ""]() { return 0; } >"" + "" : string ->"" : string ->"" : string ->0 : number +>"" : "" +>"" : "" +>0 : 0 static set ["" + ""](x) { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" >x : any } diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.types b/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.types index 0b0083b9a1a..181b935790c 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.types @@ -4,18 +4,18 @@ class C { static ["" + ""]() { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" static get ["" + ""]() { return 0; } >"" + "" : string ->"" : string ->"" : string ->0 : number +>"" : "" +>"" : "" +>0 : 0 static set ["" + ""](x) { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" >x : any } diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.types b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.types index 0653059b535..fd5971fc849 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES5.types @@ -5,24 +5,24 @@ var v = { ["" + ""]: 0, >"" + "" : string ->"" : string ->"" : string ->0 : number +>"" : "" +>"" : "" +>0 : 0 ["" + ""]() { }, >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" get ["" + ""]() { return 0; }, >"" + "" : string ->"" : string ->"" : string ->0 : number +>"" : "" +>"" : "" +>0 : 0 set ["" + ""](x) { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" >x : any } diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.types b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.types index 45d1e74f24a..886d93e061c 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit5_ES6.types @@ -5,24 +5,24 @@ var v = { ["" + ""]: 0, >"" + "" : string ->"" : string ->"" : string ->0 : number +>"" : "" +>"" : "" +>0 : 0 ["" + ""]() { }, >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" get ["" + ""]() { return 0; }, >"" + "" : string ->"" : string ->"" : string ->0 : number +>"" : "" +>"" : "" +>0 : 0 set ["" + ""](x) { } >"" + "" : string ->"" : string ->"" : string +>"" : "" +>"" : "" >x : any } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.types b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.types index 528591441b0..555782bf6cf 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES5.types @@ -3,14 +3,14 @@ class C { >C : C ["hello"]() { ->"hello" : string +>"hello" : "hello" debugger; } get ["goodbye"]() { ->"goodbye" : string +>"goodbye" : "goodbye" return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.types b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.types index cd7b75384b0..93ce203c0ef 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.types @@ -3,14 +3,14 @@ class C { >C : C ["hello"]() { ->"hello" : string +>"hello" : "hello" debugger; } get ["goodbye"]() { ->"goodbye" : string +>"goodbye" : "goodbye" return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.types b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.types index 29b64c990c2..bf2352f338d 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.types +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES5.types @@ -4,14 +4,14 @@ var v = { >{ ["hello"]() { debugger; }, get ["goodbye"]() { return 0; }} : { ["hello"](): void; readonly ["goodbye"]: number; } ["hello"]() { ->"hello" : string +>"hello" : "hello" debugger; }, get ["goodbye"]() { ->"goodbye" : string +>"goodbye" : "goodbye" return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES6.types b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES6.types index fea16b5de8d..ae4429d0437 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap2_ES6.types +++ b/tests/baselines/reference/computedPropertyNamesSourceMap2_ES6.types @@ -4,14 +4,14 @@ var v = { >{ ["hello"]() { debugger; }, get ["goodbye"]() { return 0; }} : { ["hello"](): void; readonly ["goodbye"]: number; } ["hello"]() { ->"hello" : string +>"hello" : "hello" debugger; }, get ["goodbye"]() { ->"goodbye" : string +>"goodbye" : "goodbye" return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types index d003b6b32f1..9a99ae7605b 100644 --- a/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types +++ b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types @@ -4,7 +4,7 @@ class C { static staticProp = 10; >staticProp : number ->10 : number +>10 : 10 get [C.staticProp]() { >C.staticProp : number @@ -12,7 +12,7 @@ class C { >staticProp : number return "hello"; ->"hello" : string +>"hello" : "hello" } set [C.staticProp](x: string) { >C.staticProp : number diff --git a/tests/baselines/reference/concatError.types b/tests/baselines/reference/concatError.types index 9624342bd21..bb9a85a91b4 100644 --- a/tests/baselines/reference/concatError.types +++ b/tests/baselines/reference/concatError.types @@ -20,7 +20,7 @@ fa = fa.concat([0]); >fa : number[] >concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; } >[0] : number[] ->0 : number +>0 : 0 fa = fa.concat(0); >fa = fa.concat(0) : number[] @@ -29,7 +29,7 @@ fa = fa.concat(0); >fa.concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; } >fa : number[] >concat : { (...items: number[][]): number[]; (...items: (number | number[])[]): number[]; } ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/concatTuples.types b/tests/baselines/reference/concatTuples.types index 3923470b78d..fbb3ce96a57 100644 --- a/tests/baselines/reference/concatTuples.types +++ b/tests/baselines/reference/concatTuples.types @@ -3,8 +3,8 @@ let ijs: [number, number][] = [[1, 2]]; >ijs : [number, number][] >[[1, 2]] : [number, number][] >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 ijs = ijs.concat([[3, 4], [5, 6]]); >ijs = ijs.concat([[3, 4], [5, 6]]) : [number, number][] @@ -15,9 +15,9 @@ ijs = ijs.concat([[3, 4], [5, 6]]); >concat : { (...items: [number, number][][]): [number, number][]; (...items: ([number, number] | [number, number][])[]): [number, number][]; } >[[3, 4], [5, 6]] : [number, number][] >[3, 4] : [number, number] ->3 : number ->4 : number +>3 : 3 +>4 : 4 >[5, 6] : [number, number] ->5 : number ->6 : number +>5 : 5 +>6 : 6 diff --git a/tests/baselines/reference/conditionalExpression1.errors.txt b/tests/baselines/reference/conditionalExpression1.errors.txt index 0e291986785..66af5336808 100644 --- a/tests/baselines/reference/conditionalExpression1.errors.txt +++ b/tests/baselines/reference/conditionalExpression1.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type 'string | number' is not assignable to type 'boolean'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/compiler/conditionalExpression1.ts(1,5): error TS2322: Type '"" | 1' is not assignable to type 'boolean'. + Type '""' is not assignable to type 'boolean'. ==== tests/cases/compiler/conditionalExpression1.ts (1 errors) ==== var x: boolean = (true ? 1 : ""); // should be an error ~ -!!! error TS2322: Type 'string | number' is not assignable to type 'boolean'. -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. \ No newline at end of file +!!! error TS2322: Type '"" | 1' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/conditionalExpressions2.types b/tests/baselines/reference/conditionalExpressions2.types index 77714e664fb..0247b0f649d 100644 --- a/tests/baselines/reference/conditionalExpressions2.types +++ b/tests/baselines/reference/conditionalExpressions2.types @@ -2,53 +2,53 @@ var a = false ? 1 : null; >a : number ->false ? 1 : null : number ->false : boolean ->1 : number +>false ? 1 : null : 1 +>false : false +>1 : 1 >null : null var b = false ? undefined : 0; >b : number ->false ? undefined : 0 : number ->false : boolean +>false ? undefined : 0 : 0 +>false : false >undefined : undefined ->0 : number +>0 : 0 var c = false ? 1 : 0; >c : number ->false ? 1 : 0 : number ->false : boolean ->1 : number ->0 : number +>false ? 1 : 0 : 0 | 1 +>false : false +>1 : 1 +>0 : 0 var d = false ? false : true; >d : boolean >false ? false : true : boolean ->false : boolean ->false : boolean ->true : boolean +>false : false +>false : false +>true : true var e = false ? "foo" : "bar"; >e : string ->false ? "foo" : "bar" : string ->false : boolean ->"foo" : string ->"bar" : string +>false ? "foo" : "bar" : "foo" | "bar" +>false : false +>"foo" : "foo" +>"bar" : "bar" var f = false ? null : undefined; >f : any >false ? null : undefined : null ->false : boolean +>false : false >null : null >undefined : undefined var g = true ? {g:5} : null; >g : { g: number; } >true ? {g:5} : null : { g: number; } ->true : boolean +>true : true >{g:5} : { g: number; } >g : number ->5 : number +>5 : 5 >null : null var h = [{h:5}, null]; @@ -56,14 +56,14 @@ var h = [{h:5}, null]; >[{h:5}, null] : { h: number; }[] >{h:5} : { h: number; } >h : number ->5 : number +>5 : 5 >null : null function i() { if (true) { return { x: 5 }; } else { return null; } } >i : () => { x: number; } ->true : boolean +>true : true >{ x: 5 } : { x: number; } >x : number ->5 : number +>5 : 5 >null : null diff --git a/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.errors.txt b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.errors.txt new file mode 100644 index 00000000000..25153c1ba15 --- /dev/null +++ b/tests/baselines/reference/conditionalOperatorConditionIsBooleanType.errors.txt @@ -0,0 +1,71 @@ +tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditionIsBooleanType.ts(35,1): error TS2365: Operator '>' cannot be applied to types '2' and '1'. +tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditionIsBooleanType.ts(58,23): error TS2365: Operator '>' cannot be applied to types '2' and '1'. + + +==== tests/cases/conformance/expressions/conditonalOperator/conditionalOperatorConditionIsBooleanType.ts (2 errors) ==== + //Cond ? Expr1 : Expr2, Cond is of boolean type, Expr1 and Expr2 have the same type + var condBoolean: boolean; + + var exprAny1: any; + var exprBoolean1: boolean; + var exprNumber1: number; + var exprString1: string; + var exprIsObject1: Object; + + var exprAny2: any; + var exprBoolean2: boolean; + var exprNumber2: number; + var exprString2: string; + var exprIsObject2: Object; + + //Cond is a boolean type variable + condBoolean ? exprAny1 : exprAny2; + condBoolean ? exprBoolean1 : exprBoolean2; + condBoolean ? exprNumber1 : exprNumber2; + condBoolean ? exprString1 : exprString2; + condBoolean ? exprIsObject1 : exprIsObject2; + condBoolean ? exprString1 : exprBoolean1; // union + + //Cond is a boolean type literal + true ? exprAny1 : exprAny2; + false ? exprBoolean1 : exprBoolean2; + true ? exprNumber1 : exprNumber2; + false ? exprString1 : exprString2; + true ? exprIsObject1 : exprIsObject2; + true ? exprString1 : exprBoolean1; // union + + //Cond is a boolean type expression + !true ? exprAny1 : exprAny2; + typeof "123" == "string" ? exprBoolean1 : exprBoolean2; + 2 > 1 ? exprNumber1 : exprNumber2; + ~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types '2' and '1'. + null === undefined ? exprString1 : exprString2; + true || false ? exprIsObject1 : exprIsObject2; + null === undefined ? exprString1 : exprBoolean1; // union + + //Results shoud be same as Expr1 and Expr2 + var resultIsAny1 = condBoolean ? exprAny1 : exprAny2; + var resultIsBoolean1 = condBoolean ? exprBoolean1 : exprBoolean2; + var resultIsNumber1 = condBoolean ? exprNumber1 : exprNumber2; + var resultIsString1 = condBoolean ? exprString1 : exprString2; + var resultIsObject1 = condBoolean ? exprIsObject1 : exprIsObject2; + var resultIsStringOrBoolean1 = condBoolean ? exprString1 : exprBoolean1; // union + + var resultIsAny2 = true ? exprAny1 : exprAny2; + var resultIsBoolean2 = false ? exprBoolean1 : exprBoolean2; + var resultIsNumber2 = true ? exprNumber1 : exprNumber2; + var resultIsString2 = false ? exprString1 : exprString2; + var resultIsObject2 = true ? exprIsObject1 : exprIsObject2; + var resultIsStringOrBoolean2 = true ? exprString1 : exprBoolean1; // union + var resultIsStringOrBoolean3 = false ? exprString1 : exprBoolean1; // union + + var resultIsAny3 = !true ? exprAny1 : exprAny2; + var resultIsBoolean3 = typeof "123" == "string" ? exprBoolean1 : exprBoolean2; + var resultIsNumber3 = 2 > 1 ? exprNumber1 : exprNumber2; + ~~~~~ +!!! error TS2365: Operator '>' cannot be applied to types '2' and '1'. + var resultIsString3 = null === undefined ? exprString1 : exprString2; + var resultIsObject3 = true || false ? exprIsObject1 : exprIsObject2; + var resultIsStringOrBoolean4 = typeof "123" === "string" ? exprString1 : exprBoolean1; // union + \ No newline at end of file diff --git a/tests/baselines/reference/conditionalOperatorConditionIsNumberType.types b/tests/baselines/reference/conditionalOperatorConditionIsNumberType.types index 5951dc07350..f1d7e7bd369 100644 --- a/tests/baselines/reference/conditionalOperatorConditionIsNumberType.types +++ b/tests/baselines/reference/conditionalOperatorConditionIsNumberType.types @@ -75,73 +75,73 @@ condNumber ? exprString1 : exprBoolean1; // Union //Cond is a number type literal 1 ? exprAny1 : exprAny2; >1 ? exprAny1 : exprAny2 : any ->1 : number +>1 : 1 >exprAny1 : any >exprAny2 : any 0 ? exprBoolean1 : exprBoolean2; >0 ? exprBoolean1 : exprBoolean2 : boolean ->0 : number +>0 : 0 >exprBoolean1 : boolean >exprBoolean2 : boolean 0.123456789 ? exprNumber1 : exprNumber2; >0.123456789 ? exprNumber1 : exprNumber2 : number ->0.123456789 : number +>0.123456789 : 0.123456789 >exprNumber1 : number >exprNumber2 : number - 10000000000000 ? exprString1 : exprString2; >- 10000000000000 ? exprString1 : exprString2 : string ->- 10000000000000 : number ->10000000000000 : number +>- 10000000000000 : -10000000000000 +>10000000000000 : 10000000000000 >exprString1 : string >exprString2 : string 1000000000000 ? exprIsObject1 : exprIsObject2; >1000000000000 ? exprIsObject1 : exprIsObject2 : Object ->1000000000000 : number +>1000000000000 : 1000000000000 >exprIsObject1 : Object >exprIsObject2 : Object 10000 ? exprString1 : exprBoolean1; // Union >10000 ? exprString1 : exprBoolean1 : string | boolean ->10000 : number +>10000 : 10000 >exprString1 : string >exprBoolean1 : boolean //Cond is a number type expression function foo() { return 1 }; >foo : () => number ->1 : number +>1 : 1 var array = [1, 2, 3]; >array : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 1 * 0 ? exprAny1 : exprAny2; >1 * 0 ? exprAny1 : exprAny2 : any >1 * 0 : number ->1 : number ->0 : number +>1 : 1 +>0 : 0 >exprAny1 : any >exprAny2 : any 1 + 1 ? exprBoolean1 : exprBoolean2; >1 + 1 ? exprBoolean1 : exprBoolean2 : boolean >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 >exprBoolean1 : boolean >exprBoolean2 : boolean "string".length ? exprNumber1 : exprNumber2; >"string".length ? exprNumber1 : exprNumber2 : number >"string".length : number ->"string" : string +>"string" : "string" >length : number >exprNumber1 : number >exprNumber2 : number @@ -160,7 +160,7 @@ foo() / array[1] ? exprIsObject1 : exprIsObject2; >foo : () => number >array[1] : number >array : number[] ->1 : number +>1 : 1 >exprIsObject1 : Object >exprIsObject2 : Object @@ -217,43 +217,43 @@ var resultIsStringOrBoolean1 = condNumber ? exprString1 : exprBoolean1; // Union var resultIsAny2 = 1 ? exprAny1 : exprAny2; >resultIsAny2 : any >1 ? exprAny1 : exprAny2 : any ->1 : number +>1 : 1 >exprAny1 : any >exprAny2 : any var resultIsBoolean2 = 0 ? exprBoolean1 : exprBoolean2; >resultIsBoolean2 : boolean >0 ? exprBoolean1 : exprBoolean2 : boolean ->0 : number +>0 : 0 >exprBoolean1 : boolean >exprBoolean2 : boolean var resultIsNumber2 = 0.123456789 ? exprNumber1 : exprNumber2; >resultIsNumber2 : number >0.123456789 ? exprNumber1 : exprNumber2 : number ->0.123456789 : number +>0.123456789 : 0.123456789 >exprNumber1 : number >exprNumber2 : number var resultIsString2 = - 10000000000000 ? exprString1 : exprString2; >resultIsString2 : string >- 10000000000000 ? exprString1 : exprString2 : string ->- 10000000000000 : number ->10000000000000 : number +>- 10000000000000 : -10000000000000 +>10000000000000 : 10000000000000 >exprString1 : string >exprString2 : string var resultIsObject2 = 1000000000000 ? exprIsObject1 : exprIsObject2; >resultIsObject2 : Object >1000000000000 ? exprIsObject1 : exprIsObject2 : Object ->1000000000000 : number +>1000000000000 : 1000000000000 >exprIsObject1 : Object >exprIsObject2 : Object var resultIsStringOrBoolean2 = 10000 ? exprString1 : exprBoolean1; // Union >resultIsStringOrBoolean2 : string | boolean >10000 ? exprString1 : exprBoolean1 : string | boolean ->10000 : number +>10000 : 10000 >exprString1 : string >exprBoolean1 : boolean @@ -261,8 +261,8 @@ var resultIsAny3 = 1 * 0 ? exprAny1 : exprAny2; >resultIsAny3 : any >1 * 0 ? exprAny1 : exprAny2 : any >1 * 0 : number ->1 : number ->0 : number +>1 : 1 +>0 : 0 >exprAny1 : any >exprAny2 : any @@ -270,8 +270,8 @@ var resultIsBoolean3 = 1 + 1 ? exprBoolean1 : exprBoolean2; >resultIsBoolean3 : boolean >1 + 1 ? exprBoolean1 : exprBoolean2 : boolean >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 >exprBoolean1 : boolean >exprBoolean2 : boolean @@ -279,7 +279,7 @@ var resultIsNumber3 = "string".length ? exprNumber1 : exprNumber2; >resultIsNumber3 : number >"string".length ? exprNumber1 : exprNumber2 : number >"string".length : number ->"string" : string +>"string" : "string" >length : number >exprNumber1 : number >exprNumber2 : number @@ -300,7 +300,7 @@ var resultIsObject3 = foo() / array[1] ? exprIsObject1 : exprIsObject2; >foo : () => number >array[1] : number >array : number[] ->1 : number +>1 : 1 >exprIsObject1 : Object >exprIsObject2 : Object @@ -312,7 +312,7 @@ var resultIsStringOrBoolean3 = foo() / array[1] ? exprString1 : exprBoolean1; // >foo : () => number >array[1] : number >array : number[] ->1 : number +>1 : 1 >exprString1 : string >exprBoolean1 : boolean diff --git a/tests/baselines/reference/conditionalOperatorConditionIsObjectType.types b/tests/baselines/reference/conditionalOperatorConditionIsObjectType.types index 14a0f375ead..34cfe67f602 100644 --- a/tests/baselines/reference/conditionalOperatorConditionIsObjectType.types +++ b/tests/baselines/reference/conditionalOperatorConditionIsObjectType.types @@ -115,9 +115,9 @@ condObject ? exprString1 : exprBoolean1; // union >({ a: 1, b: "s" }) : { a: number; b: string; } >{ a: 1, b: "s" } : { a: number; b: string; } >a : number ->1 : number +>1 : 1 >b : string ->"s" : string +>"s" : "s" >exprString1 : string >exprString2 : string @@ -126,9 +126,9 @@ condObject ? exprString1 : exprBoolean1; // union >({ a: 1, b: "s" }) : { a: number; b: string; } >{ a: 1, b: "s" } : { a: number; b: string; } >a : number ->1 : number +>1 : 1 >b : string ->"s" : string +>"s" : "s" >exprIsObject1 : Object >exprIsObject2 : Object @@ -137,9 +137,9 @@ condObject ? exprString1 : exprBoolean1; // union >({ a: 1, b: "s" }) : { a: number; b: string; } >{ a: 1, b: "s" } : { a: number; b: string; } >a : number ->1 : number +>1 : 1 >b : string ->"s" : string +>"s" : "s" >exprString1 : string >exprBoolean1 : boolean @@ -271,9 +271,9 @@ var resultIsString2 = ({ a: 1, b: "s" }) ? exprString1 : exprString2; >({ a: 1, b: "s" }) : { a: number; b: string; } >{ a: 1, b: "s" } : { a: number; b: string; } >a : number ->1 : number +>1 : 1 >b : string ->"s" : string +>"s" : "s" >exprString1 : string >exprString2 : string @@ -283,9 +283,9 @@ var resultIsObject2 = ({ a: 1, b: "s" }) ? exprIsObject1 : exprIsObject2; >({ a: 1, b: "s" }) : { a: number; b: string; } >{ a: 1, b: "s" } : { a: number; b: string; } >a : number ->1 : number +>1 : 1 >b : string ->"s" : string +>"s" : "s" >exprIsObject1 : Object >exprIsObject2 : Object @@ -295,9 +295,9 @@ var resultIsStringOrBoolean2 = ({ a: 1, b: "s" }) ? exprString1 : exprBoolean1; >({ a: 1, b: "s" }) : { a: number; b: string; } >{ a: 1, b: "s" } : { a: number; b: string; } >a : number ->1 : number +>1 : 1 >b : string ->"s" : string +>"s" : "s" >exprString1 : string >exprBoolean1 : boolean diff --git a/tests/baselines/reference/conditionalOperatorConditoinIsAnyType.types b/tests/baselines/reference/conditionalOperatorConditoinIsAnyType.types index d79e570ec42..5903a10d4e5 100644 --- a/tests/baselines/reference/conditionalOperatorConditoinIsAnyType.types +++ b/tests/baselines/reference/conditionalOperatorConditoinIsAnyType.types @@ -130,7 +130,7 @@ x("x") ? exprBoolean1 : exprBoolean2; >x("x") ? exprBoolean1 : exprBoolean2 : boolean >x("x") : any >x : any ->"x" : string +>"x" : "x" >exprBoolean1 : boolean >exprBoolean2 : boolean @@ -146,7 +146,7 @@ x("x") ? exprString1 : exprString2; >x("x") ? exprString1 : exprString2 : string >x("x") : any >x : any ->"x" : string +>"x" : "x" >exprString1 : string >exprString2 : string @@ -288,7 +288,7 @@ var resultIsBoolean3 = x("x") ? exprBoolean1 : exprBoolean2; >x("x") ? exprBoolean1 : exprBoolean2 : boolean >x("x") : any >x : any ->"x" : string +>"x" : "x" >exprBoolean1 : boolean >exprBoolean2 : boolean @@ -306,7 +306,7 @@ var resultIsString3 = x("x") ? exprString1 : exprString2; >x("x") ? exprString1 : exprString2 : string >x("x") : any >x : any ->"x" : string +>"x" : "x" >exprString1 : string >exprString2 : string diff --git a/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types b/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types index af5abb25063..a6906d7024a 100644 --- a/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types +++ b/tests/baselines/reference/conditionalOperatorConditoinIsStringType.types @@ -75,51 +75,51 @@ condString ? exprString1 : exprBoolean1; // union //Cond is a string type literal "" ? exprAny1 : exprAny2; >"" ? exprAny1 : exprAny2 : any ->"" : string +>"" : "" >exprAny1 : any >exprAny2 : any "string" ? exprBoolean1 : exprBoolean2; >"string" ? exprBoolean1 : exprBoolean2 : boolean ->"string" : string +>"string" : "string" >exprBoolean1 : boolean >exprBoolean2 : boolean 'c' ? exprNumber1 : exprNumber2; >'c' ? exprNumber1 : exprNumber2 : number ->'c' : string +>'c' : "c" >exprNumber1 : number >exprNumber2 : number 'string' ? exprString1 : exprString2; >'string' ? exprString1 : exprString2 : string ->'string' : string +>'string' : "string" >exprString1 : string >exprString2 : string " " ? exprIsObject1 : exprIsObject2; >" " ? exprIsObject1 : exprIsObject2 : Object ->" " : string +>" " : " " >exprIsObject1 : Object >exprIsObject2 : Object "hello " ? exprString1 : exprBoolean1; // union >"hello " ? exprString1 : exprBoolean1 : string | boolean ->"hello " : string +>"hello " : "hello " >exprString1 : string >exprBoolean1 : boolean //Cond is a string type expression function foo() { return "string" }; >foo : () => string ->"string" : string +>"string" : "string" var array = ["1", "2", "3"]; >array : string[] >["1", "2", "3"] : string[] ->"1" : string ->"2" : string ->"3" : string +>"1" : "1" +>"2" : "2" +>"3" : "3" typeof condString ? exprAny1 : exprAny2; >typeof condString ? exprAny1 : exprAny2 : any @@ -140,7 +140,7 @@ condString + "string" ? exprNumber1 : exprNumber2; >condString + "string" ? exprNumber1 : exprNumber2 : number >condString + "string" : string >condString : string ->"string" : string +>"string" : "string" >exprNumber1 : number >exprNumber2 : number @@ -155,7 +155,7 @@ array[1] ? exprIsObject1 : exprIsObject2; >array[1] ? exprIsObject1 : exprIsObject2 : Object >array[1] : string >array : string[] ->1 : number +>1 : 1 >exprIsObject1 : Object >exprIsObject2 : Object @@ -212,42 +212,42 @@ var resultIsStringOrBoolean1 = condString ? exprString1 : exprBoolean1; // union var resultIsAny2 = "" ? exprAny1 : exprAny2; >resultIsAny2 : any >"" ? exprAny1 : exprAny2 : any ->"" : string +>"" : "" >exprAny1 : any >exprAny2 : any var resultIsBoolean2 = "string" ? exprBoolean1 : exprBoolean2; >resultIsBoolean2 : boolean >"string" ? exprBoolean1 : exprBoolean2 : boolean ->"string" : string +>"string" : "string" >exprBoolean1 : boolean >exprBoolean2 : boolean var resultIsNumber2 = 'c' ? exprNumber1 : exprNumber2; >resultIsNumber2 : number >'c' ? exprNumber1 : exprNumber2 : number ->'c' : string +>'c' : "c" >exprNumber1 : number >exprNumber2 : number var resultIsString2 = 'string' ? exprString1 : exprString2; >resultIsString2 : string >'string' ? exprString1 : exprString2 : string ->'string' : string +>'string' : "string" >exprString1 : string >exprString2 : string var resultIsObject2 = " " ? exprIsObject1 : exprIsObject2; >resultIsObject2 : Object >" " ? exprIsObject1 : exprIsObject2 : Object ->" " : string +>" " : " " >exprIsObject1 : Object >exprIsObject2 : Object var resultIsStringOrBoolean2 = "hello" ? exprString1 : exprBoolean1; // union >resultIsStringOrBoolean2 : string | boolean >"hello" ? exprString1 : exprBoolean1 : string | boolean ->"hello" : string +>"hello" : "hello" >exprString1 : string >exprBoolean1 : boolean @@ -273,7 +273,7 @@ var resultIsNumber3 = condString + "string" ? exprNumber1 : exprNumber2; >condString + "string" ? exprNumber1 : exprNumber2 : number >condString + "string" : string >condString : string ->"string" : string +>"string" : "string" >exprNumber1 : number >exprNumber2 : number @@ -290,7 +290,7 @@ var resultIsObject3 = array[1] ? exprIsObject1 : exprIsObject2; >array[1] ? exprIsObject1 : exprIsObject2 : Object >array[1] : string >array : string[] ->1 : number +>1 : 1 >exprIsObject1 : Object >exprIsObject2 : Object diff --git a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types index 3f5f6454eda..3a655853163 100644 --- a/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types +++ b/tests/baselines/reference/conditionalOperatorWithIdenticalBCT.types @@ -32,62 +32,62 @@ var b: B; //Be Not contextually typed true ? x : a; >true ? x : a : X ->true : boolean +>true : true >x : X >a : A var result1 = true ? x : a; >result1 : X >true ? x : a : X ->true : boolean +>true : true >x : X >a : A //Expr1 and Expr2 are literals true ? {} : 1; >true ? {} : 1 : {} ->true : boolean +>true : true >{} : {} ->1 : number +>1 : 1 true ? { a: 1 } : { a: 2, b: 'string' }; >true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } | { a: number; b: string; } ->true : boolean +>true : true >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 >{ a: 2, b: 'string' } : { a: number; b: string; } >a : number ->2 : number +>2 : 2 >b : string ->'string' : string +>'string' : "string" var result2 = true ? {} : 1; >result2 : {} >true ? {} : 1 : {} ->true : boolean +>true : true >{} : {} ->1 : number +>1 : 1 var result3 = true ? { a: 1 } : { a: 2, b: 'string' }; >result3 : { a: number; } | { a: number; b: string; } >true ? { a: 1 } : { a: 2, b: 'string' } : { a: number; } | { a: number; b: string; } ->true : boolean +>true : true >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 >{ a: 2, b: 'string' } : { a: number; b: string; } >a : number ->2 : number +>2 : 2 >b : string ->'string' : string +>'string' : "string" //Contextually typed var resultIsX1: X = true ? x : a; >resultIsX1 : X >X : X >true ? x : a : X ->true : boolean +>true : true >x : X >a : A @@ -96,7 +96,7 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; >t : A >A : A >true ? (m) => m.propertyX : (n) => n.propertyA : (m: A) => any ->true : boolean +>true : true >(m) => m.propertyX : (m: A) => any >m : A >m.propertyX : any @@ -112,62 +112,62 @@ var result4: (t: A) => any = true ? (m) => m.propertyX : (n) => n.propertyA; //Be Not contextually typed true ? a : x; >true ? a : x : X ->true : boolean +>true : true >a : A >x : X var result5 = true ? a : x; >result5 : X >true ? a : x : X ->true : boolean +>true : true >a : A >x : X //Expr1 and Expr2 are literals true ? 1 : {}; >true ? 1 : {} : {} ->true : boolean ->1 : number +>true : true +>1 : 1 >{} : {} true ? { a: 2, b: 'string' } : { a: 1 }; >true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; b: string; } | { a: number; } ->true : boolean +>true : true >{ a: 2, b: 'string' } : { a: number; b: string; } >a : number ->2 : number +>2 : 2 >b : string ->'string' : string +>'string' : "string" >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 var result6 = true ? 1 : {}; >result6 : {} >true ? 1 : {} : {} ->true : boolean ->1 : number +>true : true +>1 : 1 >{} : {} var result7 = true ? { a: 2, b: 'string' } : { a: 1 }; >result7 : { a: number; b: string; } | { a: number; } >true ? { a: 2, b: 'string' } : { a: 1 } : { a: number; b: string; } | { a: number; } ->true : boolean +>true : true >{ a: 2, b: 'string' } : { a: number; b: string; } >a : number ->2 : number +>2 : 2 >b : string ->'string' : string +>'string' : "string" >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 //Contextually typed var resultIsX2: X = true ? x : a; >resultIsX2 : X >X : X >true ? x : a : X ->true : boolean +>true : true >x : X >a : A @@ -176,7 +176,7 @@ var result8: (t: A) => any = true ? (m) => m.propertyA : (n) => n.propertyX; >t : A >A : A >true ? (m) => m.propertyA : (n) => n.propertyX : (n: A) => any ->true : boolean +>true : true >(m) => m.propertyA : (m: A) => number >m : A >m.propertyA : number @@ -194,7 +194,7 @@ var resultIsX3: X = true ? a : b; >resultIsX3 : X >X : X >true ? a : b : A | B ->true : boolean +>true : true >a : A >b : B @@ -203,7 +203,7 @@ var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2; >t : X >X : X >true ? (m) => m.propertyX1 : (n) => n.propertyX2 : ((m: X) => number) | ((n: X) => string) ->true : boolean +>true : true >(m) => m.propertyX1 : (m: X) => number >m : X >m.propertyX1 : number @@ -218,8 +218,8 @@ var result10: (t: X) => any = true ? (m) => m.propertyX1 : (n) => n.propertyX2; //Expr1 and Expr2 are literals var result11: any = true ? 1 : 'string'; >result11 : any ->true ? 1 : 'string' : string | number ->true : boolean ->1 : number ->'string' : string +>true ? 1 : 'string' : 1 | "string" +>true : true +>1 : 1 +>'string' : "string" diff --git a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration2.types b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration2.types index a5a7dd1d0cd..23e81800264 100644 --- a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration2.types +++ b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration2.types @@ -5,14 +5,14 @@ function outer() { >outer : () => void const x = 0; ->x : number ->0 : number +>x : 0 +>0 : 0 function inner() { >inner : () => void var x = "inner"; >x : string ->"inner" : string +>"inner" : "inner" } } diff --git a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types index 1271d4ef869..919a9eb96f2 100644 --- a/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types +++ b/tests/baselines/reference/constDeclarationShadowedByVarDeclaration3.types @@ -8,11 +8,11 @@ class Rule { >RegExp : RegExp >new RegExp('') : RegExp >RegExp : RegExpConstructor ->'' : string +>'' : "" public name: string = ''; >name : string ->'' : string +>'' : "" constructor(name: string) { >name : string diff --git a/tests/baselines/reference/constDeclarations-errors.errors.txt b/tests/baselines/reference/constDeclarations-errors.errors.txt index 98b12b616f7..2c9c17cc102 100644 --- a/tests/baselines/reference/constDeclarations-errors.errors.txt +++ b/tests/baselines/reference/constDeclarations-errors.errors.txt @@ -4,12 +4,14 @@ tests/cases/compiler/constDeclarations-errors.ts(5,7): error TS1155: 'const' dec tests/cases/compiler/constDeclarations-errors.ts(5,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,15): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(5,27): error TS1155: 'const' declarations must be initialized +tests/cases/compiler/constDeclarations-errors.ts(10,19): error TS2365: Operator '<' cannot be applied to types '0' and '1'. tests/cases/compiler/constDeclarations-errors.ts(10,27): error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. tests/cases/compiler/constDeclarations-errors.ts(13,11): error TS1155: 'const' declarations must be initialized tests/cases/compiler/constDeclarations-errors.ts(16,20): error TS1155: 'const' declarations must be initialized +tests/cases/compiler/constDeclarations-errors.ts(16,25): error TS2365: Operator '<' cannot be applied to types '0' and '1'. -==== tests/cases/compiler/constDeclarations-errors.ts (9 errors) ==== +==== tests/cases/compiler/constDeclarations-errors.ts (11 errors) ==== // error, missing intialicer const c1; @@ -32,6 +34,8 @@ tests/cases/compiler/constDeclarations-errors.ts(16,20): error TS1155: 'const' d // error, assigning to a const for(const c8 = 0; c8 < 1; c8++) { } + ~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. ~~ !!! error TS2449: The operand of an increment or decrement operator cannot be a constant or a read-only property. @@ -43,4 +47,6 @@ tests/cases/compiler/constDeclarations-errors.ts(16,20): error TS1155: 'const' d // error, can not be unintalized for(const c10 = 0, c11; c10 < 1;) { } ~~~ -!!! error TS1155: 'const' declarations must be initialized \ No newline at end of file +!!! error TS1155: 'const' declarations must be initialized + ~~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '1'. \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations-es5.types b/tests/baselines/reference/constDeclarations-es5.types index a897c3f9cd0..e801607727e 100644 --- a/tests/baselines/reference/constDeclarations-es5.types +++ b/tests/baselines/reference/constDeclarations-es5.types @@ -1,18 +1,18 @@ === tests/cases/compiler/constDeclarations-es5.ts === const z7 = false; ->z7 : boolean ->false : boolean +>z7 : false +>false : false const z8: number = 23; >z8 : number ->23 : number +>23 : 23 const z9 = 0, z10 :string = "", z11 = null; ->z9 : number ->0 : number +>z9 : 0 +>0 : 0 >z10 : string ->"" : string +>"" : "" >z11 : any >null : null diff --git a/tests/baselines/reference/constDeclarations-scopes2.errors.txt b/tests/baselines/reference/constDeclarations-scopes2.errors.txt new file mode 100644 index 00000000000..b998f3a9980 --- /dev/null +++ b/tests/baselines/reference/constDeclarations-scopes2.errors.txt @@ -0,0 +1,21 @@ +tests/cases/compiler/constDeclarations-scopes2.ts(9,19): error TS2365: Operator '<' cannot be applied to types '0' and '10'. + + +==== tests/cases/compiler/constDeclarations-scopes2.ts (1 errors) ==== + + // global + const c = "string"; + + var n: number; + var b: boolean; + + // for scope + for (const c = 0; c < 10; n = c ) { + ~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '10'. + // for block + const c = false; + b = c; + } + + \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations.errors.txt b/tests/baselines/reference/constDeclarations.errors.txt new file mode 100644 index 00000000000..1642610eec2 --- /dev/null +++ b/tests/baselines/reference/constDeclarations.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/constDeclarations.ts(8,19): error TS2365: Operator '<' cannot be applied to types '0' and '9'. + + +==== tests/cases/compiler/constDeclarations.ts (1 errors) ==== + + // No error + const c1 = false; + const c2: number = 23; + const c3 = 0, c4 :string = "", c5 = null; + + + for(const c4 = 0; c4 < 9; ) { break; } + ~~~~~~ +!!! error TS2365: Operator '<' cannot be applied to types '0' and '9'. + + + for(const c5 = 0, c6 = 0; c5 < c6; ) { break; } \ No newline at end of file diff --git a/tests/baselines/reference/constDeclarations.js b/tests/baselines/reference/constDeclarations.js index 060c0aba61c..7e5902ed5a1 100644 --- a/tests/baselines/reference/constDeclarations.js +++ b/tests/baselines/reference/constDeclarations.js @@ -25,6 +25,6 @@ for (const c5 = 0, c6 = 0; c5 < c6;) { //// [constDeclarations.d.ts] -declare const c1: boolean; +declare const c1: false; declare const c2: number; -declare const c3: number, c4: string, c5: any; +declare const c3: 0, c4: string, c5: any; diff --git a/tests/baselines/reference/constDeclarations2.js b/tests/baselines/reference/constDeclarations2.js index e4ee67ebdcd..ea7134d4664 100644 --- a/tests/baselines/reference/constDeclarations2.js +++ b/tests/baselines/reference/constDeclarations2.js @@ -20,7 +20,7 @@ var M; //// [constDeclarations2.d.ts] declare module M { - const c1: boolean; + const c1: false; const c2: number; - const c3: number, c4: string, c5: any; + const c3: 0, c4: string, c5: any; } diff --git a/tests/baselines/reference/constDeclarations2.types b/tests/baselines/reference/constDeclarations2.types index f8184b8f8e0..54a273dfb4d 100644 --- a/tests/baselines/reference/constDeclarations2.types +++ b/tests/baselines/reference/constDeclarations2.types @@ -5,18 +5,18 @@ module M { >M : typeof M export const c1 = false; ->c1 : boolean ->false : boolean +>c1 : false +>false : false export const c2: number = 23; >c2 : number ->23 : number +>23 : 23 export const c3 = 0, c4 :string = "", c5 = null; ->c3 : number ->0 : number +>c3 : 0 +>0 : 0 >c4 : string ->"" : string +>"" : "" >c5 : any >null : null } diff --git a/tests/baselines/reference/constEnum1.types b/tests/baselines/reference/constEnum1.types index 9ae95992847..17f6f5de278 100644 --- a/tests/baselines/reference/constEnum1.types +++ b/tests/baselines/reference/constEnum1.types @@ -9,7 +9,7 @@ const enum E { a = 10, >a : E ->10 : number +>10 : 10 b = a, >b : E @@ -20,7 +20,7 @@ const enum E { >(a+1) : number >a+1 : number >a : E ->1 : number +>1 : 1 e, >e : E @@ -35,16 +35,16 @@ const enum E { >a << 2 >> 1 : number >a << 2 : number >a : E ->2 : number ->1 : number +>2 : 2 +>1 : 1 g = a << 2 >>> 1, >g : E >a << 2 >>> 1 : number >a << 2 : number >a : E ->2 : number ->1 : number +>2 : 2 +>1 : 1 h = a | b >h : E diff --git a/tests/baselines/reference/constEnumDeclarations.types b/tests/baselines/reference/constEnumDeclarations.types index 481c2673660..1f86028b385 100644 --- a/tests/baselines/reference/constEnumDeclarations.types +++ b/tests/baselines/reference/constEnumDeclarations.types @@ -5,11 +5,11 @@ const enum E { A = 1, >A : E ->1 : number +>1 : 1 B = 2, >B : E ->2 : number +>2 : 2 C = A | B >C : E @@ -22,12 +22,12 @@ const enum E2 { >E2 : E2 A = 1, ->A : E2 ->1 : number +>A : E2.A +>1 : 1 B, ->B : E2 +>B : E2.B C ->C : E2 +>C : E2.C } diff --git a/tests/baselines/reference/constEnumExternalModule.types b/tests/baselines/reference/constEnumExternalModule.types index 5d03b77b1b7..2bd978a2caf 100644 --- a/tests/baselines/reference/constEnumExternalModule.types +++ b/tests/baselines/reference/constEnumExternalModule.types @@ -14,7 +14,7 @@ const enum E { V = 100 >V : E ->100 : number +>100 : 100 } export = E diff --git a/tests/baselines/reference/constEnumMergingWithValues4.types b/tests/baselines/reference/constEnumMergingWithValues4.types index 92d04fc10cc..8df07d3026d 100644 --- a/tests/baselines/reference/constEnumMergingWithValues4.types +++ b/tests/baselines/reference/constEnumMergingWithValues4.types @@ -13,7 +13,7 @@ module foo { var x = 1; >x : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/constEnumOnlyModuleMerging.types b/tests/baselines/reference/constEnumOnlyModuleMerging.types index 452c0f46add..ec78f39e055 100644 --- a/tests/baselines/reference/constEnumOnlyModuleMerging.types +++ b/tests/baselines/reference/constEnumOnlyModuleMerging.types @@ -4,7 +4,7 @@ module Outer { export var x = 1; >x : number ->1 : number +>1 : 1 } module Outer { diff --git a/tests/baselines/reference/constEnumPropertyAccess1.types b/tests/baselines/reference/constEnumPropertyAccess1.types index e32ae5a6449..869a31d5e1f 100644 --- a/tests/baselines/reference/constEnumPropertyAccess1.types +++ b/tests/baselines/reference/constEnumPropertyAccess1.types @@ -9,11 +9,11 @@ const enum G { A = 1, >A : G ->1 : number +>1 : 1 B = 2, >B : G ->2 : number +>2 : 2 C = A + B, >C : G @@ -25,7 +25,7 @@ const enum G { >D : G >A * 2 : number >A : G ->2 : number +>2 : 2 } var o: { @@ -52,7 +52,7 @@ var a1 = G["A"]; >a1 : G >G["A"] : G >G : typeof G ->"A" : string +>"A" : "A" var g = o[G.A]; >g : boolean @@ -76,7 +76,7 @@ class C { >B : G return true; ->true : boolean +>true : true } set [G.B](x: number) { } >G.B : G diff --git a/tests/baselines/reference/constEnumPropertyAccess2.errors.txt b/tests/baselines/reference/constEnumPropertyAccess2.errors.txt index a943ee00962..ef5dd331d32 100644 --- a/tests/baselines/reference/constEnumPropertyAccess2.errors.txt +++ b/tests/baselines/reference/constEnumPropertyAccess2.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(14,9): error TS2475: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment. tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(15,12): error TS2476: A const enum member can only be accessed using a string literal. -tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(17,1): error TS2322: Type 'string' is not assignable to type 'G'. +tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(17,1): error TS2322: Type '"string"' is not assignable to type 'G'. tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,1): error TS2450: Left-hand side of assignment expression cannot be a constant or a read-only property. @@ -27,7 +27,7 @@ tests/cases/conformance/constEnums/constEnumPropertyAccess2.ts(19,1): error TS24 var g: G; g = "string"; ~ -!!! error TS2322: Type 'string' is not assignable to type 'G'. +!!! error TS2322: Type '"string"' is not assignable to type 'G'. function foo(x: G) { } G.B = 3; ~~~ diff --git a/tests/baselines/reference/constEnumToStringNoComments.types b/tests/baselines/reference/constEnumToStringNoComments.types index 21c4dc6c703..eef69de320d 100644 --- a/tests/baselines/reference/constEnumToStringNoComments.types +++ b/tests/baselines/reference/constEnumToStringNoComments.types @@ -3,138 +3,138 @@ const enum Foo { >Foo : Foo X = 100, ->X : Foo ->100 : number +>X : Foo.X +>100 : 100 Y = 0.5, ->Y : Foo ->0.5 : number +>Y : Foo.Y +>0.5 : 0.5 Z = 2., ->Z : Foo ->2. : number +>Z : Foo.Z +>2. : 2 A = -1, ->A : Foo ->-1 : number ->1 : number +>A : Foo.A +>-1 : -1 +>1 : 1 B = -1.5, ->B : Foo ->-1.5 : number ->1.5 : number +>B : Foo.B +>-1.5 : -1.5 +>1.5 : 1.5 C = -1. ->C : Foo ->-1. : number ->1. : number +>C : Foo.A +>-1. : -1 +>1. : 1 } let x0 = Foo.X.toString(); >x0 : string >Foo.X.toString() : string >Foo.X.toString : (radix?: number) => string ->Foo.X : Foo +>Foo.X : Foo.X >Foo : typeof Foo ->X : Foo +>X : Foo.X >toString : (radix?: number) => string let x1 = Foo["X"].toString(); >x1 : string >Foo["X"].toString() : string >Foo["X"].toString : (radix?: number) => string ->Foo["X"] : Foo +>Foo["X"] : Foo.X >Foo : typeof Foo ->"X" : string +>"X" : "X" >toString : (radix?: number) => string let y0 = Foo.Y.toString(); >y0 : string >Foo.Y.toString() : string >Foo.Y.toString : (radix?: number) => string ->Foo.Y : Foo +>Foo.Y : Foo.Y >Foo : typeof Foo ->Y : Foo +>Y : Foo.Y >toString : (radix?: number) => string let y1 = Foo["Y"].toString(); >y1 : string >Foo["Y"].toString() : string >Foo["Y"].toString : (radix?: number) => string ->Foo["Y"] : Foo +>Foo["Y"] : Foo.Y >Foo : typeof Foo ->"Y" : string +>"Y" : "Y" >toString : (radix?: number) => string let z0 = Foo.Z.toString(); >z0 : string >Foo.Z.toString() : string >Foo.Z.toString : (radix?: number) => string ->Foo.Z : Foo +>Foo.Z : Foo.Z >Foo : typeof Foo ->Z : Foo +>Z : Foo.Z >toString : (radix?: number) => string let z1 = Foo["Z"].toString(); >z1 : string >Foo["Z"].toString() : string >Foo["Z"].toString : (radix?: number) => string ->Foo["Z"] : Foo +>Foo["Z"] : Foo.Z >Foo : typeof Foo ->"Z" : string +>"Z" : "Z" >toString : (radix?: number) => string let a0 = Foo.A.toString(); >a0 : string >Foo.A.toString() : string >Foo.A.toString : (radix?: number) => string ->Foo.A : Foo +>Foo.A : Foo.A >Foo : typeof Foo ->A : Foo +>A : Foo.A >toString : (radix?: number) => string let a1 = Foo["A"].toString(); >a1 : string >Foo["A"].toString() : string >Foo["A"].toString : (radix?: number) => string ->Foo["A"] : Foo +>Foo["A"] : Foo.A >Foo : typeof Foo ->"A" : string +>"A" : "A" >toString : (radix?: number) => string let b0 = Foo.B.toString(); >b0 : string >Foo.B.toString() : string >Foo.B.toString : (radix?: number) => string ->Foo.B : Foo +>Foo.B : Foo.B >Foo : typeof Foo ->B : Foo +>B : Foo.B >toString : (radix?: number) => string let b1 = Foo["B"].toString(); >b1 : string >Foo["B"].toString() : string >Foo["B"].toString : (radix?: number) => string ->Foo["B"] : Foo +>Foo["B"] : Foo.B >Foo : typeof Foo ->"B" : string +>"B" : "B" >toString : (radix?: number) => string let c0 = Foo.C.toString(); >c0 : string >Foo.C.toString() : string >Foo.C.toString : (radix?: number) => string ->Foo.C : Foo +>Foo.C : Foo.A >Foo : typeof Foo ->C : Foo +>C : Foo.A >toString : (radix?: number) => string let c1 = Foo["C"].toString(); >c1 : string >Foo["C"].toString() : string >Foo["C"].toString : (radix?: number) => string ->Foo["C"] : Foo +>Foo["C"] : Foo.A >Foo : typeof Foo ->"C" : string +>"C" : "C" >toString : (radix?: number) => string diff --git a/tests/baselines/reference/constEnumToStringWithComments.types b/tests/baselines/reference/constEnumToStringWithComments.types index 72d7d367f5d..ff0e737ec86 100644 --- a/tests/baselines/reference/constEnumToStringWithComments.types +++ b/tests/baselines/reference/constEnumToStringWithComments.types @@ -3,138 +3,138 @@ const enum Foo { >Foo : Foo X = 100, ->X : Foo ->100 : number +>X : Foo.X +>100 : 100 Y = 0.5, ->Y : Foo ->0.5 : number +>Y : Foo.Y +>0.5 : 0.5 Z = 2., ->Z : Foo ->2. : number +>Z : Foo.Z +>2. : 2 A = -1, ->A : Foo ->-1 : number ->1 : number +>A : Foo.A +>-1 : -1 +>1 : 1 B = -1.5, ->B : Foo ->-1.5 : number ->1.5 : number +>B : Foo.B +>-1.5 : -1.5 +>1.5 : 1.5 C = -1. ->C : Foo ->-1. : number ->1. : number +>C : Foo.A +>-1. : -1 +>1. : 1 } let x0 = Foo.X.toString(); >x0 : string >Foo.X.toString() : string >Foo.X.toString : (radix?: number) => string ->Foo.X : Foo +>Foo.X : Foo.X >Foo : typeof Foo ->X : Foo +>X : Foo.X >toString : (radix?: number) => string let x1 = Foo["X"].toString(); >x1 : string >Foo["X"].toString() : string >Foo["X"].toString : (radix?: number) => string ->Foo["X"] : Foo +>Foo["X"] : Foo.X >Foo : typeof Foo ->"X" : string +>"X" : "X" >toString : (radix?: number) => string let y0 = Foo.Y.toString(); >y0 : string >Foo.Y.toString() : string >Foo.Y.toString : (radix?: number) => string ->Foo.Y : Foo +>Foo.Y : Foo.Y >Foo : typeof Foo ->Y : Foo +>Y : Foo.Y >toString : (radix?: number) => string let y1 = Foo["Y"].toString(); >y1 : string >Foo["Y"].toString() : string >Foo["Y"].toString : (radix?: number) => string ->Foo["Y"] : Foo +>Foo["Y"] : Foo.Y >Foo : typeof Foo ->"Y" : string +>"Y" : "Y" >toString : (radix?: number) => string let z0 = Foo.Z.toString(); >z0 : string >Foo.Z.toString() : string >Foo.Z.toString : (radix?: number) => string ->Foo.Z : Foo +>Foo.Z : Foo.Z >Foo : typeof Foo ->Z : Foo +>Z : Foo.Z >toString : (radix?: number) => string let z1 = Foo["Z"].toString(); >z1 : string >Foo["Z"].toString() : string >Foo["Z"].toString : (radix?: number) => string ->Foo["Z"] : Foo +>Foo["Z"] : Foo.Z >Foo : typeof Foo ->"Z" : string +>"Z" : "Z" >toString : (radix?: number) => string let a0 = Foo.A.toString(); >a0 : string >Foo.A.toString() : string >Foo.A.toString : (radix?: number) => string ->Foo.A : Foo +>Foo.A : Foo.A >Foo : typeof Foo ->A : Foo +>A : Foo.A >toString : (radix?: number) => string let a1 = Foo["A"].toString(); >a1 : string >Foo["A"].toString() : string >Foo["A"].toString : (radix?: number) => string ->Foo["A"] : Foo +>Foo["A"] : Foo.A >Foo : typeof Foo ->"A" : string +>"A" : "A" >toString : (radix?: number) => string let b0 = Foo.B.toString(); >b0 : string >Foo.B.toString() : string >Foo.B.toString : (radix?: number) => string ->Foo.B : Foo +>Foo.B : Foo.B >Foo : typeof Foo ->B : Foo +>B : Foo.B >toString : (radix?: number) => string let b1 = Foo["B"].toString(); >b1 : string >Foo["B"].toString() : string >Foo["B"].toString : (radix?: number) => string ->Foo["B"] : Foo +>Foo["B"] : Foo.B >Foo : typeof Foo ->"B" : string +>"B" : "B" >toString : (radix?: number) => string let c0 = Foo.C.toString(); >c0 : string >Foo.C.toString() : string >Foo.C.toString : (radix?: number) => string ->Foo.C : Foo +>Foo.C : Foo.A >Foo : typeof Foo ->C : Foo +>C : Foo.A >toString : (radix?: number) => string let c1 = Foo["C"].toString(); >c1 : string >Foo["C"].toString() : string >Foo["C"].toString : (radix?: number) => string ->Foo["C"] : Foo +>Foo["C"] : Foo.A >Foo : typeof Foo ->"C" : string +>"C" : "C" >toString : (radix?: number) => string diff --git a/tests/baselines/reference/constEnums.types b/tests/baselines/reference/constEnums.types index 83ee20100e5..c0bfef91434 100644 --- a/tests/baselines/reference/constEnums.types +++ b/tests/baselines/reference/constEnums.types @@ -4,7 +4,7 @@ const enum Enum1 { A0 = 100, >A0 : Enum1 ->100 : number +>100 : 100 } const enum Enum1 { @@ -19,7 +19,7 @@ const enum Enum1 { C = 10, >C : Enum1 ->10 : number +>10 : 10 D = A | B, >D : Enum1 @@ -31,20 +31,20 @@ const enum Enum1 { >E : Enum1 >A | 1 : number >A : Enum1 ->1 : number +>1 : 1 F = 1 | A, >F : Enum1 >1 | A : number ->1 : number +>1 : 1 >A : Enum1 G = (1 & 1), >G : Enum1 >(1 & 1) : number >1 & 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 H = ~(A | B), >H : Enum1 @@ -58,12 +58,12 @@ const enum Enum1 { >I : Enum1 >A >>> 1 : number >A : Enum1 ->1 : number +>1 : 1 J = 1 & A, >J : Enum1 >1 & A : number ->1 : number +>1 : 1 >A : Enum1 K = ~(1 | 5), @@ -71,8 +71,8 @@ const enum Enum1 { >~(1 | 5) : number >(1 | 5) : number >1 | 5 : number ->1 : number ->5 : number +>1 : 1 +>5 : 5 L = ~D, >L : Enum1 @@ -89,7 +89,7 @@ const enum Enum1 { >N : Enum1 >E << 1 : number >E : Enum1 ->1 : number +>1 : 1 O = E >> B, >O : Enum1 @@ -101,7 +101,7 @@ const enum Enum1 { >P : Enum1 >E >> 1 : number >E : Enum1 ->1 : number +>1 : 1 Q = -D, >Q : Enum1 @@ -112,12 +112,12 @@ const enum Enum1 { >R : Enum1 >C & 5 : number >C : Enum1 ->5 : number +>5 : 5 S = 5 & C, >S : Enum1 >5 & C : number ->5 : number +>5 : 5 >C : Enum1 T = C | D, @@ -130,12 +130,12 @@ const enum Enum1 { >U : Enum1 >C | 1 : number >C : Enum1 ->1 : number +>1 : 1 V = 10 | D, >V : Enum1 >10 | D : number ->10 : number +>10 : 10 >D : Enum1 W = Enum1.V, @@ -159,13 +159,13 @@ const enum Enum1 { >W3 : Enum1 >Enum1["A0"] : Enum1 >Enum1 : typeof Enum1 ->"A0" : string +>"A0" : "A0" W4 = Enum1["W"], >W4 : Enum1 >Enum1["W"] : Enum1 >Enum1 : typeof Enum1 ->"W" : string +>"W" : "W" } @@ -183,7 +183,7 @@ module A { V1 = 1, >V1 : E ->1 : number +>1 : 1 V2 = A.B.C.E.V1 | 100 >V2 : E @@ -197,7 +197,7 @@ module A { >C : typeof C >E : typeof E >V1 : E ->100 : number +>100 : 100 } } } @@ -226,8 +226,8 @@ module A { >B : typeof B >C : typeof C >E : typeof E ->"V2" : string ->200 : number +>"V2" : "V2" +>200 : 200 } } } @@ -246,12 +246,12 @@ module A1 { >E : E V1 = 10, ->V1 : E ->10 : number +>V1 : E.V1 +>10 : 10 V2 = 110, ->V2 : E ->110 : number +>V2 : E.V2 +>110 : 110 } } } @@ -270,12 +270,12 @@ module A2 { >E : E V1 = 10, ->V1 : E ->10 : number +>V1 : E.V1 +>10 : 10 V2 = 110, ->V2 : E ->110 : number +>V2 : E.V2 +>110 : 110 } } // module C will be classified as value @@ -284,7 +284,7 @@ module A2 { var x = 1 >x : number ->1 : number +>1 : 1 } } } @@ -496,7 +496,7 @@ function foo(x: Enum1) { case Enum1["T"]: >Enum1["T"] : Enum1 >Enum1 : typeof Enum1 ->"T" : string +>"T" : "T" case Enum1.U: >Enum1.U : Enum1 @@ -558,7 +558,7 @@ function bar(e: A.B.C.E): number { >C : typeof A.B.C >E : typeof I >V1 : I ->1 : number +>1 : 1 case A.B.C.E.V2: return 1; >A.B.C.E.V2 : I @@ -570,7 +570,7 @@ function bar(e: A.B.C.E): number { >C : typeof A.B.C >E : typeof I >V2 : I ->1 : number +>1 : 1 case A.B.C.E.V3: return 1; >A.B.C.E.V3 : I @@ -582,6 +582,6 @@ function bar(e: A.B.C.E): number { >C : typeof A.B.C >E : typeof I >V3 : I ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/constIndexedAccess.types b/tests/baselines/reference/constIndexedAccess.types index eb02c7bde2e..0740a6efc67 100644 --- a/tests/baselines/reference/constIndexedAccess.types +++ b/tests/baselines/reference/constIndexedAccess.types @@ -4,10 +4,10 @@ const enum numbers { >numbers : numbers zero, ->zero : numbers +>zero : numbers.zero one ->one : numbers +>one : numbers.one } interface indexAccess { @@ -25,69 +25,69 @@ let s = test[0]; >s : string >test[0] : string >test : indexAccess ->0 : number +>0 : 0 let n = test[1]; >n : number >test[1] : number >test : indexAccess ->1 : number +>1 : 1 let s1 = test[numbers.zero]; >s1 : string >test[numbers.zero] : string >test : indexAccess ->numbers.zero : numbers +>numbers.zero : numbers.zero >numbers : typeof numbers ->zero : numbers +>zero : numbers.zero let n1 = test[numbers.one]; >n1 : number >test[numbers.one] : number >test : indexAccess ->numbers.one : numbers +>numbers.one : numbers.one >numbers : typeof numbers ->one : numbers +>one : numbers.one let s2 = test[numbers["zero"]]; >s2 : string >test[numbers["zero"]] : string >test : indexAccess ->numbers["zero"] : numbers +>numbers["zero"] : numbers.zero >numbers : typeof numbers ->"zero" : string +>"zero" : "zero" let n2 = test[numbers["one"]]; >n2 : number >test[numbers["one"]] : number >test : indexAccess ->numbers["one"] : numbers +>numbers["one"] : numbers.one >numbers : typeof numbers ->"one" : string +>"one" : "one" enum numbersNotConst { >numbersNotConst : numbersNotConst zero, ->zero : numbersNotConst +>zero : numbersNotConst.zero one ->one : numbersNotConst +>one : numbersNotConst.one } let s3 = test[numbersNotConst.zero]; >s3 : any >test[numbersNotConst.zero] : any >test : indexAccess ->numbersNotConst.zero : numbersNotConst +>numbersNotConst.zero : numbersNotConst.zero >numbersNotConst : typeof numbersNotConst ->zero : numbersNotConst +>zero : numbersNotConst.zero let n3 = test[numbersNotConst.one]; >n3 : any >test[numbersNotConst.one] : any >test : indexAccess ->numbersNotConst.one : numbersNotConst +>numbersNotConst.one : numbersNotConst.one >numbersNotConst : typeof numbersNotConst ->one : numbersNotConst +>one : numbersNotConst.one diff --git a/tests/baselines/reference/constructSignaturesWithIdenticalOverloads.types b/tests/baselines/reference/constructSignaturesWithIdenticalOverloads.types index ca2cb6fefb7..8ea80c02d19 100644 --- a/tests/baselines/reference/constructSignaturesWithIdenticalOverloads.types +++ b/tests/baselines/reference/constructSignaturesWithIdenticalOverloads.types @@ -20,8 +20,8 @@ var r1 = new C(1, ''); >r1 : C >new C(1, '') : C >C : typeof C ->1 : number ->'' : string +>1 : 1 +>'' : "" class C2 { >C2 : C2 @@ -46,8 +46,8 @@ var r2 = new C2(1, ''); >r2 : C2 >new C2(1, '') : C2 >C2 : typeof C2 ->1 : number ->'' : string +>1 : 1 +>'' : "" interface I { >I : I @@ -71,8 +71,8 @@ var r3 = new i(1, ''); >r3 : C >new i(1, '') : C >i : I ->1 : number ->'' : string +>1 : 1 +>'' : "" interface I2 { >I2 : I2 @@ -117,8 +117,8 @@ var r4 = new i2(1, ''); >r4 : C2 >new i2(1, '') : C2 >i2 : I2 ->1 : number ->'' : string +>1 : 1 +>'' : "" var a: { >a : { new (x: number, y: string): C; new (x: number, y: string): C; } @@ -138,8 +138,8 @@ var r5 = new a(1, ''); >r5 : C >new a(1, '') : C >a : { new (x: number, y: string): C; new (x: number, y: string): C; } ->1 : number ->'' : string +>1 : 1 +>'' : "" var b: { >b : { new (x: T, y: string): C2; new (x: T, y: string): C2; } @@ -165,6 +165,6 @@ var r6 = new b(1, ''); >r6 : C2 >new b(1, '') : C2 >b : { new (x: T, y: string): C2; new (x: T, y: string): C2; } ->1 : number ->'' : string +>1 : 1 +>'' : "" diff --git a/tests/baselines/reference/constructSignaturesWithOverloads.types b/tests/baselines/reference/constructSignaturesWithOverloads.types index 8ff678c5de8..775006e24e0 100644 --- a/tests/baselines/reference/constructSignaturesWithOverloads.types +++ b/tests/baselines/reference/constructSignaturesWithOverloads.types @@ -20,8 +20,8 @@ var r1 = new C(1, ''); >r1 : C >new C(1, '') : C >C : typeof C ->1 : number ->'' : string +>1 : 1 +>'' : "" class C2 { >C2 : C2 @@ -46,8 +46,8 @@ var r2 = new C2(1, ''); >r2 : C2 >new C2(1, '') : C2 >C2 : typeof C2 ->1 : number ->'' : string +>1 : 1 +>'' : "" interface I { >I : I @@ -71,8 +71,8 @@ var r3 = new i(1, ''); >r3 : C >new i(1, '') : C >i : I ->1 : number ->'' : string +>1 : 1 +>'' : "" interface I2 { >I2 : I2 @@ -118,8 +118,8 @@ var r4 = new i2(1, ''); >r4 : C2 >new i2(1, '') : C2 >i2 : I2 ->1 : number ->'' : string +>1 : 1 +>'' : "" var a: { >a : { new (x: number, y?: string): C; new (x: number, y: string): C; } @@ -139,8 +139,8 @@ var r5 = new a(1, ''); >r5 : C >new a(1, '') : C >a : { new (x: number, y?: string): C; new (x: number, y: string): C; } ->1 : number ->'' : string +>1 : 1 +>'' : "" var b: { >b : { new (x: T, y?: string): C2; new (x: T, y: string): C2; } @@ -166,6 +166,6 @@ var r6 = new b(1, ''); >r6 : C2 >new b(1, '') : C2 >b : { new (x: T, y?: string): C2; new (x: T, y: string): C2; } ->1 : number ->'' : string +>1 : 1 +>'' : "" diff --git a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.types b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.types index e0e86df4a26..6bfac199b2b 100644 --- a/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.types +++ b/tests/baselines/reference/constructorFunctionTypeIsAssignableToBaseType2.types @@ -60,6 +60,6 @@ class Derived2 extends Base { >x : any return 1; ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/constructorImplementationWithDefaultValues.types b/tests/baselines/reference/constructorImplementationWithDefaultValues.types index fa99cc17fe0..fbb78bcb2a9 100644 --- a/tests/baselines/reference/constructorImplementationWithDefaultValues.types +++ b/tests/baselines/reference/constructorImplementationWithDefaultValues.types @@ -7,7 +7,7 @@ class C { constructor(x = 1) { >x : number ->1 : number +>1 : 1 var y = x; >y : number diff --git a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt index 2fb24c0d5d8..9cad967dd77 100644 --- a/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt +++ b/tests/baselines/reference/constructorImplementationWithDefaultValues2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(3,17): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,17): error TS2322: Type 'number' is not assignable to type 'T'. +tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(3,17): error TS2322: Type '1' is not assignable to type 'string'. +tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,17): error TS2322: Type '1' is not assignable to type 'T'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(10,27): error TS2322: Type 'T' is not assignable to type 'U'. tests/cases/conformance/classes/constructorDeclarations/constructorParameters/constructorImplementationWithDefaultValues2.ts(17,17): error TS2322: Type 'Date' is not assignable to type 'T'. @@ -9,7 +9,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co constructor(x); constructor(public x: string = 1) { // error ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '1' is not assignable to type 'string'. var y = x; } } @@ -18,7 +18,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorParameters/co constructor(x: T, y: U); constructor(x: T = 1, public y: U = x) { // error ~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'T'. +!!! error TS2322: Type '1' is not assignable to type 'T'. ~~~~~~~~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. var z = x; diff --git a/tests/baselines/reference/constructorOverloads2.types b/tests/baselines/reference/constructorOverloads2.types index dde032c0fd2..1b75c54c87f 100644 --- a/tests/baselines/reference/constructorOverloads2.types +++ b/tests/baselines/reference/constructorOverloads2.types @@ -45,13 +45,13 @@ var f1 = new Foo("hey"); >f1 : Foo >new Foo("hey") : Foo >Foo : typeof Foo ->"hey" : string +>"hey" : "hey" var f2 = new Foo(0); >f2 : Foo >new Foo(0) : Foo >Foo : typeof Foo ->0 : number +>0 : 0 var f3 = new Foo(f1); >f3 : Foo diff --git a/tests/baselines/reference/constructorParameterShadowsOuterScopes.errors.txt b/tests/baselines/reference/constructorParameterShadowsOuterScopes.errors.txt index 87af1b85f2d..978681dc5b3 100644 --- a/tests/baselines/reference/constructorParameterShadowsOuterScopes.errors.txt +++ b/tests/baselines/reference/constructorParameterShadowsOuterScopes.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/classes/propertyMemberDeclarations/constructorParameterShadowsOuterScopes.ts(8,9): error TS2301: Initializer of instance member variable 'b' cannot reference identifier 'x' declared in the constructor. -tests/cases/conformance/classes/propertyMemberDeclarations/constructorParameterShadowsOuterScopes.ts(10,9): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/classes/propertyMemberDeclarations/constructorParameterShadowsOuterScopes.ts(10,9): error TS2322: Type '2' is not assignable to type 'string'. tests/cases/conformance/classes/propertyMemberDeclarations/constructorParameterShadowsOuterScopes.ts(16,9): error TS2301: Initializer of instance member variable 'b' cannot reference identifier 'y' declared in the constructor. @@ -17,7 +17,7 @@ tests/cases/conformance/classes/propertyMemberDeclarations/constructorParameterS constructor(x: string) { x = 2; // error, x is string ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '2' is not assignable to type 'string'. } } diff --git a/tests/baselines/reference/constructorReturningAPrimitive.types b/tests/baselines/reference/constructorReturningAPrimitive.types index 4b431cfb36b..d3732d3b789 100644 --- a/tests/baselines/reference/constructorReturningAPrimitive.types +++ b/tests/baselines/reference/constructorReturningAPrimitive.types @@ -7,7 +7,7 @@ class A { constructor() { return 1; ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt index 3b9a84fea98..a1a5c5e75b9 100644 --- a/tests/baselines/reference/constructorReturnsInvalidType.errors.txt +++ b/tests/baselines/reference/constructorReturnsInvalidType.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type 'number' is not assignable to type 'X'. +tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2322: Type '1' is not assignable to type 'X'. tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class @@ -7,7 +7,7 @@ tests/cases/compiler/constructorReturnsInvalidType.ts(3,16): error TS2409: Retur constructor() { return 1; ~ -!!! error TS2322: Type 'number' is not assignable to type 'X'. +!!! error TS2322: Type '1' is not assignable to type 'X'. ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } diff --git a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt index 421e629c113..77c63a217e7 100644 --- a/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt +++ b/tests/baselines/reference/constructorWithAssignableReturnExpression.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type 'number' is not assignable to type 'D'. +tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2322: Type '1' is not assignable to type 'D'. tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(12,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignableReturnExpression.ts(26,16): error TS2322: Type '{ x: number; }' is not assignable to type 'F'. Types of property 'x' are incompatible. @@ -20,7 +20,7 @@ tests/cases/conformance/classes/constructorDeclarations/constructorWithAssignabl constructor() { return 1; // error ~ -!!! error TS2322: Type 'number' is not assignable to type 'D'. +!!! error TS2322: Type '1' is not assignable to type 'D'. ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index 4011a51f557..49d3e378855 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -38,9 +38,10 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(160,30): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(160,31): error TS2304: Cannot find name 'Property'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(167,13): error TS2365: Operator '+=' cannot be applied to types 'number' and 'void'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(181,40): error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(182,13): error TS2322: Type 'boolean' is not assignable to type 'number | true'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(184,13): error TS2322: Type 'boolean' is not assignable to type 'number | true'. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(192,13): error TS2322: Type 'boolean' is not assignable to type 'number | true'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(182,13): error TS2322: Type 'boolean' is not assignable to type 'number'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(184,13): error TS2322: Type 'boolean' is not assignable to type 'number'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(188,13): error TS2322: Type 'true' is not assignable to type 'number'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(192,13): error TS2322: Type 'boolean' is not assignable to type 'number'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(206,28): error TS1109: Expression expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(214,16): error TS2304: Cannot find name 'bool'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(219,10): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. @@ -86,7 +87,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(260,55): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS1128: Declaration or statement expected. -==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (86 errors) ==== +==== tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts (87 errors) ==== declare module "fs" { export class File { @@ -353,21 +354,23 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(262,1): error TS !!! error TS2447: The '^' operator is not allowed for boolean types. Consider using '!==' instead. b = !b;/*!*/ ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number | true'. +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. i = ~i;/*~i*/ b = i < (i - 1) && (i + 1) > i;/*< && >*/ ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number | true'. +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. var f = true ? 1 : 0;/*? :*/ // YES : i++;/*++*/ i--;/*--*/ b = true && false || true;/*&& ||*/ + ~ +!!! error TS2322: Type 'true' is not assignable to type 'number'. i = i << 5;/*<<*/ i = i >> 5;/*>>*/ var j = i; b = i == j && i != j && i <= j && i >= j;/*= == && != <= >=*/ ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number | true'. +!!! error TS2322: Type 'boolean' is not assignable to type 'number'. i += 5.0;/*+=*/ i -= i;/*-=*/ i *= i;/**=*/ diff --git a/tests/baselines/reference/contextualSignatureInstantiation.types b/tests/baselines/reference/contextualSignatureInstantiation.types index 49d6871804c..6fd318e5ec6 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation.types +++ b/tests/baselines/reference/contextualSignatureInstantiation.types @@ -74,16 +74,16 @@ var a = bar(1, 1, g); // Should be number >a : number >bar(1, 1, g) : number >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V ->1 : number ->1 : number +>1 : 1 +>1 : 1 >g : (x: T, y: T) => T var a = baz(1, 1, g); // Should be number >a : number >baz(1, 1, g) : number >baz : (x: T, y: T, cb: (x: T, y: T) => U) => U ->1 : number ->1 : number +>1 : 1 +>1 : 1 >g : (x: T, y: T) => T var b: number | string; @@ -99,16 +99,16 @@ var b = bar(1, "one", g); // Should be number | string >b : string | number >bar(1, "one", g) : string | number >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V ->1 : number ->"one" : string +>1 : 1 +>"one" : "one" >g : (x: T, y: T) => T var b = bar("one", 1, g); // Should be number | string >b : string | number >bar("one", 1, g) : string | number >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V ->"one" : string ->1 : number +>"one" : "one" +>1 : 1 >g : (x: T, y: T) => T var b = baz(b, b, g); // Should be number | string @@ -132,16 +132,16 @@ var d = bar(1, "one", h); // Should be number[] | string[] >d : number[] | string[] >bar(1, "one", h) : number[] | string[] >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V ->1 : number ->"one" : string +>1 : 1 +>"one" : "one" >h : (x: T, y: U) => T[] | U[] var d = bar("one", 1, h); // Should be number[] | string[] >d : number[] | string[] >bar("one", 1, h) : number[] | string[] >bar : (x: T, y: U, cb: (x: T, y: U) => V) => V ->"one" : string ->1 : number +>"one" : "one" +>1 : 1 >h : (x: T, y: U) => T[] | U[] var d = baz(d, d, g); // Should be number[] | string[] diff --git a/tests/baselines/reference/contextualSignatureInstantiation3.types b/tests/baselines/reference/contextualSignatureInstantiation3.types index d01b2b1f8e4..945a4374ad1 100644 --- a/tests/baselines/reference/contextualSignatureInstantiation3.types +++ b/tests/baselines/reference/contextualSignatureInstantiation3.types @@ -43,9 +43,9 @@ function singleton(x: T) { var xs = [1, 2, 3]; >xs : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 // Have compiler check that we get the correct types var v1: number[]; diff --git a/tests/baselines/reference/contextualSignatureInstantiationWithTypeParameterConstrainedToOuterTypeParameter.types b/tests/baselines/reference/contextualSignatureInstantiationWithTypeParameterConstrainedToOuterTypeParameter.types index d0a6d49487b..ac2ece4c039 100644 --- a/tests/baselines/reference/contextualSignatureInstantiationWithTypeParameterConstrainedToOuterTypeParameter.types +++ b/tests/baselines/reference/contextualSignatureInstantiationWithTypeParameterConstrainedToOuterTypeParameter.types @@ -31,7 +31,7 @@ var x = h("", f()); // Call should succeed and x should be string. All t >x : string >h("", f()) : string >h : (v: V, func: (v: V) => W) => W ->"" : string +>"" : "" >f() : (u: U) => U >f : () => (u: U) => U diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types b/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types index 965e4d21d99..97c5f0fdf90 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeIndexSignatures.types @@ -91,7 +91,7 @@ var x: IWithNoStringIndexSignature | IWithStringIndexSignature1 = { foo: "hello" >IWithStringIndexSignature1 : IWithStringIndexSignature1 >{ foo: "hello" } : { foo: string; } >foo : string ->"hello" : string +>"hello" : "hello" var x2: IWithStringIndexSignature1 | IWithStringIndexSignature2 = { z: a => a.toString() }; // a should be number >x2 : IWithStringIndexSignature1 | IWithStringIndexSignature2 @@ -143,7 +143,7 @@ var x3: IWithNoNumberIndexSignature | IWithNumberIndexSignature1 = { 0: "hello" >IWithNoNumberIndexSignature : IWithNoNumberIndexSignature >IWithNumberIndexSignature1 : IWithNumberIndexSignature1 >{ 0: "hello" } : { 0: string; } ->"hello" : string +>"hello" : "hello" var x4: IWithNumberIndexSignature1 | IWithNumberIndexSignature2 = { 1: a => a.toString() }; // a should be number >x4 : IWithNumberIndexSignature1 | IWithNumberIndexSignature2 diff --git a/tests/baselines/reference/contextualTypeWithUnionTypeMembers.types b/tests/baselines/reference/contextualTypeWithUnionTypeMembers.types index 8f2abf37e0e..3d13b94bc59 100644 --- a/tests/baselines/reference/contextualTypeWithUnionTypeMembers.types +++ b/tests/baselines/reference/contextualTypeWithUnionTypeMembers.types @@ -80,7 +80,7 @@ var i1Ori2: I1 | I2 = { // Like i1 commonPropertyType: "hello", >commonPropertyType : string ->"hello" : string +>"hello" : "hello" commonMethodType: a=> a, >commonMethodType : (a: string) => string @@ -102,7 +102,7 @@ var i1Ori2: I1 | I2 = { // Like i1 propertyOnlyInI1: "Hello", >propertyOnlyInI1 : string ->"Hello" : string +>"Hello" : "Hello" }; var i1Ori2: I1 | I2 = { // Like i2 @@ -113,7 +113,7 @@ var i1Ori2: I1 | I2 = { // Like i2 commonPropertyType: "hello", >commonPropertyType : string ->"hello" : string +>"hello" : "hello" commonMethodType: a=> a, >commonMethodType : (a: string) => string @@ -135,7 +135,7 @@ var i1Ori2: I1 | I2 = { // Like i2 propertyOnlyInI2: "Hello", >propertyOnlyInI2 : string ->"Hello" : string +>"Hello" : "Hello" }; var i1Ori2: I1 | I2 = { // Like i1 and i2 both @@ -146,7 +146,7 @@ var i1Ori2: I1 | I2 = { // Like i1 and i2 both commonPropertyType: "hello", >commonPropertyType : string ->"hello" : string +>"hello" : "hello" commonMethodType: a=> a, >commonMethodType : (a: string) => string @@ -168,7 +168,7 @@ var i1Ori2: I1 | I2 = { // Like i1 and i2 both propertyOnlyInI1: "Hello", >propertyOnlyInI1 : string ->"Hello" : string +>"Hello" : "Hello" methodOnlyInI2: a => a, >methodOnlyInI2 : (a: string) => string @@ -178,7 +178,7 @@ var i1Ori2: I1 | I2 = { // Like i1 and i2 both propertyOnlyInI2: "Hello", >propertyOnlyInI2 : string ->"Hello" : string +>"Hello" : "Hello" }; @@ -194,7 +194,7 @@ var arrayI1OrI2: Array | I2> = [i1, i2, { // Like i1 commonPropertyType: "hello", >commonPropertyType : string ->"hello" : string +>"hello" : "hello" commonMethodType: a=> a, >commonMethodType : (a: string) => string @@ -216,7 +216,7 @@ var arrayI1OrI2: Array | I2> = [i1, i2, { // Like i1 propertyOnlyInI1: "Hello", >propertyOnlyInI1 : string ->"Hello" : string +>"Hello" : "Hello" }, { // Like i2 @@ -224,7 +224,7 @@ var arrayI1OrI2: Array | I2> = [i1, i2, { // Like i1 commonPropertyType: "hello", >commonPropertyType : string ->"hello" : string +>"hello" : "hello" commonMethodType: a=> a, >commonMethodType : (a: string) => string @@ -246,14 +246,14 @@ var arrayI1OrI2: Array | I2> = [i1, i2, { // Like i1 propertyOnlyInI2: "Hello", >propertyOnlyInI2 : string ->"Hello" : string +>"Hello" : "Hello" }, { // Like i1 and i2 both >{ // Like i1 and i2 both commonPropertyType: "hello", commonMethodType: a=> a, commonMethodWithTypeParameter: a => a, methodOnlyInI1: a => a, propertyOnlyInI1: "Hello", methodOnlyInI2: a => a, propertyOnlyInI2: "Hello", } : { commonPropertyType: string; commonMethodType: (a: string) => string; commonMethodWithTypeParameter: (a: number) => number; methodOnlyInI1: (a: string) => string; propertyOnlyInI1: string; methodOnlyInI2: (a: string) => string; propertyOnlyInI2: string; } commonPropertyType: "hello", >commonPropertyType : string ->"hello" : string +>"hello" : "hello" commonMethodType: a=> a, >commonMethodType : (a: string) => string @@ -275,7 +275,7 @@ var arrayI1OrI2: Array | I2> = [i1, i2, { // Like i1 propertyOnlyInI1: "Hello", >propertyOnlyInI1 : string ->"Hello" : string +>"Hello" : "Hello" methodOnlyInI2: a => a, >methodOnlyInI2 : (a: string) => string @@ -285,7 +285,7 @@ var arrayI1OrI2: Array | I2> = [i1, i2, { // Like i1 propertyOnlyInI2: "Hello", >propertyOnlyInI2 : string ->"Hello" : string +>"Hello" : "Hello" }]; @@ -358,7 +358,7 @@ var i11Ori21: I11 | I21 = { }, commonPropertyDifferentType: "hello", >commonPropertyDifferentType : string ->"hello" : string +>"hello" : "hello" }; var i11Ori21: I11 | I21 = { @@ -388,7 +388,7 @@ var i11Ori21: I11 | I21 = { }, commonPropertyDifferentType: 10, >commonPropertyDifferentType : number ->10 : number +>10 : 10 }; var arrayOrI11OrI21: Array = [i11, i21, i11 || i21, { @@ -425,7 +425,7 @@ var arrayOrI11OrI21: Array = [i11, i21, i11 || i21, { }, commonPropertyDifferentType: "hello", >commonPropertyDifferentType : string ->"hello" : string +>"hello" : "hello" }, { >{ // Like i2 commonMethodDifferentReturnType: (a, b) => { var z = a.charCodeAt(b); return z; }, commonPropertyDifferentType: 10, } : { commonMethodDifferentReturnType: (a: string, b: number) => number; commonPropertyDifferentType: number; } @@ -451,6 +451,6 @@ var arrayOrI11OrI21: Array = [i11, i21, i11 || i21, { }, commonPropertyDifferentType: 10, >commonPropertyDifferentType : number ->10 : number +>10 : 10 }]; diff --git a/tests/baselines/reference/contextualTyping1.types b/tests/baselines/reference/contextualTyping1.types index 6b2a794f987..1f300311e94 100644 --- a/tests/baselines/reference/contextualTyping1.types +++ b/tests/baselines/reference/contextualTyping1.types @@ -4,5 +4,5 @@ var foo: {id:number;} = {id:4}; >id : number >{id:4} : { id: number; } >id : number ->4 : number +>4 : 4 diff --git a/tests/baselines/reference/contextualTyping10.types b/tests/baselines/reference/contextualTyping10.types index 938f2731a30..6379d6f82aa 100644 --- a/tests/baselines/reference/contextualTyping10.types +++ b/tests/baselines/reference/contextualTyping10.types @@ -6,8 +6,8 @@ class foo { public bar:{id:number;}[] = [{id:1}, {id:2}]; } >[{id:1}, {id:2}] : { id: number; }[] >{id:1} : { id: number; } >id : number ->1 : number +>1 : 1 >{id:2} : { id: number; } >id : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/contextualTyping15.types b/tests/baselines/reference/contextualTyping15.types index ed4fdad3bfc..6d726c70642 100644 --- a/tests/baselines/reference/contextualTyping15.types +++ b/tests/baselines/reference/contextualTyping15.types @@ -4,5 +4,5 @@ class foo { public bar: { (): number; (i: number): number; } = function() { retu >bar : { (): number; (i: number): number; } >i : number >function() { return 1 } : () => number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/contextualTyping16.types b/tests/baselines/reference/contextualTyping16.types index 63f93649208..6eded1712c1 100644 --- a/tests/baselines/reference/contextualTyping16.types +++ b/tests/baselines/reference/contextualTyping16.types @@ -4,10 +4,10 @@ var foo: {id:number;} = {id:4}; foo = {id:5}; >id : number >{id:4} : { id: number; } >id : number ->4 : number +>4 : 4 >foo = {id:5} : { id: number; } >foo : { id: number; } >{id:5} : { id: number; } >id : number ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/contextualTyping18.types b/tests/baselines/reference/contextualTyping18.types index 0bef546022d..3d5ee402828 100644 --- a/tests/baselines/reference/contextualTyping18.types +++ b/tests/baselines/reference/contextualTyping18.types @@ -10,5 +10,5 @@ var foo: {id:number;} = <{id:number;}>({ }); foo = {id: 5}; >foo : { id: number; } >{id: 5} : { id: number; } >id : number ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/contextualTyping19.types b/tests/baselines/reference/contextualTyping19.types index d384a68749a..c5ad59fa61b 100644 --- a/tests/baselines/reference/contextualTyping19.types +++ b/tests/baselines/reference/contextualTyping19.types @@ -5,14 +5,14 @@ var foo:{id:number;}[] = [{id:1}]; foo = [{id:1}, {id:2}]; >[{id:1}] : { id: number; }[] >{id:1} : { id: number; } >id : number ->1 : number +>1 : 1 >foo = [{id:1}, {id:2}] : { id: number; }[] >foo : { id: number; }[] >[{id:1}, {id:2}] : { id: number; }[] >{id:1} : { id: number; } >id : number ->1 : number +>1 : 1 >{id:2} : { id: number; } >id : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/contextualTyping23.types b/tests/baselines/reference/contextualTyping23.types index 0bb8b7a58e7..605d0bd5c9d 100644 --- a/tests/baselines/reference/contextualTyping23.types +++ b/tests/baselines/reference/contextualTyping23.types @@ -3,9 +3,9 @@ var foo:(a:{():number; (i:number):number; })=>number; foo = function(a){return 5 >foo : (a: { (): number; (i: number): number; }) => number >a : { (): number; (i: number): number; } >i : number ->foo = function(a){return 5} : (a: { (): number; (i: number): number; }) => number +>foo = function(a){return 5} : (a: { (): number; (i: number): number; }) => 5 >foo : (a: { (): number; (i: number): number; }) => number ->function(a){return 5} : (a: { (): number; (i: number): number; }) => number +>function(a){return 5} : (a: { (): number; (i: number): number; }) => 5 >a : { (): number; (i: number): number; } ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/contextualTyping24.errors.txt b/tests/baselines/reference/contextualTyping24.errors.txt index ea973050625..bafe2070bba 100644 --- a/tests/baselines/reference/contextualTyping24.errors.txt +++ b/tests/baselines/reference/contextualTyping24.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(this: void, a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. +tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(this: void, a: string) => 5' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. Types of parameters 'a' and 'a' are incompatible. Type '{ (): number; (i: number): number; }' is not assignable to type 'string'. @@ -6,6 +6,6 @@ tests/cases/compiler/contextualTyping24.ts(1,55): error TS2322: Type '(this: voi ==== tests/cases/compiler/contextualTyping24.ts (1 errors) ==== var foo:(a:{():number; (i:number):number; })=>number; foo = function(this: void, a:string){return 5}; ~~~ -!!! error TS2322: Type '(this: void, a: string) => number' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. +!!! error TS2322: Type '(this: void, a: string) => 5' is not assignable to type '(a: { (): number; (i: number): number; }) => number'. !!! error TS2322: Types of parameters 'a' and 'a' are incompatible. !!! error TS2322: Type '{ (): number; (i: number): number; }' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping28.types b/tests/baselines/reference/contextualTyping28.types index e4833fd8838..bf246ce5b72 100644 --- a/tests/baselines/reference/contextualTyping28.types +++ b/tests/baselines/reference/contextualTyping28.types @@ -5,5 +5,5 @@ function foo(param:number[]){}; foo([1]); >foo([1]) : void >foo : (param: number[]) => void >[1] : number[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/contextualTyping29.types b/tests/baselines/reference/contextualTyping29.types index 96695a6d0ba..ba96d77393c 100644 --- a/tests/baselines/reference/contextualTyping29.types +++ b/tests/baselines/reference/contextualTyping29.types @@ -5,6 +5,6 @@ function foo(param:number[]){}; foo([1, 3]); >foo([1, 3]) : void >foo : (param: number[]) => void >[1, 3] : number[] ->1 : number ->3 : number +>1 : 1 +>3 : 3 diff --git a/tests/baselines/reference/contextualTyping3.types b/tests/baselines/reference/contextualTyping3.types index 81c201ee572..c582cc0eb07 100644 --- a/tests/baselines/reference/contextualTyping3.types +++ b/tests/baselines/reference/contextualTyping3.types @@ -5,5 +5,5 @@ class foo { public bar:{id:number;} = {id:5}; } >id : number >{id:5} : { id: number; } >id : number ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/contextualTyping31.types b/tests/baselines/reference/contextualTyping31.types index 22a8f08cf90..3b9da8bd434 100644 --- a/tests/baselines/reference/contextualTyping31.types +++ b/tests/baselines/reference/contextualTyping31.types @@ -5,5 +5,5 @@ function foo(param:number[]){}; foo([1]); >foo([1]) : void >foo : (param: number[]) => void >[1] : number[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/contextualTyping32.types b/tests/baselines/reference/contextualTyping32.types index 59f6040cf7f..e6c6a72f546 100644 --- a/tests/baselines/reference/contextualTyping32.types +++ b/tests/baselines/reference/contextualTyping32.types @@ -7,7 +7,7 @@ function foo(param: {():number; (i:number):number; }[]) { }; foo([function(){ret >foo : (param: { (): number; (i: number): number; }[]) => void >[function(){return 1;}, function(){return 4}] : (() => number)[] >function(){return 1;} : () => number ->1 : number +>1 : 1 >function(){return 4} : () => number ->4 : number +>4 : 4 diff --git a/tests/baselines/reference/contextualTyping34.types b/tests/baselines/reference/contextualTyping34.types index 6bc6b622fc8..48dd3e41a66 100644 --- a/tests/baselines/reference/contextualTyping34.types +++ b/tests/baselines/reference/contextualTyping34.types @@ -6,5 +6,5 @@ var foo = <{ id: number;}> ({id:4}); >({id:4}) : { id: number; } >{id:4} : { id: number; } >id : number ->4 : number +>4 : 4 diff --git a/tests/baselines/reference/contextualTyping35.types b/tests/baselines/reference/contextualTyping35.types index 08bb6b27b8e..4465e0ca1a9 100644 --- a/tests/baselines/reference/contextualTyping35.types +++ b/tests/baselines/reference/contextualTyping35.types @@ -5,7 +5,7 @@ var foo = <{ id: number;}> {id:4, name: "as"}; >id : number >{id:4, name: "as"} : { id: number; name: string; } >id : number ->4 : number +>4 : 4 >name : string ->"as" : string +>"as" : "as" diff --git a/tests/baselines/reference/contextualTyping36.types b/tests/baselines/reference/contextualTyping36.types index 6c93ed30a9f..2cd07e33ee6 100644 --- a/tests/baselines/reference/contextualTyping36.types +++ b/tests/baselines/reference/contextualTyping36.types @@ -6,7 +6,7 @@ var foo = <{ id: number; }[]>[{ id: 4 }, <{ id: number; }>({ })]; >[{ id: 4 }, <{ id: number; }>({ })] : { id: number; }[] >{ id: 4 } : { id: number; } >id : number ->4 : number +>4 : 4 ><{ id: number; }>({ }) : { id: number; } >id : number >({ }) : {} diff --git a/tests/baselines/reference/contextualTyping37.types b/tests/baselines/reference/contextualTyping37.types index 8acd4aedf04..2f61262c9d1 100644 --- a/tests/baselines/reference/contextualTyping37.types +++ b/tests/baselines/reference/contextualTyping37.types @@ -6,6 +6,6 @@ var foo = <{ id: number; }[]>[{ foo: "s" }, { }]; >[{ foo: "s" }, { }] : ({ foo: string; } | {})[] >{ foo: "s" } : { foo: string; } >foo : string ->"s" : string +>"s" : "s" >{ } : {} diff --git a/tests/baselines/reference/contextualTyping39.errors.txt b/tests/baselines/reference/contextualTyping39.errors.txt index 9081480f4ba..622afaeba59 100644 --- a/tests/baselines/reference/contextualTyping39.errors.txt +++ b/tests/baselines/reference/contextualTyping39.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/contextualTyping39.ts(1,11): error TS2352: Type '() => string' cannot be converted to type '() => number'. - Type 'string' is not comparable to type 'number'. +tests/cases/compiler/contextualTyping39.ts(1,11): error TS2352: Type '() => "err"' cannot be converted to type '() => number'. + Type '"err"' is not comparable to type 'number'. ==== tests/cases/compiler/contextualTyping39.ts (1 errors) ==== var foo = <{ (): number; }> function() { return "err"; }; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '() => string' cannot be converted to type '() => number'. -!!! error TS2352: Type 'string' is not comparable to type 'number'. \ No newline at end of file +!!! error TS2352: Type '() => "err"' cannot be converted to type '() => number'. +!!! error TS2352: Type '"err"' is not comparable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTyping40.types b/tests/baselines/reference/contextualTyping40.types index 1889d79f139..44e0c0f0a63 100644 --- a/tests/baselines/reference/contextualTyping40.types +++ b/tests/baselines/reference/contextualTyping40.types @@ -4,5 +4,5 @@ var foo = <{():number; (i:number):number; }> function(){return 1;}; ><{():number; (i:number):number; }> function(){return 1;} : { (): number; (i: number): number; } >i : number >function(){return 1;} : () => number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/contextualTyping6.types b/tests/baselines/reference/contextualTyping6.types index b79811a948a..222212bdbf4 100644 --- a/tests/baselines/reference/contextualTyping6.types +++ b/tests/baselines/reference/contextualTyping6.types @@ -5,8 +5,8 @@ var foo:{id:number;}[] = [{id:1}, {id:2}]; >[{id:1}, {id:2}] : { id: number; }[] >{id:1} : { id: number; } >id : number ->1 : number +>1 : 1 >{id:2} : { id: number; } >id : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/contextualTypingOfConditionalExpression.types b/tests/baselines/reference/contextualTypingOfConditionalExpression.types index a2e29a0e66b..5712e7d581e 100644 --- a/tests/baselines/reference/contextualTypingOfConditionalExpression.types +++ b/tests/baselines/reference/contextualTypingOfConditionalExpression.types @@ -3,7 +3,7 @@ var x: (a: number) => void = true ? (a) => a.toExponential() : (b) => b.toFixed( >x : (a: number) => void >a : number >true ? (a) => a.toExponential() : (b) => b.toFixed() : (a: number) => string ->true : boolean +>true : true >(a) => a.toExponential() : (a: number) => string >a : number >a.toExponential() : string @@ -43,7 +43,7 @@ var x2: (a: A) => void = true ? (a) => a.foo : (b) => b.foo; >a : A >A : A >true ? (a) => a.foo : (b) => b.foo : (a: A) => number ->true : boolean +>true : true >(a) => a.foo : (a: A) => number >a : A >a.foo : number diff --git a/tests/baselines/reference/contextualTypingOfObjectLiterals.types b/tests/baselines/reference/contextualTypingOfObjectLiterals.types index a99fb2f39af..19189e32245 100644 --- a/tests/baselines/reference/contextualTypingOfObjectLiterals.types +++ b/tests/baselines/reference/contextualTypingOfObjectLiterals.types @@ -7,7 +7,7 @@ var obj2 = {x: ""}; >obj2 : { x: string; } >{x: ""} : { x: string; } >x : string ->"" : string +>"" : "" obj1 = {}; // Ok >obj1 = {} : {} diff --git a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt index 251a3a1bde3..95b3c66c264 100644 --- a/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt +++ b/tests/baselines/reference/contextualTypingWithFixedTypeParameters1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'. tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,32): error TS2339: Property 'foo' does not exist on type 'string'. -tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,38): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,38): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (3 errors) ==== @@ -12,4 +12,4 @@ tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,38): error TS ~~~ !!! error TS2339: Property 'foo' does not exist on type 'string'. ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/contextuallyTypeCommaOperator01.types b/tests/baselines/reference/contextuallyTypeCommaOperator01.types index c3b7b700d64..05516949210 100644 --- a/tests/baselines/reference/contextuallyTypeCommaOperator01.types +++ b/tests/baselines/reference/contextuallyTypeCommaOperator01.types @@ -9,7 +9,7 @@ x = (100, a => a); >x : (a: string) => string >(100, a => a) : (a: string) => string >100, a => a : (a: string) => string ->100 : number +>100 : 100 >a => a : (a: string) => string >a : string >a : string diff --git a/tests/baselines/reference/contextuallyTypeLogicalAnd01.types b/tests/baselines/reference/contextuallyTypeLogicalAnd01.types index a405888c8a9..e55e1e4b511 100644 --- a/tests/baselines/reference/contextuallyTypeLogicalAnd01.types +++ b/tests/baselines/reference/contextuallyTypeLogicalAnd01.types @@ -6,13 +6,13 @@ let x: (a: string) => string; let y = true; >y : boolean ->true : boolean +>true : true x = y && (a => a); >x = y && (a => a) : (a: string) => string >x : (a: string) => string >y && (a => a) : (a: string) => string ->y : boolean +>y : true >(a => a) : (a: string) => string >a => a : (a: string) => string >a : string diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializer.types b/tests/baselines/reference/contextuallyTypedBindingInitializer.types index 0d4dfcdd5d9..e9624b156c7 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializer.types +++ b/tests/baselines/reference/contextuallyTypedBindingInitializer.types @@ -30,7 +30,7 @@ function f2({ "show": showRename = v => v.toString() }: Show) {} function f3({ ["show"]: showRename = v => v.toString() }: Show) {} >f3 : ({["show"]: showRename}: Show) => void ->"show" : string +>"show" : "show" >showRename : (x: number) => string >v => v.toString() : (v: number) => string >v : number @@ -70,8 +70,8 @@ function g({ prop = ["hello", 1234] }: Tuples) {} >g : ({prop}: Tuples) => void >prop : [string, number] >["hello", 1234] : [string, number] ->"hello" : string ->1234 : number +>"hello" : "hello" +>1234 : 1234 >Tuples : Tuples interface StringUnion { diff --git a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types index 7e922332055..5adc82c3e62 100644 --- a/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types +++ b/tests/baselines/reference/contextuallyTypedBindingInitializerNegative.types @@ -25,7 +25,7 @@ function f2({ "show": showRename = v => v }: Show) {} function f3({ ["show"]: showRename = v => v }: Show) {} >f3 : ({["show"]: showRename}: Show) => void ->"show" : string +>"show" : "show" >showRename : ((x: number) => string) | ((v: number) => number) >v => v : (v: number) => number >v : number @@ -82,8 +82,8 @@ function g({ prop = [101, 1234] }: Tuples) {} >g : ({prop}: Tuples) => void >prop : [string, number] | [number, number] >[101, 1234] : [number, number] ->101 : number ->1234 : number +>101 : 101 +>1234 : 1234 >Tuples : Tuples interface StringUnion { diff --git a/tests/baselines/reference/contextuallyTypedFunctionExpressionsAndReturnAnnotations.types b/tests/baselines/reference/contextuallyTypedFunctionExpressionsAndReturnAnnotations.types index 94b184f65da..bb66c7fcd76 100644 --- a/tests/baselines/reference/contextuallyTypedFunctionExpressionsAndReturnAnnotations.types +++ b/tests/baselines/reference/contextuallyTypedFunctionExpressionsAndReturnAnnotations.types @@ -19,7 +19,7 @@ foo((y): (y2: number) => void => { >y.charAt : (pos: number) => string >y : string >charAt : (pos: number) => string ->0 : number +>0 : 0 return null; >null : null @@ -29,11 +29,11 @@ foo((y): (y2: number) => void => { foo((y: string) => { >foo((y: string) => { return y2 => { var z = y2.toFixed(); // Should be string return 0; };}) : any >foo : (x: (y: string) => (y2: number) => void) => any ->(y: string) => { return y2 => { var z = y2.toFixed(); // Should be string return 0; };} : (y: string) => (y2: number) => number +>(y: string) => { return y2 => { var z = y2.toFixed(); // Should be string return 0; };} : (y: string) => (y2: number) => 0 >y : string return y2 => { ->y2 => { var z = y2.toFixed(); // Should be string return 0; } : (y2: number) => number +>y2 => { var z = y2.toFixed(); // Should be string return 0; } : (y2: number) => 0 >y2 : number var z = y2.toFixed(); // Should be string @@ -44,7 +44,7 @@ foo((y: string) => { >toFixed : (fractionDigits?: number) => string return 0; ->0 : number +>0 : 0 }; }); diff --git a/tests/baselines/reference/contextuallyTypedIife.types b/tests/baselines/reference/contextuallyTypedIife.types index 2f12e543356..ca0f7f2a508 100644 --- a/tests/baselines/reference/contextuallyTypedIife.types +++ b/tests/baselines/reference/contextuallyTypedIife.types @@ -5,7 +5,7 @@ >(jake => { }) : (jake: string) => void >jake => { } : (jake: string) => void >jake : string ->"build" : string +>"build" : "build" // function expression (function (cats) { })("lol"); @@ -13,7 +13,7 @@ >(function (cats) { }) : (cats: string) => void >function (cats) { } : (cats: string) => void >cats : string ->"lol" : string +>"lol" : "lol" // Lots of Irritating Superfluous Parentheses (function (x) { } ("!")); @@ -21,7 +21,7 @@ >function (x) { } ("!") : void >function (x) { } : (x: string) => void >x : string ->"!" : string +>"!" : "!" ((((function (y) { }))))("-"); >((((function (y) { }))))("-") : void @@ -31,7 +31,7 @@ >(function (y) { }) : (y: string) => void >function (y) { } : (y: string) => void >y : string ->"-" : string +>"-" : "-" // multiple arguments ((a, b, c) => { })("foo", 101, false); @@ -41,8 +41,8 @@ >a : string >b : number >c : boolean ->"foo" : string ->101 : number +>"foo" : "foo" +>101 : 101 >false : false // default parameters @@ -51,21 +51,21 @@ >((m = 10) => m + 1) : (m?: number) => number >(m = 10) => m + 1 : (m?: number) => number >m : number ->10 : number +>10 : 10 >m + 1 : number >m : number ->1 : number ->12 : number +>1 : 1 +>12 : 12 ((n = 10) => n + 1)(); >((n = 10) => n + 1)() : number >((n = 10) => n + 1) : (n?: number) => number >(n = 10) => n + 1 : (n?: number) => number >n : number ->10 : number +>10 : 10 >n + 1 : number >n : number ->1 : number +>1 : 1 // optional parameters ((j?) => j + 1)(12); @@ -75,8 +75,8 @@ >j : number >j + 1 : number >j : number ->1 : number ->12 : number +>1 : 1 +>12 : 12 ((k?) => k + 1)(); >((k?) => k + 1)() : any @@ -85,7 +85,7 @@ >k : any >k + 1 : any >k : any ->1 : number +>1 : 1 ((l, o?) => l + o)(12); // o should be any >((l, o?) => l + o)(12) : any @@ -96,7 +96,7 @@ >l + o : any >l : number >o : any ->12 : number +>12 : 12 // rest parameters ((...numbers) => numbers.every(n => n > 0))(5,6,7); @@ -112,10 +112,10 @@ >n : number >n > 0 : boolean >n : number ->0 : number ->5 : number ->6 : number ->7 : number +>0 : 0 +>5 : 5 +>6 : 6 +>7 : 7 ((...mixed) => mixed.every(n => !!n))(5,'oops','oh no'); >((...mixed) => mixed.every(n => !!n))(5,'oops','oh no') : boolean @@ -131,9 +131,9 @@ >!!n : boolean >!n : boolean >n : string | number ->5 : number ->'oops' : string ->'oh no' : string +>5 : 5 +>'oops' : "oops" +>'oh no' : "oh no" ((...noNumbers) => noNumbers.some(n => n > 0))(); >((...noNumbers) => noNumbers.some(n => n > 0))() : boolean @@ -148,7 +148,7 @@ >n : any >n > 0 : boolean >n : any ->0 : number +>0 : 0 ((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10); >((first, ...rest) => first ? [] : rest.map(n => n > 0))(8,9,10) : boolean[] @@ -167,10 +167,10 @@ >n : number >n > 0 : boolean >n : number ->0 : number ->8 : number ->9 : number ->10 : number +>0 : 0 +>8 : 8 +>9 : 9 +>10 : 10 // destructuring parameters (with defaults too!) (({ q }) => q)({ q : 13 }); @@ -181,42 +181,42 @@ >q : number >{ q : 13 } : { q: number; } >q : number ->13 : number +>13 : 13 (({ p = 14 }) => p)({ p : 15 }); >(({ p = 14 }) => p)({ p : 15 }) : number >(({ p = 14 }) => p) : ({p}: { p: number; }) => number >({ p = 14 }) => p : ({p}: { p: number; }) => number >p : number ->14 : number +>14 : 14 >p : number >{ p : 15 } : { p: number; } >p : number ->15 : number +>15 : 15 (({ r = 17 } = { r: 18 }) => r)({r : 19}); >(({ r = 17 } = { r: 18 }) => r)({r : 19}) : number >(({ r = 17 } = { r: 18 }) => r) : ({r}?: { r: number; }) => number >({ r = 17 } = { r: 18 }) => r : ({r}?: { r: number; }) => number >r : number ->17 : number +>17 : 17 >{ r: 18 } : { r: number; } >r : number ->18 : number +>18 : 18 >r : number >{r : 19} : { r: number; } >r : number ->19 : number +>19 : 19 (({ u = 22 } = { u: 23 }) => u)(); >(({ u = 22 } = { u: 23 }) => u)() : number >(({ u = 22 } = { u: 23 }) => u) : ({u}?: { u?: number; }) => number >({ u = 22 } = { u: 23 }) => u : ({u}?: { u?: number; }) => number >u : number ->22 : number +>22 : 22 >{ u: 23 } : { u?: number; } >u : number ->23 : number +>23 : 23 >u : number // contextually typed parameters. @@ -228,7 +228,7 @@ let twelve = (f => f(12))(i => i); >f : (i: any) => any >f(12) : any >f : (i: any) => any ->12 : number +>12 : 12 >i => i : (i: any) => any >i : any >i : any @@ -243,7 +243,7 @@ let eleven = (o => o.a(11))({ a: function(n) { return n; } }); >o.a : (n: any) => any >o : { a: (n: any) => any; } >a : (n: any) => any ->11 : number +>11 : 11 >{ a: function(n) { return n; } } : { a: (n: any) => any; } >a : (n: any) => any >function(n) { return n; } : (n: any) => any diff --git a/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types index dcb25792fe0..5335cc4f81f 100644 --- a/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types +++ b/tests/baselines/reference/contextuallyTypedObjectLiteralMethodDeclaration01.types @@ -40,11 +40,11 @@ function getFoo1(): Foo { >arg : A arg.numProp = 10; ->arg.numProp = 10 : number +>arg.numProp = 10 : 10 >arg.numProp : number >arg : A >numProp : number ->10 : number +>10 : 10 }, method2(arg) { @@ -52,11 +52,11 @@ function getFoo1(): Foo { >arg : B arg.strProp = "hello"; ->arg.strProp = "hello" : string +>arg.strProp = "hello" : "hello" >arg.strProp : string >arg : B >strProp : string ->"hello" : string +>"hello" : "hello" } } } @@ -74,11 +74,11 @@ function getFoo2(): Foo { >arg : A arg.numProp = 10; ->arg.numProp = 10 : number +>arg.numProp = 10 : 10 >arg.numProp : number >arg : A >numProp : number ->10 : number +>10 : 10 }, method2: (arg) => { @@ -87,11 +87,11 @@ function getFoo2(): Foo { >arg : B arg.strProp = "hello"; ->arg.strProp = "hello" : string +>arg.strProp = "hello" : "hello" >arg.strProp : string >arg : B >strProp : string ->"hello" : string +>"hello" : "hello" } } } @@ -109,11 +109,11 @@ function getFoo3(): Foo { >arg : A arg.numProp = 10; ->arg.numProp = 10 : number +>arg.numProp = 10 : 10 >arg.numProp : number >arg : A >numProp : number ->10 : number +>10 : 10 }, method2: function (arg) { @@ -122,11 +122,11 @@ function getFoo3(): Foo { >arg : B arg.strProp = "hello"; ->arg.strProp = "hello" : string +>arg.strProp = "hello" : "hello" >arg.strProp : string >arg : B >strProp : string ->"hello" : string +>"hello" : "hello" } } } diff --git a/tests/baselines/reference/contextuallyTypingOrOperator.types b/tests/baselines/reference/contextuallyTypingOrOperator.types index 676ad04bfa9..d2f15ba7abe 100644 --- a/tests/baselines/reference/contextuallyTypingOrOperator.types +++ b/tests/baselines/reference/contextuallyTypingOrOperator.types @@ -11,11 +11,11 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; >s.length : number >s : string >length : number ->{ a: s => 1 } : { a: (s: string) => number; } ->a : (s: string) => number ->s => 1 : (s: string) => number +>{ a: s => 1 } : { a: (s: string) => 1; } +>a : (s: string) => 1 +>s => 1 : (s: string) => 1 >s : string ->1 : number +>1 : 1 var v2 = (s: string) => s.length || function (s) { s.length }; >v2 : (s: string) => number | ((s: any) => void) @@ -41,14 +41,14 @@ var v3 = (s: string) => s.length || function (s: number) { return 1 }; >length : number >function (s: number) { return 1 } : (s: number) => number >s : number ->1 : number +>1 : 1 var v4 = (s: number) => 1 || function (s: string) { return s.length }; ->v4 : (s: number) => number | ((s: string) => number) ->(s: number) => 1 || function (s: string) { return s.length } : (s: number) => number | ((s: string) => number) +>v4 : (s: number) => 1 | ((s: string) => number) +>(s: number) => 1 || function (s: string) { return s.length } : (s: number) => 1 | ((s: string) => number) >s : number ->1 || function (s: string) { return s.length } : number | ((s: string) => number) ->1 : number +>1 || function (s: string) { return s.length } : 1 | ((s: string) => number) +>1 : 1 >function (s: string) { return s.length } : (s: string) => number >s : string >s.length : number diff --git a/tests/baselines/reference/contextuallyTypingOrOperator2.types b/tests/baselines/reference/contextuallyTypingOrOperator2.types index 2a73ccc9c9d..b1deb1eb24d 100644 --- a/tests/baselines/reference/contextuallyTypingOrOperator2.types +++ b/tests/baselines/reference/contextuallyTypingOrOperator2.types @@ -11,11 +11,11 @@ var v: { a: (_: string) => number } = { a: s => s.length } || { a: s => 1 }; >s.length : number >s : string >length : number ->{ a: s => 1 } : { a: (s: string) => number; } ->a : (s: string) => number ->s => 1 : (s: string) => number +>{ a: s => 1 } : { a: (s: string) => 1; } +>a : (s: string) => 1 +>s => 1 : (s: string) => 1 >s : string ->1 : number +>1 : 1 var v2 = (s: string) => s.length || function (s) { s.aaa }; >v2 : (s: string) => number | ((s: any) => void) diff --git a/tests/baselines/reference/continueInIterationStatement1.types b/tests/baselines/reference/continueInIterationStatement1.types index 4fcf3794844..a61ec004fba 100644 --- a/tests/baselines/reference/continueInIterationStatement1.types +++ b/tests/baselines/reference/continueInIterationStatement1.types @@ -1,6 +1,6 @@ === tests/cases/compiler/continueInIterationStatement1.ts === while (true) { ->true : boolean +>true : true continue; } diff --git a/tests/baselines/reference/continueInIterationStatement2.types b/tests/baselines/reference/continueInIterationStatement2.types index 4a3d50c7501..59d7b88cc59 100644 --- a/tests/baselines/reference/continueInIterationStatement2.types +++ b/tests/baselines/reference/continueInIterationStatement2.types @@ -3,5 +3,5 @@ do { continue; } while (true); ->true : boolean +>true : true diff --git a/tests/baselines/reference/continueInLoopsWithCapturedBlockScopedBindings1.types b/tests/baselines/reference/continueInLoopsWithCapturedBlockScopedBindings1.types index 885b67d4140..4ccf96ad624 100644 --- a/tests/baselines/reference/continueInLoopsWithCapturedBlockScopedBindings1.types +++ b/tests/baselines/reference/continueInLoopsWithCapturedBlockScopedBindings1.types @@ -5,8 +5,8 @@ function foo() { for (const i of [0, 1]) { >i : number >[0, 1] : number[] ->0 : number ->1 : number +>0 : 0 +>1 : 1 if (i === 0) { >i === 0 : boolean diff --git a/tests/baselines/reference/continueLabel.types b/tests/baselines/reference/continueLabel.types index a25f3311607..788133b337b 100644 --- a/tests/baselines/reference/continueLabel.types +++ b/tests/baselines/reference/continueLabel.types @@ -2,10 +2,10 @@ label1: for(var i = 0; i < 1; i++) { >label1 : any >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/continueTarget2.types b/tests/baselines/reference/continueTarget2.types index 1e9a2325642..5b8fc5a01d2 100644 --- a/tests/baselines/reference/continueTarget2.types +++ b/tests/baselines/reference/continueTarget2.types @@ -3,7 +3,7 @@ target: >target : any while (true) { ->true : boolean +>true : true continue target; >target : any diff --git a/tests/baselines/reference/continueTarget3.types b/tests/baselines/reference/continueTarget3.types index d55f1c3f6d2..502c406b05f 100644 --- a/tests/baselines/reference/continueTarget3.types +++ b/tests/baselines/reference/continueTarget3.types @@ -7,7 +7,7 @@ target2: >target2 : any while (true) { ->true : boolean +>true : true continue target1; >target1 : any diff --git a/tests/baselines/reference/continueTarget4.types b/tests/baselines/reference/continueTarget4.types index e3e3ae82dfe..e07208ccc10 100644 --- a/tests/baselines/reference/continueTarget4.types +++ b/tests/baselines/reference/continueTarget4.types @@ -7,7 +7,7 @@ target2: >target2 : any while (true) { ->true : boolean +>true : true continue target2; >target2 : any diff --git a/tests/baselines/reference/controlFlowAssignmentExpression.types b/tests/baselines/reference/controlFlowAssignmentExpression.types index 94e71b1fd2a..4cc2c52cc1b 100644 --- a/tests/baselines/reference/controlFlowAssignmentExpression.types +++ b/tests/baselines/reference/controlFlowAssignmentExpression.types @@ -6,9 +6,9 @@ let obj: any; >obj : any x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" x = x.length; >x = x.length : number @@ -30,9 +30,9 @@ x = true; >(x = "", obj).foo : any >(x = "", obj) : any >x = "", obj : any ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" >obj : any >foo : any >(x = x.length) : number diff --git a/tests/baselines/reference/controlFlowBinaryAndExpression.types b/tests/baselines/reference/controlFlowBinaryAndExpression.types index 8a1924c42eb..1e7f4e44848 100644 --- a/tests/baselines/reference/controlFlowBinaryAndExpression.types +++ b/tests/baselines/reference/controlFlowBinaryAndExpression.types @@ -6,31 +6,31 @@ let cond: boolean; >cond : boolean (x = "") && (x = 0); ->(x = "") && (x = 0) : number ->(x = "") : string ->x = "" : string +>(x = "") && (x = 0) : "" +>(x = "") : "" +>x = "" : "" >x : string | number | boolean ->"" : string ->(x = 0) : number ->x = 0 : number +>"" : "" +>(x = 0) : 0 +>x = 0 : 0 >x : string | number | boolean ->0 : number +>0 : 0 x; // string | number >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" cond && (x = 0); ->cond && (x = 0) : number +>cond && (x = 0) : 0 >cond : boolean ->(x = 0) : number ->x = 0 : number +>(x = 0) : 0 +>x = 0 : 0 >x : string | number | boolean ->0 : number +>0 : 0 x; // string | number >x : string | number diff --git a/tests/baselines/reference/controlFlowBinaryOrExpression.types b/tests/baselines/reference/controlFlowBinaryOrExpression.types index 7e92fcdbbd1..166718b9266 100644 --- a/tests/baselines/reference/controlFlowBinaryOrExpression.types +++ b/tests/baselines/reference/controlFlowBinaryOrExpression.types @@ -6,31 +6,31 @@ let cond: boolean; >cond : boolean (x = "") || (x = 0); ->(x = "") || (x = 0) : string | number ->(x = "") : string ->x = "" : string +>(x = "") || (x = 0) : 0 +>(x = "") : "" +>x = "" : "" >x : string | number | boolean ->"" : string ->(x = 0) : number ->x = 0 : number +>"" : "" +>(x = 0) : 0 +>x = 0 : 0 >x : string | number | boolean ->0 : number +>0 : 0 x; // string | number >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" cond || (x = 0); ->cond || (x = 0) : number | true +>cond || (x = 0) : true | 0 >cond : boolean ->(x = 0) : number ->x = 0 : number +>(x = 0) : 0 +>x = 0 : 0 >x : string | number | boolean ->0 : number +>0 : 0 x; // string | number >x : string | number diff --git a/tests/baselines/reference/controlFlowCaching.types b/tests/baselines/reference/controlFlowCaching.types index 137fbc3d19c..4b7df020c94 100644 --- a/tests/baselines/reference/controlFlowCaching.types +++ b/tests/baselines/reference/controlFlowCaching.types @@ -49,14 +49,14 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >o.rotation : any >o : any >rotation : any ->360 : number +>360 : 360 start, stop, titlePos, titleRotation = 0, titleOffset, axisVector, tickVector, anchorOffset, labelOffset, labelAlign, >start : any >stop : any >titlePos : any >titleRotation : number ->0 : number +>0 : 0 >titleOffset : any >axisVector : any >tickVector : any @@ -151,7 +151,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >ta : any >tick : any >fontColor : any ->"black" : string +>"black" : "black" taTitleFontColor = o.titleFontColor || (ta.title && ta.title.fontColor) || "black", >taTitleFontColor : any @@ -170,7 +170,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >ta : any >title : any >fontColor : any ->"black" : string +>"black" : "black" taTitleGap = (o.titleGap == 0) ? 0 : o.titleGap || (ta.title && ta.title.gap) || 15, >taTitleGap : any @@ -181,7 +181,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >o : any >titleGap : any >0 : 0 ->0 : number +>0 : 0 >o.titleGap || (ta.title && ta.title.gap) || 15 : any >o.titleGap || (ta.title && ta.title.gap) : any >o.titleGap : any @@ -197,7 +197,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >ta : any >title : any >gap : any ->15 : number +>15 : 15 taTitleOrientation = o.titleOrientation || (ta.title && ta.title.orientation) || "axis", >taTitleOrientation : any @@ -216,7 +216,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >ta : any >title : any >orientation : any ->"axis" : string +>"axis" : "axis" taMajorTick = this.chart.theme.getTick("major", o), >taMajorTick : any @@ -228,7 +228,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >chart : any >theme : any >getTick : any ->"major" : string +>"major" : "major" >o : any taMinorTick = this.chart.theme.getTick("minor", o), @@ -241,7 +241,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >chart : any >theme : any >getTick : any ->"minor" : string +>"minor" : "minor" >o : any taMicroTick = this.chart.theme.getTick("micro", o), @@ -254,14 +254,14 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >chart : any >theme : any >getTick : any ->"micro" : string +>"micro" : "micro" >o : any taStroke = "stroke" in o ? o.stroke : ta.stroke, >taStroke : any >"stroke" in o ? o.stroke : ta.stroke : any >"stroke" in o : boolean ->"stroke" : string +>"stroke" : "stroke" >o : any >o.stroke : any >o : any @@ -285,7 +285,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >splitFontString : any >taFont : any >size : any ->0 : number +>0 : 0 cosr = Math.abs(Math.cos(rotation * Math.PI / 180)), >cosr : number @@ -303,7 +303,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >Math.PI : number >Math : Math >PI : number ->180 : number +>180 : 180 sinr = Math.abs(Math.sin(rotation * Math.PI / 180)), >sinr : number @@ -321,7 +321,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >Math.PI : number >Math : Math >PI : number ->180 : number +>180 : 180 tsize = taTitleFont ? g.normalizedLength(g.splitFontString(taTitleFont).size) : 0; >tsize : any @@ -338,17 +338,17 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >splitFontString : any >taTitleFont : any >size : any ->0 : number +>0 : 0 if (rotation < 0) { >rotation < 0 : boolean >rotation : number ->0 : number +>0 : 0 rotation += 360; >rotation += 360 : number >rotation : number ->360 : number +>360 : 360 } var cachedLabelW = this._getMaxLabelSize(); >cachedLabelW : any @@ -381,7 +381,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >(cachedLabelW || 0) : any >cachedLabelW || 0 : any >cachedLabelW : any ->0 : number +>0 : 0 >sinr : number >labelGap : any >Math.max(taMajorTick.length > 0 ? taMajorTick.length : 0, taMinorTick.length > 0 ? taMinorTick.length : 0) : number @@ -393,11 +393,11 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >taMajorTick.length : any >taMajorTick : any >length : any ->0 : number +>0 : 0 >taMajorTick.length : any >taMajorTick : any >length : any ->0 : number +>0 : 0 taMinorTick.length > 0 ? taMinorTick.length : 0) + >taMinorTick.length > 0 ? taMinorTick.length : 0 : any @@ -405,11 +405,11 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >taMinorTick.length : any >taMinorTick : any >length : any ->0 : number +>0 : 0 >taMinorTick.length : any >taMinorTick : any >length : any ->0 : number +>0 : 0 tsize + taTitleGap; >tsize : any @@ -420,13 +420,13 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >axisVector : any >{ x: isRtl ? -1 : 1, y: 0 } : { x: number; y: number; } >x : number ->isRtl ? -1 : 1 : number +>isRtl ? -1 : 1 : 1 | -1 >isRtl : any ->-1 : number ->1 : number ->1 : number +>-1 : -1 +>1 : 1 +>1 : 1 >y : number ->0 : number +>0 : 0 switch (rotation) { >rotation : number @@ -437,7 +437,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >rotation : number >(90 - centerAnchorLimit) : number >90 - centerAnchorLimit : number ->90 : number +>90 : 90 >centerAnchorLimit : any labelOffset.y = leftBottom ? size : 0; @@ -448,14 +448,14 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >leftBottom ? size : 0 : any >leftBottom : boolean >size : any ->0 : number +>0 : 0 } else if (rotation < (90 + centerAnchorLimit)) { >rotation < (90 + centerAnchorLimit) : boolean >rotation : number >(90 + centerAnchorLimit) : any >90 + centerAnchorLimit : any ->90 : number +>90 : 90 >centerAnchorLimit : any labelOffset.x = -size * 0.4; @@ -466,12 +466,12 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >-size * 0.4 : number >-size : number >size : any ->0.4 : number +>0.4 : 0.4 } else if (rotation < 180) { >rotation < 180 : boolean >rotation : number ->180 : number +>180 : 180 labelOffset.y = leftBottom ? 0 : -size; >labelOffset.y = leftBottom ? 0 : -size : number @@ -480,7 +480,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >y : any >leftBottom ? 0 : -size : number >leftBottom : boolean ->0 : number +>0 : 0 >-size : number >size : any @@ -489,7 +489,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >rotation : number >(270 - centerAnchorLimit) : number >270 - centerAnchorLimit : number ->270 : number +>270 : 270 >centerAnchorLimit : any labelOffset.y = leftBottom ? 0 : -size; @@ -499,7 +499,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >y : any >leftBottom ? 0 : -size : number >leftBottom : boolean ->0 : number +>0 : 0 >-size : number >size : any @@ -508,7 +508,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >rotation : number >(270 + centerAnchorLimit) : any >270 + centerAnchorLimit : any ->270 : number +>270 : 270 >centerAnchorLimit : any labelOffset.y = leftBottom ? size * 0.4 : 0; @@ -520,8 +520,8 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >leftBottom : boolean >size * 0.4 : number >size : any ->0.4 : number ->0 : number +>0.4 : 0.4 +>0 : 0 } else { labelOffset.y = leftBottom ? size : 0; @@ -532,22 +532,22 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >leftBottom ? size : 0 : any >leftBottom : boolean >size : any ->0 : number +>0 : 0 } } titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0; ->titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0 : number +>titleRotation = (taTitleOrientation && taTitleOrientation == "away") ? 180 : 0 : 0 | 180 >titleRotation : number ->(taTitleOrientation && taTitleOrientation == "away") ? 180 : 0 : number +>(taTitleOrientation && taTitleOrientation == "away") ? 180 : 0 : 0 | 180 >(taTitleOrientation && taTitleOrientation == "away") : boolean >taTitleOrientation && taTitleOrientation == "away" : boolean >taTitleOrientation : any >taTitleOrientation == "away" : boolean >taTitleOrientation : any >"away" : "away" ->180 : number ->0 : number +>180 : 180 +>0 : 0 titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize); >titlePos.y = offsets.t - titleOffset + (titleRotation ? 0 : tsize) : any @@ -563,7 +563,7 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >(titleRotation ? 0 : tsize) : any >titleRotation ? 0 : tsize : any >titleRotation : number ->0 : number +>0 : 0 >tsize : any switch (labelAlign) { @@ -573,18 +573,18 @@ function f(dim, offsets, arr, acommon, centerAnchorLimit, g, has, lin) { >"start" : "start" labelAlign = "end"; ->labelAlign = "end" : string +>labelAlign = "end" : "end" >labelAlign : any ->"end" : string +>"end" : "end" break; case "end": >"end" : "end" labelAlign = "start"; ->labelAlign = "start" : string +>labelAlign = "start" : "start" >labelAlign : any ->"start" : string +>"start" : "start" break; case "middle": diff --git a/tests/baselines/reference/controlFlowCommaOperator.types b/tests/baselines/reference/controlFlowCommaOperator.types index 8df5b8e7889..52fd3d7b87d 100644 --- a/tests/baselines/reference/controlFlowCommaOperator.types +++ b/tests/baselines/reference/controlFlowCommaOperator.types @@ -13,9 +13,9 @@ function f(x: string | number | boolean) { if (y = "", typeof x === "string") { >y = "", typeof x === "string" : boolean ->y = "" : string +>y = "" : "" >y : string | number | boolean ->"" : string +>"" : "" >typeof x === "string" : boolean >typeof x : string >x : string | number | boolean @@ -32,9 +32,9 @@ function f(x: string | number | boolean) { } else if (z = 1, typeof x === "number") { >z = 1, typeof x === "number" : boolean ->z = 1 : number +>z = 1 : 1 >z : string | number | boolean ->1 : number +>1 : 1 >typeof x === "number" : boolean >typeof x : string >x : number | boolean diff --git a/tests/baselines/reference/controlFlowConditionalExpression.types b/tests/baselines/reference/controlFlowConditionalExpression.types index c6084e052b1..a648b86e835 100644 --- a/tests/baselines/reference/controlFlowConditionalExpression.types +++ b/tests/baselines/reference/controlFlowConditionalExpression.types @@ -6,14 +6,14 @@ let cond: boolean; >cond : boolean cond ? x = "" : x = 3; ->cond ? x = "" : x = 3 : string | number +>cond ? x = "" : x = 3 : "" | 3 >cond : boolean ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string ->x = 3 : number +>"" : "" +>x = 3 : 3 >x : string | number | boolean ->3 : number +>3 : 3 x; // string | number >x : string | number diff --git a/tests/baselines/reference/controlFlowDeleteOperator.types b/tests/baselines/reference/controlFlowDeleteOperator.types index b0040f12bc2..5715cfc4043 100644 --- a/tests/baselines/reference/controlFlowDeleteOperator.types +++ b/tests/baselines/reference/controlFlowDeleteOperator.types @@ -9,7 +9,7 @@ function f() { >b : string | number >{ b: 1 } : { b: number; } >b : number ->1 : number +>1 : 1 x.a; >x.a : string | number | undefined @@ -22,18 +22,18 @@ function f() { >b : string | number x.a = 1; ->x.a = 1 : number +>x.a = 1 : 1 >x.a : string | number | undefined >x : { a?: string | number | undefined; b: string | number; } >a : string | number | undefined ->1 : number +>1 : 1 x.b = 1; ->x.b = 1 : number +>x.b = 1 : 1 >x.b : string | number >x : { a?: string | number | undefined; b: string | number; } >b : string | number ->1 : number +>1 : 1 x.a; >x.a : number diff --git a/tests/baselines/reference/controlFlowDestructuringDeclaration.types b/tests/baselines/reference/controlFlowDestructuringDeclaration.types index 2e3b1f5647e..d50b743b746 100644 --- a/tests/baselines/reference/controlFlowDestructuringDeclaration.types +++ b/tests/baselines/reference/controlFlowDestructuringDeclaration.types @@ -5,14 +5,14 @@ function f1() { let x: string | number = 1; >x : string | number ->1 : number +>1 : 1 x; >x : number let y: string | undefined = ""; >y : string | undefined ->"" : string +>"" : "" y; >y : string @@ -24,7 +24,7 @@ function f2() { let [x]: [string | number] = [1]; >x : string | number >[1] : [number] ->1 : number +>1 : 1 x; >x : number @@ -32,14 +32,14 @@ function f2() { let [y]: [string | undefined] = [""]; >y : string | undefined >[""] : [string] ->"" : string +>"" : "" y; >y : string let [z = ""]: [string | undefined] = [undefined]; >z : string ->"" : string +>"" : "" >[undefined] : [undefined] >undefined : undefined @@ -53,7 +53,7 @@ function f3() { let [x]: (string | number)[] = [1]; >x : string | number >[1] : number[] ->1 : number +>1 : 1 x; >x : number @@ -61,14 +61,14 @@ function f3() { let [y]: (string | undefined)[] = [""]; >y : string | undefined >[""] : string[] ->"" : string +>"" : "" y; >y : string let [z = ""]: (string | undefined)[] = [undefined]; >z : string ->"" : string +>"" : "" >[undefined] : undefined[] >undefined : undefined @@ -84,7 +84,7 @@ function f4() { >x : string | number >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 x; >x : number @@ -94,14 +94,14 @@ function f4() { >y : string | undefined >{ y: "" } : { y: string; } >y : string ->"" : string +>"" : "" y; >y : string let { z = "" }: { z: string | undefined } = { z: undefined }; >z : string ->"" : string +>"" : "" >z : string | undefined >{ z: undefined } : { z: undefined; } >z : undefined @@ -119,7 +119,7 @@ function f5() { >x : string | number | undefined >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 x; >x : number @@ -129,14 +129,14 @@ function f5() { >y : string | undefined >{ y: "" } : { y: string; } >y : string ->"" : string +>"" : "" y; >y : string let { z = "" }: { z?: string | undefined } = { z: undefined }; >z : string ->"" : string +>"" : "" >z : string | undefined >{ z: undefined } : { z: undefined; } >z : undefined @@ -167,7 +167,7 @@ function f6() { let { z = "" }: { z?: string | undefined } = {}; >z : string ->"" : string +>"" : "" >z : string | undefined >{} : {} @@ -183,7 +183,7 @@ function f7() { >x : string >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 let { x }: { [x: string]: string | number } = o; >x : string | number diff --git a/tests/baselines/reference/controlFlowDestructuringParameters.types b/tests/baselines/reference/controlFlowDestructuringParameters.types index 396852bf37a..d0729e6d7d5 100644 --- a/tests/baselines/reference/controlFlowDestructuringParameters.types +++ b/tests/baselines/reference/controlFlowDestructuringParameters.types @@ -8,7 +8,7 @@ >[{ x: 1 }] : { x: number; }[] >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 >map : (callbackfn: (value: { x: number; }, index: number, array: { x: number; }[]) => U, thisArg?: any) => U[] ({ x }) => x diff --git a/tests/baselines/reference/controlFlowDoWhileStatement.types b/tests/baselines/reference/controlFlowDoWhileStatement.types index d7916f51dfb..24f3e92b144 100644 --- a/tests/baselines/reference/controlFlowDoWhileStatement.types +++ b/tests/baselines/reference/controlFlowDoWhileStatement.types @@ -9,9 +9,9 @@ function a() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" do { x; // string @@ -27,18 +27,18 @@ function b() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" do { x; // string >x : string x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number ->42 : number +>42 : 42 break; } while (cond) @@ -51,9 +51,9 @@ function c() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" do { x; // string @@ -81,18 +81,18 @@ function d() { >x : string | number x = 1000; ->x = 1000 : number +>x = 1000 : 1000 >x : string | number ->1000 : number +>1000 : 1000 do { x; // number >x : number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" } while (x = x.length) >x = x.length : number @@ -111,15 +111,15 @@ function e() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" do { x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number ->42 : number +>42 : 42 } while (cond) >cond : boolean @@ -136,18 +136,18 @@ function f() { >Function : Function x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean | Function | RegExp ->"" : string +>"" : "" do { if (cond) { >cond : boolean x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number | boolean | Function | RegExp ->42 : number +>42 : 42 break; } @@ -181,18 +181,18 @@ function g() { >Function : Function x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean | Function | RegExp ->"" : string +>"" : "" do { if (cond) { >cond : boolean x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number | boolean | Function | RegExp ->42 : number +>42 : 42 break; } @@ -212,7 +212,7 @@ function g() { >/a/ : RegExp } while (true) ->true : boolean +>true : true x; // number >x : number diff --git a/tests/baselines/reference/controlFlowForInStatement.types b/tests/baselines/reference/controlFlowForInStatement.types index 1930071aeb5..e3a4407bff3 100644 --- a/tests/baselines/reference/controlFlowForInStatement.types +++ b/tests/baselines/reference/controlFlowForInStatement.types @@ -28,9 +28,9 @@ for (let y in obj) { >cond : boolean x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number | boolean | Function | RegExp ->42 : number +>42 : 42 continue; } diff --git a/tests/baselines/reference/controlFlowForStatement.types b/tests/baselines/reference/controlFlowForStatement.types index c16ee4f45ec..d227e87ea1d 100644 --- a/tests/baselines/reference/controlFlowForStatement.types +++ b/tests/baselines/reference/controlFlowForStatement.types @@ -9,13 +9,13 @@ function a() { >x : string | number | boolean for (x = ""; cond; x = 5) { ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" >cond : boolean ->x = 5 : number +>x = 5 : 5 >x : string | number | boolean ->5 : number +>5 : 5 x; // string | number >x : string | number @@ -28,9 +28,9 @@ function b() { >x : string | number | boolean for (x = 5; cond; x = x.length) { ->x = 5 : number +>x = 5 : 5 >x : string | number | boolean ->5 : number +>5 : 5 >cond : boolean >x = x.length : number >x : string | number | boolean @@ -42,9 +42,9 @@ function b() { >x : number x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" } } function c() { @@ -54,18 +54,18 @@ function c() { >x : string | number | boolean for (x = 5; x = x.toExponential(); x = 5) { ->x = 5 : number +>x = 5 : 5 >x : string | number | boolean ->5 : number +>5 : 5 >x = x.toExponential() : string >x : string | number | boolean >x.toExponential() : string >x.toExponential : (fractionDigits?: number) => string >x : number >toExponential : (fractionDigits?: number) => string ->x = 5 : number +>x = 5 : 5 >x : string | number | boolean ->5 : number +>5 : 5 x; // string >x : string @@ -78,16 +78,16 @@ function d() { >x : string | number | boolean for (x = ""; typeof x === "string"; x = 5) { ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" >typeof x === "string" : boolean >typeof x : string >x : string | number >"string" : "string" ->x = 5 : number +>x = 5 : 5 >x : string | number | boolean ->5 : number +>5 : 5 x; // string >x : string @@ -101,19 +101,19 @@ function e() { >RegExp : RegExp for (x = "" || 0; typeof x !== "string"; x = "" || true) { ->x = "" || 0 : string | number +>x = "" || 0 : 0 >x : string | number | boolean | RegExp ->"" || 0 : string | number ->"" : string ->0 : number +>"" || 0 : 0 +>"" : "" +>0 : 0 >typeof x !== "string" : boolean >typeof x : string ->x : string | number | true +>x : number | true >"string" : "string" ->x = "" || true : string | true +>x = "" || true : true >x : string | number | boolean | RegExp ->"" || true : string | true ->"" : string +>"" || true : true +>"" : "" >true : true x; // number | boolean diff --git a/tests/baselines/reference/controlFlowIIFE.types b/tests/baselines/reference/controlFlowIIFE.types index dd1fbacc424..6173e79dbbb 100644 --- a/tests/baselines/reference/controlFlowIIFE.types +++ b/tests/baselines/reference/controlFlowIIFE.types @@ -90,9 +90,9 @@ function f3() { >length : number >y : number >z : number ->y = 1 : number +>y = 1 : 1 >y : number ->1 : number +>1 : 1 } } @@ -107,9 +107,9 @@ let maybeNumber: number | undefined; >function () { maybeNumber = 1;} : () => void maybeNumber = 1; ->maybeNumber = 1 : number +>maybeNumber = 1 : 1 >maybeNumber : number | undefined ->1 : number +>1 : 1 })(); maybeNumber++; @@ -118,7 +118,7 @@ maybeNumber++; if (maybeNumber !== undefined) { >maybeNumber !== undefined : boolean ->maybeNumber : number +>maybeNumber : number | undefined >undefined : undefined maybeNumber++; @@ -136,7 +136,7 @@ if (!test) { throw new Error('Test is not defined'); >new Error('Test is not defined') : Error >Error : ErrorConstructor ->'Test is not defined' : string +>'Test is not defined' : "Test is not defined" } (() => { >(() => { test.slice(1); // No error})() : void @@ -148,6 +148,6 @@ if (!test) { >test.slice : (start?: number | undefined, end?: number | undefined) => string >test : string >slice : (start?: number | undefined, end?: number | undefined) => string ->1 : number +>1 : 1 })(); diff --git a/tests/baselines/reference/controlFlowIfStatement.types b/tests/baselines/reference/controlFlowIfStatement.types index fe609d98fb4..0507b82e60a 100644 --- a/tests/baselines/reference/controlFlowIfStatement.types +++ b/tests/baselines/reference/controlFlowIfStatement.types @@ -23,18 +23,18 @@ if (x /* RegExp */, (x = true)) { >x : true x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean | RegExp ->"" : string +>"" : "" } else { x; // boolean >x : true x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number | boolean | RegExp ->42 : number +>42 : 42 } x; // string | number >x : string | number @@ -49,15 +49,15 @@ function a() { >cond : boolean x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number ->42 : number +>42 : 42 } else { x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" return; } @@ -74,18 +74,18 @@ function b() { >cond : boolean x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number ->42 : number +>42 : 42 throw ""; ->"" : string +>"" : "" } else { x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" } x; // string >x : string @@ -130,7 +130,7 @@ function d(data: string | T): never { throw new Error('will always happen'); >new Error('will always happen') : Error >Error : ErrorConstructor ->'will always happen' : string +>'will always happen' : "will always happen" } else { return data; diff --git a/tests/baselines/reference/controlFlowInstanceof.types b/tests/baselines/reference/controlFlowInstanceof.types index e52d1a25b1d..3dc9fff8b04 100644 --- a/tests/baselines/reference/controlFlowInstanceof.types +++ b/tests/baselines/reference/controlFlowInstanceof.types @@ -33,7 +33,7 @@ function f1(s: Set | Set) { >s.add : (value: number) => Set >s : Set >add : (value: number) => Set ->42 : number +>42 : 42 } function f2(s: Set | Set) { @@ -67,7 +67,7 @@ function f2(s: Set | Set) { >s.add : (value: number) => Set >s : Set >add : (value: number) => Set ->42 : number +>42 : 42 } function f3(s: Set | Set) { diff --git a/tests/baselines/reference/controlFlowIteration.types b/tests/baselines/reference/controlFlowIteration.types index 52be501d68e..a8c05b9732f 100644 --- a/tests/baselines/reference/controlFlowIteration.types +++ b/tests/baselines/reference/controlFlowIteration.types @@ -10,15 +10,15 @@ function ff() { >x : string | undefined while (true) { ->true : boolean +>true : true if (cond) { >cond : boolean x = ""; ->x = "" : string +>x = "" : "" >x : string | undefined ->"" : string +>"" : "" } else { if (x) { diff --git a/tests/baselines/reference/controlFlowPropertyDeclarations.types b/tests/baselines/reference/controlFlowPropertyDeclarations.types index 030f22a1ffb..fae5ed27da2 100644 --- a/tests/baselines/reference/controlFlowPropertyDeclarations.types +++ b/tests/baselines/reference/controlFlowPropertyDeclarations.types @@ -8,7 +8,7 @@ var HTMLDOMPropertyConfig = require('react/lib/HTMLDOMPropertyConfig'); >HTMLDOMPropertyConfig : any >require('react/lib/HTMLDOMPropertyConfig') : any >require : any ->'react/lib/HTMLDOMPropertyConfig' : string +>'react/lib/HTMLDOMPropertyConfig' : "react/lib/HTMLDOMPropertyConfig" // Populate property map with ReactJS's attribute and property mappings // TODO handle/use .Properties value eg: MUST_USE_PROPERTY is not HTML attr @@ -70,13 +70,13 @@ function repeatString(string, times) { if (times < 0) { throw new Error(); } >times < 0 : boolean >times : any ->0 : number +>0 : 0 >new Error() : Error >Error : ErrorConstructor var repeated = ''; >repeated : string ->'' : string +>'' : "" while (times) { >times : any @@ -84,7 +84,7 @@ function repeatString(string, times) { if (times & 1) { >times & 1 : number >times : any ->1 : number +>1 : 1 repeated += string; >repeated += string : string @@ -94,7 +94,7 @@ function repeatString(string, times) { if (times >>= 1) { >times >>= 1 : number >times : any ->1 : number +>1 : 1 string += string; >string += string : any @@ -156,7 +156,7 @@ function trimEnd(haystack, needle) { >haystack.slice : any >haystack : any >slice : any ->0 : number +>0 : 0 >-needle.length : number >needle.length : any >needle : any @@ -281,7 +281,7 @@ export class HTMLtoJSX { var text = '' >text : string ->'' : string +>'' : "" if (this._inPreTag) { >this._inPreTag : boolean @@ -303,7 +303,7 @@ export class HTMLtoJSX { .replace(/\r/g, '') >replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/\r/g : RegExp ->'' : string +>'' : "" .replace(/( {2,}|\n|\t|\{|\})/g, function(whitespace) { >replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } @@ -314,13 +314,13 @@ export class HTMLtoJSX { return '{' + JSON.stringify(whitespace) + '}'; >'{' + JSON.stringify(whitespace) + '}' : string >'{' + JSON.stringify(whitespace) : string ->'{' : string +>'{' : "{" >JSON.stringify(whitespace) : string >JSON.stringify : { (value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } >JSON : JSON >stringify : { (value: any, replacer?: (key: string, value: any) => any, space?: string | number): string; (value: any, replacer?: (string | number)[], space?: string | number): string; } >whitespace : string ->'}' : string +>'}' : "}" }); } else { @@ -331,9 +331,9 @@ export class HTMLtoJSX { >text.indexOf : (searchString: string, position?: number) => number >text : string >indexOf : (searchString: string, position?: number) => number ->'\n' : string ->-1 : number ->1 : number +>'\n' : "\n" +>-1 : -1 +>1 : 1 } } this.output += text; diff --git a/tests/baselines/reference/controlFlowPropertyInitializer.types b/tests/baselines/reference/controlFlowPropertyInitializer.types index d35a4c13698..7da8fefe958 100644 --- a/tests/baselines/reference/controlFlowPropertyInitializer.types +++ b/tests/baselines/reference/controlFlowPropertyInitializer.types @@ -3,13 +3,13 @@ // Repro from #8967 const LANG = "Turbo Pascal" ->LANG : string ->"Turbo Pascal" : string +>LANG : "Turbo Pascal" +>"Turbo Pascal" : "Turbo Pascal" class BestLanguage { >BestLanguage : BestLanguage name = LANG; >name : string ->LANG : string +>LANG : "Turbo Pascal" } diff --git a/tests/baselines/reference/controlFlowWhileStatement.types b/tests/baselines/reference/controlFlowWhileStatement.types index 09a127ab51e..19f7fc49d02 100644 --- a/tests/baselines/reference/controlFlowWhileStatement.types +++ b/tests/baselines/reference/controlFlowWhileStatement.types @@ -9,9 +9,9 @@ function a() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" while (cond) { >cond : boolean @@ -27,9 +27,9 @@ function b() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" while (cond) { >cond : boolean @@ -38,9 +38,9 @@ function b() { >x : string x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number ->42 : number +>42 : 42 break; } @@ -52,9 +52,9 @@ function c() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" while (cond) { >cond : boolean @@ -83,9 +83,9 @@ function d() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" while (x = x.length) { >x = x.length : number @@ -98,9 +98,9 @@ function d() { >x : number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" } } function e() { @@ -110,9 +110,9 @@ function e() { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" while (cond) { >cond : boolean @@ -121,9 +121,9 @@ function e() { >x : string | number x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number ->42 : number +>42 : 42 x; // number >x : number @@ -140,9 +140,9 @@ function f() { >Function : Function x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean | Function | RegExp ->"" : string +>"" : "" while (cond) { >cond : boolean @@ -151,9 +151,9 @@ function f() { >cond : true x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number | boolean | Function | RegExp ->42 : number +>42 : 42 break; } @@ -184,20 +184,20 @@ function g() { >Function : Function x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean | Function | RegExp ->"" : string +>"" : "" while (true) { ->true : boolean +>true : true if (cond) { >cond : boolean x = 42; ->x = 42 : number +>x = 42 : 42 >x : string | number | boolean | Function | RegExp ->42 : number +>42 : 42 break; } @@ -226,22 +226,22 @@ function h1() { >x : string | number | boolean x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" while (x > 1) { >x > 1 : boolean >x : string | number ->1 : number +>1 : 1 x; // string | number >x : string | number x = 1; ->x = 1 : number +>x = 1 : 1 >x : string | number | boolean ->1 : number +>1 : 1 x; // number >x : number @@ -260,9 +260,9 @@ function h2() { >x : string | number | boolean x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" while (cond) { >cond : boolean @@ -287,9 +287,9 @@ function h3() { >x : string | number | boolean x = ""; ->x = "" : string +>x = "" : "" >x : string | number | boolean ->"" : string +>"" : "" while (cond) { >cond : boolean diff --git a/tests/baselines/reference/declFileAccessors.types b/tests/baselines/reference/declFileAccessors.types index 00b10f7bf40..a038c66b271 100644 --- a/tests/baselines/reference/declFileAccessors.types +++ b/tests/baselines/reference/declFileAccessors.types @@ -9,7 +9,7 @@ export class c1 { >p3 : number return 10; ->10 : number +>10 : 10 } /** setter property*/ public set p3(/** this is value*/value: number) { @@ -21,7 +21,7 @@ export class c1 { >pp3 : number return 10; ->10 : number +>10 : 10 } /** private setter property*/ private set pp3(/** this is value*/value: number) { @@ -33,7 +33,7 @@ export class c1 { >s3 : number return 10; ->10 : number +>10 : 10 } /** setter property*/ static set s3( /** this is value*/value: number) { @@ -44,7 +44,7 @@ export class c1 { >nc_p3 : number return 10; ->10 : number +>10 : 10 } public set nc_p3(value: number) { >nc_p3 : number @@ -54,7 +54,7 @@ export class c1 { >nc_pp3 : number return 10; ->10 : number +>10 : 10 } private set nc_pp3(value: number) { >nc_pp3 : number @@ -64,7 +64,7 @@ export class c1 { >nc_s3 : string return ""; ->"" : string +>"" : "" } static set nc_s3(value: string) { >nc_s3 : string @@ -76,7 +76,7 @@ export class c1 { >onlyGetter : number return 10; ->10 : number +>10 : 10 } // Only setter property @@ -96,7 +96,7 @@ class c2 { >p3 : number return 10; ->10 : number +>10 : 10 } /** setter property*/ public set p3(/** this is value*/value: number) { @@ -108,7 +108,7 @@ class c2 { >pp3 : number return 10; ->10 : number +>10 : 10 } /** private setter property*/ private set pp3(/** this is value*/value: number) { @@ -120,7 +120,7 @@ class c2 { >s3 : number return 10; ->10 : number +>10 : 10 } /** setter property*/ static set s3( /** this is value*/value: number) { @@ -131,7 +131,7 @@ class c2 { >nc_p3 : number return 10; ->10 : number +>10 : 10 } public set nc_p3(value: number) { >nc_p3 : number @@ -141,7 +141,7 @@ class c2 { >nc_pp3 : number return 10; ->10 : number +>10 : 10 } private set nc_pp3(value: number) { >nc_pp3 : number @@ -151,7 +151,7 @@ class c2 { >nc_s3 : string return ""; ->"" : string +>"" : "" } static set nc_s3(value: string) { >nc_s3 : string @@ -163,7 +163,7 @@ class c2 { >onlyGetter : number return 10; ->10 : number +>10 : 10 } // Only setter property diff --git a/tests/baselines/reference/declFileConstructors.types b/tests/baselines/reference/declFileConstructors.types index 68782eb3617..733a624e776 100644 --- a/tests/baselines/reference/declFileConstructors.types +++ b/tests/baselines/reference/declFileConstructors.types @@ -38,7 +38,7 @@ export class ConstructorWithRestParamters { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } } @@ -85,7 +85,7 @@ export class ConstructorWithParameterInitializer { constructor(public x = "hello") { >x : string ->"hello" : string +>"hello" : "hello" } } @@ -128,7 +128,7 @@ class GlobalConstructorWithRestParamters { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } } @@ -175,6 +175,6 @@ class GlobalConstructorWithParameterInitializer { constructor(public x = "hello") { >x : string ->"hello" : string +>"hello" : "hello" } } diff --git a/tests/baselines/reference/declFileEnumUsedAsValue.types b/tests/baselines/reference/declFileEnumUsedAsValue.types index 19aa3de4331..fe323095922 100644 --- a/tests/baselines/reference/declFileEnumUsedAsValue.types +++ b/tests/baselines/reference/declFileEnumUsedAsValue.types @@ -4,13 +4,13 @@ enum e { >e : e a, ->a : e +>a : e.a b, ->b : e +>b : e.b c ->c : e +>c : e.c } var x = e; >x : typeof e diff --git a/tests/baselines/reference/declFileEnums.types b/tests/baselines/reference/declFileEnums.types index 5fb0d0736be..5b0bfff5bed 100644 --- a/tests/baselines/reference/declFileEnums.types +++ b/tests/baselines/reference/declFileEnums.types @@ -4,13 +4,13 @@ enum e1 { >e1 : e1 a, ->a : e1 +>a : e1.a b, ->b : e1 +>b : e1.b c ->c : e1 +>c : e1.c } enum e2 { @@ -18,17 +18,17 @@ enum e2 { a = 10, >a : e2 ->10 : number +>10 : 10 b = a + 2, >b : e2 >a + 2 : number >a : e2 ->2 : number +>2 : 2 c = 10, >c : e2 ->10 : number +>10 : 10 } enum e3 { @@ -36,7 +36,7 @@ enum e3 { a = 10, >a : e3 ->10 : number +>10 : 10 b = Math.PI, >b : e3 @@ -48,27 +48,27 @@ enum e3 { >c : e3 >a + 3 : number >a : e3 ->3 : number +>3 : 3 } enum e4 { >e4 : e4 a, ->a : e4 +>a : e4.a b, ->b : e4 +>b : e4.b c, ->c : e4 +>c : e4.c d = 10, ->d : e4 ->10 : number +>d : e4.d +>10 : 10 e ->e : e4 +>e : e4.e } enum e5 { diff --git a/tests/baselines/reference/declFileForVarList.types b/tests/baselines/reference/declFileForVarList.types index 5e55104666b..d4c401d2383 100644 --- a/tests/baselines/reference/declFileForVarList.types +++ b/tests/baselines/reference/declFileForVarList.types @@ -4,13 +4,13 @@ var x, y, z = 1; >x : any >y : any >z : number ->1 : number +>1 : 1 var x1 = 1, y2 = 2, z2 = 3; >x1 : number ->1 : number +>1 : 1 >y2 : number ->2 : number +>2 : 2 >z2 : number ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/declFileFunctions.types b/tests/baselines/reference/declFileFunctions.types index 87840f39430..ee35577ce3e 100644 --- a/tests/baselines/reference/declFileFunctions.types +++ b/tests/baselines/reference/declFileFunctions.types @@ -29,7 +29,7 @@ export function fooWithRestParameters(a: string, ...rests: string[]) { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } export function fooWithOverloads(a: string): string; @@ -127,7 +127,7 @@ function nonExportedFooWithRestParameters(a: string, ...rests: string[]) { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } function nonExportedFooWithOverloads(a: string): string; @@ -176,7 +176,7 @@ function globalfooWithRestParameters(a: string, ...rests: string[]) { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } function globalfooWithOverloads(a: string): string; >globalfooWithOverloads : { (a: string): string; (a: number): number; } diff --git a/tests/baselines/reference/declFileMethods.types b/tests/baselines/reference/declFileMethods.types index ecd7b8e0cff..44c08117e93 100644 --- a/tests/baselines/reference/declFileMethods.types +++ b/tests/baselines/reference/declFileMethods.types @@ -32,7 +32,7 @@ export class c1 { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } public fooWithOverloads(a: string): string; @@ -81,7 +81,7 @@ export class c1 { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } private privateFooWithOverloads(a: string): string; >privateFooWithOverloads : { (a: string): string; (a: number): number; } @@ -129,7 +129,7 @@ export class c1 { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } static staticFooWithOverloads(a: string): string; >staticFooWithOverloads : { (a: string): string; (a: number): number; } @@ -177,7 +177,7 @@ export class c1 { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } private static privateStaticFooWithOverloads(a: string): string; >privateStaticFooWithOverloads : { (a: string): string; (a: number): number; } @@ -259,7 +259,7 @@ class c2 { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } public fooWithOverloads(a: string): string; @@ -308,7 +308,7 @@ class c2 { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } private privateFooWithOverloads(a: string): string; >privateFooWithOverloads : { (a: string): string; (a: number): number; } @@ -356,7 +356,7 @@ class c2 { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } static staticFooWithOverloads(a: string): string; >staticFooWithOverloads : { (a: string): string; (a: number): number; } @@ -404,7 +404,7 @@ class c2 { >rests.join : (separator?: string) => string >rests : string[] >join : (separator?: string) => string ->"" : string +>"" : "" } private static privateStaticFooWithOverloads(a: string): string; >privateStaticFooWithOverloads : { (a: string): string; (a: number): number; } diff --git a/tests/baselines/reference/declFileObjectLiteralWithAccessors.types b/tests/baselines/reference/declFileObjectLiteralWithAccessors.types index f7bb57b0e1e..389b88de565 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithAccessors.types +++ b/tests/baselines/reference/declFileObjectLiteralWithAccessors.types @@ -9,7 +9,7 @@ function /*1*/makePoint(x: number) { b: 10, >b : number ->10 : number +>10 : 10 get x() { return x; }, >x : number @@ -30,7 +30,7 @@ var /*4*/point = makePoint(2); >point : { b: number; x: number; } >makePoint(2) : { b: number; x: number; } >makePoint : (x: number) => { b: number; x: number; } ->2 : number +>2 : 2 var /*2*/x = point.x; >x : number @@ -39,9 +39,9 @@ var /*2*/x = point.x; >x : number point./*3*/x = 30; ->point./*3*/x = 30 : number +>point./*3*/x = 30 : 30 >point./*3*/x : number >point : { b: number; x: number; } >x : number ->30 : number +>30 : 30 diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.types b/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.types index dd3cbe20983..c4e563f5a03 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.types +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlyGetter.types @@ -17,7 +17,7 @@ var /*4*/point = makePoint(2); >point : { readonly x: number; } >makePoint(2) : { readonly x: number; } >makePoint : (x: number) => { readonly x: number; } ->2 : number +>2 : 2 var /*2*/x = point./*3*/x; >x : number diff --git a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types index 2b9b98a8963..2f15818e0f2 100644 --- a/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types +++ b/tests/baselines/reference/declFileObjectLiteralWithOnlySetter.types @@ -9,7 +9,7 @@ function /*1*/makePoint(x: number) { b: 10, >b : number ->10 : number +>10 : 10 set x(a: number) { this.b = a; } >x : number @@ -26,12 +26,12 @@ var /*3*/point = makePoint(2); >point : { b: number; x: number; } >makePoint(2) : { b: number; x: number; } >makePoint : (x: number) => { b: number; x: number; } ->2 : number +>2 : 2 point./*2*/x = 30; ->point./*2*/x = 30 : number +>point./*2*/x = 30 : 30 >point./*2*/x : number >point : { b: number; x: number; } >x : number ->30 : number +>30 : 30 diff --git a/tests/baselines/reference/declFilePrivateStatic.types b/tests/baselines/reference/declFilePrivateStatic.types index 35aaa3acdeb..29f8f1a9aab 100644 --- a/tests/baselines/reference/declFilePrivateStatic.types +++ b/tests/baselines/reference/declFilePrivateStatic.types @@ -5,11 +5,11 @@ class C { private static x = 1; >x : number ->1 : number +>1 : 1 static y = 1; >y : number ->1 : number +>1 : 1 private static a() { } >a : () => void @@ -19,11 +19,11 @@ class C { private static get c() { return 1; } >c : number ->1 : number +>1 : 1 static get d() { return 1; } >d : number ->1 : number +>1 : 1 private static set e(v) { } >e : any diff --git a/tests/baselines/reference/declFileRegressionTests.types b/tests/baselines/reference/declFileRegressionTests.types index 7b8933e1def..721f5b1e70a 100644 --- a/tests/baselines/reference/declFileRegressionTests.types +++ b/tests/baselines/reference/declFileRegressionTests.types @@ -7,10 +7,10 @@ var n = { w: null, x: '', y: () => { }, z: 32 }; >w : null >null : null >x : string ->'' : string +>'' : "" >y : () => void >() => { } : () => void >z : number ->32 : number +>32 : 32 diff --git a/tests/baselines/reference/declFileRestParametersOfFunctionAndFunctionType.types b/tests/baselines/reference/declFileRestParametersOfFunctionAndFunctionType.types index 0bfa5b6312c..8e0cdd8d409 100644 --- a/tests/baselines/reference/declFileRestParametersOfFunctionAndFunctionType.types +++ b/tests/baselines/reference/declFileRestParametersOfFunctionAndFunctionType.types @@ -29,7 +29,7 @@ var f6 = () => { return [10]; } >() => { return [10]; } : () => any[] >[10] : any[] >10 : any ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/declFileTypeAnnotationBuiltInType.types b/tests/baselines/reference/declFileTypeAnnotationBuiltInType.types index 2e187f0ec83..87776b3b417 100644 --- a/tests/baselines/reference/declFileTypeAnnotationBuiltInType.types +++ b/tests/baselines/reference/declFileTypeAnnotationBuiltInType.types @@ -5,13 +5,13 @@ function foo(): string { >foo : () => string return ""; ->"" : string +>"" : "" } function foo2() { >foo2 : () => string return ""; ->"" : string +>"" : "" } // number @@ -19,13 +19,13 @@ function foo3(): number { >foo3 : () => number return 10; ->10 : number +>10 : 10 } function foo4() { >foo4 : () => number return 10; ->10 : number +>10 : 10 } // boolean @@ -39,7 +39,7 @@ function foo6() { >foo6 : () => boolean return false; ->false : boolean +>false : false } // void diff --git a/tests/baselines/reference/declFileTypeAnnotationParenType.types b/tests/baselines/reference/declFileTypeAnnotationParenType.types index 31b6ad03751..f3c8db5533a 100644 --- a/tests/baselines/reference/declFileTypeAnnotationParenType.types +++ b/tests/baselines/reference/declFileTypeAnnotationParenType.types @@ -25,19 +25,19 @@ var y = [() => new c()]; var k: (() => c) | string = (() => new c()) || ""; >k : string | (() => c) >c : c ->(() => new c()) || "" : string | (() => c) +>(() => new c()) || "" : "" | (() => c) >(() => new c()) : () => c >() => new c() : () => c >new c() : c >c : typeof c ->"" : string +>"" : "" var l = (() => new c()) || ""; >l : string | (() => c) ->(() => new c()) || "" : string | (() => c) +>(() => new c()) || "" : "" | (() => c) >(() => new c()) : () => c >() => new c() : () => c >new c() : c >c : typeof c ->"" : string +>"" : "" diff --git a/tests/baselines/reference/declFileTypeofEnum.types b/tests/baselines/reference/declFileTypeofEnum.types index 1c900a453b7..1d69d0594c8 100644 --- a/tests/baselines/reference/declFileTypeofEnum.types +++ b/tests/baselines/reference/declFileTypeofEnum.types @@ -4,32 +4,32 @@ enum days { >days : days monday, ->monday : days +>monday : days.monday tuesday, ->tuesday : days +>tuesday : days.tuesday wednesday, ->wednesday : days +>wednesday : days.wednesday thursday, ->thursday : days +>thursday : days.thursday friday, ->friday : days +>friday : days.friday saturday, ->saturday : days +>saturday : days.saturday sunday ->sunday : days +>sunday : days.sunday } var weekendDay = days.saturday; >weekendDay : days ->days.saturday : days +>days.saturday : days.saturday >days : typeof days ->saturday : days +>saturday : days.saturday var daysOfMonth = days; >daysOfMonth : typeof days diff --git a/tests/baselines/reference/declFileTypeofInAnonymousType.types b/tests/baselines/reference/declFileTypeofInAnonymousType.types index fa9d0bcbd17..2ab5e673fb2 100644 --- a/tests/baselines/reference/declFileTypeofInAnonymousType.types +++ b/tests/baselines/reference/declFileTypeofInAnonymousType.types @@ -10,13 +10,13 @@ module m1 { >e : e weekday, ->weekday : e +>weekday : e.weekday weekend, ->weekend : e +>weekend : e.weekend holiday ->holiday : e +>holiday : e.holiday } } var a: { c: m1.c; }; @@ -74,10 +74,10 @@ var d = { mh: m1.e.holiday >mh : m1.e ->m1.e.holiday : m1.e +>m1.e.holiday : m1.e.holiday >m1.e : typeof m1.e >m1 : typeof m1 >e : typeof m1.e ->holiday : m1.e +>holiday : m1.e.holiday }; diff --git a/tests/baselines/reference/declInput.types b/tests/baselines/reference/declInput.types index e59e3811fdf..edca1b9a943 100644 --- a/tests/baselines/reference/declInput.types +++ b/tests/baselines/reference/declInput.types @@ -9,7 +9,7 @@ class bar { public f() { return ''; } >f : () => string ->'' : string +>'' : "" public g() { return {a: null, b: undefined, c: void 4 }; } >g : () => { a: bar; b: any; c: any; } @@ -22,16 +22,16 @@ class bar { >undefined : undefined >c : undefined >void 4 : undefined ->4 : number +>4 : 4 public h(x = 4, y = null, z = '') { x++; } >h : (x?: number, y?: any, z?: string) => void >x : number ->4 : number +>4 : 4 >y : any >null : null >z : string ->'' : string +>'' : "" >x++ : number >x : number } diff --git a/tests/baselines/reference/declInput3.types b/tests/baselines/reference/declInput3.types index 0dcbc6bd3cd..aaa947cdca9 100644 --- a/tests/baselines/reference/declInput3.types +++ b/tests/baselines/reference/declInput3.types @@ -9,7 +9,7 @@ class bar { public f() { return ''; } >f : () => string ->'' : string +>'' : "" public g() { return {a: null, b: undefined, c: void 4 }; } >g : () => { a: bar; b: any; c: any; } @@ -22,16 +22,16 @@ class bar { >undefined : undefined >c : undefined >void 4 : undefined ->4 : number +>4 : 4 public h(x = 4, y = null, z = '') { x++; } >h : (x?: number, y?: any, z?: string) => void >x : number ->4 : number +>4 : 4 >y : any >null : null >z : string ->'' : string +>'' : "" >x++ : number >x : number } diff --git a/tests/baselines/reference/declarationEmitDefaultExport3.types b/tests/baselines/reference/declarationEmitDefaultExport3.types index 91ee71f61ac..2717e248784 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport3.types +++ b/tests/baselines/reference/declarationEmitDefaultExport3.types @@ -3,5 +3,5 @@ export default function foo() { >foo : () => string return "" ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/declarationEmitDefaultExport4.types b/tests/baselines/reference/declarationEmitDefaultExport4.types index ab97484176d..db47735b1ed 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport4.types +++ b/tests/baselines/reference/declarationEmitDefaultExport4.types @@ -1,5 +1,5 @@ === tests/cases/compiler/declarationEmitDefaultExport4.ts === export default function () { return 1; ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/declarationEmitDefaultExport5.types b/tests/baselines/reference/declarationEmitDefaultExport5.types index d2b177cc084..71f0cbde697 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport5.types +++ b/tests/baselines/reference/declarationEmitDefaultExport5.types @@ -1,6 +1,6 @@ === tests/cases/compiler/declarationEmitDefaultExport5.ts === export default 1 + 2; >1 + 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/declarationEmitDefaultExport8.types b/tests/baselines/reference/declarationEmitDefaultExport8.types index bd99ee14530..ed66a0fcb6f 100644 --- a/tests/baselines/reference/declarationEmitDefaultExport8.types +++ b/tests/baselines/reference/declarationEmitDefaultExport8.types @@ -2,7 +2,7 @@ var _default = 1; >_default : number ->1 : number +>1 : 1 export {_default as d} >_default : number @@ -10,6 +10,6 @@ export {_default as d} export default 1 + 2; >1 + 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/declarationEmitDefaultExportWithTempVarName.js b/tests/baselines/reference/declarationEmitDefaultExportWithTempVarName.js index a0c8ab59b97..e02a0ae2606 100644 --- a/tests/baselines/reference/declarationEmitDefaultExportWithTempVarName.js +++ b/tests/baselines/reference/declarationEmitDefaultExportWithTempVarName.js @@ -15,5 +15,5 @@ System.register([], function(exports_1, context_1) { //// [pi.d.ts] -declare var _default: number; +declare var _default: 3.14159; export default _default; diff --git a/tests/baselines/reference/declarationEmitDefaultExportWithTempVarNameWithBundling.js b/tests/baselines/reference/declarationEmitDefaultExportWithTempVarNameWithBundling.js index adb081dc2a3..6ba5e2601d3 100644 --- a/tests/baselines/reference/declarationEmitDefaultExportWithTempVarNameWithBundling.js +++ b/tests/baselines/reference/declarationEmitDefaultExportWithTempVarNameWithBundling.js @@ -17,6 +17,6 @@ System.register("pi", [], function(exports_1, context_1) { //// [app.d.ts] declare module "pi" { - var _default: number; + var _default: 3.14159; export default _default; } diff --git a/tests/baselines/reference/declarationEmitDestructuring3.types b/tests/baselines/reference/declarationEmitDestructuring3.types index da9fc6d6606..8e15071c979 100644 --- a/tests/baselines/reference/declarationEmitDestructuring3.types +++ b/tests/baselines/reference/declarationEmitDestructuring3.types @@ -10,8 +10,8 @@ function foo([x, ...y] = [1, "string", true]) { } >x : string | number | boolean >y : (string | number | boolean)[] >[1, "string", true] : (string | number | boolean)[] ->1 : number ->"string" : string ->true : boolean +>1 : 1 +>"string" : "string" +>true : true diff --git a/tests/baselines/reference/declarationEmitDestructuring5.types b/tests/baselines/reference/declarationEmitDestructuring5.types index 961dea62bcb..c0223a0f061 100644 --- a/tests/baselines/reference/declarationEmitDestructuring5.types +++ b/tests/baselines/reference/declarationEmitDestructuring5.types @@ -22,11 +22,11 @@ function bar1([z, , , ] = [1, 3, 4, 6, 7]) { } > : undefined > : undefined >[1, 3, 4, 6, 7] : [number, number, number, number, number] ->1 : number ->3 : number ->4 : number ->6 : number ->7 : number +>1 : 1 +>3 : 3 +>4 : 4 +>6 : 6 +>7 : 7 function bar2([,,z, , , ]) { } >bar2 : ([, , z, , ,]: [any, any, any, any, any]) => void diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types index 0feeaf2db1a..640062c0785 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern1.types @@ -2,36 +2,36 @@ var [] = [1, "hello"]; // Dont emit anything >[1, "hello"] : (string | number)[] ->1 : number ->"hello" : string +>1 : 1 +>"hello" : "hello" var [x] = [1, "hello"]; // emit x: number >x : number >[1, "hello"] : [number, string] ->1 : number ->"hello" : string +>1 : 1 +>"hello" : "hello" var [x1, y1] = [1, "hello"]; // emit x1: number, y1: string >x1 : number >y1 : string >[1, "hello"] : [number, string] ->1 : number ->"hello" : string +>1 : 1 +>"hello" : "hello" var [, , z1] = [0, 1, 2]; // emit z1: number > : undefined > : undefined >z1 : number >[0, 1, 2] : [number, number, number] ->0 : number ->1 : number ->2 : number +>0 : 0 +>1 : 1 +>2 : 2 var a = [1, "hello"]; >a : (string | number)[] >[1, "hello"] : (string | number)[] ->1 : number ->"hello" : string +>1 : 1 +>"hello" : "hello" var [x2] = a; // emit x2: number | string >x2 : string | number diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.types index 406494aa13b..3bd324a1c26 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern3.types @@ -6,6 +6,6 @@ module M { >a : number >b : number >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 } diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types index 2cc56abcb05..0141b3f79e7 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern4.types @@ -2,26 +2,26 @@ var [...a5] = [1, 2, 3]; >a5 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var [x14, ...a6] = [1, 2, 3]; >x14 : number >a6 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var [x15, y15, ...a7] = [1, 2, 3]; >x15 : number >y15 : number >a7 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var [x16, y16, z16, ...a8] = [1, 2, 3]; >x16 : number @@ -29,33 +29,33 @@ var [x16, y16, z16, ...a8] = [1, 2, 3]; >z16 : number >a8 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var [...a9] = [1, "hello", true]; >a9 : (string | number | boolean)[] >[1, "hello", true] : (string | number | boolean)[] ->1 : number ->"hello" : string ->true : boolean +>1 : 1 +>"hello" : "hello" +>true : true var [x17, ...a10] = [1, "hello", true]; >x17 : string | number | boolean >a10 : (string | number | boolean)[] >[1, "hello", true] : (string | number | boolean)[] ->1 : number ->"hello" : string ->true : boolean +>1 : 1 +>"hello" : "hello" +>true : true var [x18, y18, ...a12] = [1, "hello", true]; >x18 : string | number | boolean >y18 : string | number | boolean >a12 : (string | number | boolean)[] >[1, "hello", true] : (string | number | boolean)[] ->1 : number ->"hello" : string ->true : boolean +>1 : 1 +>"hello" : "hello" +>true : true var [x19, y19, z19, ...a13] = [1, "hello", true]; >x19 : string | number | boolean @@ -63,7 +63,7 @@ var [x19, y19, z19, ...a13] = [1, "hello", true]; >z19 : string | number | boolean >a13 : (string | number | boolean)[] >[1, "hello", true] : (string | number | boolean)[] ->1 : number ->"hello" : string ->true : boolean +>1 : 1 +>"hello" : "hello" +>true : true diff --git a/tests/baselines/reference/declarationEmitDestructuringArrayPattern5.types b/tests/baselines/reference/declarationEmitDestructuringArrayPattern5.types index fa5720f4da7..41f4660bf29 100644 --- a/tests/baselines/reference/declarationEmitDestructuringArrayPattern5.types +++ b/tests/baselines/reference/declarationEmitDestructuringArrayPattern5.types @@ -4,18 +4,18 @@ var [, , z] = [1, 2, 4]; > : undefined >z : number >[1, 2, 4] : [number, number, number] ->1 : number ->2 : number ->4 : number +>1 : 1 +>2 : 2 +>4 : 4 var [, a, , ] = [3, 4, 5]; > : undefined >a : number > : undefined >[3, 4, 5] : [number, number, number] ->3 : number ->4 : number ->5 : number +>3 : 3 +>4 : 4 +>5 : 5 var [, , [, b, ]] = [3,5,[0, 1]]; > : undefined @@ -23,9 +23,9 @@ var [, , [, b, ]] = [3,5,[0, 1]]; > : undefined >b : number >[3,5,[0, 1]] : [number, number, [number, number]] ->3 : number ->5 : number +>3 : 3 +>5 : 5 >[0, 1] : [number, number] ->0 : number ->1 : number +>0 : 0 +>1 : 1 diff --git a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types index 49d4e2e837c..f8f9a6a319c 100644 --- a/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types +++ b/tests/baselines/reference/declarationEmitDestructuringObjectLiteralPattern2.types @@ -11,36 +11,36 @@ var { a: x11, b: { a: y11, b: { a: z11 }}} = { a: 1, b: { a: "hello", b: { a: tr >z11 : boolean >{ a: 1, b: { a: "hello", b: { a: true } } } : { a: number; b: { a: string; b: { a: boolean; }; }; } >a : number ->1 : number +>1 : 1 >b : { a: string; b: { a: boolean; }; } >{ a: "hello", b: { a: true } } : { a: string; b: { a: boolean; }; } >a : string ->"hello" : string +>"hello" : "hello" >b : { a: boolean; } >{ a: true } : { a: boolean; } >a : boolean ->true : boolean +>true : true function f15() { >f15 : () => { a4: string; b4: number; c4: boolean; } var a4 = "hello"; >a4 : string ->"hello" : string +>"hello" : "hello" var b4 = 1; >b4 : number ->1 : number +>1 : 1 var c4 = true; >c4 : boolean ->true : boolean +>true : true return { a4, b4, c4 }; >{ a4, b4, c4 } : { a4: string; b4: number; c4: boolean; } >a4 : string >b4 : number ->c4 : boolean +>c4 : true } var { a4, b4, c4 } = f15(); >a4 : string diff --git a/tests/baselines/reference/declarationEmit_bindingPatterns.types b/tests/baselines/reference/declarationEmit_bindingPatterns.types index eff2d4bd4a3..b3da24a2b95 100644 --- a/tests/baselines/reference/declarationEmit_bindingPatterns.types +++ b/tests/baselines/reference/declarationEmit_bindingPatterns.types @@ -5,7 +5,7 @@ const k = ({x: z = 'y'}) => { } >({x: z = 'y'}) => { } : ({x: z}: { x?: string; }) => void >x : any >z : string ->'y' : string +>'y' : "y" var a; >a : any diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict.types b/tests/baselines/reference/declarationEmit_classMemberNameConflict.types index c76072413e5..66bc493b2ee 100644 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict.types +++ b/tests/baselines/reference/declarationEmit_classMemberNameConflict.types @@ -41,7 +41,7 @@ export class C3 { get C3() { return 0; } // has to be the same as the class name >C3 : number ->0 : number +>0 : 0 bar() { >bar : () => (t: typeof C3) => void diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.js b/tests/baselines/reference/declarationEmit_classMemberNameConflict2.js index 03dc5cdbafd..d3ebddc8d17 100644 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.js +++ b/tests/baselines/reference/declarationEmit_classMemberNameConflict2.js @@ -45,7 +45,7 @@ var Foo = (function () { //// [declarationEmit_classMemberNameConflict2.d.ts] -declare const Bar: string; +declare const Bar: "bar"; declare enum Hello { World = 0, } diff --git a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.types b/tests/baselines/reference/declarationEmit_classMemberNameConflict2.types index 9f8ddd8a2d5..dd184f7ba34 100644 --- a/tests/baselines/reference/declarationEmit_classMemberNameConflict2.types +++ b/tests/baselines/reference/declarationEmit_classMemberNameConflict2.types @@ -1,8 +1,8 @@ === tests/cases/compiler/declarationEmit_classMemberNameConflict2.ts === const Bar = 'bar'; ->Bar : string ->'bar' : string +>Bar : "bar" +>'bar' : "bar" enum Hello { >Hello : Hello @@ -24,7 +24,7 @@ class Foo { // Same names + string => OK Bar = Bar; >Bar : string ->Bar : string +>Bar : "bar" // Same names + enum => OK Hello = Hello; diff --git a/tests/baselines/reference/declarationEmit_expressionInExtends2.types b/tests/baselines/reference/declarationEmit_expressionInExtends2.types index 77a1539267d..3f2b8964a2d 100644 --- a/tests/baselines/reference/declarationEmit_expressionInExtends2.types +++ b/tests/baselines/reference/declarationEmit_expressionInExtends2.types @@ -28,5 +28,5 @@ class MyClass extends getClass(2) { >MyClass : MyClass >getClass(2) : C >getClass : (c: T) => typeof C ->2 : number +>2 : 2 } diff --git a/tests/baselines/reference/declarationEmit_invalidReference.types b/tests/baselines/reference/declarationEmit_invalidReference.types index 35d623c3c05..942f2088fc0 100644 --- a/tests/baselines/reference/declarationEmit_invalidReference.types +++ b/tests/baselines/reference/declarationEmit_invalidReference.types @@ -2,5 +2,5 @@ /// var x = 0; >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/declarationEmit_protectedMembers.types b/tests/baselines/reference/declarationEmit_protectedMembers.types index d541e1d14d2..dd2f0012bf9 100644 --- a/tests/baselines/reference/declarationEmit_protectedMembers.types +++ b/tests/baselines/reference/declarationEmit_protectedMembers.types @@ -22,7 +22,7 @@ class C1 { protected get accessor() { return 0; } >accessor : number ->0 : number +>0 : 0 protected static sx: number; >sx : number @@ -42,7 +42,7 @@ class C1 { protected static get staticGetter() { return 0; } >staticGetter : number ->0 : number +>0 : 0 } // Derived class overriding protected members @@ -110,7 +110,7 @@ class C3 extends C2 { static get staticGetter() { return 1; } >staticGetter : number ->1 : number +>1 : 1 } // Protected properties in constructors diff --git a/tests/baselines/reference/declarationsAndAssignments.errors.txt b/tests/baselines/reference/declarationsAndAssignments.errors.txt index 4aa81dce7ae..64bd8d7e578 100644 --- a/tests/baselines/reference/declarationsAndAssignments.errors.txt +++ b/tests/baselines/reference/declarationsAndAssignments.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(23,25): tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(24,19): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(28,28): error TS2353: Object literal may only specify known properties, and 'y' does not exist in type '{ x: any; }'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(29,22): error TS2353: Object literal may only specify known properties, and 'x' does not exist in type '{ y: any; }'. -tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(58,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'string | number', but here has type 'string'. +tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(58,9): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'string | 1', but here has type 'string'. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,10): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,13): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(62,16): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. @@ -99,7 +99,7 @@ tests/cases/conformance/es6/destructuring/declarationsAndAssignments.ts(138,9): var x: number; var y: string; ~ -!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'string | number', but here has type 'string'. +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'string | 1', but here has type 'string'. } function f8() { diff --git a/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.types b/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.types index c33ed5219a8..db7096752c5 100644 --- a/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.types +++ b/tests/baselines/reference/declareFileExportAssignmentWithVarFromVariableStatement.types @@ -28,7 +28,7 @@ module m2 { var x = 10, m2: { >x : number ->10 : number +>10 : 10 >m2 : { (): m2.connectExport; test1: m2.connectModule; test2(): m2.connectModule; } (): m2.connectExport; diff --git a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types index 17b37c79378..d768f3c6c7a 100644 --- a/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types +++ b/tests/baselines/reference/decoratorInstantiateModulesInFunctionBodies.types @@ -3,7 +3,7 @@ // from #3108 export var test = 'abc'; >test : string ->'abc' : string +>'abc' : "abc" === tests/cases/conformance/decorators/class/b.ts === import { test } from './a'; diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.types b/tests/baselines/reference/decoratorMetadataOnInferredType.types index 41c9334244f..41ac7f060d2 100644 --- a/tests/baselines/reference/decoratorMetadataOnInferredType.types +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.types @@ -17,7 +17,7 @@ class A { >console.log : (msg: string) => void >console : { log(msg: string): void; } >log : (msg: string) => void ->'new A' : string +>'new A' : "new A" } function decorator(target: Object, propertyKey: string) { diff --git a/tests/baselines/reference/decoratorMetadataPromise.types b/tests/baselines/reference/decoratorMetadataPromise.types index dc07cdc1fe6..eff5fe92c12 100644 --- a/tests/baselines/reference/decoratorMetadataPromise.types +++ b/tests/baselines/reference/decoratorMetadataPromise.types @@ -19,7 +19,7 @@ class A { async bar(): Promise { return 0; } >bar : () => Promise >Promise : Promise ->0 : number +>0 : 0 @decorator >decorator : MethodDecorator diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.types b/tests/baselines/reference/decoratorMetadataWithConstructorType.types index ad83706f4f9..4ca404c8116 100644 --- a/tests/baselines/reference/decoratorMetadataWithConstructorType.types +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.types @@ -17,7 +17,7 @@ class A { >console.log : (msg: string) => void >console : { log(msg: string): void; } >log : (msg: string) => void ->'new A' : string +>'new A' : "new A" } function decorator(target: Object, propertyKey: string) { diff --git a/tests/baselines/reference/decoratorOnClass5.es6.types b/tests/baselines/reference/decoratorOnClass5.es6.types index 5532c50fe52..891126c9ba6 100644 --- a/tests/baselines/reference/decoratorOnClass5.es6.types +++ b/tests/baselines/reference/decoratorOnClass5.es6.types @@ -20,7 +20,7 @@ class C { static y = 1; >y : number ->1 : number +>1 : 1 } let c = new C(); diff --git a/tests/baselines/reference/decoratorOnClass6.es6.types b/tests/baselines/reference/decoratorOnClass6.es6.types index 0b335558400..89c4ebfc101 100644 --- a/tests/baselines/reference/decoratorOnClass6.es6.types +++ b/tests/baselines/reference/decoratorOnClass6.es6.types @@ -20,7 +20,7 @@ export class C { static y = 1; >y : number ->1 : number +>1 : 1 } let c = new C(); diff --git a/tests/baselines/reference/decoratorOnClass7.es6.types b/tests/baselines/reference/decoratorOnClass7.es6.types index af7ae0516e3..d2d54175bf9 100644 --- a/tests/baselines/reference/decoratorOnClass7.es6.types +++ b/tests/baselines/reference/decoratorOnClass7.es6.types @@ -20,7 +20,7 @@ export default class C { static y = 1; >y : number ->1 : number +>1 : 1 } let c = new C(); diff --git a/tests/baselines/reference/decoratorOnClass8.es6.types b/tests/baselines/reference/decoratorOnClass8.es6.types index 045b036e335..4116a8b20d6 100644 --- a/tests/baselines/reference/decoratorOnClass8.es6.types +++ b/tests/baselines/reference/decoratorOnClass8.es6.types @@ -12,5 +12,5 @@ declare function dec(target: T): T; export default class { static y = 1; >y : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/decoratorOnClassAccessor1.types b/tests/baselines/reference/decoratorOnClassAccessor1.types index e5ba5149d7a..8d46fad586f 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor1.types +++ b/tests/baselines/reference/decoratorOnClassAccessor1.types @@ -16,5 +16,5 @@ class C { @dec get accessor() { return 1; } >dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor >accessor : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/decoratorOnClassAccessor2.types b/tests/baselines/reference/decoratorOnClassAccessor2.types index 32902ce7ca0..b71e5943e0f 100644 --- a/tests/baselines/reference/decoratorOnClassAccessor2.types +++ b/tests/baselines/reference/decoratorOnClassAccessor2.types @@ -16,5 +16,5 @@ class C { @dec public get accessor() { return 1; } >dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor >accessor : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/decoratorOnClassMethod13.types b/tests/baselines/reference/decoratorOnClassMethod13.types index 5fdbe071828..eba738d5ef5 100644 --- a/tests/baselines/reference/decoratorOnClassMethod13.types +++ b/tests/baselines/reference/decoratorOnClassMethod13.types @@ -15,9 +15,9 @@ class C { @dec ["1"]() { } >dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor ->"1" : string +>"1" : "1" @dec ["b"]() { } >dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor ->"b" : string +>"b" : "b" } diff --git a/tests/baselines/reference/decoratorOnClassMethod4.types b/tests/baselines/reference/decoratorOnClassMethod4.types index 026508257a5..5c47dc8a4ca 100644 --- a/tests/baselines/reference/decoratorOnClassMethod4.types +++ b/tests/baselines/reference/decoratorOnClassMethod4.types @@ -15,5 +15,5 @@ class C { @dec ["method"]() {} >dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor ->"method" : string +>"method" : "method" } diff --git a/tests/baselines/reference/decoratorOnClassMethod5.types b/tests/baselines/reference/decoratorOnClassMethod5.types index d55ddd832b9..749eb6b3b9c 100644 --- a/tests/baselines/reference/decoratorOnClassMethod5.types +++ b/tests/baselines/reference/decoratorOnClassMethod5.types @@ -16,5 +16,5 @@ class C { @dec() ["method"]() {} >dec() : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor >dec : () => (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor ->"method" : string +>"method" : "method" } diff --git a/tests/baselines/reference/decoratorOnClassMethod7.types b/tests/baselines/reference/decoratorOnClassMethod7.types index 8a72e24bd5b..c8d21157fe9 100644 --- a/tests/baselines/reference/decoratorOnClassMethod7.types +++ b/tests/baselines/reference/decoratorOnClassMethod7.types @@ -15,5 +15,5 @@ class C { @dec public ["method"]() {} >dec : (target: any, propertyKey: string, descriptor: TypedPropertyDescriptor) => TypedPropertyDescriptor ->"method" : string +>"method" : "method" } diff --git a/tests/baselines/reference/decrementOperatorWithAnyOtherType.types b/tests/baselines/reference/decrementOperatorWithAnyOtherType.types index 65eea6d1a71..c8b8852e4d2 100644 --- a/tests/baselines/reference/decrementOperatorWithAnyOtherType.types +++ b/tests/baselines/reference/decrementOperatorWithAnyOtherType.types @@ -10,14 +10,14 @@ var ANY1; var ANY2: any[] = ["", ""]; >ANY2 : any[] >["", ""] : string[] ->"" : string ->"" : string +>"" : "" +>"" : "" var obj = {x:1,y:null}; >obj : { x: number; y: any; } >{x:1,y:null} : { x: number; y: null; } >x : number ->1 : number +>1 : 1 >y : null >null : null @@ -65,7 +65,7 @@ var ResultIsNumber5 = --ANY2[0]; >--ANY2[0] : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 var ResultIsNumber6 = --obj.x; >ResultIsNumber6 : number @@ -100,7 +100,7 @@ var ResultIsNumber9 = ANY2[0]--; >ANY2[0]-- : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 var ResultIsNumber10 = obj.x--; >ResultIsNumber10 : number @@ -143,7 +143,7 @@ var ResultIsNumber13 = M.n--; >--ANY2[0] : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 --ANY, --ANY1; >--ANY, --ANY1 : number @@ -176,7 +176,7 @@ ANY2[0]--; >ANY2[0]-- : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 ANY--, ANY1--; >ANY--, ANY1-- : number diff --git a/tests/baselines/reference/decrementOperatorWithNumberType.types b/tests/baselines/reference/decrementOperatorWithNumberType.types index f990ad18fc7..c81dc0660ec 100644 --- a/tests/baselines/reference/decrementOperatorWithNumberType.types +++ b/tests/baselines/reference/decrementOperatorWithNumberType.types @@ -6,8 +6,8 @@ var NUMBER: number; var NUMBER1: number[] = [1, 2]; >NUMBER1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 class A { >A : A @@ -72,7 +72,7 @@ var ResultIsNumber7 = NUMBER1[0]--; >NUMBER1[0]-- : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 // miss assignment operators --NUMBER; @@ -83,7 +83,7 @@ var ResultIsNumber7 = NUMBER1[0]--; >--NUMBER1[0] : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 --objA.a; >--objA.a : number @@ -115,7 +115,7 @@ NUMBER1[0]--; >NUMBER1[0]-- : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 objA.a--; >objA.a-- : number diff --git a/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt b/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt index 60a9e92bc95..b0b0f876be4 100644 --- a/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt +++ b/tests/baselines/reference/defaultArgsInFunctionExpressions.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/defaultArgsInFunctionExpressions.ts(4,19): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/compiler/defaultArgsInFunctionExpressions.ts(4,19): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(5,1): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/defaultArgsInFunctionExpressions.ts(8,20): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/defaultArgsInFunctionExpressions.ts(8,20): error TS2322: Type '3' is not assignable to type 'string'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(11,1): error TS2322: Type 'string' is not assignable to type 'number'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(14,51): error TS2352: Type 'string' cannot be converted to type 'number'. -tests/cases/compiler/defaultArgsInFunctionExpressions.ts(17,41): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/defaultArgsInFunctionExpressions.ts(17,41): error TS2322: Type '""' is not assignable to type 'number'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(20,62): error TS2352: Type 'string' cannot be converted to type 'number'. tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2304: Cannot find name 'T'. @@ -14,7 +14,7 @@ tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2304: C n = f(); var s: string = f(''); ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. s = f(); ~ !!! error TS2322: Type 'number' is not assignable to type 'string'. @@ -22,7 +22,7 @@ tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2304: C // Type check the default argument with the type annotation var f2 = function (a: string = 3) { return a; }; // Should error, but be of type (a: string) => string; ~~~~~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '3' is not assignable to type 'string'. s = f2(''); s = f2(); n = f2(); @@ -37,7 +37,7 @@ tests/cases/compiler/defaultArgsInFunctionExpressions.ts(28,15): error TS2304: C // Type check using the function's contextual type var f4: (a: number) => void = function (a = "") { }; ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. // Contextually type the default arg using the function's contextual type var f5: (a: (s: string) => any) => void = function (a = s => s) { }; diff --git a/tests/baselines/reference/defaultIndexProps1.types b/tests/baselines/reference/defaultIndexProps1.types index 0b188a40c20..d79685da387 100644 --- a/tests/baselines/reference/defaultIndexProps1.types +++ b/tests/baselines/reference/defaultIndexProps1.types @@ -4,7 +4,7 @@ class Foo { public v = "Yo"; >v : string ->"Yo" : string +>"Yo" : "Yo" } var f = new Foo(); @@ -16,17 +16,17 @@ var q = f["v"]; >q : string >f["v"] : string >f : Foo ->"v" : string +>"v" : "v" var o = {v:"Yo2"}; >o : { v: string; } >{v:"Yo2"} : { v: string; } >v : string ->"Yo2" : string +>"Yo2" : "Yo2" var q2 = o["v"]; >q2 : string >o["v"] : string >o : { v: string; } ->"v" : string +>"v" : "v" diff --git a/tests/baselines/reference/defaultIndexProps2.types b/tests/baselines/reference/defaultIndexProps2.types index 3b0d8278966..a50e4af450e 100644 --- a/tests/baselines/reference/defaultIndexProps2.types +++ b/tests/baselines/reference/defaultIndexProps2.types @@ -4,7 +4,7 @@ class Foo { public v = "Yo"; >v : string ->"Yo" : string +>"Yo" : "Yo" } var f = new Foo(); @@ -18,18 +18,18 @@ var o = {v:"Yo2"}; >o : { v: string; } >{v:"Yo2"} : { v: string; } >v : string ->"Yo2" : string +>"Yo2" : "Yo2" // WScript.Echo(o[0]); 1[0]; >1[0] : any ->1 : number ->0 : number +>1 : 1 +>0 : 0 var q = "s"[0]; >q : string >"s"[0] : string ->"s" : string ->0 : number +>"s" : "s" +>0 : 0 diff --git a/tests/baselines/reference/deleteOperatorWithBooleanType.types b/tests/baselines/reference/deleteOperatorWithBooleanType.types index 81c12ad6182..664a2530f33 100644 --- a/tests/baselines/reference/deleteOperatorWithBooleanType.types +++ b/tests/baselines/reference/deleteOperatorWithBooleanType.types @@ -15,7 +15,7 @@ class A { static foo() { return false; } >foo : () => boolean ->false : boolean +>false : false } module M { >M : typeof M @@ -39,16 +39,16 @@ var ResultIsBoolean1 = delete BOOLEAN; var ResultIsBoolean2 = delete true; >ResultIsBoolean2 : boolean >delete true : boolean ->true : boolean +>true : true var ResultIsBoolean3 = delete { x: true, y: false }; >ResultIsBoolean3 : boolean >delete { x: true, y: false } : boolean >{ x: true, y: false } : { x: boolean; y: boolean; } >x : boolean ->true : boolean +>true : true >y : boolean ->false : boolean +>false : false // boolean type expressions var ResultIsBoolean4 = delete objA.a; @@ -89,7 +89,7 @@ var ResultIsBoolean8 = delete delete BOOLEAN; // miss assignment operators delete true; >delete true : boolean ->true : boolean +>true : true delete BOOLEAN; >delete BOOLEAN : boolean @@ -101,10 +101,10 @@ delete foo(); >foo : () => boolean delete true, false; ->delete true, false : boolean +>delete true, false : false >delete true : boolean ->true : boolean ->false : boolean +>true : true +>false : false delete objA.a; >delete objA.a : boolean diff --git a/tests/baselines/reference/deleteOperatorWithEnumType.types b/tests/baselines/reference/deleteOperatorWithEnumType.types index d3266a6aa6c..5248ef6d46e 100644 --- a/tests/baselines/reference/deleteOperatorWithEnumType.types +++ b/tests/baselines/reference/deleteOperatorWithEnumType.types @@ -6,8 +6,8 @@ enum ENUM { }; enum ENUM1 { A, B, "" }; >ENUM1 : ENUM1 ->A : ENUM1 ->B : ENUM1 +>A : ENUM1.A +>B : ENUM1.B // enum type var var ResultIsBoolean1 = delete ENUM; @@ -24,9 +24,9 @@ var ResultIsBoolean2 = delete ENUM1; var ResultIsBoolean3 = delete ENUM1["A"]; >ResultIsBoolean3 : boolean >delete ENUM1["A"] : boolean ->ENUM1["A"] : ENUM1 +>ENUM1["A"] : ENUM1.A >ENUM1 : typeof ENUM1 ->"A" : string +>"A" : "A" var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]); >ResultIsBoolean4 : boolean @@ -35,10 +35,10 @@ var ResultIsBoolean4 = delete (ENUM[0] + ENUM1["B"]); >ENUM[0] + ENUM1["B"] : string >ENUM[0] : string >ENUM : typeof ENUM ->0 : number ->ENUM1["B"] : ENUM1 +>0 : 0 +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" // multiple delete operators var ResultIsBoolean5 = delete delete ENUM; @@ -56,10 +56,10 @@ var ResultIsBoolean6 = delete delete delete (ENUM[0] + ENUM1["B"]); >ENUM[0] + ENUM1["B"] : string >ENUM[0] : string >ENUM : typeof ENUM ->0 : number ->ENUM1["B"] : ENUM1 +>0 : 0 +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" // miss assignment operators delete ENUM; @@ -72,9 +72,9 @@ delete ENUM1; delete ENUM1.B; >delete ENUM1.B : boolean ->ENUM1.B : ENUM1 +>ENUM1.B : ENUM1.B >ENUM1 : typeof ENUM1 ->B : ENUM1 +>B : ENUM1.B delete ENUM, ENUM1; >delete ENUM, ENUM1 : typeof ENUM1 diff --git a/tests/baselines/reference/deleteOperatorWithNumberType.types b/tests/baselines/reference/deleteOperatorWithNumberType.types index e631745d089..e3a26b618e1 100644 --- a/tests/baselines/reference/deleteOperatorWithNumberType.types +++ b/tests/baselines/reference/deleteOperatorWithNumberType.types @@ -6,12 +6,12 @@ var NUMBER: number; var NUMBER1: number[] = [1, 2]; >NUMBER1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 function foo(): number { return 1; } >foo : () => number ->1 : number +>1 : 1 class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsBoolean2 = delete NUMBER1; var ResultIsBoolean3 = delete 1; >ResultIsBoolean3 : boolean >delete 1 : boolean ->1 : number +>1 : 1 var ResultIsBoolean4 = delete { x: 1, y: 2}; >ResultIsBoolean4 : boolean >delete { x: 1, y: 2} : boolean >{ x: 1, y: 2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 var ResultIsBoolean5 = delete { x: 1, y: (n: number) => { return n; } }; >ResultIsBoolean5 : boolean >delete { x: 1, y: (n: number) => { return n; } } : boolean >{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; } >x : number ->1 : number +>1 : 1 >y : (n: number) => number >(n: number) => { return n; } : (n: number) => number >n : number @@ -92,7 +92,7 @@ var ResultIsBoolean8 = delete NUMBER1[0]; >delete NUMBER1[0] : boolean >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 var ResultIsBoolean9 = delete foo(); >ResultIsBoolean9 : boolean @@ -136,7 +136,7 @@ var ResultIsBoolean13 = delete delete delete (NUMBER + NUMBER); // miss assignment operators delete 1; >delete 1 : boolean ->1 : number +>1 : 1 delete NUMBER; >delete NUMBER : boolean diff --git a/tests/baselines/reference/deleteOperatorWithStringType.types b/tests/baselines/reference/deleteOperatorWithStringType.types index 0492aeff176..842ad281ef7 100644 --- a/tests/baselines/reference/deleteOperatorWithStringType.types +++ b/tests/baselines/reference/deleteOperatorWithStringType.types @@ -6,12 +6,12 @@ var STRING: string; var STRING1: string[] = ["", "abc"]; >STRING1 : string[] >["", "abc"] : string[] ->"" : string ->"abc" : string +>"" : "" +>"abc" : "abc" function foo(): string { return "abc"; } >foo : () => string ->"abc" : string +>"abc" : "abc" class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return ""; } >foo : () => string ->"" : string +>"" : "" } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsBoolean2 = delete STRING1; var ResultIsBoolean3 = delete ""; >ResultIsBoolean3 : boolean >delete "" : boolean ->"" : string +>"" : "" var ResultIsBoolean4 = delete { x: "", y: "" }; >ResultIsBoolean4 : boolean >delete { x: "", y: "" } : boolean >{ x: "", y: "" } : { x: string; y: string; } >x : string ->"" : string +>"" : "" >y : string ->"" : string +>"" : "" var ResultIsBoolean5 = delete { x: "", y: (s: string) => { return s; } }; >ResultIsBoolean5 : boolean >delete { x: "", y: (s: string) => { return s; } } : boolean >{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; } >x : string ->"" : string +>"" : "" >y : (s: string) => string >(s: string) => { return s; } : (s: string) => string >s : string @@ -92,7 +92,7 @@ var ResultIsBoolean8 = delete STRING1[0]; >delete STRING1[0] : boolean >STRING1[0] : string >STRING1 : string[] ->0 : number +>0 : 0 var ResultIsBoolean9 = delete foo(); >ResultIsBoolean9 : boolean @@ -123,7 +123,7 @@ var ResultIsBoolean12 = delete STRING.charAt(0); >STRING.charAt : (pos: number) => string >STRING : string >charAt : (pos: number) => string ->0 : number +>0 : 0 // multiple delete operator var ResultIsBoolean13 = delete delete STRING; @@ -145,7 +145,7 @@ var ResultIsBoolean14 = delete delete delete (STRING + STRING); // miss assignment operators delete ""; >delete "" : boolean ->"" : string +>"" : "" delete STRING; >delete STRING : boolean diff --git a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.types b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.types index 2799555a3a2..5d981250698 100644 --- a/tests/baselines/reference/derivedClassOverridesProtectedMembers2.types +++ b/tests/baselines/reference/derivedClassOverridesProtectedMembers2.types @@ -227,12 +227,12 @@ var r7 = d2['']; >r7 : { foo: string; } >d2[''] : { foo: string; } >d2 : Derived2 ->'' : string +>'' : "" var r8 = d2[1]; >r8 : { foo: string; bar: string; } >d2[1] : { foo: string; bar: string; } >d2 : Derived2 ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/destructureOptionalParameter.types b/tests/baselines/reference/destructureOptionalParameter.types index 9baffd5f8fa..a72b03f5939 100644 --- a/tests/baselines/reference/destructureOptionalParameter.types +++ b/tests/baselines/reference/destructureOptionalParameter.types @@ -15,9 +15,9 @@ function f2({ a, b }: { a: number, b: number } = { a: 0, b: 0 }) { >b : number >{ a: 0, b: 0 } : { a: number; b: number; } >a : number ->0 : number +>0 : 0 >b : number ->0 : number +>0 : 0 a; >a : number diff --git a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt index 610167a1bc0..7fba74522e2 100644 --- a/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt +++ b/tests/baselines/reference/destructuringArrayBindingPatternAndAssignment2.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,6): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(3,12): error TS2525: Initializer provides no value for this binding element and the binding element has no default value. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(4,5): error TS2461: Type 'undefined' is not an array type. -tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. - Type 'number' is not assignable to type 'boolean'. +tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(9,5): error TS2322: Type '[number, 2, string]' is not assignable to type '[number, boolean, string]'. + Type '2' is not assignable to type 'boolean'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(22,5): error TS2322: Type 'number[]' is not assignable to type '[number, number]'. Property '0' is missing in type 'number[]'. tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAssignment2.ts(23,5): error TS2322: Type 'number[]' is not assignable to type '[string, string]'. @@ -27,8 +27,8 @@ tests/cases/conformance/es6/destructuring/destructuringArrayBindingPatternAndAss // where N is the numeric index of E in the array assignment pattern, or var [b0, b1, b2]: [number, boolean, string] = [1, 2, "string"]; // Error ~~~~~~~~~~~~ -!!! error TS2322: Type '[number, number, string]' is not assignable to type '[number, boolean, string]'. -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. +!!! error TS2322: Type '[number, 2, string]' is not assignable to type '[number, boolean, string]'. +!!! error TS2322: Type '2' is not assignable to type 'boolean'. interface J extends Array { 2: number; } diff --git a/tests/baselines/reference/destructuringAssignmentWithDefault.types b/tests/baselines/reference/destructuringAssignmentWithDefault.types index 1dc1fe23533..658816a36e4 100644 --- a/tests/baselines/reference/destructuringAssignmentWithDefault.types +++ b/tests/baselines/reference/destructuringAssignmentWithDefault.types @@ -6,7 +6,7 @@ const a: { x?: number } = { }; let x = 0; >x : number ->0 : number +>0 : 0 ({x = 1} = a); >({x = 1} = a) : { x?: number | undefined; } diff --git a/tests/baselines/reference/destructuringInFunctionType.types b/tests/baselines/reference/destructuringInFunctionType.types index 5292ea989dd..3f635d44568 100644 --- a/tests/baselines/reference/destructuringInFunctionType.types +++ b/tests/baselines/reference/destructuringInFunctionType.types @@ -70,7 +70,7 @@ var v1 = ([a, b, c]) => "hello"; >a : any >b : any >c : any ->"hello" : string +>"hello" : "hello" var v2: ([a, b, c]) => string; >v2 : ([a, b, c]: [any, any, any]) => string diff --git a/tests/baselines/reference/destructuringInVariableDeclarations1.types b/tests/baselines/reference/destructuringInVariableDeclarations1.types index 84a60c844a3..4da295f5dd0 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations1.types +++ b/tests/baselines/reference/destructuringInVariableDeclarations1.types @@ -1,10 +1,10 @@ === tests/cases/compiler/destructuringInVariableDeclarations1.ts === export let { toString } = 1; >toString : (radix?: number) => string ->1 : number +>1 : 1 { let { toFixed } = 1; >toFixed : (fractionDigits?: number) => string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/destructuringInVariableDeclarations2.types b/tests/baselines/reference/destructuringInVariableDeclarations2.types index b7456d30285..7bda9c52ef2 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations2.types +++ b/tests/baselines/reference/destructuringInVariableDeclarations2.types @@ -1,11 +1,11 @@ === tests/cases/compiler/destructuringInVariableDeclarations2.ts === let { toString } = 1; >toString : (radix?: number) => string ->1 : number +>1 : 1 { let { toFixed } = 1; >toFixed : (fractionDigits?: number) => string ->1 : number +>1 : 1 } export {}; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations3.types b/tests/baselines/reference/destructuringInVariableDeclarations3.types index 970d6deb1ed..222d4c76130 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations3.types +++ b/tests/baselines/reference/destructuringInVariableDeclarations3.types @@ -1,10 +1,10 @@ === tests/cases/compiler/destructuringInVariableDeclarations3.ts === export let { toString } = 1; >toString : (radix?: number) => string ->1 : number +>1 : 1 { let { toFixed } = 1; >toFixed : (fractionDigits?: number) => string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/destructuringInVariableDeclarations4.types b/tests/baselines/reference/destructuringInVariableDeclarations4.types index 628fe7a9562..7714b78eeec 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations4.types +++ b/tests/baselines/reference/destructuringInVariableDeclarations4.types @@ -1,11 +1,11 @@ === tests/cases/compiler/destructuringInVariableDeclarations4.ts === let { toString } = 1; >toString : (radix?: number) => string ->1 : number +>1 : 1 { let { toFixed } = 1; >toFixed : (fractionDigits?: number) => string ->1 : number +>1 : 1 } export {}; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations5.types b/tests/baselines/reference/destructuringInVariableDeclarations5.types index 9a890916d17..d6c4b3dee7a 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations5.types +++ b/tests/baselines/reference/destructuringInVariableDeclarations5.types @@ -1,10 +1,10 @@ === tests/cases/compiler/destructuringInVariableDeclarations5.ts === export let { toString } = 1; >toString : (radix?: number) => string ->1 : number +>1 : 1 { let { toFixed } = 1; >toFixed : (fractionDigits?: number) => string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/destructuringInVariableDeclarations6.types b/tests/baselines/reference/destructuringInVariableDeclarations6.types index cf1105b575a..d4f94ffcd03 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations6.types +++ b/tests/baselines/reference/destructuringInVariableDeclarations6.types @@ -1,11 +1,11 @@ === tests/cases/compiler/destructuringInVariableDeclarations6.ts === let { toString } = 1; >toString : (radix?: number) => string ->1 : number +>1 : 1 { let { toFixed } = 1; >toFixed : (fractionDigits?: number) => string ->1 : number +>1 : 1 } export {}; diff --git a/tests/baselines/reference/destructuringInVariableDeclarations7.types b/tests/baselines/reference/destructuringInVariableDeclarations7.types index c0c1b571215..e4f4603567b 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations7.types +++ b/tests/baselines/reference/destructuringInVariableDeclarations7.types @@ -1,10 +1,10 @@ === tests/cases/compiler/destructuringInVariableDeclarations7.ts === export let { toString } = 1; >toString : (radix?: number) => string ->1 : number +>1 : 1 { let { toFixed } = 1; >toFixed : (fractionDigits?: number) => string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/destructuringInVariableDeclarations8.types b/tests/baselines/reference/destructuringInVariableDeclarations8.types index ef376563551..c79650d5724 100644 --- a/tests/baselines/reference/destructuringInVariableDeclarations8.types +++ b/tests/baselines/reference/destructuringInVariableDeclarations8.types @@ -1,11 +1,11 @@ === tests/cases/compiler/destructuringInVariableDeclarations8.ts === let { toString } = 1; >toString : (radix?: number) => string ->1 : number +>1 : 1 { let { toFixed } = 1; >toFixed : (fractionDigits?: number) => string ->1 : number +>1 : 1 } export {}; diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types index 2301902bf64..e0aedcbb167 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES5.types @@ -19,31 +19,31 @@ var { b1, } = { b1:1, }; >b1 : number >{ b1:1, } : { b1: number; } >b1 : number ->1 : number +>1 : 1 var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; >b2 : any >b21 : string >{ b21: "string" } : { b21: string; } >b21 : string ->"string" : string +>"string" : "string" >{ b2: { b21: "world" } } : { b2?: { b21: string; }; } >b2 : { b21: string; } >{ b21: "world" } : { b21: string; } >b21 : string ->"world" : string +>"world" : "world" var {1: b3} = { 1: "string" }; >b3 : string >{ 1: "string" } : { 1: string; } ->"string" : string +>"string" : "string" var {b4 = 1}: any = { b4: 100000 }; >b4 : number ->1 : number +>1 : 1 >{ b4: 100000 } : { b4: number; } >b4 : number ->100000 : number +>100000 : 100000 var {b5: { b52 } } = { b5: { b52 } }; >b5 : any @@ -117,7 +117,7 @@ function foo1(): F1 { >{ "prop1": 2 } : { "prop1": number; } "prop1": 2 ->2 : number +>2 : 2 } } diff --git a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types index 48428881290..7d68d32ac51 100644 --- a/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types +++ b/tests/baselines/reference/destructuringObjectBindingPatternAndAssignment1ES6.types @@ -19,31 +19,31 @@ var { b1, } = { b1:1, }; >b1 : number >{ b1:1, } : { b1: number; } >b1 : number ->1 : number +>1 : 1 var { b2: { b21 } = { b21: "string" } } = { b2: { b21: "world" } }; >b2 : any >b21 : string >{ b21: "string" } : { b21: string; } >b21 : string ->"string" : string +>"string" : "string" >{ b2: { b21: "world" } } : { b2?: { b21: string; }; } >b2 : { b21: string; } >{ b21: "world" } : { b21: string; } >b21 : string ->"world" : string +>"world" : "world" var {1: b3} = { 1: "string" }; >b3 : string >{ 1: "string" } : { 1: string; } ->"string" : string +>"string" : "string" var {b4 = 1}: any = { b4: 100000 }; >b4 : number ->1 : number +>1 : 1 >{ b4: 100000 } : { b4: number; } >b4 : number ->100000 : number +>100000 : 100000 var {b5: { b52 } } = { b5: { b52 } }; >b5 : any @@ -117,7 +117,7 @@ function foo1(): F1 { >{ "prop1": 2 } : { "prop1": number; } "prop1": 2 ->2 : number +>2 : 2 } } diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types index 2ab9c9330d6..7d4662100ed 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES5.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES5.types @@ -70,16 +70,16 @@ function a11([a, b, c, ...x]: number[]) { } var array = [1, 2, 3]; >array : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var array2 = [true, false, "hello"]; >array2 : (string | boolean)[] >[true, false, "hello"] : (string | boolean)[] ->true : boolean ->false : boolean ->"hello" : string +>true : true +>false : false +>"hello" : "hello" a2([...array]); >a2([...array]) : void @@ -98,49 +98,49 @@ a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]] >a9([1, 2, [["string"]], false, true]) : void >a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void >[1, 2, [["string"]], false, true] : [number, number, [[string]], boolean, boolean] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >[["string"]] : [[string]] >["string"] : [string] ->"string" : string ->false : boolean ->true : boolean +>"string" : "string" +>false : false +>true : true a10([1, 2, [["string"]], false, true]); // Parameter type is any[] >a10([1, 2, [["string"]], false, true]) : void >a10 : ([a, b, [[c]], ...x]: Iterable) => void >[1, 2, [["string"]], false, true] : (number | boolean | string[][])[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >[["string"]] : string[][] >["string"] : string[] ->"string" : string ->false : boolean ->true : boolean +>"string" : "string" +>false : false +>true : true a10([1, 2, 3, false, true]); // Parameter type is any[] >a10([1, 2, 3, false, true]) : void >a10 : ([a, b, [[c]], ...x]: Iterable) => void >[1, 2, 3, false, true] : (number | boolean)[] ->1 : number ->2 : number ->3 : number ->false : boolean ->true : boolean +>1 : 1 +>2 : 2 +>3 : 3 +>false : false +>true : true a10([1, 2]); // Parameter type is any[] >a10([1, 2]) : void >a10 : ([a, b, [[c]], ...x]: Iterable) => void >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 a11([1, 2]); // Parameter type is number[] >a11([1, 2]) : void >a11 : ([a, b, c, ...x]: number[]) => void >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 // Rest parameter with generic function foo(...a: T[]) { } @@ -152,25 +152,25 @@ function foo(...a: T[]) { } foo("hello", 1, 2); >foo("hello", 1, 2) : void >foo : (...a: T[]) => void ->"hello" : string ->1 : number ->2 : number +>"hello" : "hello" +>1 : 1 +>2 : 2 foo("hello", "world"); >foo("hello", "world") : void >foo : (...a: T[]) => void ->"hello" : string ->"world" : string +>"hello" : "hello" +>"world" : "world" enum E { a, b } >E : E ->a : E ->b : E +>a : E.a +>b : E.b const enum E1 { a, b } >E1 : E1 ->a : E1 ->b : E1 +>a : E1.a +>b : E1.b function foo1(...a: T[]) { } >foo1 : (...a: T[]) => void @@ -182,25 +182,25 @@ function foo1(...a: T[]) { } foo1(1, 2, 3, E.a); >foo1(1, 2, 3, E.a) : void >foo1 : (...a: T[]) => void ->1 : number ->2 : number ->3 : number ->E.a : E +>1 : 1 +>2 : 2 +>3 : 3 +>E.a : E.a >E : typeof E ->a : E +>a : E.a foo1(1, 2, 3, E1.a, E.b); >foo1(1, 2, 3, E1.a, E.b) : void >foo1 : (...a: T[]) => void ->1 : number ->2 : number ->3 : number ->E1.a : E1 +>1 : 1 +>2 : 2 +>3 : 3 +>E1.a : E1.a >E1 : typeof E1 ->a : E1 ->E.b : E +>a : E1.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b diff --git a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types index 55a26cfe58e..8ec0a27850b 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration3ES6.types +++ b/tests/baselines/reference/destructuringParameterDeclaration3ES6.types @@ -70,16 +70,16 @@ function a11([a, b, c, ...x]: number[]) { } var array = [1, 2, 3]; >array : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var array2 = [true, false, "hello"]; >array2 : (string | boolean)[] >[true, false, "hello"] : (string | boolean)[] ->true : boolean ->false : boolean ->"hello" : string +>true : true +>false : false +>"hello" : "hello" a2([...array]); >a2([...array]) : void @@ -98,49 +98,49 @@ a9([1, 2, [["string"]], false, true]); // Parameter type is [any, any, [[any]] >a9([1, 2, [["string"]], false, true]) : void >a9 : ([a, b, [[c]]]: [any, any, [[any]]]) => void >[1, 2, [["string"]], false, true] : [number, number, [[string]], boolean, boolean] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >[["string"]] : [[string]] >["string"] : [string] ->"string" : string ->false : boolean ->true : boolean +>"string" : "string" +>false : false +>true : true a10([1, 2, [["string"]], false, true]); // Parameter type is any[] >a10([1, 2, [["string"]], false, true]) : void >a10 : ([a, b, [[c]], ...x]: Iterable) => void >[1, 2, [["string"]], false, true] : (number | boolean | string[][])[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >[["string"]] : string[][] >["string"] : string[] ->"string" : string ->false : boolean ->true : boolean +>"string" : "string" +>false : false +>true : true a10([1, 2, 3, false, true]); // Parameter type is any[] >a10([1, 2, 3, false, true]) : void >a10 : ([a, b, [[c]], ...x]: Iterable) => void >[1, 2, 3, false, true] : (number | boolean)[] ->1 : number ->2 : number ->3 : number ->false : boolean ->true : boolean +>1 : 1 +>2 : 2 +>3 : 3 +>false : false +>true : true a10([1, 2]); // Parameter type is any[] >a10([1, 2]) : void >a10 : ([a, b, [[c]], ...x]: Iterable) => void >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 a11([1, 2]); // Parameter type is number[] >a11([1, 2]) : void >a11 : ([a, b, c, ...x]: number[]) => void >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 // Rest parameter with generic function foo(...a: T[]) { } @@ -152,25 +152,25 @@ function foo(...a: T[]) { } foo("hello", 1, 2); >foo("hello", 1, 2) : void >foo : (...a: T[]) => void ->"hello" : string ->1 : number ->2 : number +>"hello" : "hello" +>1 : 1 +>2 : 2 foo("hello", "world"); >foo("hello", "world") : void >foo : (...a: T[]) => void ->"hello" : string ->"world" : string +>"hello" : "hello" +>"world" : "world" enum E { a, b } >E : E ->a : E ->b : E +>a : E.a +>b : E.b const enum E1 { a, b } >E1 : E1 ->a : E1 ->b : E1 +>a : E1.a +>b : E1.b function foo1(...a: T[]) { } >foo1 : (...a: T[]) => void @@ -182,25 +182,25 @@ function foo1(...a: T[]) { } foo1(1, 2, 3, E.a); >foo1(1, 2, 3, E.a) : void >foo1 : (...a: T[]) => void ->1 : number ->2 : number ->3 : number ->E.a : E +>1 : 1 +>2 : 2 +>3 : 3 +>E.a : E.a >E : typeof E ->a : E +>a : E.a foo1(1, 2, 3, E1.a, E.b); >foo1(1, 2, 3, E1.a, E.b) : void >foo1 : (...a: T[]) => void ->1 : number ->2 : number ->3 : number ->E1.a : E1 +>1 : 1 +>2 : 2 +>3 : 3 +>E1.a : E1.a >E1 : typeof E1 ->a : E1 ->E.b : E +>a : E1.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b diff --git a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt index c89fa97b4cd..8db71591f47 100644 --- a/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt +++ b/tests/baselines/reference/destructuringParameterDeclaration4.errors.txt @@ -2,7 +2,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(13,13): error TS2370: A rest parameter must be of an array type. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(14,17): error TS1047: A rest parameter cannot be optional. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(15,16): error TS1048: A rest parameter cannot have an initializer. -tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(20,19): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(21,7): error TS2304: Cannot find name 'array2'. tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts(22,4): error TS2345: Argument of type '[number, number, string, boolean, boolean]' is not assignable to parameter of type '[any, any, [[any]]]'. Types of property '2' are incompatible. @@ -47,7 +47,7 @@ tests/cases/conformance/es6/destructuring/destructuringParameterDeclaration4.ts( a1(1, 2, "hello", true); // Error, parameter type is (number|string)[] ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string | number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string | number'. a1(...array2); // Error parameter type is (number|string)[] ~~~~~~ !!! error TS2304: Cannot find name 'array2'. diff --git a/tests/baselines/reference/destructuringParameterProperties2.errors.txt b/tests/baselines/reference/destructuringParameterProperties2.errors.txt index deb039aa67d..d47e50db853 100644 --- a/tests/baselines/reference/destructuringParameterProperties2.errors.txt +++ b/tests/baselines/reference/destructuringParameterProperties2.errors.txt @@ -5,8 +5,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4 tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'. tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'. -tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. - Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, ""]' is not assignable to parameter of type '[number, string, boolean]'. + Type '""' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ==== @@ -46,8 +46,8 @@ tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2 var x = new C1(undefined, [0, undefined, ""]); ~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. +!!! error TS2345: Argument of type '[number, undefined, ""]' is not assignable to parameter of type '[number, string, boolean]'. +!!! error TS2345: Type '""' is not assignable to type 'boolean'. var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()]; var y = new C1(10, [0, "", true]); diff --git a/tests/baselines/reference/destructuringTypeAssertionsES5_5.types b/tests/baselines/reference/destructuringTypeAssertionsES5_5.types index a7111cc4361..87c38ef7108 100644 --- a/tests/baselines/reference/destructuringTypeAssertionsES5_5.types +++ b/tests/baselines/reference/destructuringTypeAssertionsES5_5.types @@ -2,5 +2,5 @@ var { x } = 0; >x : any >0 : any ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types index 191cdc169b1..6f95b198434 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES5.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES5.types @@ -8,19 +8,19 @@ var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } >a2 : string >{ a1: 10, a2: "world" } : { a1: number; a2: string; } >a1 : number ->10 : number +>10 : 10 >a2 : string ->"world" : string +>"world" : "world" var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; >a3 : number >a4 : string >a5 : boolean >[1, [["hello"]], true] : [number, [[string]], true] ->1 : number +>1 : 1 >[["hello"]] : [[string]] >["hello"] : [string] ->"hello" : string +>"hello" : "hello" >true : true // The type T associated with a destructuring variable declaration is determined as follows: @@ -30,42 +30,42 @@ var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; >b11 : string >{ b11: "string" } : { b11: string; } >b11 : string ->"string" : string +>"string" : "string" >{ b1: { b11: "world" } } : { b1?: { b11: string; }; } >b1 : { b11: string; } >{ b11: "world" } : { b11: string; } >b11 : string ->"world" : string +>"world" : "world" var temp = { t1: true, t2: "false" }; >temp : { t1: boolean; t2: string; } >{ t1: true, t2: "false" } : { t1: boolean; t2: string; } >t1 : boolean ->true : boolean +>true : true >t2 : string ->"false" : string +>"false" : "false" var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; >b2 : number ->3 : number +>3 : 3 >b3 : boolean ->true : boolean +>true : true >b4 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } >[3, false, { t1: false, t2: "hello" }] : [number, false, { t1: false; t2: string; }] ->3 : number +>3 : 3 >false : false >{ t1: false, t2: "hello" } : { t1: false; t2: string; } ->t1 : false +>t1 : boolean >false : false >t2 : string ->"hello" : string +>"hello" : "hello" var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; ->b5 : number ->3 : number ->b6 : boolean ->true : boolean +>b5 : 3 +>3 : 3 +>b6 : true +>true : true >b7 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } >[undefined, undefined, undefined] : [undefined, undefined, undefined] @@ -79,17 +79,17 @@ var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; var [...c1] = [1,2,3]; >c1 : number[] >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var [...c2] = [1,2,3, "string"]; >c2 : (string | number)[] >[1,2,3, "string"] : (string | number)[] ->1 : number ->2 : number ->3 : number ->"string" : string +>1 : 1 +>2 : 2 +>3 : 3 +>"string" : "string" // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): @@ -99,8 +99,8 @@ var [d1,d2] = [1,"string"] >d1 : number >d2 : string >[1,"string"] : [number, string] ->1 : number ->"string" : string +>1 : 1 +>"string" : "string" // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): @@ -108,16 +108,16 @@ var [d1,d2] = [1,"string"] var temp1 = [true, false, true] >temp1 : boolean[] >[true, false, true] : boolean[] ->true : boolean ->false : boolean ->true : boolean +>true : true +>false : false +>true : true var [d3, d4] = [1, "string", ...temp1]; >d3 : string | number | boolean >d4 : string | number | boolean >[1, "string", ...temp1] : (string | number | boolean)[] ->1 : number ->"string" : string +>1 : 1 +>"string" : "string" >...temp1 : boolean >temp1 : boolean[] @@ -129,19 +129,19 @@ var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; >e3 : { b1: number; b4: number; } >{ b1: 1000, b4: 200 } : { b1: number; b4: number; } >b1 : number ->1000 : number +>1000 : 1000 >b4 : number ->200 : number +>200 : 200 >{ e: [1, 2, { b1: 4, b4: 0 }] } : { e: [number, number, { b1: number; b4: number; }]; } >e : [number, number, { b1: number; b4: number; }] >[1, 2, { b1: 4, b4: 0 }] : [number, number, { b1: number; b4: number; }] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >{ b1: 4, b4: 0 } : { b1: number; b4: number; } >b1 : number ->4 : number +>4 : 4 >b4 : number ->0 : number +>0 : 0 var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >f : any @@ -154,13 +154,13 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; } >f : [number, number, { f3: number; f5: number; }, any] >[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >{ f3: 4, f5: 0 } : { f3: number; f5: number; } >f3 : number ->4 : number +>4 : 4 >f5 : number ->0 : number +>0 : 0 // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable @@ -178,8 +178,8 @@ var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; >{ g1: [1, 2] } : { g1: number[]; } >g1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; >h : any @@ -194,7 +194,7 @@ var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } >{ h1: [1, 2] } : { h1: number[]; } >h1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types index 50f5cfc8a5a..d01326991c0 100644 --- a/tests/baselines/reference/destructuringVariableDeclaration1ES6.types +++ b/tests/baselines/reference/destructuringVariableDeclaration1ES6.types @@ -8,19 +8,19 @@ var {a1, a2}: { a1: number, a2: string } = { a1: 10, a2: "world" } >a2 : string >{ a1: 10, a2: "world" } : { a1: number; a2: string; } >a1 : number ->10 : number +>10 : 10 >a2 : string ->"world" : string +>"world" : "world" var [a3, [[a4]], a5]: [number, [[string]], boolean] = [1, [["hello"]], true]; >a3 : number >a4 : string >a5 : boolean >[1, [["hello"]], true] : [number, [[string]], true] ->1 : number +>1 : 1 >[["hello"]] : [[string]] >["hello"] : [string] ->"hello" : string +>"hello" : "hello" >true : true // The type T associated with a destructuring variable declaration is determined as follows: @@ -30,42 +30,42 @@ var { b1: { b11 } = { b11: "string" } } = { b1: { b11: "world" } }; >b11 : string >{ b11: "string" } : { b11: string; } >b11 : string ->"string" : string +>"string" : "string" >{ b1: { b11: "world" } } : { b1?: { b11: string; }; } >b1 : { b11: string; } >{ b11: "world" } : { b11: string; } >b11 : string ->"world" : string +>"world" : "world" var temp = { t1: true, t2: "false" }; >temp : { t1: boolean; t2: string; } >{ t1: true, t2: "false" } : { t1: boolean; t2: string; } >t1 : boolean ->true : boolean +>true : true >t2 : string ->"false" : string +>"false" : "false" var [b2 = 3, b3 = true, b4 = temp] = [3, false, { t1: false, t2: "hello" }]; >b2 : number ->3 : number +>3 : 3 >b3 : boolean ->true : boolean +>true : true >b4 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } >[3, false, { t1: false, t2: "hello" }] : [number, false, { t1: false; t2: string; }] ->3 : number +>3 : 3 >false : false >{ t1: false, t2: "hello" } : { t1: false; t2: string; } ->t1 : false +>t1 : boolean >false : false >t2 : string ->"hello" : string +>"hello" : "hello" var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; ->b5 : number ->3 : number ->b6 : boolean ->true : boolean +>b5 : 3 +>3 : 3 +>b6 : true +>true : true >b7 : { t1: boolean; t2: string; } >temp : { t1: boolean; t2: string; } >[undefined, undefined, undefined] : [undefined, undefined, undefined] @@ -79,17 +79,17 @@ var [b5 = 3, b6 = true, b7 = temp] = [undefined, undefined, undefined]; var [...c1] = [1,2,3]; >c1 : number[] >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var [...c2] = [1,2,3, "string"]; >c2 : (string | number)[] >[1,2,3, "string"] : (string | number)[] ->1 : number ->2 : number ->3 : number ->"string" : string +>1 : 1 +>2 : 2 +>3 : 3 +>"string" : "string" // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): @@ -99,8 +99,8 @@ var [d1,d2] = [1,"string"] >d1 : number >d2 : string >[1,"string"] : [number, string] ->1 : number ->"string" : string +>1 : 1 +>"string" : "string" // The type T associated with a binding element is determined as follows: // Otherwise, if S is a tuple- like type (section 3.3.3): @@ -108,16 +108,16 @@ var [d1,d2] = [1,"string"] var temp1 = [true, false, true] >temp1 : boolean[] >[true, false, true] : boolean[] ->true : boolean ->false : boolean ->true : boolean +>true : true +>false : false +>true : true var [d3, d4] = [1, "string", ...temp1]; >d3 : string | number | boolean >d4 : string | number | boolean >[1, "string", ...temp1] : (string | number | boolean)[] ->1 : number ->"string" : string +>1 : 1 +>"string" : "string" >...temp1 : boolean >temp1 : boolean[] @@ -129,19 +129,19 @@ var {e: [e1, e2, e3 = { b1: 1000, b4: 200 }]} = { e: [1, 2, { b1: 4, b4: 0 }] }; >e3 : { b1: number; b4: number; } >{ b1: 1000, b4: 200 } : { b1: number; b4: number; } >b1 : number ->1000 : number +>1000 : 1000 >b4 : number ->200 : number +>200 : 200 >{ e: [1, 2, { b1: 4, b4: 0 }] } : { e: [number, number, { b1: number; b4: number; }]; } >e : [number, number, { b1: number; b4: number; }] >[1, 2, { b1: 4, b4: 0 }] : [number, number, { b1: number; b4: number; }] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >{ b1: 4, b4: 0 } : { b1: number; b4: number; } >b1 : number ->4 : number +>4 : 4 >b4 : number ->0 : number +>0 : 0 var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >f : any @@ -154,13 +154,13 @@ var {f: [f1, f2, { f3: f4, f5 }, , ]} = { f: [1, 2, { f3: 4, f5: 0 }] }; >{ f: [1, 2, { f3: 4, f5: 0 }] } : { f: [number, number, { f3: number; f5: number; }, any]; } >f : [number, number, { f3: number; f5: number; }, any] >[1, 2, { f3: 4, f5: 0 }] : [number, number, { f3: number; f5: number; }, any] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >{ f3: 4, f5: 0 } : { f3: number; f5: number; } >f3 : number ->4 : number +>4 : 4 >f5 : number ->0 : number +>0 : 0 // When a destructuring variable declaration, binding property, or binding element specifies // an initializer expression, the type of the initializer expression is required to be assignable @@ -178,8 +178,8 @@ var {g: {g1 = [undefined, null]}}: { g: { g1: any[] } } = { g: { g1: [1, 2] } }; >{ g1: [1, 2] } : { g1: number[]; } >g1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } }; >h : any @@ -194,7 +194,7 @@ var {h: {h1 = [undefined, null]}}: { h: { h1: number[] } } = { h: { h1: [1, 2] } >{ h1: [1, 2] } : { h1: number[]; } >h1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/destructuringWithLiteralInitializers.types b/tests/baselines/reference/destructuringWithLiteralInitializers.types index 9b970679f74..43391515014 100644 --- a/tests/baselines/reference/destructuringWithLiteralInitializers.types +++ b/tests/baselines/reference/destructuringWithLiteralInitializers.types @@ -10,40 +10,40 @@ f1({ x: 1, y: 1 }); >f1 : ({x, y}: { x: any; y: any; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 // (arg: { x: any, y?: number }) => void function f2({ x, y = 0 }) { } >f2 : ({x, y}: { x: any; y?: number; }) => void >x : any >y : number ->0 : number +>0 : 0 f2({ x: 1 }); >f2({ x: 1 }) : void >f2 : ({x, y}: { x: any; y?: number; }) => void >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 f2({ x: 1, y: 1 }); >f2({ x: 1, y: 1 }) : void >f2 : ({x, y}: { x: any; y?: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 // (arg: { x?: number, y?: number }) => void function f3({ x = 0, y = 0 }) { } >f3 : ({x, y}: { x?: number; y?: number; }) => void >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 f3({}); >f3({}) : void @@ -55,23 +55,23 @@ f3({ x: 1 }); >f3 : ({x, y}: { x?: number; y?: number; }) => void >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 f3({ y: 1 }); >f3({ y: 1 }) : void >f3 : ({x, y}: { x?: number; y?: number; }) => void >{ y: 1 } : { y: number; } >y : number ->1 : number +>1 : 1 f3({ x: 1, y: 1 }); >f3({ x: 1, y: 1 }) : void >f3 : ({x, y}: { x?: number; y?: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 // (arg?: { x: number, y: number }) => void function f4({ x, y } = { x: 0, y: 0 }) { } @@ -80,9 +80,9 @@ function f4({ x, y } = { x: 0, y: 0 }) { } >y : number >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 f4(); >f4() : void @@ -93,19 +93,19 @@ f4({ x: 1, y: 1 }); >f4 : ({x, y}?: { x: number; y: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 // (arg?: { x: number, y?: number }) => void function f5({ x, y = 0 } = { x: 0 }) { } >f5 : ({x, y}?: { x: number; y?: number; }) => void >x : number >y : number ->0 : number +>0 : 0 >{ x: 0 } : { x: number; y?: number; } >x : number ->0 : number +>0 : 0 f5(); >f5() : void @@ -116,24 +116,24 @@ f5({ x: 1 }); >f5 : ({x, y}?: { x: number; y?: number; }) => void >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 f5({ x: 1, y: 1 }); >f5({ x: 1, y: 1 }) : void >f5 : ({x, y}?: { x: number; y?: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 // (arg?: { x?: number, y?: number }) => void function f6({ x = 0, y = 0 } = {}) { } >f6 : ({x, y}?: { x?: number; y?: number; }) => void >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >{} : { x?: number; y?: number; } f6(); @@ -150,32 +150,32 @@ f6({ x: 1 }); >f6 : ({x, y}?: { x?: number; y?: number; }) => void >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 f6({ y: 1 }); >f6({ y: 1 }) : void >f6 : ({x, y}?: { x?: number; y?: number; }) => void >{ y: 1 } : { y: number; } >y : number ->1 : number +>1 : 1 f6({ x: 1, y: 1 }); >f6({ x: 1, y: 1 }) : void >f6 : ({x, y}?: { x?: number; y?: number; }) => void >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 // (arg?: { a: { x?: number, y?: number } }) => void function f7({ a: { x = 0, y = 0 } } = { a: {} }) { } >f7 : ({a: {x, y}}?: { a: { x?: number; y?: number; }; }) => void >a : any >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >{ a: {} } : { a: { x?: number; y?: number; }; } >a : { x?: number; y?: number; } >{} : { x?: number; y?: number; } @@ -198,7 +198,7 @@ f7({ a: { x: 1 } }); >a : { x: number; } >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 f7({ a: { y: 1 } }); >f7({ a: { y: 1 } }) : void @@ -207,7 +207,7 @@ f7({ a: { y: 1 } }); >a : { y: number; } >{ y: 1 } : { y: number; } >y : number ->1 : number +>1 : 1 f7({ a: { x: 1, y: 1 } }); >f7({ a: { x: 1, y: 1 } }) : void @@ -216,9 +216,9 @@ f7({ a: { x: 1, y: 1 } }); >a : { x: number; y: number; } >{ x: 1, y: 1 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->1 : number +>1 : 1 // (arg: [any, any]) => void function g1([x, y]) { } @@ -230,23 +230,23 @@ g1([1, 1]); >g1([1, 1]) : void >g1 : ([x, y]: [any, any]) => void >[1, 1] : [number, number] ->1 : number ->1 : number +>1 : 1 +>1 : 1 // (arg: [number, number]) => void function g2([x = 0, y = 0]) { } >g2 : ([x, y]: [number, number]) => void >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 g2([1, 1]); >g2([1, 1]) : void >g2 : ([x, y]: [number, number]) => void >[1, 1] : [number, number] ->1 : number ->1 : number +>1 : 1 +>1 : 1 // (arg?: [number, number]) => void function g3([x, y] = [0, 0]) { } @@ -254,8 +254,8 @@ function g3([x, y] = [0, 0]) { } >x : number >y : number >[0, 0] : [number, number] ->0 : number ->0 : number +>0 : 0 +>0 : 0 g3(); >g3() : void @@ -265,17 +265,17 @@ g3([1, 1]); >g3([1, 1]) : void >g3 : ([x, y]?: [number, number]) => void >[1, 1] : [number, number] ->1 : number ->1 : number +>1 : 1 +>1 : 1 // (arg?: [number, number]) => void function g4([x, y = 0] = [0]) { } >g4 : ([x, y]?: [number, number]) => void >x : number >y : number ->0 : number +>0 : 0 >[0] : [number, number] ->0 : number +>0 : 0 g4(); >g4() : void @@ -285,16 +285,16 @@ g4([1, 1]); >g4([1, 1]) : void >g4 : ([x, y]?: [number, number]) => void >[1, 1] : [number, number] ->1 : number ->1 : number +>1 : 1 +>1 : 1 // (arg?: [number, number]) => void function g5([x = 0, y = 0] = []) { } >g5 : ([x, y]?: [number, number]) => void >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 >[] : [number, number] g5(); @@ -305,6 +305,6 @@ g5([1, 1]); >g5([1, 1]) : void >g5 : ([x, y]?: [number, number]) => void >[1, 1] : [number, number] ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/destructuringWithNewExpression.types b/tests/baselines/reference/destructuringWithNewExpression.types index 1d36746a44d..2803dfd802f 100644 --- a/tests/baselines/reference/destructuringWithNewExpression.types +++ b/tests/baselines/reference/destructuringWithNewExpression.types @@ -4,7 +4,7 @@ class C { x = 0; >x : number ->0 : number +>0 : 0 } var { x } = new C; diff --git a/tests/baselines/reference/destructuringWithNumberLiteral.types b/tests/baselines/reference/destructuringWithNumberLiteral.types index 7fe902c622e..226c3fd4923 100644 --- a/tests/baselines/reference/destructuringWithNumberLiteral.types +++ b/tests/baselines/reference/destructuringWithNumberLiteral.types @@ -1,5 +1,5 @@ === tests/cases/compiler/destructuringWithNumberLiteral.ts === var { toExponential } = 0; >toExponential : (fractionDigits?: number) => string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/doNotEmitDetachedComments.types b/tests/baselines/reference/doNotEmitDetachedComments.types index d9b5f0634c2..ee361223560 100644 --- a/tests/baselines/reference/doNotEmitDetachedComments.types +++ b/tests/baselines/reference/doNotEmitDetachedComments.types @@ -7,7 +7,7 @@ var x = 10; >x : number ->10 : number +>10 : 10 // Single Line comment diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types index c316c6403c0..b8879c4236e 100644 --- a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfConstructor.types @@ -7,7 +7,7 @@ class A { var x = 10; >x : number ->10 : number +>10 : 10 } } @@ -21,7 +21,7 @@ class B { var y = 10; >y : number ->10 : number +>10 : 10 } } @@ -34,7 +34,7 @@ class C { var x = 10; >x : number ->10 : number +>10 : 10 } } @@ -49,6 +49,6 @@ class D { var y = 10; >y : number ->10 : number +>10 : 10 } } diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types index 3b4814bbbb2..78c3d946f1d 100644 --- a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfFunctionBody.types @@ -5,7 +5,7 @@ function foo1() { // Single line comment return 42; ->42 : number +>42 : 42 } function foo2() { @@ -18,7 +18,7 @@ function foo2() { */ return 42; ->42 : number +>42 : 42 } function foo3() { @@ -28,7 +28,7 @@ function foo3() { return 42; ->42 : number +>42 : 42 } function foo4() { @@ -40,7 +40,7 @@ function foo4() { */ return 42; ->42 : number +>42 : 42 } diff --git a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types index d90e93d84c5..cca2ff86469 100644 --- a/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types +++ b/tests/baselines/reference/doNotEmitDetachedCommentsAtStartOfLambdaFunction.types @@ -5,7 +5,7 @@ // Single line comment return 0; ->0 : number +>0 : 0 } () => { @@ -16,7 +16,7 @@ */ return 0; ->0 : number +>0 : 0 } () => { @@ -26,7 +26,7 @@ return 0; ->0 : number +>0 : 0 } () => { @@ -38,6 +38,6 @@ return 0; ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types index 3426c70dfb9..e76d9e6b8e1 100644 --- a/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types +++ b/tests/baselines/reference/doNotEmitPinnedCommentNotOnTopOfFile.types @@ -1,7 +1,7 @@ === tests/cases/compiler/doNotEmitPinnedCommentNotOnTopOfFile.ts === var x = 10; >x : number ->10 : number +>10 : 10 /*! @@ -11,5 +11,5 @@ var x = 10; var x = 10; >x : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types index 49fb8e378ba..491ccdbd0d0 100644 --- a/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types +++ b/tests/baselines/reference/doNotEmitPinnedCommentOnNotEmittedNode.types @@ -17,7 +17,7 @@ class C { var x = 10; >x : number ->10 : number +>10 : 10 /*! remove pinned comment anywhere else */ declare var OData: any; diff --git a/tests/baselines/reference/doNotEmitPinnedDetachedComments.types b/tests/baselines/reference/doNotEmitPinnedDetachedComments.types index d9e78e2f980..f953b81a713 100644 --- a/tests/baselines/reference/doNotEmitPinnedDetachedComments.types +++ b/tests/baselines/reference/doNotEmitPinnedDetachedComments.types @@ -1,7 +1,7 @@ === tests/cases/compiler/doNotEmitPinnedDetachedComments.ts === var x = 10; >x : number ->10 : number +>10 : 10 /*! Single Line comment */ @@ -33,7 +33,7 @@ function foo() { /*! Remove this */ return 0; ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/doNotWidenAtObjectLiteralPropertyAssignment.types b/tests/baselines/reference/doNotWidenAtObjectLiteralPropertyAssignment.types index f151b5841c0..d61bd343c64 100644 --- a/tests/baselines/reference/doNotWidenAtObjectLiteralPropertyAssignment.types +++ b/tests/baselines/reference/doNotWidenAtObjectLiteralPropertyAssignment.types @@ -26,7 +26,7 @@ var test: IIntervalTreeNode[] = [{ interval: { begin: 0 }, children: null }]; // >interval : { begin: number; } >{ begin: 0 } : { begin: number; } >begin : number ->0 : number +>0 : 0 >children : null >null : null diff --git a/tests/baselines/reference/doNotemitTripleSlashComments.types b/tests/baselines/reference/doNotemitTripleSlashComments.types index edebe5687f6..8bad6e601de 100644 --- a/tests/baselines/reference/doNotemitTripleSlashComments.types +++ b/tests/baselines/reference/doNotemitTripleSlashComments.types @@ -17,12 +17,12 @@ function bar() { } /// var x = 10; >x : number ->10 : number +>10 : 10 /// var y = "hello"; >y : string ->"hello" : string +>"hello" : "hello" /// @@ -39,5 +39,5 @@ function foo() { } var z = "world"; >z : string ->"world" : string +>"world" : "world" diff --git a/tests/baselines/reference/doWhileBreakStatements.types b/tests/baselines/reference/doWhileBreakStatements.types index f143cb17d08..bc5102dc330 100644 --- a/tests/baselines/reference/doWhileBreakStatements.types +++ b/tests/baselines/reference/doWhileBreakStatements.types @@ -3,7 +3,7 @@ do { break; } while(true) ->true : boolean +>true : true ONE: >ONE : any @@ -13,7 +13,7 @@ do { >ONE : any } while (true) ->true : boolean +>true : true TWO: >TWO : any @@ -26,7 +26,7 @@ do { >THREE : any }while (true) ->true : boolean +>true : true FOUR: >FOUR : any @@ -40,10 +40,10 @@ do { >FOUR : any }while (true) ->true : boolean +>true : true }while (true) ->true : boolean +>true : true do { SIX: @@ -51,19 +51,19 @@ do { do break SIX; while(true) >SIX : any ->true : boolean +>true : true }while (true) ->true : boolean +>true : true SEVEN: >SEVEN : any do do do break SEVEN; while (true) while (true) while (true) >SEVEN : any ->true : boolean ->true : boolean ->true : boolean +>true : true +>true : true +>true : true EIGHT: >EIGHT : any @@ -77,5 +77,5 @@ do{ >EIGHT : any }while(true) ->true : boolean +>true : true diff --git a/tests/baselines/reference/doWhileContinueStatements.types b/tests/baselines/reference/doWhileContinueStatements.types index e4d3191d040..66ff052a3cd 100644 --- a/tests/baselines/reference/doWhileContinueStatements.types +++ b/tests/baselines/reference/doWhileContinueStatements.types @@ -3,7 +3,7 @@ do { continue; } while(true) ->true : boolean +>true : true ONE: >ONE : any @@ -13,7 +13,7 @@ do { >ONE : any } while (true) ->true : boolean +>true : true TWO: >TWO : any @@ -26,7 +26,7 @@ do { >THREE : any }while (true) ->true : boolean +>true : true FOUR: >FOUR : any @@ -40,10 +40,10 @@ do { >FOUR : any }while (true) ->true : boolean +>true : true }while (true) ->true : boolean +>true : true do { SIX: @@ -51,19 +51,19 @@ do { do continue SIX; while(true) >SIX : any ->true : boolean +>true : true }while (true) ->true : boolean +>true : true SEVEN: >SEVEN : any do do do continue SEVEN; while (true) while (true) while (true) >SEVEN : any ->true : boolean ->true : boolean ->true : boolean +>true : true +>true : true +>true : true EIGHT: >EIGHT : any @@ -77,5 +77,5 @@ do{ >EIGHT : any }while(true) ->true : boolean +>true : true diff --git a/tests/baselines/reference/doWhileLoop.types b/tests/baselines/reference/doWhileLoop.types index 9d1767b45aa..24d24ae4dca 100644 --- a/tests/baselines/reference/doWhileLoop.types +++ b/tests/baselines/reference/doWhileLoop.types @@ -1,6 +1,6 @@ === tests/cases/compiler/doWhileLoop.ts === do { } while (false); ->false : boolean +>false : false var n; >n : any diff --git a/tests/baselines/reference/dottedModuleName2.types b/tests/baselines/reference/dottedModuleName2.types index 869bbfb4cfc..6e58412481d 100644 --- a/tests/baselines/reference/dottedModuleName2.types +++ b/tests/baselines/reference/dottedModuleName2.types @@ -5,7 +5,7 @@ module A.B { export var x = 1; >x : number ->1 : number +>1 : 1 } @@ -17,7 +17,7 @@ module AA { export module B { export var x = 1; >x : number ->1 : number +>1 : 1 } } @@ -49,7 +49,7 @@ module A.B.C export var x = 1; >x : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/dottedSymbolResolution1.types b/tests/baselines/reference/dottedSymbolResolution1.types index cf5a5e3ba9d..3cc8e0db513 100644 --- a/tests/baselines/reference/dottedSymbolResolution1.types +++ b/tests/baselines/reference/dottedSymbolResolution1.types @@ -68,7 +68,7 @@ function _setBarAndText(): void { >x.find : (selector: string) => JQuery >x : JQuery >find : (selector: string) => JQuery ->" " : string +>" " : " " >function () { var $this: JQuery = $(''), thisBar = $this.find(".fx-usagebars-calloutbar-this"); // bug lead to 'could not find dotted symbol' here } : () => void var $this: JQuery = $(''), @@ -76,7 +76,7 @@ function _setBarAndText(): void { >JQuery : JQuery >$('') : JQuery >$ : JQueryStatic ->'' : string +>'' : "" thisBar = $this.find(".fx-usagebars-calloutbar-this"); // bug lead to 'could not find dotted symbol' here >thisBar : JQuery @@ -84,7 +84,7 @@ function _setBarAndText(): void { >$this.find : (selector: string) => JQuery >$this : JQuery >find : (selector: string) => JQuery ->".fx-usagebars-calloutbar-this" : string +>".fx-usagebars-calloutbar-this" : ".fx-usagebars-calloutbar-this" } ); } diff --git a/tests/baselines/reference/downlevelLetConst10.types b/tests/baselines/reference/downlevelLetConst10.types index 3d700b0694d..e94ed7e1178 100644 --- a/tests/baselines/reference/downlevelLetConst10.types +++ b/tests/baselines/reference/downlevelLetConst10.types @@ -1,5 +1,5 @@ === tests/cases/compiler/downlevelLetConst10.ts === let a: number = 1 >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/downlevelLetConst13.types b/tests/baselines/reference/downlevelLetConst13.types index 0453d3a6ad3..92bb3226f94 100644 --- a/tests/baselines/reference/downlevelLetConst13.types +++ b/tests/baselines/reference/downlevelLetConst13.types @@ -1,74 +1,74 @@ === tests/cases/compiler/downlevelLetConst13.ts === 'use strict' ->'use strict' : string +>'use strict' : "use strict" // exported let\const bindings should not be renamed export let foo = 10; >foo : number ->10 : number +>10 : 10 export const bar = "123" ->bar : string ->"123" : string +>bar : "123" +>"123" : "123" export let [bar1] = [1]; >bar1 : number >[1] : [number] ->1 : number +>1 : 1 export const [bar2] = [2]; >bar2 : number >[2] : [number] ->2 : number +>2 : 2 export let {a: bar3} = { a: 1 }; >a : any >bar3 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 export const {a: bar4} = { a: 1 }; >a : any >bar4 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 export module M { >M : typeof M export let baz = 100; >baz : number ->100 : number +>100 : 100 export const baz2 = true; ->baz2 : boolean ->true : boolean +>baz2 : true +>true : true export let [bar5] = [1]; >bar5 : number >[1] : [number] ->1 : number +>1 : 1 export const [bar6] = [2]; >bar6 : number >[2] : [number] ->2 : number +>2 : 2 export let {a: bar7} = { a: 1 }; >a : any >bar7 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 export const {a: bar8} = { a: 1 }; >a : any >bar8 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/downlevelLetConst14.types b/tests/baselines/reference/downlevelLetConst14.types index ea6aadfe2a8..29c87e76cce 100644 --- a/tests/baselines/reference/downlevelLetConst14.types +++ b/tests/baselines/reference/downlevelLetConst14.types @@ -1,6 +1,6 @@ === tests/cases/compiler/downlevelLetConst14.ts === 'use strict' ->'use strict' : string +>'use strict' : "use strict" declare function use(a: any); >use : (a: any) => any @@ -8,7 +8,7 @@ declare function use(a: any); var x = 10; >x : number ->10 : number +>10 : 10 var z0, z1, z2, z3; >z0 : any @@ -18,7 +18,7 @@ var z0, z1, z2, z3; { let x = 20; >x : number ->20 : number +>20 : 20 use(x); >use(x) : any @@ -28,7 +28,7 @@ var z0, z1, z2, z3; let [z0] = [1]; >z0 : number >[1] : [number] ->1 : number +>1 : 1 use(z0); >use(z0) : any @@ -38,7 +38,7 @@ var z0, z1, z2, z3; let [z1] = [1] >z1 : number >[1] : [number] ->1 : number +>1 : 1 use(z1); >use(z1) : any @@ -50,7 +50,7 @@ var z0, z1, z2, z3; >z2 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 use(z2); >use(z2) : any @@ -62,7 +62,7 @@ var z0, z1, z2, z3; >z3 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 use(z3); >use(z3) : any @@ -99,27 +99,27 @@ var z6; var y = true; >y : boolean ->true : boolean +>true : true { let y = ""; >y : string ->"" : string +>"" : "" let [z6] = [true] >z6 : boolean >[true] : [boolean] ->true : boolean +>true : true { let y = 1; >y : number ->1 : number +>1 : 1 let {a: z6} = {a: 1} >a : any >z6 : number >{a: 1} : { a: number; } >a : number ->1 : number +>1 : 1 use(y); >use(y) : any @@ -144,7 +144,7 @@ var y = true; use(y); >use(y) : any >use : (a: any) => any ->y : boolean +>y : true use(z6); >use(z6) : any @@ -153,31 +153,31 @@ use(z6); var z = false; >z : boolean ->false : boolean +>false : false var z5 = 1; >z5 : number ->1 : number +>1 : 1 { let z = ""; >z : string ->"" : string +>"" : "" let [z5] = [5]; >z5 : number >[5] : [number] ->5 : number +>5 : 5 { let _z = 1; >_z : number ->1 : number +>1 : 1 let {a: _z5} = { a: 1 }; >a : any >_z5 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 // try to step on generated name use(_z); @@ -193,5 +193,5 @@ var z5 = 1; use(y); >use(y) : any >use : (a: any) => any ->y : boolean +>y : true diff --git a/tests/baselines/reference/downlevelLetConst15.types b/tests/baselines/reference/downlevelLetConst15.types index 72b29e3fe66..9e58c648821 100644 --- a/tests/baselines/reference/downlevelLetConst15.types +++ b/tests/baselines/reference/downlevelLetConst15.types @@ -1,6 +1,6 @@ === tests/cases/compiler/downlevelLetConst15.ts === 'use strict' ->'use strict' : string +>'use strict' : "use strict" declare function use(a: any); >use : (a: any) => any @@ -8,7 +8,7 @@ declare function use(a: any); var x = 10; >x : number ->10 : number +>10 : 10 var z0, z1, z2, z3; >z0 : any @@ -17,18 +17,18 @@ var z0, z1, z2, z3; >z3 : any { const x = 20; ->x : number ->20 : number +>x : 20 +>20 : 20 use(x); >use(x) : any >use : (a: any) => any ->x : number +>x : 20 const [z0] = [1]; >z0 : number >[1] : [number] ->1 : number +>1 : 1 use(z0); >use(z0) : any @@ -41,7 +41,7 @@ var z0, z1, z2, z3; >[{a: 1}] : [{ a: number; }] >{a: 1} : { a: number; } >a : number ->1 : number +>1 : 1 use(z1); >use(z1) : any @@ -53,7 +53,7 @@ var z0, z1, z2, z3; >z2 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 use(z2); >use(z2) : any @@ -68,7 +68,7 @@ var z0, z1, z2, z3; >a : { b: number; } >{b: 1} : { b: number; } >b : number ->1 : number +>1 : 1 use(z3); >use(z3) : any @@ -105,32 +105,32 @@ var z6; var y = true; >y : boolean ->true : boolean +>true : true { const y = ""; ->y : string ->"" : string +>y : "" +>"" : "" const [z6] = [true] >z6 : boolean >[true] : [boolean] ->true : boolean +>true : true { const y = 1; ->y : number ->1 : number +>y : 1 +>1 : 1 const {a: z6} = { a: 1 } >a : any >z6 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 use(y); >use(y) : any >use : (a: any) => any ->y : number +>y : 1 use(z6); >use(z6) : any @@ -140,7 +140,7 @@ var y = true; use(y); >use(y) : any >use : (a: any) => any ->y : string +>y : "" use(z6); >use(z6) : any @@ -150,7 +150,7 @@ var y = true; use(y); >use(y) : any >use : (a: any) => any ->y : boolean +>y : true use(z6); >use(z6) : any @@ -159,45 +159,45 @@ use(z6); var z = false; >z : boolean ->false : boolean +>false : false var z5 = 1; >z5 : number ->1 : number +>1 : 1 { const z = ""; ->z : string ->"" : string +>z : "" +>"" : "" const [z5] = [5]; >z5 : number >[5] : [number] ->5 : number +>5 : 5 { const _z = 1; ->_z : number ->1 : number +>_z : 1 +>1 : 1 const {a: _z5} = { a: 1 }; >a : any >_z5 : number >{ a: 1 } : { a: number; } >a : number ->1 : number +>1 : 1 // try to step on generated name use(_z); >use(_z) : any >use : (a: any) => any ->_z : number +>_z : 1 } use(z); >use(z) : any >use : (a: any) => any ->z : string +>z : "" } use(y); >use(y) : any >use : (a: any) => any ->y : boolean +>y : true diff --git a/tests/baselines/reference/downlevelLetConst17.types b/tests/baselines/reference/downlevelLetConst17.types index 4f539835ada..56e9356556e 100644 --- a/tests/baselines/reference/downlevelLetConst17.types +++ b/tests/baselines/reference/downlevelLetConst17.types @@ -1,6 +1,6 @@ === tests/cases/compiler/downlevelLetConst17.ts === 'use strict' ->'use strict' : string +>'use strict' : "use strict" declare function use(a: any); >use : (a: any) => any @@ -11,7 +11,7 @@ var x; for (let x = 10; ;) { >x : number ->10 : number +>10 : 10 use(x); >use(x) : any @@ -24,19 +24,19 @@ use(x); >x : any for (const x = 10; ;) { ->x : number ->10 : number +>x : 10 +>10 : 10 use(x); >use(x) : any >use : (a: any) => any ->x : number +>x : 10 } for (; ;) { let x = 10; >x : number ->10 : number +>10 : 10 use(x); >use(x) : any @@ -44,20 +44,20 @@ for (; ;) { >x : number x = 1; ->x = 1 : number +>x = 1 : 1 >x : number ->1 : number +>1 : 1 } for (; ;) { const x = 10; ->x : number ->10 : number +>x : 10 +>10 : 10 use(x); >use(x) : any >use : (a: any) => any ->x : number +>x : 10 } for (let x; ;) { @@ -69,9 +69,9 @@ for (let x; ;) { >x : any x = 1; ->x = 1 : number +>x = 1 : 1 >x : any ->1 : number +>1 : 1 } for (; ;) { @@ -84,13 +84,13 @@ for (; ;) { >x : any x = 1; ->x = 1 : number +>x = 1 : 1 >x : any ->1 : number +>1 : 1 } while (true) { ->true : boolean +>true : true let x; >x : any @@ -102,16 +102,16 @@ while (true) { } while (true) { ->true : boolean +>true : true const x = true; ->x : boolean ->true : boolean +>x : true +>true : true use(x); >use(x) : any >use : (a: any) => any ->x : boolean +>x : true } do { @@ -124,7 +124,7 @@ do { >x : any } while (true); ->true : boolean +>true : true do { let x; @@ -136,7 +136,7 @@ do { >x : any } while (true); ->true : boolean +>true : true for (let x in []) { >x : string diff --git a/tests/baselines/reference/downlevelLetConst3.types b/tests/baselines/reference/downlevelLetConst3.types index cf8def45e3c..7be4e55849d 100644 --- a/tests/baselines/reference/downlevelLetConst3.types +++ b/tests/baselines/reference/downlevelLetConst3.types @@ -1,5 +1,5 @@ === tests/cases/compiler/downlevelLetConst3.ts === const a = 1 ->a : number ->1 : number +>a : 1 +>1 : 1 diff --git a/tests/baselines/reference/downlevelLetConst5.types b/tests/baselines/reference/downlevelLetConst5.types index 2cdf6ff53cc..ebb36072415 100644 --- a/tests/baselines/reference/downlevelLetConst5.types +++ b/tests/baselines/reference/downlevelLetConst5.types @@ -1,5 +1,5 @@ === tests/cases/compiler/downlevelLetConst5.ts === const a: number = 1 >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/downlevelLetConst8.types b/tests/baselines/reference/downlevelLetConst8.types index c941d673503..01acafd1785 100644 --- a/tests/baselines/reference/downlevelLetConst8.types +++ b/tests/baselines/reference/downlevelLetConst8.types @@ -1,5 +1,5 @@ === tests/cases/compiler/downlevelLetConst8.ts === let a = 1 >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/duplicateAnonymousInners1.types b/tests/baselines/reference/duplicateAnonymousInners1.types index 6840e5a14f6..01c2f7984cc 100644 --- a/tests/baselines/reference/duplicateAnonymousInners1.types +++ b/tests/baselines/reference/duplicateAnonymousInners1.types @@ -14,7 +14,7 @@ module Foo { export var Outer=0; >Outer : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/duplicateLabel3.types b/tests/baselines/reference/duplicateLabel3.types index 920a077aa9e..56af6f24088 100644 --- a/tests/baselines/reference/duplicateLabel3.types +++ b/tests/baselines/reference/duplicateLabel3.types @@ -4,7 +4,7 @@ target: >target : any while (true) { ->true : boolean +>true : true function f() { >f : () => void @@ -13,7 +13,7 @@ while (true) { >target : any while (true) { ->true : boolean +>true : true } } } diff --git a/tests/baselines/reference/duplicateLabel4.types b/tests/baselines/reference/duplicateLabel4.types index a10a06fe7a2..2f5890ae9a4 100644 --- a/tests/baselines/reference/duplicateLabel4.types +++ b/tests/baselines/reference/duplicateLabel4.types @@ -4,12 +4,12 @@ target: >target : any while (true) { ->true : boolean +>true : true } target: >target : any while (true) { ->true : boolean +>true : true } diff --git a/tests/baselines/reference/duplicateLocalVariable1.errors.txt b/tests/baselines/reference/duplicateLocalVariable1.errors.txt index b264574ea09..87bcc71cdfc 100644 --- a/tests/baselines/reference/duplicateLocalVariable1.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable1.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/duplicateLocalVariable1.ts(2,4): error TS1005: ';' expected tests/cases/compiler/duplicateLocalVariable1.ts(2,11): error TS1146: Declaration expected. tests/cases/compiler/duplicateLocalVariable1.ts(2,13): error TS2304: Cannot find name 'commonjs'. tests/cases/compiler/duplicateLocalVariable1.ts(187,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. -tests/cases/compiler/duplicateLocalVariable1.ts(187,29): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. +tests/cases/compiler/duplicateLocalVariable1.ts(187,29): error TS2365: Operator '<' cannot be applied to types 'string' and '14'. tests/cases/compiler/duplicateLocalVariable1.ts(187,37): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -203,7 +203,7 @@ tests/cases/compiler/duplicateLocalVariable1.ts(187,37): error TS2356: An arithm ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. ~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. +!!! error TS2365: Operator '<' cannot be applied to types 'string' and '14'. ~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. bytes.push(fb.readByte()); diff --git a/tests/baselines/reference/duplicateLocalVariable2.errors.txt b/tests/baselines/reference/duplicateLocalVariable2.errors.txt index 5e89cc422cc..466e145d28d 100644 --- a/tests/baselines/reference/duplicateLocalVariable2.errors.txt +++ b/tests/baselines/reference/duplicateLocalVariable2.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/duplicateLocalVariable2.ts(27,22): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. -tests/cases/compiler/duplicateLocalVariable2.ts(27,29): error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. +tests/cases/compiler/duplicateLocalVariable2.ts(27,29): error TS2365: Operator '<' cannot be applied to types 'string' and '14'. tests/cases/compiler/duplicateLocalVariable2.ts(27,37): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. @@ -34,7 +34,7 @@ tests/cases/compiler/duplicateLocalVariable2.ts(27,37): error TS2356: An arithme ~ !!! error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type 'string', but here has type 'number'. ~~~~~~ -!!! error TS2365: Operator '<' cannot be applied to types 'string' and 'number'. +!!! error TS2365: Operator '<' cannot be applied to types 'string' and '14'. ~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. bytes.push(fb.readByte()); diff --git a/tests/baselines/reference/duplicateVariablesByScope.types b/tests/baselines/reference/duplicateVariablesByScope.types index 30e68d921ca..4eec3a2054f 100644 --- a/tests/baselines/reference/duplicateVariablesByScope.types +++ b/tests/baselines/reference/duplicateVariablesByScope.types @@ -7,20 +7,20 @@ module M { for (var j = 0; j < 10; j++) { >j : number ->0 : number +>0 : 0 >j < 10 : boolean >j : number ->10 : number +>10 : 10 >j++ : number >j : number } for (var j = 0; j < 10; j++) { >j : number ->0 : number +>0 : 0 >j < 10 : boolean >j : number ->10 : number +>10 : 10 >j++ : number >j : number } @@ -31,23 +31,23 @@ function foo() { var x = 2; >x : number ->2 : number +>2 : 2 var x = 1; >x : number ->1 : number +>1 : 1 if (true) { ->true : boolean +>true : true var result = 1; >result : number ->1 : number +>1 : 1 } else { var result = 2; >result : number ->2 : number +>2 : 2 } } @@ -60,14 +60,14 @@ class C { try { var x = 1; >x : number ->1 : number +>1 : 1 } catch (e) { >e : any var x = 2; >x : number ->2 : number +>2 : 2 } } } diff --git a/tests/baselines/reference/dynamicModuleTypecheckError.types b/tests/baselines/reference/dynamicModuleTypecheckError.types index e50107f328b..d2dbc1a71d9 100644 --- a/tests/baselines/reference/dynamicModuleTypecheckError.types +++ b/tests/baselines/reference/dynamicModuleTypecheckError.types @@ -1,14 +1,14 @@ === tests/cases/compiler/dynamicModuleTypecheckError.ts === export var x = 1; >x : number ->1 : number +>1 : 1 for(var i = 0; i < 30; i++) { >i : number ->0 : number +>0 : 0 >i < 30 : boolean >i : number ->30 : number +>30 : 30 >i++ : number >i : number @@ -17,7 +17,7 @@ for(var i = 0; i < 30; i++) { >x : number >i * 1000 : number >i : number ->1000 : number +>1000 : 1000 } diff --git a/tests/baselines/reference/dynamicRequire.types b/tests/baselines/reference/dynamicRequire.types index 43eea88a05b..9b7a6c359d5 100644 --- a/tests/baselines/reference/dynamicRequire.types +++ b/tests/baselines/reference/dynamicRequire.types @@ -9,6 +9,6 @@ function foo(name) { >require("t/" + name) : any >require : any >"t/" + name : string ->"t/" : string +>"t/" : "t/" >name : any } diff --git a/tests/baselines/reference/elidingImportNames.types b/tests/baselines/reference/elidingImportNames.types index 947cd38f6d4..8dd6b315137 100644 --- a/tests/baselines/reference/elidingImportNames.types +++ b/tests/baselines/reference/elidingImportNames.types @@ -22,10 +22,10 @@ var b2 = a2; === tests/cases/compiler/elidingImportNames_main.ts === export var main = 10; >main : number ->10 : number +>10 : 10 === tests/cases/compiler/elidingImportNames_main1.ts === export var main = 10; >main : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/emitArrowFunction.types b/tests/baselines/reference/emitArrowFunction.types index a4671ea5a31..aa0627632c8 100644 --- a/tests/baselines/reference/emitArrowFunction.types +++ b/tests/baselines/reference/emitArrowFunction.types @@ -22,7 +22,7 @@ var f4 = (x: string, y: number, z = 10) => { } >x : string >y : number >z : number ->10 : number +>10 : 10 function foo(func: () => boolean) { } >foo : (func: () => boolean) => void diff --git a/tests/baselines/reference/emitArrowFunctionES6.types b/tests/baselines/reference/emitArrowFunctionES6.types index 2cadcf2cac9..c434e4b285a 100644 --- a/tests/baselines/reference/emitArrowFunctionES6.types +++ b/tests/baselines/reference/emitArrowFunctionES6.types @@ -22,7 +22,7 @@ var f4 = (x: string, y: number, z=10) => { } >x : string >y : number >z : number ->10 : number +>10 : 10 function foo(func: () => boolean) { } >foo : (func: () => boolean) => void @@ -67,7 +67,7 @@ var p5 = ([a = 1]) => { }; >p5 : ([a]: [number]) => void >([a = 1]) => { } : ([a]: [number]) => void >a : number ->1 : number +>1 : 1 var p6 = ({ a }) => { }; >p6 : ({a}: { a: any; }) => void @@ -84,17 +84,17 @@ var p8 = ({ a = 1 }) => { }; >p8 : ({a}: { a?: number; }) => void >({ a = 1 }) => { } : ({a}: { a?: number; }) => void >a : number ->1 : number +>1 : 1 var p9 = ({ a: { b = 1 } = { b: 1 } }) => { }; >p9 : ({a: {b}}: { a?: { b?: number; }; }) => void >({ a: { b = 1 } = { b: 1 } }) => { } : ({a: {b}}: { a?: { b?: number; }; }) => void >a : any >b : number ->1 : number +>1 : 1 >{ b: 1 } : { b?: number; } >b : number ->1 : number +>1 : 1 var p10 = ([{ value, done }]) => { }; >p10 : ([{value, done}]: [{ value: any; done: any; }]) => void diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturing.types b/tests/baselines/reference/emitArrowFunctionThisCapturing.types index 81dc5d83f0d..0ef27791d17 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturing.types +++ b/tests/baselines/reference/emitArrowFunctionThisCapturing.types @@ -4,11 +4,11 @@ var f1 = () => { >() => { this.age = 10} : () => void this.age = 10 ->this.age = 10 : number +>this.age = 10 : 10 >this.age : any >this : any >age : any ->10 : number +>10 : 10 }; @@ -35,11 +35,11 @@ foo(() => { >() => { this.age = 100; return true;} : () => true this.age = 100; ->this.age = 100 : number +>this.age = 100 : 100 >this.age : any >this : any >age : any ->100 : number +>100 : 100 return true; >true : true diff --git a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types index a16b6391f02..3c20bfd195c 100644 --- a/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types +++ b/tests/baselines/reference/emitArrowFunctionThisCapturingES6.types @@ -4,11 +4,11 @@ var f1 = () => { >() => { this.age = 10} : () => void this.age = 10 ->this.age = 10 : number +>this.age = 10 : 10 >this.age : any >this : any >age : any ->10 : number +>10 : 10 }; @@ -35,11 +35,11 @@ foo(() => { >() => { this.age = 100; return true;} : () => true this.age = 100; ->this.age = 100 : number +>this.age = 100 : 100 >this.age : any >this : any >age : any ->100 : number +>100 : 100 return true; >true : true diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments01_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments01_ES6.types index 669bf411e63..6da6a224a6c 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments01_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments01_ES6.types @@ -7,7 +7,7 @@ var a = () => { >arg : any >arguments[0] : any >arguments : IArguments ->0 : number +>0 : 0 } var b = function () { @@ -22,7 +22,7 @@ var b = function () { >arg : any >arguments[0] : any >arguments : IArguments ->0 : number +>0 : 0 } } @@ -36,7 +36,7 @@ function baz() { >arg : any >arguments[0] : any >arguments : IArguments ->0 : number +>0 : 0 } } @@ -53,7 +53,7 @@ foo(() => { >arg : any >arguments[0] : any >arguments : IArguments ->0 : number +>0 : 0 }); @@ -64,7 +64,7 @@ function bar() { >arg : any >arguments[0] : any >arguments : IArguments ->0 : number +>0 : 0 } @@ -78,6 +78,6 @@ function bar() { >arg : any >arguments[0] : any >arguments : IArguments ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments10_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments10_ES6.types index dd567d3bdca..cca81995253 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments10_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments10_ES6.types @@ -5,7 +5,7 @@ function f() { var _arguments = 10; >_arguments : number ->10 : number +>10 : 10 var a = () => () => arguments; >a : () => () => IArguments diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments11_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments11_ES6.types index b977a77010c..5dddd8fba7a 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments11_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments11_ES6.types @@ -6,7 +6,7 @@ function f(arguments) { var _arguments = 10; >_arguments : number ->10 : number +>10 : 10 var a = () => () => arguments; >a : () => () => IArguments diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments13.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments13.types index 6e5a7555315..82a027d2dc8 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments13.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments13.types @@ -5,7 +5,7 @@ function f() { var _arguments = 10; >_arguments : number ->10 : number +>10 : 10 var a = (arguments) => () => _arguments; >a : (arguments: any) => () => number diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments13_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments13_ES6.types index 294f5c692e4..59b39a444e1 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments13_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments13_ES6.types @@ -5,7 +5,7 @@ function f() { var _arguments = 10; >_arguments : number ->10 : number +>10 : 10 var a = (arguments) => () => _arguments; >a : (arguments: any) => () => number diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.types index 29989ea0f9c..df47ed17890 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments14_ES6.types @@ -11,7 +11,7 @@ function f() { let arguments = 100; >arguments : number ->100 : number +>100 : 100 return () => arguments; >() => arguments : () => IArguments diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.types index 0bb34b22eef..558aada2826 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments15_ES6.types @@ -5,7 +5,7 @@ function f() { var arguments = "hello"; >arguments : string ->"hello" : string +>"hello" : "hello" if (Math.random()) { >Math.random() : number @@ -14,8 +14,8 @@ function f() { >random : () => number const arguments = 100; ->arguments : number ->100 : number +>arguments : 100 +>100 : 100 return () => arguments; >() => arguments : () => IArguments diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.types index 41c6b87fb42..bedbe3dc8b6 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments16_ES6.types @@ -5,7 +5,7 @@ function f() { var arguments = "hello"; >arguments : string ->"hello" : string +>"hello" : "hello" if (Math.random()) { >Math.random() : number @@ -17,9 +17,9 @@ function f() { >() => arguments[0] : () => any >arguments[0] : any >arguments : IArguments ->0 : number +>0 : 0 } var arguments = "world"; >arguments : string ->"world" : string +>"world" : "world" } diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.types index f62a2dce84c..223663bdb1b 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments17_ES6.types @@ -7,7 +7,7 @@ function f() { >arguments : string >{ arguments: "hello" } : { arguments: string; } >arguments : string ->"hello" : string +>"hello" : "hello" if (Math.random()) { >Math.random() : number @@ -19,9 +19,9 @@ function f() { >() => arguments[0] : () => any >arguments[0] : any >arguments : IArguments ->0 : number +>0 : 0 } var arguments = "world"; >arguments : string ->"world" : string +>"world" : "world" } diff --git a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments19_ES6.types b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments19_ES6.types index a672389720a..48d6f2e2935 100644 --- a/tests/baselines/reference/emitArrowFunctionWhenUsingArguments19_ES6.types +++ b/tests/baselines/reference/emitArrowFunctionWhenUsingArguments19_ES6.types @@ -8,7 +8,7 @@ function f() { var _arguments = 10; // No capture in 'g', so no conflict. >_arguments : number ->10 : number +>10 : 10 function h() { >h : () => void @@ -30,6 +30,6 @@ function f() { >x : any return 100; ->100 : number +>100 : 100 } } diff --git a/tests/baselines/reference/emitClassDeclarationOverloadInES6.types b/tests/baselines/reference/emitClassDeclarationOverloadInES6.types index 94cc2c88ddc..1b5397eaf63 100644 --- a/tests/baselines/reference/emitClassDeclarationOverloadInES6.types +++ b/tests/baselines/reference/emitClassDeclarationOverloadInES6.types @@ -19,5 +19,5 @@ class D { constructor(x: number, z="hello") {} >x : number >z : string ->"hello" : string +>"hello" : "hello" } diff --git a/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types index 3bdf5af2ba5..f244efc274d 100644 --- a/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types @@ -24,7 +24,7 @@ class B { x: string = "hello"; >x : string ->"hello" : string +>"hello" : "hello" _bar: string; >_bar : string @@ -32,15 +32,15 @@ class B { constructor(x: number, z = "hello", ...args) { >x : number >z : string ->"hello" : string +>"hello" : "hello" >args : any[] this.y = 10; ->this.y = 10 : number +>this.y = 10 : 10 >this.y : number >this : this >y : number ->10 : number +>10 : 10 } baz(...args): string; >baz : (...args: any[]) => string diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types index 7267af2fde0..7c95ac9b40e 100644 --- a/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types @@ -6,7 +6,7 @@ class B { >baz : (a: string, y?: number) => void >a : string >y : number ->10 : number +>10 : 10 } class C extends B { >C : C @@ -57,8 +57,8 @@ class D extends C { >super.baz : (a: string, y: number) => void >super : C >baz : (a: string, y: number) => void ->"hello" : string ->10 : number +>"hello" : "hello" +>10 : 10 } } diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types index e4f7d6c00b4..f251429937d 100644 --- a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types @@ -17,33 +17,33 @@ class C { >name2 : string return "BYE"; ->"BYE" : string +>"BYE" : "BYE" } static get ["computedname"]() { ->"computedname" : string +>"computedname" : "computedname" return ""; ->"" : string +>"" : "" } get ["computedname1"]() { ->"computedname1" : string +>"computedname1" : "computedname1" return ""; ->"" : string +>"" : "" } get ["computedname2"]() { ->"computedname2" : string +>"computedname2" : "computedname2" return ""; ->"" : string +>"" : "" } set ["computedname3"](x: any) { ->"computedname3" : string +>"computedname3" : "computedname3" >x : any } set ["computedname4"](y: string) { ->"computedname4" : string +>"computedname4" : "computedname4" >y : string } @@ -56,6 +56,6 @@ class C { >b : number static set ["computedname"](b: string) { } ->"computedname" : string +>"computedname" : "computedname" >b : string } diff --git a/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types index d4bc18539dd..203d5071a15 100644 --- a/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types @@ -3,16 +3,16 @@ class B { >B : B "hello" = 10; ->10 : number +>10 : 10 0b110 = "world"; ->"world" : string +>"world" : "world" 0o23534 = "WORLD"; ->"WORLD" : string +>"WORLD" : "WORLD" 20 = "twenty"; ->"twenty" : string +>"twenty" : "twenty" "foo"() { } 0b1110() {} @@ -21,14 +21,14 @@ class B { >interface : () => void static "hi" = 10000; ->10000 : number +>10000 : 10000 static 22 = "twenty-two"; ->"twenty-two" : string +>"twenty-two" : "twenty-two" static 0b101 = "binary"; ->"binary" : string +>"binary" : "binary" static 0o3235 = "octal"; ->"octal" : string +>"octal" : "octal" } diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types index a42c019cd40..10f0d4d2eef 100644 --- a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types @@ -9,16 +9,16 @@ class D { >foo : () => void ["computedName1"]() { } ->"computedName1" : string +>"computedName1" : "computedName1" ["computedName2"](a: string) { } ->"computedName2" : string +>"computedName2" : "computedName2" >a : string ["computedName3"](a: string): number { return 1; } ->"computedName3" : string +>"computedName3" : "computedName3" >a : string ->1 : number +>1 : 1 bar(): string { >bar : () => string @@ -34,17 +34,17 @@ class D { >x : string return "HELLO"; ->"HELLO" : string +>"HELLO" : "HELLO" } static ["computedname4"]() { } ->"computedname4" : string +>"computedname4" : "computedname4" static ["computedname5"](a: string) { } ->"computedname5" : string +>"computedname5" : "computedname5" >a : string static ["computedname6"](a: string): boolean { return true; } ->"computedname6" : string +>"computedname6" : "computedname6" >a : string >true : true @@ -54,8 +54,8 @@ class D { var x = 1 + 2; >x : number >1 + 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 return x >x : number @@ -67,5 +67,5 @@ class D { static bar(a: string): number { return 1; } >bar : (a: string) => number >a : string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types index 79899e77bee..3455e3e5c5d 100644 --- a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types @@ -4,7 +4,7 @@ class C { x: string = "Hello world"; >x : string ->"Hello world" : string +>"Hello world" : "Hello world" } class D { @@ -12,18 +12,18 @@ class D { x: string = "Hello world"; >x : string ->"Hello world" : string +>"Hello world" : "Hello world" y: number; >y : number constructor() { this.y = 10; ->this.y = 10 : number +>this.y = 10 : 10 >this.y : number >this : this >y : number ->10 : number +>10 : 10 } } @@ -53,10 +53,10 @@ class F extends D{ >super : typeof D this.j = "HI"; ->this.j = "HI" : string +>this.j = "HI" : "HI" >this.j : string >this : this >j : string ->"HI" : string +>"HI" : "HI" } } diff --git a/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types index 58d328e3e5d..cd287119909 100644 --- a/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types @@ -4,7 +4,7 @@ class C { static z: string = "Foo"; >z : string ->"Foo" : string +>"Foo" : "Foo" } class D { @@ -12,10 +12,10 @@ class D { x = 20000; >x : number ->20000 : number +>20000 : 20000 static b = true; >b : boolean ->true : boolean +>true : true } diff --git a/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types index 7c0159fbd63..bdf57efcb0f 100644 --- a/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types +++ b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types @@ -4,15 +4,15 @@ class B { x = 10; >x : number ->10 : number +>10 : 10 constructor() { this.x = 10; ->this.x = 10 : number +>this.x = 10 : 10 >this.x : number >this : this >x : number ->10 : number +>10 : 10 } static log(a: number) { } >log : (a: number) => void diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS1.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS1.types index 393499a931f..ddb10cc9447 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS1.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS1.types @@ -3,13 +3,13 @@ var array0 = [1, 2, 3] >array0 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var i0 = 0; >i0 : number ->0 : number +>0 : 0 array0[++i0] **= 2; >array0[++i0] **= 2 : number @@ -17,18 +17,18 @@ array0[++i0] **= 2; >array0 : number[] >++i0 : number >i0 : number ->2 : number +>2 : 2 var array1 = [1, 2, 3] >array1 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var i1 = 0; >i1 : number ->0 : number +>0 : 0 array1[++i1] **= array1[++i1] **= 2; >array1[++i1] **= array1[++i1] **= 2 : number @@ -41,18 +41,18 @@ array1[++i1] **= array1[++i1] **= 2; >array1 : number[] >++i1 : number >i1 : number ->2 : number +>2 : 2 var array2 = [1, 2, 3] >array2 : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 var i2 = 0; >i2 : number ->0 : number +>0 : 0 array2[++i2] **= array2[++i2] ** 2; >array2[++i2] **= array2[++i2] ** 2 : number @@ -65,20 +65,20 @@ array2[++i2] **= array2[++i2] ** 2; >array2 : number[] >++i2 : number >i2 : number ->2 : number +>2 : 2 var array3 = [2, 2, 3]; >array3 : number[] >[2, 2, 3] : number[] ->2 : number ->2 : number ->3 : number +>2 : 2 +>2 : 2 +>3 : 3 var j0 = 0, j1 = 1; >j0 : number ->0 : number +>0 : 0 >j1 : number ->1 : number +>1 : 1 array3[j0++] **= array3[j1++] **= array3[j0++] **= 1; >array3[j0++] **= array3[j1++] **= array3[j0++] **= 1 : number @@ -96,5 +96,5 @@ array3[j0++] **= array3[j1++] **= array3[j0++] **= 1; >array3 : number[] >j0++ : number >j0 : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.types index c47f539baf2..cd057d31390 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es7/exponentiationOperator/emitCompoundExponentiationAssignmentWithIndexingOnLHS2.ts === var globalCounter = 0; >globalCounter : number ->0 : number +>0 : 0 function foo() { >foo : () => { 0: number; } @@ -9,22 +9,22 @@ function foo() { globalCounter += 1; >globalCounter += 1 : number >globalCounter : number ->1 : number +>1 : 1 return { 0: 2 }; >{ 0: 2 } : { 0: number; } ->2 : number +>2 : 2 } foo()[0] **= foo()[0]; >foo()[0] **= foo()[0] : number >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number +>0 : 0 >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number +>0 : 0 var result_foo1 = foo()[0] **= foo()[0]; >result_foo1 : number @@ -32,24 +32,24 @@ var result_foo1 = foo()[0] **= foo()[0]; >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number +>0 : 0 >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number +>0 : 0 foo()[0] **= foo()[0] **= 2; >foo()[0] **= foo()[0] **= 2 : number >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number +>0 : 0 >foo()[0] **= 2 : number >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number ->2 : number +>0 : 0 +>2 : 2 var result_foo2 = foo()[0] **= foo()[0] **= 2; >result_foo2 : number @@ -57,26 +57,26 @@ var result_foo2 = foo()[0] **= foo()[0] **= 2; >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number +>0 : 0 >foo()[0] **= 2 : number >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number ->2 : number +>0 : 0 +>2 : 2 foo()[0] **= foo()[0] ** 2; >foo()[0] **= foo()[0] ** 2 : number >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number +>0 : 0 >foo()[0] ** 2 : number >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number ->2 : number +>0 : 0 +>2 : 2 var result_foo3 = foo()[0] **= foo()[0] ** 2; >result_foo3 : number @@ -84,11 +84,11 @@ var result_foo3 = foo()[0] **= foo()[0] ** 2; >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number +>0 : 0 >foo()[0] ** 2 : number >foo()[0] : number >foo() : { 0: number; } >foo : () => { 0: number; } ->0 : number ->2 : number +>0 : 0 +>2 : 2 diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types index 1877f391207..94a5f2173aa 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS3.types @@ -6,7 +6,7 @@ var object = { _0: 2, >_0 : number ->2 : number +>2 : 2 get 0() { return this._0; @@ -31,30 +31,30 @@ object[0] **= object[0]; >object[0] **= object[0] : number >object[0] : number >object : { 0: number; _0: number; } ->0 : number +>0 : 0 >object[0] : number >object : { 0: number; _0: number; } ->0 : number +>0 : 0 object[0] **= object[0] **= 2; >object[0] **= object[0] **= 2 : number >object[0] : number >object : { 0: number; _0: number; } ->0 : number +>0 : 0 >object[0] **= 2 : number >object[0] : number >object : { 0: number; _0: number; } ->0 : number ->2 : number +>0 : 0 +>2 : 2 object[0] **= object[0] ** 2; >object[0] **= object[0] ** 2 : number >object[0] : number >object : { 0: number; _0: number; } ->0 : number +>0 : 0 >object[0] ** 2 : number >object[0] : number >object : { 0: number; _0: number; } ->0 : number ->2 : number +>0 : 0 +>2 : 2 diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS4.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS4.types index abfc69d7ca6..fec095dc696 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS4.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithIndexingOnLHS4.types @@ -2,7 +2,7 @@ var globalCounter = 0; >globalCounter : number ->0 : number +>0 : 0 function incrementIdx(max: number) { >incrementIdx : (max: number) => number @@ -11,7 +11,7 @@ function incrementIdx(max: number) { globalCounter += 1; >globalCounter += 1 : number >globalCounter : number ->1 : number +>1 : 1 let idx = Math.floor(Math.random() * max); >idx : number @@ -33,11 +33,11 @@ function incrementIdx(max: number) { var array1 = [1, 2, 3, 4, 5]; >array1 : number[] >[1, 2, 3, 4, 5] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 array1[incrementIdx(array1.length)] **= 3; >array1[incrementIdx(array1.length)] **= 3 : number @@ -48,7 +48,7 @@ array1[incrementIdx(array1.length)] **= 3; >array1.length : number >array1 : number[] >length : number ->3 : number +>3 : 3 array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] **= 2; >array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] **= 2 : number @@ -67,7 +67,7 @@ array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] **= >array1.length : number >array1 : number[] >length : number ->2 : number +>2 : 2 array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] ** 2; >array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] ** 2 : number @@ -86,5 +86,5 @@ array1[incrementIdx(array1.length)] **= array1[incrementIdx(array1.length)] ** 2 >array1.length : number >array1 : number[] >length : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.types b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.types index b57878e9443..1a8a29bae9b 100644 --- a/tests/baselines/reference/emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.types +++ b/tests/baselines/reference/emitCompoundExponentiationAssignmentWithPropertyAccessingOnLHS1.types @@ -2,7 +2,7 @@ var globalCounter = 0; >globalCounter : number ->0 : number +>0 : 0 function foo() { >foo : () => { prop: number; } @@ -10,12 +10,12 @@ function foo() { globalCounter += 1; >globalCounter += 1 : number >globalCounter : number ->1 : number +>1 : 1 return { prop: 2 }; >{ prop: 2 } : { prop: number; } >prop : number ->2 : number +>2 : 2 } foo().prop **= 2; >foo().prop **= 2 : number @@ -23,7 +23,7 @@ foo().prop **= 2; >foo() : { prop: number; } >foo : () => { prop: number; } >prop : number ->2 : number +>2 : 2 var result0 = foo().prop **= 2; >result0 : number @@ -32,7 +32,7 @@ var result0 = foo().prop **= 2; >foo() : { prop: number; } >foo : () => { prop: number; } >prop : number ->2 : number +>2 : 2 foo().prop **= foo().prop **= 2; >foo().prop **= foo().prop **= 2 : number @@ -45,7 +45,7 @@ foo().prop **= foo().prop **= 2; >foo() : { prop: number; } >foo : () => { prop: number; } >prop : number ->2 : number +>2 : 2 var result1 = foo().prop **= foo().prop **= 2; >result1 : number @@ -59,7 +59,7 @@ var result1 = foo().prop **= foo().prop **= 2; >foo() : { prop: number; } >foo : () => { prop: number; } >prop : number ->2 : number +>2 : 2 foo().prop **= foo().prop ** 2; >foo().prop **= foo().prop ** 2 : number @@ -72,7 +72,7 @@ foo().prop **= foo().prop ** 2; >foo() : { prop: number; } >foo : () => { prop: number; } >prop : number ->2 : number +>2 : 2 var result2 = foo().prop **= foo().prop ** 2; >result2 : number @@ -86,5 +86,5 @@ var result2 = foo().prop **= foo().prop ** 2; >foo() : { prop: number; } >foo : () => { prop: number; } >prop : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/emitCompoundExponentiationOperator1.types b/tests/baselines/reference/emitCompoundExponentiationOperator1.types index a1c986dbb78..6a4a5b5bab9 100644 --- a/tests/baselines/reference/emitCompoundExponentiationOperator1.types +++ b/tests/baselines/reference/emitCompoundExponentiationOperator1.types @@ -6,7 +6,7 @@ var comp: number; comp **= 1; >comp **= 1 : number >comp : number ->1 : number +>1 : 1 comp **= comp ** comp; >comp **= comp ** comp : number @@ -22,7 +22,7 @@ comp **= comp ** comp ** 2; >comp : number >comp ** 2 : number >comp : number ->2 : number +>2 : 2 comp **= comp ** comp + 2; >comp **= comp ** comp + 2 : number @@ -31,7 +31,7 @@ comp **= comp ** comp + 2; >comp ** comp : number >comp : number >comp : number ->2 : number +>2 : 2 comp **= comp ** comp - 2; >comp **= comp ** comp - 2 : number @@ -40,7 +40,7 @@ comp **= comp ** comp - 2; >comp ** comp : number >comp : number >comp : number ->2 : number +>2 : 2 comp **= comp ** comp * 2; >comp **= comp ** comp * 2 : number @@ -49,7 +49,7 @@ comp **= comp ** comp * 2; >comp ** comp : number >comp : number >comp : number ->2 : number +>2 : 2 comp **= comp ** comp / 2; >comp **= comp ** comp / 2 : number @@ -58,7 +58,7 @@ comp **= comp ** comp / 2; >comp ** comp : number >comp : number >comp : number ->2 : number +>2 : 2 comp **= comp ** comp % 2; >comp **= comp ** comp % 2 : number @@ -67,7 +67,7 @@ comp **= comp ** comp % 2; >comp ** comp : number >comp : number >comp : number ->2 : number +>2 : 2 comp **= (comp - 2) ** 5; >comp **= (comp - 2) ** 5 : number @@ -76,8 +76,8 @@ comp **= (comp - 2) ** 5; >(comp - 2) : number >comp - 2 : number >comp : number ->2 : number ->5 : number +>2 : 2 +>5 : 5 comp **= (comp + 2) ** 5; >comp **= (comp + 2) ** 5 : number @@ -86,8 +86,8 @@ comp **= (comp + 2) ** 5; >(comp + 2) : number >comp + 2 : number >comp : number ->2 : number ->5 : number +>2 : 2 +>5 : 5 comp **= (comp * 2) ** 5; >comp **= (comp * 2) ** 5 : number @@ -96,8 +96,8 @@ comp **= (comp * 2) ** 5; >(comp * 2) : number >comp * 2 : number >comp : number ->2 : number ->5 : number +>2 : 2 +>5 : 5 comp **= (comp / 2) ** 5; >comp **= (comp / 2) ** 5 : number @@ -106,8 +106,8 @@ comp **= (comp / 2) ** 5; >(comp / 2) : number >comp / 2 : number >comp : number ->2 : number ->5 : number +>2 : 2 +>5 : 5 comp **= (comp % 2) ** 5; >comp **= (comp % 2) ** 5 : number @@ -116,8 +116,8 @@ comp **= (comp % 2) ** 5; >(comp % 2) : number >comp % 2 : number >comp : number ->2 : number ->5 : number +>2 : 2 +>5 : 5 comp **= comp ** (5 + 2); >comp **= comp ** (5 + 2) : number @@ -126,8 +126,8 @@ comp **= comp ** (5 + 2); >comp : number >(5 + 2) : number >5 + 2 : number ->5 : number ->2 : number +>5 : 5 +>2 : 2 comp **= comp ** (5 - 2); >comp **= comp ** (5 - 2) : number @@ -136,8 +136,8 @@ comp **= comp ** (5 - 2); >comp : number >(5 - 2) : number >5 - 2 : number ->5 : number ->2 : number +>5 : 5 +>2 : 2 comp **= comp ** (5 * 2); >comp **= comp ** (5 * 2) : number @@ -146,8 +146,8 @@ comp **= comp ** (5 * 2); >comp : number >(5 * 2) : number >5 * 2 : number ->5 : number ->2 : number +>5 : 5 +>2 : 2 comp **= comp ** (5 / 2); >comp **= comp ** (5 / 2) : number @@ -156,8 +156,8 @@ comp **= comp ** (5 / 2); >comp : number >(5 / 2) : number >5 / 2 : number ->5 : number ->2 : number +>5 : 5 +>2 : 2 comp **= comp ** (5 % 2); >comp **= comp ** (5 % 2) : number @@ -166,6 +166,6 @@ comp **= comp ** (5 % 2); >comp : number >(5 % 2) : number >5 % 2 : number ->5 : number ->2 : number +>5 : 5 +>2 : 2 diff --git a/tests/baselines/reference/emitCompoundExponentiationOperator2.types b/tests/baselines/reference/emitCompoundExponentiationOperator2.types index 03ca9b06626..f715a9593f2 100644 --- a/tests/baselines/reference/emitCompoundExponentiationOperator2.types +++ b/tests/baselines/reference/emitCompoundExponentiationOperator2.types @@ -6,14 +6,14 @@ var comp: number; comp **= 1; >comp **= 1 : number >comp : number ->1 : number +>1 : 1 comp **= comp **= 1; >comp **= comp **= 1 : number >comp : number >comp **= 1 : number >comp : number ->1 : number +>1 : 1 comp **= comp **= 1 + 2; >comp **= comp **= 1 + 2 : number @@ -21,8 +21,8 @@ comp **= comp **= 1 + 2; >comp **= 1 + 2 : number >comp : number >1 + 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 comp **= comp **= 1 - 2; >comp **= comp **= 1 - 2 : number @@ -30,8 +30,8 @@ comp **= comp **= 1 - 2; >comp **= 1 - 2 : number >comp : number >1 - 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 comp **= comp **= 1 * 2; >comp **= comp **= 1 * 2 : number @@ -39,8 +39,8 @@ comp **= comp **= 1 * 2; >comp **= 1 * 2 : number >comp : number >1 * 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 comp **= comp **= 1 / 2; >comp **= comp **= 1 / 2 : number @@ -48,8 +48,8 @@ comp **= comp **= 1 / 2; >comp **= 1 / 2 : number >comp : number >1 / 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 comp **= comp **= (1 + 2); >comp **= comp **= (1 + 2) : number @@ -58,8 +58,8 @@ comp **= comp **= (1 + 2); >comp : number >(1 + 2) : number >1 + 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 comp **= comp **= (1 - 2); >comp **= comp **= (1 - 2) : number @@ -68,8 +68,8 @@ comp **= comp **= (1 - 2); >comp : number >(1 - 2) : number >1 - 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 comp **= comp **= (1 * 2); >comp **= comp **= (1 * 2) : number @@ -78,8 +78,8 @@ comp **= comp **= (1 * 2); >comp : number >(1 * 2) : number >1 * 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 comp **= comp **= (1 / 2); >comp **= comp **= (1 / 2) : number @@ -88,8 +88,8 @@ comp **= comp **= (1 / 2); >comp : number >(1 / 2) : number >1 / 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 comp **= comp **= 1 + 2 ** 3; >comp **= comp **= 1 + 2 ** 3 : number @@ -97,10 +97,10 @@ comp **= comp **= 1 + 2 ** 3; >comp **= 1 + 2 ** 3 : number >comp : number >1 + 2 ** 3 : number ->1 : number +>1 : 1 >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 comp **= comp **= 1 - 2 ** 4; >comp **= comp **= 1 - 2 ** 4 : number @@ -108,10 +108,10 @@ comp **= comp **= 1 - 2 ** 4; >comp **= 1 - 2 ** 4 : number >comp : number >1 - 2 ** 4 : number ->1 : number +>1 : 1 >2 ** 4 : number ->2 : number ->4 : number +>2 : 2 +>4 : 4 comp **= comp **= 1 * 2 ** 5; >comp **= comp **= 1 * 2 ** 5 : number @@ -119,10 +119,10 @@ comp **= comp **= 1 * 2 ** 5; >comp **= 1 * 2 ** 5 : number >comp : number >1 * 2 ** 5 : number ->1 : number +>1 : 1 >2 ** 5 : number ->2 : number ->5 : number +>2 : 2 +>5 : 5 comp **= comp **= 1 / 2 ** 6; >comp **= comp **= 1 / 2 ** 6 : number @@ -130,10 +130,10 @@ comp **= comp **= 1 / 2 ** 6; >comp **= 1 / 2 ** 6 : number >comp : number >1 / 2 ** 6 : number ->1 : number +>1 : 1 >2 ** 6 : number ->2 : number ->6 : number +>2 : 2 +>6 : 6 comp **= comp **= (1 + 2) ** 3; >comp **= comp **= (1 + 2) ** 3 : number @@ -143,9 +143,9 @@ comp **= comp **= (1 + 2) ** 3; >(1 + 2) ** 3 : number >(1 + 2) : number >1 + 2 : number ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 comp **= comp **= (1 - 2) ** 4; >comp **= comp **= (1 - 2) ** 4 : number @@ -155,9 +155,9 @@ comp **= comp **= (1 - 2) ** 4; >(1 - 2) ** 4 : number >(1 - 2) : number >1 - 2 : number ->1 : number ->2 : number ->4 : number +>1 : 1 +>2 : 2 +>4 : 4 comp **= comp **= (1 * 2) ** 5; >comp **= comp **= (1 * 2) ** 5 : number @@ -167,9 +167,9 @@ comp **= comp **= (1 * 2) ** 5; >(1 * 2) ** 5 : number >(1 * 2) : number >1 * 2 : number ->1 : number ->2 : number ->5 : number +>1 : 1 +>2 : 2 +>5 : 5 comp **= comp **= (1 / 2) ** 6; >comp **= comp **= (1 / 2) ** 6 : number @@ -179,7 +179,7 @@ comp **= comp **= (1 / 2) ** 6; >(1 / 2) ** 6 : number >(1 / 2) : number >1 / 2 : number ->1 : number ->2 : number ->6 : number +>1 : 1 +>2 : 2 +>6 : 6 diff --git a/tests/baselines/reference/emitDefaultParametersFunction.types b/tests/baselines/reference/emitDefaultParametersFunction.types index 5c27d3ddf3d..d043a6c2b2f 100644 --- a/tests/baselines/reference/emitDefaultParametersFunction.types +++ b/tests/baselines/reference/emitDefaultParametersFunction.types @@ -3,23 +3,23 @@ function foo(x: string, y = 10) { } >foo : (x: string, y?: number) => void >x : string >y : number ->10 : number +>10 : 10 function baz(x: string, y = 5, ...rest) { } >baz : (x: string, y?: number, ...rest: any[]) => void >x : string >y : number ->5 : number +>5 : 5 >rest : any[] function bar(y = 10) { } >bar : (y?: number) => void >y : number ->10 : number +>10 : 10 function bar1(y = 10, ...rest) { } >bar1 : (y?: number, ...rest: any[]) => void >y : number ->10 : number +>10 : 10 >rest : any[] diff --git a/tests/baselines/reference/emitDefaultParametersFunctionES6.types b/tests/baselines/reference/emitDefaultParametersFunctionES6.types index e3124c75333..c5a3b8d2d3f 100644 --- a/tests/baselines/reference/emitDefaultParametersFunctionES6.types +++ b/tests/baselines/reference/emitDefaultParametersFunctionES6.types @@ -3,23 +3,23 @@ function foo(x: string, y = 10) { } >foo : (x: string, y?: number) => void >x : string >y : number ->10 : number +>10 : 10 function baz(x: string, y = 5, ...rest) { } >baz : (x: string, y?: number, ...rest: any[]) => void >x : string >y : number ->5 : number +>5 : 5 >rest : any[] function bar(y = 10) { } >bar : (y?: number) => void >y : number ->10 : number +>10 : 10 function bar1(y = 10, ...rest) { } >bar1 : (y?: number, ...rest: any[]) => void >y : number ->10 : number +>10 : 10 >rest : any[] diff --git a/tests/baselines/reference/emitDefaultParametersFunctionExpression.types b/tests/baselines/reference/emitDefaultParametersFunctionExpression.types index 61ba3200e36..7546bda0d41 100644 --- a/tests/baselines/reference/emitDefaultParametersFunctionExpression.types +++ b/tests/baselines/reference/emitDefaultParametersFunctionExpression.types @@ -3,35 +3,35 @@ var lambda1 = (y = "hello") => { } >lambda1 : (y?: string) => void >(y = "hello") => { } : (y?: string) => void >y : string ->"hello" : string +>"hello" : "hello" var lambda2 = (x: number, y = "hello") => { } >lambda2 : (x: number, y?: string) => void >(x: number, y = "hello") => { } : (x: number, y?: string) => void >x : number >y : string ->"hello" : string +>"hello" : "hello" var lambda3 = (x: number, y = "hello", ...rest) => { } >lambda3 : (x: number, y?: string, ...rest: any[]) => void >(x: number, y = "hello", ...rest) => { } : (x: number, y?: string, ...rest: any[]) => void >x : number >y : string ->"hello" : string +>"hello" : "hello" >rest : any[] var lambda4 = (y = "hello", ...rest) => { } >lambda4 : (y?: string, ...rest: any[]) => void >(y = "hello", ...rest) => { } : (y?: string, ...rest: any[]) => void >y : string ->"hello" : string +>"hello" : "hello" >rest : any[] var x = function (str = "hello", ...rest) { } >x : (str?: string, ...rest: any[]) => void >function (str = "hello", ...rest) { } : (str?: string, ...rest: any[]) => void >str : string ->"hello" : string +>"hello" : "hello" >rest : any[] var y = (function (num = 10, boo = false, ...rest) { })() @@ -40,9 +40,9 @@ var y = (function (num = 10, boo = false, ...rest) { })() >(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void >function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void >num : number ->10 : number +>10 : 10 >boo : boolean ->false : boolean +>false : false >rest : any[] var z = (function (num: number, boo = false, ...rest) { })(10) @@ -52,7 +52,7 @@ var z = (function (num: number, boo = false, ...rest) { })(10) >function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void >num : number >boo : boolean ->false : boolean +>false : false >rest : any[] ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types b/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types index 76f2c863a26..99ab6a48137 100644 --- a/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types +++ b/tests/baselines/reference/emitDefaultParametersFunctionExpressionES6.types @@ -3,35 +3,35 @@ var lambda1 = (y = "hello") => { } >lambda1 : (y?: string) => void >(y = "hello") => { } : (y?: string) => void >y : string ->"hello" : string +>"hello" : "hello" var lambda2 = (x: number, y = "hello") => { } >lambda2 : (x: number, y?: string) => void >(x: number, y = "hello") => { } : (x: number, y?: string) => void >x : number >y : string ->"hello" : string +>"hello" : "hello" var lambda3 = (x: number, y = "hello", ...rest) => { } >lambda3 : (x: number, y?: string, ...rest: any[]) => void >(x: number, y = "hello", ...rest) => { } : (x: number, y?: string, ...rest: any[]) => void >x : number >y : string ->"hello" : string +>"hello" : "hello" >rest : any[] var lambda4 = (y = "hello", ...rest) => { } >lambda4 : (y?: string, ...rest: any[]) => void >(y = "hello", ...rest) => { } : (y?: string, ...rest: any[]) => void >y : string ->"hello" : string +>"hello" : "hello" >rest : any[] var x = function (str = "hello", ...rest) { } >x : (str?: string, ...rest: any[]) => void >function (str = "hello", ...rest) { } : (str?: string, ...rest: any[]) => void >str : string ->"hello" : string +>"hello" : "hello" >rest : any[] var y = (function (num = 10, boo = false, ...rest) { })() @@ -40,9 +40,9 @@ var y = (function (num = 10, boo = false, ...rest) { })() >(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void >function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void >num : number ->10 : number +>10 : 10 >boo : boolean ->false : boolean +>false : false >rest : any[] var z = (function (num: number, boo = false, ...rest) { })(10) @@ -52,7 +52,7 @@ var z = (function (num: number, boo = false, ...rest) { })(10) >function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void >num : number >boo : boolean ->false : boolean +>false : false >rest : any[] ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/emitDefaultParametersFunctionProperty.types b/tests/baselines/reference/emitDefaultParametersFunctionProperty.types index 8a703fd114f..d26281d8eb6 100644 --- a/tests/baselines/reference/emitDefaultParametersFunctionProperty.types +++ b/tests/baselines/reference/emitDefaultParametersFunctionProperty.types @@ -6,27 +6,27 @@ var obj2 = { func1(y = 10, ...rest) { }, >func1 : (y?: number, ...rest: any[]) => void >y : number ->10 : number +>10 : 10 >rest : any[] func2(x = "hello") { }, >func2 : (x?: string) => void >x : string ->"hello" : string +>"hello" : "hello" func3(x: string, z: number, y = "hello") { }, >func3 : (x: string, z: number, y?: string) => void >x : string >z : number >y : string ->"hello" : string +>"hello" : "hello" func4(x: string, z: number, y = "hello", ...rest) { }, >func4 : (x: string, z: number, y?: string, ...rest: any[]) => void >x : string >z : number >y : string ->"hello" : string +>"hello" : "hello" >rest : any[] } diff --git a/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.types b/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.types index 1edd505c0b5..5f693b65ac5 100644 --- a/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.types +++ b/tests/baselines/reference/emitDefaultParametersFunctionPropertyES6.types @@ -6,26 +6,26 @@ var obj2 = { func1(y = 10, ...rest) { }, >func1 : (y?: number, ...rest: any[]) => void >y : number ->10 : number +>10 : 10 >rest : any[] func2(x = "hello") { }, >func2 : (x?: string) => void >x : string ->"hello" : string +>"hello" : "hello" func3(x: string, z: number, y = "hello") { }, >func3 : (x: string, z: number, y?: string) => void >x : string >z : number >y : string ->"hello" : string +>"hello" : "hello" func4(x: string, z: number, y = "hello", ...rest) { }, >func4 : (x: string, z: number, y?: string, ...rest: any[]) => void >x : string >z : number >y : string ->"hello" : string +>"hello" : "hello" >rest : any[] } diff --git a/tests/baselines/reference/emitDefaultParametersMethod.types b/tests/baselines/reference/emitDefaultParametersMethod.types index ce7dd2542fa..03193baa528 100644 --- a/tests/baselines/reference/emitDefaultParametersMethod.types +++ b/tests/baselines/reference/emitDefaultParametersMethod.types @@ -7,30 +7,30 @@ class C { >z : string >x : number >y : string ->"hello" : string +>"hello" : "hello" public foo(x: string, t = false) { } >foo : (x: string, t?: boolean) => void >x : string >t : boolean ->false : boolean +>false : false public foo1(x: string, t = false, ...rest) { } >foo1 : (x: string, t?: boolean, ...rest: any[]) => void >x : string >t : boolean ->false : boolean +>false : false >rest : any[] public bar(t = false) { } >bar : (t?: boolean) => void >t : boolean ->false : boolean +>false : false public boo(t = false, ...rest) { } >boo : (t?: boolean, ...rest: any[]) => void >t : boolean ->false : boolean +>false : false >rest : any[] } @@ -39,7 +39,7 @@ class D { constructor(y = "hello") { } >y : string ->"hello" : string +>"hello" : "hello" } class E { @@ -47,7 +47,7 @@ class E { constructor(y = "hello", ...rest) { } >y : string ->"hello" : string +>"hello" : "hello" >rest : any[] } diff --git a/tests/baselines/reference/emitDefaultParametersMethodES6.types b/tests/baselines/reference/emitDefaultParametersMethodES6.types index 09096d153bf..be54cd9b27c 100644 --- a/tests/baselines/reference/emitDefaultParametersMethodES6.types +++ b/tests/baselines/reference/emitDefaultParametersMethodES6.types @@ -7,30 +7,30 @@ class C { >z : string >x : number >y : string ->"hello" : string +>"hello" : "hello" public foo(x: string, t = false) { } >foo : (x: string, t?: boolean) => void >x : string >t : boolean ->false : boolean +>false : false public foo1(x: string, t = false, ...rest) { } >foo1 : (x: string, t?: boolean, ...rest: any[]) => void >x : string >t : boolean ->false : boolean +>false : false >rest : any[] public bar(t = false) { } >bar : (t?: boolean) => void >t : boolean ->false : boolean +>false : false public boo(t = false, ...rest) { } >boo : (t?: boolean, ...rest: any[]) => void >t : boolean ->false : boolean +>false : false >rest : any[] } @@ -39,7 +39,7 @@ class D { constructor(y = "hello") { } >y : string ->"hello" : string +>"hello" : "hello" } class E { @@ -47,6 +47,6 @@ class E { constructor(y = "hello", ...rest) { } >y : string ->"hello" : string +>"hello" : "hello" >rest : any[] } diff --git a/tests/baselines/reference/emitExponentiationOperator1.types b/tests/baselines/reference/emitExponentiationOperator1.types index a2dc4f16901..9db01d34f22 100644 --- a/tests/baselines/reference/emitExponentiationOperator1.types +++ b/tests/baselines/reference/emitExponentiationOperator1.types @@ -2,45 +2,45 @@ 1 ** -2; >1 ** -2 : number ->1 : number ->-2 : number ->2 : number +>1 : 1 +>-2 : -2 +>2 : 2 1 ** 2; >1 ** 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 (-1) ** 2 >(-1) ** 2 : number ->(-1) : number ->-1 : number ->1 : number ->2 : number +>(-1) : -1 +>-1 : -1 +>1 : 1 +>2 : 2 1 ** 2 ** 3; >1 ** 2 ** 3 : number ->1 : number +>1 : 1 >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 1 ** 2 ** -3; >1 ** 2 ** -3 : number ->1 : number +>1 : 1 >2 ** -3 : number ->2 : number ->-3 : number ->3 : number +>2 : 2 +>-3 : -3 +>3 : 3 1 ** -(2 ** 3); >1 ** -(2 ** 3) : number ->1 : number +>1 : 1 >-(2 ** 3) : number >(2 ** 3) : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 (-(1 ** 2)) ** 3; >(-(1 ** 2)) ** 3 : number @@ -48,9 +48,9 @@ >-(1 ** 2) : number >(1 ** 2) : number >1 ** 2 : number ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 (-(1 ** 2)) ** -3; >(-(1 ** 2)) ** -3 : number @@ -58,150 +58,150 @@ >-(1 ** 2) : number >(1 ** 2) : number >1 ** 2 : number ->1 : number ->2 : number ->-3 : number ->3 : number +>1 : 1 +>2 : 2 +>-3 : -3 +>3 : 3 1 ** 2 + 3; >1 ** 2 + 3 : number >1 ** 2 : number ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 1 ** 2 - 3; >1 ** 2 - 3 : number >1 ** 2 : number ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 1 ** 2 * 3; >1 ** 2 * 3 : number >1 ** 2 : number ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 1 ** 2 / 3; >1 ** 2 / 3 : number >1 ** 2 : number ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 1 ** 2 % 3; >1 ** 2 % 3 : number >1 ** 2 : number ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 1 ** -2 + 3; >1 ** -2 + 3 : number >1 ** -2 : number ->1 : number ->-2 : number ->2 : number ->3 : number +>1 : 1 +>-2 : -2 +>2 : 2 +>3 : 3 1 ** -2 - 3; >1 ** -2 - 3 : number >1 ** -2 : number ->1 : number ->-2 : number ->2 : number ->3 : number +>1 : 1 +>-2 : -2 +>2 : 2 +>3 : 3 1 ** -2 * 3; >1 ** -2 * 3 : number >1 ** -2 : number ->1 : number ->-2 : number ->2 : number ->3 : number +>1 : 1 +>-2 : -2 +>2 : 2 +>3 : 3 1 ** -2 / 3; >1 ** -2 / 3 : number >1 ** -2 : number ->1 : number ->-2 : number ->2 : number ->3 : number +>1 : 1 +>-2 : -2 +>2 : 2 +>3 : 3 1 ** -2 % 3; >1 ** -2 % 3 : number >1 ** -2 : number ->1 : number ->-2 : number ->2 : number ->3 : number +>1 : 1 +>-2 : -2 +>2 : 2 +>3 : 3 2 + 3 ** 3; >2 + 3 ** 3 : number ->2 : number +>2 : 2 >3 ** 3 : number ->3 : number ->3 : number +>3 : 3 +>3 : 3 2 - 3 ** 3; >2 - 3 ** 3 : number ->2 : number +>2 : 2 >3 ** 3 : number ->3 : number ->3 : number +>3 : 3 +>3 : 3 2 * 3 ** 3; >2 * 3 ** 3 : number ->2 : number +>2 : 2 >3 ** 3 : number ->3 : number ->3 : number +>3 : 3 +>3 : 3 2 / 3 ** 3; >2 / 3 ** 3 : number ->2 : number +>2 : 2 >3 ** 3 : number ->3 : number ->3 : number +>3 : 3 +>3 : 3 2 % 3 ** 3; >2 % 3 ** 3 : number ->2 : number +>2 : 2 >3 ** 3 : number ->3 : number ->3 : number +>3 : 3 +>3 : 3 (2 + 3) ** 4; >(2 + 3) ** 4 : number >(2 + 3) : number >2 + 3 : number ->2 : number ->3 : number ->4 : number +>2 : 2 +>3 : 3 +>4 : 4 (2 - 3) ** 4; >(2 - 3) ** 4 : number >(2 - 3) : number >2 - 3 : number ->2 : number ->3 : number ->4 : number +>2 : 2 +>3 : 3 +>4 : 4 (2 * 3) ** 4; >(2 * 3) ** 4 : number >(2 * 3) : number >2 * 3 : number ->2 : number ->3 : number ->4 : number +>2 : 2 +>3 : 3 +>4 : 4 (2 / 3) ** 4; >(2 / 3) ** 4 : number >(2 / 3) : number >2 / 3 : number ->2 : number ->3 : number ->4 : number +>2 : 2 +>3 : 3 +>4 : 4 diff --git a/tests/baselines/reference/emitExponentiationOperator2.types b/tests/baselines/reference/emitExponentiationOperator2.types index cd8773624a7..b2936f6acef 100644 --- a/tests/baselines/reference/emitExponentiationOperator2.types +++ b/tests/baselines/reference/emitExponentiationOperator2.types @@ -2,31 +2,31 @@ var temp = 10; >temp : number ->10 : number +>10 : 10 ++temp ** 3; >++temp ** 3 : number >++temp : number >temp : number ->3 : number +>3 : 3 --temp ** 3; >--temp ** 3 : number >--temp : number >temp : number ->3 : number +>3 : 3 temp++ ** 3; >temp++ ** 3 : number >temp++ : number >temp : number ->3 : number +>3 : 3 temp-- ** 3; >temp-- ** 3 : number >temp-- : number >temp : number ->3 : number +>3 : 3 --temp + temp ** 3; >--temp + temp ** 3 : number @@ -34,7 +34,7 @@ temp-- ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 --temp - temp ** 3; >--temp - temp ** 3 : number @@ -42,7 +42,7 @@ temp-- ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 --temp * temp ** 3; >--temp * temp ** 3 : number @@ -50,7 +50,7 @@ temp-- ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 --temp / temp ** 3; >--temp / temp ** 3 : number @@ -58,7 +58,7 @@ temp-- ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 --temp % temp ** 3; >--temp % temp ** 3 : number @@ -66,19 +66,19 @@ temp-- ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 temp-- ** 3; >temp-- ** 3 : number >temp-- : number >temp : number ->3 : number +>3 : 3 temp++ ** 3; >temp++ ** 3 : number >temp++ : number >temp : number ->3 : number +>3 : 3 temp-- ** -temp; >temp-- ** -temp : number @@ -100,7 +100,7 @@ temp-- + temp ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 temp-- - temp ** 3; >temp-- - temp ** 3 : number @@ -108,7 +108,7 @@ temp-- - temp ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 temp-- * temp ** 3; >temp-- * temp ** 3 : number @@ -116,7 +116,7 @@ temp-- * temp ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 temp-- / temp ** 3; >temp-- / temp ** 3 : number @@ -124,7 +124,7 @@ temp-- / temp ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 temp-- % temp ** 3; >temp-- % temp ** 3 : number @@ -132,213 +132,213 @@ temp-- % temp ** 3; >temp : number >temp ** 3 : number >temp : number ->3 : number +>3 : 3 --temp + 2 ** 3; >--temp + 2 ** 3 : number >--temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 --temp - 2 ** 3; >--temp - 2 ** 3 : number >--temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 --temp * 2 ** 3; >--temp * 2 ** 3 : number >--temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 --temp / 2 ** 3; >--temp / 2 ** 3 : number >--temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 --temp % 2 ** 3; >--temp % 2 ** 3 : number >--temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 ++temp + 2 ** 3; >++temp + 2 ** 3 : number >++temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 ++temp - 2 ** 3; >++temp - 2 ** 3 : number >++temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 ++temp * 2 ** 3; >++temp * 2 ** 3 : number >++temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 ++temp / 2 ** 3; >++temp / 2 ** 3 : number >++temp : number >temp : number >2 ** 3 : number ->2 : number ->3 : number +>2 : 2 +>3 : 3 3 ** ++temp; >3 ** ++temp : number ->3 : number +>3 : 3 >++temp : number >temp : number 3 ** --temp; >3 ** --temp : number ->3 : number +>3 : 3 >--temp : number >temp : number 3 ** temp++; >3 ** temp++ : number ->3 : number +>3 : 3 >temp++ : number >temp : number 3 ** temp--; >3 ** temp-- : number ->3 : number +>3 : 3 >temp-- : number >temp : number 3 ** ++temp ** 2; >3 ** ++temp ** 2 : number ->3 : number +>3 : 3 >++temp ** 2 : number >++temp : number >temp : number ->2 : number +>2 : 2 3 ** --temp ** 2; >3 ** --temp ** 2 : number ->3 : number +>3 : 3 >--temp ** 2 : number >--temp : number >temp : number ->2 : number +>2 : 2 3 ** temp++ ** 2; >3 ** temp++ ** 2 : number ->3 : number +>3 : 3 >temp++ ** 2 : number >temp++ : number >temp : number ->2 : number +>2 : 2 3 ** temp-- ** 2; >3 ** temp-- ** 2 : number ->3 : number +>3 : 3 >temp-- ** 2 : number >temp-- : number >temp : number ->2 : number +>2 : 2 3 ** ++temp + 2; >3 ** ++temp + 2 : number >3 ** ++temp : number ->3 : number +>3 : 3 >++temp : number >temp : number ->2 : number +>2 : 2 3 ** ++temp - 2; >3 ** ++temp - 2 : number >3 ** ++temp : number ->3 : number +>3 : 3 >++temp : number >temp : number ->2 : number +>2 : 2 3 ** ++temp * 2; >3 ** ++temp * 2 : number >3 ** ++temp : number ->3 : number +>3 : 3 >++temp : number >temp : number ->2 : number +>2 : 2 3 ** ++temp / 2; >3 ** ++temp / 2 : number >3 ** ++temp : number ->3 : number +>3 : 3 >++temp : number >temp : number ->2 : number +>2 : 2 3 ** ++temp % 2; >3 ** ++temp % 2 : number >3 ** ++temp : number ->3 : number +>3 : 3 >++temp : number >temp : number ->2 : number +>2 : 2 3 ** --temp + 2; >3 ** --temp + 2 : number >3 ** --temp : number ->3 : number +>3 : 3 >--temp : number >temp : number ->2 : number +>2 : 2 3 ** --temp - 2; >3 ** --temp - 2 : number >3 ** --temp : number ->3 : number +>3 : 3 >--temp : number >temp : number ->2 : number +>2 : 2 3 ** --temp * 2; >3 ** --temp * 2 : number >3 ** --temp : number ->3 : number +>3 : 3 >--temp : number >temp : number ->2 : number +>2 : 2 3 ** --temp / 2; >3 ** --temp / 2 : number >3 ** --temp : number ->3 : number +>3 : 3 >--temp : number >temp : number ->2 : number +>2 : 2 3 ** --temp % 2; >3 ** --temp % 2 : number >3 ** --temp : number ->3 : number +>3 : 3 >--temp : number >temp : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/emitExponentiationOperator3.types b/tests/baselines/reference/emitExponentiationOperator3.types index cc4c5374d05..38bb5a0895c 100644 --- a/tests/baselines/reference/emitExponentiationOperator3.types +++ b/tests/baselines/reference/emitExponentiationOperator3.types @@ -2,7 +2,7 @@ var temp = 10; >temp : number ->10 : number +>10 : 10 (-++temp) ** 3; >(-++temp) ** 3 : number @@ -10,7 +10,7 @@ var temp = 10; >-++temp : number >++temp : number >temp : number ->3 : number +>3 : 3 (+--temp) ** 3; >(+--temp) ** 3 : number @@ -18,7 +18,7 @@ var temp = 10; >+--temp : number >--temp : number >temp : number ->3 : number +>3 : 3 (-temp++) ** 3; >(-temp++) ** 3 : number @@ -26,7 +26,7 @@ var temp = 10; >-temp++ : number >temp++ : number >temp : number ->3 : number +>3 : 3 (+temp--) ** 3; >(+temp--) ** 3 : number @@ -34,7 +34,7 @@ var temp = 10; >+temp-- : number >temp-- : number >temp : number ->3 : number +>3 : 3 (-(1 ** ++temp)) ** 3; >(-(1 ** ++temp)) ** 3 : number @@ -42,10 +42,10 @@ var temp = 10; >-(1 ** ++temp) : number >(1 ** ++temp) : number >1 ** ++temp : number ->1 : number +>1 : 1 >++temp : number >temp : number ->3 : number +>3 : 3 (-(1 ** --temp)) ** 3; >(-(1 ** --temp)) ** 3 : number @@ -53,10 +53,10 @@ var temp = 10; >-(1 ** --temp) : number >(1 ** --temp) : number >1 ** --temp : number ->1 : number +>1 : 1 >--temp : number >temp : number ->3 : number +>3 : 3 (-(1 ** temp++)) ** 3; >(-(1 ** temp++)) ** 3 : number @@ -64,10 +64,10 @@ var temp = 10; >-(1 ** temp++) : number >(1 ** temp++) : number >1 ** temp++ : number ->1 : number +>1 : 1 >temp++ : number >temp : number ->3 : number +>3 : 3 (-(1 ** temp--)) ** 3; >(-(1 ** temp--)) ** 3 : number @@ -75,40 +75,40 @@ var temp = 10; >-(1 ** temp--) : number >(1 ** temp--) : number >1 ** temp-- : number ->1 : number +>1 : 1 >temp-- : number >temp : number ->3 : number +>3 : 3 (-3) ** temp++; >(-3) ** temp++ : number ->(-3) : number ->-3 : number ->3 : number +>(-3) : -3 +>-3 : -3 +>3 : 3 >temp++ : number >temp : number (-3) ** temp--; >(-3) ** temp-- : number ->(-3) : number ->-3 : number ->3 : number +>(-3) : -3 +>-3 : -3 +>3 : 3 >temp-- : number >temp : number (-3) ** ++temp; >(-3) ** ++temp : number ->(-3) : number ->-3 : number ->3 : number +>(-3) : -3 +>-3 : -3 +>3 : 3 >++temp : number >temp : number (-3) ** --temp; >(-3) ** --temp : number ->(-3) : number ->-3 : number ->3 : number +>(-3) : -3 +>-3 : -3 +>3 : 3 >--temp : number >temp : number @@ -116,7 +116,7 @@ var temp = 10; >(+3) ** temp++ : number >(+3) : number >+3 : number ->3 : number +>3 : 3 >temp++ : number >temp : number @@ -124,7 +124,7 @@ var temp = 10; >(+3) ** temp-- : number >(+3) : number >+3 : number ->3 : number +>3 : 3 >temp-- : number >temp : number @@ -132,7 +132,7 @@ var temp = 10; >(+3) ** ++temp : number >(+3) : number >+3 : number ->3 : number +>3 : 3 >++temp : number >temp : number @@ -140,175 +140,175 @@ var temp = 10; >(+3) ** --temp : number >(+3) : number >+3 : number ->3 : number +>3 : 3 >--temp : number >temp : number (-3) ** temp++ ** 2; >(-3) ** temp++ ** 2 : number ->(-3) : number ->-3 : number ->3 : number +>(-3) : -3 +>-3 : -3 +>3 : 3 >temp++ ** 2 : number >temp++ : number >temp : number ->2 : number +>2 : 2 (-3) ** temp-- ** 2; >(-3) ** temp-- ** 2 : number ->(-3) : number ->-3 : number ->3 : number +>(-3) : -3 +>-3 : -3 +>3 : 3 >temp-- ** 2 : number >temp-- : number >temp : number ->2 : number +>2 : 2 (-3) ** ++temp ** 2; >(-3) ** ++temp ** 2 : number ->(-3) : number ->-3 : number ->3 : number +>(-3) : -3 +>-3 : -3 +>3 : 3 >++temp ** 2 : number >++temp : number >temp : number ->2 : number +>2 : 2 (-3) ** --temp ** 2; >(-3) ** --temp ** 2 : number ->(-3) : number ->-3 : number ->3 : number +>(-3) : -3 +>-3 : -3 +>3 : 3 >--temp ** 2 : number >--temp : number >temp : number ->2 : number +>2 : 2 (+3) ** temp++ ** 2; >(+3) ** temp++ ** 2 : number >(+3) : number >+3 : number ->3 : number +>3 : 3 >temp++ ** 2 : number >temp++ : number >temp : number ->2 : number +>2 : 2 (+3) ** temp-- ** 2; >(+3) ** temp-- ** 2 : number >(+3) : number >+3 : number ->3 : number +>3 : 3 >temp-- ** 2 : number >temp-- : number >temp : number ->2 : number +>2 : 2 (+3) ** ++temp ** 2; >(+3) ** ++temp ** 2 : number >(+3) : number >+3 : number ->3 : number +>3 : 3 >++temp ** 2 : number >++temp : number >temp : number ->2 : number +>2 : 2 (+3) ** --temp ** 2; >(+3) ** --temp ** 2 : number >(+3) : number >+3 : number ->3 : number +>3 : 3 >--temp ** 2 : number >--temp : number >temp : number ->2 : number +>2 : 2 3 ** -temp++; >3 ** -temp++ : number ->3 : number +>3 : 3 >-temp++ : number >temp++ : number >temp : number 3 ** -temp--; >3 ** -temp-- : number ->3 : number +>3 : 3 >-temp-- : number >temp-- : number >temp : number 3 ** -++temp; >3 ** -++temp : number ->3 : number +>3 : 3 >-++temp : number >++temp : number >temp : number 3 ** +--temp; >3 ** +--temp : number ->3 : number +>3 : 3 >+--temp : number >--temp : number >temp : number 3 ** (-temp++) ** 2; >3 ** (-temp++) ** 2 : number ->3 : number +>3 : 3 >(-temp++) ** 2 : number >(-temp++) : number >-temp++ : number >temp++ : number >temp : number ->2 : number +>2 : 2 3 ** (-temp--) ** 2; >3 ** (-temp--) ** 2 : number ->3 : number +>3 : 3 >(-temp--) ** 2 : number >(-temp--) : number >-temp-- : number >temp-- : number >temp : number ->2 : number +>2 : 2 3 ** (+temp++) ** 2; >3 ** (+temp++) ** 2 : number ->3 : number +>3 : 3 >(+temp++) ** 2 : number >(+temp++) : number >+temp++ : number >temp++ : number >temp : number ->2 : number +>2 : 2 3 ** (+temp--) ** 2; >3 ** (+temp--) ** 2 : number ->3 : number +>3 : 3 >(+temp--) ** 2 : number >(+temp--) : number >+temp-- : number >temp-- : number >temp : number ->2 : number +>2 : 2 3 ** (-++temp) ** 2; >3 ** (-++temp) ** 2 : number ->3 : number +>3 : 3 >(-++temp) ** 2 : number >(-++temp) : number >-++temp : number >++temp : number >temp : number ->2 : number +>2 : 2 3 ** (+--temp) ** 2; >3 ** (+--temp) ** 2 : number ->3 : number +>3 : 3 >(+--temp) ** 2 : number >(+--temp) : number >+--temp : number >--temp : number >temp : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/emitExponentiationOperator4.types b/tests/baselines/reference/emitExponentiationOperator4.types index 36da1c32b4c..0049671228e 100644 --- a/tests/baselines/reference/emitExponentiationOperator4.types +++ b/tests/baselines/reference/emitExponentiationOperator4.types @@ -7,7 +7,7 @@ var temp: any; >(temp) : number >temp : number >temp : any ->3 : number +>3 : 3 (--temp) ** 3; >(--temp) ** 3 : number @@ -15,7 +15,7 @@ var temp: any; >--temp : number >--temp : number >temp : any ->3 : number +>3 : 3 (++temp) ** 3; >(++temp) ** 3 : number @@ -23,7 +23,7 @@ var temp: any; >++temp : number >++temp : number >temp : any ->3 : number +>3 : 3 (temp--) ** 3; >(temp--) ** 3 : number @@ -31,7 +31,7 @@ var temp: any; >temp-- : number >temp-- : number >temp : any ->3 : number +>3 : 3 (temp++) ** 3; >(temp++) ** 3 : number @@ -39,47 +39,47 @@ var temp: any; >temp++ : number >temp++ : number >temp : any ->3 : number +>3 : 3 1 ** (--temp) ** 3; >1 ** (--temp) ** 3 : number ->1 : number +>1 : 1 >(--temp) ** 3 : number >(--temp) : number >--temp : number >--temp : number >temp : any ->3 : number +>3 : 3 1 ** (++temp) ** 3; >1 ** (++temp) ** 3 : number ->1 : number +>1 : 1 >(++temp) ** 3 : number >(++temp) : number >++temp : number >++temp : number >temp : any ->3 : number +>3 : 3 1 ** (temp--) ** 3; >1 ** (temp--) ** 3 : number ->1 : number +>1 : 1 >(temp--) ** 3 : number >(temp--) : number >temp-- : number >temp-- : number >temp : any ->3 : number +>3 : 3 1 ** (temp++) ** 3; >1 ** (temp++) ** 3 : number ->1 : number +>1 : 1 >(temp++) ** 3 : number >(temp++) : number >temp++ : number >temp++ : number >temp : any ->3 : number +>3 : 3 (void --temp) ** 3; >(void --temp) ** 3 : number @@ -87,7 +87,7 @@ var temp: any; >void --temp : undefined >--temp : number >temp : any ->3 : number +>3 : 3 (void temp--) ** 3; >(void temp--) ** 3 : number @@ -95,14 +95,14 @@ var temp: any; >void temp-- : undefined >temp-- : number >temp : any ->3 : number +>3 : 3 (void 3) ** 4; >(void 3) ** 4 : number >(void 3) : undefined >void 3 : undefined ->3 : number ->4 : number +>3 : 3 +>4 : 4 (void temp++) ** 4; >(void temp++) ** 4 : number @@ -110,7 +110,7 @@ var temp: any; >void temp++ : undefined >temp++ : number >temp : any ->4 : number +>4 : 4 (void temp--) ** 4; >(void temp--) ** 4 : number @@ -118,57 +118,57 @@ var temp: any; >void temp-- : undefined >temp-- : number >temp : any ->4 : number +>4 : 4 1 ** (void --temp) ** 3; >1 ** (void --temp) ** 3 : number ->1 : number +>1 : 1 >(void --temp) ** 3 : number >(void --temp) : undefined >void --temp : undefined >--temp : number >temp : any ->3 : number +>3 : 3 1 ** (void temp--) ** 3; >1 ** (void temp--) ** 3 : number ->1 : number +>1 : 1 >(void temp--) ** 3 : number >(void temp--) : undefined >void temp-- : undefined >temp-- : number >temp : any ->3 : number +>3 : 3 1 ** (void 3) ** 4; >1 ** (void 3) ** 4 : number ->1 : number +>1 : 1 >(void 3) ** 4 : number >(void 3) : undefined >void 3 : undefined ->3 : number ->4 : number +>3 : 3 +>4 : 4 1 ** (void temp++) ** 4; >1 ** (void temp++) ** 4 : number ->1 : number +>1 : 1 >(void temp++) ** 4 : number >(void temp++) : undefined >void temp++ : undefined >temp++ : number >temp : any ->4 : number +>4 : 4 1 ** (void temp--) ** 4; >1 ** (void temp--) ** 4 : number ->1 : number +>1 : 1 >(void temp--) ** 4 : number >(void temp--) : undefined >void temp-- : undefined >temp-- : number >temp : any ->4 : number +>4 : 4 (~ --temp) ** 3; >(~ --temp) ** 3 : number @@ -176,7 +176,7 @@ var temp: any; >~ --temp : number >--temp : number >temp : any ->3 : number +>3 : 3 (~ temp--) ** 3; >(~ temp--) ** 3 : number @@ -184,14 +184,14 @@ var temp: any; >~ temp-- : number >temp-- : number >temp : any ->3 : number +>3 : 3 (~ 3) ** 4; >(~ 3) ** 4 : number >(~ 3) : number >~ 3 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 (~ temp++) ** 4; >(~ temp++) ** 4 : number @@ -199,7 +199,7 @@ var temp: any; >~ temp++ : number >temp++ : number >temp : any ->4 : number +>4 : 4 (~ temp--) ** 4; >(~ temp--) ** 4 : number @@ -207,54 +207,54 @@ var temp: any; >~ temp-- : number >temp-- : number >temp : any ->4 : number +>4 : 4 1 ** (~ --temp) ** 3; >1 ** (~ --temp) ** 3 : number ->1 : number +>1 : 1 >(~ --temp) ** 3 : number >(~ --temp) : number >~ --temp : number >--temp : number >temp : any ->3 : number +>3 : 3 1 ** (~ temp--) ** 3; >1 ** (~ temp--) ** 3 : number ->1 : number +>1 : 1 >(~ temp--) ** 3 : number >(~ temp--) : number >~ temp-- : number >temp-- : number >temp : any ->3 : number +>3 : 3 1 ** (~ 3) ** 4; >1 ** (~ 3) ** 4 : number ->1 : number +>1 : 1 >(~ 3) ** 4 : number >(~ 3) : number >~ 3 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 1 ** (~ temp++) ** 4; >1 ** (~ temp++) ** 4 : number ->1 : number +>1 : 1 >(~ temp++) ** 4 : number >(~ temp++) : number >~ temp++ : number >temp++ : number >temp : any ->4 : number +>4 : 4 1 ** (~ temp--) ** 4; >1 ** (~ temp--) ** 4 : number ->1 : number +>1 : 1 >(~ temp--) ** 4 : number >(~ temp--) : number >~ temp-- : number >temp-- : number >temp : any ->4 : number +>4 : 4 diff --git a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types index b4d1aebd4f6..7991ef224f0 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4.types @@ -2,11 +2,11 @@ var t1 = 10; >t1 : number ->10 : number +>10 : 10 var t2 = 10; >t2 : number ->10 : number +>10 : 10 var s; >s : any diff --git a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types index ed2f4b522e9..981829dd42b 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTempalteString4ES6.types @@ -2,11 +2,11 @@ var t1 = 10; >t1 : number ->10 : number +>10 : 10 var t2 = 10; >t2 : number ->10 : number +>10 : 10 var s; >s : any diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types index 02ae523c168..bbfb5b88e04 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1.types @@ -2,11 +2,11 @@ var t1 = 10; >t1 : number ->10 : number +>10 : 10 var t2 = 10; >t2 : number ->10 : number +>10 : 10 var s; >s : any @@ -65,7 +65,7 @@ var s; `${1 + typeof (t1 ** t2 ** t1) }`; >`${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string ->1 : number +>1 : 1 >typeof (t1 ** t2 ** t1) : string >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types index c2ee01ff23f..a005dd07463 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString1ES6.types @@ -2,11 +2,11 @@ var t1 = 10; >t1 : number ->10 : number +>10 : 10 var t2 = 10; >t2 : number ->10 : number +>10 : 10 var s; >s : any @@ -65,7 +65,7 @@ var s; `${1 + typeof (t1 ** t2 ** t1) }`; >`${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string ->1 : number +>1 : 1 >typeof (t1 ** t2 ** t1) : string >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types index 05816e94c6c..156851b60b9 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2.types @@ -2,11 +2,11 @@ var t1 = 10; >t1 : number ->10 : number +>10 : 10 var t2 = 10; >t2 : number ->10 : number +>10 : 10 var s; >s : any @@ -65,7 +65,7 @@ var s; `hello ${1 + typeof (t1 ** t2 ** t1) }`; >`hello ${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string ->1 : number +>1 : 1 >typeof (t1 ** t2 ** t1) : string >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types index b77e38587c2..dbeee05554e 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString2ES6.types @@ -2,11 +2,11 @@ var t1 = 10; >t1 : number ->10 : number +>10 : 10 var t2 = 10; >t2 : number ->10 : number +>10 : 10 var s; >s : any @@ -65,7 +65,7 @@ var s; `hello ${1 + typeof (t1 ** t2 ** t1) }`; >`hello ${1 + typeof (t1 ** t2 ** t1) }` : string >1 + typeof (t1 ** t2 ** t1) : string ->1 : number +>1 : 1 >typeof (t1 ** t2 ** t1) : string >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types index 88c23ee8a0b..d3472beac12 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3.types @@ -2,11 +2,11 @@ var t1 = 10; >t1 : number ->10 : number +>10 : 10 var t2 = 10; >t2 : number ->10 : number +>10 : 10 var s; >s : any @@ -65,7 +65,7 @@ var s; `${1 + typeof (t1 ** t2 ** t1) } world`; >`${1 + typeof (t1 ** t2 ** t1) } world` : string >1 + typeof (t1 ** t2 ** t1) : string ->1 : number +>1 : 1 >typeof (t1 ** t2 ** t1) : string >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number diff --git a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types index e0d59cc1319..239ef02a529 100644 --- a/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types +++ b/tests/baselines/reference/emitExponentiationOperatorInTemplateString3ES6.types @@ -2,11 +2,11 @@ var t1 = 10; >t1 : number ->10 : number +>10 : 10 var t2 = 10; >t2 : number ->10 : number +>10 : 10 var s; >s : any @@ -65,7 +65,7 @@ var s; `${1 + typeof (t1 ** t2 ** t1) } world`; >`${1 + typeof (t1 ** t2 ** t1) } world` : string >1 + typeof (t1 ** t2 ** t1) : string ->1 : number +>1 : 1 >typeof (t1 ** t2 ** t1) : string >(t1 ** t2 ** t1) : number >t1 ** t2 ** t1 : number diff --git a/tests/baselines/reference/emitMemberAccessExpression.types b/tests/baselines/reference/emitMemberAccessExpression.types index 7a32e452aec..c3f93e98df9 100644 --- a/tests/baselines/reference/emitMemberAccessExpression.types +++ b/tests/baselines/reference/emitMemberAccessExpression.types @@ -16,12 +16,12 @@ module Microsoft.PeopleAtWork.Model { === tests/cases/compiler/emitMemberAccessExpression_file1.ts === /// "use strict"; ->"use strict" : string +>"use strict" : "use strict" === tests/cases/compiler/emitMemberAccessExpression_file2.ts === /// "use strict"; ->"use strict" : string +>"use strict" : "use strict" module Microsoft.PeopleAtWork.Model { >Microsoft : typeof Microsoft diff --git a/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types index 0ada89e2802..5ca6aa0ead0 100644 --- a/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types +++ b/tests/baselines/reference/emitPinnedCommentsOnTopOfFile.types @@ -7,5 +7,5 @@ var x = 10; >x : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/emitPostComments.types b/tests/baselines/reference/emitPostComments.types index 5b5a05931d4..dd73d852423 100644 --- a/tests/baselines/reference/emitPostComments.types +++ b/tests/baselines/reference/emitPostComments.types @@ -2,7 +2,7 @@ var y = 10; >y : number ->10 : number +>10 : 10 /** * @name Foo diff --git a/tests/baselines/reference/emitPreComments.types b/tests/baselines/reference/emitPreComments.types index c0378350de3..5ba8e45f721 100644 --- a/tests/baselines/reference/emitPreComments.types +++ b/tests/baselines/reference/emitPreComments.types @@ -3,7 +3,7 @@ // This is pre comment var y = 10; >y : number ->10 : number +>10 : 10 /** * @name Foo diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types index cfdf0af0300..c8459efaa7c 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1.types @@ -4,7 +4,7 @@ class A { blub = 6; >blub : number ->6 : number +>6 : 6 } @@ -16,10 +16,10 @@ class B extends A { >x : number "use strict"; ->"use strict" : string +>"use strict" : "use strict" 'someStringForEgngInject'; ->'someStringForEgngInject' : string +>'someStringForEgngInject' : "someStringForEgngInject" super() >super() : void diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types index 4424042c241..5d27896c940 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types +++ b/tests/baselines/reference/emitSuperCallBeforeEmitParameterPropertyDeclaration1ES6.types @@ -4,7 +4,7 @@ class A { blub = 6; >blub : number ->6 : number +>6 : 6 } @@ -16,10 +16,10 @@ class B extends A { >x : number "use strict"; ->"use strict" : string +>"use strict" : "use strict" 'someStringForEgngInject'; ->'someStringForEgngInject' : string +>'someStringForEgngInject' : "someStringForEgngInject" super() >super() : void diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types index 2d16fed121d..c96fd01740e 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1.types @@ -4,7 +4,7 @@ class A { blub = 6; >blub : number ->6 : number +>6 : 6 } @@ -14,14 +14,14 @@ class B extends A { blub = 12; >blub : number ->12 : number +>12 : 12 constructor() { "use strict"; ->"use strict" : string +>"use strict" : "use strict" 'someStringForEgngInject'; ->'someStringForEgngInject' : string +>'someStringForEgngInject' : "someStringForEgngInject" super() >super() : void diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types index 39e8f885777..28b8c2d210a 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclaration1ES6.types @@ -4,7 +4,7 @@ class A { blub = 6; >blub : number ->6 : number +>6 : 6 } @@ -14,11 +14,11 @@ class B extends A { blub = 12; >blub : number ->12 : number +>12 : 12 constructor() { 'someStringForEgngInject'; ->'someStringForEgngInject' : string +>'someStringForEgngInject' : "someStringForEgngInject" super() >super() : void diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types index acb5703581a..8604f5d94bb 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1.types @@ -4,7 +4,7 @@ class A { blub = 6; >blub : number ->6 : number +>6 : 6 } @@ -14,16 +14,16 @@ class B extends A { blah = 2; >blah : number ->2 : number +>2 : 2 constructor(public x: number) { >x : number "use strict"; ->"use strict" : string +>"use strict" : "use strict" 'someStringForEgngInject'; ->'someStringForEgngInject' : string +>'someStringForEgngInject' : "someStringForEgngInject" super() >super() : void diff --git a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types index 96fc1fc2dc3..585ba8a9df9 100644 --- a/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types +++ b/tests/baselines/reference/emitSuperCallBeforeEmitPropertyDeclarationAndParameterPropertyDeclaration1ES6.types @@ -4,7 +4,7 @@ class A { blub = 6; >blub : number ->6 : number +>6 : 6 } @@ -14,16 +14,16 @@ class B extends A { blah = 2; >blah : number ->2 : number +>2 : 2 constructor(public x: number) { >x : number "use strict"; ->"use strict" : string +>"use strict" : "use strict" 'someStringForEgngInject'; ->'someStringForEgngInject' : string +>'someStringForEgngInject' : "someStringForEgngInject" super() >super() : void diff --git a/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types index 637196fdc22..b5c1cd2b346 100644 --- a/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types +++ b/tests/baselines/reference/emitTopOfFileTripleSlashCommentOnNotEmittedNodeIfRemoveCommentsIsFalse.types @@ -13,5 +13,5 @@ interface F { } var x = 10 >x : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/emptyArrayBindingPatternParameter04.types b/tests/baselines/reference/emptyArrayBindingPatternParameter04.types index 834eb41b34d..f6035a6ba94 100644 --- a/tests/baselines/reference/emptyArrayBindingPatternParameter04.types +++ b/tests/baselines/reference/emptyArrayBindingPatternParameter04.types @@ -3,10 +3,10 @@ function f([] = [1,2,3,4]) { >f : ([]?: number[]) => void >[1,2,3,4] : number[] ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 var x, y, z; >x : any diff --git a/tests/baselines/reference/emptyIndexer.types b/tests/baselines/reference/emptyIndexer.types index 5361ed4d7f4..7c7fb160b98 100644 --- a/tests/baselines/reference/emptyIndexer.types +++ b/tests/baselines/reference/emptyIndexer.types @@ -25,6 +25,6 @@ var n = x[''].m(); // should not crash compiler >x[''].m : () => number >x[''] : I1 >x : I2 ->'' : string +>'' : "" >m : () => number diff --git a/tests/baselines/reference/emptyThenWithoutWarning.types b/tests/baselines/reference/emptyThenWithoutWarning.types index 5da827deb2c..0632001736b 100644 --- a/tests/baselines/reference/emptyThenWithoutWarning.types +++ b/tests/baselines/reference/emptyThenWithoutWarning.types @@ -1,7 +1,7 @@ === tests/cases/compiler/emptyThenWithoutWarning.ts === let a = 4; >a : number ->4 : number +>4 : 4 if(a === 1 || a === 2 || a === 3) { >a === 1 || a === 2 || a === 3 : boolean @@ -19,5 +19,5 @@ if(a === 1 || a === 2 || a === 3) { else { let message = "Ooops"; >message : string ->"Ooops" : string +>"Ooops" : "Ooops" } diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types index 3640d468a59..9b6112365fd 100644 --- a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES5.types @@ -56,9 +56,9 @@ for (var {} = {}, {} = {}; false; void 0) { >{} : {} >{} : {} ->false : boolean +>false : false >void 0 : undefined ->0 : number +>0 : 0 } function f({} = a, [] = a, { p: {} = a} = a) { diff --git a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types index 20b7d5ec2b6..ac79fe0b1b7 100644 --- a/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types +++ b/tests/baselines/reference/emptyVariableDeclarationBindingPatterns01_ES6.types @@ -56,9 +56,9 @@ for (var {} = {}, {} = {}; false; void 0) { >{} : {} >{} : {} ->false : boolean +>false : false >void 0 : undefined ->0 : number +>0 : 0 } function f({} = a, [] = a, { p: {} = a} = a) { diff --git a/tests/baselines/reference/enumAssignmentCompat.errors.txt b/tests/baselines/reference/enumAssignmentCompat.errors.txt index f1a01247146..11f2d026261 100644 --- a/tests/baselines/reference/enumAssignmentCompat.errors.txt +++ b/tests/baselines/reference/enumAssignmentCompat.errors.txt @@ -1,11 +1,12 @@ tests/cases/compiler/enumAssignmentCompat.ts(26,5): error TS2322: Type 'typeof W' is not assignable to type 'number'. -tests/cases/compiler/enumAssignmentCompat.ts(28,5): error TS2322: Type 'W' is not assignable to type 'typeof W'. -tests/cases/compiler/enumAssignmentCompat.ts(30,5): error TS2322: Type 'number' is not assignable to type 'typeof W'. -tests/cases/compiler/enumAssignmentCompat.ts(32,5): error TS2322: Type 'W' is not assignable to type 'WStatic'. -tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' is not assignable to type 'WStatic'. +tests/cases/compiler/enumAssignmentCompat.ts(28,5): error TS2322: Type 'W.a' is not assignable to type 'typeof W'. +tests/cases/compiler/enumAssignmentCompat.ts(30,5): error TS2322: Type '3' is not assignable to type 'typeof W'. +tests/cases/compiler/enumAssignmentCompat.ts(31,5): error TS2322: Type '4' is not assignable to type 'W.a'. +tests/cases/compiler/enumAssignmentCompat.ts(32,5): error TS2322: Type 'W.a' is not assignable to type 'WStatic'. +tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type '5' is not assignable to type 'WStatic'. -==== tests/cases/compiler/enumAssignmentCompat.ts (5 errors) ==== +==== tests/cases/compiler/enumAssignmentCompat.ts (6 errors) ==== module W { export class D { } } @@ -37,18 +38,20 @@ tests/cases/compiler/enumAssignmentCompat.ts(33,5): error TS2322: Type 'number' var a: number = W.a; var b: typeof W = W.a; // error ~ -!!! error TS2322: Type 'W' is not assignable to type 'typeof W'. +!!! error TS2322: Type 'W.a' is not assignable to type 'typeof W'. var c: typeof W.a = W.a; var d: typeof W = 3; // error ~ -!!! error TS2322: Type 'number' is not assignable to type 'typeof W'. +!!! error TS2322: Type '3' is not assignable to type 'typeof W'. var e: typeof W.a = 4; + ~ +!!! error TS2322: Type '4' is not assignable to type 'W.a'. var f: WStatic = W.a; // error ~ -!!! error TS2322: Type 'W' is not assignable to type 'WStatic'. +!!! error TS2322: Type 'W.a' is not assignable to type 'WStatic'. var g: WStatic = 5; // error ~ -!!! error TS2322: Type 'number' is not assignable to type 'WStatic'. +!!! error TS2322: Type '5' is not assignable to type 'WStatic'. var h: W = 3; var i: W = W.a; i = W.a; diff --git a/tests/baselines/reference/enumAssignmentCompat2.errors.txt b/tests/baselines/reference/enumAssignmentCompat2.errors.txt index 4e0660eaae3..9cda6325434 100644 --- a/tests/baselines/reference/enumAssignmentCompat2.errors.txt +++ b/tests/baselines/reference/enumAssignmentCompat2.errors.txt @@ -1,11 +1,12 @@ tests/cases/compiler/enumAssignmentCompat2.ts(25,5): error TS2322: Type 'typeof W' is not assignable to type 'number'. -tests/cases/compiler/enumAssignmentCompat2.ts(27,5): error TS2322: Type 'W' is not assignable to type 'typeof W'. -tests/cases/compiler/enumAssignmentCompat2.ts(29,5): error TS2322: Type 'number' is not assignable to type 'typeof W'. -tests/cases/compiler/enumAssignmentCompat2.ts(31,5): error TS2322: Type 'W' is not assignable to type 'WStatic'. -tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' is not assignable to type 'WStatic'. +tests/cases/compiler/enumAssignmentCompat2.ts(27,5): error TS2322: Type 'W.a' is not assignable to type 'typeof W'. +tests/cases/compiler/enumAssignmentCompat2.ts(29,5): error TS2322: Type '3' is not assignable to type 'typeof W'. +tests/cases/compiler/enumAssignmentCompat2.ts(30,5): error TS2322: Type '4' is not assignable to type 'W.a'. +tests/cases/compiler/enumAssignmentCompat2.ts(31,5): error TS2322: Type 'W.a' is not assignable to type 'WStatic'. +tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type '5' is not assignable to type 'WStatic'. -==== tests/cases/compiler/enumAssignmentCompat2.ts (5 errors) ==== +==== tests/cases/compiler/enumAssignmentCompat2.ts (6 errors) ==== enum W { a, b, c, @@ -36,18 +37,20 @@ tests/cases/compiler/enumAssignmentCompat2.ts(32,5): error TS2322: Type 'number' var a: number = W.a; var b: typeof W = W.a; // error ~ -!!! error TS2322: Type 'W' is not assignable to type 'typeof W'. +!!! error TS2322: Type 'W.a' is not assignable to type 'typeof W'. var c: typeof W.a = W.a; var d: typeof W = 3; // error ~ -!!! error TS2322: Type 'number' is not assignable to type 'typeof W'. +!!! error TS2322: Type '3' is not assignable to type 'typeof W'. var e: typeof W.a = 4; + ~ +!!! error TS2322: Type '4' is not assignable to type 'W.a'. var f: WStatic = W.a; // error ~ -!!! error TS2322: Type 'W' is not assignable to type 'WStatic'. +!!! error TS2322: Type 'W.a' is not assignable to type 'WStatic'. var g: WStatic = 5; // error ~ -!!! error TS2322: Type 'number' is not assignable to type 'WStatic'. +!!! error TS2322: Type '5' is not assignable to type 'WStatic'. var h: W = 3; var i: W = W.a; i = W.a; diff --git a/tests/baselines/reference/enumBasics.errors.txt b/tests/baselines/reference/enumBasics.errors.txt new file mode 100644 index 00000000000..4d82402b8ee --- /dev/null +++ b/tests/baselines/reference/enumBasics.errors.txt @@ -0,0 +1,86 @@ +tests/cases/conformance/enums/enumBasics.ts(13,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'e' must be of type 'typeof E1', but here has type '{ readonly [n: number]: string; readonly A: E1; readonly B: E1; readonly C: E1; }'. + + +==== tests/cases/conformance/enums/enumBasics.ts (1 errors) ==== + // Enum without initializers have first member = 0 and successive members = N + 1 + enum E1 { + A, + B, + C + } + + // Enum type is a subtype of Number + var x: number = E1.A; + + // Enum object type is anonymous with properties of the enum type and numeric indexer + var e = E1; + var e: { + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'e' must be of type 'typeof E1', but here has type '{ readonly [n: number]: string; readonly A: E1; readonly B: E1; readonly C: E1; }'. + readonly A: E1; + readonly B: E1; + readonly C: E1; + readonly [n: number]: string; + }; + var e: typeof E1; + + // Reverse mapping of enum returns string name of property + var s = E1[e.A]; + var s: string; + + + // Enum with only constant members + enum E2 { + A = 1, B = 2, C = 3 + } + + // Enum with only computed members + enum E3 { + X = 'foo'.length, Y = 4 + 3, Z = +'foo' + } + + // Enum with constant members followed by computed members + enum E4 { + X = 0, Y, Z = 'foo'.length + } + + // Enum with > 2 constant members with no initializer for first member, non zero initializer for second element + enum E5 { + A, + B = 3, + C // 4 + } + + enum E6 { + A, + B = 0, + C // 1 + } + + // Enum with computed member initializer of type 'any' + enum E7 { + A = 'foo'['foo'] + } + + // Enum with computed member initializer of type number + enum E8 { + B = 'foo'['foo'] + } + + //Enum with computed member intializer of same enum type + enum E9 { + A, + B = A + } + + // (refer to .js to validate) + // Enum constant members are propagated + var doNotPropagate = [ + E8.B, E7.A, E4.Z, E3.X, E3.Y, E3.Z + ]; + // Enum computed members are not propagated + var doPropagate = [ + E9.A, E9.B, E6.B, E6.C, E6.A, E5.A, E5.B, E5.C + ]; + + \ No newline at end of file diff --git a/tests/baselines/reference/enumBasics1.errors.txt b/tests/baselines/reference/enumBasics1.errors.txt index fddca60bd99..352303def5b 100644 --- a/tests/baselines/reference/enumBasics1.errors.txt +++ b/tests/baselines/reference/enumBasics1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/enumBasics1.ts(26,5): error TS2339: Property 'A' does not exist on type 'E'. +tests/cases/compiler/enumBasics1.ts(26,5): error TS2339: Property 'A' does not exist on type 'E.A'. tests/cases/compiler/enumBasics1.ts(35,2): error TS2432: In an enum with multiple declarations, only one declaration can omit an initializer for its first enum element. @@ -30,7 +30,7 @@ tests/cases/compiler/enumBasics1.ts(35,2): error TS2432: In an enum with multipl */ E.A.A; // should error ~ -!!! error TS2339: Property 'A' does not exist on type 'E'. +!!! error TS2339: Property 'A' does not exist on type 'E.A'. enum E2 { diff --git a/tests/baselines/reference/enumCodeGenNewLines1.types b/tests/baselines/reference/enumCodeGenNewLines1.types index 6321511ef2d..ec4f610df11 100644 --- a/tests/baselines/reference/enumCodeGenNewLines1.types +++ b/tests/baselines/reference/enumCodeGenNewLines1.types @@ -3,15 +3,15 @@ enum foo { >foo : foo b = 1, ->b : foo ->1 : number +>b : foo.b +>1 : 1 c = 2, ->c : foo ->2 : number +>c : foo.c +>2 : 2 d = 3 ->d : foo ->3 : number +>d : foo.d +>3 : 3 } diff --git a/tests/baselines/reference/enumConstantMembers.types b/tests/baselines/reference/enumConstantMembers.types index c99b5eeb62f..bfbf71a6c17 100644 --- a/tests/baselines/reference/enumConstantMembers.types +++ b/tests/baselines/reference/enumConstantMembers.types @@ -4,47 +4,47 @@ enum E1 { >E1 : E1 a = 1, ->a : E1 ->1 : number +>a : E1.a +>1 : 1 b ->b : E1 +>b : E1.b } enum E2 { >E2 : E2 a = - 1, ->a : E2 ->- 1 : number ->1 : number +>a : E2.a +>- 1 : -1 +>1 : 1 b ->b : E2 +>b : E2.b } enum E3 { >E3 : E3 a = 0.1, ->a : E3 ->0.1 : number +>a : E3.a +>0.1 : 0.1 b // Error because 0.1 is not a constant ->b : E3 +>b : E3.b } declare enum E4 { >E4 : E4 a = 1, ->a : E4 ->1 : number +>a : E4.a +>1 : 1 b = -1, ->b : E4 ->-1 : number ->1 : number +>b : E4.b +>-1 : -1 +>1 : 1 c = 0.1 // Not a constant ->c : E4 ->0.1 : number +>c : E4.c +>0.1 : 0.1 } diff --git a/tests/baselines/reference/enumErrors.errors.txt b/tests/baselines/reference/enumErrors.errors.txt index 14cad3cb53b..f0978df709c 100644 --- a/tests/baselines/reference/enumErrors.errors.txt +++ b/tests/baselines/reference/enumErrors.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/enums/enumErrors.ts(3,6): error TS2431: Enum name cannot tests/cases/conformance/enums/enumErrors.ts(4,6): error TS2431: Enum name cannot be 'string' tests/cases/conformance/enums/enumErrors.ts(5,6): error TS2431: Enum name cannot be 'boolean' tests/cases/conformance/enums/enumErrors.ts(9,9): error TS2322: Type 'Number' is not assignable to type 'E5'. -tests/cases/conformance/enums/enumErrors.ts(26,9): error TS2322: Type 'string' is not assignable to type 'E11'. +tests/cases/conformance/enums/enumErrors.ts(26,9): error TS2322: Type '""' is not assignable to type 'E11'. tests/cases/conformance/enums/enumErrors.ts(27,9): error TS2322: Type 'Date' is not assignable to type 'E11'. tests/cases/conformance/enums/enumErrors.ts(28,9): error TS2304: Cannot find name 'window'. tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is not assignable to type 'E11'. @@ -47,7 +47,7 @@ tests/cases/conformance/enums/enumErrors.ts(29,9): error TS2322: Type '{}' is no enum E11 { A = '', ~~ -!!! error TS2322: Type 'string' is not assignable to type 'E11'. +!!! error TS2322: Type '""' is not assignable to type 'E11'. B = new Date(), ~~~~~~~~~~ !!! error TS2322: Type 'Date' is not assignable to type 'E11'. diff --git a/tests/baselines/reference/enumExportMergingES6.types b/tests/baselines/reference/enumExportMergingES6.types index da2fc22cb8a..6ede07d92a0 100644 --- a/tests/baselines/reference/enumExportMergingES6.types +++ b/tests/baselines/reference/enumExportMergingES6.types @@ -4,14 +4,14 @@ export enum Animals { Cat = 1 >Cat : Animals ->1 : number +>1 : 1 } export enum Animals { >Animals : Animals Dog = 2 >Dog : Animals ->2 : number +>2 : 2 } export enum Animals { >Animals : Animals diff --git a/tests/baselines/reference/enumIndexer.types b/tests/baselines/reference/enumIndexer.types index cbc43176b01..6c6e50822b5 100644 --- a/tests/baselines/reference/enumIndexer.types +++ b/tests/baselines/reference/enumIndexer.types @@ -3,24 +3,24 @@ enum MyEnumType { >MyEnumType : MyEnumType foo, bar ->foo : MyEnumType ->bar : MyEnumType +>foo : MyEnumType.foo +>bar : MyEnumType.bar } var _arr = [{ key: 'foo' }, { key: 'bar' }] >_arr : { key: string; }[] >[{ key: 'foo' }, { key: 'bar' }] : { key: string; }[] >{ key: 'foo' } : { key: string; } >key : string ->'foo' : string +>'foo' : "foo" >{ key: 'bar' } : { key: string; } >key : string ->'bar' : string +>'bar' : "bar" var enumValue = MyEnumType.foo; >enumValue : MyEnumType ->MyEnumType.foo : MyEnumType +>MyEnumType.foo : MyEnumType.foo >MyEnumType : typeof MyEnumType ->foo : MyEnumType +>foo : MyEnumType.foo var x = _arr.map(o => MyEnumType[o.key] === enumValue); // these are not same type >x : boolean[] diff --git a/tests/baselines/reference/enumInitializersWithExponents.types b/tests/baselines/reference/enumInitializersWithExponents.types index 8da208e5f87..25a36ffc5e3 100644 --- a/tests/baselines/reference/enumInitializersWithExponents.types +++ b/tests/baselines/reference/enumInitializersWithExponents.types @@ -4,26 +4,26 @@ declare enum E { >E : E a = 1e3, // ok ->a : E ->1e3 : number +>a : E.a +>1e3 : 1000 b = 1e25, // ok ->b : E ->1e25 : number +>b : E.b +>1e25 : 1e+25 c = 1e-3, // error ->c : E ->1e-3 : number +>c : E.c +>1e-3 : 0.001 d = 1e-9, // error ->d : E ->1e-9 : number +>d : E.d +>1e-9 : 1e-9 e = 1e0, // ok ->e : E ->1e0 : number +>e : E.e +>1e0 : 1 f = 1e+25 // ok ->f : E ->1e+25 : number +>f : E.b +>1e+25 : 1e+25 } diff --git a/tests/baselines/reference/enumLiteralTypes1.types b/tests/baselines/reference/enumLiteralTypes1.types index 1fe3c8dd637..754574f547c 100644 --- a/tests/baselines/reference/enumLiteralTypes1.types +++ b/tests/baselines/reference/enumLiteralTypes1.types @@ -1,9 +1,9 @@ === tests/cases/conformance/types/literal/enumLiteralTypes1.ts === const enum Choice { Unknown, Yes, No }; >Choice : Choice ->Unknown : Choice ->Yes : Choice ->No : Choice +>Unknown : Choice.Unknown +>Yes : Choice.Yes +>No : Choice.No type YesNo = Choice.Yes | Choice.No; >YesNo : YesNo @@ -284,11 +284,11 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); >new Error("Unexpected value") : Error >Error : ErrorConstructor ->"Unexpected value" : string +>"Unexpected value" : "Unexpected value" } function f10(x: YesNo) { ->f10 : (x: YesNo) => string +>f10 : (x: YesNo) => "true" | "false" >x : YesNo >YesNo : YesNo @@ -299,18 +299,18 @@ function f10(x: YesNo) { >Choice.Yes : Choice.Yes >Choice : typeof Choice >Yes : Choice.Yes ->"true" : string +>"true" : "true" case Choice.No: return "false"; >Choice.No : Choice.No >Choice : typeof Choice >No : Choice.No ->"false" : string +>"false" : "false" } } function f11(x: YesNo) { ->f11 : (x: YesNo) => string +>f11 : (x: YesNo) => "true" | "false" >x : YesNo >YesNo : YesNo @@ -321,13 +321,13 @@ function f11(x: YesNo) { >Choice.Yes : Choice.Yes >Choice : typeof Choice >Yes : Choice.Yes ->"true" : string +>"true" : "true" case Choice.No: return "false"; >Choice.No : Choice.No >Choice : typeof Choice >No : Choice.No ->"false" : string +>"false" : "false" } return assertNever(x); >assertNever(x) : never diff --git a/tests/baselines/reference/enumLiteralTypes2.types b/tests/baselines/reference/enumLiteralTypes2.types index 36390865aec..e27410a4dc7 100644 --- a/tests/baselines/reference/enumLiteralTypes2.types +++ b/tests/baselines/reference/enumLiteralTypes2.types @@ -2,9 +2,9 @@ const enum Choice { Unknown, Yes, No }; >Choice : Choice ->Unknown : Choice ->Yes : Choice ->No : Choice +>Unknown : Choice.Unknown +>Yes : Choice.Yes +>No : Choice.No type YesNo = Choice.Yes | Choice.No; >YesNo : YesNo @@ -285,11 +285,11 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); >new Error("Unexpected value") : Error >Error : ErrorConstructor ->"Unexpected value" : string +>"Unexpected value" : "Unexpected value" } function f10(x: YesNo) { ->f10 : (x: YesNo) => string +>f10 : (x: YesNo) => "true" | "false" >x : YesNo >YesNo : YesNo @@ -300,18 +300,18 @@ function f10(x: YesNo) { >Choice.Yes : Choice.Yes >Choice : typeof Choice >Yes : Choice.Yes ->"true" : string +>"true" : "true" case Choice.No: return "false"; >Choice.No : Choice.No >Choice : typeof Choice >No : Choice.No ->"false" : string +>"false" : "false" } } function f11(x: YesNo) { ->f11 : (x: YesNo) => string +>f11 : (x: YesNo) => "true" | "false" >x : YesNo >YesNo : YesNo @@ -322,13 +322,13 @@ function f11(x: YesNo) { >Choice.Yes : Choice.Yes >Choice : typeof Choice >Yes : Choice.Yes ->"true" : string +>"true" : "true" case Choice.No: return "false"; >Choice.No : Choice.No >Choice : typeof Choice >No : Choice.No ->"false" : string +>"false" : "false" } return assertNever(x); >assertNever(x) : never diff --git a/tests/baselines/reference/enumMapBackIntoItself.types b/tests/baselines/reference/enumMapBackIntoItself.types index ab26094512b..964f97061a1 100644 --- a/tests/baselines/reference/enumMapBackIntoItself.types +++ b/tests/baselines/reference/enumMapBackIntoItself.types @@ -3,29 +3,29 @@ enum TShirtSize { >TShirtSize : TShirtSize Small, ->Small : TShirtSize +>Small : TShirtSize.Small Medium, ->Medium : TShirtSize +>Medium : TShirtSize.Medium Large ->Large : TShirtSize +>Large : TShirtSize.Large } var mySize = TShirtSize.Large; >mySize : TShirtSize ->TShirtSize.Large : TShirtSize +>TShirtSize.Large : TShirtSize.Large >TShirtSize : typeof TShirtSize ->Large : TShirtSize +>Large : TShirtSize.Large var test = TShirtSize[mySize]; >test : string >TShirtSize[mySize] : string >TShirtSize : typeof TShirtSize ->mySize : TShirtSize +>mySize : TShirtSize.Large // specifically checking output here, bug was that test used to be undefined at runtime test + '' >test + '' : string >test : string ->'' : string +>'' : "" diff --git a/tests/baselines/reference/enumMerging.types b/tests/baselines/reference/enumMerging.types index 1ca284702c5..a70284c80ea 100644 --- a/tests/baselines/reference/enumMerging.types +++ b/tests/baselines/reference/enumMerging.types @@ -8,66 +8,66 @@ module M1 { >EImpl1 : EImpl1 A, B, C ->A : EImpl1 ->B : EImpl1 ->C : EImpl1 +>A : EImpl1.A +>B : EImpl1.B +>C : EImpl1.C } enum EImpl1 { >EImpl1 : EImpl1 D = 1, E, F ->D : EImpl1 ->1 : number ->E : EImpl1 ->F : EImpl1 +>D : EImpl1.B +>1 : 1 +>E : EImpl1.C +>F : EImpl1.F } export enum EConst1 { >EConst1 : EConst1 A = 3, B = 2, C = 1 ->A : EConst1 ->3 : number ->B : EConst1 ->2 : number ->C : EConst1 ->1 : number +>A : EConst1.A +>3 : 3 +>B : EConst1.B +>2 : 2 +>C : EConst1.C +>1 : 1 } export enum EConst1 { >EConst1 : EConst1 D = 7, E = 9, F = 8 ->D : EConst1 ->7 : number ->E : EConst1 ->9 : number ->F : EConst1 ->8 : number +>D : EConst1.D +>7 : 7 +>E : EConst1.E +>9 : 9 +>F : EConst1.F +>8 : 8 } var x = [EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F]; >x : EConst1[] >[EConst1.A, EConst1.B, EConst1.C, EConst1.D, EConst1.E, EConst1.F] : EConst1[] ->EConst1.A : EConst1 +>EConst1.A : EConst1.A >EConst1 : typeof EConst1 ->A : EConst1 ->EConst1.B : EConst1 +>A : EConst1.A +>EConst1.B : EConst1.B >EConst1 : typeof EConst1 ->B : EConst1 ->EConst1.C : EConst1 +>B : EConst1.B +>EConst1.C : EConst1.C >EConst1 : typeof EConst1 ->C : EConst1 ->EConst1.D : EConst1 +>C : EConst1.C +>EConst1.D : EConst1.D >EConst1 : typeof EConst1 ->D : EConst1 ->EConst1.E : EConst1 +>D : EConst1.D +>EConst1.E : EConst1.E >EConst1 : typeof EConst1 ->E : EConst1 ->EConst1.F : EConst1 +>E : EConst1.E +>EConst1.F : EConst1.F >EConst1 : typeof EConst1 ->F : EConst1 +>F : EConst1.F } // Enum with only computed members across 2 declarations with the same root module @@ -80,15 +80,15 @@ module M2 { A = 'foo'.length, B = 'foo'.length, C = 'foo'.length >A : EComp2 >'foo'.length : number ->'foo' : string +>'foo' : "foo" >length : number >B : EComp2 >'foo'.length : number ->'foo' : string +>'foo' : "foo" >length : number >C : EComp2 >'foo'.length : number ->'foo' : string +>'foo' : "foo" >length : number } @@ -98,15 +98,15 @@ module M2 { D = 'foo'.length, E = 'foo'.length, F = 'foo'.length >D : EComp2 >'foo'.length : number ->'foo' : string +>'foo' : "foo" >length : number >E : EComp2 >'foo'.length : number ->'foo' : string +>'foo' : "foo" >length : number >F : EComp2 >'foo'.length : number ->'foo' : string +>'foo' : "foo" >length : number } @@ -141,20 +141,20 @@ module M3 { >EInit : EInit A, ->A : EInit +>A : EInit.A B ->B : EInit +>B : EInit.B } enum EInit { >EInit : EInit C = 1, D, E ->C : EInit ->1 : number ->D : EInit ->E : EInit +>C : EInit.B +>1 : 1 +>D : EInit.D +>E : EInit.E } } @@ -164,18 +164,18 @@ module M4 { export enum Color { Red, Green, Blue } >Color : Color ->Red : Color ->Green : Color ->Blue : Color +>Red : Color.Red +>Green : Color.Green +>Blue : Color.Blue } module M5 { >M5 : typeof M5 export enum Color { Red, Green, Blue } >Color : Color ->Red : Color ->Green : Color ->Blue : Color +>Red : Color.Red +>Green : Color.Green +>Blue : Color.Blue } module M6.A { @@ -184,9 +184,9 @@ module M6.A { export enum Color { Red, Green, Blue } >Color : Color ->Red : Color ->Green : Color ->Blue : Color +>Red : Color.Red +>Green : Color.Green +>Blue : Color.Blue } module M6 { >M6 : typeof M6 @@ -196,16 +196,16 @@ module M6 { export enum Color { Yellow = 1 } >Color : Color ->Yellow : Color ->1 : number +>Yellow : Color.Green +>1 : 1 } var t = A.Color.Yellow; >t : A.Color ->A.Color.Yellow : A.Color +>A.Color.Yellow : A.Color.Green >A.Color : typeof A.Color >A : typeof A >Color : typeof A.Color ->Yellow : A.Color +>Yellow : A.Color.Green t = A.Color.Red; >t = A.Color.Red : A.Color.Red diff --git a/tests/baselines/reference/enumNegativeLiteral1.types b/tests/baselines/reference/enumNegativeLiteral1.types index 31ecbc11aa2..491e5b4b088 100644 --- a/tests/baselines/reference/enumNegativeLiteral1.types +++ b/tests/baselines/reference/enumNegativeLiteral1.types @@ -3,10 +3,10 @@ enum E { >E : E a = -5, b, c ->a : E ->-5 : number ->5 : number ->b : E ->c : E +>a : E.a +>-5 : -5 +>5 : 5 +>b : E.b +>c : E.c } diff --git a/tests/baselines/reference/enumNumbering1.types b/tests/baselines/reference/enumNumbering1.types index 81bb0325b7a..25f7225b96d 100644 --- a/tests/baselines/reference/enumNumbering1.types +++ b/tests/baselines/reference/enumNumbering1.types @@ -19,11 +19,11 @@ enum Test { >Math.random : () => number >Math : Math >random : () => number ->1000 : number +>1000 : 1000 D = 10, >D : Test ->10 : number +>10 : 10 E // Error but shouldn't be >E : Test diff --git a/tests/baselines/reference/enumOperations.types b/tests/baselines/reference/enumOperations.types index 232ecc5e71b..136d76558b2 100644 --- a/tests/baselines/reference/enumOperations.types +++ b/tests/baselines/reference/enumOperations.types @@ -2,7 +2,7 @@ enum Enum { None = 0 } >Enum : Enum >None : Enum ->0 : number +>0 : 0 var enumType: Enum = Enum.None; >enumType : Enum @@ -13,11 +13,11 @@ var enumType: Enum = Enum.None; var numberType: number = 0; >numberType : number ->0 : number +>0 : 0 var anyType: any = 0; >anyType : any ->0 : number +>0 : 0 enumType ^ numberType; >enumType ^ numberType : number diff --git a/tests/baselines/reference/enumPropertyAccess.errors.txt b/tests/baselines/reference/enumPropertyAccess.errors.txt index 666e9297120..fe670a3ef31 100644 --- a/tests/baselines/reference/enumPropertyAccess.errors.txt +++ b/tests/baselines/reference/enumPropertyAccess.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/enumPropertyAccess.ts(7,11): error TS2339: Property 'Green' does not exist on type 'Colors'. +tests/cases/compiler/enumPropertyAccess.ts(7,11): error TS2339: Property 'Green' does not exist on type 'Colors.Red'. tests/cases/compiler/enumPropertyAccess.ts(12,7): error TS2339: Property 'Green' does not exist on type 'B'. @@ -11,7 +11,7 @@ tests/cases/compiler/enumPropertyAccess.ts(12,7): error TS2339: Property 'Green' var x = Colors.Red; // type of 'x' should be 'Colors' var p = x.Green; // error ~~~~~ -!!! error TS2339: Property 'Green' does not exist on type 'Colors'. +!!! error TS2339: Property 'Green' does not exist on type 'Colors.Red'. x.toFixed(); // ok // Now with generics diff --git a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.types b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.types index 0ece7b76f1e..c558000f756 100644 --- a/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.types +++ b/tests/baselines/reference/enumWithoutInitializerAfterComputedMember.types @@ -3,12 +3,12 @@ enum E { >E : E a, ->a : E +>a : E.a b = a, ->b : E ->a : E +>b : E.a +>a : E.a c ->c : E +>c : E.c } diff --git a/tests/baselines/reference/equalityWithUnionTypes01.types b/tests/baselines/reference/equalityWithUnionTypes01.types index 61e38030949..acec449dc42 100644 --- a/tests/baselines/reference/equalityWithUnionTypes01.types +++ b/tests/baselines/reference/equalityWithUnionTypes01.types @@ -18,9 +18,9 @@ var x = { p1: 10, p2: 20 }; >x : { p1: number; p2: number; } >{ p1: 10, p2: 20 } : { p1: number; p2: number; } >p1 : number ->10 : number +>10 : 10 >p2 : number ->20 : number +>20 : 20 var y: number | I2 = x; >y : number | I2 diff --git a/tests/baselines/reference/es2015modulekind.types b/tests/baselines/reference/es2015modulekind.types index e77cf095aed..1b09ecb0a88 100644 --- a/tests/baselines/reference/es2015modulekind.types +++ b/tests/baselines/reference/es2015modulekind.types @@ -12,6 +12,6 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es2015modulekindWithES6Target.types b/tests/baselines/reference/es2015modulekindWithES6Target.types index 50b85921b0e..4872566b1c2 100644 --- a/tests/baselines/reference/es2015modulekindWithES6Target.types +++ b/tests/baselines/reference/es2015modulekindWithES6Target.types @@ -12,6 +12,6 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es3-amd.types b/tests/baselines/reference/es3-amd.types index 1e9fdbd582f..420354f364a 100644 --- a/tests/baselines/reference/es3-amd.types +++ b/tests/baselines/reference/es3-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es3-declaration-amd.types b/tests/baselines/reference/es3-declaration-amd.types index daf0bb5d74e..c174d8d0255 100644 --- a/tests/baselines/reference/es3-declaration-amd.types +++ b/tests/baselines/reference/es3-declaration-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es3-sourcemap-amd.types b/tests/baselines/reference/es3-sourcemap-amd.types index d3f712211e4..351cbe5ded9 100644 --- a/tests/baselines/reference/es3-sourcemap-amd.types +++ b/tests/baselines/reference/es3-sourcemap-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es3defaultAliasIsQuoted.types b/tests/baselines/reference/es3defaultAliasIsQuoted.types index 59ce62dff1e..b0412359660 100644 --- a/tests/baselines/reference/es3defaultAliasIsQuoted.types +++ b/tests/baselines/reference/es3defaultAliasIsQuoted.types @@ -5,7 +5,7 @@ export class Foo { static CONSTANT = "Foo"; >CONSTANT : string ->"Foo" : string +>"Foo" : "Foo" } export default function assert(value: boolean) { @@ -17,7 +17,7 @@ export default function assert(value: boolean) { >value : boolean >new Error("Assertion failed!") : Error >Error : ErrorConstructor ->"Assertion failed!" : string +>"Assertion failed!" : "Assertion failed!" } === tests/cases/compiler/es3defaultAliasQuoted_file1.ts === diff --git a/tests/baselines/reference/es5-amd.types b/tests/baselines/reference/es5-amd.types index 7dd9e8b281a..62e47b91d10 100644 --- a/tests/baselines/reference/es5-amd.types +++ b/tests/baselines/reference/es5-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5-commonjs.types b/tests/baselines/reference/es5-commonjs.types index 4c1bc922917..06a14af7f4f 100644 --- a/tests/baselines/reference/es5-commonjs.types +++ b/tests/baselines/reference/es5-commonjs.types @@ -12,7 +12,7 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5-commonjs3.types b/tests/baselines/reference/es5-commonjs3.types index facdfae00ce..6f6b9c3e499 100644 --- a/tests/baselines/reference/es5-commonjs3.types +++ b/tests/baselines/reference/es5-commonjs3.types @@ -3,5 +3,5 @@ export default "test"; export var __esModule = 1; >__esModule : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/es5-commonjs4.types b/tests/baselines/reference/es5-commonjs4.types index d3471afbfeb..fedfe9390a2 100644 --- a/tests/baselines/reference/es5-commonjs4.types +++ b/tests/baselines/reference/es5-commonjs4.types @@ -12,10 +12,10 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } export var __esModule = 1; >__esModule : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/es5-commonjs5.types b/tests/baselines/reference/es5-commonjs5.types index d8094e1e0ea..fb72fda8c11 100644 --- a/tests/baselines/reference/es5-commonjs5.types +++ b/tests/baselines/reference/es5-commonjs5.types @@ -2,6 +2,6 @@ export default function () { return "test"; ->"test" : string +>"test" : "test" } diff --git a/tests/baselines/reference/es5-commonjs6.types b/tests/baselines/reference/es5-commonjs6.types index 904b69dec22..cabe84e8a69 100644 --- a/tests/baselines/reference/es5-commonjs6.types +++ b/tests/baselines/reference/es5-commonjs6.types @@ -3,5 +3,5 @@ export default "test"; var __esModule = 1; >__esModule : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/es5-declaration-amd.types b/tests/baselines/reference/es5-declaration-amd.types index ead96c35de1..ca5422fd739 100644 --- a/tests/baselines/reference/es5-declaration-amd.types +++ b/tests/baselines/reference/es5-declaration-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5-souremap-amd.types b/tests/baselines/reference/es5-souremap-amd.types index 67606d7f1ff..d96f15b8d0e 100644 --- a/tests/baselines/reference/es5-souremap-amd.types +++ b/tests/baselines/reference/es5-souremap-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5-system.types b/tests/baselines/reference/es5-system.types index eae884a78b4..fa6d471dbf7 100644 --- a/tests/baselines/reference/es5-system.types +++ b/tests/baselines/reference/es5-system.types @@ -12,7 +12,7 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5-umd.types b/tests/baselines/reference/es5-umd.types index 60987d429e0..dcee52664cc 100644 --- a/tests/baselines/reference/es5-umd.types +++ b/tests/baselines/reference/es5-umd.types @@ -12,7 +12,7 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5-umd2.types b/tests/baselines/reference/es5-umd2.types index fab4e9dfc01..2c24088c4a0 100644 --- a/tests/baselines/reference/es5-umd2.types +++ b/tests/baselines/reference/es5-umd2.types @@ -12,7 +12,7 @@ export class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5-umd3.types b/tests/baselines/reference/es5-umd3.types index b4b5f0dc366..bb4cc91af50 100644 --- a/tests/baselines/reference/es5-umd3.types +++ b/tests/baselines/reference/es5-umd3.types @@ -12,7 +12,7 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5-umd4.types b/tests/baselines/reference/es5-umd4.types index 59d23e6bd8d..4ce47c9e4de 100644 --- a/tests/baselines/reference/es5-umd4.types +++ b/tests/baselines/reference/es5-umd4.types @@ -12,7 +12,7 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5ExportDefaultExpression.types b/tests/baselines/reference/es5ExportDefaultExpression.types index 6b371a2fc73..db4d3a3abfd 100644 --- a/tests/baselines/reference/es5ExportDefaultExpression.types +++ b/tests/baselines/reference/es5ExportDefaultExpression.types @@ -3,6 +3,6 @@ export default (1 + 2); >(1 + 2) : number >1 + 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/es5ModuleWithModuleGenAmd.types b/tests/baselines/reference/es5ModuleWithModuleGenAmd.types index 4ae6698d06a..3d648a7777f 100644 --- a/tests/baselines/reference/es5ModuleWithModuleGenAmd.types +++ b/tests/baselines/reference/es5ModuleWithModuleGenAmd.types @@ -10,6 +10,6 @@ export class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.types b/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.types index 425afed82d2..d2dc36fdd8e 100644 --- a/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.types +++ b/tests/baselines/reference/es5ModuleWithModuleGenCommonjs.types @@ -10,6 +10,6 @@ export class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.types b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.types index 251e2be25a9..349ab719d78 100644 --- a/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.types +++ b/tests/baselines/reference/es5ModuleWithoutModuleGenTarget.types @@ -10,6 +10,6 @@ export class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es5andes6module.types b/tests/baselines/reference/es5andes6module.types index 14423d87cea..44dba0eb28e 100644 --- a/tests/baselines/reference/es5andes6module.types +++ b/tests/baselines/reference/es5andes6module.types @@ -12,7 +12,7 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6-amd.types b/tests/baselines/reference/es6-amd.types index 7a6fb6e32f5..5ba03153627 100644 --- a/tests/baselines/reference/es6-amd.types +++ b/tests/baselines/reference/es6-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6-declaration-amd.types b/tests/baselines/reference/es6-declaration-amd.types index a46d22c82c5..9568cedc0bd 100644 --- a/tests/baselines/reference/es6-declaration-amd.types +++ b/tests/baselines/reference/es6-declaration-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6-sourcemap-amd.types b/tests/baselines/reference/es6-sourcemap-amd.types index 580a688afab..6cbdc98df6f 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.types +++ b/tests/baselines/reference/es6-sourcemap-amd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6-umd.types b/tests/baselines/reference/es6-umd.types index f43c491e003..ed3932d2e2a 100644 --- a/tests/baselines/reference/es6-umd.types +++ b/tests/baselines/reference/es6-umd.types @@ -12,6 +12,6 @@ class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6-umd2.types b/tests/baselines/reference/es6-umd2.types index eb66523c6ec..395f136add8 100644 --- a/tests/baselines/reference/es6-umd2.types +++ b/tests/baselines/reference/es6-umd2.types @@ -12,6 +12,6 @@ export class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6ClassSuperCodegenBug.types b/tests/baselines/reference/es6ClassSuperCodegenBug.types index 65269c99997..d98b1fea451 100644 --- a/tests/baselines/reference/es6ClassSuperCodegenBug.types +++ b/tests/baselines/reference/es6ClassSuperCodegenBug.types @@ -13,20 +13,20 @@ class B extends A { constructor() { if (true) { ->true : boolean +>true : true super('a1', 'b1'); >super('a1', 'b1') : void >super : typeof A ->'a1' : string ->'b1' : string +>'a1' : "a1" +>'b1' : "b1" } else { super('a2', 'b2'); >super('a2', 'b2') : void >super : typeof A ->'a2' : string ->'b2' : string +>'a2' : "a2" +>'b2' : "b2" } } } diff --git a/tests/baselines/reference/es6ClassTest3.types b/tests/baselines/reference/es6ClassTest3.types index 208d8cdf4d9..328589d76d6 100644 --- a/tests/baselines/reference/es6ClassTest3.types +++ b/tests/baselines/reference/es6ClassTest3.types @@ -22,18 +22,18 @@ module M { constructor() { this.x = 1; ->this.x = 1 : number +>this.x = 1 : 1 >this.x : number >this : this >x : number ->1 : number +>1 : 1 this.y = 2; ->this.y = 2 : number +>this.y = 2 : 2 >this.y : number >this : this >y : number ->2 : number +>2 : 2 } } } diff --git a/tests/baselines/reference/es6ClassTest5.types b/tests/baselines/reference/es6ClassTest5.types index 087a80170ed..7b3b69512f5 100644 --- a/tests/baselines/reference/es6ClassTest5.types +++ b/tests/baselines/reference/es6ClassTest5.types @@ -23,6 +23,6 @@ class bigClass { public break = 1; >break : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/es6ClassTest8.types b/tests/baselines/reference/es6ClassTest8.types index b12d65e595f..4dcfde53671 100644 --- a/tests/baselines/reference/es6ClassTest8.types +++ b/tests/baselines/reference/es6ClassTest8.types @@ -111,10 +111,10 @@ class Camera { >down : Vector >new Vector(0.0, -1.0, 0.0) : Vector >Vector : typeof Vector ->0.0 : number ->-1.0 : number ->1.0 : number ->0.0 : number +>0.0 : 0 +>-1.0 : -1 +>1.0 : 1 +>0.0 : 0 this.forward = Vector.norm(Vector.minus(lookAt,this.pos)); >this.forward = Vector.norm(Vector.minus(lookAt,this.pos)) : Vector diff --git a/tests/baselines/reference/es6ExportAll.types b/tests/baselines/reference/es6ExportAll.types index 876ff152e2c..b6a7056fd4a 100644 --- a/tests/baselines/reference/es6ExportAll.types +++ b/tests/baselines/reference/es6ExportAll.types @@ -11,11 +11,11 @@ export module m { export var x = 10; >x : number ->10 : number +>10 : 10 } export var x = 10; >x : number ->10 : number +>10 : 10 export module uninstantiated { >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportAllInEs5.types b/tests/baselines/reference/es6ExportAllInEs5.types index 68187384602..fc3daf6685c 100644 --- a/tests/baselines/reference/es6ExportAllInEs5.types +++ b/tests/baselines/reference/es6ExportAllInEs5.types @@ -11,11 +11,11 @@ export module m { export var x = 10; >x : number ->10 : number +>10 : 10 } export var x = 10; >x : number ->10 : number +>10 : 10 export module uninstantiated { >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClause.types b/tests/baselines/reference/es6ExportClause.types index 5cab90d6a7f..22e5f9c0e0d 100644 --- a/tests/baselines/reference/es6ExportClause.types +++ b/tests/baselines/reference/es6ExportClause.types @@ -11,11 +11,11 @@ module m { export var x = 10; >x : number ->10 : number +>10 : 10 } var x = 10; >x : number ->10 : number +>10 : 10 module uninstantiated { >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClauseInEs5.types b/tests/baselines/reference/es6ExportClauseInEs5.types index 5cab90d6a7f..22e5f9c0e0d 100644 --- a/tests/baselines/reference/es6ExportClauseInEs5.types +++ b/tests/baselines/reference/es6ExportClauseInEs5.types @@ -11,11 +11,11 @@ module m { export var x = 10; >x : number ->10 : number +>10 : 10 } var x = 10; >x : number ->10 : number +>10 : 10 module uninstantiated { >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.types b/tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.types index 3b6752d89db..f846063c7ef 100644 --- a/tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithAssignmentInEs5.types @@ -2,34 +2,34 @@ var foo = 2; >foo : number ->2 : number +>2 : 2 foo = 3; ->foo = 3 : number +>foo = 3 : 3 >foo : number ->3 : number +>3 : 3 var baz = 3; >baz : number ->3 : number +>3 : 3 baz = 4; ->baz = 4 : number +>baz = 4 : 4 >baz : number ->4 : number +>4 : 4 var buzz = 10; >buzz : number ->10 : number +>10 : 10 buzz += 3; >buzz += 3 : number >buzz : number ->3 : number +>3 : 3 var bizz = 8; >bizz : number ->8 : number +>8 : 8 bizz++; // compiles to exports.bizz = bizz += 1 >bizz++ : number diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types index 6b621f4c777..748f731f918 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifier.types @@ -11,11 +11,11 @@ export module m { export var x = 10; >x : number ->10 : number +>10 : 10 } export var x = 10; >x : number ->10 : number +>10 : 10 export module uninstantiated { >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types index 4bd93b39031..496717c3a85 100644 --- a/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types +++ b/tests/baselines/reference/es6ExportClauseWithoutModuleSpecifierInEs5.types @@ -11,11 +11,11 @@ export module m { export var x = 10; >x : number ->10 : number +>10 : 10 } export var x = 10; >x : number ->10 : number +>10 : 10 export module uninstantiated { >uninstantiated : any diff --git a/tests/baselines/reference/es6ExportDefaultExpression.types b/tests/baselines/reference/es6ExportDefaultExpression.types index 6f7665c2800..1e6a38482b6 100644 --- a/tests/baselines/reference/es6ExportDefaultExpression.types +++ b/tests/baselines/reference/es6ExportDefaultExpression.types @@ -3,6 +3,6 @@ export default (1 + 2); >(1 + 2) : number >1 + 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/es6ImportDefaultBinding.types b/tests/baselines/reference/es6ImportDefaultBinding.types index 6aa71ddf6ff..f538ee8127b 100644 --- a/tests/baselines/reference/es6ImportDefaultBinding.types +++ b/tests/baselines/reference/es6ImportDefaultBinding.types @@ -2,7 +2,7 @@ var a = 10; >a : number ->10 : number +>10 : 10 export default a; >a : number diff --git a/tests/baselines/reference/es6ImportDefaultBindingAmd.types b/tests/baselines/reference/es6ImportDefaultBindingAmd.types index 740ff2c0e14..824c5568b17 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingAmd.types +++ b/tests/baselines/reference/es6ImportDefaultBindingAmd.types @@ -2,7 +2,7 @@ var a = 10; >a : number ->10 : number +>10 : 10 export default a; >a : number diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types index fe0137403a9..0fba9c6390c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamedImport.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 export var x = a; >x : number diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types index 6d3f015c783..a97100c662c 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1.types @@ -2,7 +2,7 @@ var a = 10; >a : number ->10 : number +>10 : 10 export default a; >a : number diff --git a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types index 4f9c618f10c..18dc5efe226 100644 --- a/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types +++ b/tests/baselines/reference/es6ImportDefaultBindingFollowedWithNamespaceBinding1InEs5.types @@ -2,7 +2,7 @@ var a = 10; >a : number ->10 : number +>10 : 10 export default a; >a : number diff --git a/tests/baselines/reference/es6ImportNameSpaceImport.types b/tests/baselines/reference/es6ImportNameSpaceImport.types index 56ee0c4d87a..6b73fb90bce 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImport.types +++ b/tests/baselines/reference/es6ImportNameSpaceImport.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportNameSpaceImport_1.ts === import * as nameSpaceBinding from "./es6ImportNameSpaceImport_0"; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportAmd.types b/tests/baselines/reference/es6ImportNameSpaceImportAmd.types index beb6860c73e..96cd4e603ea 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportAmd.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportAmd.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportNameSpaceImportAmd_1.ts === import * as nameSpaceBinding from "es6ImportNameSpaceImportAmd_0"; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types index 13631060813..81971078849 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportInEs5.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportNameSpaceImportInEs5_1.ts === import * as nameSpaceBinding from "./es6ImportNameSpaceImportInEs5_0"; diff --git a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types index 4aaf33d5930..041100c7678 100644 --- a/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types +++ b/tests/baselines/reference/es6ImportNameSpaceImportNoNamedExports.types @@ -2,7 +2,7 @@ var a = 10; >a : number ->10 : number +>10 : 10 export = a; >a : number diff --git a/tests/baselines/reference/es6ImportNamedImport.types b/tests/baselines/reference/es6ImportNamedImport.types index bd7c43d7031..0ac3789c5e0 100644 --- a/tests/baselines/reference/es6ImportNamedImport.types +++ b/tests/baselines/reference/es6ImportNamedImport.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 export var x = a; >x : number @@ -14,23 +14,23 @@ export var m = a; export var a1 = 10; >a1 : number ->10 : number +>10 : 10 export var x1 = 10; >x1 : number ->10 : number +>10 : 10 export var z1 = 10; >z1 : number ->10 : number +>10 : 10 export var z2 = 10; >z2 : number ->10 : number +>10 : 10 export var aaaa = 10; >aaaa : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportNamedImport_1.ts === import { } from "./es6ImportNamedImport_0"; diff --git a/tests/baselines/reference/es6ImportNamedImportAmd.types b/tests/baselines/reference/es6ImportNamedImportAmd.types index 45ca9c08547..897187a5a0d 100644 --- a/tests/baselines/reference/es6ImportNamedImportAmd.types +++ b/tests/baselines/reference/es6ImportNamedImportAmd.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 export var x = a; >x : number @@ -14,23 +14,23 @@ export var m = a; export var a1 = 10; >a1 : number ->10 : number +>10 : 10 export var x1 = 10; >x1 : number ->10 : number +>10 : 10 export var z1 = 10; >z1 : number ->10 : number +>10 : 10 export var z2 = 10; >z2 : number ->10 : number +>10 : 10 export var aaaa = 10; >aaaa : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportNamedImportAmd_1.ts === import { } from "es6ImportNamedImportAmd_0"; diff --git a/tests/baselines/reference/es6ImportNamedImportInEs5.types b/tests/baselines/reference/es6ImportNamedImportInEs5.types index 1d55b4bf51e..f2af5280fc2 100644 --- a/tests/baselines/reference/es6ImportNamedImportInEs5.types +++ b/tests/baselines/reference/es6ImportNamedImportInEs5.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 export var x = a; >x : number @@ -14,23 +14,23 @@ export var m = a; export var a1 = 10; >a1 : number ->10 : number +>10 : 10 export var x1 = 10; >x1 : number ->10 : number +>10 : 10 export var z1 = 10; >z1 : number ->10 : number +>10 : 10 export var z2 = 10; >z2 : number ->10 : number +>10 : 10 export var aaaa = 10; >aaaa : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportNamedImportInEs5_1.ts === import { } from "./es6ImportNamedImportInEs5_0"; diff --git a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types index 09023b6dd80..5b550c77a00 100644 --- a/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types +++ b/tests/baselines/reference/es6ImportNamedImportInExportAssignment.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportNamedImportInExportAssignment_1.ts === import { a } from "./es6ImportNamedImportInExportAssignment_0"; diff --git a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types index a65a2978e1b..11c6caf3dbe 100644 --- a/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types +++ b/tests/baselines/reference/es6ImportNamedImportWithTypesAndValues.types @@ -18,7 +18,7 @@ export class C implements I { prop = "hello"; >prop : string ->"hello" : string +>"hello" : "hello" } export class C2 implements I2 { >C2 : C2 @@ -26,7 +26,7 @@ export class C2 implements I2 { prop2 = "world"; >prop2 : string ->"world" : string +>"world" : "world" } === tests/cases/compiler/client.ts === diff --git a/tests/baselines/reference/es6ImportWithoutFromClause.types b/tests/baselines/reference/es6ImportWithoutFromClause.types index d46a4a7487c..cd49acbcd0f 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClause.types +++ b/tests/baselines/reference/es6ImportWithoutFromClause.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportWithoutFromClause_1.ts === import "es6ImportWithoutFromClause_0"; diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.types b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.types index 3314b12d189..5099dee908b 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseAmd.types +++ b/tests/baselines/reference/es6ImportWithoutFromClauseAmd.types @@ -2,21 +2,21 @@ export var a = 10; >a : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportWithoutFromClauseAmd_1.ts === export var b = 10; >b : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportWithoutFromClauseAmd_2.ts === import "es6ImportWithoutFromClauseAmd_0"; import "es6ImportWithoutFromClauseAmd_2"; var _a = 10; >_a : number ->10 : number +>10 : 10 var _b = 10; >_b : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.types b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.types index ee95c07bb75..1e90de3223f 100644 --- a/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.types +++ b/tests/baselines/reference/es6ImportWithoutFromClauseInEs5.types @@ -2,7 +2,7 @@ export var a = 10; >a : number ->10 : number +>10 : 10 === tests/cases/compiler/es6ImportWithoutFromClauseInEs5_1.ts === import "es6ImportWithoutFromClauseInEs5_0"; diff --git a/tests/baselines/reference/es6Module.types b/tests/baselines/reference/es6Module.types index b55b58e8883..709dcef0e89 100644 --- a/tests/baselines/reference/es6Module.types +++ b/tests/baselines/reference/es6Module.types @@ -10,6 +10,6 @@ export class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6ModuleClassDeclaration.types b/tests/baselines/reference/es6ModuleClassDeclaration.types index e354d266abe..7b8e2ba26df 100644 --- a/tests/baselines/reference/es6ModuleClassDeclaration.types +++ b/tests/baselines/reference/es6ModuleClassDeclaration.types @@ -6,19 +6,19 @@ export class c { } private x = 10; >x : number ->10 : number +>10 : 10 public y = 30; >y : number ->30 : number +>30 : 30 static k = 20; >k : number ->20 : number +>20 : 20 private static l = 30; >l : number ->30 : number +>30 : 30 private method1() { >method1 : () => void @@ -40,19 +40,19 @@ class c2 { } private x = 10; >x : number ->10 : number +>10 : 10 public y = 30; >y : number ->30 : number +>30 : 30 static k = 20; >k : number ->20 : number +>20 : 20 private static l = 30; >l : number ->30 : number +>30 : 30 private method1() { >method1 : () => void @@ -85,19 +85,19 @@ export module m1 { } private x = 10; >x : number ->10 : number +>10 : 10 public y = 30; >y : number ->30 : number +>30 : 30 static k = 20; >k : number ->20 : number +>20 : 20 private static l = 30; >l : number ->30 : number +>30 : 30 private method1() { >method1 : () => void @@ -119,19 +119,19 @@ export module m1 { } private x = 10; >x : number ->10 : number +>10 : 10 public y = 30; >y : number ->30 : number +>30 : 30 static k = 20; >k : number ->20 : number +>20 : 20 private static l = 30; >l : number ->30 : number +>30 : 30 private method1() { >method1 : () => void @@ -172,19 +172,19 @@ module m2 { } private x = 10; >x : number ->10 : number +>10 : 10 public y = 30; >y : number ->30 : number +>30 : 30 static k = 20; >k : number ->20 : number +>20 : 20 private static l = 30; >l : number ->30 : number +>30 : 30 private method1() { >method1 : () => void @@ -206,19 +206,19 @@ module m2 { } private x = 10; >x : number ->10 : number +>10 : 10 public y = 30; >y : number ->30 : number +>30 : 30 static k = 20; >k : number ->20 : number +>20 : 20 private static l = 30; >l : number ->30 : number +>30 : 30 private method1() { >method1 : () => void diff --git a/tests/baselines/reference/es6ModuleConst.types b/tests/baselines/reference/es6ModuleConst.types index 99b9f7c2980..b83e39e61ad 100644 --- a/tests/baselines/reference/es6ModuleConst.types +++ b/tests/baselines/reference/es6ModuleConst.types @@ -1,11 +1,11 @@ === tests/cases/compiler/es6ModuleConst.ts === export const a = "hello"; ->a : string ->"hello" : string +>a : "hello" +>"hello" : "hello" export const x: string = a, y = x; >x : string ->a : string +>a : "hello" >y : string >x : string @@ -23,49 +23,49 @@ export module m1 { >m1 : typeof m1 export const k = a; ->k : string ->a : string +>k : "hello" +>a : "hello" export const l: string = b, m = k; >l : string >b : string ->m : string ->k : string +>m : "hello" +>k : "hello" const n = m1.k; ->n : string ->m1.k : string +>n : "hello" +>m1.k : "hello" >m1 : typeof m1 ->k : string +>k : "hello" const o: string = n, p = k; >o : string ->n : string ->p : string ->k : string +>n : "hello" +>p : "hello" +>k : "hello" } module m2 { >m2 : typeof m2 export const k = a; ->k : string ->a : string +>k : "hello" +>a : "hello" export const l: string = b, m = k; >l : string >b : string ->m : string ->k : string +>m : "hello" +>k : "hello" const n = m1.k; ->n : string ->m1.k : string +>n : "hello" +>m1.k : "hello" >m1 : typeof m1 ->k : string +>k : "hello" const o: string = n, p = k; >o : string ->n : string ->p : string ->k : string +>n : "hello" +>p : "hello" +>k : "hello" } diff --git a/tests/baselines/reference/es6ModuleConstEnumDeclaration.types b/tests/baselines/reference/es6ModuleConstEnumDeclaration.types index fae819f93b0..1ad8f9c4615 100644 --- a/tests/baselines/reference/es6ModuleConstEnumDeclaration.types +++ b/tests/baselines/reference/es6ModuleConstEnumDeclaration.types @@ -3,37 +3,37 @@ export const enum e1 { >e1 : e1 a, ->a : e1 +>a : e1.a b, ->b : e1 +>b : e1.b c ->c : e1 +>c : e1.c } const enum e2 { >e2 : e2 x, ->x : e2 +>x : e2.x y, ->y : e2 +>y : e2.y z ->z : e2 +>z : e2.z } var x = e1.a; >x : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y = e2.x; >y : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x export module m1 { >m1 : typeof m1 @@ -42,49 +42,49 @@ export module m1 { >e3 : e3 a, ->a : e3 +>a : e3.a b, ->b : e3 +>b : e3.b c ->c : e3 +>c : e3.c } const enum e4 { >e4 : e4 x, ->x : e4 +>x : e4.x y, ->y : e4 +>y : e4.y z ->z : e4 +>z : e4.z } var x1 = e1.a; >x1 : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y1 = e2.x; >y1 : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x var x2 = e3.a; >x2 : e3 ->e3.a : e3 +>e3.a : e3.a >e3 : typeof e3 ->a : e3 +>a : e3.a var y2 = e4.x; >y2 : e4 ->e4.x : e4 +>e4.x : e4.x >e4 : typeof e4 ->x : e4 +>x : e4.x } module m2 { >m2 : typeof m2 @@ -93,55 +93,55 @@ module m2 { >e5 : e5 a, ->a : e5 +>a : e5.a b, ->b : e5 +>b : e5.b c ->c : e5 +>c : e5.c } const enum e6 { >e6 : e6 x, ->x : e6 +>x : e6.x y, ->y : e6 +>y : e6.y z ->z : e6 +>z : e6.z } var x1 = e1.a; >x1 : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y1 = e2.x; >y1 : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x var x2 = e5.a; >x2 : e5 ->e5.a : e5 +>e5.a : e5.a >e5 : typeof e5 ->a : e5 +>a : e5.a var y2 = e6.x; >y2 : e6 ->e6.x : e6 +>e6.x : e6.x >e6 : typeof e6 ->x : e6 +>x : e6.x var x3 = m1.e3.a; >x3 : m1.e3 ->m1.e3.a : m1.e3 +>m1.e3.a : m1.e3.a >m1.e3 : typeof m1.e3 >m1 : typeof m1 >e3 : typeof m1.e3 ->a : m1.e3 +>a : m1.e3.a } diff --git a/tests/baselines/reference/es6ModuleConstEnumDeclaration2.types b/tests/baselines/reference/es6ModuleConstEnumDeclaration2.types index c43a938c9b6..ee0cb195a1a 100644 --- a/tests/baselines/reference/es6ModuleConstEnumDeclaration2.types +++ b/tests/baselines/reference/es6ModuleConstEnumDeclaration2.types @@ -4,37 +4,37 @@ export const enum e1 { >e1 : e1 a, ->a : e1 +>a : e1.a b, ->b : e1 +>b : e1.b c ->c : e1 +>c : e1.c } const enum e2 { >e2 : e2 x, ->x : e2 +>x : e2.x y, ->y : e2 +>y : e2.y z ->z : e2 +>z : e2.z } var x = e1.a; >x : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y = e2.x; >y : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x export module m1 { >m1 : typeof m1 @@ -43,49 +43,49 @@ export module m1 { >e3 : e3 a, ->a : e3 +>a : e3.a b, ->b : e3 +>b : e3.b c ->c : e3 +>c : e3.c } const enum e4 { >e4 : e4 x, ->x : e4 +>x : e4.x y, ->y : e4 +>y : e4.y z ->z : e4 +>z : e4.z } var x1 = e1.a; >x1 : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y1 = e2.x; >y1 : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x var x2 = e3.a; >x2 : e3 ->e3.a : e3 +>e3.a : e3.a >e3 : typeof e3 ->a : e3 +>a : e3.a var y2 = e4.x; >y2 : e4 ->e4.x : e4 +>e4.x : e4.x >e4 : typeof e4 ->x : e4 +>x : e4.x } module m2 { >m2 : typeof m2 @@ -94,55 +94,55 @@ module m2 { >e5 : e5 a, ->a : e5 +>a : e5.a b, ->b : e5 +>b : e5.b c ->c : e5 +>c : e5.c } const enum e6 { >e6 : e6 x, ->x : e6 +>x : e6.x y, ->y : e6 +>y : e6.y z ->z : e6 +>z : e6.z } var x1 = e1.a; >x1 : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y1 = e2.x; >y1 : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x var x2 = e5.a; >x2 : e5 ->e5.a : e5 +>e5.a : e5.a >e5 : typeof e5 ->a : e5 +>a : e5.a var y2 = e6.x; >y2 : e6 ->e6.x : e6 +>e6.x : e6.x >e6 : typeof e6 ->x : e6 +>x : e6.x var x3 = m1.e3.a; >x3 : m1.e3 ->m1.e3.a : m1.e3 +>m1.e3.a : m1.e3.a >m1.e3 : typeof m1.e3 >m1 : typeof m1 >e3 : typeof m1.e3 ->a : m1.e3 +>a : m1.e3.a } diff --git a/tests/baselines/reference/es6ModuleEnumDeclaration.types b/tests/baselines/reference/es6ModuleEnumDeclaration.types index 4b856fee009..10880510758 100644 --- a/tests/baselines/reference/es6ModuleEnumDeclaration.types +++ b/tests/baselines/reference/es6ModuleEnumDeclaration.types @@ -3,37 +3,37 @@ export enum e1 { >e1 : e1 a, ->a : e1 +>a : e1.a b, ->b : e1 +>b : e1.b c ->c : e1 +>c : e1.c } enum e2 { >e2 : e2 x, ->x : e2 +>x : e2.x y, ->y : e2 +>y : e2.y z ->z : e2 +>z : e2.z } var x = e1.a; >x : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y = e2.x; >y : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x export module m1 { >m1 : typeof m1 @@ -42,49 +42,49 @@ export module m1 { >e3 : e3 a, ->a : e3 +>a : e3.a b, ->b : e3 +>b : e3.b c ->c : e3 +>c : e3.c } enum e4 { >e4 : e4 x, ->x : e4 +>x : e4.x y, ->y : e4 +>y : e4.y z ->z : e4 +>z : e4.z } var x1 = e1.a; >x1 : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y1 = e2.x; >y1 : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x var x2 = e3.a; >x2 : e3 ->e3.a : e3 +>e3.a : e3.a >e3 : typeof e3 ->a : e3 +>a : e3.a var y2 = e4.x; >y2 : e4 ->e4.x : e4 +>e4.x : e4.x >e4 : typeof e4 ->x : e4 +>x : e4.x } module m2 { >m2 : typeof m2 @@ -93,55 +93,55 @@ module m2 { >e5 : e5 a, ->a : e5 +>a : e5.a b, ->b : e5 +>b : e5.b c ->c : e5 +>c : e5.c } enum e6 { >e6 : e6 x, ->x : e6 +>x : e6.x y, ->y : e6 +>y : e6.y z ->z : e6 +>z : e6.z } var x1 = e1.a; >x1 : e1 ->e1.a : e1 +>e1.a : e1.a >e1 : typeof e1 ->a : e1 +>a : e1.a var y1 = e2.x; >y1 : e2 ->e2.x : e2 +>e2.x : e2.x >e2 : typeof e2 ->x : e2 +>x : e2.x var x2 = e5.a; >x2 : e5 ->e5.a : e5 +>e5.a : e5.a >e5 : typeof e5 ->a : e5 +>a : e5.a var y2 = e6.x; >y2 : e6 ->e6.x : e6 +>e6.x : e6.x >e6 : typeof e6 ->x : e6 +>x : e6.x var x3 = m1.e3.a; >x3 : m1.e3 ->m1.e3.a : m1.e3 +>m1.e3.a : m1.e3.a >m1.e3 : typeof m1.e3 >m1 : typeof m1 >e3 : typeof m1.e3 ->a : m1.e3 +>a : m1.e3.a } diff --git a/tests/baselines/reference/es6ModuleInternalImport.types b/tests/baselines/reference/es6ModuleInternalImport.types index 5d7fd527afd..08dc2a9bcbe 100644 --- a/tests/baselines/reference/es6ModuleInternalImport.types +++ b/tests/baselines/reference/es6ModuleInternalImport.types @@ -4,7 +4,7 @@ export module m { export var a = 10; >a : number ->10 : number +>10 : 10 } export import a1 = m.a; >a1 : number diff --git a/tests/baselines/reference/es6ModuleLet.types b/tests/baselines/reference/es6ModuleLet.types index 9e670c0a1e1..a8bfb89dd6e 100644 --- a/tests/baselines/reference/es6ModuleLet.types +++ b/tests/baselines/reference/es6ModuleLet.types @@ -1,7 +1,7 @@ === tests/cases/compiler/es6ModuleLet.ts === export let a = "hello"; >a : string ->"hello" : string +>"hello" : "hello" export let x: string = a, y = x; >x : string diff --git a/tests/baselines/reference/es6ModuleModuleDeclaration.types b/tests/baselines/reference/es6ModuleModuleDeclaration.types index 6fb5a7c98f5..4e0f309457b 100644 --- a/tests/baselines/reference/es6ModuleModuleDeclaration.types +++ b/tests/baselines/reference/es6ModuleModuleDeclaration.types @@ -4,33 +4,33 @@ export module m1 { export var a = 10; >a : number ->10 : number +>10 : 10 var b = 10; >b : number ->10 : number +>10 : 10 export module innerExportedModule { >innerExportedModule : typeof innerExportedModule export var k = 10; >k : number ->10 : number +>10 : 10 var l = 10; >l : number ->10 : number +>10 : 10 } export module innerNonExportedModule { >innerNonExportedModule : typeof innerNonExportedModule export var x = 10; >x : number ->10 : number +>10 : 10 var y = 10; >y : number ->10 : number +>10 : 10 } } module m2 { @@ -38,32 +38,32 @@ module m2 { export var a = 10; >a : number ->10 : number +>10 : 10 var b = 10; >b : number ->10 : number +>10 : 10 export module innerExportedModule { >innerExportedModule : typeof innerExportedModule export var k = 10; >k : number ->10 : number +>10 : 10 var l = 10; >l : number ->10 : number +>10 : 10 } export module innerNonExportedModule { >innerNonExportedModule : typeof innerNonExportedModule export var x = 10; >x : number ->10 : number +>10 : 10 var y = 10; >y : number ->10 : number +>10 : 10 } } diff --git a/tests/baselines/reference/es6ModuleVariableStatement.types b/tests/baselines/reference/es6ModuleVariableStatement.types index 520430199e4..00278b6511c 100644 --- a/tests/baselines/reference/es6ModuleVariableStatement.types +++ b/tests/baselines/reference/es6ModuleVariableStatement.types @@ -1,7 +1,7 @@ === tests/cases/compiler/es6ModuleVariableStatement.ts === export var a = "hello"; >a : string ->"hello" : string +>"hello" : "hello" export var x: string = a, y = x; >x : string diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types index 067ceb005e8..90b9afbe02e 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetAmd.types @@ -10,6 +10,6 @@ export class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types index 58f0f89f955..31fc40eeabd 100644 --- a/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types +++ b/tests/baselines/reference/es6ModuleWithModuleGenTargetCommonjs.types @@ -10,6 +10,6 @@ export class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6modulekind.types b/tests/baselines/reference/es6modulekind.types index d7fde0c7d44..8994eb6657a 100644 --- a/tests/baselines/reference/es6modulekind.types +++ b/tests/baselines/reference/es6modulekind.types @@ -12,6 +12,6 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6modulekindWithES2015Target.types b/tests/baselines/reference/es6modulekindWithES2015Target.types index 63acdae43d1..313fb612d8e 100644 --- a/tests/baselines/reference/es6modulekindWithES2015Target.types +++ b/tests/baselines/reference/es6modulekindWithES2015Target.types @@ -12,6 +12,6 @@ export default class A >B : () => number { return 42; ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/es6modulekindWithES5Target.types b/tests/baselines/reference/es6modulekindWithES5Target.types index f7232f20494..4b620fb9e17 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target.types +++ b/tests/baselines/reference/es6modulekindWithES5Target.types @@ -5,11 +5,11 @@ export class C { static s = 0; >s : number ->0 : number +>0 : 0 p = 1; >p : number ->1 : number +>1 : 1 method() { } >method : () => void @@ -30,11 +30,11 @@ export class D { static s = 0; >s : number ->0 : number +>0 : 0 p = 1; >p : number ->1 : number +>1 : 1 method() { } >method : () => void diff --git a/tests/baselines/reference/es6modulekindWithES5Target11.types b/tests/baselines/reference/es6modulekindWithES5Target11.types index 51fbe371017..e3d922c0443 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target11.types +++ b/tests/baselines/reference/es6modulekindWithES5Target11.types @@ -18,11 +18,11 @@ export default class C { static y = 1 >y : number ->1 : number +>1 : 1 p = 1; >p : number ->1 : number +>1 : 1 method() { } >method : () => void diff --git a/tests/baselines/reference/es6modulekindWithES5Target2.types b/tests/baselines/reference/es6modulekindWithES5Target2.types index 04b5e5b9905..6ad697e0c25 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target2.types +++ b/tests/baselines/reference/es6modulekindWithES5Target2.types @@ -5,11 +5,11 @@ export default class C { static s = 0; >s : number ->0 : number +>0 : 0 p = 1; >p : number ->1 : number +>1 : 1 method() { } >method : () => void diff --git a/tests/baselines/reference/es6modulekindWithES5Target3.types b/tests/baselines/reference/es6modulekindWithES5Target3.types index 5bc8c69c01a..78928f56ddd 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target3.types +++ b/tests/baselines/reference/es6modulekindWithES5Target3.types @@ -13,11 +13,11 @@ export default class D { static s = 0; >s : number ->0 : number +>0 : 0 p = 1; >p : number ->1 : number +>1 : 1 method() { } >method : () => void diff --git a/tests/baselines/reference/es6modulekindWithES5Target6.types b/tests/baselines/reference/es6modulekindWithES5Target6.types index 932493ef063..de43a987d4d 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target6.types +++ b/tests/baselines/reference/es6modulekindWithES5Target6.types @@ -3,7 +3,7 @@ export function f1(d = 0) { >f1 : (d?: number) => void >d : number ->0 : number +>0 : 0 } export function f2(...arg) { @@ -14,6 +14,6 @@ export function f2(...arg) { export default function f3(d = 0) { >f3 : (d?: number) => void >d : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/es6modulekindWithES5Target7.types b/tests/baselines/reference/es6modulekindWithES5Target7.types index f1404c7883a..1c3add3b031 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target7.types +++ b/tests/baselines/reference/es6modulekindWithES5Target7.types @@ -5,7 +5,7 @@ export namespace N { var x = 0; >x : number ->0 : number +>0 : 0 } export namespace N2 { diff --git a/tests/baselines/reference/es6modulekindWithES5Target8.types b/tests/baselines/reference/es6modulekindWithES5Target8.types index 4017b02a471..754decea312 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target8.types +++ b/tests/baselines/reference/es6modulekindWithES5Target8.types @@ -1,10 +1,10 @@ === tests/cases/compiler/es6modulekindWithES5Target8.ts === export const c = 0; ->c : number ->0 : number +>c : 0 +>0 : 0 export let l = 1; >l : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/escapedIdentifiers.types b/tests/baselines/reference/escapedIdentifiers.types index 151408de308..e7f19d7144c 100644 --- a/tests/baselines/reference/escapedIdentifiers.types +++ b/tests/baselines/reference/escapedIdentifiers.types @@ -14,7 +14,7 @@ // var decl var \u0061 = 1; >\u0061 : number ->1 : number +>1 : 1 a ++; >a ++ : number @@ -26,7 +26,7 @@ a ++; var b = 1; >b : number ->1 : number +>1 : 1 b ++; >b ++ : number @@ -51,32 +51,32 @@ module moduleType\u0032 { } moduleType1.baz1 = 3; ->moduleType1.baz1 = 3 : number +>moduleType1.baz1 = 3 : 3 >moduleType1.baz1 : number >moduleType1 : typeof moduleType1 >baz1 : number ->3 : number +>3 : 3 moduleType\u0031.baz1 = 3; ->moduleType\u0031.baz1 = 3 : number +>moduleType\u0031.baz1 = 3 : 3 >moduleType\u0031.baz1 : number >moduleType\u0031 : typeof moduleType1 >baz1 : number ->3 : number +>3 : 3 moduleType2.baz2 = 3; ->moduleType2.baz2 = 3 : number +>moduleType2.baz2 = 3 : 3 >moduleType2.baz2 : number >moduleType2 : typeof moduleType\u0032 >baz2 : number ->3 : number +>3 : 3 moduleType\u0032.baz2 = 3; ->moduleType\u0032.baz2 = 3 : number +>moduleType\u0032.baz2 = 3 : 3 >moduleType\u0032.baz2 : number >moduleType\u0032 : typeof moduleType\u0032 >baz2 : number ->3 : number +>3 : 3 // classes @@ -99,11 +99,11 @@ var classType1Object1 = new classType1(); >classType1 : typeof classType1 classType1Object1.foo1 = 2; ->classType1Object1.foo1 = 2 : number +>classType1Object1.foo1 = 2 : 2 >classType1Object1.foo1 : number >classType1Object1 : classType1 >foo1 : number ->2 : number +>2 : 2 var classType1Object2 = new classType\u0031(); >classType1Object2 : classType1 @@ -111,11 +111,11 @@ var classType1Object2 = new classType\u0031(); >classType\u0031 : typeof classType1 classType1Object2.foo1 = 2; ->classType1Object2.foo1 = 2 : number +>classType1Object2.foo1 = 2 : 2 >classType1Object2.foo1 : number >classType1Object2 : classType1 >foo1 : number ->2 : number +>2 : 2 var classType2Object1 = new classType2(); >classType2Object1 : classType\u0032 @@ -123,11 +123,11 @@ var classType2Object1 = new classType2(); >classType2 : typeof classType\u0032 classType2Object1.foo2 = 2; ->classType2Object1.foo2 = 2 : number +>classType2Object1.foo2 = 2 : 2 >classType2Object1.foo2 : number >classType2Object1 : classType\u0032 >foo2 : number ->2 : number +>2 : 2 var classType2Object2 = new classType\u0032(); >classType2Object2 : classType\u0032 @@ -135,11 +135,11 @@ var classType2Object2 = new classType\u0032(); >classType\u0032 : typeof classType\u0032 classType2Object2.foo2 = 2; ->classType2Object2.foo2 = 2 : number +>classType2Object2.foo2 = 2 : 2 >classType2Object2.foo2 : number >classType2Object2 : classType\u0032 >foo2 : number ->2 : number +>2 : 2 // interfaces interface interfaceType1 { @@ -161,14 +161,14 @@ var interfaceType1Object1 = { bar1: 0 }; >interfaceType1 : interfaceType1 >{ bar1: 0 } : { bar1: number; } >bar1 : number ->0 : number +>0 : 0 interfaceType1Object1.bar1 = 2; ->interfaceType1Object1.bar1 = 2 : number +>interfaceType1Object1.bar1 = 2 : 2 >interfaceType1Object1.bar1 : number >interfaceType1Object1 : interfaceType1 >bar1 : number ->2 : number +>2 : 2 var interfaceType1Object2 = { bar1: 0 }; >interfaceType1Object2 : interfaceType1 @@ -176,14 +176,14 @@ var interfaceType1Object2 = { bar1: 0 }; >interfaceType\u0031 : interfaceType1 >{ bar1: 0 } : { bar1: number; } >bar1 : number ->0 : number +>0 : 0 interfaceType1Object2.bar1 = 2; ->interfaceType1Object2.bar1 = 2 : number +>interfaceType1Object2.bar1 = 2 : 2 >interfaceType1Object2.bar1 : number >interfaceType1Object2 : interfaceType1 >bar1 : number ->2 : number +>2 : 2 var interfaceType2Object1 = { bar2: 0 }; >interfaceType2Object1 : interfaceType\u0032 @@ -191,14 +191,14 @@ var interfaceType2Object1 = { bar2: 0 }; >interfaceType2 : interfaceType\u0032 >{ bar2: 0 } : { bar2: number; } >bar2 : number ->0 : number +>0 : 0 interfaceType2Object1.bar2 = 2; ->interfaceType2Object1.bar2 = 2 : number +>interfaceType2Object1.bar2 = 2 : 2 >interfaceType2Object1.bar2 : number >interfaceType2Object1 : interfaceType\u0032 >bar2 : number ->2 : number +>2 : 2 var interfaceType2Object2 = { bar2: 0 }; >interfaceType2Object2 : interfaceType\u0032 @@ -206,14 +206,14 @@ var interfaceType2Object2 = { bar2: 0 }; >interfaceType\u0032 : interfaceType\u0032 >{ bar2: 0 } : { bar2: number; } >bar2 : number ->0 : number +>0 : 0 interfaceType2Object2.bar2 = 2; ->interfaceType2Object2.bar2 = 2 : number +>interfaceType2Object2.bar2 = 2 : 2 >interfaceType2Object2.bar2 : number >interfaceType2Object2 : interfaceType\u0032 >bar2 : number ->2 : number +>2 : 2 // arguments @@ -228,14 +228,14 @@ class testClass { >arg4 : number arg\u0031 = 1; ->arg\u0031 = 1 : number +>arg\u0031 = 1 : 1 >arg\u0031 : number ->1 : number +>1 : 1 arg2 = 'string'; ->arg2 = 'string' : string +>arg2 = 'string' : "string" >arg2 : string ->'string' : string +>'string' : "string" arg\u0033 = true; >arg\u0033 = true : true @@ -243,9 +243,9 @@ class testClass { >true : true arg4 = 2; ->arg4 = 2 : number +>arg4 = 2 : 2 >arg4 : number ->2 : number +>2 : 2 } } @@ -264,24 +264,24 @@ var constructorTestObject = new constructorTestClass(1, 'string', true, 2); >constructorTestObject : constructorTestClass >new constructorTestClass(1, 'string', true, 2) : constructorTestClass >constructorTestClass : typeof constructorTestClass ->1 : number ->'string' : string +>1 : 1 +>'string' : "string" >true : true ->2 : number +>2 : 2 constructorTestObject.arg\u0031 = 1; ->constructorTestObject.arg\u0031 = 1 : number +>constructorTestObject.arg\u0031 = 1 : 1 >constructorTestObject.arg\u0031 : number >constructorTestObject : constructorTestClass >arg\u0031 : number ->1 : number +>1 : 1 constructorTestObject.arg2 = 'string'; ->constructorTestObject.arg2 = 'string' : string +>constructorTestObject.arg2 = 'string' : "string" >constructorTestObject.arg2 : string >constructorTestObject : constructorTestClass >arg2 : string ->'string' : string +>'string' : "string" constructorTestObject.arg\u0033 = true; >constructorTestObject.arg\u0033 = true : true @@ -291,11 +291,11 @@ constructorTestObject.arg\u0033 = true; >true : true constructorTestObject.arg4 = 2; ->constructorTestObject.arg4 = 2 : number +>constructorTestObject.arg4 = 2 : 2 >constructorTestObject.arg4 : number >constructorTestObject : constructorTestClass >arg4 : number ->2 : number +>2 : 2 // Lables @@ -303,10 +303,10 @@ l\u0061bel1: >l\u0061bel1 : any while (false) ->false : boolean +>false : false { while(false) ->false : boolean +>false : false continue label1; // it will go to next iteration of outer loop >label1 : any @@ -316,10 +316,10 @@ label2: >label2 : any while (false) ->false : boolean +>false : false { while(false) ->false : boolean +>false : false continue l\u0061bel2; // it will go to next iteration of outer loop >l\u0061bel2 : any @@ -329,10 +329,10 @@ label3: >label3 : any while (false) ->false : boolean +>false : false { while(false) ->false : boolean +>false : false continue label3; // it will go to next iteration of outer loop >label3 : any @@ -342,10 +342,10 @@ l\u0061bel4: >l\u0061bel4 : any while (false) ->false : boolean +>false : false { while(false) ->false : boolean +>false : false continue l\u0061bel4; // it will go to next iteration of outer loop >l\u0061bel4 : any diff --git a/tests/baselines/reference/escapedReservedCompilerNamedIdentifier.types b/tests/baselines/reference/escapedReservedCompilerNamedIdentifier.types index 1ebbf8aedb2..1cecaaa74f0 100644 --- a/tests/baselines/reference/escapedReservedCompilerNamedIdentifier.types +++ b/tests/baselines/reference/escapedReservedCompilerNamedIdentifier.types @@ -2,21 +2,21 @@ // double underscores var __proto__ = 10; >__proto__ : number ->10 : number +>10 : 10 var o = { >o : { "__proto__": number; } >{ "__proto__": 0} : { "__proto__": number; } "__proto__": 0 ->0 : number +>0 : 0 }; var b = o["__proto__"]; >b : number >o["__proto__"] : number >o : { "__proto__": number; } ->"__proto__" : string +>"__proto__" : "___proto__" var o1 = { >o1 : { __proto__: number; } @@ -24,33 +24,33 @@ var o1 = { __proto__: 0 >__proto__ : number ->0 : number +>0 : 0 }; var b1 = o1["__proto__"]; >b1 : number >o1["__proto__"] : number >o1 : { __proto__: number; } ->"__proto__" : string +>"__proto__" : "___proto__" // Triple underscores var ___proto__ = 10; >___proto__ : number ->10 : number +>10 : 10 var o2 = { >o2 : { "___proto__": number; } >{ "___proto__": 0} : { "___proto__": number; } "___proto__": 0 ->0 : number +>0 : 0 }; var b2 = o2["___proto__"]; >b2 : number >o2["___proto__"] : number >o2 : { "___proto__": number; } ->"___proto__" : string +>"___proto__" : "____proto__" var o3 = { >o3 : { ___proto__: number; } @@ -58,33 +58,33 @@ var o3 = { ___proto__: 0 >___proto__ : number ->0 : number +>0 : 0 }; var b3 = o3["___proto__"]; >b3 : number >o3["___proto__"] : number >o3 : { ___proto__: number; } ->"___proto__" : string +>"___proto__" : "____proto__" // One underscore var _proto__ = 10; >_proto__ : number ->10 : number +>10 : 10 var o4 = { >o4 : { "_proto__": number; } >{ "_proto__": 0} : { "_proto__": number; } "_proto__": 0 ->0 : number +>0 : 0 }; var b4 = o4["_proto__"]; >b4 : number >o4["_proto__"] : number >o4 : { "_proto__": number; } ->"_proto__" : string +>"_proto__" : "_proto__" var o5 = { >o5 : { _proto__: number; } @@ -92,12 +92,12 @@ var o5 = { _proto__: 0 >_proto__ : number ->0 : number +>0 : 0 }; var b5 = o5["_proto__"]; >b5 : number >o5["_proto__"] : number >o5 : { _proto__: number; } ->"_proto__" : string +>"_proto__" : "_proto__" diff --git a/tests/baselines/reference/everyTypeWithAnnotationAndInitializer.types b/tests/baselines/reference/everyTypeWithAnnotationAndInitializer.types index 0e7059f4eed..a3f2d3e3149 100644 --- a/tests/baselines/reference/everyTypeWithAnnotationAndInitializer.types +++ b/tests/baselines/reference/everyTypeWithAnnotationAndInitializer.types @@ -37,7 +37,7 @@ class D{ function F(x: string): number { return 42; } >F : (x: string) => number >x : string ->42 : number +>42 : 42 module M { >M : typeof M @@ -60,18 +60,18 @@ module M { var aNumber: number = 9.9; >aNumber : number ->9.9 : number +>9.9 : 9.9 var aString: string = 'this is a string'; >aString : string ->'this is a string' : string +>'this is a string' : "this is a string" var aDate: Date = new Date(12); >aDate : Date >Date : Date >new Date(12) : Date >Date : DateConstructor ->12 : number +>12 : 12 var anObject: Object = new Object(); >anObject : Object @@ -114,7 +114,7 @@ var anObjectLiteral: I = { id: 12 }; >I : I >{ id: 12 } : { id: number; } >id : number ->12 : number +>12 : 12 var anOtherObjectLiteral: { id: number } = new C(); >anOtherObjectLiteral : { id: number; } @@ -135,9 +135,9 @@ var anOtherFunction: (x: string) => number = F; var aLambda: typeof F = (x) => 2; >aLambda : (x: string) => number >F : (x: string) => number ->(x) => 2 : (x: string) => number +>(x) => 2 : (x: string) => 2 >x : string ->2 : number +>2 : 2 var aModule: typeof M = M; >aModule : typeof M @@ -158,8 +158,8 @@ var aFunctionInModule: typeof M.F2 = (x) => 'this is a string'; >M.F2 : (x: number) => string >M : typeof M >F2 : (x: number) => string ->(x) => 'this is a string' : (x: number) => string +>(x) => 'this is a string' : (x: number) => "this is a string" >x : number ->'this is a string' : string +>'this is a string' : "this is a string" diff --git a/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt b/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt index 13c2058b657..c110ce1d6c6 100644 --- a/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt +++ b/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt @@ -1,7 +1,7 @@ -tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(34,5): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(35,5): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(36,5): error TS2322: Type 'number' is not assignable to type 'Date'. -tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(38,5): error TS2322: Type 'number' is not assignable to type 'void'. +tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(34,5): error TS2322: Type '"this is a string"' is not assignable to type 'number'. +tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(35,5): error TS2322: Type '9.9' is not assignable to type 'string'. +tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(36,5): error TS2322: Type '9.9' is not assignable to type 'Date'. +tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(38,5): error TS2322: Type '9.9' is not assignable to type 'void'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(40,5): error TS2322: Type 'D<{}>' is not assignable to type 'I'. Property 'id' is missing in type 'D<{}>'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(41,5): error TS2322: Type 'D<{}>' is not assignable to type 'C'. @@ -20,8 +20,8 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(47,5): error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: string) => number'. Types of parameters 'x' and 'x' are incompatible. Type 'string' is not assignable to type 'number'. -tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(48,5): error TS2322: Type '(x: string) => string' is not assignable to type '(x: string) => number'. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(48,5): error TS2322: Type '(x: string) => "a string"' is not assignable to type '(x: string) => number'. + Type '"a string"' is not assignable to type 'number'. tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(50,5): error TS2322: Type 'typeof N' is not assignable to type 'typeof M'. Types of property 'A' are incompatible. Type 'typeof N.A' is not assignable to type 'typeof M.A'. @@ -68,17 +68,17 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd var aNumber: number = 'this is a string'; ~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"this is a string"' is not assignable to type 'number'. var aString: string = 9.9; ~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '9.9' is not assignable to type 'string'. var aDate: Date = 9.9; ~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'Date'. +!!! error TS2322: Type '9.9' is not assignable to type 'Date'. var aVoid: void = 9.9; ~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'void'. +!!! error TS2322: Type '9.9' is not assignable to type 'void'. var anInterface: I = new D(); ~~~~~~~~~~~ @@ -115,8 +115,8 @@ tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAnd !!! error TS2322: Type 'string' is not assignable to type 'number'. var aLambda: typeof F = (x) => 'a string'; ~~~~~~~ -!!! error TS2322: Type '(x: string) => string' is not assignable to type '(x: string) => number'. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '(x: string) => "a string"' is not assignable to type '(x: string) => number'. +!!! error TS2322: Type '"a string"' is not assignable to type 'number'. var aModule: typeof M = N; ~~~~~~~ diff --git a/tests/baselines/reference/everyTypeWithInitializer.types b/tests/baselines/reference/everyTypeWithInitializer.types index abc0e770e35..947eff14f7f 100644 --- a/tests/baselines/reference/everyTypeWithInitializer.types +++ b/tests/baselines/reference/everyTypeWithInitializer.types @@ -37,7 +37,7 @@ class D{ function F(x: string): number { return 42; } >F : (x: string) => number >x : string ->42 : number +>42 : 42 module M { >M : typeof M @@ -60,17 +60,17 @@ module M { var aNumber = 9.9; >aNumber : number ->9.9 : number +>9.9 : 9.9 var aString = 'this is a string'; >aString : string ->'this is a string' : string +>'this is a string' : "this is a string" var aDate = new Date(12); >aDate : Date >new Date(12) : Date >Date : DateConstructor ->12 : number +>12 : 12 var anObject = new Object(); >anObject : Object @@ -106,7 +106,7 @@ var anObjectLiteral = { id: 12 }; >anObjectLiteral : { id: number; } >{ id: 12 } : { id: number; } >id : number ->12 : number +>12 : 12 var aFunction = F; >aFunction : (x: string) => number @@ -116,7 +116,7 @@ var aLambda = (x) => 2; >aLambda : (x: any) => number >(x) => 2 : (x: any) => number >x : any ->2 : number +>2 : 2 var aModule = M; >aModule : typeof M diff --git a/tests/baselines/reference/excessPropertyErrorsSuppressed.types b/tests/baselines/reference/excessPropertyErrorsSuppressed.types index 47a4dbf92a9..c0b8f66d840 100644 --- a/tests/baselines/reference/excessPropertyErrorsSuppressed.types +++ b/tests/baselines/reference/excessPropertyErrorsSuppressed.types @@ -5,7 +5,7 @@ var x: { a: string } = { a: "hello", b: 42 }; // No error >a : string >{ a: "hello", b: 42 } : { a: string; b: number; } >a : string ->"hello" : string +>"hello" : "hello" >b : number ->42 : number +>42 : 42 diff --git a/tests/baselines/reference/exponentiationOperatorWithAnyAndNumber.types b/tests/baselines/reference/exponentiationOperatorWithAnyAndNumber.types index ec48b80f192..6e8b3cb3d2b 100644 --- a/tests/baselines/reference/exponentiationOperatorWithAnyAndNumber.types +++ b/tests/baselines/reference/exponentiationOperatorWithAnyAndNumber.types @@ -22,30 +22,30 @@ var r3 = a ** 0; >r3 : number >a ** 0 : number >a : any ->0 : number +>0 : 0 var r4 = 0 ** a; >r4 : number >0 ** a : number ->0 : number +>0 : 0 >a : any var r5 = 0 ** 0; >r5 : number >0 ** 0 : number ->0 : number ->0 : number +>0 : 0 +>0 : 0 var r6 = b ** 0; >r6 : number >b ** 0 : number >b : number ->0 : number +>0 : 0 var r7 = 0 ** b; >r7 : number >0 ** b : number ->0 : number +>0 : 0 >b : number var r8 = b ** b; diff --git a/tests/baselines/reference/exponentiationOperatorWithEnum.types b/tests/baselines/reference/exponentiationOperatorWithEnum.types index 037ff9d1261..9609e13000b 100644 --- a/tests/baselines/reference/exponentiationOperatorWithEnum.types +++ b/tests/baselines/reference/exponentiationOperatorWithEnum.types @@ -5,10 +5,10 @@ enum E { >E : E a, ->a : E +>a : E.a b ->b : E +>b : E.b } var a: any; @@ -55,58 +55,58 @@ var r5 = b ** c; var r6 = E.a ** a; >r6 : number >E.a ** a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var r7 = E.a ** b; >r7 : number >E.a ** b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var r8 = E.a ** E.b; >r8 : number >E.a ** E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var r9 = E.a ** 1; >r9 : number >E.a ** 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var r10 = a ** E.b; >r10 : number >a ** E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var r11 = b ** E.b; >r11 : number >b ** E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var r12 = 1 ** E.b; >r12 : number >1 ** E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b diff --git a/tests/baselines/reference/exponentiationOperatorWithEnumUnion.types b/tests/baselines/reference/exponentiationOperatorWithEnumUnion.types index 5be479b9e63..52b714d951f 100644 --- a/tests/baselines/reference/exponentiationOperatorWithEnumUnion.types +++ b/tests/baselines/reference/exponentiationOperatorWithEnumUnion.types @@ -5,19 +5,19 @@ enum E { >E : E a, ->a : E +>a : E.a b ->b : E +>b : E.b } enum F { >F : F c, ->c : F +>c : F.c d ->d : F +>d : F.d } var a: any; @@ -65,58 +65,58 @@ var r5 = b ** c; var r6 = E.a ** a; >r6 : number >E.a ** a : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >a : any var r7 = E.a ** b; >r7 : number >E.a ** b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a >b : number var r8 = E.a ** E.b; >r8 : number >E.a ** E.b : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->E.b : E +>a : E.a +>E.b : E.b >E : typeof E ->b : E +>b : E.b var r9 = E.a ** 1; >r9 : number >E.a ** 1 : number ->E.a : E +>E.a : E.a >E : typeof E ->a : E ->1 : number +>a : E.a +>1 : 1 var r10 = a ** E.b; >r10 : number >a ** E.b : number >a : any ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var r11 = b ** E.b; >r11 : number >b ** E.b : number >b : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b var r12 = 1 ** E.b; >r12 : number >1 ** E.b : number ->1 : number ->E.b : E +>1 : 1 +>E.b : E.b >E : typeof E ->b : E +>b : E.b diff --git a/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.types b/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.types index 2a3c4807763..3d9841a18ef 100644 --- a/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.types +++ b/tests/baselines/reference/exponentiationOperatorWithNullValueAndValidOperands.types @@ -6,10 +6,10 @@ enum E { >E : E a, ->a : E +>a : E.a b ->b : E +>b : E.b } var a: any; @@ -35,15 +35,15 @@ var r3 = null ** 1; >r3 : number >null ** 1 : number >null : null ->1 : number +>1 : 1 var r4 = null ** E.a; >r4 : number >null ** E.a : number >null : null ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var r5 = a ** null; >r5 : number @@ -60,14 +60,14 @@ var r6 = b ** null; var r7 = 0 ** null; >r7 : number >0 ** null : number ->0 : number +>0 : 0 >null : null var r8 = E.b ** null; >r8 : number >E.b ** null : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >null : null diff --git a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.types b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.types index 4e44144511e..7ccc43df30c 100644 --- a/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.types +++ b/tests/baselines/reference/exponentiationOperatorWithUndefinedValueAndValidOperands.types @@ -6,10 +6,10 @@ enum E { >E : E a, ->a : E +>a : E.a b ->b : E +>b : E.b } var a: any; @@ -35,15 +35,15 @@ var rk3 = undefined ** 1; >rk3 : number >undefined ** 1 : number >undefined : undefined ->1 : number +>1 : 1 var rk4 = undefined ** E.a; >rk4 : number >undefined ** E.a : number >undefined : undefined ->E.a : E +>E.a : E.a >E : typeof E ->a : E +>a : E.a var rk5 = a ** undefined; >rk5 : number @@ -60,14 +60,14 @@ var rk6 = b ** undefined; var rk7 = 0 ** undefined; >rk7 : number >0 ** undefined : number ->0 : number +>0 : 0 >undefined : undefined var rk8 = E.b ** undefined; >rk8 : number >E.b ** undefined : number ->E.b : E +>E.b : E.b >E : typeof E ->b : E +>b : E.b >undefined : undefined diff --git a/tests/baselines/reference/exportAssignDottedName.types b/tests/baselines/reference/exportAssignDottedName.types index 6fceb21231c..a2dd681ed8a 100644 --- a/tests/baselines/reference/exportAssignDottedName.types +++ b/tests/baselines/reference/exportAssignDottedName.types @@ -12,6 +12,6 @@ export function x(){ >x : () => boolean return true; ->true : boolean +>true : true } diff --git a/tests/baselines/reference/exportAssignImportedIdentifier.types b/tests/baselines/reference/exportAssignImportedIdentifier.types index e70de693624..f07e908695e 100644 --- a/tests/baselines/reference/exportAssignImportedIdentifier.types +++ b/tests/baselines/reference/exportAssignImportedIdentifier.types @@ -12,7 +12,7 @@ export function x(){ >x : () => boolean return true; ->true : boolean +>true : true } === tests/cases/conformance/externalModules/foo2.ts === diff --git a/tests/baselines/reference/exportAssignTypes.types b/tests/baselines/reference/exportAssignTypes.types index dc99d1512f1..a25a55bfd41 100644 --- a/tests/baselines/reference/exportAssignTypes.types +++ b/tests/baselines/reference/exportAssignTypes.types @@ -57,7 +57,7 @@ var v7: {(p1: x): x} = iGeneric; === tests/cases/conformance/externalModules/expString.ts === var x = "test"; >x : string ->"test" : string +>"test" : "test" export = x; >x : string @@ -65,7 +65,7 @@ export = x; === tests/cases/conformance/externalModules/expNumber.ts === var x = 42; >x : number ->42 : number +>42 : 42 export = x; >x : number @@ -73,7 +73,7 @@ export = x; === tests/cases/conformance/externalModules/expBoolean.ts === var x = true; >x : boolean ->true : boolean +>true : true export = x; >x : boolean @@ -82,8 +82,8 @@ export = x; var x = [1,2]; >x : number[] >[1,2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 export = x; >x : number[] @@ -93,9 +93,9 @@ var x = { answer: 42, when: 1776}; >x : { answer: number; when: number; } >{ answer: 42, when: 1776} : { answer: number; when: number; } >answer : number ->42 : number +>42 : 42 >when : number ->1776 : number +>1776 : 1776 export = x; >x : { answer: number; when: number; } diff --git a/tests/baselines/reference/exportAssignValueAndType.types b/tests/baselines/reference/exportAssignValueAndType.types index 2dc7442b9ac..221033220f5 100644 --- a/tests/baselines/reference/exportAssignValueAndType.types +++ b/tests/baselines/reference/exportAssignValueAndType.types @@ -21,7 +21,7 @@ interface server { var x = 5; >x : number ->5 : number +>5 : 5 var server = new Date(); >server : Date diff --git a/tests/baselines/reference/exportAssignmentClass.types b/tests/baselines/reference/exportAssignmentClass.types index b724c837244..6081d965584 100644 --- a/tests/baselines/reference/exportAssignmentClass.types +++ b/tests/baselines/reference/exportAssignmentClass.types @@ -17,7 +17,7 @@ var x = d.p; class C { public p = 0; } >C : C >p : number ->0 : number +>0 : 0 export = C; >C : C diff --git a/tests/baselines/reference/exportAssignmentConstrainedGenericType.errors.txt b/tests/baselines/reference/exportAssignmentConstrainedGenericType.errors.txt index cf63c48925f..5ba27334f5e 100644 --- a/tests/baselines/reference/exportAssignmentConstrainedGenericType.errors.txt +++ b/tests/baselines/reference/exportAssignmentConstrainedGenericType.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/externalModules/foo_1.ts(2,17): error TS2345: Argument of type 'boolean' is not assignable to parameter of type '{ a: string; b: number; }'. +tests/cases/conformance/externalModules/foo_1.ts(2,17): error TS2345: Argument of type 'true' is not assignable to parameter of type '{ a: string; b: number; }'. ==== tests/cases/conformance/externalModules/foo_1.ts (1 errors) ==== import foo = require("./foo_0"); var x = new foo(true); // Should error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type '{ a: string; b: number; }'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type '{ a: string; b: number; }'. var y = new foo({a: "test", b: 42}); // Should be OK var z: number = y.test.b; ==== tests/cases/conformance/externalModules/foo_0.ts (0 errors) ==== diff --git a/tests/baselines/reference/exportAssignmentEnum.types b/tests/baselines/reference/exportAssignmentEnum.types index a186cf6f255..23a3fd4d141 100644 --- a/tests/baselines/reference/exportAssignmentEnum.types +++ b/tests/baselines/reference/exportAssignmentEnum.types @@ -4,34 +4,34 @@ import EnumE = require("./exportAssignmentEnum_A"); var a = EnumE.A; >a : EnumE ->EnumE.A : EnumE +>EnumE.A : EnumE.A >EnumE : typeof EnumE ->A : EnumE +>A : EnumE.A var b = EnumE.B; >b : EnumE ->EnumE.B : EnumE +>EnumE.B : EnumE.B >EnumE : typeof EnumE ->B : EnumE +>B : EnumE.B var c = EnumE.C; >c : EnumE ->EnumE.C : EnumE +>EnumE.C : EnumE.C >EnumE : typeof EnumE ->C : EnumE +>C : EnumE.C === tests/cases/compiler/exportAssignmentEnum_A.ts === enum E { >E : E A, ->A : E +>A : E.A B, ->B : E +>B : E.B C, ->C : E +>C : E.C } export = E; diff --git a/tests/baselines/reference/exportAssignmentFunction.types b/tests/baselines/reference/exportAssignmentFunction.types index bd10465d221..e22cb061739 100644 --- a/tests/baselines/reference/exportAssignmentFunction.types +++ b/tests/baselines/reference/exportAssignmentFunction.types @@ -10,7 +10,7 @@ var n: number = fooFunc(); === tests/cases/compiler/exportAssignmentFunction_A.ts === function foo() { return 0; } >foo : () => number ->0 : number +>0 : 0 export = foo; >foo : () => number diff --git a/tests/baselines/reference/exportAssignmentMergedInterface.types b/tests/baselines/reference/exportAssignmentMergedInterface.types index 52978783f6d..2a7449a60fb 100644 --- a/tests/baselines/reference/exportAssignmentMergedInterface.types +++ b/tests/baselines/reference/exportAssignmentMergedInterface.types @@ -9,12 +9,12 @@ var x: foo; x("test"); >x("test") : void >x : foo ->"test" : string +>"test" : "test" x(42); >x(42) : number >x : foo ->42 : number +>42 : 42 var y: string = x.b; >y : string @@ -33,9 +33,9 @@ var z = {x: 1, y: 2}; >z : { x: number; y: number; } >{x: 1, y: 2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 z = x.d; >z = x.d : { x: number; y: number; } diff --git a/tests/baselines/reference/exportAssignmentMergedModule.types b/tests/baselines/reference/exportAssignmentMergedModule.types index 39f0d8d859e..239b65e08ad 100644 --- a/tests/baselines/reference/exportAssignmentMergedModule.types +++ b/tests/baselines/reference/exportAssignmentMergedModule.types @@ -27,7 +27,7 @@ if(!!foo.b){ >foo.c : (a: number) => number >foo : typeof foo >c : (a: number) => number ->42 : number +>42 : 42 } === tests/cases/conformance/externalModules/foo_0.ts === module Foo { @@ -37,11 +37,11 @@ module Foo { >a : () => number return 5; ->5 : number +>5 : 5 } export var b = true; >b : boolean ->true : boolean +>true : true } module Foo { >Foo : typeof Foo @@ -58,7 +58,7 @@ module Foo { export var answer = 42; >answer : number ->42 : number +>42 : 42 } } export = Foo; diff --git a/tests/baselines/reference/exportAssignmentTopLevelClodule.types b/tests/baselines/reference/exportAssignmentTopLevelClodule.types index a8a827ba9c3..559514129b7 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelClodule.types +++ b/tests/baselines/reference/exportAssignmentTopLevelClodule.types @@ -21,14 +21,14 @@ class Foo { test = "test"; >test : string ->"test" : string +>"test" : "test" } module Foo { >Foo : typeof Foo export var answer = 42; >answer : number ->42 : number +>42 : 42 } export = Foo; >Foo : Foo diff --git a/tests/baselines/reference/exportAssignmentTopLevelEnumdule.types b/tests/baselines/reference/exportAssignmentTopLevelEnumdule.types index fba15dc3ca8..f67a691d020 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelEnumdule.types +++ b/tests/baselines/reference/exportAssignmentTopLevelEnumdule.types @@ -26,16 +26,16 @@ enum foo { >foo : foo red, green, blue ->red : foo ->green : foo ->blue : foo +>red : foo.red +>green : foo.green +>blue : foo.blue } module foo { >foo : typeof foo export var answer = 42; >answer : number ->42 : number +>42 : 42 } export = foo; >foo : foo diff --git a/tests/baselines/reference/exportAssignmentTopLevelFundule.types b/tests/baselines/reference/exportAssignmentTopLevelFundule.types index 950693dcc62..644fc086dbc 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelFundule.types +++ b/tests/baselines/reference/exportAssignmentTopLevelFundule.types @@ -20,14 +20,14 @@ function foo() { >foo : typeof foo return "test"; ->"test" : string +>"test" : "test" } module foo { >foo : typeof foo export var answer = 42; >answer : number ->42 : number +>42 : 42 } export = foo; >foo : typeof foo diff --git a/tests/baselines/reference/exportAssignmentTopLevelIdentifier.types b/tests/baselines/reference/exportAssignmentTopLevelIdentifier.types index 9851eab1898..e7a35a9a69c 100644 --- a/tests/baselines/reference/exportAssignmentTopLevelIdentifier.types +++ b/tests/baselines/reference/exportAssignmentTopLevelIdentifier.types @@ -17,7 +17,7 @@ module Foo { export var answer = 42; >answer : number ->42 : number +>42 : 42 } export = Foo; >Foo : typeof Foo diff --git a/tests/baselines/reference/exportAssignmentVariable.types b/tests/baselines/reference/exportAssignmentVariable.types index 7c6d9b45cce..219a2f9f9a1 100644 --- a/tests/baselines/reference/exportAssignmentVariable.types +++ b/tests/baselines/reference/exportAssignmentVariable.types @@ -9,7 +9,7 @@ var n: number = y; === tests/cases/compiler/exportAssignmentVariable_A.ts === var x = 0; >x : number ->0 : number +>0 : 0 export = x; >x : number diff --git a/tests/baselines/reference/exportCodeGen.types b/tests/baselines/reference/exportCodeGen.types index e08678a76da..03d4ea0d977 100644 --- a/tests/baselines/reference/exportCodeGen.types +++ b/tests/baselines/reference/exportCodeGen.types @@ -7,7 +7,7 @@ module A { export var x = 12; >x : number ->12 : number +>12 : 12 function lt12() { >lt12 : () => boolean @@ -15,7 +15,7 @@ module A { return x < 12; >x < 12 : boolean >x : number ->12 : number +>12 : 12 } } @@ -25,7 +25,7 @@ module B { var x = 12; >x : number ->12 : number +>12 : 12 function lt12() { >lt12 : () => boolean @@ -33,7 +33,7 @@ module B { return x < 12; >x < 12 : boolean >x : number ->12 : number +>12 : 12 } } @@ -45,7 +45,7 @@ module C { >no : () => boolean return false; ->false : boolean +>false : false } } @@ -57,7 +57,7 @@ module D { >yes : () => boolean return true; ->true : boolean +>true : true } } @@ -85,7 +85,7 @@ module E { export var x = 42; >x : number ->42 : number +>42 : 42 } } @@ -114,6 +114,6 @@ module F { var x = 42; >x : number ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.types b/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.types index 1ad841fe947..ec229047501 100644 --- a/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.types +++ b/tests/baselines/reference/exportDeclarationWithModuleSpecifierNameOnNextLine1.types @@ -2,7 +2,7 @@ export var x = "x"; >x : string ->"x" : string +>"x" : "x" === tests/cases/compiler/t2.ts === export { x } from diff --git a/tests/baselines/reference/exportDefaultAsyncFunction2.types b/tests/baselines/reference/exportDefaultAsyncFunction2.types index ae66620159d..a9ff903e53a 100644 --- a/tests/baselines/reference/exportDefaultAsyncFunction2.types +++ b/tests/baselines/reference/exportDefaultAsyncFunction2.types @@ -24,12 +24,12 @@ export default async(() => await(Promise.resolve(1))); >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->1 : number +>1 : 1 === tests/cases/compiler/b.ts === export default async () => { return 0; }; >async () => { return 0; } : () => Promise ->0 : number +>0 : 0 === tests/cases/compiler/c.ts === import { async, await } from 'asyncawait'; diff --git a/tests/baselines/reference/exportDefaultClassWithStaticPropertyAssignmentsInES6.types b/tests/baselines/reference/exportDefaultClassWithStaticPropertyAssignmentsInES6.types index 657e0301f83..47e83523da1 100644 --- a/tests/baselines/reference/exportDefaultClassWithStaticPropertyAssignmentsInES6.types +++ b/tests/baselines/reference/exportDefaultClassWithStaticPropertyAssignmentsInES6.types @@ -2,5 +2,5 @@ export default class { static z: string = "Foo"; >z : string ->"Foo" : string +>"Foo" : "Foo" } diff --git a/tests/baselines/reference/exportDefaultProperty.types b/tests/baselines/reference/exportDefaultProperty.types index 47cfabfbc16..67de741fde4 100644 --- a/tests/baselines/reference/exportDefaultProperty.types +++ b/tests/baselines/reference/exportDefaultProperty.types @@ -39,7 +39,7 @@ import fooLength from "./b"; fooLength + 1; >fooLength + 1 : number >fooLength : number ->1 : number +>1 : 1 === tests/cases/compiler/declarations.d.ts === // This test is just like exportEqualsProperty, but with `export default`. @@ -82,7 +82,7 @@ namespace A { export namespace B { export const b: number = 0; } >B : typeof B >b : number ->0 : number +>0 : 0 } export default A.B; >A.B : typeof default @@ -92,6 +92,6 @@ export default A.B; === tests/cases/compiler/b.ts === export default "foo".length; >"foo".length : number ->"foo" : string +>"foo" : "foo" >length : number diff --git a/tests/baselines/reference/exportEqualNamespaces.types b/tests/baselines/reference/exportEqualNamespaces.types index 0e27102c015..46c6e2a5533 100644 --- a/tests/baselines/reference/exportEqualNamespaces.types +++ b/tests/baselines/reference/exportEqualNamespaces.types @@ -21,7 +21,7 @@ interface server { var x = 5; >x : number ->5 : number +>5 : 5 var server = new Date(); >server : Date diff --git a/tests/baselines/reference/exportEqualsAmd.types b/tests/baselines/reference/exportEqualsAmd.types index f5b1bb49910..e6f76b411cb 100644 --- a/tests/baselines/reference/exportEqualsAmd.types +++ b/tests/baselines/reference/exportEqualsAmd.types @@ -1,6 +1,6 @@ === tests/cases/compiler/exportEqualsAmd.ts === export = { ["hi"]: "there" }; >{ ["hi"]: "there" } : { ["hi"]: string; } ->"hi" : string ->"there" : string +>"hi" : "hi" +>"there" : "there" diff --git a/tests/baselines/reference/exportEqualsCommonJs.types b/tests/baselines/reference/exportEqualsCommonJs.types index 13b968595be..ea0c082edff 100644 --- a/tests/baselines/reference/exportEqualsCommonJs.types +++ b/tests/baselines/reference/exportEqualsCommonJs.types @@ -1,6 +1,6 @@ === tests/cases/compiler/exportEqualsCommonJs.ts === export = { ["hi"]: "there" }; >{ ["hi"]: "there" } : { ["hi"]: string; } ->"hi" : string ->"there" : string +>"hi" : "hi" +>"there" : "there" diff --git a/tests/baselines/reference/exportEqualsDefaultProperty.types b/tests/baselines/reference/exportEqualsDefaultProperty.types index 31a6c8052f9..b6e3be008a1 100644 --- a/tests/baselines/reference/exportEqualsDefaultProperty.types +++ b/tests/baselines/reference/exportEqualsDefaultProperty.types @@ -5,10 +5,10 @@ var x = { >{ "greeting": "hello, world", "default": 42} : { "greeting": string; "default": number; } "greeting": "hello, world", ->"hello, world" : string +>"hello, world" : "hello, world" "default": 42 ->42 : number +>42 : 42 }; @@ -24,5 +24,5 @@ foo.toExponential(2); >foo.toExponential : (fractionDigits?: number) => string >foo : number >toExponential : (fractionDigits?: number) => string ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/exportEqualsProperty.types b/tests/baselines/reference/exportEqualsProperty.types index a92af53b12b..9386a60a7f9 100644 --- a/tests/baselines/reference/exportEqualsProperty.types +++ b/tests/baselines/reference/exportEqualsProperty.types @@ -34,7 +34,7 @@ import fooLength = require("./b"); fooLength + 1; >fooLength + 1 : number >fooLength : number ->1 : number +>1 : 1 === tests/cases/compiler/declarations.d.ts === // This test is just like exportDefaultProperty, but with `export =`. @@ -77,7 +77,7 @@ namespace A { export namespace B { export const b: number = 0; } >B : typeof B >b : number ->0 : number +>0 : 0 } export = A.B; >A.B : typeof A.B @@ -87,6 +87,6 @@ export = A.B; === tests/cases/compiler/b.ts === export = "foo".length; >"foo".length : number ->"foo" : string +>"foo" : "foo" >length : number diff --git a/tests/baselines/reference/exportEqualsUmd.types b/tests/baselines/reference/exportEqualsUmd.types index ab456f0ae48..6b3110dc2a4 100644 --- a/tests/baselines/reference/exportEqualsUmd.types +++ b/tests/baselines/reference/exportEqualsUmd.types @@ -1,6 +1,6 @@ === tests/cases/compiler/exportEqualsUmd.ts === export = { ["hi"]: "there" }; >{ ["hi"]: "there" } : { ["hi"]: string; } ->"hi" : string ->"there" : string +>"hi" : "hi" +>"there" : "there" diff --git a/tests/baselines/reference/exportImport.types b/tests/baselines/reference/exportImport.types index a6361d3cbac..decfe97a594 100644 --- a/tests/baselines/reference/exportImport.types +++ b/tests/baselines/reference/exportImport.types @@ -21,7 +21,7 @@ export = Widget1 class Widget1 { name = 'one'; } >Widget1 : Widget1 >name : string ->'one' : string +>'one' : "one" === tests/cases/compiler/exporter.ts === export import w = require('./w1'); diff --git a/tests/baselines/reference/exportImportAlias.types b/tests/baselines/reference/exportImportAlias.types index f0c21d461bc..4d79214f9b8 100644 --- a/tests/baselines/reference/exportImportAlias.types +++ b/tests/baselines/reference/exportImportAlias.types @@ -6,7 +6,7 @@ module A { export var x = 'hello world' >x : string ->'hello world' : string +>'hello world' : "hello world" export class Point { >Point : Point @@ -53,8 +53,8 @@ var b: { x: number; y: number; } = new C.a.Point(0, 0); >C : typeof C >a : typeof A >Point : typeof A.Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 var c: { name: string }; >c : { name: string; } @@ -74,7 +74,7 @@ module X { >Y : typeof Y return 42; ->42 : number +>42 : 42 } export module Y { @@ -117,8 +117,8 @@ var n: { x: number; y: number; } = new Z.y.Point(0, 0); >Z : typeof Z >y : typeof X.Y >Point : typeof X.Y.Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 module K { >K : typeof K @@ -135,7 +135,7 @@ module K { export var y = 12; >y : number ->12 : number +>12 : 12 export interface Point { >Point : Point @@ -168,7 +168,7 @@ var o = new M.D('Hello'); >M.D : typeof K.L >M : typeof M >D : typeof K.L ->'Hello' : string +>'Hello' : "Hello" var p: { x: number; y: number; } >p : { x: number; y: number; } diff --git a/tests/baselines/reference/exportImportAndClodule.types b/tests/baselines/reference/exportImportAndClodule.types index 36ca259666c..8f0150b0e17 100644 --- a/tests/baselines/reference/exportImportAndClodule.types +++ b/tests/baselines/reference/exportImportAndClodule.types @@ -13,7 +13,7 @@ module K { export var y = 12; >y : number ->12 : number +>12 : 12 export interface Point { >Point : Point @@ -44,7 +44,7 @@ var o = new M.D('Hello'); >M.D : typeof K.L >M : typeof M >D : typeof K.L ->'Hello' : string +>'Hello' : "Hello" var p: { x: number; y: number; } >p : { x: number; y: number; } diff --git a/tests/baselines/reference/exportImportMultipleFiles.types b/tests/baselines/reference/exportImportMultipleFiles.types index 6ac5e7641ea..c4bdce56bf0 100644 --- a/tests/baselines/reference/exportImportMultipleFiles.types +++ b/tests/baselines/reference/exportImportMultipleFiles.types @@ -9,8 +9,8 @@ lib.math.add(3, 4); // Shouldnt be error >lib : typeof lib >math : typeof lib.math >add : (a: any, b: any) => any ->3 : number ->4 : number +>3 : 3 +>4 : 4 === tests/cases/compiler/exportImportMultipleFiles_math.ts === export function add(a, b) { return a + b; } @@ -30,6 +30,6 @@ math.add(3, 4); // OK >math.add : (a: any, b: any) => any >math : typeof math >add : (a: any, b: any) => any ->3 : number ->4 : number +>3 : 3 +>4 : 4 diff --git a/tests/baselines/reference/exportImportNonInstantiatedModule.types b/tests/baselines/reference/exportImportNonInstantiatedModule.types index 0b1da72dad8..d43cd69dac7 100644 --- a/tests/baselines/reference/exportImportNonInstantiatedModule.types +++ b/tests/baselines/reference/exportImportNonInstantiatedModule.types @@ -23,5 +23,5 @@ var x: B.A1.I = { x: 1 }; >I : A.I >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportImportNonInstantiatedModule2.types b/tests/baselines/reference/exportImportNonInstantiatedModule2.types index 34f0810c12d..01016fcc4ec 100644 --- a/tests/baselines/reference/exportImportNonInstantiatedModule2.types +++ b/tests/baselines/reference/exportImportNonInstantiatedModule2.types @@ -10,7 +10,7 @@ export function w(): e.w { // Should be OK return {name: 'value' }; >{name: 'value' } : { name: string; } >name : string ->'value' : string +>'value' : "value" } === tests/cases/compiler/w1.ts === diff --git a/tests/baselines/reference/exportNonVisibleType.types b/tests/baselines/reference/exportNonVisibleType.types index 2ad420ac531..2bb65cf05f0 100644 --- a/tests/baselines/reference/exportNonVisibleType.types +++ b/tests/baselines/reference/exportNonVisibleType.types @@ -14,9 +14,9 @@ var x: I1 = {a: "test", b: 42}; >I1 : I1 >{a: "test", b: 42} : { a: string; b: number; } >a : string ->"test" : string +>"test" : "test" >b : number ->42 : number +>42 : 42 export = x; // Should fail, I1 not exported. >x : I1 diff --git a/tests/baselines/reference/exportPrivateType.types b/tests/baselines/reference/exportPrivateType.types index a91577c2b9c..5a986f94f63 100644 --- a/tests/baselines/reference/exportPrivateType.types +++ b/tests/baselines/reference/exportPrivateType.types @@ -18,7 +18,7 @@ module foo { test() { return true; } >test : () => boolean ->true : boolean +>true : true } interface I1 { diff --git a/tests/baselines/reference/exportStarForValues10.types b/tests/baselines/reference/exportStarForValues10.types index 370f02318c1..2be6b0c7bfe 100644 --- a/tests/baselines/reference/exportStarForValues10.types +++ b/tests/baselines/reference/exportStarForValues10.types @@ -2,7 +2,7 @@ export var v = 1; >v : number ->1 : number +>1 : 1 === tests/cases/compiler/file1.ts === export interface Foo { x } @@ -14,5 +14,5 @@ export * from "file0"; export * from "file1"; var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportStarForValues2.types b/tests/baselines/reference/exportStarForValues2.types index f1de53bd7cf..3a92d860ef8 100644 --- a/tests/baselines/reference/exportStarForValues2.types +++ b/tests/baselines/reference/exportStarForValues2.types @@ -8,11 +8,11 @@ export interface Foo { x } export * from "file1" var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file3.ts === export * from "file2" var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportStarForValues3.types b/tests/baselines/reference/exportStarForValues3.types index d2ee5ebb1d4..90d38d86703 100644 --- a/tests/baselines/reference/exportStarForValues3.types +++ b/tests/baselines/reference/exportStarForValues3.types @@ -12,7 +12,7 @@ export interface A { x } export * from "file1" var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file3.ts === export interface B { x } @@ -22,7 +22,7 @@ export interface B { x } export * from "file1" var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file4.ts === export interface C { x } @@ -33,11 +33,11 @@ export * from "file2" export * from "file3" var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file5.ts === export * from "file4" var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportStarForValues4.types b/tests/baselines/reference/exportStarForValues4.types index b381f9461e8..b00dd126a9c 100644 --- a/tests/baselines/reference/exportStarForValues4.types +++ b/tests/baselines/reference/exportStarForValues4.types @@ -13,7 +13,7 @@ export * from "file1" export * from "file3" var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file3.ts === export interface B { x } @@ -23,5 +23,5 @@ export interface B { x } export * from "file2" var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportStarForValues6.types b/tests/baselines/reference/exportStarForValues6.types index 4fe38a45d02..3d418e2dc24 100644 --- a/tests/baselines/reference/exportStarForValues6.types +++ b/tests/baselines/reference/exportStarForValues6.types @@ -8,5 +8,5 @@ export interface Foo { x } export * from "file1" export var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportStarForValues7.types b/tests/baselines/reference/exportStarForValues7.types index d37661320d6..41927bab512 100644 --- a/tests/baselines/reference/exportStarForValues7.types +++ b/tests/baselines/reference/exportStarForValues7.types @@ -8,11 +8,11 @@ export interface Foo { x } export * from "file1" export var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file3.ts === export * from "file2" export var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportStarForValues8.types b/tests/baselines/reference/exportStarForValues8.types index 9cc1484eecb..7d06bd0d1f5 100644 --- a/tests/baselines/reference/exportStarForValues8.types +++ b/tests/baselines/reference/exportStarForValues8.types @@ -12,7 +12,7 @@ export interface A { x } export * from "file1" export var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file3.ts === export interface B { x } @@ -22,7 +22,7 @@ export interface B { x } export * from "file1" export var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file4.ts === export interface C { x } @@ -33,11 +33,11 @@ export * from "file2" export * from "file3" export var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file5.ts === export * from "file4" export var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportStarForValues9.types b/tests/baselines/reference/exportStarForValues9.types index 3cf250ec50b..aa09e1f12cf 100644 --- a/tests/baselines/reference/exportStarForValues9.types +++ b/tests/baselines/reference/exportStarForValues9.types @@ -13,7 +13,7 @@ export * from "file1" export * from "file3" export var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/file3.ts === export interface B { x } @@ -23,5 +23,5 @@ export interface B { x } export * from "file2" export var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportStarForValuesInSystem.types b/tests/baselines/reference/exportStarForValuesInSystem.types index 36d07741e10..bbb9a5a6b15 100644 --- a/tests/baselines/reference/exportStarForValuesInSystem.types +++ b/tests/baselines/reference/exportStarForValuesInSystem.types @@ -8,5 +8,5 @@ export interface Foo { x } export * from "file1" var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/exportToString.types b/tests/baselines/reference/exportToString.types index 17037852f3b..8c3aa782e29 100644 --- a/tests/baselines/reference/exportToString.types +++ b/tests/baselines/reference/exportToString.types @@ -1,8 +1,8 @@ === tests/cases/compiler/exportToString.ts === const toString = 0; ->toString : number ->0 : number +>toString : 0 +>0 : 0 export { toString }; ->toString : number +>toString : 0 diff --git a/tests/baselines/reference/exportVisibility.types b/tests/baselines/reference/exportVisibility.types index cf1e092473e..0249661834b 100644 --- a/tests/baselines/reference/exportVisibility.types +++ b/tests/baselines/reference/exportVisibility.types @@ -14,6 +14,6 @@ export function test(foo: Foo) { >Foo : Foo return true; ->true : boolean +>true : true } diff --git a/tests/baselines/reference/exportedVariable1.types b/tests/baselines/reference/exportedVariable1.types index fa7017fefa8..1d30c50ca3b 100644 --- a/tests/baselines/reference/exportedVariable1.types +++ b/tests/baselines/reference/exportedVariable1.types @@ -3,7 +3,7 @@ export var foo = {name: "Bill"}; >foo : { name: string; } >{name: "Bill"} : { name: string; } >name : string ->"Bill" : string +>"Bill" : "Bill" var upper = foo.name.toUpperCase(); >upper : string diff --git a/tests/baselines/reference/exportsAndImports1-amd.types b/tests/baselines/reference/exportsAndImports1-amd.types index 4ba83121541..05c8b6d7af5 100644 --- a/tests/baselines/reference/exportsAndImports1-amd.types +++ b/tests/baselines/reference/exportsAndImports1-amd.types @@ -2,7 +2,7 @@ var v = 1; >v : number ->1 : number +>1 : 1 function f() { } >f : () => void @@ -17,17 +17,17 @@ enum E { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } const enum D { >D : D A, B, C ->A : D ->B : D ->C : D +>A : D.A +>B : D.B +>C : D.C } module M { >M : typeof M diff --git a/tests/baselines/reference/exportsAndImports1-es6.types b/tests/baselines/reference/exportsAndImports1-es6.types index 4ba83121541..05c8b6d7af5 100644 --- a/tests/baselines/reference/exportsAndImports1-es6.types +++ b/tests/baselines/reference/exportsAndImports1-es6.types @@ -2,7 +2,7 @@ var v = 1; >v : number ->1 : number +>1 : 1 function f() { } >f : () => void @@ -17,17 +17,17 @@ enum E { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } const enum D { >D : D A, B, C ->A : D ->B : D ->C : D +>A : D.A +>B : D.B +>C : D.C } module M { >M : typeof M diff --git a/tests/baselines/reference/exportsAndImports1.types b/tests/baselines/reference/exportsAndImports1.types index 4ba83121541..05c8b6d7af5 100644 --- a/tests/baselines/reference/exportsAndImports1.types +++ b/tests/baselines/reference/exportsAndImports1.types @@ -2,7 +2,7 @@ var v = 1; >v : number ->1 : number +>1 : 1 function f() { } >f : () => void @@ -17,17 +17,17 @@ enum E { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } const enum D { >D : D A, B, C ->A : D ->B : D ->C : D +>A : D.A +>B : D.B +>C : D.C } module M { >M : typeof M diff --git a/tests/baselines/reference/exportsAndImports2-amd.types b/tests/baselines/reference/exportsAndImports2-amd.types index 32de763c567..46e42174a77 100644 --- a/tests/baselines/reference/exportsAndImports2-amd.types +++ b/tests/baselines/reference/exportsAndImports2-amd.types @@ -2,11 +2,11 @@ export var x = "x"; >x : string ->"x" : string +>"x" : "x" export var y = "y"; >y : string ->"y" : string +>"y" : "y" === tests/cases/conformance/es6/modules/t2.ts === export { x as y, y as x } from "./t1"; diff --git a/tests/baselines/reference/exportsAndImports2-es6.types b/tests/baselines/reference/exportsAndImports2-es6.types index 32de763c567..46e42174a77 100644 --- a/tests/baselines/reference/exportsAndImports2-es6.types +++ b/tests/baselines/reference/exportsAndImports2-es6.types @@ -2,11 +2,11 @@ export var x = "x"; >x : string ->"x" : string +>"x" : "x" export var y = "y"; >y : string ->"y" : string +>"y" : "y" === tests/cases/conformance/es6/modules/t2.ts === export { x as y, y as x } from "./t1"; diff --git a/tests/baselines/reference/exportsAndImports2.types b/tests/baselines/reference/exportsAndImports2.types index 32de763c567..46e42174a77 100644 --- a/tests/baselines/reference/exportsAndImports2.types +++ b/tests/baselines/reference/exportsAndImports2.types @@ -2,11 +2,11 @@ export var x = "x"; >x : string ->"x" : string +>"x" : "x" export var y = "y"; >y : string ->"y" : string +>"y" : "y" === tests/cases/conformance/es6/modules/t2.ts === export { x as y, y as x } from "./t1"; diff --git a/tests/baselines/reference/exportsAndImports3-amd.types b/tests/baselines/reference/exportsAndImports3-amd.types index 0b8235d969c..5292f01af0d 100644 --- a/tests/baselines/reference/exportsAndImports3-amd.types +++ b/tests/baselines/reference/exportsAndImports3-amd.types @@ -2,7 +2,7 @@ export var v = 1; >v : number ->1 : number +>1 : 1 export function f() { } >f : () => void @@ -17,17 +17,17 @@ export enum E { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } export const enum D { >D : D A, B, C ->A : D ->B : D ->C : D +>A : D.A +>B : D.B +>C : D.C } export module M { >M : typeof M diff --git a/tests/baselines/reference/exportsAndImports3-es6.types b/tests/baselines/reference/exportsAndImports3-es6.types index 0b8235d969c..5292f01af0d 100644 --- a/tests/baselines/reference/exportsAndImports3-es6.types +++ b/tests/baselines/reference/exportsAndImports3-es6.types @@ -2,7 +2,7 @@ export var v = 1; >v : number ->1 : number +>1 : 1 export function f() { } >f : () => void @@ -17,17 +17,17 @@ export enum E { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } export const enum D { >D : D A, B, C ->A : D ->B : D ->C : D +>A : D.A +>B : D.B +>C : D.C } export module M { >M : typeof M diff --git a/tests/baselines/reference/exportsAndImports3.types b/tests/baselines/reference/exportsAndImports3.types index 0b8235d969c..5292f01af0d 100644 --- a/tests/baselines/reference/exportsAndImports3.types +++ b/tests/baselines/reference/exportsAndImports3.types @@ -2,7 +2,7 @@ export var v = 1; >v : number ->1 : number +>1 : 1 export function f() { } >f : () => void @@ -17,17 +17,17 @@ export enum E { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } export const enum D { >D : D A, B, C ->A : D ->B : D ->C : D +>A : D.A +>B : D.B +>C : D.C } export module M { >M : typeof M diff --git a/tests/baselines/reference/exportsAndImports4-amd.types b/tests/baselines/reference/exportsAndImports4-amd.types index 4bd6f8c0e1e..dfddd897e59 100644 --- a/tests/baselines/reference/exportsAndImports4-amd.types +++ b/tests/baselines/reference/exportsAndImports4-amd.types @@ -3,63 +3,63 @@ import a = require("./t1"); >a : typeof a a.default; ->a.default : string +>a.default : "hello" >a : typeof a ->default : string +>default : "hello" import b from "./t1"; ->b : string +>b : "hello" b; ->b : string +>b : "hello" import * as c from "./t1"; >c : typeof a c.default; ->c.default : string +>c.default : "hello" >c : typeof a ->default : string +>default : "hello" import { default as d } from "./t1"; ->default : string ->d : string +>default : "hello" +>d : "hello" d; ->d : string +>d : "hello" import e1, * as e2 from "./t1"; ->e1 : string +>e1 : "hello" >e2 : typeof a e1; ->e1 : string +>e1 : "hello" e2.default; ->e2.default : string +>e2.default : "hello" >e2 : typeof a ->default : string +>default : "hello" import f1, { default as f2 } from "./t1"; ->f1 : string ->default : string ->f2 : string +>f1 : "hello" +>default : "hello" +>f2 : "hello" f1; ->f1 : string +>f1 : "hello" f2; ->f2 : string +>f2 : "hello" export { a, b, c, d, e1, e2, f1, f2 }; >a : typeof a ->b : string +>b : "hello" >c : typeof a ->d : string ->e1 : string +>d : "hello" +>e1 : "hello" >e2 : typeof a ->f1 : string ->f2 : string +>f1 : "hello" +>f2 : "hello" === tests/cases/conformance/es6/modules/t1.ts === diff --git a/tests/baselines/reference/exportsAndImports4-es6.types b/tests/baselines/reference/exportsAndImports4-es6.types index 4bd6f8c0e1e..dfddd897e59 100644 --- a/tests/baselines/reference/exportsAndImports4-es6.types +++ b/tests/baselines/reference/exportsAndImports4-es6.types @@ -3,63 +3,63 @@ import a = require("./t1"); >a : typeof a a.default; ->a.default : string +>a.default : "hello" >a : typeof a ->default : string +>default : "hello" import b from "./t1"; ->b : string +>b : "hello" b; ->b : string +>b : "hello" import * as c from "./t1"; >c : typeof a c.default; ->c.default : string +>c.default : "hello" >c : typeof a ->default : string +>default : "hello" import { default as d } from "./t1"; ->default : string ->d : string +>default : "hello" +>d : "hello" d; ->d : string +>d : "hello" import e1, * as e2 from "./t1"; ->e1 : string +>e1 : "hello" >e2 : typeof a e1; ->e1 : string +>e1 : "hello" e2.default; ->e2.default : string +>e2.default : "hello" >e2 : typeof a ->default : string +>default : "hello" import f1, { default as f2 } from "./t1"; ->f1 : string ->default : string ->f2 : string +>f1 : "hello" +>default : "hello" +>f2 : "hello" f1; ->f1 : string +>f1 : "hello" f2; ->f2 : string +>f2 : "hello" export { a, b, c, d, e1, e2, f1, f2 }; >a : typeof a ->b : string +>b : "hello" >c : typeof a ->d : string ->e1 : string +>d : "hello" +>e1 : "hello" >e2 : typeof a ->f1 : string ->f2 : string +>f1 : "hello" +>f2 : "hello" === tests/cases/conformance/es6/modules/t1.ts === diff --git a/tests/baselines/reference/exportsAndImports4.types b/tests/baselines/reference/exportsAndImports4.types index 4bd6f8c0e1e..dfddd897e59 100644 --- a/tests/baselines/reference/exportsAndImports4.types +++ b/tests/baselines/reference/exportsAndImports4.types @@ -3,63 +3,63 @@ import a = require("./t1"); >a : typeof a a.default; ->a.default : string +>a.default : "hello" >a : typeof a ->default : string +>default : "hello" import b from "./t1"; ->b : string +>b : "hello" b; ->b : string +>b : "hello" import * as c from "./t1"; >c : typeof a c.default; ->c.default : string +>c.default : "hello" >c : typeof a ->default : string +>default : "hello" import { default as d } from "./t1"; ->default : string ->d : string +>default : "hello" +>d : "hello" d; ->d : string +>d : "hello" import e1, * as e2 from "./t1"; ->e1 : string +>e1 : "hello" >e2 : typeof a e1; ->e1 : string +>e1 : "hello" e2.default; ->e2.default : string +>e2.default : "hello" >e2 : typeof a ->default : string +>default : "hello" import f1, { default as f2 } from "./t1"; ->f1 : string ->default : string ->f2 : string +>f1 : "hello" +>default : "hello" +>f2 : "hello" f1; ->f1 : string +>f1 : "hello" f2; ->f2 : string +>f2 : "hello" export { a, b, c, d, e1, e2, f1, f2 }; >a : typeof a ->b : string +>b : "hello" >c : typeof a ->d : string ->e1 : string +>d : "hello" +>e1 : "hello" >e2 : typeof a ->f1 : string ->f2 : string +>f1 : "hello" +>f2 : "hello" === tests/cases/conformance/es6/modules/t1.ts === diff --git a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.types b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.types index 853fa787f0a..c12e84e320b 100644 --- a/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.types +++ b/tests/baselines/reference/exportsAndImportsWithContextualKeywordNames02.types @@ -2,7 +2,7 @@ let as = 100; >as : number ->100 : number +>100 : 100 export { as as return, as }; >as : number diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores2.types b/tests/baselines/reference/exportsAndImportsWithUnderscores2.types index a684440f5bd..3b86789cc44 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores2.types +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores2.types @@ -9,7 +9,7 @@ export default R = { >{ "__esmodule": true, "__proto__": {}} : { "__esmodule": boolean; "__proto__": {}; } "__esmodule": true, ->true : boolean +>true : true "__proto__": {} >{} : {} diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores3.types b/tests/baselines/reference/exportsAndImportsWithUnderscores3.types index 5addb44172d..b860928aa62 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores3.types +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores3.types @@ -9,13 +9,13 @@ export default R = { >{ "___": 30, "___hello": 21, "_hi": 40,} : { "___": number; "___hello": number; "_hi": number; } "___": 30, ->30 : number +>30 : 30 "___hello": 21, ->21 : number +>21 : 21 "_hi": 40, ->40 : number +>40 : 40 } === tests/cases/conformance/es6/modules/m2.ts === diff --git a/tests/baselines/reference/exportsAndImportsWithUnderscores4.types b/tests/baselines/reference/exportsAndImportsWithUnderscores4.types index a9042042285..cf339db5dee 100644 --- a/tests/baselines/reference/exportsAndImportsWithUnderscores4.types +++ b/tests/baselines/reference/exportsAndImportsWithUnderscores4.types @@ -11,7 +11,7 @@ export function _() { >console.log : any >console : any >log : any ->"_" : string +>"_" : "_" } export function __() { >__ : () => void @@ -21,7 +21,7 @@ export function __() { >console.log : any >console : any >log : any ->"__" : string +>"__" : "__" } export function ___() { >___ : () => void @@ -31,7 +31,7 @@ export function ___() { >console.log : any >console : any >log : any ->"___" : string +>"___" : "___" } export function _hi() { >_hi : () => void @@ -41,7 +41,7 @@ export function _hi() { >console.log : any >console : any >log : any ->"_hi" : string +>"_hi" : "_hi" } export function __proto() { >__proto : () => void @@ -51,7 +51,7 @@ export function __proto() { >console.log : any >console : any >log : any ->"__proto" : string +>"__proto" : "__proto" } export function __esmodule() { >__esmodule : () => void @@ -61,7 +61,7 @@ export function __esmodule() { >console.log : any >console : any >log : any ->"__esmodule" : string +>"__esmodule" : "__esmodule" } export function ___hello(){ >___hello : () => void @@ -71,7 +71,7 @@ export function ___hello(){ >console.log : any >console : any >log : any ->"___hello" : string +>"___hello" : "___hello" } === tests/cases/conformance/es6/modules/m2.ts === diff --git a/tests/baselines/reference/expr.errors.txt b/tests/baselines/reference/expr.errors.txt index 41d15a0835b..17e39cc80be 100644 --- a/tests/baselines/reference/expr.errors.txt +++ b/tests/baselines/reference/expr.errors.txt @@ -4,14 +4,14 @@ tests/cases/compiler/expr.ts(94,5): error TS2365: Operator '==' cannot be applie tests/cases/compiler/expr.ts(95,5): error TS2365: Operator '==' cannot be applied to types 'string' and 'boolean'. tests/cases/compiler/expr.ts(98,5): error TS2365: Operator '==' cannot be applied to types 'string' and 'E'. tests/cases/compiler/expr.ts(115,5): error TS2365: Operator '==' cannot be applied to types 'E' and 'string'. -tests/cases/compiler/expr.ts(116,5): error TS2365: Operator '==' cannot be applied to types 'E' and 'boolean'. -tests/cases/compiler/expr.ts(142,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'. +tests/cases/compiler/expr.ts(116,5): error TS2365: Operator '==' cannot be applied to types 'E' and 'false'. +tests/cases/compiler/expr.ts(142,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'false'. tests/cases/compiler/expr.ts(143,5): error TS2365: Operator '+' cannot be applied to types 'number' and 'I'. tests/cases/compiler/expr.ts(161,5): error TS2365: Operator '+' cannot be applied to types 'I' and 'number'. -tests/cases/compiler/expr.ts(163,5): error TS2365: Operator '+' cannot be applied to types 'I' and 'boolean'. +tests/cases/compiler/expr.ts(163,5): error TS2365: Operator '+' cannot be applied to types 'I' and 'false'. tests/cases/compiler/expr.ts(165,5): error TS2365: Operator '+' cannot be applied to types 'I' and 'I'. tests/cases/compiler/expr.ts(166,5): error TS2365: Operator '+' cannot be applied to types 'I' and 'E'. -tests/cases/compiler/expr.ts(170,5): error TS2365: Operator '+' cannot be applied to types 'E' and 'boolean'. +tests/cases/compiler/expr.ts(170,5): error TS2365: Operator '+' cannot be applied to types 'E' and 'false'. tests/cases/compiler/expr.ts(172,5): error TS2365: Operator '+' cannot be applied to types 'E' and 'I'. tests/cases/compiler/expr.ts(176,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/compiler/expr.ts(177,7): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -199,7 +199,7 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari !!! error TS2365: Operator '==' cannot be applied to types 'E' and 'string'. e==b; ~~~~ -!!! error TS2365: Operator '==' cannot be applied to types 'E' and 'boolean'. +!!! error TS2365: Operator '==' cannot be applied to types 'E' and 'false'. e==a; e==i; e==e; @@ -227,7 +227,7 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari n+s; n+b; ~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'boolean'. +!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'false'. n+i; ~~~ !!! error TS2365: Operator '+' cannot be applied to types 'number' and 'I'. @@ -254,7 +254,7 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari i+s; i+b; ~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'I' and 'boolean'. +!!! error TS2365: Operator '+' cannot be applied to types 'I' and 'false'. i+a; i+i; ~~~ @@ -267,7 +267,7 @@ tests/cases/compiler/expr.ts(242,7): error TS2363: The right-hand side of an ari e+s; e+b; ~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'boolean'. +!!! error TS2365: Operator '+' cannot be applied to types 'E' and 'false'. e+a; e+i; ~~~ diff --git a/tests/baselines/reference/extBaseClass1.types b/tests/baselines/reference/extBaseClass1.types index 1ab2ec3ba53..7e25c832f2a 100644 --- a/tests/baselines/reference/extBaseClass1.types +++ b/tests/baselines/reference/extBaseClass1.types @@ -7,7 +7,7 @@ module M { public x=10; >x : number ->10 : number +>10 : 10 } export class C extends B { diff --git a/tests/baselines/reference/extendBooleanInterface.types b/tests/baselines/reference/extendBooleanInterface.types index 8f91deba713..1230846c7ce 100644 --- a/tests/baselines/reference/extendBooleanInterface.types +++ b/tests/baselines/reference/extendBooleanInterface.types @@ -15,35 +15,35 @@ interface Boolean { var x = true; >x : boolean ->true : boolean +>true : true var a: string = x.doStuff(); >a : string >x.doStuff() : string >x.doStuff : () => string ->x : boolean +>x : true >doStuff : () => string var b: string = x.doOtherStuff('hm'); >b : string >x.doOtherStuff('hm') : string >x.doOtherStuff : (x: T) => T ->x : boolean +>x : true >doOtherStuff : (x: T) => T ->'hm' : string +>'hm' : "hm" var c: string = x['doStuff'](); >c : string >x['doStuff']() : string >x['doStuff'] : () => string ->x : boolean ->'doStuff' : string +>x : true +>'doStuff' : "doStuff" var d: string = x['doOtherStuff']('hm'); >d : string >x['doOtherStuff']('hm') : string >x['doOtherStuff'] : (x: T) => T ->x : boolean ->'doOtherStuff' : string ->'hm' : string +>x : true +>'doOtherStuff' : "doOtherStuff" +>'hm' : "hm" diff --git a/tests/baselines/reference/extendConstructSignatureInInterface.types b/tests/baselines/reference/extendConstructSignatureInInterface.types index 363107b2e54..c89b7ca01f3 100644 --- a/tests/baselines/reference/extendConstructSignatureInInterface.types +++ b/tests/baselines/reference/extendConstructSignatureInInterface.types @@ -21,5 +21,5 @@ var e: E = new E(1); >E : E >new E(1) : E >E : typeof E ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/extendNumberInterface.types b/tests/baselines/reference/extendNumberInterface.types index 97ef307bab8..f96ead3d794 100644 --- a/tests/baselines/reference/extendNumberInterface.types +++ b/tests/baselines/reference/extendNumberInterface.types @@ -15,7 +15,7 @@ interface Number { var x = 1; >x : number ->1 : number +>1 : 1 var a: string = x.doStuff(); >a : string @@ -30,20 +30,20 @@ var b: string = x.doOtherStuff('hm'); >x.doOtherStuff : (x: T) => T >x : number >doOtherStuff : (x: T) => T ->'hm' : string +>'hm' : "hm" var c: string = x['doStuff'](); >c : string >x['doStuff']() : string >x['doStuff'] : () => string >x : number ->'doStuff' : string +>'doStuff' : "doStuff" var d: string = x['doOtherStuff']('hm'); >d : string >x['doOtherStuff']('hm') : string >x['doOtherStuff'] : (x: T) => T >x : number ->'doOtherStuff' : string ->'hm' : string +>'doOtherStuff' : "doOtherStuff" +>'hm' : "hm" diff --git a/tests/baselines/reference/extendStringInterface.types b/tests/baselines/reference/extendStringInterface.types index edfd8239015..5b3b5c6b9ea 100644 --- a/tests/baselines/reference/extendStringInterface.types +++ b/tests/baselines/reference/extendStringInterface.types @@ -15,7 +15,7 @@ interface String { var x = ''; >x : string ->'' : string +>'' : "" var a: string = x.doStuff(); >a : string @@ -30,20 +30,20 @@ var b: string = x.doOtherStuff('hm'); >x.doOtherStuff : (x: T) => T >x : string >doOtherStuff : (x: T) => T ->'hm' : string +>'hm' : "hm" var c: string = x['doStuff'](); >c : string >x['doStuff']() : string >x['doStuff'] : () => string >x : string ->'doStuff' : string +>'doStuff' : "doStuff" var d: string = x['doOtherStuff']('hm'); >d : string >x['doOtherStuff']('hm') : string >x['doOtherStuff'] : (x: T) => T >x : string ->'doOtherStuff' : string ->'hm' : string +>'doOtherStuff' : "doOtherStuff" +>'hm' : "hm" diff --git a/tests/baselines/reference/extendedInterfaceGenericType.types b/tests/baselines/reference/extendedInterfaceGenericType.types index a536ec75190..5235dd2f9c8 100644 --- a/tests/baselines/reference/extendedInterfaceGenericType.types +++ b/tests/baselines/reference/extendedInterfaceGenericType.types @@ -37,5 +37,5 @@ betaOfNumber.takesArgOfT(5); >betaOfNumber.takesArgOfT : (arg: number) => Alpha >betaOfNumber : Beta >takesArgOfT : (arg: number) => Alpha ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/externFunc.types b/tests/baselines/reference/externFunc.types index ab417859ea5..5cda004d4cf 100644 --- a/tests/baselines/reference/externFunc.types +++ b/tests/baselines/reference/externFunc.types @@ -6,5 +6,5 @@ declare function parseInt(s:string):number; parseInt("2"); >parseInt("2") : number >parseInt : { (s: string, radix?: number): number; (s: string): number; } ->"2" : string +>"2" : "2" diff --git a/tests/baselines/reference/externalModuleQualification.types b/tests/baselines/reference/externalModuleQualification.types index a7b70697209..42f0d3579b4 100644 --- a/tests/baselines/reference/externalModuleQualification.types +++ b/tests/baselines/reference/externalModuleQualification.types @@ -1,7 +1,7 @@ === tests/cases/compiler/externalModuleQualification.ts === export var ID = "test"; >ID : string ->"test" : string +>"test" : "test" export class DiffEditor { >DiffEditor : DiffEditor diff --git a/tests/baselines/reference/externalModuleReferenceDoubleUnderscore1.types b/tests/baselines/reference/externalModuleReferenceDoubleUnderscore1.types index 8d2c9b65991..ad292656d25 100644 --- a/tests/baselines/reference/externalModuleReferenceDoubleUnderscore1.types +++ b/tests/baselines/reference/externalModuleReferenceDoubleUnderscore1.types @@ -14,31 +14,31 @@ declare module '__timezonecomplete/basics' { >TimeUnit : TimeUnit Second = 0, ->Second : TimeUnit ->0 : number +>Second : TimeUnit.Second +>0 : 0 Minute = 1, ->Minute : TimeUnit ->1 : number +>Minute : TimeUnit.Minute +>1 : 1 Hour = 2, ->Hour : TimeUnit ->2 : number +>Hour : TimeUnit.Hour +>2 : 2 Day = 3, ->Day : TimeUnit ->3 : number +>Day : TimeUnit.Day +>3 : 3 Week = 4, ->Week : TimeUnit ->4 : number +>Week : TimeUnit.Week +>4 : 4 Month = 5, ->Month : TimeUnit ->5 : number +>Month : TimeUnit.Month +>5 : 5 Year = 6, ->Year : TimeUnit ->6 : number +>Year : TimeUnit.Year +>6 : 6 } } diff --git a/tests/baselines/reference/externalModuleResolution.types b/tests/baselines/reference/externalModuleResolution.types index 45e2aef6883..1f0901dd040 100644 --- a/tests/baselines/reference/externalModuleResolution.types +++ b/tests/baselines/reference/externalModuleResolution.types @@ -13,7 +13,7 @@ module M2 { export var Y = 1; >Y : number ->1 : number +>1 : 1 } export = M2 >M2 : typeof M2 diff --git a/tests/baselines/reference/externalModuleResolution2.types b/tests/baselines/reference/externalModuleResolution2.types index 9f48b8b38f1..8eb1ae5d546 100644 --- a/tests/baselines/reference/externalModuleResolution2.types +++ b/tests/baselines/reference/externalModuleResolution2.types @@ -13,7 +13,7 @@ module M2 { export var X = 1; >X : number ->1 : number +>1 : 1 } export = M2 >M2 : typeof M2 diff --git a/tests/baselines/reference/fallFromLastCase1.types b/tests/baselines/reference/fallFromLastCase1.types index 1a21727e7a1..0353ae88387 100644 --- a/tests/baselines/reference/fallFromLastCase1.types +++ b/tests/baselines/reference/fallFromLastCase1.types @@ -17,7 +17,7 @@ function foo1(a: number) { use("1"); >use("1") : any >use : (a: string) => any ->"1" : string +>"1" : "1" break; case 2: @@ -26,7 +26,7 @@ function foo1(a: number) { use("2"); >use("2") : any >use : (a: string) => any ->"2" : string +>"2" : "2" } } @@ -44,13 +44,13 @@ function foo2(a: number) { use("1"); >use("1") : any >use : (a: string) => any ->"1" : string +>"1" : "1" break; default: use("2"); >use("2") : any >use : (a: string) => any ->"2" : string +>"2" : "2" } } diff --git a/tests/baselines/reference/fallbackToBindingPatternForTypeInference.types b/tests/baselines/reference/fallbackToBindingPatternForTypeInference.types index fc41085098a..961642216c9 100644 --- a/tests/baselines/reference/fallbackToBindingPatternForTypeInference.types +++ b/tests/baselines/reference/fallbackToBindingPatternForTypeInference.types @@ -16,27 +16,27 @@ trans(({a}) => a); trans(([b,c]) => 'foo'); >trans(([b,c]) => 'foo') : number >trans : (f: (x: T) => string) => number ->([b,c]) => 'foo' : ([b, c]: [any, any]) => string +>([b,c]) => 'foo' : ([b, c]: [any, any]) => "foo" >b : any >c : any ->'foo' : string +>'foo' : "foo" trans(({d: [e,f]}) => 'foo'); >trans(({d: [e,f]}) => 'foo') : number >trans : (f: (x: T) => string) => number ->({d: [e,f]}) => 'foo' : ({d: [e, f]}: { d: [any, any]; }) => string +>({d: [e,f]}) => 'foo' : ({d: [e, f]}: { d: [any, any]; }) => "foo" >d : any >e : any >f : any ->'foo' : string +>'foo' : "foo" trans(([{g},{h}]) => 'foo'); >trans(([{g},{h}]) => 'foo') : number >trans : (f: (x: T) => string) => number ->([{g},{h}]) => 'foo' : ([{g}, {h}]: [{ g: any; }, { h: any; }]) => string +>([{g},{h}]) => 'foo' : ([{g}, {h}]: [{ g: any; }, { h: any; }]) => "foo" >g : any >h : any ->'foo' : string +>'foo' : "foo" trans(({a, b = 10}) => a); >trans(({a, b = 10}) => a) : number @@ -44,6 +44,6 @@ trans(({a, b = 10}) => a); >({a, b = 10}) => a : ({a, b}: { a: any; b?: number; }) => any >a : any >b : number ->10 : number +>10 : 10 >a : any diff --git a/tests/baselines/reference/fatArrowSelf.types b/tests/baselines/reference/fatArrowSelf.types index 574262265bc..1f9627b595e 100644 --- a/tests/baselines/reference/fatArrowSelf.types +++ b/tests/baselines/reference/fatArrowSelf.types @@ -41,7 +41,7 @@ module Consumer { >this : this >emitter : Events.EventEmitter >addListener : (type: string, listener: Events.ListenerCallback) => void ->'change' : string +>'change' : "change" >(e) => { this.changed(); } : (e: any) => void >e : any diff --git a/tests/baselines/reference/fatArrowfunctionAsType.types b/tests/baselines/reference/fatArrowfunctionAsType.types index a165048695f..82616951795 100644 --- a/tests/baselines/reference/fatArrowfunctionAsType.types +++ b/tests/baselines/reference/fatArrowfunctionAsType.types @@ -14,7 +14,7 @@ var c: (x: T) => void = function (x: T) { return 42; } >T : T >x : T >T : T ->42 : number +>42 : 42 b = c; >b = c : (x: T) => void diff --git a/tests/baselines/reference/fatarrowfunctions.types b/tests/baselines/reference/fatarrowfunctions.types index 7fd15ee29a7..304c341c916 100644 --- a/tests/baselines/reference/fatarrowfunctions.types +++ b/tests/baselines/reference/fatarrowfunctions.types @@ -79,7 +79,7 @@ foo(()=>{return 0;}); >foo(()=>{return 0;}) : any >foo : (x: any) => any >()=>{return 0;} : () => number ->0 : number +>0 : 0 foo((x:number,y,z)=>x+y+z); >foo((x:number,y,z)=>x+y+z) : any @@ -150,7 +150,7 @@ foo(()=>{return 0;}); >foo(()=>{return 0;}) : any >foo : (x: any) => any >()=>{return 0;} : () => number ->0 : number +>0 : 0 foo(((x) => x)); @@ -189,7 +189,7 @@ var z = (x:number) => x*x; var w = () => 3; >w : () => number >() => 3 : () => number ->3 : number +>3 : 3 function ternaryTest(isWhile:boolean) { >ternaryTest : (isWhile: boolean) => void @@ -203,7 +203,7 @@ function ternaryTest(isWhile:boolean) { >n : any >n > 0 : boolean >n : any ->0 : number +>0 : 0 >function (n) { return n === 0; } : (n: any) => boolean >n : any >n === 0 : boolean @@ -224,7 +224,7 @@ var messenger = { message: "Hello World", >message : string ->"Hello World" : string +>"Hello World" : "Hello World" start: function() { >start : () => void @@ -240,7 +240,7 @@ var messenger = { >this : any >message : any >toString : any ->3000 : number +>3000 : 3000 } }; diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types index 39cd994dcc1..bc33ec4c2ff 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types +++ b/tests/baselines/reference/fatarrowfunctionsInFunctionParameterDefaults.types @@ -19,5 +19,5 @@ fn.call(4); // Should be 4 >fn.call : (this: Function, thisArg: any, ...argArray: any[]) => any >fn : (x?: () => any, y?: any) => any >call : (this: Function, thisArg: any, ...argArray: any[]) => any ->4 : number +>4 : 4 diff --git a/tests/baselines/reference/fatarrowfunctionsInFunctions.types b/tests/baselines/reference/fatarrowfunctionsInFunctions.types index 00abaec9f25..8b9bd7ccd7a 100644 --- a/tests/baselines/reference/fatarrowfunctionsInFunctions.types +++ b/tests/baselines/reference/fatarrowfunctionsInFunctions.types @@ -11,7 +11,7 @@ var messenger = { message: "Hello World", >message : string ->"Hello World" : string +>"Hello World" : "Hello World" start: function() { >start : () => void @@ -35,7 +35,7 @@ var messenger = { >toString : any }, 3000); ->3000 : number +>3000 : 3000 } }; messenger.start(); diff --git a/tests/baselines/reference/fileReferencesWithNoExtensions.types b/tests/baselines/reference/fileReferencesWithNoExtensions.types index 7b56dbe0d20..380792f1b70 100644 --- a/tests/baselines/reference/fileReferencesWithNoExtensions.types +++ b/tests/baselines/reference/fileReferencesWithNoExtensions.types @@ -17,7 +17,7 @@ var c = cc; // Check that c.ts has precedence over c.d.ts === tests/cases/compiler/a.ts === var aa = 1; >aa : number ->1 : number +>1 : 1 === tests/cases/compiler/b.d.ts === declare var bb: number; @@ -26,7 +26,7 @@ declare var bb: number; === tests/cases/compiler/c.ts === var cc = 1; >cc : number ->1 : number +>1 : 1 === tests/cases/compiler/c.d.ts === declare var xx: number; diff --git a/tests/baselines/reference/fileWithNextLine1.types b/tests/baselines/reference/fileWithNextLine1.types index 2afb1f2ae37..d314fd996dd 100644 --- a/tests/baselines/reference/fileWithNextLine1.types +++ b/tests/baselines/reference/fileWithNextLine1.types @@ -3,5 +3,5 @@ // 0. It should be counted as a space and should not cause an error. var v = '…'; >v : string ->'…' : string +>'…' : "\u0085" diff --git a/tests/baselines/reference/fileWithNextLine2.types b/tests/baselines/reference/fileWithNextLine2.types index c3e1fd642cf..d7d08ef5b3f 100644 --- a/tests/baselines/reference/fileWithNextLine2.types +++ b/tests/baselines/reference/fileWithNextLine2.types @@ -3,5 +3,5 @@ // it should be treated like a space var v =…0; >v : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/fixingTypeParametersRepeatedly1.types b/tests/baselines/reference/fixingTypeParametersRepeatedly1.types index 273c66b342d..41e705ba943 100644 --- a/tests/baselines/reference/fixingTypeParametersRepeatedly1.types +++ b/tests/baselines/reference/fixingTypeParametersRepeatedly1.types @@ -17,7 +17,7 @@ declare function f(x: T, y: (p: T) => T, z: (p: T) => T): T; f("", x => null, x => x.toLowerCase()); >f("", x => null, x => x.toLowerCase()) : string >f : (x: T, y: (p: T) => T, z: (p: T) => T) => T ->"" : string +>"" : "" >x => null : (x: string) => any >x : string >null : null @@ -50,7 +50,7 @@ declare function g(); g("", x => null, x => x.toLowerCase()); >g("", x => null, x => x.toLowerCase()) : string >g : { (x: T, y: (p: T) => T, z: (p: T) => T): T; (): any; } ->"" : string +>"" : "" >x => null : (x: string) => any >x : string >null : null diff --git a/tests/baselines/reference/for-of13.types b/tests/baselines/reference/for-of13.types index e176b1bbf0c..af30e85fa17 100644 --- a/tests/baselines/reference/for-of13.types +++ b/tests/baselines/reference/for-of13.types @@ -7,6 +7,6 @@ for (v of [""].values()) { } >[""].values() : IterableIterator >[""].values : () => IterableIterator >[""] : string[] ->"" : string +>"" : "" >values : () => IterableIterator diff --git a/tests/baselines/reference/for-of18.types b/tests/baselines/reference/for-of18.types index 415f2b11568..86978b62cc7 100644 --- a/tests/baselines/reference/for-of18.types +++ b/tests/baselines/reference/for-of18.types @@ -18,11 +18,11 @@ class StringIterator { value: "", >value : string ->"" : string +>"" : "" done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/for-of19.types b/tests/baselines/reference/for-of19.types index 5128617bf24..a2882ccf1ac 100644 --- a/tests/baselines/reference/for-of19.types +++ b/tests/baselines/reference/for-of19.types @@ -27,7 +27,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/for-of20.types b/tests/baselines/reference/for-of20.types index de12979c650..9274c7f4b96 100644 --- a/tests/baselines/reference/for-of20.types +++ b/tests/baselines/reference/for-of20.types @@ -27,7 +27,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/for-of21.types b/tests/baselines/reference/for-of21.types index cab24c525d9..1366cb1a420 100644 --- a/tests/baselines/reference/for-of21.types +++ b/tests/baselines/reference/for-of21.types @@ -27,7 +27,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/for-of22.types b/tests/baselines/reference/for-of22.types index f15a1d7e114..80cd42b2b33 100644 --- a/tests/baselines/reference/for-of22.types +++ b/tests/baselines/reference/for-of22.types @@ -28,7 +28,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/for-of23.types b/tests/baselines/reference/for-of23.types index 87f1eeabbb7..ed74156f514 100644 --- a/tests/baselines/reference/for-of23.types +++ b/tests/baselines/reference/for-of23.types @@ -5,8 +5,8 @@ for (const v of new FooIterator) { >FooIterator : typeof FooIterator const v = 0; // new scope ->v : number ->0 : number +>v : 0 +>0 : 0 } class Foo { } @@ -28,7 +28,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/for-of36.types b/tests/baselines/reference/for-of36.types index f55b5377acc..1448c212371 100644 --- a/tests/baselines/reference/for-of36.types +++ b/tests/baselines/reference/for-of36.types @@ -2,7 +2,7 @@ var tuple: [string, boolean] = ["", true]; >tuple : [string, boolean] >["", true] : [string, true] ->"" : string +>"" : "" >true : true for (var v of tuple) { diff --git a/tests/baselines/reference/for-of37.types b/tests/baselines/reference/for-of37.types index 986e2678402..1168921596e 100644 --- a/tests/baselines/reference/for-of37.types +++ b/tests/baselines/reference/for-of37.types @@ -5,7 +5,7 @@ var map = new Map([["", true]]); >Map : MapConstructor >[["", true]] : [string, true][] >["", true] : [string, true] ->"" : string +>"" : "" >true : true for (var v of map) { diff --git a/tests/baselines/reference/for-of38.types b/tests/baselines/reference/for-of38.types index 78223cfc5be..e2201d24394 100644 --- a/tests/baselines/reference/for-of38.types +++ b/tests/baselines/reference/for-of38.types @@ -5,7 +5,7 @@ var map = new Map([["", true]]); >Map : MapConstructor >[["", true]] : [string, true][] >["", true] : [string, true] ->"" : string +>"" : "" >true : true for (var [k, v] of map) { diff --git a/tests/baselines/reference/for-of4.types b/tests/baselines/reference/for-of4.types index 5b8990797ba..ef73afdb9d2 100644 --- a/tests/baselines/reference/for-of4.types +++ b/tests/baselines/reference/for-of4.types @@ -2,7 +2,7 @@ for (var v of [0]) { >v : number >[0] : number[] ->0 : number +>0 : 0 v; >v : number diff --git a/tests/baselines/reference/for-of40.types b/tests/baselines/reference/for-of40.types index 9d2207409f3..4c690ed9ce7 100644 --- a/tests/baselines/reference/for-of40.types +++ b/tests/baselines/reference/for-of40.types @@ -5,14 +5,14 @@ var map = new Map([["", true]]); >Map : MapConstructor >[["", true]] : [string, true][] >["", true] : [string, true] ->"" : string +>"" : "" >true : true for (var [k = "", v = false] of map) { >k : string ->"" : string +>"" : "" >v : boolean ->false : boolean +>false : false >map : Map k; diff --git a/tests/baselines/reference/for-of41.types b/tests/baselines/reference/for-of41.types index 31e3e253002..70550035783 100644 --- a/tests/baselines/reference/for-of41.types +++ b/tests/baselines/reference/for-of41.types @@ -5,11 +5,11 @@ var array = [{x: [0], y: {p: ""}}] >{x: [0], y: {p: ""}} : { x: number[]; y: { p: string; }; } >x : number[] >[0] : number[] ->0 : number +>0 : 0 >y : { p: string; } >{p: ""} : { p: string; } >p : string ->"" : string +>"" : "" for (var {x: [a], y: {p}} of array) { >x : any diff --git a/tests/baselines/reference/for-of42.types b/tests/baselines/reference/for-of42.types index 64327bcc27f..c0495982a08 100644 --- a/tests/baselines/reference/for-of42.types +++ b/tests/baselines/reference/for-of42.types @@ -4,9 +4,9 @@ var array = [{ x: "", y: 0 }] >[{ x: "", y: 0 }] : { x: string; y: number; }[] >{ x: "", y: 0 } : { x: string; y: number; } >x : string ->"" : string +>"" : "" >y : number ->0 : number +>0 : 0 for (var {x: a, y: b} of array) { >x : any diff --git a/tests/baselines/reference/for-of43.types b/tests/baselines/reference/for-of43.types index a11cd47182c..2327f1bafed 100644 --- a/tests/baselines/reference/for-of43.types +++ b/tests/baselines/reference/for-of43.types @@ -4,22 +4,22 @@ var array = [{ x: "", y: 0 }] >[{ x: "", y: 0 }] : { x: string; y: number; }[] >{ x: "", y: 0 } : { x: string; y: number; } >x : string ->"" : string +>"" : "" >y : number ->0 : number +>0 : 0 for (var {x: a = "", y: b = true} of array) { >x : any >a : string ->"" : string +>"" : "" >y : any ->b : number | boolean ->true : boolean +>b : number | true +>true : true >array : { x: string; y: number; }[] a; >a : string b; ->b : number | boolean +>b : number | true } diff --git a/tests/baselines/reference/for-of44.types b/tests/baselines/reference/for-of44.types index 152edd6f165..42da734edb9 100644 --- a/tests/baselines/reference/for-of44.types +++ b/tests/baselines/reference/for-of44.types @@ -1,15 +1,15 @@ === tests/cases/conformance/es6/for-ofStatements/for-of44.ts === var array: [number, string | boolean | symbol][] = [[0, ""], [0, true], [1, Symbol()]] >array : [number, string | boolean | symbol][] ->[[0, ""], [0, true], [1, Symbol()]] : ([number, string] | [number, true] | [number, symbol])[] ->[0, ""] : [number, string] ->0 : number ->"" : string +>[[0, ""], [0, true], [1, Symbol()]] : ([number, ""] | [number, true] | [number, symbol])[] +>[0, ""] : [number, ""] +>0 : 0 +>"" : "" >[0, true] : [number, true] ->0 : number +>0 : 0 >true : true >[1, Symbol()] : [number, symbol] ->1 : number +>1 : 1 >Symbol() : symbol >Symbol : SymbolConstructor diff --git a/tests/baselines/reference/for-of45.types b/tests/baselines/reference/for-of45.types index a2a70ddfed3..6e6a0a11bf4 100644 --- a/tests/baselines/reference/for-of45.types +++ b/tests/baselines/reference/for-of45.types @@ -9,14 +9,14 @@ var map = new Map([["", true]]); >Map : MapConstructor >[["", true]] : [string, true][] >["", true] : [string, true] ->"" : string +>"" : "" >true : true for ([k = "", v = false] of map) { ->[k = "", v = false] : [string, false] ->k = "" : string +>[k = "", v = false] : [string, boolean] +>k = "" : "" >k : string ->"" : string +>"" : "" >v = false : false >v : boolean >false : false diff --git a/tests/baselines/reference/for-of46.errors.txt b/tests/baselines/reference/for-of46.errors.txt index 13685b122ca..c2a47bffdf6 100644 --- a/tests/baselines/reference/for-of46.errors.txt +++ b/tests/baselines/reference/for-of46.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,7): error TS2322: Type 'boolean' is not assignable to type 'string'. -tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,18): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,7): error TS2322: Type 'false' is not assignable to type 'string'. +tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,18): error TS2322: Type '""' is not assignable to type 'boolean'. ==== tests/cases/conformance/es6/for-ofStatements/for-of46.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/conformance/es6/for-ofStatements/for-of46.ts(3,18): error TS2322: Ty var map = new Map([["", true]]); for ([k = false, v = ""] of map) { ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. +!!! error TS2322: Type 'false' is not assignable to type 'string'. ~ -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. k; v; } \ No newline at end of file diff --git a/tests/baselines/reference/for-of5.types b/tests/baselines/reference/for-of5.types index 921c327c185..b5bc8f0b30a 100644 --- a/tests/baselines/reference/for-of5.types +++ b/tests/baselines/reference/for-of5.types @@ -2,7 +2,7 @@ for (let v of [0]) { >v : number >[0] : number[] ->0 : number +>0 : 0 v; >v : number diff --git a/tests/baselines/reference/for-of50.types b/tests/baselines/reference/for-of50.types index 87ad29793e8..8da06665711 100644 --- a/tests/baselines/reference/for-of50.types +++ b/tests/baselines/reference/for-of50.types @@ -5,7 +5,7 @@ var map = new Map([["", true]]); >Map : MapConstructor >[["", true]] : [string, true][] >["", true] : [string, true] ->"" : string +>"" : "" >true : true for (const [k, v] of map) { diff --git a/tests/baselines/reference/for-of8.types b/tests/baselines/reference/for-of8.types index 36bb20ef6b0..6122cd935fe 100644 --- a/tests/baselines/reference/for-of8.types +++ b/tests/baselines/reference/for-of8.types @@ -5,5 +5,5 @@ v; for (var v of [0]) { } >v : number >[0] : number[] ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/for-of9.types b/tests/baselines/reference/for-of9.types index bf06bf46034..4cd3cceb825 100644 --- a/tests/baselines/reference/for-of9.types +++ b/tests/baselines/reference/for-of9.types @@ -5,9 +5,9 @@ var v: string; for (v of ["hello"]) { } >v : string >["hello"] : string[] ->"hello" : string +>"hello" : "hello" for (v of "hello") { } >v : string ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/forInModule.types b/tests/baselines/reference/forInModule.types index d78a511206b..74bb866ec51 100644 --- a/tests/baselines/reference/forInModule.types +++ b/tests/baselines/reference/forInModule.types @@ -4,10 +4,10 @@ module Foo { for (var i = 0; i < 1; i++) { >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/forStatements.types b/tests/baselines/reference/forStatements.types index 95b198a7fec..aba3d17b63b 100644 --- a/tests/baselines/reference/forStatements.types +++ b/tests/baselines/reference/forStatements.types @@ -38,7 +38,7 @@ class D{ function F(x: string): number { return 42; } >F : (x: string) => number >x : string ->42 : number +>42 : 42 module M { >M : typeof M @@ -61,18 +61,18 @@ module M { for(var aNumber: number = 9.9;;){} >aNumber : number ->9.9 : number +>9.9 : 9.9 for(var aString: string = 'this is a string';;){} >aString : string ->'this is a string' : string +>'this is a string' : "this is a string" for(var aDate: Date = new Date(12);;){} >aDate : Date >Date : Date >new Date(12) : Date >Date : DateConstructor ->12 : number +>12 : 12 for(var anObject: Object = new Object();;){} >anObject : Object @@ -115,7 +115,7 @@ for(var anObjectLiteral: I = { id: 12 };;){} >I : I >{ id: 12 } : { id: number; } >id : number ->12 : number +>12 : 12 for(var anOtherObjectLiteral: { id: number } = new C();;){} >anOtherObjectLiteral : { id: number; } @@ -136,9 +136,9 @@ for(var anOtherFunction: (x: string) => number = F;;){} for(var aLambda: typeof F = (x) => 2;;){} >aLambda : (x: string) => number >F : (x: string) => number ->(x) => 2 : (x: string) => number +>(x) => 2 : (x: string) => 2 >x : string ->2 : number +>2 : 2 for(var aModule: typeof M = M;;){} >aModule : typeof M @@ -159,7 +159,7 @@ for(var aFunctionInModule: typeof M.F2 = (x) => 'this is a string';;){} >M.F2 : (x: number) => string >M : typeof M >F2 : (x: number) => string ->(x) => 'this is a string' : (x: number) => string +>(x) => 'this is a string' : (x: number) => "this is a string" >x : number ->'this is a string' : string +>'this is a string' : "this is a string" diff --git a/tests/baselines/reference/forStatementsMultipleValidDecl.types b/tests/baselines/reference/forStatementsMultipleValidDecl.types index acb26f17312..f40f4bbbc3c 100644 --- a/tests/baselines/reference/forStatementsMultipleValidDecl.types +++ b/tests/baselines/reference/forStatementsMultipleValidDecl.types @@ -7,7 +7,7 @@ for (var x: number; ;) { } for (var x = 2; ;) { } >x : number ->2 : number +>2 : 2 for (var x = undefined; ;) { } >x : number @@ -20,7 +20,7 @@ function declSpace() { for (var x = 'this is a string'; ;) { } >x : string ->'this is a string' : string +>'this is a string' : "this is a string" } interface Point { x: number; y: number; } >Point : Point @@ -35,16 +35,16 @@ for (var p = { x: 1, y: 2 }; ;) { } >p : Point >{ x: 1, y: 2 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 for (var p: Point = { x: 0, y: undefined }; ;) { } >p : Point >Point : Point >{ x: 0, y: undefined } : { x: number; y: undefined; } >x : number ->0 : number +>0 : 0 >y : undefined >undefined : undefined @@ -52,7 +52,7 @@ for (var p = { x: 1, y: undefined }; ;) { } >p : Point >{ x: 1, y: undefined } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number >undefined : number >undefined : undefined @@ -63,9 +63,9 @@ for (var p: { x: number; y: number; } = { x: 1, y: 2 }; ;) { } >y : number >{ x: 1, y: 2 } : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { } >p : Point @@ -74,7 +74,7 @@ for (var p = <{ x: number; y: number; }>{ x: 0, y: undefined }; ;) { } >y : number >{ x: 0, y: undefined } : { x: number; y: undefined; } >x : number ->0 : number +>0 : 0 >y : undefined >undefined : undefined @@ -86,13 +86,13 @@ for (var fn = function (s: string) { return 42; }; ;) { } >fn : (s: string) => number >function (s: string) { return 42; } : (s: string) => number >s : string ->42 : number +>42 : 42 for (var fn = (s: string) => 3; ;) { } >fn : (s: string) => number >(s: string) => 3 : (s: string) => number >s : string ->3 : number +>3 : 3 for (var fn: (s: string) => number; ;) { } >fn : (s: string) => number @@ -118,8 +118,8 @@ for (var a: string[]; ;) { } for (var a = ['a', 'b']; ;) { } >a : string[] >['a', 'b'] : string[] ->'a' : string ->'b' : string +>'a' : "a" +>'b' : "b" for (var a = []; ;) { } >a : string[] diff --git a/tests/baselines/reference/fromAsIdentifier2.types b/tests/baselines/reference/fromAsIdentifier2.types index ae605f79268..cea6974c946 100644 --- a/tests/baselines/reference/fromAsIdentifier2.types +++ b/tests/baselines/reference/fromAsIdentifier2.types @@ -1,6 +1,6 @@ === tests/cases/compiler/fromAsIdentifier2.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" var from; >from : any diff --git a/tests/baselines/reference/funcdecl.types b/tests/baselines/reference/funcdecl.types index 94c310d7b25..8c632237ef3 100644 --- a/tests/baselines/reference/funcdecl.types +++ b/tests/baselines/reference/funcdecl.types @@ -3,7 +3,7 @@ function simpleFunc() { >simpleFunc : () => string return "this is my simple func"; ->"this is my simple func" : string +>"this is my simple func" : "this is my simple func" } var simpleFuncVar = simpleFunc; >simpleFuncVar : () => string @@ -20,7 +20,7 @@ function withReturn() : string{ >withReturn : () => string return "Hello"; ->"Hello" : string +>"Hello" : "Hello" } var withReturnVar = withReturn; >withReturnVar : () => string @@ -64,9 +64,9 @@ function withInitializedParams(a: string, b0, b = 30, c = "string value") { >a : string >b0 : any >b : number ->30 : number +>30 : 30 >c : string ->"string value" : string +>"string value" : "string value" } var withInitializedParamsVar = withInitializedParams; >withInitializedParamsVar : (a: string, b0: any, b?: number, c?: string) => void @@ -76,7 +76,7 @@ function withOptionalInitializedParams(a: string, c: string = "hello string") { >withOptionalInitializedParams : (a: string, c?: string) => void >a : string >c : string ->"hello string" : string +>"hello string" : "hello string" } var withOptionalInitializedParamsVar = withOptionalInitializedParams; >withOptionalInitializedParamsVar : (a: string, c?: string) => void @@ -139,7 +139,7 @@ m2.foo(() => { var b = 30; >b : number ->30 : number +>30 : 30 return b; >b : number @@ -164,5 +164,5 @@ var f2 = () => { >() => { return "string";} : () => string return "string"; ->"string" : string +>"string" : "string" } diff --git a/tests/baselines/reference/functionAssignment.errors.txt b/tests/baselines/reference/functionAssignment.errors.txt index 19fd0897f98..292c2804431 100644 --- a/tests/baselines/reference/functionAssignment.errors.txt +++ b/tests/baselines/reference/functionAssignment.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/functionAssignment.ts(22,5): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/functionAssignment.ts(22,5): error TS2322: Type '4' is not assignable to type 'string'. tests/cases/compiler/functionAssignment.ts(34,17): error TS2339: Property 'length' does not exist on type 'number'. @@ -26,7 +26,7 @@ tests/cases/compiler/functionAssignment.ts(34,17): error TS2339: Property 'lengt var n = ''; n = 4; ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '4' is not assignable to type 'string'. }); function f3(a: { a: number; b: number; }) { } diff --git a/tests/baselines/reference/functionAssignmentError.types b/tests/baselines/reference/functionAssignmentError.types index 6430aa10fc4..189b6eddf2d 100644 --- a/tests/baselines/reference/functionAssignmentError.types +++ b/tests/baselines/reference/functionAssignmentError.types @@ -2,11 +2,11 @@ var func = function (){return "ONE";}; >func : () => string >function (){return "ONE";} : () => string ->"ONE" : string +>"ONE" : "ONE" func = function (){return "ONE";}; ->func = function (){return "ONE";} : () => string +>func = function (){return "ONE";} : () => "ONE" >func : () => string ->function (){return "ONE";} : () => string ->"ONE" : string +>function (){return "ONE";} : () => "ONE" +>"ONE" : "ONE" diff --git a/tests/baselines/reference/functionCall1.types b/tests/baselines/reference/functionCall1.types index 777fcd79f91..9295a06982e 100644 --- a/tests/baselines/reference/functionCall1.types +++ b/tests/baselines/reference/functionCall1.types @@ -1,7 +1,7 @@ === tests/cases/compiler/functionCall1.ts === function foo():any{return ""}; >foo : () => any ->"" : string +>"" : "" var x = foo(); >x : any diff --git a/tests/baselines/reference/functionCall10.errors.txt b/tests/baselines/reference/functionCall10.errors.txt index 8352fc70a58..7891b7008cb 100644 --- a/tests/baselines/reference/functionCall10.errors.txt +++ b/tests/baselines/reference/functionCall10.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/functionCall10.ts(3,5): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. -tests/cases/compiler/functionCall10.ts(5,8): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/compiler/functionCall10.ts(3,5): error TS2345: Argument of type '"foo"' is not assignable to parameter of type 'number'. +tests/cases/compiler/functionCall10.ts(5,8): error TS2345: Argument of type '"bar"' is not assignable to parameter of type 'number'. ==== tests/cases/compiler/functionCall10.ts (2 errors) ==== @@ -7,9 +7,9 @@ tests/cases/compiler/functionCall10.ts(5,8): error TS2345: Argument of type 'str foo(0, 1); foo('foo'); ~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"foo"' is not assignable to parameter of type 'number'. foo(); foo(1, 'bar'); ~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"bar"' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/functionCall11.errors.txt b/tests/baselines/reference/functionCall11.errors.txt index a1790974bbb..f1a5949acd7 100644 --- a/tests/baselines/reference/functionCall11.errors.txt +++ b/tests/baselines/reference/functionCall11.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/functionCall11.ts(4,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/functionCall11.ts(5,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall11.ts(5,5): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. tests/cases/compiler/functionCall11.ts(6,1): error TS2346: Supplied parameters do not match any signature of call target. @@ -12,7 +12,7 @@ tests/cases/compiler/functionCall11.ts(6,1): error TS2346: Supplied parameters d !!! error TS2346: Supplied parameters do not match any signature of call target. foo(1, 'bar'); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo', 1, 'bar'); ~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/functionCall12.errors.txt b/tests/baselines/reference/functionCall12.errors.txt index eabe1131ec1..ef93a34b080 100644 --- a/tests/baselines/reference/functionCall12.errors.txt +++ b/tests/baselines/reference/functionCall12.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/functionCall12.ts(4,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/functionCall12.ts(5,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/compiler/functionCall12.ts(7,15): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall12.ts(5,5): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall12.ts(7,15): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/functionCall12.ts (3 errors) ==== @@ -12,9 +12,9 @@ tests/cases/compiler/functionCall12.ts(7,15): error TS2345: Argument of type 'nu !!! error TS2346: Supplied parameters do not match any signature of call target. foo(1, 'bar'); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo', 1, 'bar'); foo('foo', 1, 3); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/functionCall13.errors.txt b/tests/baselines/reference/functionCall13.errors.txt index 31c05915aab..a89d7fc1efa 100644 --- a/tests/baselines/reference/functionCall13.errors.txt +++ b/tests/baselines/reference/functionCall13.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/functionCall13.ts(4,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/functionCall13.ts(5,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall13.ts(5,5): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/functionCall13.ts (2 errors) ==== @@ -11,6 +11,6 @@ tests/cases/compiler/functionCall13.ts(5,5): error TS2345: Argument of type 'num !!! error TS2346: Supplied parameters do not match any signature of call target. foo(1, 'bar'); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo', 1, 3); \ No newline at end of file diff --git a/tests/baselines/reference/functionCall14.errors.txt b/tests/baselines/reference/functionCall14.errors.txt index 3b671d0252b..2de62978c84 100644 --- a/tests/baselines/reference/functionCall14.errors.txt +++ b/tests/baselines/reference/functionCall14.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/functionCall14.ts(5,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall14.ts(5,5): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/functionCall14.ts (1 errors) ==== @@ -8,6 +8,6 @@ tests/cases/compiler/functionCall14.ts(5,5): error TS2345: Argument of type 'num foo(); foo(1, 'bar'); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo', 1, 3); \ No newline at end of file diff --git a/tests/baselines/reference/functionCall16.errors.txt b/tests/baselines/reference/functionCall16.errors.txt index eb71df23eca..d338c1305dd 100644 --- a/tests/baselines/reference/functionCall16.errors.txt +++ b/tests/baselines/reference/functionCall16.errors.txt @@ -1,13 +1,13 @@ -tests/cases/compiler/functionCall16.ts(2,12): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall16.ts(2,12): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. tests/cases/compiler/functionCall16.ts(5,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/functionCall16.ts(6,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall16.ts(6,5): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/functionCall16.ts (3 errors) ==== function foo(a:string, b?:string, ...c:number[]){} foo('foo', 1); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo'); foo('foo', 'bar'); foo(); @@ -15,6 +15,6 @@ tests/cases/compiler/functionCall16.ts(6,5): error TS2345: Argument of type 'num !!! error TS2346: Supplied parameters do not match any signature of call target. foo(1, 'bar'); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo', 'bar', 3); \ No newline at end of file diff --git a/tests/baselines/reference/functionCall17.errors.txt b/tests/baselines/reference/functionCall17.errors.txt index 09f36c22cfb..f266554b518 100644 --- a/tests/baselines/reference/functionCall17.errors.txt +++ b/tests/baselines/reference/functionCall17.errors.txt @@ -1,23 +1,23 @@ -tests/cases/compiler/functionCall17.ts(2,12): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall17.ts(2,12): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. tests/cases/compiler/functionCall17.ts(4,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/functionCall17.ts(5,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/compiler/functionCall17.ts(6,12): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall17.ts(5,5): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall17.ts(6,12): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/functionCall17.ts (4 errors) ==== function foo(a:string, b?:string, c?:number, ...d:number[]){} foo('foo', 1); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo'); foo(); ~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. foo(1, 'bar'); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo', 1, 3); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. foo('foo', 'bar', 3, 4); \ No newline at end of file diff --git a/tests/baselines/reference/functionCall2.types b/tests/baselines/reference/functionCall2.types index 152d54cb186..aec991aa85f 100644 --- a/tests/baselines/reference/functionCall2.types +++ b/tests/baselines/reference/functionCall2.types @@ -1,7 +1,7 @@ === tests/cases/compiler/functionCall2.ts === function foo():number{return 1}; >foo : () => number ->1 : number +>1 : 1 var x = foo(); >x : number diff --git a/tests/baselines/reference/functionCall3.types b/tests/baselines/reference/functionCall3.types index b58803ae666..2df6de6fa74 100644 --- a/tests/baselines/reference/functionCall3.types +++ b/tests/baselines/reference/functionCall3.types @@ -2,7 +2,7 @@ function foo():any[]{return [1];} >foo : () => any[] >[1] : number[] ->1 : number +>1 : 1 var x = foo(); >x : any[] diff --git a/tests/baselines/reference/functionCall4.types b/tests/baselines/reference/functionCall4.types index ea60c759a7d..41c406ef483 100644 --- a/tests/baselines/reference/functionCall4.types +++ b/tests/baselines/reference/functionCall4.types @@ -1,7 +1,7 @@ === tests/cases/compiler/functionCall4.ts === function foo():any{return ""}; >foo : () => any ->"" : string +>"" : "" function bar():()=>any{return foo}; >bar : () => () => any diff --git a/tests/baselines/reference/functionCall6.errors.txt b/tests/baselines/reference/functionCall6.errors.txt index 4da265ea5e2..3d590d8f5c2 100644 --- a/tests/baselines/reference/functionCall6.errors.txt +++ b/tests/baselines/reference/functionCall6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/functionCall6.ts(3,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall6.ts(3,5): error TS2345: Argument of type '2' is not assignable to parameter of type 'string'. tests/cases/compiler/functionCall6.ts(4,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/functionCall6.ts(5,1): error TS2346: Supplied parameters do not match any signature of call target. @@ -8,7 +8,7 @@ tests/cases/compiler/functionCall6.ts(5,1): error TS2346: Supplied parameters do foo('bar'); foo(2); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '2' is not assignable to parameter of type 'string'. foo('foo', 'bar'); ~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/functionCall7.errors.txt b/tests/baselines/reference/functionCall7.errors.txt index 576ea9c266e..138c5f62f16 100644 --- a/tests/baselines/reference/functionCall7.errors.txt +++ b/tests/baselines/reference/functionCall7.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/functionCall7.ts(5,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/functionCall7.ts(6,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'c1'. +tests/cases/compiler/functionCall7.ts(6,5): error TS2345: Argument of type '4' is not assignable to parameter of type 'c1'. tests/cases/compiler/functionCall7.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target. @@ -13,7 +13,7 @@ tests/cases/compiler/functionCall7.ts(7,1): error TS2346: Supplied parameters do !!! error TS2346: Supplied parameters do not match any signature of call target. foo(4); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'c1'. +!!! error TS2345: Argument of type '4' is not assignable to parameter of type 'c1'. foo(); ~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/functionCall8.errors.txt b/tests/baselines/reference/functionCall8.errors.txt index 0e5479c8cfd..7cf197d5812 100644 --- a/tests/baselines/reference/functionCall8.errors.txt +++ b/tests/baselines/reference/functionCall8.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/functionCall8.ts(3,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/functionCall8.ts(4,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionCall8.ts(4,5): error TS2345: Argument of type '4' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/functionCall8.ts (2 errors) ==== @@ -10,6 +10,6 @@ tests/cases/compiler/functionCall8.ts(4,5): error TS2345: Argument of type 'numb !!! error TS2346: Supplied parameters do not match any signature of call target. foo(4); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '4' is not assignable to parameter of type 'string'. foo(); \ No newline at end of file diff --git a/tests/baselines/reference/functionCall9.errors.txt b/tests/baselines/reference/functionCall9.errors.txt index d9d00593414..83cda64e204 100644 --- a/tests/baselines/reference/functionCall9.errors.txt +++ b/tests/baselines/reference/functionCall9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/functionCall9.ts(4,11): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/compiler/functionCall9.ts(4,11): error TS2345: Argument of type '"bar"' is not assignable to parameter of type 'number'. tests/cases/compiler/functionCall9.ts(5,1): error TS2346: Supplied parameters do not match any signature of call target. @@ -8,7 +8,7 @@ tests/cases/compiler/functionCall9.ts(5,1): error TS2346: Supplied parameters do foo('foo'); foo('foo','bar'); ~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"bar"' is not assignable to parameter of type 'number'. foo('foo', 1, 'bar'); ~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt index 7d3fa793ec8..7f3d8d90802 100644 --- a/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt +++ b/tests/baselines/reference/functionConstraintSatisfaction2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(5,5): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Function'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(5,5): error TS2345: Argument of type '1' is not assignable to parameter of type 'Function'. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(6,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstraintSatisfaction2.ts(23,14): error TS2345: Argument of type 'Function' is not assignable to parameter of type '(x: string) => string'. @@ -33,7 +33,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/functionConstrain foo(1); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Function'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'Function'. foo(() => { }, 1); ~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/functionExpressionContextualTyping1.types b/tests/baselines/reference/functionExpressionContextualTyping1.types index 893744c4954..e9e6ad66a6d 100644 --- a/tests/baselines/reference/functionExpressionContextualTyping1.types +++ b/tests/baselines/reference/functionExpressionContextualTyping1.types @@ -4,8 +4,8 @@ enum E { red, blue } >E : E ->red : E ->blue : E +>red : E.red +>blue : E.blue // A contextual signature S is extracted from a function type T as follows: // If T is a function type with exactly one call signature, and if that call signature is non- generic, S is that signature. @@ -14,7 +14,7 @@ var a0: (n: number, s: string) => number = (num, str) => { >a0 : (n: number, s: string) => number >n : number >s : string ->(num, str) => { num.toExponential(); return 0;} : (num: number, str: string) => number +>(num, str) => { num.toExponential(); return 0;} : (num: number, str: string) => 0 >num : number >str : string @@ -25,7 +25,7 @@ var a0: (n: number, s: string) => number = (num, str) => { >toExponential : (fractionDigits?: number) => string return 0; ->0 : number +>0 : 0 } class Class { @@ -41,7 +41,7 @@ var a1: (c: Class) => number = (a1) => { >c : Class >Class : Class >Number : Number ->(a1) => { a1.foo(); return 1;} : (a1: Class) => number +>(a1) => { a1.foo(); return 1;} : (a1: Class) => 1 >a1 : Class a1.foo(); @@ -51,7 +51,7 @@ var a1: (c: Class) => number = (a1) => { >foo : () => void return 1; ->1 : number +>1 : 1 } // A contextual signature S is extracted from a function type T as follows: @@ -87,15 +87,15 @@ b2 = (foo, bar) => { return foo + 1; } >bar : string >foo + 1 : number >foo : number ->1 : number +>1 : 1 b2 = (foo, bar) => { return "hello"; } ->b2 = (foo, bar) => { return "hello"; } : (foo: number, bar: string) => string +>b2 = (foo, bar) => { return "hello"; } : (foo: number, bar: string) => "hello" >b2 : ((n: number, s: string) => number) | ((n: number, s: string) => string) ->(foo, bar) => { return "hello"; } : (foo: number, bar: string) => string +>(foo, bar) => { return "hello"; } : (foo: number, bar: string) => "hello" >foo : number >bar : string ->"hello" : string +>"hello" : "hello" var b3: (name: string, num: number, boo: boolean) => void; >b3 : (name: string, num: number, boo: boolean) => void @@ -114,18 +114,18 @@ var b4: (n: E) => string = (number = 1) => { return "hello"; }; >b4 : (n: E) => string >n : E >E : E ->(number = 1) => { return "hello"; } : (number?: E) => string +>(number = 1) => { return "hello"; } : (number?: E) => "hello" >number : E >1 : 1 ->"hello" : string +>"hello" : "hello" var b5: (n: {}) => string = (number = "string") => { return "hello"; }; >b5 : (n: {}) => string >n : {} ->(number = "string") => { return "hello"; } : (number?: {}) => string +>(number = "string") => { return "hello"; } : (number?: {}) => "hello" >number : {} ->"string" : string ->"hello" : string +>"string" : "string" +>"hello" : "hello" // A contextual signature S is extracted from a function type T as follows: // Otherwise, no contextual signature can be extracted from T and S is undefined. diff --git a/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt b/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt index 6a3a7998f09..6248f4e9b5b 100644 --- a/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt +++ b/tests/baselines/reference/functionExpressionContextualTyping2.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts(11,1): error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '((n: number, s: string) => number) | ((n: number, s: string) => string)'. - Type '(foo: number, bar: string) => boolean' is not assignable to type '(n: number, s: string) => string'. - Type 'boolean' is not assignable to type 'string'. +tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts(11,1): error TS2322: Type '(foo: number, bar: string) => true' is not assignable to type '((n: number, s: string) => number) | ((n: number, s: string) => string)'. + Type '(foo: number, bar: string) => true' is not assignable to type '(n: number, s: string) => string'. + Type 'true' is not assignable to type 'string'. ==== tests/cases/conformance/expressions/contextualTyping/functionExpressionContextualTyping2.ts (1 errors) ==== @@ -16,6 +16,6 @@ tests/cases/conformance/expressions/contextualTyping/functionExpressionContextua var a1: typeof a0 | ((n: number, s: string) => string); a1 = (foo, bar) => { return true; } // Error ~~ -!!! error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '((n: number, s: string) => number) | ((n: number, s: string) => string)'. -!!! error TS2322: Type '(foo: number, bar: string) => boolean' is not assignable to type '(n: number, s: string) => string'. -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type '(foo: number, bar: string) => true' is not assignable to type '((n: number, s: string) => number) | ((n: number, s: string) => string)'. +!!! error TS2322: Type '(foo: number, bar: string) => true' is not assignable to type '(n: number, s: string) => string'. +!!! error TS2322: Type 'true' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/functionImplementations.types b/tests/baselines/reference/functionImplementations.types index 6cb1cde1c82..683c4c8ea5f 100644 --- a/tests/baselines/reference/functionImplementations.types +++ b/tests/baselines/reference/functionImplementations.types @@ -102,7 +102,7 @@ var n = function () { >function () { return 3;} : () => number return 3; ->3 : number +>3 : 3 } (); @@ -149,7 +149,7 @@ var n = function (x: T) { >x : T } (4); ->4 : number +>4 : 4 // FunctionExpression with no return type annotation and returns a constrained type parameter type var n = function (x: T) { @@ -164,19 +164,19 @@ var n = function (x: T) { >x : T } (4); ->4 : number +>4 : 4 // FunctionExpression with no return type annotation with multiple return statements with identical types var n = function () { >n : number ->function () { return 3; return 5;}() : number ->function () { return 3; return 5;} : () => number +>function () { return 3; return 5;}() : 3 | 5 +>function () { return 3; return 5;} : () => 3 | 5 return 3; ->3 : number +>3 : 3 return 5; ->5 : number +>5 : 5 }(); @@ -255,7 +255,7 @@ function thisFunc() { function opt1(n = 4) { >opt1 : (n?: number) => void >n : number ->4 : number +>4 : 4 var m = n; >m : number @@ -331,7 +331,7 @@ var f7: (x: number) => string | number = x => { // should be (x: number) => numb if (x < 0) { return x; } >x < 0 : boolean >x : number ->0 : number +>0 : 0 >x : number return x.toString(); diff --git a/tests/baselines/reference/functionInIfStatementInModule.types b/tests/baselines/reference/functionInIfStatementInModule.types index 11cdd80f0a1..48dd8f82d79 100644 --- a/tests/baselines/reference/functionInIfStatementInModule.types +++ b/tests/baselines/reference/functionInIfStatementInModule.types @@ -4,7 +4,7 @@ module Midori >Midori : typeof Midori { if (false) { ->false : boolean +>false : false function Foo(src) >Foo : (src: any) => void diff --git a/tests/baselines/reference/functionLiteral.types b/tests/baselines/reference/functionLiteral.types index 06c811093c3..69a7fc44e51 100644 --- a/tests/baselines/reference/functionLiteral.types +++ b/tests/baselines/reference/functionLiteral.types @@ -4,7 +4,7 @@ var x = () => 1; >x : () => number >() => 1 : () => number ->1 : number +>1 : 1 var x: { >x : () => number diff --git a/tests/baselines/reference/functionMergedWithModule.types b/tests/baselines/reference/functionMergedWithModule.types index ec0143f2923..1752016d5fd 100644 --- a/tests/baselines/reference/functionMergedWithModule.types +++ b/tests/baselines/reference/functionMergedWithModule.types @@ -5,7 +5,7 @@ function foo(title: string) { var x = 10; >x : number ->10 : number +>10 : 10 } module foo.Bar { diff --git a/tests/baselines/reference/functionOnlyHasThrow.types b/tests/baselines/reference/functionOnlyHasThrow.types index c4e8cce38a2..18011f10ada 100644 --- a/tests/baselines/reference/functionOnlyHasThrow.types +++ b/tests/baselines/reference/functionOnlyHasThrow.types @@ -5,5 +5,5 @@ function clone():number { throw new Error("To be implemented"); >new Error("To be implemented") : Error >Error : ErrorConstructor ->"To be implemented" : string +>"To be implemented" : "To be implemented" } diff --git a/tests/baselines/reference/functionOverloadCompatibilityWithVoid02.types b/tests/baselines/reference/functionOverloadCompatibilityWithVoid02.types index aa6fda7222b..6530f5a0a27 100644 --- a/tests/baselines/reference/functionOverloadCompatibilityWithVoid02.types +++ b/tests/baselines/reference/functionOverloadCompatibilityWithVoid02.types @@ -8,5 +8,5 @@ function f(x: string): number { >x : string return 0; ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/functionOverloads.errors.txt b/tests/baselines/reference/functionOverloads.errors.txt index bd3bab3388b..5530f813384 100644 --- a/tests/baselines/reference/functionOverloads.errors.txt +++ b/tests/baselines/reference/functionOverloads.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/functionOverloads.ts(4,13): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionOverloads.ts(4,13): error TS2345: Argument of type '5' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/functionOverloads.ts (1 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/functionOverloads.ts(4,13): error TS2345: Argument of type function foo(bar?: string): any { return "" }; var x = foo(5); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '5' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads12.types b/tests/baselines/reference/functionOverloads12.types index 5db8ff68cd4..d29f6262844 100644 --- a/tests/baselines/reference/functionOverloads12.types +++ b/tests/baselines/reference/functionOverloads12.types @@ -8,7 +8,7 @@ function foo():number; function foo():any { if (true) return ""; else return 0;} >foo : { (): string; (): number; } ->true : boolean ->"" : string ->0 : number +>true : true +>"" : "" +>0 : 0 diff --git a/tests/baselines/reference/functionOverloads13.types b/tests/baselines/reference/functionOverloads13.types index f26067c7eb8..2e77cf73645 100644 --- a/tests/baselines/reference/functionOverloads13.types +++ b/tests/baselines/reference/functionOverloads13.types @@ -10,5 +10,5 @@ function foo(bar:number):number; function foo(bar?:number):any { return "" } >foo : { (bar: number): string; (bar: number): number; } >bar : number ->"" : string +>"" : "" diff --git a/tests/baselines/reference/functionOverloads14.types b/tests/baselines/reference/functionOverloads14.types index 032ed700545..3e88bd04f88 100644 --- a/tests/baselines/reference/functionOverloads14.types +++ b/tests/baselines/reference/functionOverloads14.types @@ -12,5 +12,5 @@ function foo():{a:any;} { return {a:1} } >a : any >{a:1} : { a: number; } >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/functionOverloads15.types b/tests/baselines/reference/functionOverloads15.types index 8fe428e9a40..86c9fc6a665 100644 --- a/tests/baselines/reference/functionOverloads15.types +++ b/tests/baselines/reference/functionOverloads15.types @@ -16,5 +16,5 @@ function foo(foo:{a:string; b?:number;}):any { return "" } >foo : { a: string; b?: number; } >a : string >b : number ->"" : string +>"" : "" diff --git a/tests/baselines/reference/functionOverloads16.types b/tests/baselines/reference/functionOverloads16.types index e6c6ceb57a6..1d7a4184de1 100644 --- a/tests/baselines/reference/functionOverloads16.types +++ b/tests/baselines/reference/functionOverloads16.types @@ -14,5 +14,5 @@ function foo(foo:{a:string; b?:number;}):any { return "" } >foo : { a: string; b?: number; } >a : string >b : number ->"" : string +>"" : "" diff --git a/tests/baselines/reference/functionOverloads2.errors.txt b/tests/baselines/reference/functionOverloads2.errors.txt index 85a4a882487..60fbe2843d9 100644 --- a/tests/baselines/reference/functionOverloads2.errors.txt +++ b/tests/baselines/reference/functionOverloads2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/functionOverloads2.ts(4,13): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. +tests/cases/compiler/functionOverloads2.ts(4,13): error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. ==== tests/cases/compiler/functionOverloads2.ts (1 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/functionOverloads2.ts(4,13): error TS2345: Argument of type function foo(bar: any): any { return bar }; var x = foo(true); ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. \ No newline at end of file +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads21.types b/tests/baselines/reference/functionOverloads21.types index 3b4cf261ea9..4d87e3a123c 100644 --- a/tests/baselines/reference/functionOverloads21.types +++ b/tests/baselines/reference/functionOverloads21.types @@ -15,5 +15,5 @@ function foo(bar:{a:any; b?:string;}[]) { return 0 } >bar : { a: any; b?: string; }[] >a : any >b : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/functionOverloads22.types b/tests/baselines/reference/functionOverloads22.types index 7557b1c049f..ff6b30c084b 100644 --- a/tests/baselines/reference/functionOverloads22.types +++ b/tests/baselines/reference/functionOverloads22.types @@ -18,5 +18,5 @@ function foo(bar:any):{a:any;b?:any;}[] { return [{a:""}] } >[{a:""}] : { a: string; }[] >{a:""} : { a: string; } >a : string ->"" : string +>"" : "" diff --git a/tests/baselines/reference/functionOverloads23.types b/tests/baselines/reference/functionOverloads23.types index ee510a336e1..98970307672 100644 --- a/tests/baselines/reference/functionOverloads23.types +++ b/tests/baselines/reference/functionOverloads23.types @@ -13,5 +13,5 @@ function foo(bar:(a?)=>void) { return 0 } >foo : { (bar: (b: string) => void): any; (bar: (a: number) => void): any; } >bar : (a?: any) => void >a : any ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/functionOverloads25.types b/tests/baselines/reference/functionOverloads25.types index 5b5c3781e74..53539cbc122 100644 --- a/tests/baselines/reference/functionOverloads25.types +++ b/tests/baselines/reference/functionOverloads25.types @@ -9,7 +9,7 @@ function foo(bar:string):number; function foo(bar?:any):any{ return '' }; >foo : { (): string; (bar: string): number; } >bar : any ->'' : string +>'' : "" var x = foo(); >x : string diff --git a/tests/baselines/reference/functionOverloads26.types b/tests/baselines/reference/functionOverloads26.types index 9345507b72e..19f11bcf3fc 100644 --- a/tests/baselines/reference/functionOverloads26.types +++ b/tests/baselines/reference/functionOverloads26.types @@ -9,11 +9,11 @@ function foo(bar:string):number; function foo(bar?:any):any{ return '' } >foo : { (): string; (bar: string): number; } >bar : any ->'' : string +>'' : "" var x = foo('baz'); >x : number >foo('baz') : number >foo : { (): string; (bar: string): number; } ->'baz' : string +>'baz' : "baz" diff --git a/tests/baselines/reference/functionOverloads27.errors.txt b/tests/baselines/reference/functionOverloads27.errors.txt index a5d16935f2f..2b21de7134b 100644 --- a/tests/baselines/reference/functionOverloads27.errors.txt +++ b/tests/baselines/reference/functionOverloads27.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/functionOverloads27.ts(4,13): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/functionOverloads27.ts(4,13): error TS2345: Argument of type '5' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/functionOverloads27.ts (1 errors) ==== @@ -7,5 +7,5 @@ tests/cases/compiler/functionOverloads27.ts(4,13): error TS2345: Argument of typ function foo(bar?:any):any{ return '' } var x = foo(5); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '5' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads28.types b/tests/baselines/reference/functionOverloads28.types index ae4ab6c0664..96d126adf3e 100644 --- a/tests/baselines/reference/functionOverloads28.types +++ b/tests/baselines/reference/functionOverloads28.types @@ -9,7 +9,7 @@ function foo(bar:string):number; function foo(bar?:any):any{ return '' } >foo : { (): string; (bar: string): number; } >bar : any ->'' : string +>'' : "" var t:any; var x = foo(t); >t : any diff --git a/tests/baselines/reference/functionOverloads30.types b/tests/baselines/reference/functionOverloads30.types index a97bc0bb74d..fdbefa027ef 100644 --- a/tests/baselines/reference/functionOverloads30.types +++ b/tests/baselines/reference/functionOverloads30.types @@ -16,5 +16,5 @@ var x = foo('bar'); >x : string >foo('bar') : string >foo : { (bar: string): string; (bar: number): number; } ->'bar' : string +>'bar' : "bar" diff --git a/tests/baselines/reference/functionOverloads31.types b/tests/baselines/reference/functionOverloads31.types index c85470ebd65..a80ba71153e 100644 --- a/tests/baselines/reference/functionOverloads31.types +++ b/tests/baselines/reference/functionOverloads31.types @@ -16,5 +16,5 @@ var x = foo(5); >x : number >foo(5) : number >foo : { (bar: string): string; (bar: number): number; } ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/functionOverloads33.types b/tests/baselines/reference/functionOverloads33.types index 3d57c983305..99d8f429b80 100644 --- a/tests/baselines/reference/functionOverloads33.types +++ b/tests/baselines/reference/functionOverloads33.types @@ -16,5 +16,5 @@ var x = foo(5); >x : number >foo(5) : number >foo : { (bar: string): string; (bar: any): number; } ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/functionOverloads35.types b/tests/baselines/reference/functionOverloads35.types index 1b811cf4246..8686bc2fdf8 100644 --- a/tests/baselines/reference/functionOverloads35.types +++ b/tests/baselines/reference/functionOverloads35.types @@ -21,5 +21,5 @@ var x = foo({a:1}); >foo : { (bar: { a: number; }): number; (bar: { a: string; }): string; } >{a:1} : { a: number; } >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/functionOverloads36.types b/tests/baselines/reference/functionOverloads36.types index c8c1f7cede8..8a78f466d34 100644 --- a/tests/baselines/reference/functionOverloads36.types +++ b/tests/baselines/reference/functionOverloads36.types @@ -21,5 +21,5 @@ var x = foo({a:'foo'}); >foo : { (bar: { a: number; }): number; (bar: { a: string; }): string; } >{a:'foo'} : { a: string; } >a : string ->'foo' : string +>'foo' : "foo" diff --git a/tests/baselines/reference/functionOverloads38.types b/tests/baselines/reference/functionOverloads38.types index d718569c9bf..e8b32f78e7c 100644 --- a/tests/baselines/reference/functionOverloads38.types +++ b/tests/baselines/reference/functionOverloads38.types @@ -22,5 +22,5 @@ var x = foo([{a:1}]); >[{a:1}] : { a: number; }[] >{a:1} : { a: number; } >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/functionOverloads39.types b/tests/baselines/reference/functionOverloads39.types index bf4a6ec5ae9..058a98680f6 100644 --- a/tests/baselines/reference/functionOverloads39.types +++ b/tests/baselines/reference/functionOverloads39.types @@ -21,6 +21,6 @@ var x = foo([{a:true}]); >foo : { (bar: { a: number; }[]): string; (bar: { a: boolean; }[]): number; } >[{a:true}] : { a: true; }[] >{a:true} : { a: true; } ->a : true +>a : boolean >true : true diff --git a/tests/baselines/reference/functionOverloads40.errors.txt b/tests/baselines/reference/functionOverloads40.errors.txt index f965a4eb9e1..d871946cde2 100644 --- a/tests/baselines/reference/functionOverloads40.errors.txt +++ b/tests/baselines/reference/functionOverloads40.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/functionOverloads40.ts(4,13): error TS2345: Argument of type '{ a: string; }[]' is not assignable to parameter of type '{ a: boolean; }[]'. - Type '{ a: string; }' is not assignable to type '{ a: boolean; }'. +tests/cases/compiler/functionOverloads40.ts(4,13): error TS2345: Argument of type '{ a: "bar"; }[]' is not assignable to parameter of type '{ a: boolean; }[]'. + Type '{ a: "bar"; }' is not assignable to type '{ a: boolean; }'. Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'boolean'. + Type '"bar"' is not assignable to type 'boolean'. ==== tests/cases/compiler/functionOverloads40.ts (1 errors) ==== @@ -10,8 +10,8 @@ tests/cases/compiler/functionOverloads40.ts(4,13): error TS2345: Argument of typ function foo(bar:{a:any;}[]):any{ return bar } var x = foo([{a:'bar'}]); ~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: string; }[]' is not assignable to parameter of type '{ a: boolean; }[]'. -!!! error TS2345: Type '{ a: string; }' is not assignable to type '{ a: boolean; }'. +!!! error TS2345: Argument of type '{ a: "bar"; }[]' is not assignable to parameter of type '{ a: boolean; }[]'. +!!! error TS2345: Type '{ a: "bar"; }' is not assignable to type '{ a: boolean; }'. !!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. +!!! error TS2345: Type '"bar"' is not assignable to type 'boolean'. \ No newline at end of file diff --git a/tests/baselines/reference/functionOverloads42.types b/tests/baselines/reference/functionOverloads42.types index 32e99d46aa1..e709ea8b7ef 100644 --- a/tests/baselines/reference/functionOverloads42.types +++ b/tests/baselines/reference/functionOverloads42.types @@ -22,5 +22,5 @@ var x = foo([{a:'s'}]); >[{a:'s'}] : { a: string; }[] >{a:'s'} : { a: string; } >a : string ->'s' : string +>'s' : "s" diff --git a/tests/baselines/reference/functionOverloads43.types b/tests/baselines/reference/functionOverloads43.types index e48ffd41f60..41a29fd0fe3 100644 --- a/tests/baselines/reference/functionOverloads43.types +++ b/tests/baselines/reference/functionOverloads43.types @@ -34,7 +34,7 @@ var x = foo([{a: "str"}]); >[{a: "str"}] : { a: string; }[] >{a: "str"} : { a: string; } >a : string ->"str" : string +>"str" : "str" var y = foo([{a: 100}]); >y : number @@ -43,5 +43,5 @@ var y = foo([{a: 100}]); >[{a: 100}] : { a: number; }[] >{a: 100} : { a: number; } >a : number ->100 : number +>100 : 100 diff --git a/tests/baselines/reference/functionOverloads44.types b/tests/baselines/reference/functionOverloads44.types index 48fcfa3371b..af046ba7206 100644 --- a/tests/baselines/reference/functionOverloads44.types +++ b/tests/baselines/reference/functionOverloads44.types @@ -66,7 +66,7 @@ var x1 = foo1([{a: "str"}]); >[{a: "str"}] : { a: string; }[] >{a: "str"} : { a: string; } >a : string ->"str" : string +>"str" : "str" var y1 = foo1([{a: 100}]); >y1 : Dog @@ -75,7 +75,7 @@ var y1 = foo1([{a: 100}]); >[{a: 100}] : { a: number; }[] >{a: 100} : { a: number; } >a : number ->100 : number +>100 : 100 var x2 = foo2([{a: "str"}]); >x2 : Dog | Cat @@ -84,7 +84,7 @@ var x2 = foo2([{a: "str"}]); >[{a: "str"}] : { a: string; }[] >{a: "str"} : { a: string; } >a : string ->"str" : string +>"str" : "str" var y2 = foo2([{a: 100}]); >y2 : Cat @@ -93,5 +93,5 @@ var y2 = foo2([{a: 100}]); >[{a: 100}] : { a: number; }[] >{a: 100} : { a: number; } >a : number ->100 : number +>100 : 100 diff --git a/tests/baselines/reference/functionOverloads45.types b/tests/baselines/reference/functionOverloads45.types index 29eb55a40ed..ca778e68056 100644 --- a/tests/baselines/reference/functionOverloads45.types +++ b/tests/baselines/reference/functionOverloads45.types @@ -66,7 +66,7 @@ var x1 = foo1([{a: "str"}]); >[{a: "str"}] : { a: string; }[] >{a: "str"} : { a: string; } >a : string ->"str" : string +>"str" : "str" var y1 = foo1([{a: 100}]); >y1 : Cat @@ -75,7 +75,7 @@ var y1 = foo1([{a: 100}]); >[{a: 100}] : { a: number; }[] >{a: 100} : { a: number; } >a : number ->100 : number +>100 : 100 var x2 = foo2([{a: "str"}]); >x2 : Dog @@ -84,7 +84,7 @@ var x2 = foo2([{a: "str"}]); >[{a: "str"}] : { a: string; }[] >{a: "str"} : { a: string; } >a : string ->"str" : string +>"str" : "str" var y2 = foo2([{a: 100}]); >y2 : Cat @@ -93,5 +93,5 @@ var y2 = foo2([{a: 100}]); >[{a: 100}] : { a: number; }[] >{a: 100} : { a: number; } >a : number ->100 : number +>100 : 100 diff --git a/tests/baselines/reference/functionOverloads7.types b/tests/baselines/reference/functionOverloads7.types index 7160068126f..5bbc25dd5e2 100644 --- a/tests/baselines/reference/functionOverloads7.types +++ b/tests/baselines/reference/functionOverloads7.types @@ -12,7 +12,7 @@ class foo { private bar(foo?: any){ return "foo" } >bar : { (): any; (foo: string): any; } >foo : any ->"foo" : string +>"foo" : "foo" public n() { >n : () => void @@ -31,7 +31,7 @@ class foo { >this.bar : { (): any; (foo: string): any; } >this : this >bar : { (): any; (foo: string): any; } ->"test" : string +>"test" : "test" } } diff --git a/tests/baselines/reference/functionOverloads8.types b/tests/baselines/reference/functionOverloads8.types index 4751533e2af..c6876cdbe8f 100644 --- a/tests/baselines/reference/functionOverloads8.types +++ b/tests/baselines/reference/functionOverloads8.types @@ -9,5 +9,5 @@ function foo(foo:string); function foo(foo?:any){ return '' } >foo : { (): any; (foo: string): any; } >foo : any ->'' : string +>'' : "" diff --git a/tests/baselines/reference/functionOverloads9.types b/tests/baselines/reference/functionOverloads9.types index 88586c32eb2..6b7e1992f99 100644 --- a/tests/baselines/reference/functionOverloads9.types +++ b/tests/baselines/reference/functionOverloads9.types @@ -6,11 +6,11 @@ function foo(foo:string); function foo(foo?:string){ return '' }; >foo : (foo: string) => any >foo : string ->'' : string +>'' : "" var x = foo('foo'); >x : any >foo('foo') : any >foo : (foo: string) => any ->'foo' : string +>'foo' : "foo" diff --git a/tests/baselines/reference/functionReturn.types b/tests/baselines/reference/functionReturn.types index f9c0b36fbc2..7b8f58de2a8 100644 --- a/tests/baselines/reference/functionReturn.types +++ b/tests/baselines/reference/functionReturn.types @@ -21,7 +21,7 @@ function f4(): string { >f4 : () => string return ''; ->'' : string +>'' : "" return; } @@ -29,7 +29,7 @@ function f5(): string { >f5 : () => string return ''; ->'' : string +>'' : "" return undefined; >undefined : undefined diff --git a/tests/baselines/reference/functionType.types b/tests/baselines/reference/functionType.types index ac3d5c9944d..985a66f435d 100644 --- a/tests/baselines/reference/functionType.types +++ b/tests/baselines/reference/functionType.types @@ -7,7 +7,7 @@ salt.apply("hello", []); >salt.apply : (this: Function, thisArg: any, argArray?: any) => any >salt : () => void >apply : (this: Function, thisArg: any, argArray?: any) => any ->"hello" : string +>"hello" : "hello" >[] : undefined[] (new Function("return 5"))(); @@ -15,7 +15,7 @@ salt.apply("hello", []); >(new Function("return 5")) : Function >new Function("return 5") : Function >Function : FunctionConstructor ->"return 5" : string +>"return 5" : "return 5" diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.types index d695157db40..c45eb6f59cd 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements1.types @@ -2,5 +2,5 @@ function foo(x = 0) { } >foo : (x?: number) => void >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.types index 8f8f03fafb1..783b0f72422 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements10.types @@ -3,11 +3,11 @@ function foo(a = [0]) { } >foo : (a?: number[]) => void >a : number[] >[0] : number[] ->0 : number +>0 : 0 function bar(a = [0]) { >bar : (a?: number[]) => void >a : number[] >[0] : number[] ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.types index e0a87bb2656..c548b0d5e92 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements11.types @@ -7,12 +7,12 @@ function foo(a = v[0]) { } >a : any >v[0] : any >v : any[] ->0 : number +>0 : 0 function bar(a = v[0]) { >bar : (a?: any) => void >a : any >v[0] : any >v : any[] ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.types index 58c2009886a..63b66352e54 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements13.types @@ -7,14 +7,14 @@ function foo(a = [1 + 1]) { } >a : number[] >[1 + 1] : number[] >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 function bar(a = [1 + 1]) { >bar : (a?: number[]) => void >a : number[] >[1 + 1] : number[] >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.types index 2a5fbab6919..b88e03e5cce 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements14.types @@ -8,8 +8,8 @@ function foo(a = v[1 + 1]) { } >v[1 + 1] : any >v : any[] >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 function bar(a = v[1 + 1]) { >bar : (a?: any) => void @@ -17,6 +17,6 @@ function bar(a = v[1 + 1]) { >v[1 + 1] : any >v : any[] >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.types index e35f5a5f4e0..99020ba020a 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements15.types @@ -7,14 +7,14 @@ function foo(a = (1 + 1)) { } >a : number >(1 + 1) : number >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 function bar(a = (1 + 1)) { >bar : (a?: number) => void >a : number >(1 + 1) : number >1 + 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.types index 76b6b56dfa4..ac34fa3ad51 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements2.types @@ -2,5 +2,5 @@ function foo(x = 0) { >foo : (x?: number) => void >x : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.types index 4254c0d28a9..6d10e3fe396 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements3.types @@ -2,10 +2,10 @@ function foo(a = "") { } >foo : (a?: string) => void >a : string ->"" : string +>"" : "" function bar(a = "") { >bar : (a?: string) => void >a : string ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.types index 99e93927e0a..52ef4b0bca0 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements5.types @@ -2,10 +2,10 @@ function foo(a = 0) { } >foo : (a?: number) => void >a : number ->0 : number +>0 : 0 function bar(a = 0) { >bar : (a?: number) => void >a : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.types index 6100a6dedce..d47f63a0ba4 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements6.types @@ -2,10 +2,10 @@ function foo(a = true) { } >foo : (a?: boolean) => void >a : boolean ->true : boolean +>true : true function bar(a = true) { >bar : (a?: boolean) => void >a : boolean ->true : boolean +>true : true } diff --git a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.types b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.types index 866087a9f9b..987691e14e4 100644 --- a/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.types +++ b/tests/baselines/reference/functionWithDefaultParameterWithNoStatements7.types @@ -2,10 +2,10 @@ function foo(a = false) { } >foo : (a?: boolean) => void >a : boolean ->false : boolean +>false : false function bar(a = false) { >bar : (a?: boolean) => void >a : boolean ->false : boolean +>false : false } diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements.types b/tests/baselines/reference/functionWithMultipleReturnStatements.types index 63cbe235c38..775ca52e1db 100644 --- a/tests/baselines/reference/functionWithMultipleReturnStatements.types +++ b/tests/baselines/reference/functionWithMultipleReturnStatements.types @@ -4,62 +4,62 @@ // it is an error if there is no single BCT, these are error cases function f1() { ->f1 : () => string | number +>f1 : () => "" | 1 if (true) { ->true : boolean +>true : true return 1; ->1 : number +>1 : 1 } else { return ''; ->'' : string +>'' : "" } } function f2() { ->f2 : () => string | number +>f2 : () => "" | 1 | 2 if (true) { ->true : boolean +>true : true return 1; ->1 : number +>1 : 1 } else if (false) { ->false : boolean +>false : false return 2; ->2 : number +>2 : 2 } else { return ''; ->'' : string +>'' : "" } } function f3() { ->f3 : () => string | number +>f3 : () => "" | 1 try { return 1; ->1 : number +>1 : 1 } catch (e) { >e : any return ''; ->'' : string +>'' : "" } } function f4() { ->f4 : () => string | number +>f4 : () => "" | 1 try { return 1; ->1 : number +>1 : 1 } catch (e) { >e : any @@ -67,18 +67,18 @@ function f4() { } finally { return ''; ->'' : string +>'' : "" } } function f5() { ->f5 : () => string | number +>f5 : () => "" | 1 return 1; ->1 : number +>1 : 1 return ''; ->'' : string +>'' : "" } function f6(x: T, y:U) { @@ -91,7 +91,7 @@ function f6(x: T, y:U) { >U : U if (true) { ->true : boolean +>true : true return x; >x : T @@ -115,7 +115,7 @@ function f8(x: T, y: U) { >U : U if (true) { ->true : boolean +>true : true return x; >x : T diff --git a/tests/baselines/reference/functionWithMultipleReturnStatements2.types b/tests/baselines/reference/functionWithMultipleReturnStatements2.types index 7700329971a..4615299bbf1 100644 --- a/tests/baselines/reference/functionWithMultipleReturnStatements2.types +++ b/tests/baselines/reference/functionWithMultipleReturnStatements2.types @@ -7,10 +7,10 @@ function f1() { >f1 : () => number if (true) { ->true : boolean +>true : true return 1; ->1 : number +>1 : 1 } else { return null; @@ -19,23 +19,23 @@ function f1() { } function f2() { ->f2 : () => number +>f2 : () => 1 | 2 if (true) { ->true : boolean +>true : true return 1; ->1 : number +>1 : 1 } else if (false) { ->false : boolean +>false : false return null; >null : null } else { return 2; ->2 : number +>2 : 2 } } @@ -44,7 +44,7 @@ function f4() { try { return 1; ->1 : number +>1 : 1 } catch (e) { >e : any @@ -54,7 +54,7 @@ function f4() { } finally { return 1; ->1 : number +>1 : 1 } } @@ -62,7 +62,7 @@ function f5() { >f5 : () => Object return 1; ->1 : number +>1 : 1 return new Object(); >new Object() : Object @@ -76,7 +76,7 @@ function f6(x: T) { >T : T if (true) { ->true : boolean +>true : true return x; >x : T @@ -110,7 +110,7 @@ function f9() { >f9 : () => { x: number; y?: number; } | { x: number; z?: number; } if (true) { ->true : boolean +>true : true return a; >a : { x: number; y?: number; } @@ -126,7 +126,7 @@ function f10() { >f10 : () => { x: number; y?: number; } | { x: number; z?: number; } if (true) { ->true : boolean +>true : true return b; >b : { x: number; z?: number; } @@ -142,7 +142,7 @@ function f11() { >f11 : () => (x: number) => void if (true) { ->true : boolean +>true : true return (x: number) => { } >(x: number) => { } : (x: number) => void @@ -161,7 +161,7 @@ function f12() { >f12 : () => (x: Object) => void if (true) { ->true : boolean +>true : true return (x: Object) => { } >(x: Object) => { } : (x: Object) => void diff --git a/tests/baselines/reference/functionWithNoBestCommonType1.types b/tests/baselines/reference/functionWithNoBestCommonType1.types index 801c25d239f..f93ffad3379 100644 --- a/tests/baselines/reference/functionWithNoBestCommonType1.types +++ b/tests/baselines/reference/functionWithNoBestCommonType1.types @@ -1,10 +1,10 @@ === tests/cases/compiler/functionWithNoBestCommonType1.ts === function foo() { ->foo : () => boolean | void +>foo : () => true | void return true; ->true : boolean +>true : true return bar(); >bar() : void diff --git a/tests/baselines/reference/functionWithNoBestCommonType2.types b/tests/baselines/reference/functionWithNoBestCommonType2.types index cae5f1dbb64..76fdbda535f 100644 --- a/tests/baselines/reference/functionWithNoBestCommonType2.types +++ b/tests/baselines/reference/functionWithNoBestCommonType2.types @@ -1,11 +1,11 @@ === tests/cases/compiler/functionWithNoBestCommonType2.ts === var v = function () { ->v : () => boolean | void ->function () { return true; return bar();} : () => boolean | void +>v : () => true | void +>function () { return true; return bar();} : () => true | void return true; ->true : boolean +>true : true return bar(); >bar() : void diff --git a/tests/baselines/reference/functionWithThrowButNoReturn1.types b/tests/baselines/reference/functionWithThrowButNoReturn1.types index c136d8a4076..462d5b9c88a 100644 --- a/tests/baselines/reference/functionWithThrowButNoReturn1.types +++ b/tests/baselines/reference/functionWithThrowButNoReturn1.types @@ -5,7 +5,7 @@ function fn(): number { throw new Error('NYI'); >new Error('NYI') : Error >Error : ErrorConstructor ->'NYI' : string +>'NYI' : "NYI" var t; >t : any diff --git a/tests/baselines/reference/functionsInClassExpressions.types b/tests/baselines/reference/functionsInClassExpressions.types index ee4b5696cc1..b00f3df3490 100644 --- a/tests/baselines/reference/functionsInClassExpressions.types +++ b/tests/baselines/reference/functionsInClassExpressions.types @@ -12,7 +12,7 @@ let Foo = class { } bar = 0; >bar : number ->0 : number +>0 : 0 inc = () => { >inc : () => void diff --git a/tests/baselines/reference/funduleOfFunctionWithoutReturnTypeAnnotation.types b/tests/baselines/reference/funduleOfFunctionWithoutReturnTypeAnnotation.types index 2d71370c2ac..e58cf1551fa 100644 --- a/tests/baselines/reference/funduleOfFunctionWithoutReturnTypeAnnotation.types +++ b/tests/baselines/reference/funduleOfFunctionWithoutReturnTypeAnnotation.types @@ -12,6 +12,6 @@ module fn { export var n = 1; >n : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/generatedContextualTyping.types b/tests/baselines/reference/generatedContextualTyping.types index 2e9625cdb8b..a9b350f8564 100644 --- a/tests/baselines/reference/generatedContextualTyping.types +++ b/tests/baselines/reference/generatedContextualTyping.types @@ -2849,7 +2849,7 @@ var x285: () => Base[] = true ? () => [d1, d2] : () => [d1, d2]; >x285 : () => Base[] >Base : Base >true ? () => [d1, d2] : () => [d1, d2] : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >() => [d1, d2] : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -2863,7 +2863,7 @@ var x286: () => Base[] = true ? function() { return [d1, d2] } : function() { re >x286 : () => Base[] >Base : Base >true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -2877,7 +2877,7 @@ var x287: () => Base[] = true ? function named() { return [d1, d2] } : function >x287 : () => Base[] >Base : Base >true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >named : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -2893,7 +2893,7 @@ var x288: { (): Base[]; } = true ? () => [d1, d2] : () => [d1, d2]; >x288 : () => Base[] >Base : Base >true ? () => [d1, d2] : () => [d1, d2] : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >() => [d1, d2] : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -2907,7 +2907,7 @@ var x289: { (): Base[]; } = true ? function() { return [d1, d2] } : function() { >x289 : () => Base[] >Base : Base >true ? function() { return [d1, d2] } : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -2921,7 +2921,7 @@ var x290: { (): Base[]; } = true ? function named() { return [d1, d2] } : functi >x290 : () => Base[] >Base : Base >true ? function named() { return [d1, d2] } : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >named : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -2937,7 +2937,7 @@ var x291: Base[] = true ? [d1, d2] : [d1, d2]; >x291 : Base[] >Base : Base >true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean +>true : true >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2950,7 +2950,7 @@ var x292: Array = true ? [d1, d2] : [d1, d2]; >Array : T[] >Base : Base >true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean +>true : true >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2963,7 +2963,7 @@ var x293: { [n: number]: Base; } = true ? [d1, d2] : [d1, d2]; >n : number >Base : Base >true ? [d1, d2] : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean +>true : true >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -2976,7 +2976,7 @@ var x294: {n: Base[]; } = true ? { n: [d1, d2] } : { n: [d1, d2] }; >n : Base[] >Base : Base >true ? { n: [d1, d2] } : { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->true : boolean +>true : true >{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } >n : (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -2993,7 +2993,7 @@ var x295: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : n = >s : Base[] >Base : Base >true ? n => { var n: Base[]; return null; } : n => { var n: Base[]; return null; } : (n: Base[]) => any ->true : boolean +>true : true >n => { var n: Base[]; return null; } : (n: Base[]) => any >n : Base[] >n : Base[] @@ -3010,7 +3010,7 @@ var x296: Genric = true ? { func: n => { return [d1, d2]; } } : { func: n >Genric : Genric >Base : Base >true ? { func: n => { return [d1, d2]; } } : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->true : boolean +>true : true >{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } >func : (n: Base[]) => (Derived1 | Derived2)[] >n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] @@ -3030,7 +3030,7 @@ var x297: () => Base[] = true ? undefined : () => [d1, d2]; >x297 : () => Base[] >Base : Base >true ? undefined : () => [d1, d2] : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >() => [d1, d2] : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -3041,7 +3041,7 @@ var x298: () => Base[] = true ? undefined : function() { return [d1, d2] }; >x298 : () => Base[] >Base : Base >true ? undefined : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -3052,7 +3052,7 @@ var x299: () => Base[] = true ? undefined : function named() { return [d1, d2] } >x299 : () => Base[] >Base : Base >true ? undefined : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >named : () => (Derived1 | Derived2)[] @@ -3064,7 +3064,7 @@ var x300: { (): Base[]; } = true ? undefined : () => [d1, d2]; >x300 : () => Base[] >Base : Base >true ? undefined : () => [d1, d2] : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >() => [d1, d2] : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -3075,7 +3075,7 @@ var x301: { (): Base[]; } = true ? undefined : function() { return [d1, d2] }; >x301 : () => Base[] >Base : Base >true ? undefined : function() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -3086,7 +3086,7 @@ var x302: { (): Base[]; } = true ? undefined : function named() { return [d1, d2 >x302 : () => Base[] >Base : Base >true ? undefined : function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >named : () => (Derived1 | Derived2)[] @@ -3098,7 +3098,7 @@ var x303: Base[] = true ? undefined : [d1, d2]; >x303 : Base[] >Base : Base >true ? undefined : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -3109,7 +3109,7 @@ var x304: Array = true ? undefined : [d1, d2]; >Array : T[] >Base : Base >true ? undefined : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -3120,7 +3120,7 @@ var x305: { [n: number]: Base; } = true ? undefined : [d1, d2]; >n : number >Base : Base >true ? undefined : [d1, d2] : (Derived1 | Derived2)[] ->true : boolean +>true : true >undefined : undefined >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -3131,7 +3131,7 @@ var x306: {n: Base[]; } = true ? undefined : { n: [d1, d2] }; >n : Base[] >Base : Base >true ? undefined : { n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } ->true : boolean +>true : true >undefined : undefined >{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } >n : (Derived1 | Derived2)[] @@ -3144,7 +3144,7 @@ var x307: (s: Base[]) => any = true ? undefined : n => { var n: Base[]; return n >s : Base[] >Base : Base >true ? undefined : n => { var n: Base[]; return null; } : (n: Base[]) => any ->true : boolean +>true : true >undefined : undefined >n => { var n: Base[]; return null; } : (n: Base[]) => any >n : Base[] @@ -3157,7 +3157,7 @@ var x308: Genric = true ? undefined : { func: n => { return [d1, d2]; } }; >Genric : Genric >Base : Base >true ? undefined : { func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->true : boolean +>true : true >undefined : undefined >{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } >func : (n: Base[]) => (Derived1 | Derived2)[] @@ -3171,7 +3171,7 @@ var x309: () => Base[] = true ? () => [d1, d2] : undefined; >x309 : () => Base[] >Base : Base >true ? () => [d1, d2] : undefined : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >() => [d1, d2] : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -3182,7 +3182,7 @@ var x310: () => Base[] = true ? function() { return [d1, d2] } : undefined; >x310 : () => Base[] >Base : Base >true ? function() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -3193,7 +3193,7 @@ var x311: () => Base[] = true ? function named() { return [d1, d2] } : undefined >x311 : () => Base[] >Base : Base >true ? function named() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >named : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -3205,7 +3205,7 @@ var x312: { (): Base[]; } = true ? () => [d1, d2] : undefined; >x312 : () => Base[] >Base : Base >true ? () => [d1, d2] : undefined : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >() => [d1, d2] : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -3216,7 +3216,7 @@ var x313: { (): Base[]; } = true ? function() { return [d1, d2] } : undefined; >x313 : () => Base[] >Base : Base >true ? function() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >function() { return [d1, d2] } : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 @@ -3227,7 +3227,7 @@ var x314: { (): Base[]; } = true ? function named() { return [d1, d2] } : undefi >x314 : () => Base[] >Base : Base >true ? function named() { return [d1, d2] } : undefined : () => (Derived1 | Derived2)[] ->true : boolean +>true : true >function named() { return [d1, d2] } : () => (Derived1 | Derived2)[] >named : () => (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -3239,7 +3239,7 @@ var x315: Base[] = true ? [d1, d2] : undefined; >x315 : Base[] >Base : Base >true ? [d1, d2] : undefined : (Derived1 | Derived2)[] ->true : boolean +>true : true >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3250,7 +3250,7 @@ var x316: Array = true ? [d1, d2] : undefined; >Array : T[] >Base : Base >true ? [d1, d2] : undefined : (Derived1 | Derived2)[] ->true : boolean +>true : true >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3261,7 +3261,7 @@ var x317: { [n: number]: Base; } = true ? [d1, d2] : undefined; >n : number >Base : Base >true ? [d1, d2] : undefined : (Derived1 | Derived2)[] ->true : boolean +>true : true >[d1, d2] : (Derived1 | Derived2)[] >d1 : Derived1 >d2 : Derived2 @@ -3272,7 +3272,7 @@ var x318: {n: Base[]; } = true ? { n: [d1, d2] } : undefined; >n : Base[] >Base : Base >true ? { n: [d1, d2] } : undefined : { n: (Derived1 | Derived2)[]; } ->true : boolean +>true : true >{ n: [d1, d2] } : { n: (Derived1 | Derived2)[]; } >n : (Derived1 | Derived2)[] >[d1, d2] : (Derived1 | Derived2)[] @@ -3285,7 +3285,7 @@ var x319: (s: Base[]) => any = true ? n => { var n: Base[]; return null; } : und >s : Base[] >Base : Base >true ? n => { var n: Base[]; return null; } : undefined : (n: Base[]) => any ->true : boolean +>true : true >n => { var n: Base[]; return null; } : (n: Base[]) => any >n : Base[] >n : Base[] @@ -3298,7 +3298,7 @@ var x320: Genric = true ? { func: n => { return [d1, d2]; } } : undefined; >Genric : Genric >Base : Base >true ? { func: n => { return [d1, d2]; } } : undefined : { func: (n: Base[]) => (Derived1 | Derived2)[]; } ->true : boolean +>true : true >{ func: n => { return [d1, d2]; } } : { func: (n: Base[]) => (Derived1 | Derived2)[]; } >func : (n: Base[]) => (Derived1 | Derived2)[] >n => { return [d1, d2]; } : (n: Base[]) => (Derived1 | Derived2)[] diff --git a/tests/baselines/reference/generatorES6_2.types b/tests/baselines/reference/generatorES6_2.types index 9c9c8692757..61a2adbc697 100644 --- a/tests/baselines/reference/generatorES6_2.types +++ b/tests/baselines/reference/generatorES6_2.types @@ -3,10 +3,10 @@ class C { >C : C public * foo() { ->foo : () => IterableIterator +>foo : () => IterableIterator<1> yield 1 >yield 1 : any ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/generatorES6_3.types b/tests/baselines/reference/generatorES6_3.types index e87ad23ba77..9ecd01d6e23 100644 --- a/tests/baselines/reference/generatorES6_3.types +++ b/tests/baselines/reference/generatorES6_3.types @@ -1,9 +1,9 @@ === tests/cases/compiler/generatorES6_3.ts === var v = function*() { ->v : () => IterableIterator ->function*() { yield 0} : () => IterableIterator +>v : () => IterableIterator<0> +>function*() { yield 0} : () => IterableIterator<0> yield 0 >yield 0 : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/generatorES6_4.types b/tests/baselines/reference/generatorES6_4.types index 64b0924919b..786e7b64020 100644 --- a/tests/baselines/reference/generatorES6_4.types +++ b/tests/baselines/reference/generatorES6_4.types @@ -1,13 +1,13 @@ === tests/cases/compiler/generatorES6_4.ts === var v = { ->v : { foo(): IterableIterator; } ->{ *foo() { yield 0 }} : { foo(): IterableIterator; } +>v : { foo(): IterableIterator<0>; } +>{ *foo() { yield 0 }} : { foo(): IterableIterator<0>; } *foo() { ->foo : () => IterableIterator +>foo : () => IterableIterator<0> yield 0 >yield 0 : any ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/generatorES6_6.types b/tests/baselines/reference/generatorES6_6.types index 4e3de8cea1e..6f50181d0ef 100644 --- a/tests/baselines/reference/generatorES6_6.types +++ b/tests/baselines/reference/generatorES6_6.types @@ -10,6 +10,6 @@ class C { let a = yield 1; >a : any >yield 1 : any ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/generatorTypeCheck11.types b/tests/baselines/reference/generatorTypeCheck11.types index ce47d497851..7613cc189a9 100644 --- a/tests/baselines/reference/generatorTypeCheck11.types +++ b/tests/baselines/reference/generatorTypeCheck11.types @@ -4,5 +4,5 @@ function* g(): IterableIterator { >IterableIterator : IterableIterator return 0; ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/generatorTypeCheck12.types b/tests/baselines/reference/generatorTypeCheck12.types index 3dd3c20f18d..ef5b3564e18 100644 --- a/tests/baselines/reference/generatorTypeCheck12.types +++ b/tests/baselines/reference/generatorTypeCheck12.types @@ -4,5 +4,5 @@ function* g(): IterableIterator { >IterableIterator : IterableIterator return ""; ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/generatorTypeCheck13.types b/tests/baselines/reference/generatorTypeCheck13.types index d77b630ae72..8dfafd89884 100644 --- a/tests/baselines/reference/generatorTypeCheck13.types +++ b/tests/baselines/reference/generatorTypeCheck13.types @@ -5,8 +5,8 @@ function* g(): IterableIterator { yield 0; >yield 0 : any ->0 : number +>0 : 0 return ""; ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/generatorTypeCheck14.types b/tests/baselines/reference/generatorTypeCheck14.types index db1b5bde19a..48565fe2be0 100644 --- a/tests/baselines/reference/generatorTypeCheck14.types +++ b/tests/baselines/reference/generatorTypeCheck14.types @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck14.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> yield 0; >yield 0 : any ->0 : number +>0 : 0 return ""; ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/generatorTypeCheck15.types b/tests/baselines/reference/generatorTypeCheck15.types index 4437d78572d..eb14208009a 100644 --- a/tests/baselines/reference/generatorTypeCheck15.types +++ b/tests/baselines/reference/generatorTypeCheck15.types @@ -3,5 +3,5 @@ function* g() { >g : () => IterableIterator return ""; ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/generatorTypeCheck33.types b/tests/baselines/reference/generatorTypeCheck33.types index f3b8af225d1..707bf7beccd 100644 --- a/tests/baselines/reference/generatorTypeCheck33.types +++ b/tests/baselines/reference/generatorTypeCheck33.types @@ -1,16 +1,16 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck33.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> yield 0; >yield 0 : any ->0 : number +>0 : 0 function* g2() { ->g2 : () => IterableIterator +>g2 : () => IterableIterator<""> yield ""; >yield "" : any ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/generatorTypeCheck34.types b/tests/baselines/reference/generatorTypeCheck34.types index 35063e988eb..2ca11177218 100644 --- a/tests/baselines/reference/generatorTypeCheck34.types +++ b/tests/baselines/reference/generatorTypeCheck34.types @@ -1,15 +1,15 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck34.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> yield 0; >yield 0 : any ->0 : number +>0 : 0 function* g2() { >g2 : () => IterableIterator return ""; ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/generatorTypeCheck35.types b/tests/baselines/reference/generatorTypeCheck35.types index 0bfc22ab3f0..dcd5ab4be84 100644 --- a/tests/baselines/reference/generatorTypeCheck35.types +++ b/tests/baselines/reference/generatorTypeCheck35.types @@ -1,15 +1,15 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck35.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> yield 0; >yield 0 : any ->0 : number +>0 : 0 function g2() { >g2 : () => string return ""; ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/generatorTypeCheck36.types b/tests/baselines/reference/generatorTypeCheck36.types index 110a4d3e02e..318a46c25fb 100644 --- a/tests/baselines/reference/generatorTypeCheck36.types +++ b/tests/baselines/reference/generatorTypeCheck36.types @@ -5,5 +5,5 @@ function* g() { yield yield 0; >yield yield 0 : any >yield 0 : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/generatorTypeCheck37.types b/tests/baselines/reference/generatorTypeCheck37.types index e8611ec167a..aaa790c8094 100644 --- a/tests/baselines/reference/generatorTypeCheck37.types +++ b/tests/baselines/reference/generatorTypeCheck37.types @@ -5,5 +5,5 @@ function* g() { return yield yield 0; >yield yield 0 : any >yield 0 : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/generatorTypeCheck38.types b/tests/baselines/reference/generatorTypeCheck38.types index 08503e8640f..31fe452e656 100644 --- a/tests/baselines/reference/generatorTypeCheck38.types +++ b/tests/baselines/reference/generatorTypeCheck38.types @@ -3,11 +3,11 @@ var yield; >yield : any function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> yield 0; >yield 0 : any ->0 : number +>0 : 0 var v: typeof yield; >v : any diff --git a/tests/baselines/reference/generatorTypeCheck41.types b/tests/baselines/reference/generatorTypeCheck41.types index 0bed082dc43..1a9ea21f978 100644 --- a/tests/baselines/reference/generatorTypeCheck41.types +++ b/tests/baselines/reference/generatorTypeCheck41.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck41.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> let x = { >x : { [x: number]: number; } @@ -8,7 +8,7 @@ function* g() { [yield 0]: 0 >yield 0 : any ->0 : number ->0 : number +>0 : 0 +>0 : 0 } } diff --git a/tests/baselines/reference/generatorTypeCheck42.types b/tests/baselines/reference/generatorTypeCheck42.types index 7538b8f2499..79b2516051e 100644 --- a/tests/baselines/reference/generatorTypeCheck42.types +++ b/tests/baselines/reference/generatorTypeCheck42.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck42.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> let x = { >x : { [x: number]: () => void; } @@ -8,7 +8,7 @@ function* g() { [yield 0]() { >yield 0 : any ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/generatorTypeCheck43.types b/tests/baselines/reference/generatorTypeCheck43.types index a132dfcb015..754d3fee814 100644 --- a/tests/baselines/reference/generatorTypeCheck43.types +++ b/tests/baselines/reference/generatorTypeCheck43.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck43.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> let x = { >x : { [x: number]: () => IterableIterator; } @@ -8,7 +8,7 @@ function* g() { *[yield 0]() { >yield 0 : any ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/generatorTypeCheck44.types b/tests/baselines/reference/generatorTypeCheck44.types index 5c432e41cbe..e06b8961ca0 100644 --- a/tests/baselines/reference/generatorTypeCheck44.types +++ b/tests/baselines/reference/generatorTypeCheck44.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck44.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> let x = { >x : { [x: number]: number; } @@ -8,10 +8,10 @@ function* g() { get [yield 0]() { >yield 0 : any ->0 : number +>0 : 0 return 0; ->0 : number +>0 : 0 } } } diff --git a/tests/baselines/reference/generatorTypeCheck45.types b/tests/baselines/reference/generatorTypeCheck45.types index 7ea442420d6..96895acde0f 100644 --- a/tests/baselines/reference/generatorTypeCheck45.types +++ b/tests/baselines/reference/generatorTypeCheck45.types @@ -19,7 +19,7 @@ declare function foo(x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) foo("", function* () { yield x => x.length }, p => undefined); // T is fixed, should be string >foo("", function* () { yield x => x.length }, p => undefined) : string >foo : (x: T, fun: () => Iterator<(x: T) => U>, fun2: (y: U) => T) => T ->"" : string +>"" : "" >function* () { yield x => x.length } : () => IterableIterator<(x: string) => number> >yield x => x.length : any >x => x.length : (x: string) => number diff --git a/tests/baselines/reference/generatorTypeCheck46.types b/tests/baselines/reference/generatorTypeCheck46.types index daf0d67b6ec..c69ae0881da 100644 --- a/tests/baselines/reference/generatorTypeCheck46.types +++ b/tests/baselines/reference/generatorTypeCheck46.types @@ -19,7 +19,7 @@ declare function foo(x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) foo("", function* () { >foo("", function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }}, p => undefined) : string >foo : (x: T, fun: () => Iterable<(x: T) => U>, fun2: (y: U) => T) => T ->"" : string +>"" : "" >function* () { yield* { *[Symbol.iterator]() { yield x => x.length } }} : () => IterableIterator<(x: string) => number> yield* { diff --git a/tests/baselines/reference/generatorTypeCheck49.types b/tests/baselines/reference/generatorTypeCheck49.types index f56cca33438..cd9f3e82d09 100644 --- a/tests/baselines/reference/generatorTypeCheck49.types +++ b/tests/baselines/reference/generatorTypeCheck49.types @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/yieldExpressions/generatorTypeCheck49.ts === function* g() { ->g : () => IterableIterator +>g : () => IterableIterator<0> yield 0; >yield 0 : any ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/genericAndNonGenericOverload1.types b/tests/baselines/reference/genericAndNonGenericOverload1.types index 28eeb2d4da0..f7d0d4b35f8 100644 --- a/tests/baselines/reference/genericAndNonGenericOverload1.types +++ b/tests/baselines/reference/genericAndNonGenericOverload1.types @@ -21,5 +21,5 @@ var c2: callable2; c2(1); >c2(1) : string >c2 : callable2 ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types index f7dd10b11dd..086c6e23a8e 100644 --- a/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types +++ b/tests/baselines/reference/genericArgumentCallSigAssignmentCompat.types @@ -49,11 +49,11 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => boolean ->[true, 1, null, 'yes'] : (string | number | true)[] +>[true, 1, null, 'yes'] : (true | 1 | "yes")[] >true : true ->1 : number +>1 : 1 >null : null ->'yes' : string +>'yes' : "yes" >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericArray1.types b/tests/baselines/reference/genericArray1.types index bf44c88f518..baa2ec8a9cf 100644 --- a/tests/baselines/reference/genericArray1.types +++ b/tests/baselines/reference/genericArray1.types @@ -16,9 +16,9 @@ var lengths = ["a", "b", "c"].map(x => x.length); >["a", "b", "c"].map(x => x.length) : number[] >["a", "b", "c"].map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] >["a", "b", "c"] : string[] ->"a" : string ->"b" : string ->"c" : string +>"a" : "a" +>"b" : "b" +>"c" : "c" >map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] >x => x.length : (x: string) => number >x : string diff --git a/tests/baselines/reference/genericBaseClassLiteralProperty2.types b/tests/baselines/reference/genericBaseClassLiteralProperty2.types index 3e320824925..01740426935 100644 --- a/tests/baselines/reference/genericBaseClassLiteralProperty2.types +++ b/tests/baselines/reference/genericBaseClassLiteralProperty2.types @@ -38,7 +38,7 @@ class DataView2 extends BaseCollection2 { >this._itemsByKey : { [key: string]: CollectionItem2; } >this : this >_itemsByKey : { [key: string]: CollectionItem2; } ->'dummy' : string +>'dummy' : "dummy" >item : CollectionItem2 } } diff --git a/tests/baselines/reference/genericCallTypeArgumentInference.types b/tests/baselines/reference/genericCallTypeArgumentInference.types index 09cd907a5a9..f9b01f1be86 100644 --- a/tests/baselines/reference/genericCallTypeArgumentInference.types +++ b/tests/baselines/reference/genericCallTypeArgumentInference.types @@ -15,7 +15,7 @@ var r = foo(''); // string >r : string >foo('') : string >foo : (t: T) => T ->'' : string +>'' : "" function foo2(t: T, u: U) { >foo2 : (t: T, u: U) => U @@ -49,14 +49,14 @@ var r2 = foo2('', 1); // number >r2 : number >foo2('', 1) : number >foo2 : (t: T, u: U) => U ->'' : string ->1 : number +>'' : "" +>1 : 1 var r3 = foo2b(1); // {} >r3 : {} >foo2b(1) : {} >foo2b : (u: U) => T ->1 : number +>1 : 1 class C { >C : C @@ -175,8 +175,8 @@ var c = new C('', 1); >c : C >new C('', 1) : C >C : typeof C ->'' : string ->1 : number +>'' : "" +>1 : 1 var r4 = c.foo('', 1); // string >r4 : string @@ -184,8 +184,8 @@ var r4 = c.foo('', 1); // string >c.foo : (t: string, u: number) => string >c : C >foo : (t: string, u: number) => string ->'' : string ->1 : number +>'' : "" +>1 : 1 var r5 = c.foo2('', 1); // number >r5 : number @@ -193,8 +193,8 @@ var r5 = c.foo2('', 1); // number >c.foo2 : (t: string, u: number) => number >c : C >foo2 : (t: string, u: number) => number ->'' : string ->1 : number +>'' : "" +>1 : 1 var r6 = c.foo3(true, 1); // boolean >r6 : boolean @@ -203,7 +203,7 @@ var r6 = c.foo3(true, 1); // boolean >c : C >foo3 : (t: T, u: number) => T >true : true ->1 : number +>1 : 1 var r7 = c.foo4('', true); // string >r7 : string @@ -211,7 +211,7 @@ var r7 = c.foo4('', true); // string >c.foo4 : (t: string, u: U) => string >c : C >foo4 : (t: string, u: U) => string ->'' : string +>'' : "" >true : true var r8 = c.foo5(true, 1); // boolean @@ -221,7 +221,7 @@ var r8 = c.foo5(true, 1); // boolean >c : C >foo5 : (t: T, u: U) => T >true : true ->1 : number +>1 : 1 var r9 = c.foo6(); // {} >r9 : {} @@ -236,7 +236,7 @@ var r10 = c.foo7(''); // {} >c.foo7 : (u: U) => T >c : C >foo7 : (u: U) => T ->'' : string +>'' : "" var r11 = c.foo8(); // {} >r11 : {} @@ -331,8 +331,8 @@ var r4 = i.foo('', 1); // string >i.foo : (t: string, u: number) => string >i : I >foo : (t: string, u: number) => string ->'' : string ->1 : number +>'' : "" +>1 : 1 var r5 = i.foo2('', 1); // number >r5 : number @@ -340,8 +340,8 @@ var r5 = i.foo2('', 1); // number >i.foo2 : (t: string, u: number) => number >i : I >foo2 : (t: string, u: number) => number ->'' : string ->1 : number +>'' : "" +>1 : 1 var r6 = i.foo3(true, 1); // boolean >r6 : boolean @@ -350,7 +350,7 @@ var r6 = i.foo3(true, 1); // boolean >i : I >foo3 : (t: T, u: number) => T >true : true ->1 : number +>1 : 1 var r7 = i.foo4('', true); // string >r7 : string @@ -358,7 +358,7 @@ var r7 = i.foo4('', true); // string >i.foo4 : (t: string, u: U) => string >i : I >foo4 : (t: string, u: U) => string ->'' : string +>'' : "" >true : true var r8 = i.foo5(true, 1); // boolean @@ -368,7 +368,7 @@ var r8 = i.foo5(true, 1); // boolean >i : I >foo5 : (t: T, u: U) => T >true : true ->1 : number +>1 : 1 var r9 = i.foo6(); // {} >r9 : {} @@ -383,7 +383,7 @@ var r10 = i.foo7(''); // {} >i.foo7 : (u: U) => T >i : I >foo7 : (u: U) => T ->'' : string +>'' : "" var r11 = i.foo8(); // {} >r11 : {} diff --git a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types index 48a7150ef44..2727f0c1ece 100644 --- a/tests/baselines/reference/genericCallWithArrayLiteralArgs.types +++ b/tests/baselines/reference/genericCallWithArrayLiteralArgs.types @@ -14,24 +14,24 @@ var r = foo([1, 2]); // number[] >foo([1, 2]) : number[] >foo : (t: T) => T >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var r = foo([1, 2]); // number[] >r : number[] >foo([1, 2]) : number[] >foo : (t: T) => T >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var ra = foo([1, 2]); // any[] >ra : any[] >foo([1, 2]) : any[] >foo : (t: T) => T >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var r2 = foo([]); // any[] >r2 : any[] @@ -50,16 +50,16 @@ var r4 = foo([1, '']); // {}[] >foo([1, '']) : (string | number)[] >foo : (t: T) => T >[1, ''] : (string | number)[] ->1 : number ->'' : string +>1 : 1 +>'' : "" var r5 = foo([1, '']); // any[] >r5 : any[] >foo([1, '']) : any[] >foo : (t: T) => T >[1, ''] : (string | number)[] ->1 : number ->'' : string +>1 : 1 +>'' : "" var r6 = foo([1, '']); // Object[] >r6 : Object[] @@ -67,6 +67,6 @@ var r6 = foo([1, '']); // Object[] >foo : (t: T) => T >Object : Object >[1, ''] : (string | number)[] ->1 : number ->'' : string +>1 : 1 +>'' : "" diff --git a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt index 805bde82b64..6982031c9ba 100644 --- a/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt +++ b/tests/baselines/reference/genericCallWithConstraintsTypeArgumentInference2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts(11,26): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Date'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts(11,26): error TS2345: Argument of type '1' is not assignable to parameter of type 'Date'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithConstraintsTypeArgumentInference2.ts (1 errors) ==== @@ -14,5 +14,5 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithCon var r3 = foo(new Object()); // {} var r4 = foo(1); // error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Date'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'Date'. var r5 = foo(new Date()); // no error \ No newline at end of file diff --git a/tests/baselines/reference/genericCallWithFixedArguments.types b/tests/baselines/reference/genericCallWithFixedArguments.types index f22dbc01252..e10bbb9dd35 100644 --- a/tests/baselines/reference/genericCallWithFixedArguments.types +++ b/tests/baselines/reference/genericCallWithFixedArguments.types @@ -18,6 +18,6 @@ g(7) // the parameter list is fixed, so this should not error >g : (x: any) => void >A : A >B : B ->7 : number +>7 : 7 diff --git a/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt b/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt index 75ae76b1dbc..fb7062dbcea 100644 --- a/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt +++ b/tests/baselines/reference/genericCallWithFunctionTypedArguments5.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,14): error TS2345: Argument of type '{ cb: (x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(10,14): error TS2345: Argument of type '{ cb: (x: T, y: T) => ""; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'. Types of property 'cb' are incompatible. - Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,14): error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'. + Type '(x: T, y: T) => ""' is not assignable to type '(t: {}) => string'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts(11,14): error TS2345: Argument of type '{ cb: (x: string, y: number) => ""; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'. Types of property 'cb' are incompatible. - Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. + Type '(x: string, y: number) => ""' is not assignable to type '(t: string) => string'. ==== tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFunctionTypedArguments5.ts (2 errors) ==== @@ -18,14 +18,14 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithFun // more args not allowed var r2 = foo({ cb: (x: T, y: T) => '' }); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ cb: (x: T, y: T) => string; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'. +!!! error TS2345: Argument of type '{ cb: (x: T, y: T) => ""; }' is not assignable to parameter of type '{ cb: (t: {}) => string; }'. !!! error TS2345: Types of property 'cb' are incompatible. -!!! error TS2345: Type '(x: T, y: T) => string' is not assignable to type '(t: {}) => string'. +!!! error TS2345: Type '(x: T, y: T) => ""' is not assignable to type '(t: {}) => string'. var r3 = foo({ cb: (x: string, y: number) => '' }); // error ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ cb: (x: string, y: number) => string; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'. +!!! error TS2345: Argument of type '{ cb: (x: string, y: number) => ""; }' is not assignable to parameter of type '{ cb: (t: string) => string; }'. !!! error TS2345: Types of property 'cb' are incompatible. -!!! error TS2345: Type '(x: string, y: number) => string' is not assignable to type '(t: string) => string'. +!!! error TS2345: Type '(x: string, y: number) => ""' is not assignable to type '(t: string) => string'. function foo2(arg: { cb: (t: T, t2: T) => U }) { return arg.cb(null, null); diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt index e3da7eaeaec..714fe32d31a 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt @@ -1,14 +1,14 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(10,29): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(15,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(16,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(25,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. Types of parameters 'a' and 'x' are incompatible. Type 'Date' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(37,36): error TS2345: Argument of type '(x: E) => F' is not assignable to parameter of type '(x: E) => E'. Type 'F' is not assignable to type 'E'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(50,21): error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. -tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(51,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(51,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGenericSignatureArguments2.ts(60,23): error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. Types of parameters 'a' and 'x' are incompatible. Type 'Date' is not assignable to type 'T'. @@ -39,7 +39,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen !!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. var r10 = r7(1); // error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. } function foo2(a: (x: T) => T, b: (x: T) => T) { @@ -85,7 +85,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen !!! error TS2345: Argument of type 'Date' is not assignable to parameter of type 'T'. var r10 = r7(1); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. } function foo2(a: (x: T) => T, b: (x: U) => U) { diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexers.types b/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexers.types index e1659323033..26e19e68577 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexers.types +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexers.types @@ -58,11 +58,11 @@ function other(arg: T) { >d : T >r2[1] : T >r2 : { [x: string]: Object; [x: number]: T; } ->1 : number +>1 : 1 var e = r2['1']; >e : Object >r2['1'] : Object >r2 : { [x: string]: Object; [x: number]: T; } ->'1' : string +>'1' : "1" } diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.types b/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.types index bde72409edc..4141caac617 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.types +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndIndexersErrors.types @@ -67,18 +67,18 @@ function other3(arg: T) { >d : T >r2[1] : T >r2 : { [x: string]: Object; [x: number]: T; } ->1 : number +>1 : 1 var e = r2['1']; >e : Object >r2['1'] : Object >r2 : { [x: string]: Object; [x: number]: T; } ->'1' : string +>'1' : "1" var u: U = r2[1]; // ok >u : U >U : U >r2[1] : T >r2 : { [x: string]: Object; [x: number]: T; } ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt index 9795248e2f7..b65b21e127b 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndInitializers.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(5,33): error TS2322: Type 'number' is not assignable to type 'T'. +tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(5,33): error TS2322: Type '1' is not assignable to type 'T'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(6,37): error TS2322: Type 'T' is not assignable to type 'U'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericCallWithObjectTypeArgsAndInitializers.ts(8,56): error TS2322: Type 'U' is not assignable to type 'V'. Type 'T' is not assignable to type 'V'. @@ -11,7 +11,7 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/genericC function foo2(x: T = undefined) { return x; } // ok function foo3(x: T = 1) { } // error ~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'T'. +!!! error TS2322: Type '1' is not assignable to type 'T'. function foo4(x: T, y: U = x) { } // error ~~~~~~~~ !!! error TS2322: Type 'T' is not assignable to type 'U'. diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.types b/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.types index 71e943c1ad3..e7676596c07 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.types +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndNumericIndexer.types @@ -62,7 +62,7 @@ function other2(arg: T) { >d : T >r2[1] : T >r2 : { [x: number]: T; } ->1 : number +>1 : 1 } function other3(arg: T) { @@ -89,7 +89,7 @@ function other3(arg: T) { >d : T >r2[1] : T >r2 : { [x: number]: T; } ->1 : number +>1 : 1 // BUG 821629 //var u: U = r2[1]; // ok diff --git a/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.types b/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.types index 196103f422b..a0b6e89c70a 100644 --- a/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.types +++ b/tests/baselines/reference/genericCallWithObjectTypeArgsAndStringIndexer.types @@ -63,7 +63,7 @@ function other2(arg: T) { >Date : Date >r2['hm'] : T >r2 : { [x: string]: T; } ->'hm' : string +>'hm' : "hm" } function other3(arg: T) { @@ -91,7 +91,7 @@ function other3(arg: T) { >Date : Date >r2['hm'] : T >r2 : { [x: string]: T; } ->'hm' : string +>'hm' : "hm" // BUG 821629 //var u: U = r2['hm']; // ok diff --git a/tests/baselines/reference/genericCallWithOverloadedFunctionTypedArguments.types b/tests/baselines/reference/genericCallWithOverloadedFunctionTypedArguments.types index dbdecbec3e4..ab07e9c880a 100644 --- a/tests/baselines/reference/genericCallWithOverloadedFunctionTypedArguments.types +++ b/tests/baselines/reference/genericCallWithOverloadedFunctionTypedArguments.types @@ -119,7 +119,7 @@ module GenericParameter { >T : T >x : T >T : T ->'' : string +>'' : "" var r11 = foo6((x: T, y?: T) => ''); // any => string (+1 overload) >r11 : { (x: any): string; (x: any, y?: any): string; } @@ -131,7 +131,7 @@ module GenericParameter { >T : T >y : T >T : T ->'' : string +>'' : "" function foo7(x:T, cb: { (x: T): string; (x: T, y?: T): string }) { >foo7 : (x: T, cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; } @@ -154,7 +154,7 @@ module GenericParameter { >r12 : { (x: any): string; (x: any, y?: any): string; } >foo7(1, (x) => x) : { (x: any): string; (x: any, y?: any): string; } >foo7 : (x: T, cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; } ->1 : number +>1 : 1 >(x) => x : (x: any) => any >x : any >x : any @@ -163,12 +163,12 @@ module GenericParameter { >r13 : { (x: any): string; (x: any, y?: any): string; } >foo7(1, (x: T) => '') : { (x: any): string; (x: any, y?: any): string; } >foo7 : (x: T, cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; } ->1 : number +>1 : 1 >(x: T) => '' : (x: T) => string >T : T >x : T >T : T ->'' : string +>'' : "" var a: { (x: T): string; (x: number): T; } >a : { (x: T): string; (x: number): T; } @@ -183,6 +183,6 @@ module GenericParameter { >r14 : { (x: any): string; (x: any, y?: any): string; } >foo7(1, a) : { (x: any): string; (x: any, y?: any): string; } >foo7 : (x: T, cb: { (x: T): string; (x: T, y?: T): string; }) => { (x: T): string; (x: T, y?: T): string; } ->1 : number +>1 : 1 >a : { (x: T): string; (x: number): T; } } diff --git a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt index af5d92f4e3c..aec6b9c34b7 100644 --- a/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt +++ b/tests/baselines/reference/genericCallbackInvokedInsideItsContainingFunction1.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(2,14): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(3,16): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(3,16): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(4,14): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(8,15): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(9,15): error TS2346: Supplied parameters do not match any signature of call target. @@ -15,7 +15,7 @@ tests/cases/compiler/genericCallbackInvokedInsideItsContainingFunction1.ts(14,15 !!! error TS2346: Supplied parameters do not match any signature of call target. var r2 = f(1); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. var r3 = f(null); ~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/genericClassExpressionInFunction.types b/tests/baselines/reference/genericClassExpressionInFunction.types index 943391fdd59..e5e85fb8bf0 100644 --- a/tests/baselines/reference/genericClassExpressionInFunction.types +++ b/tests/baselines/reference/genericClassExpressionInFunction.types @@ -86,23 +86,23 @@ var s = new S(); >S : typeof S c.genericVar = 12; ->c.genericVar = 12 : number +>c.genericVar = 12 : 12 >c.genericVar : number >c : C >genericVar : number ->12 : number +>12 : 12 k.genericVar = 12; ->k.genericVar = 12 : number +>k.genericVar = 12 : 12 >k.genericVar : number >k : K >genericVar : number ->12 : number +>12 : 12 s.genericVar = 12; ->s.genericVar = 12 : number +>s.genericVar = 12 : 12 >s.genericVar : number >s : S >genericVar : number ->12 : number +>12 : 12 diff --git a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types index 88ef74283ae..3db47b0e479 100644 --- a/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types +++ b/tests/baselines/reference/genericClassPropertyInheritanceSpecialization.types @@ -179,7 +179,7 @@ module Portal.Controls.Validators { >_validate : (value: TValue) => number >value : TValue >TValue : TValue ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/genericClassWithStaticFactory.types b/tests/baselines/reference/genericClassWithStaticFactory.types index c1af646e7fb..1c09fcd493e 100644 --- a/tests/baselines/reference/genericClassWithStaticFactory.types +++ b/tests/baselines/reference/genericClassWithStaticFactory.types @@ -109,9 +109,9 @@ module Editor { >next : List for (i = 0; !(entry.isHead); i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >!(entry.isHead) : boolean >(entry.isHead) : boolean >entry.isHead : boolean diff --git a/tests/baselines/reference/genericCloduleInModule.types b/tests/baselines/reference/genericCloduleInModule.types index 3ae3a8cf06d..97ef24ff49b 100644 --- a/tests/baselines/reference/genericCloduleInModule.types +++ b/tests/baselines/reference/genericCloduleInModule.types @@ -17,7 +17,7 @@ module A { export var x = 1; >x : number ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/genericConstructSignatureInInterface.types b/tests/baselines/reference/genericConstructSignatureInInterface.types index c6653a0d90d..d1d7646e945 100644 --- a/tests/baselines/reference/genericConstructSignatureInInterface.types +++ b/tests/baselines/reference/genericConstructSignatureInInterface.types @@ -16,5 +16,5 @@ var r = new v(1); >r : any >new v(1) : any >v : C ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/genericContextualTypingSpecialization.types b/tests/baselines/reference/genericContextualTypingSpecialization.types index 561370a6a32..82255020347 100644 --- a/tests/baselines/reference/genericContextualTypingSpecialization.types +++ b/tests/baselines/reference/genericContextualTypingSpecialization.types @@ -13,5 +13,5 @@ b.reduce((c, d) => c + d, 0); // should not error on '+' >c + d : number >c : number >d : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/genericFunctions0.types b/tests/baselines/reference/genericFunctions0.types index aac759af092..58256739dd4 100644 --- a/tests/baselines/reference/genericFunctions0.types +++ b/tests/baselines/reference/genericFunctions0.types @@ -10,5 +10,5 @@ var x = foo(5); // 'x' should be number >x : number >foo(5) : number >foo : (x: T) => T ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/genericFunctions1.types b/tests/baselines/reference/genericFunctions1.types index 602ee6b81a4..d055fa3e13e 100644 --- a/tests/baselines/reference/genericFunctions1.types +++ b/tests/baselines/reference/genericFunctions1.types @@ -10,5 +10,5 @@ var x = foo(5); // 'x' should be number >x : number >foo(5) : number >foo : (x: T) => T ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/genericFunctionsWithOptionalParameters3.types b/tests/baselines/reference/genericFunctionsWithOptionalParameters3.types index 627181e5d05..cba9effcdaa 100644 --- a/tests/baselines/reference/genericFunctionsWithOptionalParameters3.types +++ b/tests/baselines/reference/genericFunctionsWithOptionalParameters3.types @@ -63,9 +63,9 @@ var r3 = utils.mapReduce(c, (x) => { return 1 }, (y) => { return new Date() }); >utils : Utils >mapReduce : (c: Collection, mapper: (x: T) => U, reducer: (y: U) => V) => Collection >c : Collection ->(x) => { return 1 } : (x: string) => number +>(x) => { return 1 } : (x: string) => 1 >x : string ->1 : number +>1 : 1 >(y) => { return new Date() } : (y: number) => Date >y : number >new Date() : Date @@ -78,9 +78,9 @@ var r4 = utils.mapReduce(c, (x: string) => { return 1 }, (y: number) => { return >utils : Utils >mapReduce : (c: Collection, mapper: (x: T) => U, reducer: (y: U) => V) => Collection >c : Collection ->(x: string) => { return 1 } : (x: string) => number +>(x: string) => { return 1 } : (x: string) => 1 >x : string ->1 : number +>1 : 1 >(y: number) => { return new Date() } : (y: number) => Date >y : number >new Date() : Date @@ -90,7 +90,7 @@ var f1 = (x: string) => { return 1 }; >f1 : (x: string) => number >(x: string) => { return 1 } : (x: string) => number >x : string ->1 : number +>1 : 1 var f2 = (y: number) => { return new Date() }; >f2 : (y: number) => Date diff --git a/tests/baselines/reference/genericInference1.types b/tests/baselines/reference/genericInference1.types index eeed8aa9f3e..30b7279ebc0 100644 --- a/tests/baselines/reference/genericInference1.types +++ b/tests/baselines/reference/genericInference1.types @@ -3,9 +3,9 @@ >['a', 'b', 'c'].map(x => x.length) : number[] >['a', 'b', 'c'].map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] >['a', 'b', 'c'] : string[] ->'a' : string ->'b' : string ->'c' : string +>'a' : "a" +>'b' : "b" +>'c' : "c" >map : (callbackfn: (value: string, index: number, array: string[]) => U, thisArg?: any) => U[] >x => x.length : (x: string) => number >x : string diff --git a/tests/baselines/reference/genericInference2.types b/tests/baselines/reference/genericInference2.types index e5c7052b0db..54006dba419 100644 --- a/tests/baselines/reference/genericInference2.types +++ b/tests/baselines/reference/genericInference2.types @@ -41,7 +41,7 @@ >ko.observable : (value: T) => ko.Observable >ko : typeof ko >observable : (value: T) => ko.Observable ->"Bob" : string +>"Bob" : "Bob" age: ko.observable(37) >age : ko.Observable @@ -49,7 +49,7 @@ >ko.observable : (value: T) => ko.Observable >ko : typeof ko >observable : (value: T) => ko.Observable ->37 : number +>37 : 37 }; var x_v = o.name().length; // should be 'number' @@ -74,7 +74,7 @@ >o.name : ko.Observable >o : { name: ko.Observable; age: ko.Observable; } >name : ko.Observable ->"Robert" : string +>"Robert" : "Robert" var zz_v = o.name.N; // should be 'number' >zz_v : number diff --git a/tests/baselines/reference/genericMethodOverspecialization.types b/tests/baselines/reference/genericMethodOverspecialization.types index 375eefaa86c..268943a9723 100644 --- a/tests/baselines/reference/genericMethodOverspecialization.types +++ b/tests/baselines/reference/genericMethodOverspecialization.types @@ -2,11 +2,11 @@ var names = ["list", "table1", "table2", "table3", "summary"]; >names : string[] >["list", "table1", "table2", "table3", "summary"] : string[] ->"list" : string ->"table1" : string ->"table2" : string ->"table3" : string ->"summary" : string +>"list" : "list" +>"table1" : "table1" +>"table2" : "table2" +>"table3" : "table3" +>"summary" : "summary" interface HTMLElement { >HTMLElement : HTMLElement diff --git a/tests/baselines/reference/genericNewInterface.errors.txt b/tests/baselines/reference/genericNewInterface.errors.txt index f489b72c1b6..7754d5749fd 100644 --- a/tests/baselines/reference/genericNewInterface.errors.txt +++ b/tests/baselines/reference/genericNewInterface.errors.txt @@ -1,12 +1,12 @@ -tests/cases/compiler/genericNewInterface.ts(2,21): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/compiler/genericNewInterface.ts(10,21): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/genericNewInterface.ts(2,21): error TS2345: Argument of type '42' is not assignable to parameter of type 'string'. +tests/cases/compiler/genericNewInterface.ts(10,21): error TS2345: Argument of type '1024' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/genericNewInterface.ts (2 errors) ==== function createInstance(ctor: new (s: string) => T): T { return new ctor(42); //should be an error ~~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '42' is not assignable to parameter of type 'string'. } interface INewable { @@ -16,5 +16,5 @@ tests/cases/compiler/genericNewInterface.ts(10,21): error TS2345: Argument of ty function createInstance2(ctor: INewable): T { return new ctor(1024); //should be an error ~~~~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1024' is not assignable to parameter of type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/genericObjectLitReturnType.types b/tests/baselines/reference/genericObjectLitReturnType.types index 6bdc352cbc7..0b54e9f8e35 100644 --- a/tests/baselines/reference/genericObjectLitReturnType.types +++ b/tests/baselines/reference/genericObjectLitReturnType.types @@ -23,13 +23,13 @@ var t1 = x.f(5); >x.f : (t: number) => { a: number; } >x : X >f : (t: number) => { a: number; } ->5 : number +>5 : 5 t1.a = 5; // Should not error: t1 should have type {a: number}, instead has type {a: T} ->t1.a = 5 : number +>t1.a = 5 : 5 >t1.a : number >t1 : { a: number; } >a : number ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.types b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.types index 2f62a20c415..834f071659e 100644 --- a/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.types +++ b/tests/baselines/reference/genericRecursiveImplicitConstructorErrors2.types @@ -15,10 +15,10 @@ module TypeScript2 { >PullSymbolVisibility : PullSymbolVisibility Private, ->Private : PullSymbolVisibility +>Private : PullSymbolVisibility.Private Public ->Public : PullSymbolVisibility +>Public : PullSymbolVisibility.Public }   export class PullSymbol { diff --git a/tests/baselines/reference/genericRestArgs.errors.txt b/tests/baselines/reference/genericRestArgs.errors.txt index 8a977452958..1dc8bd6f977 100644 --- a/tests/baselines/reference/genericRestArgs.errors.txt +++ b/tests/baselines/reference/genericRestArgs.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/genericRestArgs.ts(2,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. -tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/compiler/genericRestArgs.ts(5,34): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/compiler/genericRestArgs.ts(10,12): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'number' is not a valid type argument because it is not a supertype of candidate 'string'. -tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'. +tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type '1' is not assignable to parameter of type 'any[]'. ==== tests/cases/compiler/genericRestArgs.ts (4 errors) ==== @@ -16,7 +16,7 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type ' var a1Gc = makeArrayG(1, ""); var a1Gd = makeArrayG(1, ""); // error ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. function makeArrayGOpt(item1?: T, item2?: T, item3?: T) { return [item1, item2, item3]; @@ -28,4 +28,4 @@ tests/cases/compiler/genericRestArgs.ts(12,30): error TS2345: Argument of type ' var a2Gb = makeArrayG(1, ""); var a2Gc = makeArrayG(1, ""); // error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'any[]'. \ No newline at end of file +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'any[]'. \ No newline at end of file diff --git a/tests/baselines/reference/genericReversingTypeParameters.types b/tests/baselines/reference/genericReversingTypeParameters.types index 524a2ebba03..daab3c0248f 100644 --- a/tests/baselines/reference/genericReversingTypeParameters.types +++ b/tests/baselines/reference/genericReversingTypeParameters.types @@ -36,7 +36,7 @@ var r1 = b.get(''); >b.get : (key: string) => number >b : BiMap >get : (key: string) => number ->'' : string +>'' : "" var i = b.inverse(); // used to get the type wrong here. >i : BiMap @@ -51,5 +51,5 @@ var r2b = i.get(1); >i.get : (key: number) => string >i : BiMap >get : (key: number) => string ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/genericReversingTypeParameters2.types b/tests/baselines/reference/genericReversingTypeParameters2.types index 28c1f40ce9f..d64c135cf20 100644 --- a/tests/baselines/reference/genericReversingTypeParameters2.types +++ b/tests/baselines/reference/genericReversingTypeParameters2.types @@ -43,5 +43,5 @@ var r2b = i.get(1); >i.get : (key: number) => string >i : BiMap >get : (key: number) => string ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/genericStaticAnyTypeFunction.types b/tests/baselines/reference/genericStaticAnyTypeFunction.types index 38b3c3708e7..3a6a182b08a 100644 --- a/tests/baselines/reference/genericStaticAnyTypeFunction.types +++ b/tests/baselines/reference/genericStaticAnyTypeFunction.types @@ -16,7 +16,7 @@ class A { } static goo() { return 0; } >goo : () => number ->0 : number +>0 : 0 static two(source: T): T { >two : (source: T) => T @@ -32,7 +32,7 @@ class A { >one : (source: T, value: number) => T >T : T >source : T ->42 : number +>42 : 42 } diff --git a/tests/baselines/reference/genericTypeAliases.types b/tests/baselines/reference/genericTypeAliases.types index 929ecf7d7e1..3f5f0d71f2b 100644 --- a/tests/baselines/reference/genericTypeAliases.types +++ b/tests/baselines/reference/genericTypeAliases.types @@ -21,7 +21,7 @@ var tree: Tree = { left: 0, >left : number ->0 : number +>0 : 0 right: { >right : { left: number; right: number; } @@ -29,17 +29,17 @@ var tree: Tree = { left: 1, >left : number ->1 : number +>1 : 1 right: 2 >right : number ->2 : number +>2 : 2 }, }, right: 3 >right : number ->3 : number +>3 : 3 }; @@ -54,15 +54,15 @@ var ls: Lazy; >Lazy : Lazy ls = "eager"; ->ls = "eager" : string +>ls = "eager" : "eager" >ls : Lazy ->"eager" : string +>"eager" : "eager" ls = () => "lazy"; ->ls = () => "lazy" : () => string +>ls = () => "lazy" : () => "lazy" >ls : Lazy ->() => "lazy" : () => string ->"lazy" : string +>() => "lazy" : () => "lazy" +>"lazy" : "lazy" type Foo = T | { x: Foo }; >Foo : Foo @@ -100,16 +100,16 @@ y = x; >x : Foo x = "string"; ->x = "string" : string +>x = "string" : "string" >x : Foo ->"string" : string +>"string" : "string" x = { x: "hello" }; >x = { x: "hello" } : { x: string; } >x : Foo >{ x: "hello" } : { x: string; } >x : string ->"hello" : string +>"hello" : "hello" x = { x: { x: "world" } }; >x = { x: { x: "world" } } : { x: { x: string; }; } @@ -118,23 +118,23 @@ x = { x: { x: "world" } }; >x : { x: string; } >{ x: "world" } : { x: string; } >x : string ->"world" : string +>"world" : "world" var z: Foo; >z : Foo >Foo : Foo z = 42; ->z = 42 : number +>z = 42 : 42 >z : Foo ->42 : number +>42 : 42 z = { x: 42 }; >z = { x: 42 } : { x: number; } >z : Foo >{ x: 42 } : { x: number; } >x : number ->42 : number +>42 : 42 z = { x: { x: 42 } }; >z = { x: { x: 42 } } : { x: { x: number; }; } @@ -143,7 +143,7 @@ z = { x: { x: 42 } }; >x : { x: number; } >{ x: 42 } : { x: number; } >x : number ->42 : number +>42 : 42 type Strange = string; // Type parameter not used >Strange : string @@ -154,9 +154,9 @@ var s: Strange; >Strange : string s = "hello"; ->s = "hello" : string +>s = "hello" : "hello" >s : string ->"hello" : string +>"hello" : "hello" interface Tuple { >Tuple : Tuple @@ -194,25 +194,25 @@ var p: TaggedPair; >TaggedPair : TaggedPair p.a = 1; ->p.a = 1 : number +>p.a = 1 : 1 >p.a : number >p : TaggedPair >a : number ->1 : number +>1 : 1 p.b = 2; ->p.b = 2 : number +>p.b = 2 : 2 >p.b : number >p : TaggedPair >b : number ->2 : number +>2 : 2 p.tag = "test"; ->p.tag = "test" : string +>p.tag = "test" : "test" >p.tag : string >p : TaggedPair >tag : string ->"test" : string +>"test" : "test" function f() { >f : () => Foo diff --git a/tests/baselines/reference/genericTypeArgumentInference1.types b/tests/baselines/reference/genericTypeArgumentInference1.types index e2a570de28f..2dc6e51ff0f 100644 --- a/tests/baselines/reference/genericTypeArgumentInference1.types +++ b/tests/baselines/reference/genericTypeArgumentInference1.types @@ -47,11 +47,11 @@ var r = _.all([true, 1, null, 'yes'], _.identity); >_.all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >_ : Underscore.Static >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T ->[true, 1, null, 'yes'] : (string | number | true)[] +>[true, 1, null, 'yes'] : (true | 1 | "yes")[] >true : true ->1 : number +>1 : 1 >null : null ->'yes' : string +>'yes' : "yes" >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T @@ -87,7 +87,7 @@ var r4 = _.all([true], _.identity); >all : (list: T[], iterator?: Underscore.Iterator, context?: any) => T >[true] : any[] >true : any ->true : boolean +>true : true >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T diff --git a/tests/baselines/reference/genericTypeParameterEquivalence2.types b/tests/baselines/reference/genericTypeParameterEquivalence2.types index 44e495088bc..6ab297fe32c 100644 --- a/tests/baselines/reference/genericTypeParameterEquivalence2.types +++ b/tests/baselines/reference/genericTypeParameterEquivalence2.types @@ -49,7 +49,7 @@ function forEach(list: A[], f: (a: A, n?: number) => void ): void { for (var i = 0; i < list.length; ++i) { >i : number ->0 : number +>0 : 0 >i < list.length : boolean >i : number >list.length : number diff --git a/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types b/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types index a316773e5c8..c7c11a42743 100644 --- a/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types +++ b/tests/baselines/reference/genericWithIndexerOfTypeParameterType1.types @@ -31,5 +31,5 @@ var value: string = lazyArray.array()["test"]; // used to be an error >lazyArray.array : () => { [objectId: string]: string; } >lazyArray : LazyArray >array : () => { [objectId: string]: string; } ->"test" : string +>"test" : "test" diff --git a/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt b/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt index 98db4282244..ba9ec881f99 100644 --- a/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt +++ b/tests/baselines/reference/genericWithOpenTypeParameters1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/genericWithOpenTypeParameters1.ts(7,40): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +tests/cases/compiler/genericWithOpenTypeParameters1.ts(7,40): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. tests/cases/compiler/genericWithOpenTypeParameters1.ts(8,35): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/genericWithOpenTypeParameters1.ts(9,35): error TS2346: Supplied parameters do not match any signature of call target. @@ -12,7 +12,7 @@ tests/cases/compiler/genericWithOpenTypeParameters1.ts(9,35): error TS2346: Supp x.foo(1); // no error var f = (x: B) => { return x.foo(1); } // error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. var f2 = (x: B) => { return x.foo(1); } // error ~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt index 5b076b078c5..845a4011d9f 100644 --- a/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt +++ b/tests/baselines/reference/getSetAccessorContextualTyping.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,16): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts(8,16): error TS2322: Type '"string"' is not assignable to type 'number'. ==== tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyping.ts (1 errors) ==== @@ -11,7 +11,7 @@ tests/cases/conformance/expressions/contextualTyping/getSetAccessorContextualTyp get X() { return "string"; // Error; get contextual type by set accessor parameter type annotation ~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"string"' is not assignable to type 'number'. } set Y(y) { } diff --git a/tests/baselines/reference/getterSetterNonAccessor.types b/tests/baselines/reference/getterSetterNonAccessor.types index 0534ca623e7..f5eb22296f3 100644 --- a/tests/baselines/reference/getterSetterNonAccessor.types +++ b/tests/baselines/reference/getterSetterNonAccessor.types @@ -1,7 +1,7 @@ === tests/cases/compiler/getterSetterNonAccessor.ts === function getFunc():any{return 0;} >getFunc : () => any ->0 : number +>0 : 0 function setFunc(v){} >setFunc : (v: any) => void @@ -13,7 +13,7 @@ Object.defineProperty({}, "0", ({ >Object : ObjectConstructor >defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any >{} : {} ->"0" : string +>"0" : "0" >({ get: getFunc, set: setFunc, configurable: true }) : PropertyDescriptor >PropertyDescriptor : PropertyDescriptor >({ get: getFunc, set: setFunc, configurable: true }) : { get: () => any; set: (v: any) => void; configurable: true; } @@ -28,7 +28,7 @@ Object.defineProperty({}, "0", ({ >setFunc : (v: any) => void configurable: true ->configurable : true +>configurable : boolean >true : true })); diff --git a/tests/baselines/reference/global.types b/tests/baselines/reference/global.types index f866f062068..c56e039f230 100644 --- a/tests/baselines/reference/global.types +++ b/tests/baselines/reference/global.types @@ -15,13 +15,13 @@ module M { var x=10; >x : number ->10 : number +>10 : 10 M.f(3); >M.f(3) : number >M.f : (y: number) => number >M : typeof M >f : (y: number) => number ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/globalIsContextualKeyword.types b/tests/baselines/reference/globalIsContextualKeyword.types index d0bf624af6d..371c05c2183 100644 --- a/tests/baselines/reference/globalIsContextualKeyword.types +++ b/tests/baselines/reference/globalIsContextualKeyword.types @@ -4,7 +4,7 @@ function a() { let global = 1; >global : number ->1 : number +>1 : 1 } function b() { >b : () => void @@ -28,5 +28,5 @@ let obj = { global: "123" >global : string ->"123" : string +>"123" : "123" } diff --git a/tests/baselines/reference/globalThisCapture.types b/tests/baselines/reference/globalThisCapture.types index b8ed146d8c4..063100ff78e 100644 --- a/tests/baselines/reference/globalThisCapture.types +++ b/tests/baselines/reference/globalThisCapture.types @@ -15,5 +15,5 @@ var parts = []; parts[0]; >parts[0] : any >parts : any[] ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/grammarAmbiguities1.errors.txt b/tests/baselines/reference/grammarAmbiguities1.errors.txt index 12df5f3c1e0..8809c4aa334 100644 --- a/tests/baselines/reference/grammarAmbiguities1.errors.txt +++ b/tests/baselines/reference/grammarAmbiguities1.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/grammarAmbiguities1.ts(8,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/grammarAmbiguities1.ts(8,3): error TS2365: Operator '<' cannot be applied to types '(x: any) => any' and 'typeof A'. -tests/cases/compiler/grammarAmbiguities1.ts(8,10): error TS2365: Operator '>' cannot be applied to types 'typeof B' and 'number'. +tests/cases/compiler/grammarAmbiguities1.ts(8,10): error TS2365: Operator '>' cannot be applied to types 'typeof B' and '7'. tests/cases/compiler/grammarAmbiguities1.ts(9,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/grammarAmbiguities1.ts(9,3): error TS2365: Operator '<' cannot be applied to types '(x: any) => any' and 'typeof A'. tests/cases/compiler/grammarAmbiguities1.ts(9,10): error TS2365: Operator '>' cannot be applied to types 'typeof B' and 'number'. @@ -20,7 +20,7 @@ tests/cases/compiler/grammarAmbiguities1.ts(9,10): error TS2365: Operator '>' ca ~~~~~ !!! error TS2365: Operator '<' cannot be applied to types '(x: any) => any' and 'typeof A'. ~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'typeof B' and 'number'. +!!! error TS2365: Operator '>' cannot be applied to types 'typeof B' and '7'. f(g < A, B > +(7)); ~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/heterogeneousArrayLiterals.types b/tests/baselines/reference/heterogeneousArrayLiterals.types index 026e9c26bae..f1c5b6b8dfc 100644 --- a/tests/baselines/reference/heterogeneousArrayLiterals.types +++ b/tests/baselines/reference/heterogeneousArrayLiterals.types @@ -4,27 +4,27 @@ var a = [1, '']; // {}[] >a : (string | number)[] >[1, ''] : (string | number)[] ->1 : number ->'' : string +>1 : 1 +>'' : "" var b = [1, null]; // number[] >b : number[] >[1, null] : number[] ->1 : number +>1 : 1 >null : null var c = [1, '', null]; // {}[] >c : (string | number)[] >[1, '', null] : (string | number)[] ->1 : number ->'' : string +>1 : 1 +>'' : "" >null : null var d = [{}, 1]; // {}[] >d : {}[] >[{}, 1] : {}[] >{} : {} ->1 : number +>1 : 1 var e = [{}, Object]; // {}[] >e : {}[] @@ -37,61 +37,61 @@ var f = [[], [1]]; // number[][] >[[], [1]] : number[][] >[] : undefined[] >[1] : number[] ->1 : number +>1 : 1 var g = [[1], ['']]; // {}[] >g : (number[] | string[])[] >[[1], ['']] : (number[] | string[])[] >[1] : number[] ->1 : number +>1 : 1 >[''] : string[] ->'' : string +>'' : "" var h = [{ foo: 1, bar: '' }, { foo: 2 }]; // {foo: number}[] >h : ({ foo: number; bar: string; } | { foo: number; })[] >[{ foo: 1, bar: '' }, { foo: 2 }] : ({ foo: number; bar: string; } | { foo: number; })[] >{ foo: 1, bar: '' } : { foo: number; bar: string; } >foo : number ->1 : number +>1 : 1 >bar : string ->'' : string +>'' : "" >{ foo: 2 } : { foo: number; } >foo : number ->2 : number +>2 : 2 var i = [{ foo: 1, bar: '' }, { foo: '' }]; // {}[] >i : ({ foo: number; bar: string; } | { foo: string; })[] >[{ foo: 1, bar: '' }, { foo: '' }] : ({ foo: number; bar: string; } | { foo: string; })[] >{ foo: 1, bar: '' } : { foo: number; bar: string; } >foo : number ->1 : number +>1 : 1 >bar : string ->'' : string +>'' : "" >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" var j = [() => 1, () => '']; // {}[] >j : ((() => number) | (() => string))[] >[() => 1, () => ''] : ((() => number) | (() => string))[] >() => 1 : () => number ->1 : number +>1 : 1 >() => '' : () => string ->'' : string +>'' : "" var k = [() => 1, () => 1]; // { (): number }[] >k : (() => number)[] >[() => 1, () => 1] : (() => number)[] >() => 1 : () => number ->1 : number +>1 : 1 >() => 1 : () => number ->1 : number +>1 : 1 var l = [() => 1, () => null]; // { (): any }[] >l : (() => any)[] >[() => 1, () => null] : (() => any)[] >() => 1 : () => number ->1 : number +>1 : 1 >() => null : () => any >null : null @@ -99,9 +99,9 @@ var m = [() => 1, () => '', () => null]; // { (): any }[] >m : (() => any)[] >[() => 1, () => '', () => null] : (() => any)[] >() => 1 : () => number ->1 : number +>1 : 1 >() => '' : () => string ->'' : string +>'' : "" >() => null : () => any >null : null @@ -110,10 +110,10 @@ var n = [[() => 1], [() => '']]; // {}[] >[[() => 1], [() => '']] : ((() => number)[] | (() => string)[])[] >[() => 1] : (() => number)[] >() => 1 : () => number ->1 : number +>1 : 1 >[() => ''] : (() => string)[] >() => '' : () => string ->'' : string +>'' : "" class Base { foo: string; } >Base : Base @@ -182,7 +182,7 @@ module Derived { >() => base : () => Base >base : Base >() => 1 : () => number ->1 : number +>1 : 1 var l = [() => base, () => null]; // { (): any }[] >l : (() => any)[] @@ -299,7 +299,7 @@ function foo(t: T, u: U) { >d : (number | T)[] >[t, 1] : (number | T)[] >t : T ->1 : number +>1 : 1 var e = [() => t, () => u]; // {}[] >e : ((() => T) | (() => U))[] @@ -353,7 +353,7 @@ function foo2(t: T, u: U) { >d : (number | T)[] >[t, 1] : (number | T)[] >t : T ->1 : number +>1 : 1 var e = [() => t, () => u]; // {}[] >e : ((() => T) | (() => U))[] @@ -431,7 +431,7 @@ function foo3(t: T, u: U) { >d : (number | T)[] >[t, 1] : (number | T)[] >t : T ->1 : number +>1 : 1 var e = [() => t, () => u]; // {}[] >e : ((() => T) | (() => U))[] @@ -509,7 +509,7 @@ function foo4(t: T, u: U) { >d : (number | T)[] >[t, 1] : (number | T)[] >t : T ->1 : number +>1 : 1 var e = [() => t, () => u]; // {}[] >e : ((() => T) | (() => U))[] diff --git a/tests/baselines/reference/hidingCallSignatures.types b/tests/baselines/reference/hidingCallSignatures.types index c45cab69d8a..87285361f99 100644 --- a/tests/baselines/reference/hidingCallSignatures.types +++ b/tests/baselines/reference/hidingCallSignatures.types @@ -36,12 +36,12 @@ var d: D; d(""); // number >d("") : number >d : D ->"" : string +>"" : "" new d(""); // should be string >new d("") : string >d : D ->"" : string +>"" : "" var f: F; >f : F @@ -50,7 +50,7 @@ var f: F; f(""); // string >f("") : string >f : F ->"" : string +>"" : "" var e: E; >e : E @@ -59,5 +59,5 @@ var e: E; e(""); // {} >e("") : {} >e : E ->"" : string +>"" : "" diff --git a/tests/baselines/reference/hidingConstructSignatures.types b/tests/baselines/reference/hidingConstructSignatures.types index 0fd9860de25..7432732277f 100644 --- a/tests/baselines/reference/hidingConstructSignatures.types +++ b/tests/baselines/reference/hidingConstructSignatures.types @@ -36,12 +36,12 @@ var d: D; d(""); // string >d("") : string >d : D ->"" : string +>"" : "" new d(""); // should be number >new d("") : number >d : D ->"" : string +>"" : "" var f: F; >f : F @@ -50,7 +50,7 @@ var f: F; new f(""); // string >new f("") : string >f : F ->"" : string +>"" : "" var e: E; >e : E @@ -59,5 +59,5 @@ var e: E; new e(""); // {} >new e("") : {} >e : E ->"" : string +>"" : "" diff --git a/tests/baselines/reference/hidingIndexSignatures.types b/tests/baselines/reference/hidingIndexSignatures.types index 9a6346ace7b..a6609aa75c8 100644 --- a/tests/baselines/reference/hidingIndexSignatures.types +++ b/tests/baselines/reference/hidingIndexSignatures.types @@ -21,7 +21,7 @@ var b: B; b[""]; // Should be number >b[""] : number >b : B ->"" : string +>"" : "" var a: A; >a : A @@ -30,5 +30,5 @@ var a: A; a[""]; // Should be {} >a[""] : {} >a : A ->"" : string +>"" : "" diff --git a/tests/baselines/reference/ifDoWhileStatements.types b/tests/baselines/reference/ifDoWhileStatements.types index 660eaa4fb63..eee459391c5 100644 --- a/tests/baselines/reference/ifDoWhileStatements.types +++ b/tests/baselines/reference/ifDoWhileStatements.types @@ -49,14 +49,14 @@ class D{ function F(x: string): number { return 42; } >F : (x: string) => number >x : string ->42 : number +>42 : 42 function F2(x: number): boolean { return x < 42; } >F2 : (x: number) => boolean >x : number >x < 42 : boolean >x : number ->42 : number +>42 : 42 module M { >M : typeof M @@ -98,13 +98,13 @@ module N { // literals if (true) { } ->true : boolean +>true : true while (true) { } ->true : boolean +>true : true do { }while(true) ->true : boolean +>true : true if (null) { } >null : null @@ -125,31 +125,31 @@ do { }while(undefined) >undefined : undefined if (0.0) { } ->0.0 : number +>0.0 : 0 while (0.0) { } ->0.0 : number +>0.0 : 0 do { }while(0.0) ->0.0 : number +>0.0 : 0 if ('a string') { } ->'a string' : string +>'a string' : "a string" while ('a string') { } ->'a string' : string +>'a string' : "a string" do { }while('a string') ->'a string' : string +>'a string' : "a string" if ('') { } ->'' : string +>'' : "" while ('') { } ->'' : string +>'' : "" do { }while('') ->'' : string +>'' : "" if (/[a-z]/) { } >/[a-z]/ : RegExp @@ -171,18 +171,18 @@ do { }while([]) if ([1, 2]) { } >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 while ([1, 2]) { } >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 do { }while([1, 2]) >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 if ({}) { } >{} : {} @@ -196,35 +196,35 @@ do { }while({}) if ({ x: 1, y: 'a' }) { } >{ x: 1, y: 'a' } : { x: number; y: string; } >x : number ->1 : number +>1 : 1 >y : string ->'a' : string +>'a' : "a" while ({ x: 1, y: 'a' }) { } >{ x: 1, y: 'a' } : { x: number; y: string; } >x : number ->1 : number +>1 : 1 >y : string ->'a' : string +>'a' : "a" do { }while({ x: 1, y: 'a' }) >{ x: 1, y: 'a' } : { x: number; y: string; } >x : number ->1 : number +>1 : 1 >y : string ->'a' : string +>'a' : "a" if (() => 43) { } >() => 43 : () => number ->43 : number +>43 : 43 while (() => 43) { } >() => 43 : () => number ->43 : number +>43 : 43 do { }while(() => 43) >() => 43 : () => number ->43 : number +>43 : 43 if (new C()) { } >new C() : C @@ -256,7 +256,7 @@ do { }while(new D()) // references var a = true; >a : boolean ->true : boolean +>true : true if (a) { } >a : boolean @@ -295,7 +295,7 @@ do { }while(c) var d = 0.0; >d : number ->0.0 : number +>0.0 : 0 if (d) { } >d : number @@ -308,7 +308,7 @@ do { }while(d) var e = 'a string'; >e : string ->'a string' : string +>'a string' : "a string" if (e) { } >e : string @@ -321,7 +321,7 @@ do { }while(e) var f = ''; >f : string ->'' : string +>'' : "" if (f) { } >f : string @@ -361,8 +361,8 @@ do { }while(h) var i = [1, 2]; >i : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 if (i) { } >i : number[] @@ -390,9 +390,9 @@ var k = { x: 1, y: 'a' }; >k : { x: number; y: string; } >{ x: 1, y: 'a' } : { x: number; y: string; } >x : number ->1 : number +>1 : 1 >y : string ->'a' : string +>'a' : "a" if (k) { } >k : { x: number; y: string; } diff --git a/tests/baselines/reference/implicitAnyAnyReturningFunction.types b/tests/baselines/reference/implicitAnyAnyReturningFunction.types index 66f9cf49cb0..73b90b76a0b 100644 --- a/tests/baselines/reference/implicitAnyAnyReturningFunction.types +++ b/tests/baselines/reference/implicitAnyAnyReturningFunction.types @@ -4,7 +4,7 @@ function A() { return ""; >"" : any ->"" : string +>"" : "" } function B() { @@ -26,7 +26,7 @@ class C { return ""; >"" : any ->"" : string +>"" : "" } public B() { diff --git a/tests/baselines/reference/implicitAnyGenerics.types b/tests/baselines/reference/implicitAnyGenerics.types index e335c958fe9..2d43ecbbdbe 100644 --- a/tests/baselines/reference/implicitAnyGenerics.types +++ b/tests/baselines/reference/implicitAnyGenerics.types @@ -49,20 +49,20 @@ var d2 = new D(1); >d2 : D >new D(1) : D >D : typeof D ->1 : number +>1 : 1 var d3 = new D(1); >d3 : D >new D(1) : D >D : typeof D ->1 : number +>1 : 1 var d4 = new D(1); >d4 : D >new D(1) : D >D : typeof D >1 : any ->1 : number +>1 : 1 var d5: D = new D(null); >d5 : D diff --git a/tests/baselines/reference/implicitAnyInCatch.types b/tests/baselines/reference/implicitAnyInCatch.types index 6dda46fd3ca..d2a1be4a910 100644 --- a/tests/baselines/reference/implicitAnyInCatch.types +++ b/tests/baselines/reference/implicitAnyInCatch.types @@ -9,7 +9,7 @@ try { } catch (error) { >error : any >number : any >-2147024809 : -2147024809 ->2147024809 : number +>2147024809 : 2147024809 } for (var key in this) { } >key : string diff --git a/tests/baselines/reference/implicitIndexSignatures.types b/tests/baselines/reference/implicitIndexSignatures.types index 6d670c6341b..ac8da0c7b6c 100644 --- a/tests/baselines/reference/implicitIndexSignatures.types +++ b/tests/baselines/reference/implicitIndexSignatures.types @@ -14,9 +14,9 @@ const names1 = { a: "foo", b: "bar" }; >names1 : { a: string; b: string; } >{ a: "foo", b: "bar" } : { a: string; b: string; } >a : string ->"foo" : string +>"foo" : "foo" >b : string ->"bar" : string +>"bar" : "bar" let names2: { a: string, b: string }; >names2 : { a: string; b: string; } @@ -32,9 +32,9 @@ map = { x: "xxx", y: "yyy" }; >map : { [x: string]: string; } >{ x: "xxx", y: "yyy" } : { x: string; y: string; } >x : string ->"xxx" : string +>"xxx" : "xxx" >y : string ->"yyy" : string +>"yyy" : "yyy" map = empty1; >map = empty1 : {} @@ -79,9 +79,9 @@ function f1() { >o1 : { a: number; b: number; } >{ a: 1, b: 2 } : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 let o2: { a: number, b: number }; >o2 : { a: number; b: number; } @@ -108,9 +108,9 @@ function f2() { >o1 : { a: string; b: string; } >{ a: "1", b: "2" } : { a: string; b: string; } >a : string ->"1" : string +>"1" : "1" >b : string ->"2" : string +>"2" : "2" let o2: { a: string, b: string }; >o2 : { a: string; b: string; } @@ -137,9 +137,9 @@ function f3() { >o1 : { a: number; b: string; } >{ a: 1, b: "2" } : { a: number; b: string; } >a : number ->1 : number +>1 : 1 >b : string ->"2" : string +>"2" : "2" let o2: { a: number, b: string }; >o2 : { a: number; b: string; } @@ -165,10 +165,10 @@ function f4() { const o1 = { 0: "0", 1: "1", count: 2 }; >o1 : { 0: string; 1: string; count: number; } >{ 0: "0", 1: "1", count: 2 } : { 0: string; 1: string; count: number; } ->"0" : string ->"1" : string +>"0" : "0" +>"1" : "1" >count : number ->2 : number +>2 : 2 let o2: { 0: string, 1: string, count: number }; >o2 : { 0: string; 1: string; count: number; } diff --git a/tests/baselines/reference/importAliasIdentifiers.types b/tests/baselines/reference/importAliasIdentifiers.types index 6746a5b3af7..4c9701ded10 100644 --- a/tests/baselines/reference/importAliasIdentifiers.types +++ b/tests/baselines/reference/importAliasIdentifiers.types @@ -52,9 +52,9 @@ module clodule { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } import clolias = clodule; @@ -83,9 +83,9 @@ function fundule() { return { x: 0, y: 0 }; >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } module fundule { @@ -103,9 +103,9 @@ module fundule { >Point : Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } import funlias = fundule; diff --git a/tests/baselines/reference/importAliasWithDottedName.types b/tests/baselines/reference/importAliasWithDottedName.types index 24ec5d1b0bb..b5882fce117 100644 --- a/tests/baselines/reference/importAliasWithDottedName.types +++ b/tests/baselines/reference/importAliasWithDottedName.types @@ -4,14 +4,14 @@ module M { export var x = 1; >x : number ->1 : number +>1 : 1 export module N { >N : typeof N export var y = 2; >y : number ->2 : number +>2 : 2 } } diff --git a/tests/baselines/reference/importAndVariableDeclarationConflict2.types b/tests/baselines/reference/importAndVariableDeclarationConflict2.types index eafc7be6deb..4b6e9acec06 100644 --- a/tests/baselines/reference/importAndVariableDeclarationConflict2.types +++ b/tests/baselines/reference/importAndVariableDeclarationConflict2.types @@ -4,7 +4,7 @@ module m { export var m = ''; >m : string ->'' : string +>'' : "" } import x = m.m; @@ -20,6 +20,6 @@ class C { var x = ''; >x : string ->'' : string +>'' : "" } } diff --git a/tests/baselines/reference/importImportOnlyModule.types b/tests/baselines/reference/importImportOnlyModule.types index c1275bed511..d02cdb3353f 100644 --- a/tests/baselines/reference/importImportOnlyModule.types +++ b/tests/baselines/reference/importImportOnlyModule.types @@ -12,11 +12,11 @@ export class C1 { m1 = 42; >m1 : number ->42 : number +>42 : 42 static s1 = true; >s1 : boolean ->true : boolean +>true : true } === tests/cases/conformance/externalModules/foo_1.ts === @@ -25,5 +25,5 @@ import c1 = require('./foo_0'); // Makes this an external module var answer = 42; // No exports >answer : number ->42 : number +>42 : 42 diff --git a/tests/baselines/reference/importInTypePosition.types b/tests/baselines/reference/importInTypePosition.types index 7360416e4b3..22802728fd0 100644 --- a/tests/baselines/reference/importInTypePosition.types +++ b/tests/baselines/reference/importInTypePosition.types @@ -13,8 +13,8 @@ module A { >Origin : Point >new Point(0, 0) : Point >Point : typeof Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 } // no code gen expected @@ -46,8 +46,8 @@ module C { >p : a.Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/importStatements.types b/tests/baselines/reference/importStatements.types index ecf4453b360..53509ceb70c 100644 --- a/tests/baselines/reference/importStatements.types +++ b/tests/baselines/reference/importStatements.types @@ -14,8 +14,8 @@ module A { >Origin : Point >new Point(0, 0) : Point >Point : typeof Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 } // no code gen expected @@ -48,9 +48,9 @@ module C { >p : a.Point >{x:0, y:0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } // code gen expected @@ -67,8 +67,8 @@ module D { >a.Point : typeof a.Point >a : typeof a >Point : typeof a.Point ->1 : number ->1 : number +>1 : 1 +>1 : 1 } module E { diff --git a/tests/baselines/reference/import_reference-exported-alias.types b/tests/baselines/reference/import_reference-exported-alias.types index 3f9c34f62dc..2f2496a7b77 100644 --- a/tests/baselines/reference/import_reference-exported-alias.types +++ b/tests/baselines/reference/import_reference-exported-alias.types @@ -34,7 +34,7 @@ module App { >getUserName : () => string return "Bill Gates"; ->"Bill Gates" : string +>"Bill Gates" : "Bill Gates" } } } diff --git a/tests/baselines/reference/import_reference-to-type-alias.types b/tests/baselines/reference/import_reference-to-type-alias.types index 53c7dabcd5f..e2327650f1a 100644 --- a/tests/baselines/reference/import_reference-to-type-alias.types +++ b/tests/baselines/reference/import_reference-to-type-alias.types @@ -32,7 +32,7 @@ export module App { >getUserName : () => string return "Bill Gates"; ->"Bill Gates" : string +>"Bill Gates" : "Bill Gates" } } } diff --git a/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.types b/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.types index 2fda99dc064..0449bfd16bf 100644 --- a/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.types +++ b/tests/baselines/reference/import_unneeded-require-when-referenecing-aliased-type-throug-array.types @@ -12,7 +12,7 @@ var p = testData[0].name; >testData[0].name : string >testData[0] : ITest >testData : ITest[] ->0 : number +>0 : 0 >name : string === tests/cases/compiler/b.ts === diff --git a/tests/baselines/reference/inOperatorWithFunction.types b/tests/baselines/reference/inOperatorWithFunction.types index e85a86632c7..21e9da3f040 100644 --- a/tests/baselines/reference/inOperatorWithFunction.types +++ b/tests/baselines/reference/inOperatorWithFunction.types @@ -9,7 +9,7 @@ fn("a" in { "a": true }); >fn("a" in { "a": true }) : boolean >fn : (val: boolean) => boolean >"a" in { "a": true } : boolean ->"a" : string +>"a" : "a" >{ "a": true } : { "a": boolean; } ->true : boolean +>true : true diff --git a/tests/baselines/reference/inOperatorWithValidOperands.types b/tests/baselines/reference/inOperatorWithValidOperands.types index 0cca583e683..7e121e54146 100644 --- a/tests/baselines/reference/inOperatorWithValidOperands.types +++ b/tests/baselines/reference/inOperatorWithValidOperands.types @@ -31,13 +31,13 @@ var ra3 = a2 in x; var ra4 = '' in x; >ra4 : boolean >'' in x : boolean ->'' : string +>'' : "" >x : any var ra5 = 0 in x; >ra5 : boolean >0 in x : boolean ->0 : number +>0 : 0 >x : any // valid right operands diff --git a/tests/baselines/reference/incompatibleTypes.errors.txt b/tests/baselines/reference/incompatibleTypes.errors.txt index cb6de6576b2..0939eb68c2b 100644 --- a/tests/baselines/reference/incompatibleTypes.errors.txt +++ b/tests/baselines/reference/incompatibleTypes.errors.txt @@ -22,8 +22,8 @@ tests/cases/compiler/incompatibleTypes.ts(49,7): error TS2345: Argument of type Object literal may only specify known properties, and 'e' does not exist in type '{ c: { b: string; }; d: string; }'. tests/cases/compiler/incompatibleTypes.ts(66,47): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. Object literal may only specify known properties, and 'e' does not exist in type '{ a: { a: string; }; b: string; }'. -tests/cases/compiler/incompatibleTypes.ts(72,5): error TS2322: Type 'number' is not assignable to type '() => string'. -tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => number' is not assignable to type '() => any'. +tests/cases/compiler/incompatibleTypes.ts(72,5): error TS2322: Type '5' is not assignable to type '() => string'. +tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => 0' is not assignable to type '() => any'. ==== tests/cases/compiler/incompatibleTypes.ts (9 errors) ==== @@ -131,9 +131,9 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => var i1c1: { (): string; } = 5; ~~~~ -!!! error TS2322: Type 'number' is not assignable to type '() => string'. +!!! error TS2322: Type '5' is not assignable to type '() => string'. var fp1: () =>any = a => 0; ~~~ -!!! error TS2322: Type '(a: any) => number' is not assignable to type '() => any'. +!!! error TS2322: Type '(a: any) => 0' is not assignable to type '() => any'. \ No newline at end of file diff --git a/tests/baselines/reference/incrementOperatorWithAnyOtherType.types b/tests/baselines/reference/incrementOperatorWithAnyOtherType.types index 3643b646ace..715de620bff 100644 --- a/tests/baselines/reference/incrementOperatorWithAnyOtherType.types +++ b/tests/baselines/reference/incrementOperatorWithAnyOtherType.types @@ -10,14 +10,14 @@ var ANY1; var ANY2: any[] = ["", ""]; >ANY2 : any[] >["", ""] : string[] ->"" : string ->"" : string +>"" : "" +>"" : "" var obj = {x:1,y:null}; >obj : { x: number; y: any; } >{x:1,y:null} : { x: number; y: null; } >x : number ->1 : number +>1 : 1 >y : null >null : null @@ -65,7 +65,7 @@ var ResultIsNumber5 = ++ANY2[0]; >++ANY2[0] : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 var ResultIsNumber6 = ++obj.x; >ResultIsNumber6 : number @@ -100,7 +100,7 @@ var ResultIsNumber9 = ANY2[0]++; >ANY2[0]++ : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 var ResultIsNumber10 = obj.x++; >ResultIsNumber10 : number @@ -143,7 +143,7 @@ var ResultIsNumber13 = M.n++; >++ANY2[0] : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 ++ANY, ++ANY1; >++ANY, ++ANY1 : number @@ -176,7 +176,7 @@ ANY2[0]++; >ANY2[0]++ : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 ANY++, ANY1++; >ANY++, ANY1++ : number diff --git a/tests/baselines/reference/incrementOperatorWithNumberType.types b/tests/baselines/reference/incrementOperatorWithNumberType.types index 21211a3848c..03030289a77 100644 --- a/tests/baselines/reference/incrementOperatorWithNumberType.types +++ b/tests/baselines/reference/incrementOperatorWithNumberType.types @@ -6,8 +6,8 @@ var NUMBER: number; var NUMBER1: number[] = [1, 2]; >NUMBER1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 class A { >A : A @@ -72,7 +72,7 @@ var ResultIsNumber7 = NUMBER1[0]++; >NUMBER1[0]++ : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 // miss assignment operators ++NUMBER; @@ -83,7 +83,7 @@ var ResultIsNumber7 = NUMBER1[0]++; >++NUMBER1[0] : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 ++objA.a; >++objA.a : number @@ -115,7 +115,7 @@ NUMBER1[0]++; >NUMBER1[0]++ : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 objA.a++; >objA.a++ : number diff --git a/tests/baselines/reference/indexClassByNumber.types b/tests/baselines/reference/indexClassByNumber.types index b1fb79f256a..dfd27305ba9 100644 --- a/tests/baselines/reference/indexClassByNumber.types +++ b/tests/baselines/reference/indexClassByNumber.types @@ -10,9 +10,9 @@ var f = new foo(); >foo : typeof foo f[0] = 4; // Shouldn't be allowed ->f[0] = 4 : number +>f[0] = 4 : 4 >f[0] : any >f : foo ->0 : number ->4 : number +>0 : 0 +>4 : 4 diff --git a/tests/baselines/reference/indexIntoArraySubclass.errors.txt b/tests/baselines/reference/indexIntoArraySubclass.errors.txt index 1628e12d22f..bbcf259fb33 100644 --- a/tests/baselines/reference/indexIntoArraySubclass.errors.txt +++ b/tests/baselines/reference/indexIntoArraySubclass.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/indexIntoArraySubclass.ts(4,1): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/indexIntoArraySubclass.ts(4,1): error TS2322: Type '0' is not assignable to type 'string'. ==== tests/cases/compiler/indexIntoArraySubclass.ts (1 errors) ==== @@ -7,4 +7,4 @@ tests/cases/compiler/indexIntoArraySubclass.ts(4,1): error TS2322: Type 'number' var r = x2[0]; // string r = 0; //error ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/indexIntoEnum.types b/tests/baselines/reference/indexIntoEnum.types index 3c0d91cd240..9a22174d9bc 100644 --- a/tests/baselines/reference/indexIntoEnum.types +++ b/tests/baselines/reference/indexIntoEnum.types @@ -9,5 +9,5 @@ module M { >x : string >E[0] : string >E : typeof E ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/indexSignaturesInferentialTyping.types b/tests/baselines/reference/indexSignaturesInferentialTyping.types index 47c7aa21388..202e1489818 100644 --- a/tests/baselines/reference/indexSignaturesInferentialTyping.types +++ b/tests/baselines/reference/indexSignaturesInferentialTyping.types @@ -22,16 +22,16 @@ var x1 = foo({ 0: 0, 1: 1 }); // type should be number >foo({ 0: 0, 1: 1 }) : number >foo : (items: { [index: number]: T; }) => T >{ 0: 0, 1: 1 } : { 0: number; 1: number; } ->0 : number ->1 : number +>0 : 0 +>1 : 1 var x2 = bar({ 0: 0, 1: 1 }); >x2 : number >bar({ 0: 0, 1: 1 }) : number >bar : (items: { [index: string]: T; }) => T >{ 0: 0, 1: 1 } : { 0: number; 1: number; } ->0 : number ->1 : number +>0 : 0 +>1 : 1 var x3 = bar({ zero: 0, one: 1 }); // type should be number >x3 : number @@ -39,7 +39,7 @@ var x3 = bar({ zero: 0, one: 1 }); // type should be number >bar : (items: { [index: string]: T; }) => T >{ zero: 0, one: 1 } : { zero: number; one: number; } >zero : number ->0 : number +>0 : 0 >one : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/indexer.types b/tests/baselines/reference/indexer.types index f24c90f6ea1..6f648d8d232 100644 --- a/tests/baselines/reference/indexer.types +++ b/tests/baselines/reference/indexer.types @@ -20,15 +20,15 @@ var jq:JQuery={ 0: { id : "a" }, 1: { id : "b" } }; >{ 0: { id : "a" }, 1: { id : "b" } } : { 0: { id: string; }; 1: { id: string; }; } >{ id : "a" } : { id: string; } >id : string ->"a" : string +>"a" : "a" >{ id : "b" } : { id: string; } >id : string ->"b" : string +>"b" : "b" jq[0].id; >jq[0].id : string >jq[0] : JQueryElement >jq : JQuery ->0 : number +>0 : 0 >id : string diff --git a/tests/baselines/reference/indexer3.types b/tests/baselines/reference/indexer3.types index 28bcd9cab0c..58bf9b51f2e 100644 --- a/tests/baselines/reference/indexer3.types +++ b/tests/baselines/reference/indexer3.types @@ -10,5 +10,5 @@ var r: Date = dateMap["hello"] // result type includes indexer using BCT >Date : Date >dateMap["hello"] : Date >dateMap : { [x: string]: Date; } ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/indexerA.types b/tests/baselines/reference/indexerA.types index ee6351eae33..e0eadbc06b4 100644 --- a/tests/baselines/reference/indexerA.types +++ b/tests/baselines/reference/indexerA.types @@ -20,15 +20,15 @@ var jq:JQuery={ 0: { id : "a" }, 1: { id : "b" } }; >{ 0: { id : "a" }, 1: { id : "b" } } : { 0: { id: string; }; 1: { id: string; }; } >{ id : "a" } : { id: string; } >id : string ->"a" : string +>"a" : "a" >{ id : "b" } : { id: string; } >id : string ->"b" : string +>"b" : "b" jq[0].id; >jq[0].id : string >jq[0] : JQueryElement >jq : JQuery ->0 : number +>0 : 0 >id : string diff --git a/tests/baselines/reference/indexerWithTuple.types b/tests/baselines/reference/indexerWithTuple.types index 54ee714f5ef..8a14fa9816e 100644 --- a/tests/baselines/reference/indexerWithTuple.types +++ b/tests/baselines/reference/indexerWithTuple.types @@ -2,55 +2,55 @@ var strNumTuple: [string, number] = ["foo", 10]; >strNumTuple : [string, number] >["foo", 10] : [string, number] ->"foo" : string ->10 : number +>"foo" : "foo" +>10 : 10 var numTupleTuple: [number, [string, number]] = [10, ["bar", 20]]; >numTupleTuple : [number, [string, number]] >[10, ["bar", 20]] : [number, [string, number]] ->10 : number +>10 : 10 >["bar", 20] : [string, number] ->"bar" : string ->20 : number +>"bar" : "bar" +>20 : 20 var unionTuple1: [number, string| number] = [10, "foo"]; >unionTuple1 : [number, string | number] >[10, "foo"] : [number, string] ->10 : number ->"foo" : string +>10 : 10 +>"foo" : "foo" var unionTuple2: [boolean, string| number] = [true, "foo"]; >unionTuple2 : [boolean, string | number] >[true, "foo"] : [true, string] >true : true ->"foo" : string +>"foo" : "foo" // no error var idx0 = 0; >idx0 : number ->0 : number +>0 : 0 var idx1 = 1; >idx1 : number ->1 : number +>1 : 1 var ele10 = strNumTuple[0]; // string >ele10 : string >strNumTuple[0] : string >strNumTuple : [string, number] ->0 : number +>0 : 0 var ele11 = strNumTuple[1]; // number >ele11 : number >strNumTuple[1] : number >strNumTuple : [string, number] ->1 : number +>1 : 1 var ele12 = strNumTuple[2]; // string | number >ele12 : string | number >strNumTuple[2] : string | number >strNumTuple : [string, number] ->2 : number +>2 : 2 var ele13 = strNumTuple[idx0]; // string | number >ele13 : string | number @@ -68,43 +68,43 @@ var ele15 = strNumTuple["0"]; // string >ele15 : string >strNumTuple["0"] : string >strNumTuple : [string, number] ->"0" : string +>"0" : "0" var ele16 = strNumTuple["1"]; // number >ele16 : number >strNumTuple["1"] : number >strNumTuple : [string, number] ->"1" : string +>"1" : "1" var strNumTuple1 = numTupleTuple[1]; //[string, number]; >strNumTuple1 : [string, number] >numTupleTuple[1] : [string, number] >numTupleTuple : [number, [string, number]] ->1 : number +>1 : 1 var ele17 = numTupleTuple[2]; // number | [string, number] >ele17 : number | [string, number] >numTupleTuple[2] : number | [string, number] >numTupleTuple : [number, [string, number]] ->2 : number +>2 : 2 var eleUnion10 = unionTuple1[0]; // number >eleUnion10 : number >unionTuple1[0] : number >unionTuple1 : [number, string | number] ->0 : number +>0 : 0 var eleUnion11 = unionTuple1[1]; // string | number >eleUnion11 : string | number >unionTuple1[1] : string | number >unionTuple1 : [number, string | number] ->1 : number +>1 : 1 var eleUnion12 = unionTuple1[2]; // string | number >eleUnion12 : string | number >unionTuple1[2] : string | number >unionTuple1 : [number, string | number] ->2 : number +>2 : 2 var eleUnion13 = unionTuple1[idx0]; // string | number >eleUnion13 : string | number @@ -122,31 +122,31 @@ var eleUnion15 = unionTuple1["0"]; // number >eleUnion15 : number >unionTuple1["0"] : number >unionTuple1 : [number, string | number] ->"0" : string +>"0" : "0" var eleUnion16 = unionTuple1["1"]; // string | number >eleUnion16 : string | number >unionTuple1["1"] : string | number >unionTuple1 : [number, string | number] ->"1" : string +>"1" : "1" var eleUnion20 = unionTuple2[0]; // boolean >eleUnion20 : boolean >unionTuple2[0] : boolean >unionTuple2 : [boolean, string | number] ->0 : number +>0 : 0 var eleUnion21 = unionTuple2[1]; // string | number >eleUnion21 : string | number >unionTuple2[1] : string | number >unionTuple2 : [boolean, string | number] ->1 : number +>1 : 1 var eleUnion22 = unionTuple2[2]; // string | number | boolean >eleUnion22 : string | number | boolean >unionTuple2[2] : string | number | boolean >unionTuple2 : [boolean, string | number] ->2 : number +>2 : 2 var eleUnion23 = unionTuple2[idx0]; // string | number | boolean >eleUnion23 : string | number | boolean @@ -164,11 +164,11 @@ var eleUnion25 = unionTuple2["0"]; // boolean >eleUnion25 : boolean >unionTuple2["0"] : boolean >unionTuple2 : [boolean, string | number] ->"0" : string +>"0" : "0" var eleUnion26 = unionTuple2["1"]; // string | number >eleUnion26 : string | number >unionTuple2["1"] : string | number >unionTuple2 : [boolean, string | number] ->"1" : string +>"1" : "1" diff --git a/tests/baselines/reference/indexersInClassType.types b/tests/baselines/reference/indexersInClassType.types index 496526776d9..02316d810b9 100644 --- a/tests/baselines/reference/indexersInClassType.types +++ b/tests/baselines/reference/indexersInClassType.types @@ -39,7 +39,7 @@ var r2 = r[1]; >r2 : Date >r[1] : Date >r : C ->1 : number +>1 : 1 var r3 = r.a >r3 : {} diff --git a/tests/baselines/reference/inferParameterWithMethodCallInitializer.types b/tests/baselines/reference/inferParameterWithMethodCallInitializer.types index 9aeccb2b2e0..41c01808ae0 100644 --- a/tests/baselines/reference/inferParameterWithMethodCallInitializer.types +++ b/tests/baselines/reference/inferParameterWithMethodCallInitializer.types @@ -3,7 +3,7 @@ function getNumber(): number { >getNumber : () => number return 1; ->1 : number +>1 : 1 } class Example { >Example : Example @@ -12,7 +12,7 @@ class Example { >getNumber : () => number return 1; ->1 : number +>1 : 1 } doSomething(a = this.getNumber()): typeof a { >doSomething : (a?: number) => number diff --git a/tests/baselines/reference/inferSecondaryParameter.types b/tests/baselines/reference/inferSecondaryParameter.types index 34dbb14ea66..c4d827bb3c5 100644 --- a/tests/baselines/reference/inferSecondaryParameter.types +++ b/tests/baselines/reference/inferSecondaryParameter.types @@ -23,7 +23,7 @@ b.m("test", function (bug) { >b.m : (test: string, fn: Function) => any >b : Ib >m : (test: string, fn: Function) => any ->"test" : string +>"test" : "test" >function (bug) { var a: number = bug;} : (bug: any) => void >bug : any diff --git a/tests/baselines/reference/inferSetterParamType.errors.txt b/tests/baselines/reference/inferSetterParamType.errors.txt index 2ae2a16f9d2..02c02ba69d5 100644 --- a/tests/baselines/reference/inferSetterParamType.errors.txt +++ b/tests/baselines/reference/inferSetterParamType.errors.txt @@ -1,7 +1,7 @@ tests/cases/compiler/inferSetterParamType.ts(3,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(6,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. tests/cases/compiler/inferSetterParamType.ts(12,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. -tests/cases/compiler/inferSetterParamType.ts(13,16): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/inferSetterParamType.ts(13,16): error TS2322: Type '0' is not assignable to type 'string'. tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. @@ -26,7 +26,7 @@ tests/cases/compiler/inferSetterParamType.ts(15,9): error TS1056: Accessors are !!! error TS1056: Accessors are only available when targeting ECMAScript 5 and higher. return 0; // should be an error - can't coerce infered return type to match setter annotated type ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '0' is not assignable to type 'string'. } set bar(n:string) { ~~~ diff --git a/tests/baselines/reference/inferTypeArgumentsInSignatureWithRestParameters.types b/tests/baselines/reference/inferTypeArgumentsInSignatureWithRestParameters.types index f4d94388f42..24cecbfd183 100644 --- a/tests/baselines/reference/inferTypeArgumentsInSignatureWithRestParameters.types +++ b/tests/baselines/reference/inferTypeArgumentsInSignatureWithRestParameters.types @@ -28,11 +28,11 @@ function i(array: T[], opt?: any[]) { } var a = [1, 2, 3, 4, 5]; >a : number[] >[1, 2, 3, 4, 5] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 f(a); // OK >f(a) : void diff --git a/tests/baselines/reference/inferenceFromParameterlessLambda.types b/tests/baselines/reference/inferenceFromParameterlessLambda.types index 57747d881f6..907c2ab5468 100644 --- a/tests/baselines/reference/inferenceFromParameterlessLambda.types +++ b/tests/baselines/reference/inferenceFromParameterlessLambda.types @@ -33,6 +33,6 @@ foo(n => n.length, () => 'hi'); >n.length : number >n : string >length : number ->() => 'hi' : () => string ->'hi' : string +>() => 'hi' : () => "hi" +>'hi' : "hi" diff --git a/tests/baselines/reference/inferenceLimit.types b/tests/baselines/reference/inferenceLimit.types index 37b51e49644..c31ce844b11 100644 --- a/tests/baselines/reference/inferenceLimit.types +++ b/tests/baselines/reference/inferenceLimit.types @@ -1,6 +1,6 @@ === tests/cases/compiler/file1.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" import * as MyModule from "./mymodule"; >MyModule : typeof MyModule diff --git a/tests/baselines/reference/inferentialTypingObjectLiteralMethod1.types b/tests/baselines/reference/inferentialTypingObjectLiteralMethod1.types index da2fa24060f..9365013f050 100644 --- a/tests/baselines/reference/inferentialTypingObjectLiteralMethod1.types +++ b/tests/baselines/reference/inferentialTypingObjectLiteralMethod1.types @@ -29,7 +29,7 @@ declare function foo(x: T, y: Int, z: Int): T; foo("", { method(p1) { return p1.length } }, { method(p2) { return undefined } }); >foo("", { method(p1) { return p1.length } }, { method(p2) { return undefined } }) : string >foo : (x: T, y: Int, z: Int) => T ->"" : string +>"" : "" >{ method(p1) { return p1.length } } : { method(p1: string): number; } >method : (p1: string) => number >p1 : string diff --git a/tests/baselines/reference/inferentialTypingObjectLiteralMethod2.types b/tests/baselines/reference/inferentialTypingObjectLiteralMethod2.types index f70305739b8..2ee813193a2 100644 --- a/tests/baselines/reference/inferentialTypingObjectLiteralMethod2.types +++ b/tests/baselines/reference/inferentialTypingObjectLiteralMethod2.types @@ -29,7 +29,7 @@ declare function foo(x: T, y: Int, z: Int): T; foo("", { method(p1) { return p1.length } }, { method(p2) { return undefined } }); >foo("", { method(p1) { return p1.length } }, { method(p2) { return undefined } }) : string >foo : (x: T, y: Int, z: Int) => T ->"" : string +>"" : "" >{ method(p1) { return p1.length } } : { method(p1: string): number; } >method : (p1: string) => number >p1 : string diff --git a/tests/baselines/reference/inferentialTypingUsingApparentType3.types b/tests/baselines/reference/inferentialTypingUsingApparentType3.types index e375fe981e8..1738eff89a8 100644 --- a/tests/baselines/reference/inferentialTypingUsingApparentType3.types +++ b/tests/baselines/reference/inferentialTypingUsingApparentType3.types @@ -19,7 +19,7 @@ class CharField implements Field { >input : string return "Yup"; ->"Yup" : string +>"Yup" : "Yup" } } @@ -32,7 +32,7 @@ class NumberField implements Field { >input : number return 123; ->123 : number +>123 : 123 } } diff --git a/tests/baselines/reference/inferentialTypingWithFunctionType.types b/tests/baselines/reference/inferentialTypingWithFunctionType.types index 460156c91ea..0360adefd7c 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionType.types +++ b/tests/baselines/reference/inferentialTypingWithFunctionType.types @@ -22,6 +22,6 @@ var s = map("", identity); >s : string >map("", identity) : string >map : (x: T, f: (s: T) => U) => U ->"" : string +>"" : "" >identity : (y: V) => V diff --git a/tests/baselines/reference/inferentialTypingWithFunctionType2.types b/tests/baselines/reference/inferentialTypingWithFunctionType2.types index 6dc4cda3b68..2c4bb2542fb 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionType2.types +++ b/tests/baselines/reference/inferentialTypingWithFunctionType2.types @@ -15,10 +15,10 @@ var x = [1, 2, 3].map(identity)[0]; >[1, 2, 3].map(identity) : number[] >[1, 2, 3].map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >identity : (a: A) => A ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/inferentialTypingWithFunctionTypeNested.types b/tests/baselines/reference/inferentialTypingWithFunctionTypeNested.types index a83379b4c73..86219faf537 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionTypeNested.types +++ b/tests/baselines/reference/inferentialTypingWithFunctionTypeNested.types @@ -23,7 +23,7 @@ var s = map("", () => { return { x: identity }; }); >s : string >map("", () => { return { x: identity }; }) : string >map : (x: T, f: () => { x: (s: T) => U; }) => U ->"" : string +>"" : "" >() => { return { x: identity }; } : () => { x: (y: string) => string; } >{ x: identity } : { x: (y: V) => V; } >x : (y: V) => V diff --git a/tests/baselines/reference/inferentialTypingWithFunctionTypeSyntacticScenarios.types b/tests/baselines/reference/inferentialTypingWithFunctionTypeSyntacticScenarios.types index 5a4decef4dc..cb7904b8060 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionTypeSyntacticScenarios.types +++ b/tests/baselines/reference/inferentialTypingWithFunctionTypeSyntacticScenarios.types @@ -33,7 +33,7 @@ s = map("", dottedIdentity.x); >s : string >map("", dottedIdentity.x) : string >map : (array: T, func: (x: T) => U) => U ->"" : string +>"" : "" >dottedIdentity.x : (y: V) => V >dottedIdentity : { x: (y: V) => V; } >x : (y: V) => V @@ -44,10 +44,10 @@ s = map("", dottedIdentity['x']); >s : string >map("", dottedIdentity['x']) : string >map : (array: T, func: (x: T) => U) => U ->"" : string +>"" : "" >dottedIdentity['x'] : (y: V) => V >dottedIdentity : { x: (y: V) => V; } ->'x' : string +>'x' : "x" // function call s = map("", (() => identity)()); @@ -55,7 +55,7 @@ s = map("", (() => identity)()); >s : string >map("", (() => identity)()) : string >map : (array: T, func: (x: T) => U) => U ->"" : string +>"" : "" >(() => identity)() : (y: V) => V >(() => identity) : () => (y: V) => V >() => identity : () => (y: V) => V @@ -77,7 +77,7 @@ s = map("", new ic()); >s : string >map("", new ic()) : string >map : (array: T, func: (x: T) => U) => U ->"" : string +>"" : "" >new ic() : (y: V) => V >ic : IdentityConstructor @@ -90,7 +90,7 @@ s = map("", t = identity); >s : string >map("", t = identity) : string >map : (array: T, func: (x: T) => U) => U ->"" : string +>"" : "" >t = identity : (y: V) => V >t : any >identity : (y: V) => V @@ -101,7 +101,7 @@ s = map("", identity); >s : string >map("", identity) : string >map : (array: T, func: (x: T) => U) => U ->"" : string +>"" : "" >identity : (y: V) => V >identity : (y: V) => V >identity : (y: V) => V @@ -112,7 +112,7 @@ s = map("", (identity)); >s : string >map("", (identity)) : string >map : (array: T, func: (x: T) => U) => U ->"" : string +>"" : "" >(identity) : (y: V) => V >identity : (y: V) => V @@ -122,9 +122,9 @@ s = map("", ("", identity)); >s : string >map("", ("", identity)) : string >map : (array: T, func: (x: T) => U) => U ->"" : string +>"" : "" >("", identity) : (y: V) => V >"", identity : (y: V) => V ->"" : string +>"" : "" >identity : (y: V) => V diff --git a/tests/baselines/reference/inferentialTypingWithFunctionTypeZip.types b/tests/baselines/reference/inferentialTypingWithFunctionTypeZip.types index cc9d8790bd4..58d51e48987 100644 --- a/tests/baselines/reference/inferentialTypingWithFunctionTypeZip.types +++ b/tests/baselines/reference/inferentialTypingWithFunctionTypeZip.types @@ -34,11 +34,11 @@ var result = zipWith([1, 2], ['a', 'b'], pair); >zipWith([1, 2], ['a', 'b'], pair) : { x: number; y: {}; }[] >zipWith : (a: T[], b: S[], f: (x: T) => (y: S) => U) => U[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >['a', 'b'] : string[] ->'a' : string ->'b' : string +>'a' : "a" +>'b' : "b" >pair : (x: T) => (y: S) => { x: T; y: S; } var i = result[0].x; // number @@ -46,6 +46,6 @@ var i = result[0].x; // number >result[0].x : number >result[0] : { x: number; y: {}; } >result : { x: number; y: {}; }[] ->0 : number +>0 : 0 >x : number diff --git a/tests/baselines/reference/inferentialTypingWithObjectLiteralProperties.errors.txt b/tests/baselines/reference/inferentialTypingWithObjectLiteralProperties.errors.txt index 9dfb41c0fac..69f21589670 100644 --- a/tests/baselines/reference/inferentialTypingWithObjectLiteralProperties.errors.txt +++ b/tests/baselines/reference/inferentialTypingWithObjectLiteralProperties.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/inferentialTypingWithObjectLiteralProperties.ts(4,1): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/compiler/inferentialTypingWithObjectLiteralProperties.ts(5,1): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/inferentialTypingWithObjectLiteralProperties.ts(4,1): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/compiler/inferentialTypingWithObjectLiteralProperties.ts(5,1): error TS2322: Type '""' is not assignable to type 'number'. ==== tests/cases/compiler/inferentialTypingWithObjectLiteralProperties.ts (2 errors) ==== @@ -8,8 +8,8 @@ tests/cases/compiler/inferentialTypingWithObjectLiteralProperties.ts(5,1): error } f({ x: [null] }, { x: [1] }).x[0] = "" // ok ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. f({ x: [1] }, { x: [null] }).x[0] = "" // was error TS2011: Cannot convert 'string' to 'number'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.types b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.types index 9c1d4aa31b0..3775ffd2faa 100644 --- a/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.types +++ b/tests/baselines/reference/inferredFunctionReturnTypeIsEmptyType.types @@ -1,17 +1,17 @@ === tests/cases/compiler/inferredFunctionReturnTypeIsEmptyType.ts === function foo() { ->foo : () => string | number +>foo : () => 42 | "42" if (true) { ->true : boolean +>true : true return 42; ->42 : number +>42 : 42 } else { return "42"; ->"42" : string +>"42" : "42" } }; diff --git a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.types b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.types index 3f170d1a6ec..444c9b77069 100644 --- a/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.types +++ b/tests/baselines/reference/inheritanceMemberFuncOverridingMethod.types @@ -6,7 +6,7 @@ class a { >x : () => string return "10"; ->"10" : string +>"10" : "10" } } @@ -18,6 +18,6 @@ class b extends a { >x : () => string return "20"; ->"20" : string +>"20" : "20" } } diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.types b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.types index 22fa0a6660f..5a1320cd666 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.types +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingMethod.types @@ -6,7 +6,7 @@ class a { >x : () => string return "10"; ->"10" : string +>"10" : "10" } } @@ -18,6 +18,6 @@ class b extends a { >x : () => string return "20"; ->"20" : string +>"20" : "20" } } diff --git a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.types b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.types index a7df20382ec..3b6741770a4 100644 --- a/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.types +++ b/tests/baselines/reference/inheritanceStaticFuncOverridingPropertyOfFuncType.types @@ -14,6 +14,6 @@ class b extends a { >x : () => string return "20"; ->"20" : string +>"20" : "20" } } diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams.errors.txt b/tests/baselines/reference/inheritedConstructorWithRestParams.errors.txt index fd63eafbaf7..5e9775b81d9 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams.errors.txt +++ b/tests/baselines/reference/inheritedConstructorWithRestParams.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/inheritedConstructorWithRestParams.ts(13,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/compiler/inheritedConstructorWithRestParams.ts(14,13): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/inheritedConstructorWithRestParams.ts(13,17): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. +tests/cases/compiler/inheritedConstructorWithRestParams.ts(14,13): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/inheritedConstructorWithRestParams.ts (2 errors) ==== @@ -17,7 +17,7 @@ tests/cases/compiler/inheritedConstructorWithRestParams.ts(14,13): error TS2345: // Errors new Derived("", 3); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. new Derived(3); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/inheritedConstructorWithRestParams2.errors.txt b/tests/baselines/reference/inheritedConstructorWithRestParams2.errors.txt index 514d0d8941f..9249e9512bc 100644 --- a/tests/baselines/reference/inheritedConstructorWithRestParams2.errors.txt +++ b/tests/baselines/reference/inheritedConstructorWithRestParams2.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/inheritedConstructorWithRestParams2.ts(32,13): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/compiler/inheritedConstructorWithRestParams2.ts(33,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/compiler/inheritedConstructorWithRestParams2.ts(34,17): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/inheritedConstructorWithRestParams2.ts(32,13): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. +tests/cases/compiler/inheritedConstructorWithRestParams2.ts(33,17): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. +tests/cases/compiler/inheritedConstructorWithRestParams2.ts(34,17): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/inheritedConstructorWithRestParams2.ts (3 errors) ==== @@ -37,10 +37,10 @@ tests/cases/compiler/inheritedConstructorWithRestParams2.ts(34,17): error TS2345 // Errors new Derived(3); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. new Derived("", 3, "", 3); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. new Derived("", 3, "", ""); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/inheritedFunctionAssignmentCompatibility.types b/tests/baselines/reference/inheritedFunctionAssignmentCompatibility.types index b13fde1189a..ce918d27e9f 100644 --- a/tests/baselines/reference/inheritedFunctionAssignmentCompatibility.types +++ b/tests/baselines/reference/inheritedFunctionAssignmentCompatibility.types @@ -14,7 +14,7 @@ fn((a, b) => true); >(a, b) => true : (a: any, b: any) => boolean >a : any >b : any ->true : boolean +>true : true fn(function (a, b) { return true; }) >fn(function (a, b) { return true; }) : void @@ -22,6 +22,6 @@ fn(function (a, b) { return true; }) >function (a, b) { return true; } : (a: any, b: any) => boolean >a : any >b : any ->true : boolean +>true : true diff --git a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types index 563cb58a755..d15aab73b04 100644 --- a/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types +++ b/tests/baselines/reference/inheritedOverloadedSpecializedSignatures.types @@ -26,7 +26,7 @@ b('foo').charAt(0); >b : B >'foo' : "foo" >charAt : (pos: number) => string ->0 : number +>0 : 0 interface A { >A : A @@ -118,7 +118,7 @@ var x5: void = c('A0'); >x5 : void >c('A0') : void >c : C ->'A0' : string +>'A0' : "A0" var x6: number[] = c('C1'); >x6 : number[] @@ -142,5 +142,5 @@ var x9: void = c('generic'); >x9 : void >c('generic') : void >c : C ->'generic' : string +>'generic' : "generic" diff --git a/tests/baselines/reference/initializePropertiesWithRenamedLet.types b/tests/baselines/reference/initializePropertiesWithRenamedLet.types index 3c6938cd643..65ea68059a7 100644 --- a/tests/baselines/reference/initializePropertiesWithRenamedLet.types +++ b/tests/baselines/reference/initializePropertiesWithRenamedLet.types @@ -4,7 +4,7 @@ var x0; >x0 : any if (true) { ->true : boolean +>true : true let x0; >x0 : any @@ -27,20 +27,20 @@ var x, y, z; >z : any if (true) { ->true : boolean +>true : true let { x: x } = { x: 0 }; >x : any >x : number >{ x: 0 } : { x: number; } >x : number ->0 : number +>0 : 0 let { y } = { y: 0 }; >y : number >{ y: 0 } : { y: number; } >y : number ->0 : number +>0 : 0 let z; >z : any @@ -53,7 +53,7 @@ if (true) { >z : any >{ z: 0 } : { z: number; } >z : number ->0 : number +>0 : 0 ({ z } = { z: 0 }); >({ z } = { z: 0 }) : { z: number; } @@ -62,5 +62,5 @@ if (true) { >z : any >{ z: 0 } : { z: number; } >z : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/initializersInAmbientEnums.types b/tests/baselines/reference/initializersInAmbientEnums.types index 40996e9b40a..042ddbc50c9 100644 --- a/tests/baselines/reference/initializersInAmbientEnums.types +++ b/tests/baselines/reference/initializersInAmbientEnums.types @@ -4,7 +4,7 @@ declare enum E { a = 10, >a : E ->10 : number +>10 : 10 b = a, >b : E @@ -13,8 +13,8 @@ declare enum E { e = 10 << 2 * 8, >e : E >10 << 2 * 8 : number ->10 : number +>10 : 10 >2 * 8 : number ->2 : number ->8 : number +>2 : 2 +>8 : 8 } diff --git a/tests/baselines/reference/initializersWidened.types b/tests/baselines/reference/initializersWidened.types index 766f859029a..17de14e9e94 100644 --- a/tests/baselines/reference/initializersWidened.types +++ b/tests/baselines/reference/initializersWidened.types @@ -12,7 +12,7 @@ var y1 = undefined; var z1 = void 0; >z1 : any >void 0 : undefined ->0 : number +>0 : 0 // these are not widened @@ -35,7 +35,7 @@ var y3: undefined = undefined; var z3: undefined = void 0; >z3 : undefined >void 0 : undefined ->0 : number +>0 : 0 // widen only when all constituents of union are widening @@ -55,9 +55,9 @@ var z4 = void 0 || void 0; >z4 : any >void 0 || void 0 : undefined >void 0 : undefined ->0 : number +>0 : 0 >void 0 : undefined ->0 : number +>0 : 0 var x5 = null || x2; >x5 : null @@ -75,6 +75,6 @@ var z5 = void 0 || y2; >z5 : undefined >void 0 || y2 : undefined >void 0 : undefined ->0 : number +>0 : 0 >y2 : undefined diff --git a/tests/baselines/reference/innerFunc.types b/tests/baselines/reference/innerFunc.types index 48d98ae42e1..700ca630233 100644 --- a/tests/baselines/reference/innerFunc.types +++ b/tests/baselines/reference/innerFunc.types @@ -4,7 +4,7 @@ function salt() { function pepper() { return 5;} >pepper : () => number ->5 : number +>5 : 5 return pepper(); >pepper() : number @@ -19,7 +19,7 @@ module M { function oxygen() { return 6; }; >oxygen : () => number ->6 : number +>6 : 6 return oxygen(); >oxygen() : number diff --git a/tests/baselines/reference/innerOverloads.types b/tests/baselines/reference/innerOverloads.types index 68af57b3bea..b15f9e5bf22 100644 --- a/tests/baselines/reference/innerOverloads.types +++ b/tests/baselines/reference/innerOverloads.types @@ -19,7 +19,7 @@ function outer() { return inner(0); >inner(0) : any >inner : { (x: number): any; (x: string): any; } ->0 : number +>0 : 0 } var x = outer(); // should work diff --git a/tests/baselines/reference/innerTypeCheckOfLambdaArgument.errors.txt b/tests/baselines/reference/innerTypeCheckOfLambdaArgument.errors.txt index b5e56d2f4e3..0e0bcde70de 100644 --- a/tests/baselines/reference/innerTypeCheckOfLambdaArgument.errors.txt +++ b/tests/baselines/reference/innerTypeCheckOfLambdaArgument.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/innerTypeCheckOfLambdaArgument.ts(10,7): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/innerTypeCheckOfLambdaArgument.ts(10,7): error TS2322: Type '10' is not assignable to type 'string'. ==== tests/cases/compiler/innerTypeCheckOfLambdaArgument.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/innerTypeCheckOfLambdaArgument.ts(10,7): error TS2322: Type // otherwise, there's a bug in overload resolution / partial typechecking var k: string = 10; ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '10' is not assignable to type 'string'. } ); \ No newline at end of file diff --git a/tests/baselines/reference/instanceAndStaticDeclarations1.types b/tests/baselines/reference/instanceAndStaticDeclarations1.types index cbed990690d..91bd5e7eb52 100644 --- a/tests/baselines/reference/instanceAndStaticDeclarations1.types +++ b/tests/baselines/reference/instanceAndStaticDeclarations1.types @@ -50,8 +50,8 @@ class Point { >origin : Point >new Point(0, 0) : Point >Point : typeof Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 static distance(p1: Point, p2: Point) { return p1.distance(p2); } >distance : (p1: Point, p2: Point) => number diff --git a/tests/baselines/reference/instanceMemberInitialization.types b/tests/baselines/reference/instanceMemberInitialization.types index 4d65c62aa49..ca97ccac333 100644 --- a/tests/baselines/reference/instanceMemberInitialization.types +++ b/tests/baselines/reference/instanceMemberInitialization.types @@ -4,7 +4,7 @@ class C { x = 1; >x : number ->1 : number +>1 : 1 } var c = new C(); @@ -13,11 +13,11 @@ var c = new C(); >C : typeof C c.x = 3; ->c.x = 3 : number +>c.x = 3 : 3 >c.x : number >c : C >x : number ->3 : number +>3 : 3 var c2 = new C(); >c2 : C diff --git a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types index d98a6025796..e9048af2e34 100644 --- a/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types +++ b/tests/baselines/reference/instanceofWithStructurallyIdenticalTypes.types @@ -40,7 +40,7 @@ function foo1(x: C1 | C2 | C3): string { >x.item : string[] >x : C2 >item : string[] ->0 : number +>0 : 0 } else if (x instanceof C3) { >x instanceof C3 : boolean @@ -53,7 +53,7 @@ function foo1(x: C1 | C2 | C3): string { >item : string } return "error"; ->"error" : string +>"error" : "error" } function isC1(c: C1 | C2 | C3): c is C1 { return c instanceof C1 } @@ -119,7 +119,7 @@ function foo2(x: C1 | C2 | C3): string { >x.item : string[] >x : C2 >item : string[] ->0 : number +>0 : 0 } else if (isC3(x)) { >isC3(x) : boolean @@ -132,7 +132,7 @@ function foo2(x: C1 | C2 | C3): string { >item : string } return "error"; ->"error" : string +>"error" : "error" } // More tests diff --git a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types index 5cdce6b99fe..11be8be8252 100644 --- a/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types +++ b/tests/baselines/reference/instantiateContextuallyTypedGenericThis.types @@ -42,12 +42,12 @@ $.each(lines, function(dit) { >dit.charAt : (pos: number) => string >dit : string >charAt : (pos: number) => string ->0 : number +>0 : 0 >this.charAt(1) : string >this.charAt : (pos: number) => string >this : string >charAt : (pos: number) => string ->1 : number +>1 : 1 }); diff --git a/tests/baselines/reference/instantiateCrossFileMerge.types b/tests/baselines/reference/instantiateCrossFileMerge.types index 8fbeaab3d1f..2da25e6b138 100644 --- a/tests/baselines/reference/instantiateCrossFileMerge.types +++ b/tests/baselines/reference/instantiateCrossFileMerge.types @@ -22,5 +22,5 @@ new P(r => { r('foo') }); >r : (value: string) => void >r('foo') : void >r : (value: string) => void ->'foo' : string +>'foo' : "foo" diff --git a/tests/baselines/reference/instantiatedModule.types b/tests/baselines/reference/instantiatedModule.types index 743c6561161..b7072d6bb73 100644 --- a/tests/baselines/reference/instantiatedModule.types +++ b/tests/baselines/reference/instantiatedModule.types @@ -11,7 +11,7 @@ module M { export var Point = 1; >Point : number ->1 : number +>1 : 1 } // primary expression @@ -69,9 +69,9 @@ module M2 { return { x: 0, y: 0 }; >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } } } @@ -141,8 +141,8 @@ module M3 { export enum Color { Blue, Red } >Color : Color ->Blue : Color ->Red : Color +>Blue : Color.Blue +>Red : Color.Red } var m3: typeof M3; @@ -186,17 +186,17 @@ var p3: M3.Color; var p3 = M3.Color.Red; >p3 : M3.Color ->M3.Color.Red : M3.Color +>M3.Color.Red : M3.Color.Red >M3.Color : typeof M3.Color >M3 : typeof M3 >Color : typeof M3.Color ->Red : M3.Color +>Red : M3.Color.Red var p3 = m3.Color.Blue; >p3 : M3.Color ->m3.Color.Blue : M3.Color +>m3.Color.Blue : M3.Color.Blue >m3.Color : typeof M3.Color >m3 : typeof M3 >Color : typeof M3.Color ->Blue : M3.Color +>Blue : M3.Color.Blue diff --git a/tests/baselines/reference/interface0.types b/tests/baselines/reference/interface0.types index 8fd04eea83c..9a70cf066b1 100644 --- a/tests/baselines/reference/interface0.types +++ b/tests/baselines/reference/interface0.types @@ -13,5 +13,5 @@ var y: Generic = { x: 3 }; >Generic : Generic >{ x: 3 } : { x: number; } >x : number ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/interfaceClassMerging.types b/tests/baselines/reference/interfaceClassMerging.types index 0b17005c868..60712d226a4 100644 --- a/tests/baselines/reference/interfaceClassMerging.types +++ b/tests/baselines/reference/interfaceClassMerging.types @@ -32,7 +32,7 @@ class Foo { >this.method : (a: number) => string >this : this >method : (a: number) => string ->0 : number +>0 : 0 } } @@ -62,14 +62,14 @@ bar.method(0); >bar.method : (a: number) => string >bar : Bar >method : (a: number) => string ->0 : number +>0 : 0 bar.optionalMethod(1); >bar.optionalMethod(1) : string >bar.optionalMethod : (a: number) => string >bar : Bar >optionalMethod : (a: number) => string ->1 : number +>1 : 1 bar.property; >bar.property : string @@ -91,7 +91,7 @@ bar.additionalMethod(2); >bar.additionalMethod : (a: number) => string >bar : Bar >additionalMethod : (a: number) => string ->2 : number +>2 : 2 var obj: { >obj : { method(a: number): string; property: string; additionalProperty: string; additionalMethod(a: number): string; } diff --git a/tests/baselines/reference/interfaceContextualType.types b/tests/baselines/reference/interfaceContextualType.types index d1ff4021c5d..65dda5b737f 100644 --- a/tests/baselines/reference/interfaceContextualType.types +++ b/tests/baselines/reference/interfaceContextualType.types @@ -39,9 +39,9 @@ class Bug { >this.values : IMap >this : this >values : IMap ->'comments' : string +>'comments' : "comments" >{ italic: true } : { italic: true; } ->italic : true +>italic : boolean >true : true } shouldBeOK() { @@ -57,7 +57,7 @@ class Bug { comments: { italic: true } >comments : { italic: true; } >{ italic: true } : { italic: true; } ->italic : true +>italic : boolean >true : true }; diff --git a/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types b/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types index 65a7ec60168..4f60c5d36cc 100644 --- a/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types +++ b/tests/baselines/reference/interfaceDoesNotDependOnBaseTypes.types @@ -14,7 +14,7 @@ if (typeof x !== "string") { >x.push : (...items: StringTree[]) => number >x : StringTreeArray >push : (...items: StringTree[]) => number ->"" : string +>"" : "" x.push([""]); >x.push([""]) : number @@ -22,7 +22,7 @@ if (typeof x !== "string") { >x : StringTreeArray >push : (...items: StringTree[]) => number >[""] : string[] ->"" : string +>"" : "" } type StringTree = string | StringTreeArray; diff --git a/tests/baselines/reference/interfaceSubtyping.types b/tests/baselines/reference/interfaceSubtyping.types index 26a900a56b2..07c0d6446b5 100644 --- a/tests/baselines/reference/interfaceSubtyping.types +++ b/tests/baselines/reference/interfaceSubtyping.types @@ -14,6 +14,6 @@ class Camera implements iface{ } foo() { return "s"; } >foo : () => string ->"s" : string +>"s" : "s" } diff --git a/tests/baselines/reference/interfaceWithOverloadedCallAndConstructSignatures.types b/tests/baselines/reference/interfaceWithOverloadedCallAndConstructSignatures.types index 1110992fd52..755514680d2 100644 --- a/tests/baselines/reference/interfaceWithOverloadedCallAndConstructSignatures.types +++ b/tests/baselines/reference/interfaceWithOverloadedCallAndConstructSignatures.types @@ -25,7 +25,7 @@ var r2 = f(''); >r2 : number >f('') : number >f : Foo ->'' : string +>'' : "" var r3 = new f(); >r3 : any @@ -36,5 +36,5 @@ var r4 = new f(''); >r4 : Object >new f('') : Object >f : Foo ->'' : string +>'' : "" diff --git a/tests/baselines/reference/interfaceWithPropertyOfEveryType.types b/tests/baselines/reference/interfaceWithPropertyOfEveryType.types index 0ad754476a2..533bc070702 100644 --- a/tests/baselines/reference/interfaceWithPropertyOfEveryType.types +++ b/tests/baselines/reference/interfaceWithPropertyOfEveryType.types @@ -11,7 +11,7 @@ module M { export var y = 1; >y : number ->1 : number +>1 : 1 } enum E { A } >E : E @@ -80,18 +80,18 @@ interface Foo { var a: Foo = { >a : Foo >Foo : Foo ->{ a: 1, b: '', c: true, d: {}, e: null , f: [1], g: {}, h: (x: number) => 1, i: (x: T) => x, j: null, k: new C(), l: f1, m: M, n: {}, o: E.A} : { a: number; b: string; c: true; d: {}; e: null; f: number[]; g: {}; h: (x: number) => number; i: (x: T) => T; j: Foo; k: C; l: () => void; m: typeof M; n: {}; o: E; } +>{ a: 1, b: '', c: true, d: {}, e: null , f: [1], g: {}, h: (x: number) => 1, i: (x: T) => x, j: null, k: new C(), l: f1, m: M, n: {}, o: E.A} : { a: number; b: string; c: true; d: {}; e: null; f: number[]; g: {}; h: (x: number) => 1; i: (x: T) => T; j: Foo; k: C; l: () => void; m: typeof M; n: {}; o: E; } a: 1, >a : number ->1 : number +>1 : 1 b: '', >b : string ->'' : string +>'' : "" c: true, ->c : true +>c : boolean >true : true d: {}, @@ -105,17 +105,17 @@ var a: Foo = { f: [1], >f : number[] >[1] : number[] ->1 : number +>1 : 1 g: {}, >g : {} >{} : {} h: (x: number) => 1, ->h : (x: number) => number ->(x: number) => 1 : (x: number) => number +>h : (x: number) => 1 +>(x: number) => 1 : (x: number) => 1 >x : number ->1 : number +>1 : 1 i: (x: T) => x, >i : (x: T) => T diff --git a/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types b/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types index 5288d9f15a4..b6c658e10dc 100644 --- a/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types +++ b/tests/baselines/reference/interfaceWithSpecializedCallAndConstructSignatures.types @@ -30,7 +30,7 @@ var r2 = f('A'); >r2 : any >f('A') : any >f : Foo ->'A' : string +>'A' : "A" var r3 = new f('a'); >r3 : any @@ -42,5 +42,5 @@ var r4 = new f('A'); >r4 : Object >new f('A') : Object >f : Foo ->'A' : string +>'A' : "A" diff --git a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithExport.types b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithExport.types index 58afd2071fe..155f035c6c7 100644 --- a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithExport.types +++ b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithExport.types @@ -37,7 +37,7 @@ export module m2 { >cProp.foo : (a: number) => number >cProp : c >foo : (a: number) => number ->10 : number +>10 : 10 } } diff --git a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExport.types b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExport.types index 43f612d3f44..6a0ee6fa986 100644 --- a/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExport.types +++ b/tests/baselines/reference/internalAliasClassInsideLocalModuleWithoutExport.types @@ -37,6 +37,6 @@ export module m2 { >cProp.foo : (a: number) => number >cProp : c >foo : (a: number) => number ->10 : number +>10 : 10 } } diff --git a/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithExport.types b/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithExport.types index 3d72c04aad6..407d0602de6 100644 --- a/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithExport.types +++ b/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithExport.types @@ -31,5 +31,5 @@ var cReturnVal = cProp.foo(10); >cProp.foo : (a: number) => number >cProp : xc >foo : (a: number) => number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithoutExport.types b/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithoutExport.types index f816fdce7af..405232d72b7 100644 --- a/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithoutExport.types +++ b/tests/baselines/reference/internalAliasClassInsideTopLevelModuleWithoutExport.types @@ -31,5 +31,5 @@ var cReturnVal = cProp.foo(10); >cProp.foo : (a: number) => number >cProp : xc >foo : (a: number) => number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/internalAliasEnum.types b/tests/baselines/reference/internalAliasEnum.types index 3f86d63c879..0465dbc8841 100644 --- a/tests/baselines/reference/internalAliasEnum.types +++ b/tests/baselines/reference/internalAliasEnum.types @@ -6,13 +6,13 @@ module a { >weekend : weekend Friday, ->Friday : weekend +>Friday : weekend.Friday Saturday, ->Saturday : weekend +>Saturday : weekend.Saturday Sunday ->Sunday : weekend +>Sunday : weekend.Sunday } } diff --git a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.types b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.types index 66d946e47b3..e35e5db5b47 100644 --- a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.types +++ b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithExport.types @@ -6,13 +6,13 @@ export module a { >weekend : weekend Friday, ->Friday : weekend +>Friday : weekend.Friday Saturday, ->Saturday : weekend +>Saturday : weekend.Saturday Sunday ->Sunday : weekend +>Sunday : weekend.Sunday } } diff --git a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.types b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.types index f53a6fa355b..f063bb24352 100644 --- a/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.types +++ b/tests/baselines/reference/internalAliasEnumInsideLocalModuleWithoutExport.types @@ -6,13 +6,13 @@ export module a { >weekend : weekend Friday, ->Friday : weekend +>Friday : weekend.Friday Saturday, ->Saturday : weekend +>Saturday : weekend.Saturday Sunday ->Sunday : weekend +>Sunday : weekend.Sunday } } diff --git a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.types b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.types index 437e211bf16..f49f4c74215 100644 --- a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.types +++ b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithExport.types @@ -6,13 +6,13 @@ export module a { >weekend : weekend Friday, ->Friday : weekend +>Friday : weekend.Friday Saturday, ->Saturday : weekend +>Saturday : weekend.Saturday Sunday ->Sunday : weekend +>Sunday : weekend.Sunday } } diff --git a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.types b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.types index c9b75f84266..209dba7aed1 100644 --- a/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.types +++ b/tests/baselines/reference/internalAliasEnumInsideTopLevelModuleWithoutExport.types @@ -6,13 +6,13 @@ export module a { >weekend : weekend Friday, ->Friday : weekend +>Friday : weekend.Friday Saturday, ->Saturday : weekend +>Saturday : weekend.Saturday Sunday ->Sunday : weekend +>Sunday : weekend.Sunday } } diff --git a/tests/baselines/reference/internalAliasFunction.types b/tests/baselines/reference/internalAliasFunction.types index d67535c76f7..92e0fd11aa8 100644 --- a/tests/baselines/reference/internalAliasFunction.types +++ b/tests/baselines/reference/internalAliasFunction.types @@ -23,7 +23,7 @@ module c { >bVal : number >b(10) : number >b : (x: number) => number ->10 : number +>10 : 10 export var bVal2 = b; >bVal2 : (x: number) => number diff --git a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithExport.types b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithExport.types index 928d8530228..275d7467ca5 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithExport.types +++ b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithExport.types @@ -23,7 +23,7 @@ export module c { >bVal : number >b(10) : number >b : (x: number) => number ->10 : number +>10 : 10 export var bVal2 = b; >bVal2 : (x: number) => number diff --git a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExport.types b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExport.types index 630be11c71e..45e72ff89c5 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExport.types +++ b/tests/baselines/reference/internalAliasFunctionInsideLocalModuleWithoutExport.types @@ -23,7 +23,7 @@ export module c { >bVal : number >b(10) : number >b : (x: number) => number ->10 : number +>10 : 10 export var bVal2 = b; >bVal2 : (x: number) => number diff --git a/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithExport.types b/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithExport.types index c1e9f9af3d7..078b595651d 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithExport.types +++ b/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithExport.types @@ -20,7 +20,7 @@ export var bVal = b(10); >bVal : number >b(10) : number >b : (x: number) => number ->10 : number +>10 : 10 export var bVal2 = b; >bVal2 : (x: number) => number diff --git a/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithoutExport.types b/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithoutExport.types index bca35e33dec..2bab16ff814 100644 --- a/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithoutExport.types +++ b/tests/baselines/reference/internalAliasFunctionInsideTopLevelModuleWithoutExport.types @@ -20,7 +20,7 @@ export var bVal = b(10); >bVal : number >b(10) : number >b : (x: number) => number ->10 : number +>10 : 10 export var bVal2 = b; >bVal2 : (x: number) => number diff --git a/tests/baselines/reference/internalAliasVar.types b/tests/baselines/reference/internalAliasVar.types index 59da851b569..40897b403f0 100644 --- a/tests/baselines/reference/internalAliasVar.types +++ b/tests/baselines/reference/internalAliasVar.types @@ -4,7 +4,7 @@ module a { export var x = 10; >x : number ->10 : number +>10 : 10 } module c { diff --git a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithExport.types b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithExport.types index 995c24bc382..5527b00e47e 100644 --- a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithExport.types +++ b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithExport.types @@ -4,7 +4,7 @@ export module a { export var x = 10; >x : number ->10 : number +>10 : 10 } export module c { diff --git a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExport.types b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExport.types index 5e322f8483c..fe8f6fb54ea 100644 --- a/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExport.types +++ b/tests/baselines/reference/internalAliasVarInsideLocalModuleWithoutExport.types @@ -4,7 +4,7 @@ export module a { export var x = 10; >x : number ->10 : number +>10 : 10 } export module c { diff --git a/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithExport.types b/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithExport.types index 199de9cae51..41245f5b05e 100644 --- a/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithExport.types +++ b/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithExport.types @@ -4,7 +4,7 @@ export module a { export var x = 10; >x : number ->10 : number +>10 : 10 } export import b = a.x; diff --git a/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithoutExport.types b/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithoutExport.types index d7a7309ccb4..e05e20108b2 100644 --- a/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithoutExport.types +++ b/tests/baselines/reference/internalAliasVarInsideTopLevelModuleWithoutExport.types @@ -4,7 +4,7 @@ export module a { export var x = 10; >x : number ->10 : number +>10 : 10 } import b = a.x; diff --git a/tests/baselines/reference/internalImportInstantiatedModuleMergedWithClassNotReferencingInstanceNoConflict.types b/tests/baselines/reference/internalImportInstantiatedModuleMergedWithClassNotReferencingInstanceNoConflict.types index e0548f1f867..f7949e5a3fe 100644 --- a/tests/baselines/reference/internalImportInstantiatedModuleMergedWithClassNotReferencingInstanceNoConflict.types +++ b/tests/baselines/reference/internalImportInstantiatedModuleMergedWithClassNotReferencingInstanceNoConflict.types @@ -14,7 +14,7 @@ module A { export var a = 10; >a : number ->10 : number +>10 : 10 } module B { diff --git a/tests/baselines/reference/internalImportUnInstantiatedModuleNotReferencingInstanceNoConflict.types b/tests/baselines/reference/internalImportUnInstantiatedModuleNotReferencingInstanceNoConflict.types index 1226ca3cbc4..856b61b66d7 100644 --- a/tests/baselines/reference/internalImportUnInstantiatedModuleNotReferencingInstanceNoConflict.types +++ b/tests/baselines/reference/internalImportUnInstantiatedModuleNotReferencingInstanceNoConflict.types @@ -12,7 +12,7 @@ module B { var A = 1; >A : number ->1 : number +>1 : 1 import Y = A; >Y : any diff --git a/tests/baselines/reference/intersectionTypeInference1.types b/tests/baselines/reference/intersectionTypeInference1.types index b74b2d2a453..9417f633361 100644 --- a/tests/baselines/reference/intersectionTypeInference1.types +++ b/tests/baselines/reference/intersectionTypeInference1.types @@ -37,5 +37,5 @@ export const Form3 = brokenFunction(parameterFn)({store: "hello"}) >parameterFn : (props: { store: string; }) => void >{store: "hello"} : { store: string; } >store : string ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/intersectionTypeMembers.types b/tests/baselines/reference/intersectionTypeMembers.types index 6c3217698b8..4d1da7eab73 100644 --- a/tests/baselines/reference/intersectionTypeMembers.types +++ b/tests/baselines/reference/intersectionTypeMembers.types @@ -21,25 +21,25 @@ var abc: A & B & C; >C : C abc.a = "hello"; ->abc.a = "hello" : string +>abc.a = "hello" : "hello" >abc.a : string >abc : A & B & C >a : string ->"hello" : string +>"hello" : "hello" abc.b = "hello"; ->abc.b = "hello" : string +>abc.b = "hello" : "hello" >abc.b : string >abc : A & B & C >b : string ->"hello" : string +>"hello" : "hello" abc.c = "hello"; ->abc.c = "hello" : string +>abc.c = "hello" : "hello" >abc.c : string >abc : A & B & C >c : string ->"hello" : string +>"hello" : "hello" interface X { x: A } >X : X @@ -63,31 +63,31 @@ var xyz: X & Y & Z; >Z : Z xyz.x.a = "hello"; ->xyz.x.a = "hello" : string +>xyz.x.a = "hello" : "hello" >xyz.x.a : string >xyz.x : A & B & C >xyz : X & Y & Z >x : A & B & C >a : string ->"hello" : string +>"hello" : "hello" xyz.x.b = "hello"; ->xyz.x.b = "hello" : string +>xyz.x.b = "hello" : "hello" >xyz.x.b : string >xyz.x : A & B & C >xyz : X & Y & Z >x : A & B & C >b : string ->"hello" : string +>"hello" : "hello" xyz.x.c = "hello"; ->xyz.x.c = "hello" : string +>xyz.x.c = "hello" : "hello" >xyz.x.c : string >xyz.x : A & B & C >xyz : X & Y & Z >x : A & B & C >c : string ->"hello" : string +>"hello" : "hello" type F1 = (x: string) => string; >F1 : F1 @@ -106,13 +106,13 @@ var s = f("hello"); >s : string >f("hello") : string >f : F1 & F2 ->"hello" : string +>"hello" : "hello" var n = f(42); >n : number >f(42) : number >f : F1 & F2 ->42 : number +>42 : 42 interface D { >D : D @@ -150,24 +150,24 @@ const de: D & E = { d: 'yes', >d : string ->'yes' : string +>'yes' : "yes" f: 'no' >f : string ->'no' : string +>'no' : "no" }, different: { e: 12 }, >different : { e: number; } >{ e: 12 } : { e: number; } >e : number ->12 : number +>12 : 12 other: { g: 101 } >other : { g: number; } >{ g: 101 } : { g: number; } >g : number ->101 : number +>101 : 101 } } diff --git a/tests/baselines/reference/intersectionTypeOverloading.types b/tests/baselines/reference/intersectionTypeOverloading.types index f301ef6e4b7..8afa23ecb29 100644 --- a/tests/baselines/reference/intersectionTypeOverloading.types +++ b/tests/baselines/reference/intersectionTypeOverloading.types @@ -24,7 +24,7 @@ var x = fg("abc"); >x : string >fg("abc") : string >fg : F & G ->"abc" : string +>"abc" : "abc" var x: string; >x : string @@ -33,7 +33,7 @@ var y = gf("abc"); >y : any >gf("abc") : any >gf : G & F ->"abc" : string +>"abc" : "abc" var y: any; >y : any diff --git a/tests/baselines/reference/invalidAssignmentsToVoid.errors.txt b/tests/baselines/reference/invalidAssignmentsToVoid.errors.txt index 3ac4f122e58..4b9b316e010 100644 --- a/tests/baselines/reference/invalidAssignmentsToVoid.errors.txt +++ b/tests/baselines/reference/invalidAssignmentsToVoid.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(2,1): error TS2322: Type 'number' is not assignable to type 'void'. -tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(3,1): error TS2322: Type 'boolean' is not assignable to type 'void'. -tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(4,1): error TS2322: Type 'string' is not assignable to type 'void'. +tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(2,1): error TS2322: Type '1' is not assignable to type 'void'. +tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(3,1): error TS2322: Type 'true' is not assignable to type 'void'. +tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(4,1): error TS2322: Type '""' is not assignable to type 'void'. tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(5,1): error TS2322: Type '{}' is not assignable to type 'void'. tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(9,1): error TS2322: Type 'typeof C' is not assignable to type 'void'. tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(10,1): error TS2322: Type 'C' is not assignable to type 'void'. @@ -14,13 +14,13 @@ tests/cases/conformance/types/primitives/void/invalidAssignmentsToVoid.ts(22,1): var x: void; x = 1; ~ -!!! error TS2322: Type 'number' is not assignable to type 'void'. +!!! error TS2322: Type '1' is not assignable to type 'void'. x = true; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'void'. +!!! error TS2322: Type 'true' is not assignable to type 'void'. x = ''; ~ -!!! error TS2322: Type 'string' is not assignable to type 'void'. +!!! error TS2322: Type '""' is not assignable to type 'void'. x = {} ~ !!! error TS2322: Type '{}' is not assignable to type 'void'. diff --git a/tests/baselines/reference/invalidBooleanAssignments.errors.txt b/tests/baselines/reference/invalidBooleanAssignments.errors.txt index 99d32aff9bc..7963197a003 100644 --- a/tests/baselines/reference/invalidBooleanAssignments.errors.txt +++ b/tests/baselines/reference/invalidBooleanAssignments.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(3,5): error TS2322: Type 'boolean' is not assignable to type 'number'. -tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(4,5): error TS2322: Type 'boolean' is not assignable to type 'string'. -tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(5,5): error TS2322: Type 'boolean' is not assignable to type 'void'. -tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(9,5): error TS2322: Type 'boolean' is not assignable to type 'E'. -tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(12,5): error TS2322: Type 'boolean' is not assignable to type 'C'. -tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(15,5): error TS2322: Type 'boolean' is not assignable to type 'I'. -tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(17,5): error TS2322: Type 'boolean' is not assignable to type '() => string'. +tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(3,5): error TS2322: Type 'true' is not assignable to type 'number'. +tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(4,5): error TS2322: Type 'true' is not assignable to type 'string'. +tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(5,5): error TS2322: Type 'true' is not assignable to type 'void'. +tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(9,5): error TS2322: Type 'true' is not assignable to type 'E'. +tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(12,5): error TS2322: Type 'true' is not assignable to type 'C'. +tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(15,5): error TS2322: Type 'true' is not assignable to type 'I'. +tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(17,5): error TS2322: Type 'true' is not assignable to type '() => string'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(21,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(24,5): error TS2322: Type 'boolean' is not assignable to type 'T'. tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26,1): error TS2364: Invalid left-hand side of assignment expression. @@ -15,33 +15,33 @@ tests/cases/conformance/types/primitives/boolean/invalidBooleanAssignments.ts(26 var a: number = x; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'number'. +!!! error TS2322: Type 'true' is not assignable to type 'number'. var b: string = x; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. +!!! error TS2322: Type 'true' is not assignable to type 'string'. var c: void = x; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'void'. +!!! error TS2322: Type 'true' is not assignable to type 'void'. var d: typeof undefined = x; enum E { A } var e: E = x; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'E'. +!!! error TS2322: Type 'true' is not assignable to type 'E'. class C { foo: string } var f: C = x; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'C'. +!!! error TS2322: Type 'true' is not assignable to type 'C'. interface I { bar: string } var g: I = x; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'I'. +!!! error TS2322: Type 'true' is not assignable to type 'I'. var h: { (): string } = x; ~ -!!! error TS2322: Type 'boolean' is not assignable to type '() => string'. +!!! error TS2322: Type 'true' is not assignable to type '() => string'. var h2: { toString(): string } = x; // no error module M { export var a = 1; } diff --git a/tests/baselines/reference/invalidEnumAssignments.errors.txt b/tests/baselines/reference/invalidEnumAssignments.errors.txt index 962e4bf62d5..e769a829c97 100644 --- a/tests/baselines/reference/invalidEnumAssignments.errors.txt +++ b/tests/baselines/reference/invalidEnumAssignments.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(14,1): error TS2322: Type 'E2' is not assignable to type 'E'. -tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(15,1): error TS2322: Type 'E' is not assignable to type 'E2'. +tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(14,1): error TS2322: Type 'E2.A' is not assignable to type 'E'. +tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(15,1): error TS2322: Type 'E.A' is not assignable to type 'E2'. tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(16,1): error TS2322: Type 'void' is not assignable to type 'E'. tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(17,1): error TS2322: Type '{}' is not assignable to type 'E'. -tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(18,1): error TS2322: Type 'string' is not assignable to type 'E'. +tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(18,1): error TS2322: Type '""' is not assignable to type 'E'. tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(21,5): error TS2322: Type 'T' is not assignable to type 'E'. @@ -22,10 +22,10 @@ tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(21,5): e e = E2.A; ~ -!!! error TS2322: Type 'E2' is not assignable to type 'E'. +!!! error TS2322: Type 'E2.A' is not assignable to type 'E'. e2 = E.A; ~~ -!!! error TS2322: Type 'E' is not assignable to type 'E2'. +!!! error TS2322: Type 'E.A' is not assignable to type 'E2'. e = null; ~ !!! error TS2322: Type 'void' is not assignable to type 'E'. @@ -34,7 +34,7 @@ tests/cases/conformance/types/primitives/enum/invalidEnumAssignments.ts(21,5): e !!! error TS2322: Type '{}' is not assignable to type 'E'. e = ''; ~ -!!! error TS2322: Type 'string' is not assignable to type 'E'. +!!! error TS2322: Type '""' is not assignable to type 'E'. function f(a: T) { e = a; diff --git a/tests/baselines/reference/invalidNumberAssignments.errors.txt b/tests/baselines/reference/invalidNumberAssignments.errors.txt index fd8acaba032..23f308830ff 100644 --- a/tests/baselines/reference/invalidNumberAssignments.errors.txt +++ b/tests/baselines/reference/invalidNumberAssignments.errors.txt @@ -3,8 +3,8 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(4,5) tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(5,5): error TS2322: Type 'number' is not assignable to type 'void'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(9,5): error TS2322: Type 'number' is not assignable to type 'C'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(12,5): error TS2322: Type 'number' is not assignable to type 'I'. -tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. -tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. +tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(14,5): error TS2322: Type '1' is not assignable to type '{ baz: string; }'. +tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(15,5): error TS2322: Type '1' is not assignable to type '{ 0: number; }'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(21,5): error TS2322: Type 'number' is not assignable to type 'T'. tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. @@ -36,10 +36,10 @@ tests/cases/conformance/types/primitives/number/invalidNumberAssignments.ts(23,1 var g: { baz: string } = 1; ~ -!!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. +!!! error TS2322: Type '1' is not assignable to type '{ baz: string; }'. var g2: { 0: number } = 1; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. +!!! error TS2322: Type '1' is not assignable to type '{ 0: number; }'. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/invalidSplice.types b/tests/baselines/reference/invalidSplice.types index 1e3b42ff551..876846d3da9 100644 --- a/tests/baselines/reference/invalidSplice.types +++ b/tests/baselines/reference/invalidSplice.types @@ -5,8 +5,8 @@ var arr = [].splice(0,3,4,5); >[].splice : { (start: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } >[] : undefined[] >splice : { (start: number): any[]; (start: number, deleteCount: number, ...items: any[]): any[]; } ->0 : number ->3 : number ->4 : number ->5 : number +>0 : 0 +>3 : 3 +>4 : 4 +>5 : 5 diff --git a/tests/baselines/reference/invalidStringAssignments.errors.txt b/tests/baselines/reference/invalidStringAssignments.errors.txt index d7ac2134dc1..b37c56e8a40 100644 --- a/tests/baselines/reference/invalidStringAssignments.errors.txt +++ b/tests/baselines/reference/invalidStringAssignments.errors.txt @@ -3,8 +3,8 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(4,5) tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(5,5): error TS2322: Type 'string' is not assignable to type 'void'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(9,5): error TS2322: Type 'string' is not assignable to type 'C'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(12,5): error TS2322: Type 'string' is not assignable to type 'I'. -tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. -tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. +tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(14,5): error TS2322: Type '1' is not assignable to type '{ baz: string; }'. +tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(15,5): error TS2322: Type '1' is not assignable to type '{ 0: number; }'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(21,5): error TS2322: Type 'string' is not assignable to type 'T'. tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. @@ -37,10 +37,10 @@ tests/cases/conformance/types/primitives/string/invalidStringAssignments.ts(26,5 var g: { baz: string } = 1; ~ -!!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. +!!! error TS2322: Type '1' is not assignable to type '{ baz: string; }'. var g2: { 0: number } = 1; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. +!!! error TS2322: Type '1' is not assignable to type '{ 0: number; }'. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/invalidSwitchBreakStatement.errors.txt b/tests/baselines/reference/invalidSwitchBreakStatement.errors.txt new file mode 100644 index 00000000000..31715e3fc0b --- /dev/null +++ b/tests/baselines/reference/invalidSwitchBreakStatement.errors.txt @@ -0,0 +1,13 @@ +tests/cases/conformance/statements/breakStatements/invalidSwitchBreakStatement.ts(4,10): error TS2678: Type '5' is not comparable to type '12'. + + +==== tests/cases/conformance/statements/breakStatements/invalidSwitchBreakStatement.ts (1 errors) ==== + // break is not allowed in a switch statement + + switch (12) { + case 5: + ~ +!!! error TS2678: Type '5' is not comparable to type '12'. + break; + } + \ No newline at end of file diff --git a/tests/baselines/reference/invalidSwitchContinueStatement.errors.txt b/tests/baselines/reference/invalidSwitchContinueStatement.errors.txt index 9b86b019a7c..b5231d5948b 100644 --- a/tests/baselines/reference/invalidSwitchContinueStatement.errors.txt +++ b/tests/baselines/reference/invalidSwitchContinueStatement.errors.txt @@ -1,11 +1,14 @@ +tests/cases/conformance/statements/continueStatements/invalidSwitchContinueStatement.ts(4,10): error TS2678: Type '5' is not comparable to type '12'. tests/cases/conformance/statements/continueStatements/invalidSwitchContinueStatement.ts(5,9): error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. -==== tests/cases/conformance/statements/continueStatements/invalidSwitchContinueStatement.ts (1 errors) ==== +==== tests/cases/conformance/statements/continueStatements/invalidSwitchContinueStatement.ts (2 errors) ==== // continue is not allowed in a switch statement switch (12) { case 5: + ~ +!!! error TS2678: Type '5' is not comparable to type '12'. continue; ~~~~~~~~~ !!! error TS1104: A 'continue' statement can only be used within an enclosing iteration statement. diff --git a/tests/baselines/reference/invalidUndefinedValues.types b/tests/baselines/reference/invalidUndefinedValues.types index b88c2021618..b873f575263 100644 --- a/tests/baselines/reference/invalidUndefinedValues.types +++ b/tests/baselines/reference/invalidUndefinedValues.types @@ -4,19 +4,19 @@ var x: typeof undefined; >undefined : undefined x = 1; ->x = 1 : number +>x = 1 : 1 >x : any ->1 : number +>1 : 1 x = ''; ->x = '' : string +>x = '' : "" >x : any ->'' : string +>'' : "" x = true; ->x = true : boolean +>x = true : true >x : any ->true : boolean +>true : true var a: void; >a : void @@ -65,7 +65,7 @@ x = c; module M { export var x = 1; } >M : typeof M >x : number ->1 : number +>1 : 1 x = M; >x = M : typeof M diff --git a/tests/baselines/reference/invalidVoidAssignments.errors.txt b/tests/baselines/reference/invalidVoidAssignments.errors.txt index af8cec62672..de19fc3a218 100644 --- a/tests/baselines/reference/invalidVoidAssignments.errors.txt +++ b/tests/baselines/reference/invalidVoidAssignments.errors.txt @@ -3,8 +3,8 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(4,5): er tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(5,5): error TS2322: Type 'void' is not assignable to type 'number'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(9,5): error TS2322: Type 'void' is not assignable to type 'C'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(12,5): error TS2322: Type 'void' is not assignable to type 'I'. -tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. -tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(15,5): error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. +tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(14,5): error TS2322: Type '1' is not assignable to type '{ baz: string; }'. +tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(15,5): error TS2322: Type '1' is not assignable to type '{ 0: number; }'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(18,1): error TS2364: Invalid left-hand side of assignment expression. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(21,5): error TS2322: Type 'void' is not assignable to type 'T'. tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(23,1): error TS2364: Invalid left-hand side of assignment expression. @@ -39,10 +39,10 @@ tests/cases/conformance/types/primitives/void/invalidVoidAssignments.ts(29,1): e var g: { baz: string } = 1; ~ -!!! error TS2322: Type 'number' is not assignable to type '{ baz: string; }'. +!!! error TS2322: Type '1' is not assignable to type '{ baz: string; }'. var g2: { 0: number } = 1; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ 0: number; }'. +!!! error TS2322: Type '1' is not assignable to type '{ 0: number; }'. module M { export var x = 1; } M = x; diff --git a/tests/baselines/reference/invalidVoidValues.errors.txt b/tests/baselines/reference/invalidVoidValues.errors.txt index eb5ddd02259..8fc015f692f 100644 --- a/tests/baselines/reference/invalidVoidValues.errors.txt +++ b/tests/baselines/reference/invalidVoidValues.errors.txt @@ -1,6 +1,6 @@ -tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(2,1): error TS2322: Type 'number' is not assignable to type 'void'. -tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(3,1): error TS2322: Type 'string' is not assignable to type 'void'. -tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(4,1): error TS2322: Type 'boolean' is not assignable to type 'void'. +tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(2,1): error TS2322: Type '1' is not assignable to type 'void'. +tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(3,1): error TS2322: Type '""' is not assignable to type 'void'. +tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(4,1): error TS2322: Type 'true' is not assignable to type 'void'. tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(7,1): error TS2322: Type 'typeof E' is not assignable to type 'void'. tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(8,1): error TS2322: Type 'E' is not assignable to type 'void'. tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(12,1): error TS2322: Type 'C' is not assignable to type 'void'. @@ -15,13 +15,13 @@ tests/cases/conformance/types/primitives/void/invalidVoidValues.ts(26,1): error var x: void; x = 1; ~ -!!! error TS2322: Type 'number' is not assignable to type 'void'. +!!! error TS2322: Type '1' is not assignable to type 'void'. x = ''; ~ -!!! error TS2322: Type 'string' is not assignable to type 'void'. +!!! error TS2322: Type '""' is not assignable to type 'void'. x = true; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'void'. +!!! error TS2322: Type 'true' is not assignable to type 'void'. enum E { A } x = E; diff --git a/tests/baselines/reference/invocationExpressionInFunctionParameter.errors.txt b/tests/baselines/reference/invocationExpressionInFunctionParameter.errors.txt index b38ed09f47e..e887d564df4 100644 --- a/tests/baselines/reference/invocationExpressionInFunctionParameter.errors.txt +++ b/tests/baselines/reference/invocationExpressionInFunctionParameter.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/invocationExpressionInFunctionParameter.ts(3,24): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/invocationExpressionInFunctionParameter.ts(3,24): error TS2345: Argument of type '123' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/invocationExpressionInFunctionParameter.ts (1 errors) ==== @@ -6,5 +6,5 @@ tests/cases/compiler/invocationExpressionInFunctionParameter.ts(3,24): error TS2 } function foo3(x = foo1(123)) { //should error, 123 is not string ~~~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'string'. } \ No newline at end of file diff --git a/tests/baselines/reference/ipromise2.types b/tests/baselines/reference/ipromise2.types index b52c3460dd4..ac0df6ee4b5 100644 --- a/tests/baselines/reference/ipromise2.types +++ b/tests/baselines/reference/ipromise2.types @@ -108,11 +108,11 @@ var p2 = p.then(function (s) { >p.then : { (success?: (value: string) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; } >p : Windows.Foundation.IPromise >then : { (success?: (value: string) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; } ->function (s) { return 34;} : (s: string) => number +>function (s) { return 34;} : (s: string) => 34 >s : string return 34; ->34 : number +>34 : 34 } ); diff --git a/tests/baselines/reference/ipromise4.types b/tests/baselines/reference/ipromise4.types index b12c47c7ed5..844afc05783 100644 --- a/tests/baselines/reference/ipromise4.types +++ b/tests/baselines/reference/ipromise4.types @@ -114,9 +114,9 @@ p.then(function (x) { return "hello"; } ).then(function (x) { return x } ); // s >p.then : { (success?: (value: number) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: number) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: number) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; } >p : Windows.Foundation.IPromise >then : { (success?: (value: number) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: number) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: number) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; } ->function (x) { return "hello"; } : (x: number) => string +>function (x) { return "hello"; } : (x: number) => "hello" >x : number ->"hello" : string +>"hello" : "hello" >then : { (success?: (value: string) => Windows.Foundation.IPromise, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => Windows.Foundation.IPromise, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => U, error?: (error: any) => Windows.Foundation.IPromise, progress?: (progress: any) => void): Windows.Foundation.IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): Windows.Foundation.IPromise; } >function (x) { return x } : (x: string) => string >x : string diff --git a/tests/baselines/reference/isLiteral1.types b/tests/baselines/reference/isLiteral1.types index 7ef84568f86..ae512e8bcb1 100644 --- a/tests/baselines/reference/isLiteral1.types +++ b/tests/baselines/reference/isLiteral1.types @@ -1,5 +1,5 @@ === tests/cases/compiler/isLiteral1.ts === var x: number = 02343; >x : number ->02343 : number +>02343 : 2343 diff --git a/tests/baselines/reference/isLiteral2.types b/tests/baselines/reference/isLiteral2.types index ab62993fab6..7ee40a96272 100644 --- a/tests/baselines/reference/isLiteral2.types +++ b/tests/baselines/reference/isLiteral2.types @@ -1,5 +1,5 @@ === tests/cases/compiler/isLiteral2.ts === var x: number = 02343 >x : number ->02343 : number +>02343 : 2343 diff --git a/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types index 4583a1c0730..0412a79c479 100644 --- a/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types +++ b/tests/baselines/reference/isolatedModulesNonAmbientConstEnum.types @@ -3,7 +3,7 @@ const enum E { X = 100 }; >E : E >X : E ->100 : number +>100 : 100 var e = E.X; >e : E diff --git a/tests/baselines/reference/isolatedModulesSourceMap.types b/tests/baselines/reference/isolatedModulesSourceMap.types index d2a474c023d..2ac7b1f2f65 100644 --- a/tests/baselines/reference/isolatedModulesSourceMap.types +++ b/tests/baselines/reference/isolatedModulesSourceMap.types @@ -2,5 +2,5 @@ export var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/iterableArrayPattern1.types b/tests/baselines/reference/iterableArrayPattern1.types index a2c9807d26a..816ce7ac6cf 100644 --- a/tests/baselines/reference/iterableArrayPattern1.types +++ b/tests/baselines/reference/iterableArrayPattern1.types @@ -21,7 +21,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iterableArrayPattern11.types b/tests/baselines/reference/iterableArrayPattern11.types index 5ec182ec397..0acadd7cfc8 100644 --- a/tests/baselines/reference/iterableArrayPattern11.types +++ b/tests/baselines/reference/iterableArrayPattern11.types @@ -37,7 +37,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iterableArrayPattern12.types b/tests/baselines/reference/iterableArrayPattern12.types index 89af4d47d01..c00e1daae81 100644 --- a/tests/baselines/reference/iterableArrayPattern12.types +++ b/tests/baselines/reference/iterableArrayPattern12.types @@ -37,7 +37,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iterableArrayPattern13.types b/tests/baselines/reference/iterableArrayPattern13.types index e8873a74b72..04dab57748d 100644 --- a/tests/baselines/reference/iterableArrayPattern13.types +++ b/tests/baselines/reference/iterableArrayPattern13.types @@ -35,7 +35,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iterableArrayPattern2.types b/tests/baselines/reference/iterableArrayPattern2.types index 48f44443591..63786a1d351 100644 --- a/tests/baselines/reference/iterableArrayPattern2.types +++ b/tests/baselines/reference/iterableArrayPattern2.types @@ -21,7 +21,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iterableArrayPattern3.types b/tests/baselines/reference/iterableArrayPattern3.types index dd001d46376..a21e702526b 100644 --- a/tests/baselines/reference/iterableArrayPattern3.types +++ b/tests/baselines/reference/iterableArrayPattern3.types @@ -38,7 +38,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iterableArrayPattern30.types b/tests/baselines/reference/iterableArrayPattern30.types index 8cfb50c3abb..1abdba039ed 100644 --- a/tests/baselines/reference/iterableArrayPattern30.types +++ b/tests/baselines/reference/iterableArrayPattern30.types @@ -8,9 +8,9 @@ const [[k1, v1], [k2, v2]] = new Map([["", true], ["hello", true]]) >Map : MapConstructor >[["", true], ["hello", true]] : [string, true][] >["", true] : [string, true] ->"" : string +>"" : "" >true : true >["hello", true] : [string, true] ->"hello" : string +>"hello" : "hello" >true : true diff --git a/tests/baselines/reference/iterableArrayPattern4.types b/tests/baselines/reference/iterableArrayPattern4.types index 2d6531494a4..a3be4114498 100644 --- a/tests/baselines/reference/iterableArrayPattern4.types +++ b/tests/baselines/reference/iterableArrayPattern4.types @@ -39,7 +39,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iterableArrayPattern9.types b/tests/baselines/reference/iterableArrayPattern9.types index e9e342e7775..b24d057f4a7 100644 --- a/tests/baselines/reference/iterableArrayPattern9.types +++ b/tests/baselines/reference/iterableArrayPattern9.types @@ -31,7 +31,7 @@ class FooIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInArray.types b/tests/baselines/reference/iteratorSpreadInArray.types index 780acf32fab..4b5a63e5d57 100644 --- a/tests/baselines/reference/iteratorSpreadInArray.types +++ b/tests/baselines/reference/iteratorSpreadInArray.types @@ -22,7 +22,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInArray2.types b/tests/baselines/reference/iteratorSpreadInArray2.types index f2e64e5282e..19bf5eab004 100644 --- a/tests/baselines/reference/iteratorSpreadInArray2.types +++ b/tests/baselines/reference/iteratorSpreadInArray2.types @@ -25,7 +25,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } @@ -51,11 +51,11 @@ class NumberIterator { value: 0, >value : number ->0 : number +>0 : 0 done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInArray3.types b/tests/baselines/reference/iteratorSpreadInArray3.types index a59da81e157..1fd29bb2381 100644 --- a/tests/baselines/reference/iteratorSpreadInArray3.types +++ b/tests/baselines/reference/iteratorSpreadInArray3.types @@ -4,8 +4,8 @@ var array = [...[0, 1], ...new SymbolIterator]; >[...[0, 1], ...new SymbolIterator] : (number | symbol)[] >...[0, 1] : number >[0, 1] : number[] ->0 : number ->1 : number +>0 : 0 +>1 : 1 >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator @@ -26,7 +26,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInArray4.types b/tests/baselines/reference/iteratorSpreadInArray4.types index 0e16758acf4..6024e79dee5 100644 --- a/tests/baselines/reference/iteratorSpreadInArray4.types +++ b/tests/baselines/reference/iteratorSpreadInArray4.types @@ -2,8 +2,8 @@ var array = [0, 1, ...new SymbolIterator]; >array : (number | symbol)[] >[0, 1, ...new SymbolIterator] : (number | symbol)[] ->0 : number ->1 : number +>0 : 0 +>1 : 1 >...new SymbolIterator : symbol >new SymbolIterator : SymbolIterator >SymbolIterator : typeof SymbolIterator @@ -24,7 +24,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInArray7.types b/tests/baselines/reference/iteratorSpreadInArray7.types index 38549a606ab..ef0e3898e0f 100644 --- a/tests/baselines/reference/iteratorSpreadInArray7.types +++ b/tests/baselines/reference/iteratorSpreadInArray7.types @@ -28,7 +28,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInCall11.types b/tests/baselines/reference/iteratorSpreadInCall11.types index dd440a1b4ac..5990b26df64 100644 --- a/tests/baselines/reference/iteratorSpreadInCall11.types +++ b/tests/baselines/reference/iteratorSpreadInCall11.types @@ -13,7 +13,7 @@ function foo(...s: T[]) { return s[0] } >T : T >s[0] : T >s : T[] ->0 : number +>0 : 0 class SymbolIterator { >SymbolIterator : SymbolIterator @@ -31,7 +31,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInCall12.types b/tests/baselines/reference/iteratorSpreadInCall12.types index 8543e59f55f..b614fdde16b 100644 --- a/tests/baselines/reference/iteratorSpreadInCall12.types +++ b/tests/baselines/reference/iteratorSpreadInCall12.types @@ -38,7 +38,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } @@ -64,11 +64,11 @@ class StringIterator { value: "", >value : string ->"" : string +>"" : "" done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInCall3.types b/tests/baselines/reference/iteratorSpreadInCall3.types index 54857755b55..56b7f6db6d1 100644 --- a/tests/baselines/reference/iteratorSpreadInCall3.types +++ b/tests/baselines/reference/iteratorSpreadInCall3.types @@ -26,7 +26,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorSpreadInCall5.types b/tests/baselines/reference/iteratorSpreadInCall5.types index bf4a0f7ad65..9542a76daf1 100644 --- a/tests/baselines/reference/iteratorSpreadInCall5.types +++ b/tests/baselines/reference/iteratorSpreadInCall5.types @@ -29,7 +29,7 @@ class SymbolIterator { done: false >done : boolean ->false : boolean +>false : false }; } @@ -55,11 +55,11 @@ class StringIterator { value: "", >value : string ->"" : string +>"" : "" done: false >done : boolean ->false : boolean +>false : false }; } diff --git a/tests/baselines/reference/iteratorsAndStrictNullChecks.types b/tests/baselines/reference/iteratorsAndStrictNullChecks.types index ce1d7430f77..43efed86ed4 100644 --- a/tests/baselines/reference/iteratorsAndStrictNullChecks.types +++ b/tests/baselines/reference/iteratorsAndStrictNullChecks.types @@ -4,8 +4,8 @@ for (const x of ["a", "b"]) { >x : string >["a", "b"] : string[] ->"a" : string ->"b" : string +>"a" : "a" +>"b" : "b" x.substring; >x.substring : (start: number, end?: number | undefined) => string @@ -17,15 +17,15 @@ for (const x of ["a", "b"]) { const xs = [1, 2, 3]; >xs : number[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 const ys = [4, 5]; >ys : number[] >[4, 5] : number[] ->4 : number ->5 : number +>4 : 4 +>5 : 5 xs.push(...ys); >xs.push(...ys) : number diff --git a/tests/baselines/reference/jsFileCompilationExternalPackageError.types b/tests/baselines/reference/jsFileCompilationExternalPackageError.types index ae2eb085f28..d3a696d7bfe 100644 --- a/tests/baselines/reference/jsFileCompilationExternalPackageError.types +++ b/tests/baselines/reference/jsFileCompilationExternalPackageError.types @@ -17,18 +17,18 @@ c++; === tests/cases/compiler/node_modules/b.ts === var a = 10; >a : number ->10 : number +>10 : 10 === tests/cases/compiler/node_modules/c.js === exports.a = 10; ->exports.a = 10 : number +>exports.a = 10 : 10 >exports.a : any >exports : any >a : any ->10 : number +>10 : 10 c = 10; ->c = 10 : number +>c = 10 : 10 >c : any ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.types b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.types index 094f59d2022..3cac906f5d7 100644 --- a/tests/baselines/reference/jsFileCompilationLetBeingRenamed.types +++ b/tests/baselines/reference/jsFileCompilationLetBeingRenamed.types @@ -6,10 +6,10 @@ function foo(a) { for (let a = 0; a < 10; a++) { >a : number ->0 : number +>0 : 0 >a < 10 : boolean >a : number ->10 : number +>10 : 10 >a++ : number >a : number diff --git a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types index 443ed739828..c420454b8cf 100644 --- a/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types +++ b/tests/baselines/reference/jsFileCompilationRestParamJsDocFunction.types @@ -42,7 +42,7 @@ function apply(func, thisArg, args) { >thisArg : any >args[0] : any >args : any[] ->0 : number +>0 : 0 case 2: return func.call(thisArg, args[0], args[1]); >2 : 2 @@ -53,10 +53,10 @@ function apply(func, thisArg, args) { >thisArg : any >args[0] : any >args : any[] ->0 : number +>0 : 0 >args[1] : any >args : any[] ->1 : number +>1 : 1 case 3: return func.call(thisArg, args[0], args[1], args[2]); >3 : 3 @@ -67,13 +67,13 @@ function apply(func, thisArg, args) { >thisArg : any >args[0] : any >args : any[] ->0 : number +>0 : 0 >args[1] : any >args : any[] ->1 : number +>1 : 1 >args[2] : any >args : any[] ->2 : number +>2 : 2 } return func.apply(thisArg, args); >func.apply(thisArg, args) : any diff --git a/tests/baselines/reference/jsFileCompilationShortHandProperty.types b/tests/baselines/reference/jsFileCompilationShortHandProperty.types index e4dd1755ceb..d6badf44909 100644 --- a/tests/baselines/reference/jsFileCompilationShortHandProperty.types +++ b/tests/baselines/reference/jsFileCompilationShortHandProperty.types @@ -5,11 +5,11 @@ function foo() { var a = 10; >a : number ->10 : number +>10 : 10 var b = "Hello"; >b : string ->"Hello" : string +>"Hello" : "Hello" return { >{ a, b } : { a: number; b: string; } diff --git a/tests/baselines/reference/jsdocLiteral.types b/tests/baselines/reference/jsdocLiteral.types index b6c9e522ac3..c0a17c9bad1 100644 --- a/tests/baselines/reference/jsdocLiteral.types +++ b/tests/baselines/reference/jsdocLiteral.types @@ -25,6 +25,6 @@ function f(p1, p2, p3, p4, p5) { >p3 : "literal" | "other" >p4 : number | "literal" >p5 : true | 12 | "str" ->'.' : string +>'.' : "." } diff --git a/tests/baselines/reference/json.stringify.types b/tests/baselines/reference/json.stringify.types index aaf92a17c0a..b063b06d8d0 100644 --- a/tests/baselines/reference/json.stringify.types +++ b/tests/baselines/reference/json.stringify.types @@ -11,7 +11,7 @@ JSON.stringify(value, undefined, 2); >stringify : { (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >value : null >undefined : undefined ->2 : number +>2 : 2 JSON.stringify(value, null, 2); >JSON.stringify(value, null, 2) : string @@ -20,7 +20,7 @@ JSON.stringify(value, null, 2); >stringify : { (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >value : null >null : null ->2 : number +>2 : 2 JSON.stringify(value, ["a", 1], 2); >JSON.stringify(value, ["a", 1], 2) : string @@ -29,9 +29,9 @@ JSON.stringify(value, ["a", 1], 2); >stringify : { (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >value : null >["a", 1] : (string | number)[] ->"a" : string ->1 : number ->2 : number +>"a" : "a" +>1 : 1 +>2 : 2 JSON.stringify(value, (k) => undefined, 2); >JSON.stringify(value, (k) => undefined, 2) : string @@ -42,7 +42,7 @@ JSON.stringify(value, (k) => undefined, 2); >(k) => undefined : (k: string) => undefined >k : string >undefined : undefined ->2 : number +>2 : 2 JSON.stringify(value, undefined, 2); >JSON.stringify(value, undefined, 2) : string @@ -51,5 +51,5 @@ JSON.stringify(value, undefined, 2); >stringify : { (value: any, replacer?: ((key: string, value: any) => any) | undefined, space?: string | number | undefined): string; (value: any, replacer?: (string | number)[] | null | undefined, space?: string | number | undefined): string; } >value : null >undefined : undefined ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/jsxHash.types b/tests/baselines/reference/jsxHash.types index 6d413141ca6..41f89c4b087 100644 --- a/tests/baselines/reference/jsxHash.types +++ b/tests/baselines/reference/jsxHash.types @@ -3,21 +3,21 @@ var t02 = {0}#; >t02 : any >{0}# : any >a : any ->0 : number +>0 : 0 >a : any var t03 = #{0}; >t03 : any >#{0} : any >a : any ->0 : number +>0 : 0 >a : any var t04 = #{0}#; >t04 : any >#{0}# : any >a : any ->0 : number +>0 : 0 >a : any var t05 = #; diff --git a/tests/baselines/reference/jsxPreserveWithJsInput.types b/tests/baselines/reference/jsxPreserveWithJsInput.types index 7f4ed6daa2b..4ae5c6aeed4 100644 --- a/tests/baselines/reference/jsxPreserveWithJsInput.types +++ b/tests/baselines/reference/jsxPreserveWithJsInput.types @@ -2,14 +2,14 @@ var elemA = 42; >elemA : number ->42 : number +>42 : 42 === tests/cases/compiler/b.jsx === var elemB = {"test"}; >elemB : any >{"test"} : any >b : any ->"test" : string +>"test" : "test" >b : any === tests/cases/compiler/c.js === @@ -17,19 +17,19 @@ var elemC = {42}; >elemC : any >{42} : any >c : any ->42 : number +>42 : 42 >c : any === tests/cases/compiler/d.ts === var elemD = 42; >elemD : number ->42 : number +>42 : 42 === tests/cases/compiler/e.tsx === var elemE = {true}; >elemE : any >{true} : any >e : any ->true : boolean +>true : true >e : any diff --git a/tests/baselines/reference/jsxReactTestSuite.types b/tests/baselines/reference/jsxReactTestSuite.types index 8bab7ce6e7d..712a7368a62 100644 --- a/tests/baselines/reference/jsxReactTestSuite.types +++ b/tests/baselines/reference/jsxReactTestSuite.types @@ -120,8 +120,8 @@ var x = "foo" + "bar" >"foo" + "bar" : string ->"foo" : string ->"bar" : string +>"foo" : "foo" +>"bar" : "bar" } attr2={ >attr2 : any @@ -130,12 +130,12 @@ var x = >"foo" + "bar" + "baz" + "bug" : string >"foo" + "bar" + "baz" : string >"foo" + "bar" : string ->"foo" : string ->"bar" : string +>"foo" : "foo" +>"bar" : "bar" "baz" + "bug" ->"baz" : string ->"bug" : string +>"baz" : "baz" +>"bug" : "bug" } attr3={ >attr3 : any @@ -144,12 +144,12 @@ var x = >"foo" + "bar" + "baz" + "bug" : string >"foo" + "bar" + "baz" : string >"foo" + "bar" : string ->"foo" : string ->"bar" : string +>"foo" : "foo" +>"bar" : "bar" "baz" + "bug" ->"baz" : string ->"bug" : string +>"baz" : "baz" +>"bug" : "bug" // Extra line here. } @@ -254,7 +254,7 @@ var x = >y : any ={2 } z />; ->2 : number +>2 : 2 >z : any Component : any >x : any >y : any ->2 : number +>2 : 2 ; > : any >Component : any >x : any >y : any ->2 : number +>2 : 2 >z : any ; > : any >Component : any >x : any ->1 : number +>1 : 1 >y : any @@ -313,7 +313,7 @@ var x = > : any >Component : any >x : any ->1 : number +>1 : 1 >y : any >z : any >z : any @@ -331,10 +331,10 @@ var x = >z : any >{ y: 2 } : { y: number; } >y : number ->2 : number +>2 : 2 >z : any >z : any ->3 : number +>3 : 3 >Component : any diff --git a/tests/baselines/reference/keywordField.types b/tests/baselines/reference/keywordField.types index 8bc977edd74..b5e90e627ed 100644 --- a/tests/baselines/reference/keywordField.types +++ b/tests/baselines/reference/keywordField.types @@ -4,17 +4,17 @@ var obj:any = {}; >{} : {} obj.if = 1; ->obj.if = 1 : number +>obj.if = 1 : 1 >obj.if : any >obj : any >if : any ->1 : number +>1 : 1 var a = { if: "test" } >a : { if: string; } >{ if: "test" } : { if: string; } >if : string ->"test" : string +>"test" : "test" var n = a.if >n : string @@ -26,5 +26,5 @@ var q = a["if"]; >q : string >a["if"] : string >a : { if: string; } ->"if" : string +>"if" : "if" diff --git a/tests/baselines/reference/lambdaASIEmit.types b/tests/baselines/reference/lambdaASIEmit.types index 8ea881c4cd5..381e45c5fd2 100644 --- a/tests/baselines/reference/lambdaASIEmit.types +++ b/tests/baselines/reference/lambdaASIEmit.types @@ -13,5 +13,5 @@ Foo(() => // do something 127); ->127 : number +>127 : 127 diff --git a/tests/baselines/reference/lambdaExpression.types b/tests/baselines/reference/lambdaExpression.types index 714cd851d63..fc60097b6b0 100644 --- a/tests/baselines/reference/lambdaExpression.types +++ b/tests/baselines/reference/lambdaExpression.types @@ -1,18 +1,18 @@ === tests/cases/compiler/lambdaExpression.ts === () => 0; // Needs to be wrapped in parens to be a valid expression (not declaration) >() => 0 : () => number ->0 : number +>0 : 0 var y = 0; >y : number ->0 : number +>0 : 0 (()=>0); >(()=>0) : () => number >()=>0 : () => number ->0 : number +>0 : 0 var x = 0; >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/letConstInCaseClauses.errors.txt b/tests/baselines/reference/letConstInCaseClauses.errors.txt index af0777d56a4..754da95d367 100644 --- a/tests/baselines/reference/letConstInCaseClauses.errors.txt +++ b/tests/baselines/reference/letConstInCaseClauses.errors.txt @@ -1,8 +1,10 @@ tests/cases/compiler/letConstInCaseClauses.ts(7,5): error TS2304: Cannot find name 'console'. tests/cases/compiler/letConstInCaseClauses.ts(21,5): error TS2304: Cannot find name 'console'. +tests/cases/compiler/letConstInCaseClauses.ts(23,14): error TS2678: Type '10' is not comparable to type '1'. +tests/cases/compiler/letConstInCaseClauses.ts(27,14): error TS2678: Type '10' is not comparable to type '2'. -==== tests/cases/compiler/letConstInCaseClauses.ts (2 errors) ==== +==== tests/cases/compiler/letConstInCaseClauses.ts (4 errors) ==== var x = 10; var y = 20; @@ -30,10 +32,14 @@ tests/cases/compiler/letConstInCaseClauses.ts(21,5): error TS2304: Cannot find n !!! error TS2304: Cannot find name 'console'. switch (x) { case 10: + ~~ +!!! error TS2678: Type '10' is not comparable to type '1'. const x = 20; } switch (y) { case 10: + ~~ +!!! error TS2678: Type '10' is not comparable to type '2'. const y = 20; } } \ No newline at end of file diff --git a/tests/baselines/reference/letConstMatchingParameterNames.types b/tests/baselines/reference/letConstMatchingParameterNames.types index 2e29dff289b..acf508f77a3 100644 --- a/tests/baselines/reference/letConstMatchingParameterNames.types +++ b/tests/baselines/reference/letConstMatchingParameterNames.types @@ -1,11 +1,11 @@ === tests/cases/compiler/letConstMatchingParameterNames.ts === let parent = true; >parent : boolean ->true : boolean +>true : true const parent2 = true; ->parent2 : boolean ->true : boolean +>parent2 : true +>true : true declare function use(a: any); >use : (a: any) => any @@ -16,11 +16,11 @@ function a() { let parent = 1; >parent : number ->1 : number +>1 : 1 const parent2 = 2; ->parent2 : number ->2 : number +>parent2 : 2 +>2 : 2 function b(parent: string, parent2: number) { >b : (parent: string, parent2: number) => void diff --git a/tests/baselines/reference/letDeclarations-access.types b/tests/baselines/reference/letDeclarations-access.types index 673fc97f80b..b2f984a4956 100644 --- a/tests/baselines/reference/letDeclarations-access.types +++ b/tests/baselines/reference/letDeclarations-access.types @@ -2,69 +2,69 @@ let x = 0 >x : number ->0 : number +>0 : 0 // No errors x = 1; ->x = 1 : number +>x = 1 : 1 >x : number ->1 : number +>1 : 1 x += 2; >x += 2 : number >x : number ->2 : number +>2 : 2 x -= 3; >x -= 3 : number >x : number ->3 : number +>3 : 3 x *= 4; >x *= 4 : number >x : number ->4 : number +>4 : 4 x /= 5; >x /= 5 : number >x : number ->5 : number +>5 : 5 x %= 6; >x %= 6 : number >x : number ->6 : number +>6 : 6 x <<= 7; >x <<= 7 : number >x : number ->7 : number +>7 : 7 x >>= 8; >x >>= 8 : number >x : number ->8 : number +>8 : 8 x >>>= 9; >x >>>= 9 : number >x : number ->9 : number +>9 : 9 x &= 10; >x &= 10 : number >x : number ->10 : number +>10 : 10 x |= 11; >x |= 11 : number >x : number ->11 : number +>11 : 11 x ^= 12; >x ^= 12 : number >x : number ->12 : number +>12 : 12 x++; >x++ : number @@ -86,7 +86,7 @@ var a = x + 1; >a : number >x + 1 : number >x : number ->1 : number +>1 : 1 function f(v: number) { } >f : (v: number) => void diff --git a/tests/baselines/reference/letDeclarations-es5-1.types b/tests/baselines/reference/letDeclarations-es5-1.types index b088677cd0a..31506b717a9 100644 --- a/tests/baselines/reference/letDeclarations-es5-1.types +++ b/tests/baselines/reference/letDeclarations-es5-1.types @@ -13,17 +13,17 @@ let l7 = false; >l7 : boolean ->false : boolean +>false : false let l8: number = 23; >l8 : number ->23 : number +>23 : 23 let l9 = 0, l10 :string = "", l11 = null; >l9 : number ->0 : number +>0 : 0 >l10 : string ->"" : string +>"" : "" >l11 : any >null : null diff --git a/tests/baselines/reference/letDeclarations-es5.types b/tests/baselines/reference/letDeclarations-es5.types index f6e8d418632..9756951e705 100644 --- a/tests/baselines/reference/letDeclarations-es5.types +++ b/tests/baselines/reference/letDeclarations-es5.types @@ -14,17 +14,17 @@ let l3, l4, l5 :string, l6; let l7 = false; >l7 : boolean ->false : boolean +>false : false let l8: number = 23; >l8 : number ->23 : number +>23 : 23 let l9 = 0, l10 :string = "", l11 = null; >l9 : number ->0 : number +>0 : 0 >l10 : string ->"" : string +>"" : "" >l11 : any >null : null @@ -34,10 +34,10 @@ for(let l11 in {}) { } for(let l12 = 0; l12 < 9; l12++) { } >l12 : number ->0 : number +>0 : 0 >l12 < 9 : boolean >l12 : number ->9 : number +>9 : 9 >l12++ : number >l12 : number diff --git a/tests/baselines/reference/letDeclarations.types b/tests/baselines/reference/letDeclarations.types index bb20f895a14..b1548f788ef 100644 --- a/tests/baselines/reference/letDeclarations.types +++ b/tests/baselines/reference/letDeclarations.types @@ -14,17 +14,17 @@ let l3, l4, l5 :string, l6; let l7 = false; >l7 : boolean ->false : boolean +>false : false let l8: number = 23; >l8 : number ->23 : number +>23 : 23 let l9 = 0, l10 :string = "", l11 = null; >l9 : number ->0 : number +>0 : 0 >l10 : string ->"" : string +>"" : "" >l11 : any >null : null @@ -34,10 +34,10 @@ for(let l11 in {}) { } for(let l12 = 0; l12 < 9; l12++) { } >l12 : number ->0 : number +>0 : 0 >l12 < 9 : boolean >l12 : number ->9 : number +>9 : 9 >l12++ : number >l12 : number diff --git a/tests/baselines/reference/letDeclarations2.types b/tests/baselines/reference/letDeclarations2.types index eeb66838a6a..893514adb3f 100644 --- a/tests/baselines/reference/letDeclarations2.types +++ b/tests/baselines/reference/letDeclarations2.types @@ -5,9 +5,9 @@ module M { let l1 = "s"; >l1 : string ->"s" : string +>"s" : "s" export let l2 = 0; >l2 : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/letIdentifierInElementAccess01.types b/tests/baselines/reference/letIdentifierInElementAccess01.types index 187fd7e221c..d169daa0307 100644 --- a/tests/baselines/reference/letIdentifierInElementAccess01.types +++ b/tests/baselines/reference/letIdentifierInElementAccess01.types @@ -4,10 +4,10 @@ var let: any = {}; >{} : {} (let[0] = 100); ->(let[0] = 100) : number ->let[0] = 100 : number +>(let[0] = 100) : 100 +>let[0] = 100 : 100 >let[0] : any >let : any ->0 : number ->100 : number +>0 : 0 +>100 : 100 diff --git a/tests/baselines/reference/letInNonStrictMode.types b/tests/baselines/reference/letInNonStrictMode.types index ceb59dba6a3..d37f7fe20a3 100644 --- a/tests/baselines/reference/letInNonStrictMode.types +++ b/tests/baselines/reference/letInNonStrictMode.types @@ -2,12 +2,12 @@ let [x] = [1]; >x : number >[1] : [number] ->1 : number +>1 : 1 let {a: y} = {a: 1}; >a : any >y : number >{a: 1} : { a: number; } >a : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES5.types b/tests/baselines/reference/letInVarDeclOfForIn_ES5.types index 095ae16b91e..d3751f58959 100644 --- a/tests/baselines/reference/letInVarDeclOfForIn_ES5.types +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES5.types @@ -4,16 +4,16 @@ for (var let in [1,2,3]) {} >let : string >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 { for (var let in [1,2,3]) {} >let : string >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 } diff --git a/tests/baselines/reference/letInVarDeclOfForIn_ES6.types b/tests/baselines/reference/letInVarDeclOfForIn_ES6.types index a5e2ce108db..1d672c12ea6 100644 --- a/tests/baselines/reference/letInVarDeclOfForIn_ES6.types +++ b/tests/baselines/reference/letInVarDeclOfForIn_ES6.types @@ -4,16 +4,16 @@ for (var let in [1,2,3]) {} >let : string >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 { for (var let in [1,2,3]) {} >let : string >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 } diff --git a/tests/baselines/reference/letInVarDeclOfForOf_ES5.types b/tests/baselines/reference/letInVarDeclOfForOf_ES5.types index a1000df8bed..6b1648dcaf3 100644 --- a/tests/baselines/reference/letInVarDeclOfForOf_ES5.types +++ b/tests/baselines/reference/letInVarDeclOfForOf_ES5.types @@ -4,16 +4,16 @@ for (var let of [1,2,3]) {} >let : number >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 { for (var let of [1,2,3]) {} >let : number >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 } diff --git a/tests/baselines/reference/letInVarDeclOfForOf_ES6.types b/tests/baselines/reference/letInVarDeclOfForOf_ES6.types index 1515895feda..3231dbc0b2c 100644 --- a/tests/baselines/reference/letInVarDeclOfForOf_ES6.types +++ b/tests/baselines/reference/letInVarDeclOfForOf_ES6.types @@ -4,16 +4,16 @@ for (var let of [1,2,3]) {} >let : number >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 { for (var let of [1,2,3]) {} >let : number >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 } diff --git a/tests/baselines/reference/library_ArraySlice.types b/tests/baselines/reference/library_ArraySlice.types index b92d9254390..5fe3858628a 100644 --- a/tests/baselines/reference/library_ArraySlice.types +++ b/tests/baselines/reference/library_ArraySlice.types @@ -15,7 +15,7 @@ Array.prototype.slice(0); >Array : ArrayConstructor >prototype : any[] >slice : (start?: number, end?: number) => any[] ->0 : number +>0 : 0 Array.prototype.slice(0, 1); >Array.prototype.slice(0, 1) : any[] @@ -24,6 +24,6 @@ Array.prototype.slice(0, 1); >Array : ArrayConstructor >prototype : any[] >slice : (start?: number, end?: number) => any[] ->0 : number ->1 : number +>0 : 0 +>1 : 1 diff --git a/tests/baselines/reference/library_DatePrototypeProperties.types b/tests/baselines/reference/library_DatePrototypeProperties.types index c048b9833d6..6a299f67232 100644 --- a/tests/baselines/reference/library_DatePrototypeProperties.types +++ b/tests/baselines/reference/library_DatePrototypeProperties.types @@ -215,7 +215,7 @@ Date.prototype.setTime(0); >Date : DateConstructor >prototype : Date >setTime : (time: number) => number ->0 : number +>0 : 0 Date.prototype.setMilliseconds(0); >Date.prototype.setMilliseconds(0) : number @@ -224,7 +224,7 @@ Date.prototype.setMilliseconds(0); >Date : DateConstructor >prototype : Date >setMilliseconds : (ms: number) => number ->0 : number +>0 : 0 Date.prototype.setUTCMilliseconds(0); >Date.prototype.setUTCMilliseconds(0) : number @@ -233,7 +233,7 @@ Date.prototype.setUTCMilliseconds(0); >Date : DateConstructor >prototype : Date >setUTCMilliseconds : (ms: number) => number ->0 : number +>0 : 0 Date.prototype.setSeconds(0); >Date.prototype.setSeconds(0) : number @@ -242,7 +242,7 @@ Date.prototype.setSeconds(0); >Date : DateConstructor >prototype : Date >setSeconds : (sec: number, ms?: number) => number ->0 : number +>0 : 0 Date.prototype.setUTCSeconds(0); >Date.prototype.setUTCSeconds(0) : number @@ -251,7 +251,7 @@ Date.prototype.setUTCSeconds(0); >Date : DateConstructor >prototype : Date >setUTCSeconds : (sec: number, ms?: number) => number ->0 : number +>0 : 0 Date.prototype.setMinutes(0); >Date.prototype.setMinutes(0) : number @@ -260,7 +260,7 @@ Date.prototype.setMinutes(0); >Date : DateConstructor >prototype : Date >setMinutes : (min: number, sec?: number, ms?: number) => number ->0 : number +>0 : 0 Date.prototype.setUTCMinutes(0); >Date.prototype.setUTCMinutes(0) : number @@ -269,7 +269,7 @@ Date.prototype.setUTCMinutes(0); >Date : DateConstructor >prototype : Date >setUTCMinutes : (min: number, sec?: number, ms?: number) => number ->0 : number +>0 : 0 Date.prototype.setHours(0); >Date.prototype.setHours(0) : number @@ -278,7 +278,7 @@ Date.prototype.setHours(0); >Date : DateConstructor >prototype : Date >setHours : (hours: number, min?: number, sec?: number, ms?: number) => number ->0 : number +>0 : 0 Date.prototype.setUTCHours(0); >Date.prototype.setUTCHours(0) : number @@ -287,7 +287,7 @@ Date.prototype.setUTCHours(0); >Date : DateConstructor >prototype : Date >setUTCHours : (hours: number, min?: number, sec?: number, ms?: number) => number ->0 : number +>0 : 0 Date.prototype.setDate(0); >Date.prototype.setDate(0) : number @@ -296,7 +296,7 @@ Date.prototype.setDate(0); >Date : DateConstructor >prototype : Date >setDate : (date: number) => number ->0 : number +>0 : 0 Date.prototype.setUTCDate(0); >Date.prototype.setUTCDate(0) : number @@ -305,7 +305,7 @@ Date.prototype.setUTCDate(0); >Date : DateConstructor >prototype : Date >setUTCDate : (date: number) => number ->0 : number +>0 : 0 Date.prototype.setMonth(0); >Date.prototype.setMonth(0) : number @@ -314,7 +314,7 @@ Date.prototype.setMonth(0); >Date : DateConstructor >prototype : Date >setMonth : (month: number, date?: number) => number ->0 : number +>0 : 0 Date.prototype.setUTCMonth(0); >Date.prototype.setUTCMonth(0) : number @@ -323,7 +323,7 @@ Date.prototype.setUTCMonth(0); >Date : DateConstructor >prototype : Date >setUTCMonth : (month: number, date?: number) => number ->0 : number +>0 : 0 Date.prototype.setFullYear(0); >Date.prototype.setFullYear(0) : number @@ -332,7 +332,7 @@ Date.prototype.setFullYear(0); >Date : DateConstructor >prototype : Date >setFullYear : (year: number, month?: number, date?: number) => number ->0 : number +>0 : 0 Date.prototype.setUTCFullYear(0); >Date.prototype.setUTCFullYear(0) : number @@ -341,7 +341,7 @@ Date.prototype.setUTCFullYear(0); >Date : DateConstructor >prototype : Date >setUTCFullYear : (year: number, month?: number, date?: number) => number ->0 : number +>0 : 0 Date.prototype.toUTCString(); >Date.prototype.toUTCString() : string diff --git a/tests/baselines/reference/library_ObjectPrototypeProperties.types b/tests/baselines/reference/library_ObjectPrototypeProperties.types index 616a9da633b..2f41dd7c1eb 100644 --- a/tests/baselines/reference/library_ObjectPrototypeProperties.types +++ b/tests/baselines/reference/library_ObjectPrototypeProperties.types @@ -39,7 +39,7 @@ Object.prototype.hasOwnProperty("string"); >Object : ObjectConstructor >prototype : Object >hasOwnProperty : (v: string) => boolean ->"string" : string +>"string" : "string" Object.prototype.isPrototypeOf(Object); >Object.prototype.isPrototypeOf(Object) : boolean @@ -57,5 +57,5 @@ Object.prototype.propertyIsEnumerable("string"); >Object : ObjectConstructor >prototype : Object >propertyIsEnumerable : (v: string) => boolean ->"string" : string +>"string" : "string" diff --git a/tests/baselines/reference/library_RegExpExecArraySlice.types b/tests/baselines/reference/library_RegExpExecArraySlice.types index b4673adb988..0fd2a319833 100644 --- a/tests/baselines/reference/library_RegExpExecArraySlice.types +++ b/tests/baselines/reference/library_RegExpExecArraySlice.types @@ -15,13 +15,13 @@ regExpExecArrayValue.slice(0); >regExpExecArrayValue.slice : (start?: number, end?: number) => string[] >regExpExecArrayValue : RegExpExecArray >slice : (start?: number, end?: number) => string[] ->0 : number +>0 : 0 regExpExecArrayValue.slice(0,1); >regExpExecArrayValue.slice(0,1) : string[] >regExpExecArrayValue.slice : (start?: number, end?: number) => string[] >regExpExecArrayValue : RegExpExecArray >slice : (start?: number, end?: number) => string[] ->0 : number ->1 : number +>0 : 0 +>1 : 1 diff --git a/tests/baselines/reference/library_StringSlice.types b/tests/baselines/reference/library_StringSlice.types index 09b2a0b3995..a4f8e2e98e9 100644 --- a/tests/baselines/reference/library_StringSlice.types +++ b/tests/baselines/reference/library_StringSlice.types @@ -15,7 +15,7 @@ String.prototype.slice(0); >String : StringConstructor >prototype : String >slice : (start?: number, end?: number) => string ->0 : number +>0 : 0 String.prototype.slice(0,1); >String.prototype.slice(0,1) : string @@ -24,6 +24,6 @@ String.prototype.slice(0,1); >String : StringConstructor >prototype : String >slice : (start?: number, end?: number) => string ->0 : number ->1 : number +>0 : 0 +>1 : 1 diff --git a/tests/baselines/reference/literals1.types b/tests/baselines/reference/literals1.types index 69e50c22f4a..5b1a5c9cd68 100644 --- a/tests/baselines/reference/literals1.types +++ b/tests/baselines/reference/literals1.types @@ -1,47 +1,47 @@ === tests/cases/compiler/literals1.ts === var a = 42; >a : number ->42 : number +>42 : 42 var b = 0xFA34; >b : number ->0xFA34 : number +>0xFA34 : 64052 var c = 0.1715; >c : number ->0.1715 : number +>0.1715 : 0.1715 var d = 3.14E5; >d : number ->3.14E5 : number +>3.14E5 : 314000 var e = 8.14e-5; >e : number ->8.14e-5 : number +>8.14e-5 : 0.0000814 var f = true; >f : boolean ->true : boolean +>true : true var g = false; >g : boolean ->false : boolean +>false : false var h = ""; >h : string ->"" : string +>"" : "" var i = "hi"; >i : string ->"hi" : string +>"hi" : "hi" var j = ''; >j : string ->'' : string +>'' : "" var k = 'q\tq'; >k : string ->'q\tq' : string +>'q\tq' : "q\tq" var m = /q/; >m : RegExp diff --git a/tests/baselines/reference/localClassesInLoop.types b/tests/baselines/reference/localClassesInLoop.types index f1c06f93463..c88bfc0435d 100644 --- a/tests/baselines/reference/localClassesInLoop.types +++ b/tests/baselines/reference/localClassesInLoop.types @@ -4,7 +4,7 @@ declare function use(a: any); >a : any "use strict" ->"use strict" : string +>"use strict" : "use strict" var data = []; >data : any[] @@ -12,10 +12,10 @@ var data = []; for (let x = 0; x < 2; ++x) { >x : number ->0 : number +>0 : 0 >x < 2 : boolean >x : number ->2 : number +>2 : 2 >++x : number >x : number @@ -38,9 +38,9 @@ use(data[0]() === data[1]()); >data[0]() : any >data[0] : any >data : any[] ->0 : number +>0 : 0 >data[1]() : any >data[1] : any >data : any[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/localClassesInLoop_ES6.types b/tests/baselines/reference/localClassesInLoop_ES6.types index 518e75f4afa..9d487f6c600 100644 --- a/tests/baselines/reference/localClassesInLoop_ES6.types +++ b/tests/baselines/reference/localClassesInLoop_ES6.types @@ -5,7 +5,7 @@ declare function use(a: any); >a : any "use strict" ->"use strict" : string +>"use strict" : "use strict" var data = []; >data : any[] @@ -13,10 +13,10 @@ var data = []; for (let x = 0; x < 2; ++x) { >x : number ->0 : number +>0 : 0 >x < 2 : boolean >x : number ->2 : number +>2 : 2 >++x : number >x : number @@ -39,9 +39,9 @@ use(data[0]() === data[1]()); >data[0]() : any >data[0] : any >data : any[] ->0 : number +>0 : 0 >data[1]() : any >data[1] : any >data : any[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/localImportNameVsGlobalName.types b/tests/baselines/reference/localImportNameVsGlobalName.types index dd7f05fc8dd..d70cac65adf 100644 --- a/tests/baselines/reference/localImportNameVsGlobalName.types +++ b/tests/baselines/reference/localImportNameVsGlobalName.types @@ -4,10 +4,10 @@ module Keyboard { export enum Key { UP, DOWN, LEFT, RIGHT } >Key : Key ->UP : Key ->DOWN : Key ->LEFT : Key ->RIGHT : Key +>UP : Key.UP +>DOWN : Key.DOWN +>LEFT : Key.LEFT +>RIGHT : Key.RIGHT } module App { diff --git a/tests/baselines/reference/localTypes1.types b/tests/baselines/reference/localTypes1.types index 78e92fd8324..7ac6896b9f3 100644 --- a/tests/baselines/reference/localTypes1.types +++ b/tests/baselines/reference/localTypes1.types @@ -7,9 +7,9 @@ function f1() { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } class C { >C : C @@ -41,7 +41,7 @@ function f1() { >a[0].x : E >a[0] : I >a : I[] ->0 : number +>0 : 0 >x : E >E.B : E.B >E : typeof E @@ -61,9 +61,9 @@ function f2() { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } class C { >C : C @@ -95,7 +95,7 @@ function f2() { >a[0].x : E >a[0] : I >a : I[] ->0 : number +>0 : 0 >x : E >E.B : E.B >E : typeof E @@ -114,15 +114,15 @@ function f3(b: boolean) { >b : boolean if (true) { ->true : boolean +>true : true enum E { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } if (b) { >b : boolean @@ -157,7 +157,7 @@ function f3(b: boolean) { >a[0].x : E >a[0] : I >a : I[] ->0 : number +>0 : 0 >x : E >E.B : E.B >E : typeof E @@ -197,7 +197,7 @@ function f3(b: boolean) { >c[0].x : E >c[0] : J >c : J[] ->0 : number +>0 : 0 >x : E >E.B : E.B >E : typeof E @@ -220,9 +220,9 @@ function f5() { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } class C { >C : C @@ -243,9 +243,9 @@ function f5() { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } class C { >C : C @@ -268,9 +268,9 @@ class A { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } class C { >C : C @@ -287,9 +287,9 @@ class A { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } class C { >C : C @@ -309,9 +309,9 @@ class A { >E : E A, B, C ->A : E ->B : E ->C : E +>A : E.A +>B : E.B +>C : E.C } class C { >C : C @@ -361,25 +361,25 @@ function f6() { >C : typeof C x.a = "a"; ->x.a = "a" : string +>x.a = "a" : "a" >x.a : string >x : C >a : string ->"a" : string +>"a" : "a" x.b = "b"; ->x.b = "b" : string +>x.b = "b" : "b" >x.b : string >x : C >b : string ->"b" : string +>"b" : "b" x.c = "c"; ->x.c = "c" : string +>x.c = "c" : "c" >x.c : string >x : C >c : string ->"c" : string +>"c" : "c" return x; >x : C diff --git a/tests/baselines/reference/localTypes2.types b/tests/baselines/reference/localTypes2.types index a6b85b7bb14..e661b9fc0bf 100644 --- a/tests/baselines/reference/localTypes2.types +++ b/tests/baselines/reference/localTypes2.types @@ -24,8 +24,8 @@ function f1() { >v : C >new C(10, 20) : C >C : typeof C ->10 : number ->20 : number +>10 : 10 +>20 : 20 let x = v.x; >x : number @@ -64,13 +64,13 @@ function f2() { >C : typeof C >f(10) : typeof C >f : (x: number) => typeof C ->10 : number +>10 : 10 let v = new C(20); >v : C >new C(20) : C >C : typeof C ->20 : number +>20 : 20 let x = v.x; >x : number @@ -111,8 +111,8 @@ function f3() { >C : typeof C >f(10, 20) : typeof C >f : (x: number, y: number) => typeof C ->10 : number ->20 : number +>10 : 10 +>20 : 20 let v = new C(); >v : C diff --git a/tests/baselines/reference/localTypes3.types b/tests/baselines/reference/localTypes3.types index 551096468c5..3ce32fef9e6 100644 --- a/tests/baselines/reference/localTypes3.types +++ b/tests/baselines/reference/localTypes3.types @@ -28,8 +28,8 @@ function f1() { >v : C >new C(10, "hello") : C >C : typeof C ->10 : number ->"hello" : string +>10 : 10 +>"hello" : "hello" let x = v.x; >x : number @@ -72,13 +72,13 @@ function f2() { >C : typeof C >f(10) : typeof C >f : (x: X) => typeof C ->10 : number +>10 : 10 let v = new C("hello"); >v : f.C >new C("hello") : f.C >C : typeof C ->"hello" : string +>"hello" : "hello" let x = v.x; >x : number @@ -123,8 +123,8 @@ function f3() { >C : typeof C >f(10, "hello") : typeof C >f : (x: X, y: Y) => typeof C ->10 : number ->"hello" : string +>10 : 10 +>"hello" : "hello" let v = new C(); >v : f.C diff --git a/tests/baselines/reference/logicalAndOperatorStrictMode.types b/tests/baselines/reference/logicalAndOperatorStrictMode.types index a2321b06958..892da985120 100644 --- a/tests/baselines/reference/logicalAndOperatorStrictMode.types +++ b/tests/baselines/reference/logicalAndOperatorStrictMode.types @@ -3,19 +3,19 @@ const a = [0]; >a : number[] >[0] : number[] ->0 : number +>0 : 0 const s = ""; ->s : string ->"" : string +>s : "" +>"" : "" const x = 0; ->x : number ->0 : number +>x : 0 +>0 : 0 const b = false; ->b : boolean ->false : boolean +>b : false +>false : false const v: void = undefined; >v : void @@ -30,11 +30,11 @@ const n = null; >null : null const z = s || x || u; ->z : string | number | undefined ->s || x || u : string | number | undefined ->s || x : string | number ->s : string ->x : number +>z : undefined +>s || x || u : undefined +>s || x : 0 +>s : "" +>x : 0 >u : undefined const a1 = a && a; @@ -44,22 +44,22 @@ const a1 = a && a; >a : number[] const a2 = a && s; ->a2 : string ->a && s : string +>a2 : "" +>a && s : "" >a : number[] ->s : string +>s : "" const a3 = a && x; ->a3 : number ->a && x : number +>a3 : 0 +>a && x : 0 >a : number[] ->x : number +>x : 0 const a4 = a && b; ->a4 : boolean ->a && b : boolean +>a4 : false +>a && b : false >a : number[] ->b : boolean +>b : false const a5 = a && v; >a5 : void @@ -80,154 +80,154 @@ const a7 = a && n; >n : null const a8 = a && z; ->a8 : string | number | undefined ->a && z : string | number | undefined +>a8 : undefined +>a && z : undefined >a : number[] ->z : string | number | undefined +>z : undefined const s1 = s && a; ->s1 : "" | number[] ->s && a : "" | number[] ->s : string +>s1 : "" +>s && a : "" +>s : "" >a : number[] const s2 = s && s; ->s2 : string ->s && s : string ->s : string ->s : string +>s2 : "" +>s && s : "" +>s : "" +>s : never const s3 = s && x; ->s3 : number | "" ->s && x : number | "" ->s : string ->x : number +>s3 : "" +>s && x : "" +>s : "" +>x : 0 const s4 = s && b; ->s4 : boolean | "" ->s && b : boolean | "" ->s : string ->b : boolean +>s4 : "" +>s && b : "" +>s : "" +>b : false const s5 = s && v; ->s5 : void | "" ->s && v : void | "" ->s : string +>s5 : "" +>s && v : "" +>s : "" >v : void const s6 = s && u; ->s6 : "" | undefined ->s && u : "" | undefined ->s : string +>s6 : "" +>s && u : "" +>s : "" >u : undefined const s7 = s && n; ->s7 : "" | null ->s && n : "" | null ->s : string +>s7 : "" +>s && n : "" +>s : "" >n : null const s8 = s && z; ->s8 : string | number | undefined ->s && z : string | number | undefined ->s : string ->z : string | number | undefined +>s8 : "" +>s && z : "" +>s : "" +>z : undefined const x1 = x && a; ->x1 : 0 | number[] ->x && a : 0 | number[] ->x : number +>x1 : 0 +>x && a : 0 +>x : 0 >a : number[] const x2 = x && s; ->x2 : string | 0 ->x && s : string | 0 ->x : number ->s : string +>x2 : 0 +>x && s : 0 +>x : 0 +>s : "" const x3 = x && x; ->x3 : number ->x && x : number ->x : number ->x : number +>x3 : 0 +>x && x : 0 +>x : 0 +>x : never const x4 = x && b; ->x4 : boolean | 0 ->x && b : boolean | 0 ->x : number ->b : boolean +>x4 : 0 +>x && b : 0 +>x : 0 +>b : false const x5 = x && v; ->x5 : void | 0 ->x && v : void | 0 ->x : number +>x5 : 0 +>x && v : 0 +>x : 0 >v : void const x6 = x && u; ->x6 : 0 | undefined ->x && u : 0 | undefined ->x : number +>x6 : 0 +>x && u : 0 +>x : 0 >u : undefined const x7 = x && n; ->x7 : 0 | null ->x && n : 0 | null ->x : number +>x7 : 0 +>x && n : 0 +>x : 0 >n : null const x8 = x && z; ->x8 : string | number | undefined ->x && z : string | number | undefined ->x : number ->z : string | number | undefined +>x8 : 0 +>x && z : 0 +>x : 0 +>z : undefined const b1 = b && a; ->b1 : false | number[] ->b && a : false | number[] ->b : boolean +>b1 : false +>b && a : false +>b : false >a : number[] const b2 = b && s; ->b2 : string | false ->b && s : string | false ->b : boolean ->s : string +>b2 : false +>b && s : false +>b : false +>s : "" const b3 = b && x; ->b3 : number | false ->b && x : number | false ->b : boolean ->x : number +>b3 : false +>b && x : false +>b : false +>x : 0 const b4 = b && b; ->b4 : boolean ->b && b : boolean ->b : boolean ->b : true +>b4 : false +>b && b : false +>b : false +>b : never const b5 = b && v; ->b5 : false | void ->b && v : false | void ->b : boolean +>b5 : false +>b && v : false +>b : false >v : void const b6 = b && u; ->b6 : false | undefined ->b && u : false | undefined ->b : boolean +>b6 : false +>b && u : false +>b : false >u : undefined const b7 = b && n; ->b7 : false | null ->b && n : false | null ->b : boolean +>b7 : false +>b && n : false +>b : false >n : null const b8 = b && z; ->b8 : string | number | false | undefined ->b && z : string | number | false | undefined ->b : boolean ->z : string | number | undefined +>b8 : false +>b && z : false +>b : false +>z : undefined const v1 = v && a; >v1 : void @@ -239,19 +239,19 @@ const v2 = v && s; >v2 : void >v && s : void >v : void ->s : string +>s : "" const v3 = v && x; >v3 : void >v && x : void >v : void ->x : number +>x : 0 const v4 = v && b; >v4 : void >v && b : void >v : void ->b : boolean +>b : false const v5 = v && v; >v5 : void @@ -275,7 +275,7 @@ const v8 = v && z; >v8 : void >v && z : void >v : void ->z : string | number | undefined +>z : undefined const u1 = u && a; >u1 : undefined @@ -287,19 +287,19 @@ const u2 = u && s; >u2 : undefined >u && s : undefined >u : undefined ->s : string +>s : "" const u3 = u && x; >u3 : undefined >u && x : undefined >u : undefined ->x : number +>x : 0 const u4 = u && b; >u4 : undefined >u && b : undefined >u : undefined ->b : boolean +>b : false const u5 = u && v; >u5 : undefined @@ -323,7 +323,7 @@ const u8 = u && z; >u8 : undefined >u && z : undefined >u : undefined ->z : string | number | undefined +>z : undefined const n1 = n && a; >n1 : null @@ -335,19 +335,19 @@ const n2 = n && s; >n2 : null >n && s : null >n : null ->s : string +>s : "" const n3 = n && x; >n3 : null >n && x : null >n : null ->x : number +>x : 0 const n4 = n && b; >n4 : null >n && b : null >n : null ->b : boolean +>b : false const n5 = n && v; >n5 : null @@ -371,53 +371,53 @@ const n8 = n && z; >n8 : null >n && z : null >n : null ->z : string | number | undefined +>z : undefined const z1 = z && a; ->z1 : "" | 0 | number[] | undefined ->z && a : "" | 0 | number[] | undefined ->z : string | number | undefined +>z1 : undefined +>z && a : undefined +>z : undefined >a : number[] const z2 = z && s; ->z2 : string | 0 | undefined ->z && s : string | 0 | undefined ->z : string | number | undefined ->s : string +>z2 : undefined +>z && s : undefined +>z : undefined +>s : "" const z3 = z && x; ->z3 : number | "" | undefined ->z && x : number | "" | undefined ->z : string | number | undefined ->x : number +>z3 : undefined +>z && x : undefined +>z : undefined +>x : 0 const z4 = z && b; ->z4 : boolean | "" | 0 | undefined ->z && b : boolean | "" | 0 | undefined ->z : string | number | undefined ->b : boolean +>z4 : undefined +>z && b : undefined +>z : undefined +>b : false const z5 = z && v; ->z5 : void | "" | 0 ->z && v : void | "" | 0 ->z : string | number | undefined +>z5 : undefined +>z && v : undefined +>z : undefined >v : void const z6 = z && u; ->z6 : "" | 0 | undefined ->z && u : "" | 0 | undefined ->z : string | number | undefined +>z6 : undefined +>z && u : undefined +>z : undefined >u : undefined const z7 = z && n; ->z7 : "" | 0 | null | undefined ->z && n : "" | 0 | null | undefined ->z : string | number | undefined +>z7 : undefined +>z && n : undefined +>z : undefined >n : null const z8 = z && z; ->z8 : string | number | undefined ->z && z : string | number | undefined ->z : string | number | undefined ->z : string | number +>z8 : undefined +>z && z : undefined +>z : undefined +>z : never diff --git a/tests/baselines/reference/logicalAndOperatorWithEveryType.types b/tests/baselines/reference/logicalAndOperatorWithEveryType.types index 22187bb16a9..54770acfab4 100644 --- a/tests/baselines/reference/logicalAndOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalAndOperatorWithEveryType.types @@ -4,9 +4,9 @@ enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a1: any; >a1 : any @@ -364,7 +364,7 @@ var rf5 = a5 && a6; >a6 : E var rf6 = a6 && a6; ->rf6 : E.b | E.c +>rf6 : E >a6 && a6 : E.b | E.c >a6 : E >a6 : E.b | E.c diff --git a/tests/baselines/reference/logicalNotOperatorWithBooleanType.types b/tests/baselines/reference/logicalNotOperatorWithBooleanType.types index 63d5d38edda..93fdea731f1 100644 --- a/tests/baselines/reference/logicalNotOperatorWithBooleanType.types +++ b/tests/baselines/reference/logicalNotOperatorWithBooleanType.types @@ -15,7 +15,7 @@ class A { static foo() { return false; } >foo : () => boolean ->false : boolean +>false : false } module M { >M : typeof M @@ -39,16 +39,16 @@ var ResultIsBoolean1 = !BOOLEAN; var ResultIsBoolean2 = !true; >ResultIsBoolean2 : boolean >!true : boolean ->true : boolean +>true : true var ResultIsBoolean3 = !{ x: true, y: false }; >ResultIsBoolean3 : boolean >!{ x: true, y: false } : boolean >{ x: true, y: false } : { x: boolean; y: boolean; } >x : boolean ->true : boolean +>true : true >y : boolean ->false : boolean +>false : false // boolean type expressions var ResultIsBoolean4 = !objA.a; @@ -89,7 +89,7 @@ var ResultIsBoolean = !!BOOLEAN; // miss assignment operators !true; >!true : boolean ->true : boolean +>true : true !BOOLEAN; >!BOOLEAN : boolean @@ -101,10 +101,10 @@ var ResultIsBoolean = !!BOOLEAN; >foo : () => boolean !true, false; ->!true, false : boolean +>!true, false : false >!true : boolean ->true : boolean ->false : boolean +>true : true +>false : false !objA.a; >!objA.a : boolean diff --git a/tests/baselines/reference/logicalNotOperatorWithEnumType.types b/tests/baselines/reference/logicalNotOperatorWithEnumType.types index 5d57916ceaa..4495038eb85 100644 --- a/tests/baselines/reference/logicalNotOperatorWithEnumType.types +++ b/tests/baselines/reference/logicalNotOperatorWithEnumType.types @@ -3,9 +3,9 @@ enum ENUM { A, B, C }; >ENUM : ENUM ->A : ENUM ->B : ENUM ->C : ENUM +>A : ENUM.A +>B : ENUM.B +>C : ENUM.C enum ENUM1 { }; >ENUM1 : ENUM1 @@ -20,21 +20,21 @@ var ResultIsBoolean1 = !ENUM; var ResultIsBoolean2 = !ENUM["B"]; >ResultIsBoolean2 : boolean >!ENUM["B"] : boolean ->ENUM["B"] : ENUM +>ENUM["B"] : ENUM.B >ENUM : typeof ENUM ->"B" : string +>"B" : "B" var ResultIsBoolean3 = !(ENUM.B + ENUM["C"]); >ResultIsBoolean3 : boolean >!(ENUM.B + ENUM["C"]) : boolean >(ENUM.B + ENUM["C"]) : number >ENUM.B + ENUM["C"] : number ->ENUM.B : ENUM +>ENUM.B : ENUM.B >ENUM : typeof ENUM ->B : ENUM ->ENUM["C"] : ENUM +>B : ENUM.B +>ENUM["C"] : ENUM.C >ENUM : typeof ENUM ->"C" : string +>"C" : "C" // multiple ! operators var ResultIsBoolean4 = !!ENUM; @@ -50,12 +50,12 @@ var ResultIsBoolean5 = !!!(ENUM["B"] + ENUM.C); >!(ENUM["B"] + ENUM.C) : boolean >(ENUM["B"] + ENUM.C) : number >ENUM["B"] + ENUM.C : number ->ENUM["B"] : ENUM +>ENUM["B"] : ENUM.B >ENUM : typeof ENUM ->"B" : string ->ENUM.C : ENUM +>"B" : "B" +>ENUM.C : ENUM.C >ENUM : typeof ENUM ->C : ENUM +>C : ENUM.C // miss assignment operators !ENUM; @@ -68,9 +68,9 @@ var ResultIsBoolean5 = !!!(ENUM["B"] + ENUM.C); !ENUM.B; >!ENUM.B : boolean ->ENUM.B : ENUM +>ENUM.B : ENUM.B >ENUM : typeof ENUM ->B : ENUM +>B : ENUM.B !ENUM, ENUM1; >!ENUM, ENUM1 : typeof ENUM1 diff --git a/tests/baselines/reference/logicalNotOperatorWithNumberType.types b/tests/baselines/reference/logicalNotOperatorWithNumberType.types index 6b7ce5b6088..f66f878c3be 100644 --- a/tests/baselines/reference/logicalNotOperatorWithNumberType.types +++ b/tests/baselines/reference/logicalNotOperatorWithNumberType.types @@ -6,12 +6,12 @@ var NUMBER: number; var NUMBER1: number[] = [1, 2]; >NUMBER1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 function foo(): number { return 1; } >foo : () => number ->1 : number +>1 : 1 class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsBoolean2 = !NUMBER1; var ResultIsBoolean3 = !1; >ResultIsBoolean3 : boolean >!1 : boolean ->1 : number +>1 : 1 var ResultIsBoolean4 = !{ x: 1, y: 2}; >ResultIsBoolean4 : boolean >!{ x: 1, y: 2} : boolean >{ x: 1, y: 2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 var ResultIsBoolean5 = !{ x: 1, y: (n: number) => { return n; } }; >ResultIsBoolean5 : boolean >!{ x: 1, y: (n: number) => { return n; } } : boolean >{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; } >x : number ->1 : number +>1 : 1 >y : (n: number) => number >(n: number) => { return n; } : (n: number) => number >n : number @@ -92,7 +92,7 @@ var ResultIsBoolean8 = !NUMBER1[0]; >!NUMBER1[0] : boolean >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 var ResultIsBoolean9 = !foo(); >ResultIsBoolean9 : boolean @@ -136,7 +136,7 @@ var ResultIsBoolean13 = !!!(NUMBER + NUMBER); // miss assignment operators !1; >!1 : boolean ->1 : number +>1 : 1 !NUMBER; >!NUMBER : boolean diff --git a/tests/baselines/reference/logicalNotOperatorWithStringType.types b/tests/baselines/reference/logicalNotOperatorWithStringType.types index 5ca820ea6d0..0d3c1e88fd1 100644 --- a/tests/baselines/reference/logicalNotOperatorWithStringType.types +++ b/tests/baselines/reference/logicalNotOperatorWithStringType.types @@ -6,12 +6,12 @@ var STRING: string; var STRING1: string[] = ["", "abc"]; >STRING1 : string[] >["", "abc"] : string[] ->"" : string ->"abc" : string +>"" : "" +>"abc" : "abc" function foo(): string { return "abc"; } >foo : () => string ->"abc" : string +>"abc" : "abc" class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return ""; } >foo : () => string ->"" : string +>"" : "" } module M { >M : typeof M @@ -49,24 +49,24 @@ var ResultIsBoolean2 = !STRING1; // string type literal var ResultIsBoolean3 = !""; >ResultIsBoolean3 : boolean ->!"" : boolean ->"" : string +>!"" : true +>"" : "" var ResultIsBoolean4 = !{ x: "", y: "" }; >ResultIsBoolean4 : boolean >!{ x: "", y: "" } : boolean >{ x: "", y: "" } : { x: string; y: string; } >x : string ->"" : string +>"" : "" >y : string ->"" : string +>"" : "" var ResultIsBoolean5 = !{ x: "", y: (s: string) => { return s; } }; >ResultIsBoolean5 : boolean >!{ x: "", y: (s: string) => { return s; } } : boolean >{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; } >x : string ->"" : string +>"" : "" >y : (s: string) => string >(s: string) => { return s; } : (s: string) => string >s : string @@ -92,7 +92,7 @@ var ResultIsBoolean8 = !STRING1[0]; >!STRING1[0] : boolean >STRING1[0] : string >STRING1 : string[] ->0 : number +>0 : 0 var ResultIsBoolean9 = !foo(); >ResultIsBoolean9 : boolean @@ -123,7 +123,7 @@ var ResultIsBoolean12 = !STRING.charAt(0); >STRING.charAt : (pos: number) => string >STRING : string >charAt : (pos: number) => string ->0 : number +>0 : 0 // multiple ! operator var ResultIsBoolean13 = !!STRING; @@ -144,8 +144,8 @@ var ResultIsBoolean14 = !!!(STRING + STRING); // miss assignment operators !""; ->!"" : boolean ->"" : string +>!"" : true +>"" : "" !STRING; >!STRING : boolean diff --git a/tests/baselines/reference/logicalOrOperatorWithEveryType.types b/tests/baselines/reference/logicalOrOperatorWithEveryType.types index 8f2f4af0698..327ae64cf07 100644 --- a/tests/baselines/reference/logicalOrOperatorWithEveryType.types +++ b/tests/baselines/reference/logicalOrOperatorWithEveryType.types @@ -6,9 +6,9 @@ enum E { a, b, c } >E : E ->a : E ->b : E ->c : E +>a : E.a +>b : E.b +>c : E.c var a1: any; >a1 : any @@ -163,7 +163,7 @@ var rc1 = a1 || a3; // any || number is any >a3 : number var rc2 = a2 || a3; // boolean || number is boolean | number ->rc2 : number | true +>rc2 : number | boolean >a2 || a3 : number | true >a2 : boolean >a3 : number @@ -223,7 +223,7 @@ var rd1 = a1 || a4; // any || string is any >a4 : string var rd2 = a2 || a4; // boolean || string is boolean | string ->rd2 : string | true +>rd2 : string | boolean >a2 || a4 : string | true >a2 : boolean >a4 : string @@ -283,7 +283,7 @@ var re1 = a1 || a5; // any || void is any >a5 : void var re2 = a2 || a5; // boolean || void is boolean | void ->re2 : true | void +>re2 : boolean | void >a2 || a5 : true | void >a2 : boolean >a5 : void @@ -343,7 +343,7 @@ var rg1 = a1 || a6; // any || enum is any >a6 : E var rg2 = a2 || a6; // boolean || enum is boolean | enum ->rg2 : true | E +>rg2 : boolean | E >a2 || a6 : true | E >a2 : boolean >a6 : E @@ -403,7 +403,7 @@ var rh1 = a1 || a7; // any || object is any >a7 : { a: string; } var rh2 = a2 || a7; // boolean || object is boolean | object ->rh2 : true | { a: string; } +>rh2 : boolean | { a: string; } >a2 || a7 : true | { a: string; } >a2 : boolean >a7 : { a: string; } @@ -463,7 +463,7 @@ var ri1 = a1 || a8; // any || array is any >a8 : string[] var ri2 = a2 || a8; // boolean || array is boolean | array ->ri2 : true | string[] +>ri2 : boolean | string[] >a2 || a8 : true | string[] >a2 : boolean >a8 : string[] @@ -523,7 +523,7 @@ var rj1 = a1 || null; // any || null is any >null : null var rj2 = a2 || null; // boolean || null is boolean ->rj2 : true +>rj2 : boolean >a2 || null : true >a2 : boolean >null : null @@ -583,7 +583,7 @@ var rf1 = a1 || undefined; // any || undefined is any >undefined : undefined var rf2 = a2 || undefined; // boolean || undefined is boolean ->rf2 : true +>rf2 : boolean >a2 || undefined : true >a2 : boolean >undefined : undefined diff --git a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types index f887ad7ae14..ecd3fc52709 100644 --- a/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types +++ b/tests/baselines/reference/logicalOrOperatorWithTypeParameters.types @@ -112,7 +112,7 @@ function fn3t : T >{ a: '' } : { a: string; } >a : string ->'' : string +>'' : "" var r4: { a: string } = t || u; >r4 : { a: string; } diff --git a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt index 744ebed7d08..405fa4d2036 100644 --- a/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt +++ b/tests/baselines/reference/matchReturnTypeInAllBranches.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type 'number' is not assignable to type 'boolean'. +tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type '12345' is not assignable to type 'boolean'. ==== tests/cases/compiler/matchReturnTypeInAllBranches.ts (1 errors) ==== @@ -33,7 +33,7 @@ tests/cases/compiler/matchReturnTypeInAllBranches.ts(30,20): error TS2322: Type { return 12345; ~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. +!!! error TS2322: Type '12345' is not assignable to type 'boolean'. } } } diff --git a/tests/baselines/reference/matchingOfObjectLiteralConstraints.types b/tests/baselines/reference/matchingOfObjectLiteralConstraints.types index f694571c727..76f61c978a8 100644 --- a/tests/baselines/reference/matchingOfObjectLiteralConstraints.types +++ b/tests/baselines/reference/matchingOfObjectLiteralConstraints.types @@ -15,7 +15,7 @@ foo2({ y: "foo" }, "foo"); >foo2 : (x: U, z: T) => void >{ y: "foo" } : { y: string; } >y : string ->"foo" : string ->"foo" : string +>"foo" : "foo" +>"foo" : "foo" diff --git a/tests/baselines/reference/maxConstraints.errors.txt b/tests/baselines/reference/maxConstraints.errors.txt index a7d07a5b5f2..71f1a8b024f 100644 --- a/tests/baselines/reference/maxConstraints.errors.txt +++ b/tests/baselines/reference/maxConstraints.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. +tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type '1' is not assignable to parameter of type 'Comparable'. ==== tests/cases/compiler/maxConstraints.ts (1 errors) ==== @@ -11,4 +11,4 @@ tests/cases/compiler/maxConstraints.ts(8,22): error TS2345: Argument of type 'nu var max2: Comparer = (x, y) => { return (x.compareTo(y) > 0) ? x : y }; var maxResult = max2(1, 2); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'Comparable'. \ No newline at end of file +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'Comparable'. \ No newline at end of file diff --git a/tests/baselines/reference/memberAccessMustUseModuleInstances.types b/tests/baselines/reference/memberAccessMustUseModuleInstances.types index b1848660dac..43291fdf8ca 100644 --- a/tests/baselines/reference/memberAccessMustUseModuleInstances.types +++ b/tests/baselines/reference/memberAccessMustUseModuleInstances.types @@ -10,7 +10,7 @@ WinJS.Promise.timeout(10); >WinJS : typeof WinJS >Promise : typeof WinJS.Promise >timeout : (delay: number) => WinJS.Promise ->10 : number +>10 : 10 === tests/cases/compiler/memberAccessMustUseModuleInstances_0.ts === export class Promise { diff --git a/tests/baselines/reference/memberVariableDeclarations1.types b/tests/baselines/reference/memberVariableDeclarations1.types index 6f3a3856e1c..b0c316ced68 100644 --- a/tests/baselines/reference/memberVariableDeclarations1.types +++ b/tests/baselines/reference/memberVariableDeclarations1.types @@ -12,7 +12,7 @@ class Employee { public retired = false; >retired : boolean ->false : boolean +>false : false public manager: Employee = null; >manager : Employee diff --git a/tests/baselines/reference/mergeWithImportedNamespace.types b/tests/baselines/reference/mergeWithImportedNamespace.types index d6c1df3b609..b4cd2bf4e6d 100644 --- a/tests/baselines/reference/mergeWithImportedNamespace.types +++ b/tests/baselines/reference/mergeWithImportedNamespace.types @@ -2,7 +2,7 @@ export namespace N { export var x = 1; } >N : typeof N >x : number ->1 : number +>1 : 1 === tests/cases/compiler/f2.ts === import {N} from "./f1"; diff --git a/tests/baselines/reference/mergedDeclarations1.types b/tests/baselines/reference/mergedDeclarations1.types index 2a4f18947ce..09eaa2a7ca2 100644 --- a/tests/baselines/reference/mergedDeclarations1.types +++ b/tests/baselines/reference/mergedDeclarations1.types @@ -28,8 +28,8 @@ module point { >origin : Point >point(0, 0) : Point >point : typeof point ->0 : number ->0 : number +>0 : 0 +>0 : 0 export function equals(p1: Point, p2: Point) { >equals : (p1: Point, p2: Point) => boolean @@ -60,8 +60,8 @@ var p1 = point(0, 0); >p1 : Point >point(0, 0) : Point >point : typeof point ->0 : number ->0 : number +>0 : 0 +>0 : 0 var p2 = point.origin; >p2 : Point diff --git a/tests/baselines/reference/mergedDeclarations4.types b/tests/baselines/reference/mergedDeclarations4.types index 9c55747c6f6..4bf9f3b896e 100644 --- a/tests/baselines/reference/mergedDeclarations4.types +++ b/tests/baselines/reference/mergedDeclarations4.types @@ -30,7 +30,7 @@ module M { export var hello = 1; >hello : number ->1 : number +>1 : 1 } f(); >f() : void diff --git a/tests/baselines/reference/mergedInterfacesWithIndexers.types b/tests/baselines/reference/mergedInterfacesWithIndexers.types index b228931660a..947c47f6ed7 100644 --- a/tests/baselines/reference/mergedInterfacesWithIndexers.types +++ b/tests/baselines/reference/mergedInterfacesWithIndexers.types @@ -25,17 +25,17 @@ var r = a[1]; >r : string >a[1] : string >a : A ->1 : number +>1 : 1 var r2 = a['1']; >r2 : { length: number; } >a['1'] : { length: number; } >a : A ->'1' : string +>'1' : "1" var r3 = a['hi']; >r3 : { length: number; } >a['hi'] : { length: number; } >a : A ->'hi' : string +>'hi' : "hi" diff --git a/tests/baselines/reference/mergedModuleDeclarationWithSharedExportedVar.types b/tests/baselines/reference/mergedModuleDeclarationWithSharedExportedVar.types index 484cee0b0af..641778fe9bb 100644 --- a/tests/baselines/reference/mergedModuleDeclarationWithSharedExportedVar.types +++ b/tests/baselines/reference/mergedModuleDeclarationWithSharedExportedVar.types @@ -4,7 +4,7 @@ module M { export var v = 10; >v : number ->10 : number +>10 : 10 v; >v : number diff --git a/tests/baselines/reference/methodContainingLocalFunction.types b/tests/baselines/reference/methodContainingLocalFunction.types index 8b6d102ade8..313b457ae70 100644 --- a/tests/baselines/reference/methodContainingLocalFunction.types +++ b/tests/baselines/reference/methodContainingLocalFunction.types @@ -129,7 +129,7 @@ enum E { >localFunction : () => void return 0; ->0 : number +>0 : 0 })() } diff --git a/tests/baselines/reference/missingSemicolonInModuleSpecifier.types b/tests/baselines/reference/missingSemicolonInModuleSpecifier.types index b68c68b62e0..f7730558b68 100644 --- a/tests/baselines/reference/missingSemicolonInModuleSpecifier.types +++ b/tests/baselines/reference/missingSemicolonInModuleSpecifier.types @@ -1,16 +1,16 @@ === tests/cases/compiler/a.ts === export const x = 1; ->x : number ->1 : number +>x : 1 +>1 : 1 === tests/cases/compiler/b.ts === import {x} from "./a" ->x : number +>x : 1 (function() { return 1; }()) >(function() { return 1; }()) : number >function() { return 1; }() : number >function() { return 1; } : () => number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.types b/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.types index dfd482a6bc8..097383ee75e 100644 --- a/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.types +++ b/tests/baselines/reference/modifierOnClassDeclarationMemberInFunction.types @@ -8,7 +8,7 @@ function f() { public baz = 1; >baz : number ->1 : number +>1 : 1 static foo() { } >foo : () => void diff --git a/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.types b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.types index 87a200ee56e..4f454754b2b 100644 --- a/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.types +++ b/tests/baselines/reference/modifierOnClassExpressionMemberInFunction.types @@ -10,13 +10,13 @@ function g() { public prop1 = 1; >prop1 : number ->1 : number +>1 : 1 private foo() { } >foo : () => void static prop2 = 43; >prop2 : number ->43 : number +>43 : 43 } } diff --git a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.errors.txt b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.errors.txt index b5da9f97867..f5a8b84ac29 100644 --- a/tests/baselines/reference/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.errors.txt +++ b/tests/baselines/reference/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.ts(8,1): error TS2322: Type 'boolean' is not assignable to type 'string'. +tests/cases/compiler/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.ts(8,1): error TS2322: Type 'false' is not assignable to type 'string'. tests/cases/compiler/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6WellknownSymbolLib.ts(8,3): error TS2304: Cannot find name 'Symbol'. @@ -12,6 +12,6 @@ tests/cases/compiler/modularizeLibrary_ErrorFromUsingWellknownSymbolWithOutES6We let a = ['c', 'd']; a[Symbol.isConcatSpreadable] = false; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string'. +!!! error TS2322: Type 'false' is not assignable to type 'string'. ~~~~~~ !!! error TS2304: Cannot find name 'Symbol'. \ No newline at end of file diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types index 3851714cad8..34f51fea3f3 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions1.types @@ -18,9 +18,9 @@ function f(x: number, y: number, z: number) { f(1, 2, 3); // no error >f(1, 2, 3) : any[] >f : (x: number, y: number, z: number) => any[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 // Using ES6 collection var m = new Map(); @@ -56,12 +56,12 @@ function* gen() { let i = 0; >i : number ->0 : number +>0 : 0 while (i < 10) { >i < 10 : boolean >i : number ->10 : number +>10 : 10 yield i; >yield i : any @@ -78,12 +78,12 @@ function* gen2() { let i = 0; >i : number ->0 : number +>0 : 0 while (i < 10) { >i < 10 : boolean >i : number ->10 : number +>10 : 10 yield i; >yield i : any @@ -101,7 +101,7 @@ Math.sign(1); >Math.sign : (x: number) => number >Math : Math >sign : (x: number) => number ->1 : number +>1 : 1 // Using ES6 object var o = { @@ -110,7 +110,7 @@ var o = { a: 2, >a : number ->2 : number +>2 : 2 [Symbol.hasInstance](value: any) { >Symbol.hasInstance : symbol @@ -119,7 +119,7 @@ var o = { >value : any return false; ->false : boolean +>false : false } }; o.hasOwnProperty(Symbol.hasInstance); @@ -159,7 +159,7 @@ out().then(() => { >console.log : any >console : any >log : any ->"Yea!" : string +>"Yea!" : "Yea!" }); @@ -188,7 +188,7 @@ var reg = new RegExp("/s"); >reg : RegExp >new RegExp("/s") : RegExp >RegExp : RegExpConstructor ->"/s" : string +>"/s" : "/s" reg.flags; >reg.flags : string @@ -198,15 +198,15 @@ reg.flags; // Using ES6 string var str = "Hello world"; >str : string ->"Hello world" : string +>"Hello world" : "Hello world" str.includes("hello", 0); >str.includes("hello", 0) : boolean >str.includes : (searchString: string, position?: number) => boolean >str : string >includes : (searchString: string, position?: number) => boolean ->"hello" : string ->0 : number +>"hello" : "hello" +>0 : 0 // Using ES6 symbol var s = Symbol(); @@ -226,6 +226,6 @@ const o1 = { >value : any return false; ->false : boolean +>false : false } } diff --git a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types index f9c1894f86f..0d5847133ec 100644 --- a/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types +++ b/tests/baselines/reference/modularizeLibrary_NoErrorDuplicateLibOptions2.types @@ -18,9 +18,9 @@ function f(x: number, y: number, z: number) { f(1, 2, 3); // no error >f(1, 2, 3) : any[] >f : (x: number, y: number, z: number) => any[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 // Using ES6 collection var m = new Map(); @@ -56,12 +56,12 @@ function* gen() { let i = 0; >i : number ->0 : number +>0 : 0 while (i < 10) { >i < 10 : boolean >i : number ->10 : number +>10 : 10 yield i; >yield i : any @@ -78,12 +78,12 @@ function* gen2() { let i = 0; >i : number ->0 : number +>0 : 0 while (i < 10) { >i < 10 : boolean >i : number ->10 : number +>10 : 10 yield i; >yield i : any @@ -101,7 +101,7 @@ Math.sign(1); >Math.sign : (x: number) => number >Math : Math >sign : (x: number) => number ->1 : number +>1 : 1 // Using ES6 object var o = { @@ -110,7 +110,7 @@ var o = { a: 2, >a : number ->2 : number +>2 : 2 [Symbol.hasInstance](value: any) { >Symbol.hasInstance : symbol @@ -119,7 +119,7 @@ var o = { >value : any return false; ->false : boolean +>false : false } }; o.hasOwnProperty(Symbol.hasInstance); @@ -159,7 +159,7 @@ out().then(() => { >console.log : any >console : any >log : any ->"Yea!" : string +>"Yea!" : "Yea!" }); @@ -188,7 +188,7 @@ var reg = new RegExp("/s"); >reg : RegExp >new RegExp("/s") : RegExp >RegExp : RegExpConstructor ->"/s" : string +>"/s" : "/s" reg.flags; >reg.flags : string @@ -198,15 +198,15 @@ reg.flags; // Using ES6 string var str = "Hello world"; >str : string ->"Hello world" : string +>"Hello world" : "Hello world" str.includes("hello", 0); >str.includes("hello", 0) : boolean >str.includes : (searchString: string, position?: number) => boolean >str : string >includes : (searchString: string, position?: number) => boolean ->"hello" : string ->0 : number +>"hello" : "hello" +>0 : 0 // Using ES6 symbol var s = Symbol(); @@ -226,6 +226,6 @@ const o1 = { >value : any return false; ->false : boolean +>false : false } } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types index 8728176c2c1..12950cf56b2 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES5UsingES6Lib.types @@ -18,9 +18,9 @@ function f(x: number, y: number, z: number) { f(1, 2, 3); // no error >f(1, 2, 3) : any[] >f : (x: number, y: number, z: number) => any[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 // Using ES6 collection var m = new Map(); @@ -56,12 +56,12 @@ function* gen() { let i = 0; >i : number ->0 : number +>0 : 0 while (i < 10) { >i < 10 : boolean >i : number ->10 : number +>10 : 10 yield i; >yield i : any @@ -78,12 +78,12 @@ function* gen2() { let i = 0; >i : number ->0 : number +>0 : 0 while (i < 10) { >i < 10 : boolean >i : number ->10 : number +>10 : 10 yield i; >yield i : any @@ -101,7 +101,7 @@ Math.sign(1); >Math.sign : (x: number) => number >Math : Math >sign : (x: number) => number ->1 : number +>1 : 1 // Using ES6 object var o = { @@ -110,7 +110,7 @@ var o = { a: 2, >a : number ->2 : number +>2 : 2 [Symbol.hasInstance](value: any) { >Symbol.hasInstance : symbol @@ -119,7 +119,7 @@ var o = { >value : any return false; ->false : boolean +>false : false } }; o.hasOwnProperty(Symbol.hasInstance); @@ -159,7 +159,7 @@ out().then(() => { >console.log : any >console : any >log : any ->"Yea!" : string +>"Yea!" : "Yea!" }); @@ -188,7 +188,7 @@ var reg = new RegExp("/s"); >reg : RegExp >new RegExp("/s") : RegExp >RegExp : RegExpConstructor ->"/s" : string +>"/s" : "/s" reg.flags; >reg.flags : string @@ -198,15 +198,15 @@ reg.flags; // Using ES6 string var str = "Hello world"; >str : string ->"Hello world" : string +>"Hello world" : "Hello world" str.includes("hello", 0); >str.includes("hello", 0) : boolean >str.includes : (searchString: string, position?: number) => boolean >str : string >includes : (searchString: string, position?: number) => boolean ->"hello" : string ->0 : number +>"hello" : "hello" +>0 : 0 // Using ES6 symbol var s = Symbol(); @@ -226,6 +226,6 @@ const o1 = { >value : any return false; ->false : boolean +>false : false } } diff --git a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types index 248364f8d55..5b96ce987bc 100644 --- a/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types +++ b/tests/baselines/reference/modularizeLibrary_TargetES6UsingES6Lib.types @@ -18,9 +18,9 @@ function f(x: number, y: number, z: number) { f(1, 2, 3); // no error >f(1, 2, 3) : any[] >f : (x: number, y: number, z: number) => any[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 // Using ES6 collection var m = new Map(); @@ -56,7 +56,7 @@ Math.sign(1); >Math.sign : (x: number) => number >Math : Math >sign : (x: number) => number ->1 : number +>1 : 1 // Using ES6 object var o = { @@ -65,7 +65,7 @@ var o = { a: 2, >a : number ->2 : number +>2 : 2 [Symbol.hasInstance](value: any) { >Symbol.hasInstance : symbol @@ -74,7 +74,7 @@ var o = { >value : any return false; ->false : boolean +>false : false } }; o.hasOwnProperty(Symbol.hasInstance); @@ -111,7 +111,7 @@ var reg = new RegExp("/s"); >reg : RegExp >new RegExp("/s") : RegExp >RegExp : RegExpConstructor ->"/s" : string +>"/s" : "/s" reg.flags; >reg.flags : string @@ -121,15 +121,15 @@ reg.flags; // Using ES6 string var str = "Hello world"; >str : string ->"Hello world" : string +>"Hello world" : "Hello world" str.includes("hello", 0); >str.includes("hello", 0) : boolean >str.includes : (searchString: string, position?: number) => boolean >str : string >includes : (searchString: string, position?: number) => boolean ->"hello" : string ->0 : number +>"hello" : "hello" +>0 : 0 // Using ES6 symbol var s = Symbol(); @@ -149,6 +149,6 @@ const o1 = { >value : any return false; ->false : boolean +>false : false } } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types index d17a6fcbcbb..a097b116186 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6ArrayLib.types @@ -18,7 +18,7 @@ function f(x: number, y: number, z: number) { f(1, 2, 3); >f(1, 2, 3) : any[] >f : (x: number, y: number, z: number) => any[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types index cee8d3fb96b..cceb9a1925e 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibAndES6FeatureLibs.types @@ -28,18 +28,18 @@ function* idGen() { let i = 10; >i : number ->10 : number +>10 : 10 while (i < 20) { >i < 20 : boolean >i : number ->20 : number +>20 : 20 yield i + 2; >yield i + 2 : any >i + 2 : number >i : number ->2 : number +>2 : 2 } } diff --git a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types index 3ae08c79fd4..6accc7e7905 100644 --- a/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types +++ b/tests/baselines/reference/modularizeLibrary_UsingES5LibES6ArrayLibES6WellknownSymbolLib.types @@ -17,22 +17,22 @@ function f(x: number, y: number, z: number) { f(1, 2, 3); // no error >f(1, 2, 3) : any[] >f : (x: number, y: number, z: number) => any[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 let a = ['c', 'd']; >a : string[] >['c', 'd'] : string[] ->'c' : string ->'d' : string +>'c' : "c" +>'d' : "d" a[Symbol.isConcatSpreadable] = false; ->a[Symbol.isConcatSpreadable] = false : boolean +>a[Symbol.isConcatSpreadable] = false : false >a[Symbol.isConcatSpreadable] : any >a : string[] >Symbol.isConcatSpreadable : symbol >Symbol : SymbolConstructor >isConcatSpreadable : symbol ->false : boolean +>false : false diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types index fad835029c2..6c693b2b23b 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit1.types @@ -79,5 +79,5 @@ let y = x.map(x => x + 1); >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types index 85e4ead2ac0..ee302e6407e 100644 --- a/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types +++ b/tests/baselines/reference/moduleAugmentationDeclarationEmit2.types @@ -79,7 +79,7 @@ let y = x.map(x => x + 1); >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 let z1 = Observable.someValue.toFixed(); >z1 : string diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types index e6ee79e3585..6c2c8c8e781 100644 --- a/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule1.types @@ -20,7 +20,7 @@ let y = x.map(x => x + 1); >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 === tests/cases/compiler/map.ts === diff --git a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types index 70288e48f02..b938cf9944e 100644 --- a/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types +++ b/tests/baselines/reference/moduleAugmentationExtendAmbientModule2.types @@ -20,7 +20,7 @@ let y = x.map(x => x + 1); >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 let z1 = Observable.someValue.toFixed(); >z1 : string diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule1.types b/tests/baselines/reference/moduleAugmentationExtendFileModule1.types index fad835029c2..6c693b2b23b 100644 --- a/tests/baselines/reference/moduleAugmentationExtendFileModule1.types +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule1.types @@ -79,5 +79,5 @@ let y = x.map(x => x + 1); >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/moduleAugmentationExtendFileModule2.types b/tests/baselines/reference/moduleAugmentationExtendFileModule2.types index 85e4ead2ac0..ee302e6407e 100644 --- a/tests/baselines/reference/moduleAugmentationExtendFileModule2.types +++ b/tests/baselines/reference/moduleAugmentationExtendFileModule2.types @@ -79,7 +79,7 @@ let y = x.map(x => x + 1); >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 let z1 = Observable.someValue.toFixed(); >z1 : string diff --git a/tests/baselines/reference/moduleAugmentationGlobal1.types b/tests/baselines/reference/moduleAugmentationGlobal1.types index 9963cbe1162..48ed21e2145 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal1.types +++ b/tests/baselines/reference/moduleAugmentationGlobal1.types @@ -25,7 +25,7 @@ declare global { let x = [1]; >x : number[] >[1] : number[] ->1 : number +>1 : 1 let y = x.getA().x; >y : number diff --git a/tests/baselines/reference/moduleAugmentationGlobal2.types b/tests/baselines/reference/moduleAugmentationGlobal2.types index 96252569da6..f80f0ec7c72 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal2.types +++ b/tests/baselines/reference/moduleAugmentationGlobal2.types @@ -24,7 +24,7 @@ declare global { let x = [1]; >x : number[] >[1] : number[] ->1 : number +>1 : 1 let y = x.getCountAsString().toLowerCase(); >y : string diff --git a/tests/baselines/reference/moduleAugmentationGlobal3.types b/tests/baselines/reference/moduleAugmentationGlobal3.types index 0e8e731aec1..3b9ed24a452 100644 --- a/tests/baselines/reference/moduleAugmentationGlobal3.types +++ b/tests/baselines/reference/moduleAugmentationGlobal3.types @@ -27,7 +27,7 @@ import "./f2"; let x = [1]; >x : number[] >[1] : number[] ->1 : number +>1 : 1 let y = x.getCountAsString().toLowerCase(); >y : string diff --git a/tests/baselines/reference/moduleAugmentationInAmbientModule5.types b/tests/baselines/reference/moduleAugmentationInAmbientModule5.types index 998452be450..d6d81f97a3a 100644 --- a/tests/baselines/reference/moduleAugmentationInAmbientModule5.types +++ b/tests/baselines/reference/moduleAugmentationInAmbientModule5.types @@ -5,7 +5,7 @@ import "array"; let x = [1]; >x : number[] >[1] : number[] ->1 : number +>1 : 1 let y = x.getA().x; >y : number diff --git a/tests/baselines/reference/moduleAugmentationNoNewNames.types b/tests/baselines/reference/moduleAugmentationNoNewNames.types index 37dc54b6663..06eab66c8d1 100644 --- a/tests/baselines/reference/moduleAugmentationNoNewNames.types +++ b/tests/baselines/reference/moduleAugmentationNoNewNames.types @@ -82,5 +82,5 @@ let y = x.map(x => x + 1); >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/moduleAugmentationsBundledOutput1.types b/tests/baselines/reference/moduleAugmentationsBundledOutput1.types index 80e9127905d..c3cac91fa38 100644 --- a/tests/baselines/reference/moduleAugmentationsBundledOutput1.types +++ b/tests/baselines/reference/moduleAugmentationsBundledOutput1.types @@ -18,7 +18,7 @@ import {Cls} from "./m1"; >prototype : Cls >foo : any >function() { return 1; } : () => number ->1 : number +>1 : 1 (Cls.prototype).bar = function() { return "1"; }; >(Cls.prototype).bar = function() { return "1"; } : () => string @@ -30,7 +30,7 @@ import {Cls} from "./m1"; >prototype : Cls >bar : any >function() { return "1"; } : () => string ->"1" : string +>"1" : "1" declare module "./m1" { interface Cls { diff --git a/tests/baselines/reference/moduleCodeGenTest3.types b/tests/baselines/reference/moduleCodeGenTest3.types index 288b794326f..77c59d8fc73 100644 --- a/tests/baselines/reference/moduleCodeGenTest3.types +++ b/tests/baselines/reference/moduleCodeGenTest3.types @@ -2,12 +2,12 @@ module Baz { export var x = "hello"; } >Baz : typeof Baz >x : string ->"hello" : string +>"hello" : "hello" Baz.x = "goodbye"; ->Baz.x = "goodbye" : string +>Baz.x = "goodbye" : "goodbye" >Baz.x : string >Baz : typeof Baz >x : string ->"goodbye" : string +>"goodbye" : "goodbye" diff --git a/tests/baselines/reference/moduleCodeGenTest5.types b/tests/baselines/reference/moduleCodeGenTest5.types index c2e4ccf6d65..b49c0c895d2 100644 --- a/tests/baselines/reference/moduleCodeGenTest5.types +++ b/tests/baselines/reference/moduleCodeGenTest5.types @@ -1,11 +1,11 @@ === tests/cases/compiler/moduleCodeGenTest5.ts === export var x = 0; >x : number ->0 : number +>0 : 0 var y = 0; >y : number ->0 : number +>0 : 0 export function f1() {} >f1 : () => void @@ -18,7 +18,7 @@ export class C1 { public p1 = 0; >p1 : number ->0 : number +>0 : 0 public p2() {} >p2 : () => void @@ -28,7 +28,7 @@ class C2{ public p1 = 0; >p1 : number ->0 : number +>0 : 0 public p2() {} >p2 : () => void @@ -37,7 +37,7 @@ class C2{ export enum E1 {A=0} >E1 : E1 >A : E1 ->0 : number +>0 : 0 var u = E1.A; >u : E1 @@ -48,7 +48,7 @@ var u = E1.A; enum E2 {B=0} >E2 : E2 >B : E2 ->0 : number +>0 : 0 var v = E2.B; >v : E2 diff --git a/tests/baselines/reference/moduleCodegenTest4.types b/tests/baselines/reference/moduleCodegenTest4.types index 919432c938f..1c419e8710f 100644 --- a/tests/baselines/reference/moduleCodegenTest4.types +++ b/tests/baselines/reference/moduleCodegenTest4.types @@ -2,16 +2,16 @@ export module Baz { export var x = "hello"; } >Baz : typeof Baz >x : string ->"hello" : string +>"hello" : "hello" Baz.x = "goodbye"; ->Baz.x = "goodbye" : string +>Baz.x = "goodbye" : "goodbye" >Baz.x : string >Baz : typeof Baz >x : string ->"goodbye" : string +>"goodbye" : "goodbye" void 0; >void 0 : undefined ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/moduleIdentifiers.types b/tests/baselines/reference/moduleIdentifiers.types index dc540823815..fccf8a9a904 100644 --- a/tests/baselines/reference/moduleIdentifiers.types +++ b/tests/baselines/reference/moduleIdentifiers.types @@ -9,7 +9,7 @@ module M { export var a = 1 >a : number ->1 : number +>1 : 1 } //var p: M.P; diff --git a/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types b/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types index 733eb617c66..a9a0c4bbd5c 100644 --- a/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types +++ b/tests/baselines/reference/moduleMemberWithoutTypeAnnotation1.types @@ -75,7 +75,7 @@ module TypeScript { >findTokenInternal : (x: any, y: any, z: any) => any >null : null >position : number ->0 : number +>0 : 0 return null; >null : null diff --git a/tests/baselines/reference/moduleMerge.types b/tests/baselines/reference/moduleMerge.types index 06d532673ed..99fe3c2a7c6 100644 --- a/tests/baselines/reference/moduleMerge.types +++ b/tests/baselines/reference/moduleMerge.types @@ -11,7 +11,7 @@ module A >Hello : () => string { return "from private B"; ->"from private B" : string +>"from private B" : "from private B" } } } @@ -26,7 +26,7 @@ module A >Hello : () => string { return "from export B"; ->"from export B" : string +>"from export B" : "from export B" } } } diff --git a/tests/baselines/reference/moduleNoEmit.types b/tests/baselines/reference/moduleNoEmit.types index 1097bea5a4c..da5f58fde37 100644 --- a/tests/baselines/reference/moduleNoEmit.types +++ b/tests/baselines/reference/moduleNoEmit.types @@ -4,6 +4,6 @@ module Foo { 1+1; >1+1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 } diff --git a/tests/baselines/reference/modulePrologueAMD.types b/tests/baselines/reference/modulePrologueAMD.types index b57b5a8bf2f..f4c390ac060 100644 --- a/tests/baselines/reference/modulePrologueAMD.types +++ b/tests/baselines/reference/modulePrologueAMD.types @@ -1,6 +1,6 @@ === tests/cases/compiler/modulePrologueAMD.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" export class Foo {} >Foo : Foo diff --git a/tests/baselines/reference/modulePrologueCommonjs.types b/tests/baselines/reference/modulePrologueCommonjs.types index 5d76532b3e4..0aeaef6c38e 100644 --- a/tests/baselines/reference/modulePrologueCommonjs.types +++ b/tests/baselines/reference/modulePrologueCommonjs.types @@ -1,6 +1,6 @@ === tests/cases/compiler/modulePrologueCommonjs.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" export class Foo {} >Foo : Foo diff --git a/tests/baselines/reference/modulePrologueES6.types b/tests/baselines/reference/modulePrologueES6.types index 5f09a60ac6a..4b6a74608cb 100644 --- a/tests/baselines/reference/modulePrologueES6.types +++ b/tests/baselines/reference/modulePrologueES6.types @@ -1,6 +1,6 @@ === tests/cases/compiler/modulePrologueES6.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" export class Foo {} >Foo : Foo diff --git a/tests/baselines/reference/modulePrologueSystem.types b/tests/baselines/reference/modulePrologueSystem.types index ac0d52e4a2b..f54048b79a4 100644 --- a/tests/baselines/reference/modulePrologueSystem.types +++ b/tests/baselines/reference/modulePrologueSystem.types @@ -1,6 +1,6 @@ === tests/cases/compiler/modulePrologueSystem.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" export class Foo {} >Foo : Foo diff --git a/tests/baselines/reference/modulePrologueUmd.types b/tests/baselines/reference/modulePrologueUmd.types index 2a1064da8e2..02f90df9704 100644 --- a/tests/baselines/reference/modulePrologueUmd.types +++ b/tests/baselines/reference/modulePrologueUmd.types @@ -1,6 +1,6 @@ === tests/cases/compiler/modulePrologueUmd.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" export class Foo {} >Foo : Foo diff --git a/tests/baselines/reference/moduleResolutionNoResolve.types b/tests/baselines/reference/moduleResolutionNoResolve.types index 3e96ed2b197..dbec43bf1a2 100644 --- a/tests/baselines/reference/moduleResolutionNoResolve.types +++ b/tests/baselines/reference/moduleResolutionNoResolve.types @@ -6,5 +6,5 @@ import a = require('./b'); === tests/cases/compiler/b.ts === export var c = ''; >c : string ->'' : string +>'' : "" diff --git a/tests/baselines/reference/moduleResolutionWithExtensions.types b/tests/baselines/reference/moduleResolutionWithExtensions.types index f59eda1a81e..60196f2b25d 100644 --- a/tests/baselines/reference/moduleResolutionWithExtensions.types +++ b/tests/baselines/reference/moduleResolutionWithExtensions.types @@ -5,12 +5,12 @@ No type information for this code. No type information for this code.// No extension: '.ts' added No type information for this code.=== /src/b.ts === import a from './a'; ->a : number +>a : 0 // '.js' extension: stripped and replaced with '.ts' === /src/d.ts === import a from './a.js'; ->a : number +>a : 0 === /src/jquery.d.ts === declare var x: number; diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.types b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.types index 57be71c802b..bfeb5a14c94 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.types +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings1.types @@ -8,5 +8,5 @@ No type information for this code. No type information for this code.=== tests/cases/compiler/c.ts === export var foo = 42; >foo : number ->42 : number +>42 : 42 diff --git a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types index 600b0d946c6..1e1f0be5101 100644 --- a/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types +++ b/tests/baselines/reference/moduleSameValueDuplicateExportedBindings2.types @@ -11,9 +11,9 @@ export enum Animals { >Animals : Animals Cat, ->Cat : Animals +>Cat : Animals.Cat Dog ->Dog : Animals +>Dog : Animals.Dog }; diff --git a/tests/baselines/reference/moduleScoping.types b/tests/baselines/reference/moduleScoping.types index b2ee83dc69b..7ae2c0a2abf 100644 --- a/tests/baselines/reference/moduleScoping.types +++ b/tests/baselines/reference/moduleScoping.types @@ -1,29 +1,29 @@ === tests/cases/conformance/externalModules/file1.ts === var v1 = "sausages"; // Global scope >v1 : string ->"sausages" : string +>"sausages" : "sausages" === tests/cases/conformance/externalModules/file2.ts === var v2 = 42; // Global scope >v2 : number ->42 : number +>42 : 42 var v4 = () => 5; >v4 : () => number >() => 5 : () => number ->5 : number +>5 : 5 === tests/cases/conformance/externalModules/file3.ts === export var v3 = true; >v3 : boolean ->true : boolean +>true : true var v2 = [1,2,3]; // Module scope. Should not appear in global scope >v2 : number[] >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 === tests/cases/conformance/externalModules/file4.ts === import file3 = require('./file3'); @@ -47,7 +47,7 @@ var v4 = {a: true, b: NaN}; // Should shadow global v2 in this module >v4 : { a: boolean; b: number; } >{a: true, b: NaN} : { a: boolean; b: number; } >a : boolean ->true : boolean +>true : true >b : number >NaN : number diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.types b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.types index b473adf2aa4..865546d12fa 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.types +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt.types @@ -7,7 +7,7 @@ module Z.M { >bar : () => string return ""; ->"" : string +>"" : "" } } module A.M { diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.types b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.types index 56160637e0f..b2a3198eab8 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.types +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt2.types @@ -7,7 +7,7 @@ module Z.M { >bar : () => string return ""; ->"" : string +>"" : "" } } module A.M { diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.types b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.types index b8574a2c71f..02f47ec112b 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.types +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt4.types @@ -7,7 +7,7 @@ module Z.M { >bar : () => string return ""; ->"" : string +>"" : "" } } module A.M { diff --git a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.types b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.types index 65f820e0606..32e5cbd850e 100644 --- a/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.types +++ b/tests/baselines/reference/moduleSharesNameWithImportDeclarationInsideIt6.types @@ -7,7 +7,7 @@ module Z.M { >bar : () => string return ""; ->"" : string +>"" : "" } } module A.M { diff --git a/tests/baselines/reference/moduleUnassignedVariable.types b/tests/baselines/reference/moduleUnassignedVariable.types index 3e5ab538ad5..cfc3cb0b3d2 100644 --- a/tests/baselines/reference/moduleUnassignedVariable.types +++ b/tests/baselines/reference/moduleUnassignedVariable.types @@ -4,7 +4,7 @@ module Bar { export var a = 1; >a : number ->1 : number +>1 : 1 function fooA() { return a; } // Correct: return Bar.a >fooA : () => number diff --git a/tests/baselines/reference/moduleVariableArrayIndexer.types b/tests/baselines/reference/moduleVariableArrayIndexer.types index 4c8e73b9478..aa31ab27c6a 100644 --- a/tests/baselines/reference/moduleVariableArrayIndexer.types +++ b/tests/baselines/reference/moduleVariableArrayIndexer.types @@ -4,7 +4,7 @@ module Bar { export var a = 1; >a : number ->1 : number +>1 : 1 var t = undefined[a][a]; // CG: var t = undefined[Bar.a][a]; >t : any diff --git a/tests/baselines/reference/moduleVariables.types b/tests/baselines/reference/moduleVariables.types index 5bdf8490aed..71cd74bd078 100644 --- a/tests/baselines/reference/moduleVariables.types +++ b/tests/baselines/reference/moduleVariables.types @@ -4,14 +4,14 @@ declare var console: any; var x = 1; >x : number ->1 : number +>1 : 1 module M { >M : typeof M export var x = 2; >x : number ->2 : number +>2 : 2 console.log(x); // 2 >console.log(x) : any @@ -37,7 +37,7 @@ module M { var x = 3; >x : number ->3 : number +>3 : 3 console.log(x); // 3 >console.log(x) : any diff --git a/tests/baselines/reference/moduleVisibilityTest1.types b/tests/baselines/reference/moduleVisibilityTest1.types index b54f897d014..c8b7a1a8e31 100644 --- a/tests/baselines/reference/moduleVisibilityTest1.types +++ b/tests/baselines/reference/moduleVisibilityTest1.types @@ -6,15 +6,15 @@ module OuterMod { export function someExportedOuterFunc() { return -1; } >someExportedOuterFunc : () => number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 export module OuterInnerMod { >OuterInnerMod : typeof OuterInnerMod export function someExportedOuterInnerFunc() { return "foo"; } >someExportedOuterInnerFunc : () => string ->"foo" : string +>"foo" : "foo" } } @@ -31,26 +31,26 @@ module M { export function someExportedInnerFunc() { return -2; } >someExportedInnerFunc : () => number ->-2 : number ->2 : number +>-2 : -2 +>2 : 2 } export enum E { >E : E A, ->A : E +>A : E.A B, ->B : E +>B : E.B C, ->C : E +>C : E.C } export var x = 5; >x : number ->5 : number +>5 : 5 export declare var exported_var; >exported_var : any @@ -72,7 +72,7 @@ module M { class B {public b = 0;} >B : B >b : number ->0 : number +>0 : 0 export class C implements I { >C : C @@ -101,30 +101,30 @@ module M { public someMethod() { return 0; } >someMethod : () => number ->0 : number +>0 : 0 public someProp = 1; >someProp : number ->1 : number +>1 : 1 constructor() { function someInnerFunc() { return 2; } >someInnerFunc : () => number ->2 : number +>2 : 2 var someInnerVar = 3; >someInnerVar : number ->3 : number +>3 : 3 } } var someModuleVar = 4; >someModuleVar : number ->4 : number +>4 : 4 function someModuleFunction() { return 5;} >someModuleFunction : () => number ->5 : number +>5 : 5 } module M { @@ -136,11 +136,11 @@ module M { export var meb = M.E.B; >meb : E ->M.E.B : E +>M.E.B : E.B >M.E : typeof E >M : typeof M >E : typeof E ->B : E +>B : E.B } var cprime : M.I = null; @@ -167,11 +167,11 @@ var z = M.x; var alpha = M.E.A; >alpha : M.E ->M.E.A : M.E +>M.E.A : M.E.A >M.E : typeof M.E >M : typeof M >E : typeof M.E ->A : M.E +>A : M.E.A var omega = M.exported_var; >omega : any diff --git a/tests/baselines/reference/moduleWithStatementsOfEveryKind.types b/tests/baselines/reference/moduleWithStatementsOfEveryKind.types index c6f4be850be..6f2d5243704 100644 --- a/tests/baselines/reference/moduleWithStatementsOfEveryKind.types +++ b/tests/baselines/reference/moduleWithStatementsOfEveryKind.types @@ -40,19 +40,19 @@ module A { } enum Color { Blue, Red } >Color : Color ->Blue : Color ->Red : Color +>Blue : Color.Blue +>Red : Color.Red var x = 12; >x : number ->12 : number +>12 : 12 function F(s: string): number { >F : (s: string) => number >s : string return 2; ->2 : number +>2 : 2 } var array: I[] = null; >array : I[] @@ -66,18 +66,18 @@ module A { return 'hello ' + s; >'hello ' + s : string ->'hello ' : string +>'hello ' : "hello " >s : string } var ol = { s: 'hello', id: 2, isvalid: true }; >ol : { s: string; id: number; isvalid: boolean; } >{ s: 'hello', id: 2, isvalid: true } : { s: string; id: number; isvalid: boolean; } >s : string ->'hello' : string +>'hello' : "hello" >id : number ->2 : number +>2 : 2 >isvalid : boolean ->true : boolean +>true : true declare class DC { >DC : DC @@ -128,19 +128,19 @@ module Y { } export enum Color { Blue, Red } >Color : Color ->Blue : Color ->Red : Color +>Blue : Color.Blue +>Red : Color.Red export var x = 12; >x : number ->12 : number +>12 : 12 export function F(s: string): number { >F : (s: string) => number >s : string return 2; ->2 : number +>2 : 2 } export var array: I[] = null; >array : I[] @@ -154,18 +154,18 @@ module Y { return 'hello ' + s; >'hello ' + s : string ->'hello ' : string +>'hello ' : "hello " >s : string } export var ol = { s: 'hello', id: 2, isvalid: true }; >ol : { s: string; id: number; isvalid: boolean; } >{ s: 'hello', id: 2, isvalid: true } : { s: string; id: number; isvalid: boolean; } >s : string ->'hello' : string +>'hello' : "hello" >id : number ->2 : number +>2 : 2 >isvalid : boolean ->true : boolean +>true : true export declare class DC { >DC : DC diff --git a/tests/baselines/reference/moduledecl.types b/tests/baselines/reference/moduledecl.types index 0c117fb5184..e6382861972 100644 --- a/tests/baselines/reference/moduledecl.types +++ b/tests/baselines/reference/moduledecl.types @@ -156,7 +156,7 @@ module m1 { >d : () => string return "Hello"; ->"Hello" : string +>"Hello" : "Hello" } public e: { x: number; y: string; }; @@ -220,7 +220,7 @@ module m { var a = 10; >a : number ->10 : number +>10 : 10 export var b: number; >b : number @@ -270,7 +270,7 @@ module m13 { >f : () => number return 20; ->20 : number +>20 : 20 } } } @@ -318,14 +318,14 @@ module exportTests { >f2 : () => number return 30; ->30 : number +>30 : 30 } public f3() { >f3 : () => string return "string"; ->"string" : string +>"string" : "string" } } class C2_private { @@ -335,14 +335,14 @@ module exportTests { >f2 : () => number return 30; ->30 : number +>30 : 30 } public f3() { >f3 : () => string return "string"; ->"string" : string +>"string" : "string" } } diff --git a/tests/baselines/reference/multiModuleClodule1.types b/tests/baselines/reference/multiModuleClodule1.types index b958d18f984..86749bd1935 100644 --- a/tests/baselines/reference/multiModuleClodule1.types +++ b/tests/baselines/reference/multiModuleClodule1.types @@ -20,11 +20,11 @@ module C { export var x = 1; >x : number ->1 : number +>1 : 1 var y = 2; >y : number ->2 : number +>2 : 2 } module C { >C : typeof C @@ -34,7 +34,7 @@ module C { function baz() { return ''; } >baz : () => string ->'' : string +>'' : "" } var c = new C(C.x); diff --git a/tests/baselines/reference/multiModuleFundule1.types b/tests/baselines/reference/multiModuleFundule1.types index 7eed100c199..aed6f825a7c 100644 --- a/tests/baselines/reference/multiModuleFundule1.types +++ b/tests/baselines/reference/multiModuleFundule1.types @@ -8,7 +8,7 @@ module C { export var x = 1; >x : number ->1 : number +>1 : 1 } module C { >C : typeof C @@ -21,13 +21,13 @@ var r = C(2); >r : void >C(2) : void >C : typeof C ->2 : number +>2 : 2 var r2 = new C(2); // using void returning function as constructor >r2 : any >new C(2) : any >C : typeof C ->2 : number +>2 : 2 var r3 = C.foo(); >r3 : void diff --git a/tests/baselines/reference/multipleDeclarations.types b/tests/baselines/reference/multipleDeclarations.types index 900d03195d4..195bdc2ad0d 100644 --- a/tests/baselines/reference/multipleDeclarations.types +++ b/tests/baselines/reference/multipleDeclarations.types @@ -42,11 +42,11 @@ class X { >this : this this.mistake = 'frankly, complete nonsense'; ->this.mistake = 'frankly, complete nonsense' : string +>this.mistake = 'frankly, complete nonsense' : "frankly, complete nonsense" >this.mistake : () => void >this : this >mistake : () => void ->'frankly, complete nonsense' : string +>'frankly, complete nonsense' : "frankly, complete nonsense" } m() { >m : () => void @@ -61,13 +61,13 @@ let x = new X(); >X : typeof X X.prototype.mistake = false; ->X.prototype.mistake = false : boolean +>X.prototype.mistake = false : false >X.prototype.mistake : () => void >X.prototype : X >X : typeof X >prototype : X >mistake : () => void ->false : boolean +>false : false x.m(); >x.m() : void @@ -104,21 +104,21 @@ class Y { >this : this this.mistake = 'even more nonsense'; ->this.mistake = 'even more nonsense' : string +>this.mistake = 'even more nonsense' : "even more nonsense" >this.mistake : any >this : this >mistake : any ->'even more nonsense' : string +>'even more nonsense' : "even more nonsense" } } Y.prototype.mistake = true; ->Y.prototype.mistake = true : boolean +>Y.prototype.mistake = true : true >Y.prototype.mistake : any >Y.prototype : Y >Y : typeof Y >prototype : Y >mistake : any ->true : boolean +>true : true let y = new Y(); >y : Y diff --git a/tests/baselines/reference/nameCollision.types b/tests/baselines/reference/nameCollision.types index e8badb7ab92..cfb56fb61e9 100644 --- a/tests/baselines/reference/nameCollision.types +++ b/tests/baselines/reference/nameCollision.types @@ -6,11 +6,11 @@ module A { // in the generated function call. var A = 12; >A : number ->12 : number +>12 : 12 var _A = ''; >_A : string ->'' : string +>'' : "" } module B { @@ -18,7 +18,7 @@ module B { var A = 12; >A : number ->12 : number +>12 : 12 } module B { @@ -39,29 +39,29 @@ module X { var X = 13; >X : number ->13 : number +>13 : 13 export module Y { >Y : typeof X.Y var Y = 13; >Y : number ->13 : number +>13 : 13 export module Z { >Z : typeof X.Y.Z var X = 12; >X : number ->12 : number +>12 : 12 var Y = 12; >Y : number ->12 : number +>12 : 12 var Z = 12; >Z : number ->12 : number +>12 : 12 } } } @@ -74,8 +74,8 @@ module Y.Y { >Y : Y Red, Blue ->Red : Y ->Blue : Y +>Red : Y.Red +>Blue : Y.Blue } } @@ -93,5 +93,5 @@ module D { export var E = 'hello'; >E : string ->'hello' : string +>'hello' : "hello" } diff --git a/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.types b/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.types index 7a3c07af187..43b91520db3 100644 --- a/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.types +++ b/tests/baselines/reference/nameCollisionWithBlockScopedVariable1.types @@ -10,7 +10,7 @@ module M { { let M = 0; >M : number ->0 : number +>0 : 0 new C(); >new C() : C diff --git a/tests/baselines/reference/nameCollisionsInPropertyAssignments.types b/tests/baselines/reference/nameCollisionsInPropertyAssignments.types index bffe75896c4..d1064ea3abb 100644 --- a/tests/baselines/reference/nameCollisionsInPropertyAssignments.types +++ b/tests/baselines/reference/nameCollisionsInPropertyAssignments.types @@ -1,7 +1,7 @@ === tests/cases/compiler/nameCollisionsInPropertyAssignments.ts === var x = 1 >x : number ->1 : number +>1 : 1 var y = { x() { x++; } }; >y : { x(): void; } diff --git a/tests/baselines/reference/nameDelimitedBySlashes.types b/tests/baselines/reference/nameDelimitedBySlashes.types index 4987a52196f..03f4437ff67 100644 --- a/tests/baselines/reference/nameDelimitedBySlashes.types +++ b/tests/baselines/reference/nameDelimitedBySlashes.types @@ -8,10 +8,10 @@ var x = foo.foo + 42; >foo.foo : number >foo : typeof foo >foo : number ->42 : number +>42 : 42 === tests/cases/conformance/externalModules/test/foo_0.ts === export var foo = 42; >foo : number ->42 : number +>42 : 42 diff --git a/tests/baselines/reference/nameWithFileExtension.types b/tests/baselines/reference/nameWithFileExtension.types index a0fca3d4562..3f3e96eae1c 100644 --- a/tests/baselines/reference/nameWithFileExtension.types +++ b/tests/baselines/reference/nameWithFileExtension.types @@ -8,10 +8,10 @@ var x = foo.foo + 42; >foo.foo : number >foo : typeof foo >foo : number ->42 : number +>42 : 42 === tests/cases/conformance/externalModules/foo_0.ts === export var foo = 42; >foo : number ->42 : number +>42 : 42 diff --git a/tests/baselines/reference/nameWithRelativePaths.types b/tests/baselines/reference/nameWithRelativePaths.types index ea552cfa531..e27170e82f9 100644 --- a/tests/baselines/reference/nameWithRelativePaths.types +++ b/tests/baselines/reference/nameWithRelativePaths.types @@ -30,14 +30,14 @@ if(foo2.M2.x){ === tests/cases/conformance/externalModules/foo_0.ts === export var foo = 42; >foo : number ->42 : number +>42 : 42 === tests/cases/conformance/externalModules/test/test/foo_1.ts === export function f(){ >f : () => number return 42; ->42 : number +>42 : 42 } === tests/cases/conformance/externalModules/test/foo_2.ts === @@ -46,6 +46,6 @@ export module M2 { export var x = true; >x : boolean ->true : boolean +>true : true } diff --git a/tests/baselines/reference/namedFunctionExpressionInModule.types b/tests/baselines/reference/namedFunctionExpressionInModule.types index 8202cfbaf1b..2a361de76fb 100644 --- a/tests/baselines/reference/namedFunctionExpressionInModule.types +++ b/tests/baselines/reference/namedFunctionExpressionInModule.types @@ -13,8 +13,8 @@ module Variables{ x(1, 2, 3); >x(1, 2, 3) : void >x : (a: any, b: any, c: any) => void ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 } diff --git a/tests/baselines/reference/narrowingByDiscriminantInLoop.types b/tests/baselines/reference/narrowingByDiscriminantInLoop.types index 50f322636cc..c0f6fe73bca 100644 --- a/tests/baselines/reference/narrowingByDiscriminantInLoop.types +++ b/tests/baselines/reference/narrowingByDiscriminantInLoop.types @@ -185,7 +185,7 @@ function f1(x: A | B) { >B : B while (true) { ->true : boolean +>true : true x.prop; >x.prop : { a: string; } | { b: string; } @@ -230,7 +230,7 @@ function f2(x: A | B) { >B : B while (true) { ->true : boolean +>true : true if (x.kind) { >x.kind : boolean diff --git a/tests/baselines/reference/narrowingOfDottedNames.types b/tests/baselines/reference/narrowingOfDottedNames.types index 697e080b661..c9c3392b0c3 100644 --- a/tests/baselines/reference/narrowingOfDottedNames.types +++ b/tests/baselines/reference/narrowingOfDottedNames.types @@ -48,7 +48,7 @@ function f1(x: A | B) { >B : B while (true) { ->true : boolean +>true : true if (x instanceof A) { >x instanceof A : boolean @@ -84,7 +84,7 @@ function f2(x: A | B) { >B : B while (true) { ->true : boolean +>true : true if (isA(x)) { >isA(x) : boolean diff --git a/tests/baselines/reference/negateOperatorWithAnyOtherType.types b/tests/baselines/reference/negateOperatorWithAnyOtherType.types index f864c9d166c..75054b49573 100644 --- a/tests/baselines/reference/negateOperatorWithAnyOtherType.types +++ b/tests/baselines/reference/negateOperatorWithAnyOtherType.types @@ -10,8 +10,8 @@ var ANY1; var ANY2: any[] = ["", ""]; >ANY2 : any[] >["", ""] : string[] ->"" : string ->"" : string +>"" : "" +>"" : "" var obj: () => {} >obj : () => {} @@ -20,7 +20,7 @@ var obj1 = { x: "", y: () => { }}; >obj1 : { x: string; y: () => void; } >{ x: "", y: () => { }} : { x: string; y: () => void; } >x : string ->"" : string +>"" : "" >y : () => void >() => { } : () => void @@ -108,7 +108,7 @@ var ResultIsNumber8 = -ANY2[0]; >-ANY2[0] : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 var ResultIsNumber9 = -obj1.x; >ResultIsNumber9 : number @@ -173,7 +173,7 @@ var ResultIsNumber15 = -(ANY - ANY1); >-ANY2[0] : number >ANY2[0] : any >ANY2 : any[] ->0 : number +>0 : 0 -ANY, ANY1; >-ANY, ANY1 : any diff --git a/tests/baselines/reference/negateOperatorWithBooleanType.types b/tests/baselines/reference/negateOperatorWithBooleanType.types index bd61a560898..ca383455ec8 100644 --- a/tests/baselines/reference/negateOperatorWithBooleanType.types +++ b/tests/baselines/reference/negateOperatorWithBooleanType.types @@ -15,7 +15,7 @@ class A { static foo() { return false; } >foo : () => boolean ->false : boolean +>false : false } module M { >M : typeof M @@ -39,16 +39,16 @@ var ResultIsNumber1 = -BOOLEAN; var ResultIsNumber2 = -true; >ResultIsNumber2 : number >-true : number ->true : boolean +>true : true var ResultIsNumber3 = -{ x: true, y: false }; >ResultIsNumber3 : number >-{ x: true, y: false } : number >{ x: true, y: false } : { x: boolean; y: boolean; } >x : boolean ->true : boolean +>true : true >y : boolean ->false : boolean +>false : false // boolean type expressions var ResultIsNumber4 = -objA.a; @@ -82,7 +82,7 @@ var ResultIsNumber7 = -A.foo(); // miss assignment operators -true; >-true : number ->true : boolean +>true : true -BOOLEAN; >-BOOLEAN : number @@ -94,10 +94,10 @@ var ResultIsNumber7 = -A.foo(); >foo : () => boolean -true, false; ->-true, false : boolean +>-true, false : false >-true : number ->true : boolean ->false : boolean +>true : true +>false : false -objA.a; >-objA.a : number diff --git a/tests/baselines/reference/negateOperatorWithEnumType.types b/tests/baselines/reference/negateOperatorWithEnumType.types index 2f39a581ef8..d49f01c7f0d 100644 --- a/tests/baselines/reference/negateOperatorWithEnumType.types +++ b/tests/baselines/reference/negateOperatorWithEnumType.types @@ -6,8 +6,8 @@ enum ENUM { }; enum ENUM1 { A, B, "" }; >ENUM1 : ENUM1 ->A : ENUM1 ->B : ENUM1 +>A : ENUM1.A +>B : ENUM1.B // enum type var var ResultIsNumber1 = -ENUM; @@ -19,21 +19,21 @@ var ResultIsNumber1 = -ENUM; var ResultIsNumber2 = -ENUM1["B"]; >ResultIsNumber2 : number >-ENUM1["B"] : number ->ENUM1["B"] : ENUM1 +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" var ResultIsNumber3 = -(ENUM1.B + ENUM1[""]); >ResultIsNumber3 : number >-(ENUM1.B + ENUM1[""]) : number >(ENUM1.B + ENUM1[""]) : number >ENUM1.B + ENUM1[""] : number ->ENUM1.B : ENUM1 +>ENUM1.B : ENUM1.B >ENUM1 : typeof ENUM1 ->B : ENUM1 ->ENUM1[""] : ENUM1 +>B : ENUM1.B +>ENUM1[""] : ENUM1."" >ENUM1 : typeof ENUM1 ->"" : string +>"" : "" // miss assignment operators -ENUM; @@ -46,9 +46,9 @@ var ResultIsNumber3 = -(ENUM1.B + ENUM1[""]); -ENUM1["B"]; >-ENUM1["B"] : number ->ENUM1["B"] : ENUM1 +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" -ENUM, ENUM1; >-ENUM, ENUM1 : typeof ENUM1 diff --git a/tests/baselines/reference/negateOperatorWithNumberType.types b/tests/baselines/reference/negateOperatorWithNumberType.types index e53a4e54444..d3d9b474637 100644 --- a/tests/baselines/reference/negateOperatorWithNumberType.types +++ b/tests/baselines/reference/negateOperatorWithNumberType.types @@ -6,12 +6,12 @@ var NUMBER: number; var NUMBER1: number[] = [1, 2]; >NUMBER1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 function foo(): number { return 1; } >foo : () => number ->1 : number +>1 : 1 class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } module M { >M : typeof M @@ -49,24 +49,24 @@ var ResultIsNumber2 = -NUMBER1; // number type literal var ResultIsNumber3 = -1; >ResultIsNumber3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 var ResultIsNumber4 = -{ x: 1, y: 2}; >ResultIsNumber4 : number >-{ x: 1, y: 2} : number >{ x: 1, y: 2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 var ResultIsNumber5 = -{ x: 1, y: (n: number) => { return n; } }; >ResultIsNumber5 : number >-{ x: 1, y: (n: number) => { return n; } } : number >{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; } >x : number ->1 : number +>1 : 1 >y : (n: number) => number >(n: number) => { return n; } : (n: number) => number >n : number @@ -92,7 +92,7 @@ var ResultIsNumber8 = -NUMBER1[0]; >-NUMBER1[0] : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 var ResultIsNumber9 = -foo(); >ResultIsNumber9 : number @@ -118,8 +118,8 @@ var ResultIsNumber11 = -(NUMBER - NUMBER); // miss assignment operators -1; ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 -NUMBER; >-NUMBER : number diff --git a/tests/baselines/reference/negateOperatorWithStringType.types b/tests/baselines/reference/negateOperatorWithStringType.types index 6ef570557fe..053fd113801 100644 --- a/tests/baselines/reference/negateOperatorWithStringType.types +++ b/tests/baselines/reference/negateOperatorWithStringType.types @@ -6,12 +6,12 @@ var STRING: string; var STRING1: string[] = ["", "abc"]; >STRING1 : string[] >["", "abc"] : string[] ->"" : string ->"abc" : string +>"" : "" +>"abc" : "abc" function foo(): string { return "abc"; } >foo : () => string ->"abc" : string +>"abc" : "abc" class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return ""; } >foo : () => string ->"" : string +>"" : "" } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsNumber2 = -STRING1; var ResultIsNumber3 = -""; >ResultIsNumber3 : number >-"" : number ->"" : string +>"" : "" var ResultIsNumber4 = -{ x: "", y: "" }; >ResultIsNumber4 : number >-{ x: "", y: "" } : number >{ x: "", y: "" } : { x: string; y: string; } >x : string ->"" : string +>"" : "" >y : string ->"" : string +>"" : "" var ResultIsNumber5 = -{ x: "", y: (s: string) => { return s; } }; >ResultIsNumber5 : number >-{ x: "", y: (s: string) => { return s; } } : number >{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; } >x : string ->"" : string +>"" : "" >y : (s: string) => string >(s: string) => { return s; } : (s: string) => string >s : string @@ -92,7 +92,7 @@ var ResultIsNumber8 = -STRING1[0]; >-STRING1[0] : number >STRING1[0] : string >STRING1 : string[] ->0 : number +>0 : 0 var ResultIsNumber9 = -foo(); >ResultIsNumber9 : number @@ -123,12 +123,12 @@ var ResultIsNumber12 = -STRING.charAt(0); >STRING.charAt : (pos: number) => string >STRING : string >charAt : (pos: number) => string ->0 : number +>0 : 0 // miss assignment operators -""; >-"" : number ->"" : string +>"" : "" -STRING; >-STRING : number diff --git a/tests/baselines/reference/negativeZero.types b/tests/baselines/reference/negativeZero.types index 3468e22fdb2..114dc337927 100644 --- a/tests/baselines/reference/negativeZero.types +++ b/tests/baselines/reference/negativeZero.types @@ -1,6 +1,6 @@ === tests/cases/compiler/negativeZero.ts === var x = -0 >x : number ->-0 : number ->0 : number +>-0 : 0 +>0 : 0 diff --git a/tests/baselines/reference/nestedBlockScopedBindings1.types b/tests/baselines/reference/nestedBlockScopedBindings1.types index e192b0748a5..1812d54e370 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings1.types +++ b/tests/baselines/reference/nestedBlockScopedBindings1.types @@ -4,12 +4,12 @@ function a0() { { let x = 1; >x : number ->1 : number +>1 : 1 } { let x = 1; >x : number ->1 : number +>1 : 1 } } @@ -22,7 +22,7 @@ function a1() { { let x = 1; >x : number ->1 : number +>1 : 1 } } @@ -31,7 +31,7 @@ function a2() { { let x = 1; >x : number ->1 : number +>1 : 1 } { let x; @@ -44,10 +44,10 @@ function a3() { { let x = 1; >x : number ->1 : number +>1 : 1 } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -67,14 +67,14 @@ function a4() { >x : any } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 let x = 1; >x : number ->1 : number +>1 : 1 break; } diff --git a/tests/baselines/reference/nestedBlockScopedBindings10.types b/tests/baselines/reference/nestedBlockScopedBindings10.types index 747f2ef1f2b..d002a4f8cb4 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings10.types +++ b/tests/baselines/reference/nestedBlockScopedBindings10.types @@ -4,13 +4,13 @@ >x : any x = 1; ->x = 1 : number +>x = 1 : 1 >x : any ->1 : number +>1 : 1 } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -19,9 +19,9 @@ switch (1) { >y : any y = 1; ->y = 1 : number +>y = 1 : 1 >y : any ->1 : number +>1 : 1 break; } diff --git a/tests/baselines/reference/nestedBlockScopedBindings11.types b/tests/baselines/reference/nestedBlockScopedBindings11.types index 4d1914d6f1a..ed356c53ad9 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings11.types +++ b/tests/baselines/reference/nestedBlockScopedBindings11.types @@ -14,7 +14,7 @@ var y; >y : any switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 diff --git a/tests/baselines/reference/nestedBlockScopedBindings12.types b/tests/baselines/reference/nestedBlockScopedBindings12.types index ec75d16a37f..1ac7dc39bf0 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings12.types +++ b/tests/baselines/reference/nestedBlockScopedBindings12.types @@ -6,16 +6,16 @@ var x; >x : any x = 1; ->x = 1 : number +>x = 1 : 1 >x : any ->1 : number +>1 : 1 } var y; >y : any switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -24,9 +24,9 @@ switch (1) { >y : any y = 1; ->y = 1 : number +>y = 1 : 1 >y : any ->1 : number +>1 : 1 break; } diff --git a/tests/baselines/reference/nestedBlockScopedBindings2.types b/tests/baselines/reference/nestedBlockScopedBindings2.types index 3e7dbe4b757..2a7d077ad71 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings2.types +++ b/tests/baselines/reference/nestedBlockScopedBindings2.types @@ -4,7 +4,7 @@ function a0() { { let x = 1; >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number @@ -13,7 +13,7 @@ function a0() { { let x = 1; >x : number ->1 : number +>1 : 1 } } @@ -26,7 +26,7 @@ function a1() { { let x = 1; >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number @@ -39,7 +39,7 @@ function a2() { { let x = 1; >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number @@ -61,14 +61,14 @@ function a3() { { let x = 1; >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number >x : number } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -92,7 +92,7 @@ function a4() { >x : any } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -120,7 +120,7 @@ function a5() { >x : any } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -136,7 +136,7 @@ function a6() { >a6 : () => void switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -147,7 +147,7 @@ function a6() { break; } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -163,7 +163,7 @@ function a7() { >a7 : () => void switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -178,7 +178,7 @@ function a7() { break; } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -194,7 +194,7 @@ function a8() { >a8 : () => void switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -205,7 +205,7 @@ function a8() { break; } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -225,7 +225,7 @@ function a9() { >a9 : () => void switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -240,7 +240,7 @@ function a9() { break; } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 diff --git a/tests/baselines/reference/nestedBlockScopedBindings3.types b/tests/baselines/reference/nestedBlockScopedBindings3.types index e10cffb7123..0de8123861d 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings3.types +++ b/tests/baselines/reference/nestedBlockScopedBindings3.types @@ -4,10 +4,10 @@ function a0() { { for (let x = 0; x < 1; ) { >x : number ->0 : number +>0 : 0 >x < 1 : boolean >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number @@ -32,7 +32,7 @@ function a1() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 () => x; >() => x : () => any @@ -54,14 +54,14 @@ function a2() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : any >x : any >x + 1 : any >x : any ->1 : number +>1 : 1 } for (let x;;) { >x : any @@ -71,7 +71,7 @@ function a2() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 } } @@ -83,17 +83,17 @@ function a3() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : any >x : any >x + 1 : any >x : any ->1 : number +>1 : 1 } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -112,21 +112,21 @@ function a4() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : any >x : any >x + 1 : any >x : any ->1 : number +>1 : 1 () => x; >() => x : () => any >x : any } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -146,21 +146,21 @@ function a5() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : any >x : any >x + 1 : any >x : any ->1 : number +>1 : 1 () => x; >() => x : () => any >x : any } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 diff --git a/tests/baselines/reference/nestedBlockScopedBindings4.types b/tests/baselines/reference/nestedBlockScopedBindings4.types index b38d61f3f44..65b5d73db9d 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings4.types +++ b/tests/baselines/reference/nestedBlockScopedBindings4.types @@ -6,14 +6,14 @@ function a0() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : any >x : any >x + 1 : any >x : any ->1 : number +>1 : 1 } for (let x;;) { >x : any @@ -23,7 +23,7 @@ function a0() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 } } @@ -34,14 +34,14 @@ function a1() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : any >x : any >x + 1 : any >x : any ->1 : number +>1 : 1 () => x; >() => x : () => any @@ -55,7 +55,7 @@ function a1() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 } } @@ -66,14 +66,14 @@ function a2() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : any >x : any >x + 1 : any >x : any ->1 : number +>1 : 1 } for (let x;;) { >x : any @@ -83,7 +83,7 @@ function a2() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 () => x; >() => x : () => any @@ -99,14 +99,14 @@ function a3() { >x : any >x < 1 : boolean >x : any ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : any >x : any >x + 1 : any >x : any ->1 : number +>1 : 1 () => x; >() => x : () => any @@ -120,7 +120,7 @@ function a3() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 () => x; >() => x : () => any diff --git a/tests/baselines/reference/nestedBlockScopedBindings6.types b/tests/baselines/reference/nestedBlockScopedBindings6.types index fa4fa5ec695..865dea31e37 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings6.types +++ b/tests/baselines/reference/nestedBlockScopedBindings6.types @@ -5,14 +5,14 @@ function a0() { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : number >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 } for (let x;;) { >x : any @@ -22,7 +22,7 @@ function a0() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 } } @@ -32,14 +32,14 @@ function a1() { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : number >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number @@ -53,7 +53,7 @@ function a1() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 } } @@ -63,14 +63,14 @@ function a2() { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : number >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 } for (let x;;) { >x : any @@ -80,7 +80,7 @@ function a2() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 () => x; >() => x : () => any @@ -94,14 +94,14 @@ function a3() { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : number >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number @@ -115,7 +115,7 @@ function a3() { >x : any >x + 2 : any >x : any ->2 : number +>2 : 2 () => x; >() => x : () => any @@ -129,21 +129,21 @@ function a4() { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : number >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number >x : number } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -162,17 +162,17 @@ function a5() { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : number >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -194,17 +194,17 @@ function a6() { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : number >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 @@ -222,21 +222,21 @@ function a7() { for (let x of [1]) { >x : number >[1] : number[] ->1 : number +>1 : 1 x = x + 1; >x = x + 1 : number >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 () => x; >() => x : () => number >x : number } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 diff --git a/tests/baselines/reference/nestedBlockScopedBindings9.types b/tests/baselines/reference/nestedBlockScopedBindings9.types index e27254717fa..0aa2ecaa9d7 100644 --- a/tests/baselines/reference/nestedBlockScopedBindings9.types +++ b/tests/baselines/reference/nestedBlockScopedBindings9.types @@ -9,7 +9,7 @@ } switch (1) { ->1 : number +>1 : 1 case 1: >1 : 1 diff --git a/tests/baselines/reference/nestedIfStatement.types b/tests/baselines/reference/nestedIfStatement.types index 19799d25172..d6ea5b80b4f 100644 --- a/tests/baselines/reference/nestedIfStatement.types +++ b/tests/baselines/reference/nestedIfStatement.types @@ -1,15 +1,15 @@ === tests/cases/compiler/nestedIfStatement.ts === if (0) { ->0 : number +>0 : 0 } else if (1) { ->1 : number +>1 : 1 } else if (2) { ->2 : number +>2 : 2 } else if (3) { ->3 : number +>3 : 3 } else { } diff --git a/tests/baselines/reference/nestedLoopTypeGuards.types b/tests/baselines/reference/nestedLoopTypeGuards.types index 9611fba2fbf..9d7b793badf 100644 --- a/tests/baselines/reference/nestedLoopTypeGuards.types +++ b/tests/baselines/reference/nestedLoopTypeGuards.types @@ -16,19 +16,19 @@ function f1() { // a is narrowed to "number | string" for (var i = 0; i < 1; i++) { >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number for (var j = 0; j < 1; j++) {} >j : number ->0 : number +>0 : 0 >j < 1 : boolean >j : number ->1 : number +>1 : 1 >j++ : number >j : number @@ -41,10 +41,10 @@ function f1() { // a is narrowed to "string' for (var j = 0; j < 1; j++) { >j : number ->0 : number +>0 : 0 >j < 1 : boolean >j : number ->1 : number +>1 : 1 >j++ : number >j : number @@ -71,10 +71,10 @@ function f2() { >'string' : "string" while (1) { ->1 : number +>1 : 1 while (1) {} ->1 : number +>1 : 1 if (typeof a === 'string') { >typeof a === 'string' : boolean @@ -83,7 +83,7 @@ function f2() { >'string' : "string" while (1) { ->1 : number +>1 : 1 a.length; // Should not error here >a.length : number diff --git a/tests/baselines/reference/nestedModules.types b/tests/baselines/reference/nestedModules.types index eee3ee3968a..95f6ae40669 100644 --- a/tests/baselines/reference/nestedModules.types +++ b/tests/baselines/reference/nestedModules.types @@ -27,9 +27,9 @@ module A { >Point : C.Point >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/nestedRedeclarationInES6AMD.types b/tests/baselines/reference/nestedRedeclarationInES6AMD.types index 2b8d971e3c1..ebc93abd3af 100644 --- a/tests/baselines/reference/nestedRedeclarationInES6AMD.types +++ b/tests/baselines/reference/nestedRedeclarationInES6AMD.types @@ -4,11 +4,11 @@ function a() { { let status = 1; >status : number ->1 : number +>1 : 1 status = 2; ->status = 2 : number +>status = 2 : 2 >status : number ->2 : number +>2 : 2 } } diff --git a/tests/baselines/reference/nestedSelf.types b/tests/baselines/reference/nestedSelf.types index ed7f084246a..9fb4b0bd65d 100644 --- a/tests/baselines/reference/nestedSelf.types +++ b/tests/baselines/reference/nestedSelf.types @@ -7,16 +7,16 @@ module M { public n = 42; >n : number ->42 : number +>42 : 42 public foo() { [1,2,3].map((x) => { return this.n * x; })} >foo : () => void >[1,2,3].map((x) => { return this.n * x; }) : number[] >[1,2,3].map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >map : (callbackfn: (value: number, index: number, array: number[]) => U, thisArg?: any) => U[] >(x) => { return this.n * x; } : (x: number) => number >x : number diff --git a/tests/baselines/reference/neverType.js b/tests/baselines/reference/neverType.js index 56a1373903e..a1e4c71f803 100644 --- a/tests/baselines/reference/neverType.js +++ b/tests/baselines/reference/neverType.js @@ -180,8 +180,8 @@ declare function fail(): never; declare function failOrThrow(shouldFail: boolean): never; declare function infiniteLoop1(): void; declare function infiniteLoop2(): never; -declare function move1(direction: "up" | "down"): number; -declare function move2(direction: "up" | "down"): number; +declare function move1(direction: "up" | "down"): 1 | -1; +declare function move2(direction: "up" | "down"): 1 | -1; declare function check(x: T | undefined): T; declare class C { void1(): void; diff --git a/tests/baselines/reference/neverType.types b/tests/baselines/reference/neverType.types index 72d8eae6b3b..69a2c4c7dfe 100644 --- a/tests/baselines/reference/neverType.types +++ b/tests/baselines/reference/neverType.types @@ -27,7 +27,7 @@ function fail() { return error("Something failed"); >error("Something failed") : never >error : (message: string) => never ->"Something failed" : string +>"Something failed" : "Something failed" } function failOrThrow(shouldFail: boolean) { @@ -50,7 +50,7 @@ function infiniteLoop1() { >infiniteLoop1 : () => void while (true) { ->true : boolean +>true : true } } @@ -58,12 +58,12 @@ function infiniteLoop2(): never { >infiniteLoop2 : () => never while (true) { ->true : boolean +>true : true } } function move1(direction: "up" | "down") { ->move1 : (direction: "up" | "down") => number +>move1 : (direction: "up" | "down") => 1 | -1 >direction : "up" | "down" switch (direction) { @@ -73,44 +73,44 @@ function move1(direction: "up" | "down") { >"up" : "up" return 1; ->1 : number +>1 : 1 case "down": >"down" : "down" return -1; ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 } return error("Should never get here"); >error("Should never get here") : never >error : (message: string) => never ->"Should never get here" : string +>"Should never get here" : "Should never get here" } function move2(direction: "up" | "down") { ->move2 : (direction: "up" | "down") => number +>move2 : (direction: "up" | "down") => 1 | -1 >direction : "up" | "down" return direction === "up" ? 1 : ->direction === "up" ? 1 : direction === "down" ? -1 : error("Should never get here") : number +>direction === "up" ? 1 : direction === "down" ? -1 : error("Should never get here") : 1 | -1 >direction === "up" : boolean >direction : "up" | "down" >"up" : "up" ->1 : number +>1 : 1 direction === "down" ? -1 : ->direction === "down" ? -1 : error("Should never get here") : number +>direction === "down" ? -1 : error("Should never get here") : -1 >direction === "down" : boolean >direction : "down" >"down" : "down" ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 error("Should never get here"); >error("Should never get here") : never >error : (message: string) => never ->"Should never get here" : string +>"Should never get here" : "Should never get here" } function check(x: T | undefined) { @@ -124,7 +124,7 @@ function check(x: T | undefined) { >x : T | undefined >error("Undefined value") : never >error : (message: string) => never ->"Undefined value" : string +>"Undefined value" : "Undefined value" } class C { @@ -141,7 +141,7 @@ class C { >void2 : () => void while (true) {} ->true : boolean +>true : true } never1(): never { >never1 : () => never @@ -154,7 +154,7 @@ class C { >never2 : () => never while (true) {} ->true : boolean +>true : true } } @@ -178,7 +178,7 @@ function f2(x: string | number) { >x : string | number while (true) { ->true : boolean +>true : true if (typeof x === "boolean") { >typeof x === "boolean" : boolean @@ -210,13 +210,13 @@ let errorCallback = () => error("Error callback"); >() => error("Error callback") : () => never >error("Error callback") : never >error : (message: string) => never ->"Error callback" : string +>"Error callback" : "Error callback" test(() => "hello"); >test(() => "hello") : string >test : (cb: () => string) => string ->() => "hello" : () => string ->"hello" : string +>() => "hello" : () => "hello" +>"hello" : "hello" test(() => fail()); >test(() => fail()) : string diff --git a/tests/baselines/reference/neverTypeErrors1.errors.txt b/tests/baselines/reference/neverTypeErrors1.errors.txt index 8fd6f9c924e..cb79c0c19fb 100644 --- a/tests/baselines/reference/neverTypeErrors1.errors.txt +++ b/tests/baselines/reference/neverTypeErrors1.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/types/never/neverTypeErrors1.ts(3,5): error TS2322: Type 'number' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors1.ts(4,5): error TS2322: Type 'string' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors1.ts(5,5): error TS2322: Type 'boolean' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors1.ts(3,5): error TS2322: Type '1' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors1.ts(4,5): error TS2322: Type '"abc"' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors1.ts(5,5): error TS2322: Type 'false' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(6,5): error TS2322: Type 'undefined' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(7,5): error TS2322: Type 'null' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(8,5): error TS2322: Type '{}' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(12,5): error TS2322: Type 'undefined' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors1.ts(16,12): error TS2322: Type 'number' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors1.ts(16,12): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -14,13 +14,13 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A let x: never; x = 1; ~ -!!! error TS2322: Type 'number' is not assignable to type 'never'. +!!! error TS2322: Type '1' is not assignable to type 'never'. x = "abc"; ~ -!!! error TS2322: Type 'string' is not assignable to type 'never'. +!!! error TS2322: Type '"abc"' is not assignable to type 'never'. x = false; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'never'. +!!! error TS2322: Type 'false' is not assignable to type 'never'. x = undefined; ~ !!! error TS2322: Type 'undefined' is not assignable to type 'never'. @@ -41,7 +41,7 @@ tests/cases/conformance/types/never/neverTypeErrors1.ts(19,16): error TS2534: A function f3(): never { return 1; ~ -!!! error TS2322: Type 'number' is not assignable to type 'never'. +!!! error TS2322: Type '1' is not assignable to type 'never'. } function f4(): never { diff --git a/tests/baselines/reference/neverTypeErrors2.errors.txt b/tests/baselines/reference/neverTypeErrors2.errors.txt index c6292657ad1..ed27e615ea1 100644 --- a/tests/baselines/reference/neverTypeErrors2.errors.txt +++ b/tests/baselines/reference/neverTypeErrors2.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/types/never/neverTypeErrors2.ts(4,5): error TS2322: Type 'number' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors2.ts(5,5): error TS2322: Type 'string' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors2.ts(6,5): error TS2322: Type 'boolean' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors2.ts(4,5): error TS2322: Type '1' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors2.ts(5,5): error TS2322: Type '"abc"' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors2.ts(6,5): error TS2322: Type 'false' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(7,5): error TS2322: Type 'undefined' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(8,5): error TS2322: Type 'null' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(9,5): error TS2322: Type '{}' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(13,5): error TS2322: Type 'undefined' is not assignable to type 'never'. -tests/cases/conformance/types/never/neverTypeErrors2.ts(17,12): error TS2322: Type 'number' is not assignable to type 'never'. +tests/cases/conformance/types/never/neverTypeErrors2.ts(17,12): error TS2322: Type '1' is not assignable to type 'never'. tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function returning 'never' cannot have a reachable end point. @@ -15,13 +15,13 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A let x: never; x = 1; ~ -!!! error TS2322: Type 'number' is not assignable to type 'never'. +!!! error TS2322: Type '1' is not assignable to type 'never'. x = "abc"; ~ -!!! error TS2322: Type 'string' is not assignable to type 'never'. +!!! error TS2322: Type '"abc"' is not assignable to type 'never'. x = false; ~ -!!! error TS2322: Type 'boolean' is not assignable to type 'never'. +!!! error TS2322: Type 'false' is not assignable to type 'never'. x = undefined; ~ !!! error TS2322: Type 'undefined' is not assignable to type 'never'. @@ -42,7 +42,7 @@ tests/cases/conformance/types/never/neverTypeErrors2.ts(20,16): error TS2534: A function f3(): never { return 1; ~ -!!! error TS2322: Type 'number' is not assignable to type 'never'. +!!! error TS2322: Type '1' is not assignable to type 'never'. } function f4(): never { diff --git a/tests/baselines/reference/newArrays.types b/tests/baselines/reference/newArrays.types index 3c0928a46ea..7676b9b14f7 100644 --- a/tests/baselines/reference/newArrays.types +++ b/tests/baselines/reference/newArrays.types @@ -14,11 +14,11 @@ module M { public x = 10; >x : number ->10 : number +>10 : 10 public y = 10; >y : number ->10 : number +>10 : 10 public m () { >m : () => void diff --git a/tests/baselines/reference/newExpressionWithTypeParameterConstrainedToOuterTypeParameter.types b/tests/baselines/reference/newExpressionWithTypeParameterConstrainedToOuterTypeParameter.types index 6d541198802..badd17765b8 100644 --- a/tests/baselines/reference/newExpressionWithTypeParameterConstrainedToOuterTypeParameter.types +++ b/tests/baselines/reference/newExpressionWithTypeParameterConstrainedToOuterTypeParameter.types @@ -15,7 +15,7 @@ var i: I; >I : I var y = new i(""); // y should be string ->y : "" +>y : string >new i("") : "" >i : I >"" : "" diff --git a/tests/baselines/reference/newLineFlagWithCRLF.types b/tests/baselines/reference/newLineFlagWithCRLF.types index 4898d2495b2..fc8caa2c324 100644 --- a/tests/baselines/reference/newLineFlagWithCRLF.types +++ b/tests/baselines/reference/newLineFlagWithCRLF.types @@ -1,11 +1,11 @@ === tests/cases/compiler/newLineFlagWithCRLF.ts === var x=1; >x : number ->1 : number +>1 : 1 x=2; ->x=2 : number +>x=2 : 2 >x : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/newLineFlagWithLF.types b/tests/baselines/reference/newLineFlagWithLF.types index bfdf6072e0e..e16a15282a0 100644 --- a/tests/baselines/reference/newLineFlagWithLF.types +++ b/tests/baselines/reference/newLineFlagWithLF.types @@ -1,11 +1,11 @@ === tests/cases/compiler/newLineFlagWithLF.ts === var x=1; >x : number ->1 : number +>1 : 1 x=2; ->x=2 : number +>x=2 : 2 >x : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/newOperatorConformance.types b/tests/baselines/reference/newOperatorConformance.types index 912c0a5c81a..c7fb0125a1a 100644 --- a/tests/baselines/reference/newOperatorConformance.types +++ b/tests/baselines/reference/newOperatorConformance.types @@ -110,7 +110,7 @@ function newFn2(s: T) { >p : string >new s(32) : string >s : T ->32 : number +>32 : 32 var p: string; >p : string diff --git a/tests/baselines/reference/newWithSpreadES5.types b/tests/baselines/reference/newWithSpreadES5.types index a2c83ed6372..dfa45b33ee1 100644 --- a/tests/baselines/reference/newWithSpreadES5.types +++ b/tests/baselines/reference/newWithSpreadES5.types @@ -84,26 +84,26 @@ var i: C[][]; new f(1, 2, "string"); >new f(1, 2, "string") : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new f(1, 2, ...a); >new f(1, 2, ...a) : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] new f(1, 2, ...a, "string"); >new f(1, 2, ...a, "string") : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Multiple spreads arguments new f2(...a, ...a); @@ -117,8 +117,8 @@ new f2(...a, ...a); new f(1 ,2, ...a, ...a); >new f(1 ,2, ...a, ...a) : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] >...a : string @@ -129,16 +129,16 @@ new f(1, 2, "string")(); >new f(1, 2, "string")() : any >new f(1, 2, "string") : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new f(1, 2, ...a)(); >new f(1, 2, ...a)() : any >new f(1, 2, ...a) : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -146,11 +146,11 @@ new f(1, 2, ...a, "string")(); >new f(1, 2, ...a, "string")() : any >new f(1, 2, ...a, "string") : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Property access expression new b.f(1, 2, "string"); @@ -158,17 +158,17 @@ new b.f(1, 2, "string"); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new b.f(1, 2, ...a); >new b.f(1, 2, ...a) : any >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -177,11 +177,11 @@ new b.f(1, 2, ...a, "string"); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Parenthesised expression new (b.f)(1, 2, "string"); @@ -190,9 +190,9 @@ new (b.f)(1, 2, "string"); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new (b.f)(1, 2, ...a); >new (b.f)(1, 2, ...a) : any @@ -200,8 +200,8 @@ new (b.f)(1, 2, ...a); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -211,11 +211,11 @@ new (b.f)(1, 2, ...a, "string"); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression new d[1].f(1, 2, "string"); @@ -223,21 +223,21 @@ new d[1].f(1, 2, "string"); >d[1].f : new (x: number, y: number, ...z: string[]) => any >d[1] : A >d : A[] ->1 : number +>1 : 1 >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new d[1].f(1, 2, ...a); >new d[1].f(1, 2, ...a) : any >d[1].f : new (x: number, y: number, ...z: string[]) => any >d[1] : A >d : A[] ->1 : number +>1 : 1 >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -246,13 +246,13 @@ new d[1].f(1, 2, ...a, "string"); >d[1].f : new (x: number, y: number, ...z: string[]) => any >d[1] : A >d : A[] ->1 : number +>1 : 1 >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression with a punctuated key new e["a-b"].f(1, 2, "string"); @@ -260,21 +260,21 @@ new e["a-b"].f(1, 2, "string"); >e["a-b"].f : new (x: number, y: number, ...z: string[]) => any >e["a-b"] : A >e : { [key: string]: A; } ->"a-b" : string +>"a-b" : "a-b" >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new e["a-b"].f(1, 2, ...a); >new e["a-b"].f(1, 2, ...a) : any >e["a-b"].f : new (x: number, y: number, ...z: string[]) => any >e["a-b"] : A >e : { [key: string]: A; } ->"a-b" : string +>"a-b" : "a-b" >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -283,56 +283,56 @@ new e["a-b"].f(1, 2, ...a, "string"); >e["a-b"].f : new (x: number, y: number, ...z: string[]) => any >e["a-b"] : A >e : { [key: string]: A; } ->"a-b" : string +>"a-b" : "a-b" >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Basic expression new B(1, 2, "string"); >new B(1, 2, "string") : B >B : typeof B ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new B(1, 2, ...a); >new B(1, 2, ...a) : B >B : typeof B ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] new B(1, 2, ...a, "string"); >new B(1, 2, ...a, "string") : B >B : typeof B ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Property access expression new c["a-b"](1, 2, "string"); >new c["a-b"](1, 2, "string") : B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number ->"string" : string +>"a-b" : "a-b" +>1 : 1 +>2 : 2 +>"string" : "string" new c["a-b"](1, 2, ...a); >new c["a-b"](1, 2, ...a) : B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -340,12 +340,12 @@ new c["a-b"](1, 2, ...a, "string"); >new c["a-b"](1, 2, ...a, "string") : B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Parenthesised expression new (c["a-b"])(1, 2, "string"); @@ -353,19 +353,19 @@ new (c["a-b"])(1, 2, "string"); >(c["a-b"]) : typeof B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number ->"string" : string +>"a-b" : "a-b" +>1 : 1 +>2 : 2 +>"string" : "string" new (c["a-b"])(1, 2, ...a); >new (c["a-b"])(1, 2, ...a) : B >(c["a-b"]) : typeof B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -374,12 +374,12 @@ new (c["a-b"])(1, 2, ...a, "string"); >(c["a-b"]) : typeof B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression new g[1]["a-b"](1, 2, "string"); @@ -387,21 +387,21 @@ new g[1]["a-b"](1, 2, "string"); >g[1]["a-b"] : typeof B >g[1] : C >g : C[] ->1 : number ->"a-b" : string ->1 : number ->2 : number ->"string" : string +>1 : 1 +>"a-b" : "a-b" +>1 : 1 +>2 : 2 +>"string" : "string" new g[1]["a-b"](1, 2, ...a); >new g[1]["a-b"](1, 2, ...a) : B >g[1]["a-b"] : typeof B >g[1] : C >g : C[] ->1 : number ->"a-b" : string ->1 : number ->2 : number +>1 : 1 +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -410,13 +410,13 @@ new g[1]["a-b"](1, 2, ...a, "string"); >g[1]["a-b"] : typeof B >g[1] : C >g : C[] ->1 : number ->"a-b" : string ->1 : number ->2 : number +>1 : 1 +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression with a punctuated key new h["a-b"]["a-b"](1, 2, "string"); @@ -424,21 +424,21 @@ new h["a-b"]["a-b"](1, 2, "string"); >h["a-b"]["a-b"] : typeof B >h["a-b"] : C >h : { [key: string]: C; } ->"a-b" : string ->"a-b" : string ->1 : number ->2 : number ->"string" : string +>"a-b" : "a-b" +>"a-b" : "a-b" +>1 : 1 +>2 : 2 +>"string" : "string" new h["a-b"]["a-b"](1, 2, ...a); >new h["a-b"]["a-b"](1, 2, ...a) : B >h["a-b"]["a-b"] : typeof B >h["a-b"] : C >h : { [key: string]: C; } ->"a-b" : string ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -447,13 +447,13 @@ new h["a-b"]["a-b"](1, 2, ...a, "string"); >h["a-b"]["a-b"] : typeof B >h["a-b"] : C >h : { [key: string]: C; } ->"a-b" : string ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression with a number new i["a-b"][1](1, 2, "string"); @@ -461,21 +461,21 @@ new i["a-b"][1](1, 2, "string"); >i["a-b"][1] : any >i["a-b"] : any >i : C[][] ->"a-b" : string ->1 : number ->1 : number ->2 : number ->"string" : string +>"a-b" : "a-b" +>1 : 1 +>1 : 1 +>2 : 2 +>"string" : "string" new i["a-b"][1](1, 2, ...a); >new i["a-b"][1](1, 2, ...a) : any >i["a-b"][1] : any >i["a-b"] : any >i : C[][] ->"a-b" : string ->1 : number ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -484,11 +484,11 @@ new i["a-b"][1](1, 2, ...a, "string"); >i["a-b"][1] : any >i["a-b"] : any >i : C[][] ->"a-b" : string ->1 : number ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" diff --git a/tests/baselines/reference/newWithSpreadES6.types b/tests/baselines/reference/newWithSpreadES6.types index 52951729e3d..587e7683e6a 100644 --- a/tests/baselines/reference/newWithSpreadES6.types +++ b/tests/baselines/reference/newWithSpreadES6.types @@ -85,26 +85,26 @@ var i: C[][]; new f(1, 2, "string"); >new f(1, 2, "string") : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new f(1, 2, ...a); >new f(1, 2, ...a) : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] new f(1, 2, ...a, "string"); >new f(1, 2, ...a, "string") : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Multiple spreads arguments new f2(...a, ...a); @@ -118,8 +118,8 @@ new f2(...a, ...a); new f(1 ,2, ...a, ...a); >new f(1 ,2, ...a, ...a) : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] >...a : string @@ -130,16 +130,16 @@ new f(1, 2, "string")(); >new f(1, 2, "string")() : any >new f(1, 2, "string") : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new f(1, 2, ...a)(); >new f(1, 2, ...a)() : any >new f(1, 2, ...a) : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -147,11 +147,11 @@ new f(1, 2, ...a, "string")(); >new f(1, 2, ...a, "string")() : any >new f(1, 2, ...a, "string") : any >f : (x: number, y: number, ...z: string[]) => void ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Property access expression new b.f(1, 2, "string"); @@ -159,17 +159,17 @@ new b.f(1, 2, "string"); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new b.f(1, 2, ...a); >new b.f(1, 2, ...a) : any >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -178,11 +178,11 @@ new b.f(1, 2, ...a, "string"); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Parenthesised expression new (b.f)(1, 2, "string"); @@ -191,9 +191,9 @@ new (b.f)(1, 2, "string"); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new (b.f)(1, 2, ...a); >new (b.f)(1, 2, ...a) : any @@ -201,8 +201,8 @@ new (b.f)(1, 2, ...a); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -212,11 +212,11 @@ new (b.f)(1, 2, ...a, "string"); >b.f : new (x: number, y: number, ...z: string[]) => any >b : A >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression new d[1].f(1, 2, "string"); @@ -224,21 +224,21 @@ new d[1].f(1, 2, "string"); >d[1].f : new (x: number, y: number, ...z: string[]) => any >d[1] : A >d : A[] ->1 : number +>1 : 1 >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new d[1].f(1, 2, ...a); >new d[1].f(1, 2, ...a) : any >d[1].f : new (x: number, y: number, ...z: string[]) => any >d[1] : A >d : A[] ->1 : number +>1 : 1 >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -247,13 +247,13 @@ new d[1].f(1, 2, ...a, "string"); >d[1].f : new (x: number, y: number, ...z: string[]) => any >d[1] : A >d : A[] ->1 : number +>1 : 1 >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression with a punctuated key new e["a-b"].f(1, 2, "string"); @@ -261,21 +261,21 @@ new e["a-b"].f(1, 2, "string"); >e["a-b"].f : new (x: number, y: number, ...z: string[]) => any >e["a-b"] : A >e : { [key: string]: A; } ->"a-b" : string +>"a-b" : "a-b" >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new e["a-b"].f(1, 2, ...a); >new e["a-b"].f(1, 2, ...a) : any >e["a-b"].f : new (x: number, y: number, ...z: string[]) => any >e["a-b"] : A >e : { [key: string]: A; } ->"a-b" : string +>"a-b" : "a-b" >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -284,56 +284,56 @@ new e["a-b"].f(1, 2, ...a, "string"); >e["a-b"].f : new (x: number, y: number, ...z: string[]) => any >e["a-b"] : A >e : { [key: string]: A; } ->"a-b" : string +>"a-b" : "a-b" >f : new (x: number, y: number, ...z: string[]) => any ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Basic expression new B(1, 2, "string"); >new B(1, 2, "string") : B >B : typeof B ->1 : number ->2 : number ->"string" : string +>1 : 1 +>2 : 2 +>"string" : "string" new B(1, 2, ...a); >new B(1, 2, ...a) : B >B : typeof B ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] new B(1, 2, ...a, "string"); >new B(1, 2, ...a, "string") : B >B : typeof B ->1 : number ->2 : number +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Property access expression new c["a-b"](1, 2, "string"); >new c["a-b"](1, 2, "string") : B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number ->"string" : string +>"a-b" : "a-b" +>1 : 1 +>2 : 2 +>"string" : "string" new c["a-b"](1, 2, ...a); >new c["a-b"](1, 2, ...a) : B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -341,12 +341,12 @@ new c["a-b"](1, 2, ...a, "string"); >new c["a-b"](1, 2, ...a, "string") : B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Parenthesised expression new (c["a-b"])(1, 2, "string"); @@ -354,19 +354,19 @@ new (c["a-b"])(1, 2, "string"); >(c["a-b"]) : typeof B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number ->"string" : string +>"a-b" : "a-b" +>1 : 1 +>2 : 2 +>"string" : "string" new (c["a-b"])(1, 2, ...a); >new (c["a-b"])(1, 2, ...a) : B >(c["a-b"]) : typeof B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -375,12 +375,12 @@ new (c["a-b"])(1, 2, ...a, "string"); >(c["a-b"]) : typeof B >c["a-b"] : typeof B >c : C ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression new g[1]["a-b"](1, 2, "string"); @@ -388,21 +388,21 @@ new g[1]["a-b"](1, 2, "string"); >g[1]["a-b"] : typeof B >g[1] : C >g : C[] ->1 : number ->"a-b" : string ->1 : number ->2 : number ->"string" : string +>1 : 1 +>"a-b" : "a-b" +>1 : 1 +>2 : 2 +>"string" : "string" new g[1]["a-b"](1, 2, ...a); >new g[1]["a-b"](1, 2, ...a) : B >g[1]["a-b"] : typeof B >g[1] : C >g : C[] ->1 : number ->"a-b" : string ->1 : number ->2 : number +>1 : 1 +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -411,13 +411,13 @@ new g[1]["a-b"](1, 2, ...a, "string"); >g[1]["a-b"] : typeof B >g[1] : C >g : C[] ->1 : number ->"a-b" : string ->1 : number ->2 : number +>1 : 1 +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression with a punctuated key new h["a-b"]["a-b"](1, 2, "string"); @@ -425,21 +425,21 @@ new h["a-b"]["a-b"](1, 2, "string"); >h["a-b"]["a-b"] : typeof B >h["a-b"] : C >h : { [key: string]: C; } ->"a-b" : string ->"a-b" : string ->1 : number ->2 : number ->"string" : string +>"a-b" : "a-b" +>"a-b" : "a-b" +>1 : 1 +>2 : 2 +>"string" : "string" new h["a-b"]["a-b"](1, 2, ...a); >new h["a-b"]["a-b"](1, 2, ...a) : B >h["a-b"]["a-b"] : typeof B >h["a-b"] : C >h : { [key: string]: C; } ->"a-b" : string ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -448,13 +448,13 @@ new h["a-b"]["a-b"](1, 2, ...a, "string"); >h["a-b"]["a-b"] : typeof B >h["a-b"] : C >h : { [key: string]: C; } ->"a-b" : string ->"a-b" : string ->1 : number ->2 : number +>"a-b" : "a-b" +>"a-b" : "a-b" +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" // Element access expression with a number new i["a-b"][1](1, 2, "string"); @@ -462,21 +462,21 @@ new i["a-b"][1](1, 2, "string"); >i["a-b"][1] : any >i["a-b"] : any >i : C[][] ->"a-b" : string ->1 : number ->1 : number ->2 : number ->"string" : string +>"a-b" : "a-b" +>1 : 1 +>1 : 1 +>2 : 2 +>"string" : "string" new i["a-b"][1](1, 2, ...a); >new i["a-b"][1](1, 2, ...a) : any >i["a-b"][1] : any >i["a-b"] : any >i : C[][] ->"a-b" : string ->1 : number ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>1 : 1 +>2 : 2 >...a : string >a : string[] @@ -485,11 +485,11 @@ new i["a-b"][1](1, 2, ...a, "string"); >i["a-b"][1] : any >i["a-b"] : any >i : C[][] ->"a-b" : string ->1 : number ->1 : number ->2 : number +>"a-b" : "a-b" +>1 : 1 +>1 : 1 +>2 : 2 >...a : string >a : string[] ->"string" : string +>"string" : "string" diff --git a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInConstructor.types b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInConstructor.types index 8c3cc633c10..da98162609f 100644 --- a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInConstructor.types +++ b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInConstructor.types @@ -15,7 +15,7 @@ class class1 { var _this = 2; >_this : number ->2 : number +>2 : 2 return callback(_this); >callback(_this) : any @@ -32,7 +32,7 @@ class class2 { constructor() { var _this = 2; >_this : number ->2 : number +>2 : 2 var x2 = { >x2 : { doStuff: (callback: any) => () => any; } diff --git a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInFunction.types b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInFunction.types index 3edf54a594f..1094638c7a1 100644 --- a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInFunction.types +++ b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInFunction.types @@ -11,7 +11,7 @@ function x() { var _this = 5; >_this : number ->5 : number +>5 : 5 x => { console.log(_this); }; >x => { console.log(_this); } : (x: any) => void diff --git a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInLambda.types b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInLambda.types index 83732f9c350..a0a9a25c516 100644 --- a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInLambda.types +++ b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInLambda.types @@ -15,7 +15,7 @@ var x = { var _this = 2; >_this : number ->2 : number +>2 : 2 return callback(_this); >callback(_this) : any diff --git a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInMethod.types b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInMethod.types index 49d0e3ed93a..6cec96104b5 100644 --- a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInMethod.types +++ b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInMethod.types @@ -1,7 +1,7 @@ === tests/cases/compiler/noCollisionThisExpressionAndLocalVarInMethod.ts === var _this = 2; >_this : number ->2 : number +>2 : 2 class a { >a : a @@ -20,7 +20,7 @@ class a { var _this = 2; >_this : number ->2 : number +>2 : 2 return callback(_this); >callback(_this) : any @@ -34,7 +34,7 @@ class a { var _this = 2; >_this : number ->2 : number +>2 : 2 return { >{ doStuff: (callback) => () => { return callback(_this); } } : { doStuff: (callback: any) => () => any; } diff --git a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInProperty.types b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInProperty.types index 8918ccc825c..e118d925515 100644 --- a/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInProperty.types +++ b/tests/baselines/reference/noCollisionThisExpressionAndLocalVarInProperty.types @@ -14,7 +14,7 @@ class class1 { var _this = 2; >_this : number ->2 : number +>2 : 2 return callback(_this); >callback(_this) : any @@ -30,7 +30,7 @@ class class2 { constructor() { var _this = 2; >_this : number ->2 : number +>2 : 2 } public prop1 = { >prop1 : { doStuff: (callback: any) => () => any; } @@ -45,7 +45,7 @@ class class2 { return callback(10); >callback(10) : any >callback : any ->10 : number +>10 : 10 } } } diff --git a/tests/baselines/reference/noCollisionThisExpressionAndVarInGlobal.types b/tests/baselines/reference/noCollisionThisExpressionAndVarInGlobal.types index c5943ef5c14..36332f39505 100644 --- a/tests/baselines/reference/noCollisionThisExpressionAndVarInGlobal.types +++ b/tests/baselines/reference/noCollisionThisExpressionAndVarInGlobal.types @@ -1,7 +1,7 @@ === tests/cases/compiler/noCollisionThisExpressionAndVarInGlobal.ts === var _this = 1; >_this : number ->1 : number +>1 : 1 var f = () => _this; >f : () => number diff --git a/tests/baselines/reference/noCollisionThisExpressionInFunctionAndVarInGlobal.types b/tests/baselines/reference/noCollisionThisExpressionInFunctionAndVarInGlobal.types index ba65e03ba59..6fb54bbdf9e 100644 --- a/tests/baselines/reference/noCollisionThisExpressionInFunctionAndVarInGlobal.types +++ b/tests/baselines/reference/noCollisionThisExpressionInFunctionAndVarInGlobal.types @@ -8,7 +8,7 @@ var console: { } var _this = 5; >_this : number ->5 : number +>5 : 5 function x() { >x : () => void diff --git a/tests/baselines/reference/noEmitOnError.errors.txt b/tests/baselines/reference/noEmitOnError.errors.txt index e03e5948092..87a71c30756 100644 --- a/tests/baselines/reference/noEmitOnError.errors.txt +++ b/tests/baselines/reference/noEmitOnError.errors.txt @@ -1,9 +1,9 @@ -tests/cases/compiler/noEmitOnError.ts(2,5): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/compiler/noEmitOnError.ts(2,5): error TS2322: Type '""' is not assignable to type 'number'. ==== tests/cases/compiler/noEmitOnError.ts (1 errors) ==== var x: number = ""; ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/noErrorTruncation.errors.txt b/tests/baselines/reference/noErrorTruncation.errors.txt index d27fad84e50..af3acb54bba 100644 --- a/tests/baselines/reference/noErrorTruncation.errors.txt +++ b/tests/baselines/reference/noErrorTruncation.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type 'number' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. +tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type '42' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. ==== tests/cases/compiler/noErrorTruncation.ts (1 errors) ==== @@ -13,7 +13,7 @@ tests/cases/compiler/noErrorTruncation.ts(10,7): error TS2322: Type 'number' is const x: SomeLongOptionA ~ -!!! error TS2322: Type 'number' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. +!!! error TS2322: Type '42' is not assignable to type '{ someLongOptionA: string; } | { someLongOptionB: string; } | { someLongOptionC: string; } | { someLongOptionD: string; } | { someLongOptionE: string; } | { someLongOptionF: string; }'. | SomeLongOptionB | SomeLongOptionC | SomeLongOptionD diff --git a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types index 9d07a26558d..c494d0795dd 100644 --- a/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types +++ b/tests/baselines/reference/noImplicitAnyDestructuringVarDeclaration2.types @@ -4,21 +4,21 @@ let [a, b, c] = [1, 2, 3]; // no error >b : number >c : number >[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 let [a1 = 10, b1 = 10, c1 = 10] = [1, 2, 3]; // no error >a1 : number ->10 : number +>10 : 10 >b1 : number ->10 : number +>10 : 10 >c1 : number ->10 : number +>10 : 10 >[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error >a2 : number @@ -28,9 +28,9 @@ let [a2 = undefined, b2 = undefined, c2 = undefined] = [1, 2, 3]; // no error >c2 : number >undefined : undefined >[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // no error >a3 : any @@ -43,9 +43,9 @@ let [a3 = undefined, b3 = null, c3 = undefined] = [1, 2, 3]; // n >undefined : any >undefined : undefined >[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 let [a4] = [undefined], [b4] = [null], c4 = undefined, d4 = null; // no error >a4 : any @@ -69,26 +69,26 @@ let {x, y, z} = { x: 1, y: 2, z: 3 }; // no error >z : number >{ x: 1, y: 2, z: 3 } : { x: number; y: number; z: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 >z : number ->3 : number +>3 : 3 let {x1 = 10, y1 = 10, z1 = 10} = { x1: 1, y1: 2, z1: 3 }; // no error >x1 : number ->10 : number +>10 : 10 >y1 : number ->10 : number +>10 : 10 >z1 : number ->10 : number +>10 : 10 >{ x1: 1, y1: 2, z1: 3 } : { x1?: number; y1?: number; z1?: number; } >x1 : number ->1 : number +>1 : 1 >y1 : number ->2 : number +>2 : 2 >z1 : number ->3 : number +>3 : 3 let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; // no error >x2 : number @@ -99,11 +99,11 @@ let {x2 = undefined, y2 = undefined, z2 = undefined} = { x2: 1, y2: 2, z2: 3 }; >undefined : undefined >{ x2: 1, y2: 2, z2: 3 } : { x2?: number; y2?: number; z2?: number; } >x2 : number ->1 : number +>1 : 1 >y2 : number ->2 : number +>2 : 2 >z2 : number ->3 : number +>3 : 3 let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, z3: 3 }; // no error >x3 : any @@ -117,11 +117,11 @@ let {x3 = undefined, y3 = null, z3 = undefined} = { x3: 1, y3: 2, >undefined : undefined >{ x3: 1, y3: 2, z3: 3 } : { x3?: number; y3?: number; z3?: number; } >x3 : number ->1 : number +>1 : 1 >y3 : number ->2 : number +>2 : 2 >z3 : number ->3 : number +>3 : 3 let {x4} = { x4: undefined }, {y4} = { y4: null }; // no error >x4 : any diff --git a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types index afe2ff7bd22..928185a0953 100644 --- a/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types +++ b/tests/baselines/reference/noImplicitAnyInContextuallyTypesFunctionParamter.types @@ -3,8 +3,8 @@ var regexMatchList = ['', '']; >regexMatchList : string[] >['', ''] : string[] ->'' : string ->'' : string +>'' : "" +>'' : "" regexMatchList.forEach(match => ''.replace(match, '')); >regexMatchList.forEach(match => ''.replace(match, '')) : void @@ -15,8 +15,8 @@ regexMatchList.forEach(match => ''.replace(match, '')); >match : string >''.replace(match, '') : string >''.replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } ->'' : string +>'' : "" >replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >match : string ->'' : string +>'' : "" diff --git a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types index d82b37e0f9e..6bb0c04fbb0 100644 --- a/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types +++ b/tests/baselines/reference/noImplicitAnyIndexingSuppressed.types @@ -12,7 +12,7 @@ var strRepresentation1 = MyEmusEnum[0] >strRepresentation1 : string >MyEmusEnum[0] : string >MyEmusEnum : typeof MyEmusEnum ->0 : number +>0 : 0 // Should be okay; should be a string. var strRepresentation2 = MyEmusEnum[MyEmusEnum.emu] @@ -28,14 +28,14 @@ var strRepresentation3 = MyEmusEnum["monehh"]; >strRepresentation3 : any >MyEmusEnum["monehh"] : any >MyEmusEnum : typeof MyEmusEnum ->"monehh" : string +>"monehh" : "monehh" // Should be okay; should be a MyEmusEnum var strRepresentation4 = MyEmusEnum["emu"]; >strRepresentation4 : MyEmusEnum >MyEmusEnum["emu"] : MyEmusEnum >MyEmusEnum : typeof MyEmusEnum ->"emu" : string +>"emu" : "emu" // Should be okay, as we suppress implicit 'any' property access checks @@ -43,18 +43,18 @@ var x = {}["hi"]; >x : any >{}["hi"] : any >{} : {} ->"hi" : string +>"hi" : "hi" // Should be okay, as we suppress implicit 'any' property access checks var y = {}[10]; >y : any >{}[10] : any >{} : {} ->10 : number +>10 : 10 var hi: any = "hi"; >hi : any ->"hi" : string +>"hi" : "hi" var emptyObj = {}; >emptyObj : {} @@ -90,13 +90,13 @@ var m: MyMap = { >{ "0": 0, "1": 1, "2": 2, "Okay that's enough for today.": NaN} : { "0": number; "1": number; "2": number; "Okay that's enough for today.": number; } "0": 0, ->0 : number +>0 : 0 "1": 1, ->1 : number +>1 : 1 "2": 2, ->2 : number +>2 : 2 "Okay that's enough for today.": NaN >NaN : number diff --git a/tests/baselines/reference/noImplicitReturnsInAsync1.types b/tests/baselines/reference/noImplicitReturnsInAsync1.types index 27746bdec5a..19da8fdfaf4 100644 --- a/tests/baselines/reference/noImplicitReturnsInAsync1.types +++ b/tests/baselines/reference/noImplicitReturnsInAsync1.types @@ -19,5 +19,5 @@ async function test(isError: boolean = false) { >Promise.resolve : { (value: T | PromiseLike): Promise; (): Promise; } >Promise : PromiseConstructor >resolve : { (value: T | PromiseLike): Promise; (): Promise; } ->"The test is passed without an error." : string +>"The test is passed without an error." : "The test is passed without an error." } diff --git a/tests/baselines/reference/noImplicitReturnsWithProtectedBlocks1.types b/tests/baselines/reference/noImplicitReturnsWithProtectedBlocks1.types index 90db4fb42e1..87214276b7c 100644 --- a/tests/baselines/reference/noImplicitReturnsWithProtectedBlocks1.types +++ b/tests/baselines/reference/noImplicitReturnsWithProtectedBlocks1.types @@ -18,6 +18,6 @@ function main1() : number { log("in finally"); >log("in finally") : void >log : (s: string) => void ->"in finally" : string +>"in finally" : "in finally" } } diff --git a/tests/baselines/reference/noImplicitUseStrict_amd.types b/tests/baselines/reference/noImplicitUseStrict_amd.types index c9e1b5749dc..5eec5bf57af 100644 --- a/tests/baselines/reference/noImplicitUseStrict_amd.types +++ b/tests/baselines/reference/noImplicitUseStrict_amd.types @@ -2,5 +2,5 @@ export var x = 0; >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/noImplicitUseStrict_commonjs.types b/tests/baselines/reference/noImplicitUseStrict_commonjs.types index 9999d3b94ba..ad7ed27dfe6 100644 --- a/tests/baselines/reference/noImplicitUseStrict_commonjs.types +++ b/tests/baselines/reference/noImplicitUseStrict_commonjs.types @@ -2,5 +2,5 @@ export var x = 0; >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/noImplicitUseStrict_es6.types b/tests/baselines/reference/noImplicitUseStrict_es6.types index 838c7316be0..38a83033ff7 100644 --- a/tests/baselines/reference/noImplicitUseStrict_es6.types +++ b/tests/baselines/reference/noImplicitUseStrict_es6.types @@ -2,5 +2,5 @@ export var x = 0; >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/noImplicitUseStrict_system.types b/tests/baselines/reference/noImplicitUseStrict_system.types index 1da563f938b..66246719284 100644 --- a/tests/baselines/reference/noImplicitUseStrict_system.types +++ b/tests/baselines/reference/noImplicitUseStrict_system.types @@ -2,5 +2,5 @@ export var x = 0; >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/noImplicitUseStrict_umd.types b/tests/baselines/reference/noImplicitUseStrict_umd.types index 6a3fd6ece77..102f21c238b 100644 --- a/tests/baselines/reference/noImplicitUseStrict_umd.types +++ b/tests/baselines/reference/noImplicitUseStrict_umd.types @@ -2,5 +2,5 @@ export var x = 0; >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.types b/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.types index e90fa04699b..c971741c5f1 100644 --- a/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.types +++ b/tests/baselines/reference/noReachabilityErrorsOnEmptyStatement.types @@ -3,5 +3,5 @@ function foo() { >foo : () => number return 1;; ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/nodeResolution1.types b/tests/baselines/reference/nodeResolution1.types index 4f29acfcc03..cd4feb3aba8 100644 --- a/tests/baselines/reference/nodeResolution1.types +++ b/tests/baselines/reference/nodeResolution1.types @@ -6,5 +6,5 @@ import y = require("./a"); export var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/nodeResolution4.types b/tests/baselines/reference/nodeResolution4.types index b273b203bde..f52f28df25a 100644 --- a/tests/baselines/reference/nodeResolution4.types +++ b/tests/baselines/reference/nodeResolution4.types @@ -6,7 +6,7 @@ import y = require("./a"); var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/a.ts === /// diff --git a/tests/baselines/reference/nodeResolution6.types b/tests/baselines/reference/nodeResolution6.types index 13c5d6d9276..9e685e8c493 100644 --- a/tests/baselines/reference/nodeResolution6.types +++ b/tests/baselines/reference/nodeResolution6.types @@ -6,7 +6,7 @@ import y = require("a"); var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/node_modules/a.d.ts === /// diff --git a/tests/baselines/reference/nodeResolution8.types b/tests/baselines/reference/nodeResolution8.types index cced0d3008d..757af64a0ef 100644 --- a/tests/baselines/reference/nodeResolution8.types +++ b/tests/baselines/reference/nodeResolution8.types @@ -6,7 +6,7 @@ import y = require("a"); var x = 1; >x : number ->1 : number +>1 : 1 === tests/cases/compiler/node_modules/a/index.d.ts === /// diff --git a/tests/baselines/reference/nonInstantiatedModule.types b/tests/baselines/reference/nonInstantiatedModule.types index c1aac2824dc..97231a5e2c6 100644 --- a/tests/baselines/reference/nonInstantiatedModule.types +++ b/tests/baselines/reference/nonInstantiatedModule.types @@ -9,7 +9,7 @@ module M { export var a = 1; >a : number ->1 : number +>1 : 1 } // primary expression @@ -52,9 +52,9 @@ module M2 { return { x: 0, y: 0 }; >{ x: 0, y: 0 } : { x: number; y: number; } >x : number ->0 : number +>0 : 0 >y : number ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/nonIterableRestElement1.types b/tests/baselines/reference/nonIterableRestElement1.types index a15fe5afd38..c226eb04138 100644 --- a/tests/baselines/reference/nonIterableRestElement1.types +++ b/tests/baselines/reference/nonIterableRestElement1.types @@ -9,6 +9,6 @@ var c = {}; >...c : any >c : {} >["", 0] : (string | number)[] ->"" : string ->0 : number +>"" : "" +>0 : 0 diff --git a/tests/baselines/reference/nonIterableRestElement2.types b/tests/baselines/reference/nonIterableRestElement2.types index c39a592d2e6..af99cc04655 100644 --- a/tests/baselines/reference/nonIterableRestElement2.types +++ b/tests/baselines/reference/nonIterableRestElement2.types @@ -9,6 +9,6 @@ var c = {}; >...c : any >c : {} >["", 0] : (string | number)[] ->"" : string ->0 : number +>"" : "" +>0 : 0 diff --git a/tests/baselines/reference/null.types b/tests/baselines/reference/null.types index 6fd8b423f13..35c084c3cbf 100644 --- a/tests/baselines/reference/null.types +++ b/tests/baselines/reference/null.types @@ -7,13 +7,13 @@ var x=null; var y=3+x; >y : any >3+x : any ->3 : number +>3 : 3 >x : any var z=3+null; >z : number >3+null : number ->3 : number +>3 : 3 >null : null class C { @@ -36,7 +36,7 @@ function g() { >null : null return 3; ->3 : number +>3 : 3 } interface I { >I : I @@ -54,7 +54,7 @@ var w:I={x:null,y:3}; >x : null >null : null >y : number ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types b/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types index 42243076e9f..a65baab4442 100644 --- a/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types +++ b/tests/baselines/reference/nullIsSubtypeOfEverythingButUndefined.types @@ -4,14 +4,14 @@ var r0 = true ? null : null; >r0 : any >true ? null : null : null ->true : boolean +>true : true >null : null >null : null var r0 = true ? null : null; >r0 : any >true ? null : null : null ->true : boolean +>true : true >null : null >null : null @@ -22,63 +22,63 @@ var u: typeof undefined; var r0b = true ? u : null; >r0b : any >true ? u : null : any ->true : boolean +>true : true >u : any >null : null var r0b = true ? null : u; >r0b : any >true ? null : u : any ->true : boolean +>true : true >null : null >u : any var r1 = true ? 1 : null; >r1 : number ->true ? 1 : null : number ->true : boolean ->1 : number +>true ? 1 : null : 1 +>true : true +>1 : 1 >null : null var r1 = true ? null : 1; >r1 : number ->true ? null : 1 : number ->true : boolean +>true ? null : 1 : 1 +>true : true >null : null ->1 : number +>1 : 1 var r2 = true ? '' : null; >r2 : string ->true ? '' : null : string ->true : boolean ->'' : string +>true ? '' : null : "" +>true : true +>'' : "" >null : null var r2 = true ? null : ''; >r2 : string ->true ? null : '' : string ->true : boolean +>true ? null : '' : "" +>true : true >null : null ->'' : string +>'' : "" var r3 = true ? true : null; >r3 : boolean ->true ? true : null : boolean ->true : boolean ->true : boolean +>true ? true : null : true +>true : true +>true : true >null : null var r3 = true ? null : true; >r3 : boolean ->true ? null : true : boolean ->true : boolean +>true ? null : true : true +>true : true >null : null ->true : boolean +>true : true var r4 = true ? new Date() : null; >r4 : Date >true ? new Date() : null : Date ->true : boolean +>true : true >new Date() : Date >Date : DateConstructor >null : null @@ -86,7 +86,7 @@ var r4 = true ? new Date() : null; var r4 = true ? null : new Date(); >r4 : Date >true ? null : new Date() : Date ->true : boolean +>true : true >null : null >new Date() : Date >Date : DateConstructor @@ -94,53 +94,53 @@ var r4 = true ? null : new Date(); var r5 = true ? /1/ : null; >r5 : RegExp >true ? /1/ : null : RegExp ->true : boolean +>true : true >/1/ : RegExp >null : null var r5 = true ? null : /1/; >r5 : RegExp >true ? null : /1/ : RegExp ->true : boolean +>true : true >null : null >/1/ : RegExp var r6 = true ? { foo: 1 } : null; >r6 : { foo: number; } >true ? { foo: 1 } : null : { foo: number; } ->true : boolean +>true : true >{ foo: 1 } : { foo: number; } >foo : number ->1 : number +>1 : 1 >null : null var r6 = true ? null : { foo: 1 }; >r6 : { foo: number; } >true ? null : { foo: 1 } : { foo: number; } ->true : boolean +>true : true >null : null >{ foo: 1 } : { foo: number; } >foo : number ->1 : number +>1 : 1 var r7 = true ? () => { } : null; >r7 : () => void >true ? () => { } : null : () => void ->true : boolean +>true : true >() => { } : () => void >null : null var r7 = true ? null : () => { }; >r7 : () => void >true ? null : () => { } : () => void ->true : boolean +>true : true >null : null >() => { } : () => void var r8 = true ? (x: T) => { return x } : null; >r8 : (x: T) => T >true ? (x: T) => { return x } : null : (x: T) => T ->true : boolean +>true : true >(x: T) => { return x } : (x: T) => T >T : T >x : T @@ -151,7 +151,7 @@ var r8 = true ? (x: T) => { return x } : null; var r8b = true ? null : (x: T) => { return x }; // type parameters not identical across declarations >r8b : (x: T) => T >true ? null : (x: T) => { return x } : (x: T) => T ->true : boolean +>true : true >null : null >(x: T) => { return x } : (x: T) => T >T : T @@ -170,14 +170,14 @@ var i1: I1; var r9 = true ? i1 : null; >r9 : I1 >true ? i1 : null : I1 ->true : boolean +>true : true >i1 : I1 >null : null var r9 = true ? null : i1; >r9 : I1 >true ? null : i1 : I1 ->true : boolean +>true : true >null : null >i1 : I1 @@ -192,14 +192,14 @@ var c1: C1; var r10 = true ? c1 : null; >r10 : C1 >true ? c1 : null : C1 ->true : boolean +>true : true >c1 : C1 >null : null var r10 = true ? null : c1; >r10 : C1 >true ? null : c1 : C1 ->true : boolean +>true : true >null : null >c1 : C1 @@ -216,14 +216,14 @@ var c2: C2; var r12 = true ? c2 : null; >r12 : C2 >true ? c2 : null : C2 ->true : boolean +>true : true >c2 : C2 >null : null var r12 = true ? null : c2; >r12 : C2 >true ? null : c2 : C2 ->true : boolean +>true : true >null : null >c2 : C2 @@ -234,21 +234,21 @@ enum E { A } var r13 = true ? E : null; >r13 : typeof E >true ? E : null : typeof E ->true : boolean +>true : true >E : typeof E >null : null var r13 = true ? null : E; >r13 : typeof E >true ? null : E : typeof E ->true : boolean +>true : true >null : null >E : typeof E var r14 = true ? E.A : null; >r14 : E >true ? E.A : null : E ->true : boolean +>true : true >E.A : E >E : typeof E >A : E @@ -257,7 +257,7 @@ var r14 = true ? E.A : null; var r14 = true ? null : E.A; >r14 : E >true ? null : E.A : E ->true : boolean +>true : true >null : null >E.A : E >E : typeof E @@ -271,7 +271,7 @@ module f { export var bar = 1; >bar : number ->1 : number +>1 : 1 } var af: typeof f; >af : typeof f @@ -280,14 +280,14 @@ var af: typeof f; var r15 = true ? af : null; >r15 : typeof f >true ? af : null : typeof f ->true : boolean +>true : true >af : typeof f >null : null var r15 = true ? null : af; >r15 : typeof f >true ? null : af : typeof f ->true : boolean +>true : true >null : null >af : typeof f @@ -300,7 +300,7 @@ module c { export var bar = 1; >bar : number ->1 : number +>1 : 1 } var ac: typeof c; >ac : typeof c @@ -309,14 +309,14 @@ var ac: typeof c; var r16 = true ? ac : null; >r16 : typeof c >true ? ac : null : typeof c ->true : boolean +>true : true >ac : typeof c >null : null var r16 = true ? null : ac; >r16 : typeof c >true ? null : ac : typeof c ->true : boolean +>true : true >null : null >ac : typeof c @@ -329,14 +329,14 @@ function f17(x: T) { var r17 = true ? x : null; >r17 : T >true ? x : null : T ->true : boolean +>true : true >x : T >null : null var r17 = true ? null : x; >r17 : T >true ? null : x : T ->true : boolean +>true : true >null : null >x : T } @@ -351,14 +351,14 @@ function f18(x: U) { var r18 = true ? x : null; >r18 : U >true ? x : null : U ->true : boolean +>true : true >x : U >null : null var r18 = true ? null : x; >r18 : U >true ? null : x : U ->true : boolean +>true : true >null : null >x : U } @@ -370,7 +370,7 @@ function f18(x: U) { var r19 = true ? new Object() : null; >r19 : Object >true ? new Object() : null : Object ->true : boolean +>true : true >new Object() : Object >Object : ObjectConstructor >null : null @@ -378,7 +378,7 @@ var r19 = true ? new Object() : null; var r19 = true ? null : new Object(); >r19 : Object >true ? null : new Object() : Object ->true : boolean +>true : true >null : null >new Object() : Object >Object : ObjectConstructor @@ -386,14 +386,14 @@ var r19 = true ? null : new Object(); var r20 = true ? {} : null; >r20 : {} >true ? {} : null : {} ->true : boolean +>true : true >{} : {} >null : null var r20 = true ? null : {}; >r20 : {} >true ? null : {} : {} ->true : boolean +>true : true >null : null >{} : {} diff --git a/tests/baselines/reference/nullOrUndefinedTypeGuardIsOrderIndependent.types b/tests/baselines/reference/nullOrUndefinedTypeGuardIsOrderIndependent.types index f599366e66e..4d5f6d11538 100644 --- a/tests/baselines/reference/nullOrUndefinedTypeGuardIsOrderIndependent.types +++ b/tests/baselines/reference/nullOrUndefinedTypeGuardIsOrderIndependent.types @@ -7,7 +7,7 @@ function test(strOrNull: string | null, strOrUndefined: string | undefined) { var str: string = "original"; >str : string ->"original" : string +>"original" : "original" var nil: null; >nil : null diff --git a/tests/baselines/reference/numberAsInLHS.types b/tests/baselines/reference/numberAsInLHS.types index 848f937c618..af2541bffe7 100644 --- a/tests/baselines/reference/numberAsInLHS.types +++ b/tests/baselines/reference/numberAsInLHS.types @@ -1,8 +1,8 @@ === tests/cases/compiler/numberAsInLHS.ts === 3 in [0, 1] >3 in [0, 1] : boolean ->3 : number +>3 : 3 >[0, 1] : number[] ->0 : number ->1 : number +>0 : 0 +>1 : 1 diff --git a/tests/baselines/reference/numberPropertyAccess.types b/tests/baselines/reference/numberPropertyAccess.types index b7f5479ed79..e7ffcbc246d 100644 --- a/tests/baselines/reference/numberPropertyAccess.types +++ b/tests/baselines/reference/numberPropertyAccess.types @@ -1,7 +1,7 @@ === tests/cases/conformance/types/primitives/number/numberPropertyAccess.ts === var x = 1; >x : number ->1 : number +>1 : 1 var a = x.toExponential(); >a : string @@ -16,20 +16,20 @@ var b = x.hasOwnProperty('toFixed'); >x.hasOwnProperty : (v: string) => boolean >x : number >hasOwnProperty : (v: string) => boolean ->'toFixed' : string +>'toFixed' : "toFixed" var c = x['toExponential'](); >c : string >x['toExponential']() : string >x['toExponential'] : (fractionDigits?: number) => string >x : number ->'toExponential' : string +>'toExponential' : "toExponential" var d = x['hasOwnProperty']('toFixed'); >d : boolean >x['hasOwnProperty']('toFixed') : boolean >x['hasOwnProperty'] : (v: string) => boolean >x : number ->'hasOwnProperty' : string ->'toFixed' : string +>'hasOwnProperty' : "hasOwnProperty" +>'toFixed' : "toFixed" diff --git a/tests/baselines/reference/numberToString.errors.txt b/tests/baselines/reference/numberToString.errors.txt index 07cc9009a67..60a382e47c3 100644 --- a/tests/baselines/reference/numberToString.errors.txt +++ b/tests/baselines/reference/numberToString.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/numberToString.ts(2,12): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/numberToString.ts(9,4): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/numberToString.ts(9,4): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/numberToString.ts (2 errors) ==== @@ -15,6 +15,6 @@ tests/cases/compiler/numberToString.ts(9,4): error TS2345: Argument of type 'num f1(3); f2(3); // error no coercion to string ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. f2(3+""); // ok + operator promotes \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexExpressions.errors.txt b/tests/baselines/reference/numericIndexExpressions.errors.txt index 2c3b8d76796..da0993ffee3 100644 --- a/tests/baselines/reference/numericIndexExpressions.errors.txt +++ b/tests/baselines/reference/numericIndexExpressions.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/numericIndexExpressions.ts(10,1): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/numericIndexExpressions.ts(11,1): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/numericIndexExpressions.ts(14,1): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/numericIndexExpressions.ts(15,1): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/numericIndexExpressions.ts(10,1): error TS2322: Type '4' is not assignable to type 'string'. +tests/cases/compiler/numericIndexExpressions.ts(11,1): error TS2322: Type '4' is not assignable to type 'string'. +tests/cases/compiler/numericIndexExpressions.ts(14,1): error TS2322: Type '4' is not assignable to type 'string'. +tests/cases/compiler/numericIndexExpressions.ts(15,1): error TS2322: Type '4' is not assignable to type 'string'. ==== tests/cases/compiler/numericIndexExpressions.ts (4 errors) ==== @@ -16,15 +16,15 @@ tests/cases/compiler/numericIndexExpressions.ts(15,1): error TS2322: Type 'numbe var x: Numbers1; x[1] = 4; // error ~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '4' is not assignable to type 'string'. x['1'] = 4; // error ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '4' is not assignable to type 'string'. var y: Strings1; y['1'] = 4; // should be error ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '4' is not assignable to type 'string'. y[1] = 4; // should be error ~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file +!!! error TS2322: Type '4' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/numericIndexingResults.types b/tests/baselines/reference/numericIndexingResults.types index 9a060b388e3..8d25a44eab0 100644 --- a/tests/baselines/reference/numericIndexingResults.types +++ b/tests/baselines/reference/numericIndexingResults.types @@ -6,10 +6,10 @@ class C { >x : number 1 = ''; ->'' : string +>'' : "" "2" = '' ->'' : string +>'' : "" } var c: C; @@ -20,37 +20,37 @@ var r1 = c['1']; >r1 : string >c['1'] : string >c : C ->'1' : string +>'1' : "1" var r2 = c['2']; >r2 : string >c['2'] : string >c : C ->'2' : string +>'2' : "2" var r3 = c['3']; >r3 : any >c['3'] : any >c : C ->'3' : string +>'3' : "3" var r4 = c[1]; >r4 : string >c[1] : string >c : C ->1 : number +>1 : 1 var r5 = c[2]; >r5 : string >c[2] : string >c : C ->2 : number +>2 : 2 var r6 = c[3]; >r6 : string >c[3] : string >c : C ->3 : number +>3 : 3 interface I { >I : I @@ -70,37 +70,37 @@ var r1 = i['1']; >r1 : string >i['1'] : string >i : I ->'1' : string +>'1' : "1" var r2 = i['2']; >r2 : string >i['2'] : string >i : I ->'2' : string +>'2' : "2" var r3 = i['3']; >r3 : any >i['3'] : any >i : I ->'3' : string +>'3' : "3" var r4 = i[1]; >r4 : string >i[1] : string >i : I ->1 : number +>1 : 1 var r5 = i[2]; >r5 : string >i[2] : string >i : I ->2 : number +>2 : 2 var r6 = i[3]; >r6 : string >i[3] : string >i : I ->3 : number +>3 : 3 var a: { >a : { [x: number]: string; 1: string; "2": string; } @@ -116,121 +116,121 @@ var r1 = a['1']; >r1 : string >a['1'] : string >a : { [x: number]: string; 1: string; "2": string; } ->'1' : string +>'1' : "1" var r2 = a['2']; >r2 : string >a['2'] : string >a : { [x: number]: string; 1: string; "2": string; } ->'2' : string +>'2' : "2" var r3 = a['3']; >r3 : any >a['3'] : any >a : { [x: number]: string; 1: string; "2": string; } ->'3' : string +>'3' : "3" var r4 = a[1]; >r4 : string >a[1] : string >a : { [x: number]: string; 1: string; "2": string; } ->1 : number +>1 : 1 var r5 = a[2]; >r5 : string >a[2] : string >a : { [x: number]: string; 1: string; "2": string; } ->2 : number +>2 : 2 var r6 = a[3]; >r6 : string >a[3] : string >a : { [x: number]: string; 1: string; "2": string; } ->3 : number +>3 : 3 var b: { [x: number]: string } = { 1: '', "2": '' } >b : { [x: number]: string; } >x : number >{ 1: '', "2": '' } : { 1: string; "2": string; } ->'' : string ->'' : string +>'' : "" +>'' : "" var r1a = b['1']; >r1a : any >b['1'] : any >b : { [x: number]: string; } ->'1' : string +>'1' : "1" var r2a = b['2']; >r2a : any >b['2'] : any >b : { [x: number]: string; } ->'2' : string +>'2' : "2" var r3 = b['3']; >r3 : any >b['3'] : any >b : { [x: number]: string; } ->'3' : string +>'3' : "3" var r4 = b[1]; >r4 : string >b[1] : string >b : { [x: number]: string; } ->1 : number +>1 : 1 var r5 = b[2]; >r5 : string >b[2] : string >b : { [x: number]: string; } ->2 : number +>2 : 2 var r6 = b[3]; >r6 : string >b[3] : string >b : { [x: number]: string; } ->3 : number +>3 : 3 var b2: { [x: number]: string; 1: string; "2": string; } = { 1: '', "2": '' } >b2 : { [x: number]: string; 1: string; "2": string; } >x : number >{ 1: '', "2": '' } : { 1: string; "2": string; } ->'' : string ->'' : string +>'' : "" +>'' : "" var r1b = b2['1']; >r1b : string >b2['1'] : string >b2 : { [x: number]: string; 1: string; "2": string; } ->'1' : string +>'1' : "1" var r2b = b2['2']; >r2b : string >b2['2'] : string >b2 : { [x: number]: string; 1: string; "2": string; } ->'2' : string +>'2' : "2" var r3 = b2['3']; >r3 : any >b2['3'] : any >b2 : { [x: number]: string; 1: string; "2": string; } ->'3' : string +>'3' : "3" var r4 = b2[1]; >r4 : string >b2[1] : string >b2 : { [x: number]: string; 1: string; "2": string; } ->1 : number +>1 : 1 var r5 = b2[2]; >r5 : string >b2[2] : string >b2 : { [x: number]: string; 1: string; "2": string; } ->2 : number +>2 : 2 var r6 = b2[3]; >r6 : string >b2[3] : string >b2 : { [x: number]: string; 1: string; "2": string; } ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/numericLiteralTypes1.types b/tests/baselines/reference/numericLiteralTypes1.types index 38912e05365..f091dd99d60 100644 --- a/tests/baselines/reference/numericLiteralTypes1.types +++ b/tests/baselines/reference/numericLiteralTypes1.types @@ -46,17 +46,17 @@ function f1() { type B1 = -1 | 0 | 1; >B1 : B1 >-1 : -1 ->1 : number +>1 : 1 type B2 = 1 | 0 | -1; >B2 : B1 >-1 : -1 ->1 : number +>1 : 1 type B3 = 0 | -1 | 1; >B3 : B1 >-1 : -1 ->1 : number +>1 : 1 function f2() { >f2 : () => void @@ -65,7 +65,7 @@ function f2() { >b : B1 >B1 : B1 >-1 : -1 ->1 : number +>1 : 1 var b: B2 = 0; >b : B1 @@ -242,7 +242,7 @@ function f5(a: 1, b: 0 | 1 | 2) { >z3 : number >g(2) : number >g : { (x: 0): string; (x: 1): boolean; (x: number): number; } ->2 : number +>2 : 2 var z4 = g(a); >z4 : boolean @@ -264,14 +264,14 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); >new Error("Unexpected value") : Error >Error : ErrorConstructor ->"Unexpected value" : string +>"Unexpected value" : "Unexpected value" } type Tag = 0 | 1 | 2; >Tag : 0 | 1 | 2 function f10(x: Tag) { ->f10 : (x: 0 | 1 | 2) => string +>f10 : (x: 0 | 1 | 2) => "a" | "b" | "c" >x : 0 | 1 | 2 >Tag : 0 | 1 | 2 @@ -280,20 +280,20 @@ function f10(x: Tag) { case 0: return "a"; >0 : 0 ->"a" : string +>"a" : "a" case 1: return "b"; >1 : 1 ->"b" : string +>"b" : "b" case 2: return "c"; >2 : 2 ->"c" : string +>"c" : "c" } } function f11(x: Tag) { ->f11 : (x: 0 | 1 | 2) => string +>f11 : (x: 0 | 1 | 2) => "a" | "b" | "c" >x : 0 | 1 | 2 >Tag : 0 | 1 | 2 @@ -302,15 +302,15 @@ function f11(x: Tag) { case 0: return "a"; >0 : 0 ->"a" : string +>"a" : "a" case 1: return "b"; >1 : 1 ->"b" : string +>"b" : "b" case 2: return "c"; >2 : 2 ->"c" : string +>"c" : "c" } return assertNever(x); >assertNever(x) : never @@ -370,7 +370,7 @@ function f14(x: 0 | 1 | 2, y: string) { >y : string var b = x || y; ->b : string | 1 | 2 +>b : string | number >x || y : string | 1 | 2 >x : 0 | 1 | 2 >y : string @@ -383,31 +383,31 @@ function f15(x: 0 | false, y: 1 | "one") { >y : 1 | "one" var a = x && y; ->a : false | 0 +>a : number | boolean >x && y : false | 0 >x : false | 0 >y : 1 | "one" var b = y && x; ->b : false | 0 +>b : number | boolean >y && x : false | 0 >y : 1 | "one" >x : false | 0 var c = x || y; ->c : 1 | "one" +>c : string | number >x || y : 1 | "one" >x : false | 0 >y : 1 | "one" var d = y || x; ->d : false | 0 | 1 | "one" +>d : string | number | boolean >y || x : false | 0 | 1 | "one" >y : 1 | "one" >x : false | 0 var e = !x; ->e : true +>e : boolean >!x : true >x : false | 0 diff --git a/tests/baselines/reference/numericLiteralTypes2.types b/tests/baselines/reference/numericLiteralTypes2.types index 13292e5f75c..a5744de2a34 100644 --- a/tests/baselines/reference/numericLiteralTypes2.types +++ b/tests/baselines/reference/numericLiteralTypes2.types @@ -47,17 +47,17 @@ function f1() { type B1 = -1 | 0 | 1; >B1 : B1 >-1 : -1 ->1 : number +>1 : 1 type B2 = 1 | 0 | -1; >B2 : B1 >-1 : -1 ->1 : number +>1 : 1 type B3 = 0 | -1 | 1; >B3 : B1 >-1 : -1 ->1 : number +>1 : 1 function f2() { >f2 : () => void @@ -66,7 +66,7 @@ function f2() { >b : B1 >B1 : B1 >-1 : -1 ->1 : number +>1 : 1 var b: B2 = 0; >b : B1 @@ -243,7 +243,7 @@ function f5(a: 1, b: 0 | 1 | 2) { >z3 : number >g(2) : number >g : { (x: 0): string; (x: 1): boolean; (x: number): number; } ->2 : number +>2 : 2 var z4 = g(a); >z4 : boolean @@ -265,14 +265,14 @@ function assertNever(x: never): never { throw new Error("Unexpected value"); >new Error("Unexpected value") : Error >Error : ErrorConstructor ->"Unexpected value" : string +>"Unexpected value" : "Unexpected value" } type Tag = 0 | 1 | 2; >Tag : 0 | 1 | 2 function f10(x: Tag) { ->f10 : (x: 0 | 1 | 2) => string +>f10 : (x: 0 | 1 | 2) => "a" | "b" | "c" >x : 0 | 1 | 2 >Tag : 0 | 1 | 2 @@ -281,20 +281,20 @@ function f10(x: Tag) { case 0: return "a"; >0 : 0 ->"a" : string +>"a" : "a" case 1: return "b"; >1 : 1 ->"b" : string +>"b" : "b" case 2: return "c"; >2 : 2 ->"c" : string +>"c" : "c" } } function f11(x: Tag) { ->f11 : (x: 0 | 1 | 2) => string +>f11 : (x: 0 | 1 | 2) => "a" | "b" | "c" >x : 0 | 1 | 2 >Tag : 0 | 1 | 2 @@ -303,15 +303,15 @@ function f11(x: Tag) { case 0: return "a"; >0 : 0 ->"a" : string +>"a" : "a" case 1: return "b"; >1 : 1 ->"b" : string +>"b" : "b" case 2: return "c"; >2 : 2 ->"c" : string +>"c" : "c" } return assertNever(x); >assertNever(x) : never @@ -365,13 +365,13 @@ function f14(x: 0 | 1 | 2, y: string) { >y : string var a = x && y; ->a : string | 0 +>a : string | number >x && y : string | 0 >x : 0 | 1 | 2 >y : string var b = x || y; ->b : string | 1 | 2 +>b : string | number >x || y : string | 1 | 2 >x : 0 | 1 | 2 >y : string @@ -384,36 +384,36 @@ function f15(x: 0 | false, y: 1 | "one") { >y : 1 | "one" var a = x && y; ->a : false | 0 +>a : number | boolean >x && y : false | 0 >x : false | 0 >y : 1 | "one" var b = y && x; ->b : false | 0 +>b : number | boolean >y && x : false | 0 >y : 1 | "one" >x : false | 0 var c = x || y; ->c : 1 | "one" +>c : string | number >x || y : 1 | "one" >x : false | 0 >y : 1 | "one" var d = y || x; ->d : 1 | "one" +>d : string | number >y || x : 1 | "one" >y : 1 | "one" >x : false | 0 var e = !x; ->e : true +>e : boolean >!x : true >x : false | 0 var f = !y; ->f : false +>f : boolean >!y : false >y : 1 | "one" } diff --git a/tests/baselines/reference/numericMethodName1.types b/tests/baselines/reference/numericMethodName1.types index e6e631fc705..4f907f06feb 100644 --- a/tests/baselines/reference/numericMethodName1.types +++ b/tests/baselines/reference/numericMethodName1.types @@ -3,6 +3,6 @@ class C { >C : C 1 = 2; ->2 : number +>2 : 2 } diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.types b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.types index d736121a3b7..d5838d7174a 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.types +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers05.types @@ -4,5 +4,5 @@ var { as } = { as: 1 } >as : number >{ as: 1 } : { as: number; } >as : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.types b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.types index 739771385b2..427957c1ef8 100644 --- a/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.types +++ b/tests/baselines/reference/objectBindingPatternKeywordIdentifiers06.types @@ -5,5 +5,5 @@ var { as: as } = { as: 1 } >as : number >{ as: 1 } : { as: number; } >as : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/objectCreationExpressionInFunctionParameter.errors.txt b/tests/baselines/reference/objectCreationExpressionInFunctionParameter.errors.txt index bd9e021494c..6948f080aef 100644 --- a/tests/baselines/reference/objectCreationExpressionInFunctionParameter.errors.txt +++ b/tests/baselines/reference/objectCreationExpressionInFunctionParameter.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/objectCreationExpressionInFunctionParameter.ts(5,24): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/objectCreationExpressionInFunctionParameter.ts(5,24): error TS2345: Argument of type '123' is not assignable to parameter of type 'string'. tests/cases/compiler/objectCreationExpressionInFunctionParameter.ts(6,2): error TS1128: Declaration or statement expected. @@ -9,7 +9,7 @@ tests/cases/compiler/objectCreationExpressionInFunctionParameter.ts(6,2): error } function foo(x = new A(123)) { //should error, 123 is not string ~~~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '123' is not assignable to parameter of type 'string'. }} ~ !!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/objectLitGetterSetter.types b/tests/baselines/reference/objectLitGetterSetter.types index 4f7865374e2..d973765c855 100644 --- a/tests/baselines/reference/objectLitGetterSetter.types +++ b/tests/baselines/reference/objectLitGetterSetter.types @@ -9,23 +9,23 @@ >Object : ObjectConstructor >defineProperty : (o: any, p: string, attributes: PropertyDescriptor) => any >obj : {} ->"accProperty" : string +>"accProperty" : "accProperty" >({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } }) : PropertyDescriptor >PropertyDescriptor : PropertyDescriptor ->({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } }) : { get: () => number; set: (v: any) => void; } ->{ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } } : { get: () => number; set: (v: any) => void; } +>({ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } }) : { get: () => 11; set: (v: any) => void; } +>{ get: function () { eval("public = 1;"); return 11; }, set: function (v) { } } : { get: () => 11; set: (v: any) => void; } get: function () { ->get : () => number ->function () { eval("public = 1;"); return 11; } : () => number +>get : () => 11 +>function () { eval("public = 1;"); return 11; } : () => 11 eval("public = 1;"); >eval("public = 1;") : any >eval : (x: string) => any ->"public = 1;" : string +>"public = 1;" : "public = 1;" return 11; ->11 : number +>11 : 11 }, set: function (v) { diff --git a/tests/baselines/reference/objectLiteral1.types b/tests/baselines/reference/objectLiteral1.types index 491b4ce365b..244cb62dbef 100644 --- a/tests/baselines/reference/objectLiteral1.types +++ b/tests/baselines/reference/objectLiteral1.types @@ -3,7 +3,7 @@ var v30 = {a:1, b:2}; >v30 : { a: number; b: number; } >{a:1, b:2} : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/objectLiteral2.types b/tests/baselines/reference/objectLiteral2.types index 387bd0ba90f..52184a27833 100644 --- a/tests/baselines/reference/objectLiteral2.types +++ b/tests/baselines/reference/objectLiteral2.types @@ -3,8 +3,8 @@ var v30 = {a:1, b:2}, v31; >v30 : { a: number; b: number; } >{a:1, b:2} : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 >v31 : any diff --git a/tests/baselines/reference/objectLiteralArraySpecialization.types b/tests/baselines/reference/objectLiteralArraySpecialization.types index 405d8bff472..d51b7ffc3cf 100644 --- a/tests/baselines/reference/objectLiteralArraySpecialization.types +++ b/tests/baselines/reference/objectLiteralArraySpecialization.types @@ -31,14 +31,14 @@ var thing = create([ { name: "bob", id: 24 }, { name: "doug", id: 32 } ]); // sh >[ { name: "bob", id: 24 }, { name: "doug", id: 32 } ] : { name: string; id: number; }[] >{ name: "bob", id: 24 } : { name: string; id: number; } >name : string ->"bob" : string +>"bob" : "bob" >id : number ->24 : number +>24 : 24 >{ name: "doug", id: 32 } : { name: string; id: number; } >name : string ->"doug" : string +>"doug" : "doug" >id : number ->32 : number +>32 : 32 thing.doSomething((x, y) => x.name === "bob"); // should not error >thing.doSomething((x, y) => x.name === "bob") : void diff --git a/tests/baselines/reference/objectLiteralContextualTyping.types b/tests/baselines/reference/objectLiteralContextualTyping.types index 8100b7a5446..a0c6ff7417b 100644 --- a/tests/baselines/reference/objectLiteralContextualTyping.types +++ b/tests/baselines/reference/objectLiteralContextualTyping.types @@ -29,7 +29,7 @@ var x = foo({ name: "Sprocket" }); >foo : { (item: Item): string; (item: any): number; } >{ name: "Sprocket" } : { name: string; } >name : string ->"Sprocket" : string +>"Sprocket" : "Sprocket" var x: string; >x : string @@ -40,9 +40,9 @@ var y = foo({ name: "Sprocket", description: "Bumpy wheel" }); >foo : { (item: Item): string; (item: any): number; } >{ name: "Sprocket", description: "Bumpy wheel" } : { name: string; description: string; } >name : string ->"Sprocket" : string +>"Sprocket" : "Sprocket" >description : string ->"Bumpy wheel" : string +>"Bumpy wheel" : "Bumpy wheel" var y: string; >y : string @@ -53,9 +53,9 @@ var z = foo({ name: "Sprocket", description: false }); >foo : { (item: Item): string; (item: any): number; } >{ name: "Sprocket", description: false } : { name: string; description: boolean; } >name : string ->"Sprocket" : string +>"Sprocket" : "Sprocket" >description : boolean ->false : boolean +>false : false var z: number; >z : number @@ -66,7 +66,7 @@ var w = foo({ a: 10 }); >foo : { (item: Item): string; (item: any): number; } >{ a: 10 } : { a: number; } >a : number ->10 : number +>10 : 10 var w: number; >w : number diff --git a/tests/baselines/reference/objectLiteralErrors.errors.txt b/tests/baselines/reference/objectLiteralErrors.errors.txt index 2505748760c..234ac24a8fd 100644 --- a/tests/baselines/reference/objectLiteralErrors.errors.txt +++ b/tests/baselines/reference/objectLiteralErrors.errors.txt @@ -73,7 +73,7 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46) tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(40,46): error TS2300: Duplicate identifier 'a'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,16): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(43,47): error TS2380: 'get' and 'set' accessor must have the same type. -tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,29): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(44,29): error TS2322: Type '4' is not assignable to type 'string'. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,16): error TS2380: 'get' and 'set' accessor must have the same type. tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55): error TS2380: 'get' and 'set' accessor must have the same type. @@ -274,7 +274,7 @@ tests/cases/conformance/expressions/objectLiterals/objectLiteralErrors.ts(45,55) !!! error TS2380: 'get' and 'set' accessor must have the same type. var g2 = { get a() { return 4; }, set a(n: string) { } }; ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '4' is not assignable to type 'string'. var g3 = { get a(): number { return undefined; }, set a(n: string) { } }; ~ !!! error TS2380: 'get' and 'set' accessor must have the same type. diff --git a/tests/baselines/reference/objectLiteralShorthandProperties.types b/tests/baselines/reference/objectLiteralShorthandProperties.types index 9d537173d49..4f4482906aa 100644 --- a/tests/baselines/reference/objectLiteralShorthandProperties.types +++ b/tests/baselines/reference/objectLiteralShorthandProperties.types @@ -27,7 +27,7 @@ var x3 = { a: 0, >a : number ->0 : number +>0 : 0 b, >b : any diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.types b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.types index 869a67fb22f..88a910a99fb 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.types +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignment.types @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignment.ts === var id: number = 10000; >id : number ->10000 : number +>10000 : 10000 var name: string = "my name"; >name : string ->"my name" : string +>"my name" : "my name" var person: { name: string; id: number } = { name, id }; >person : { name: string; id: number; } @@ -54,16 +54,16 @@ var person1 = bar("Hello", 5); >person1 : { name: string; id: number; } >bar("Hello", 5) : { name: string; id: number; } >bar : (name: string, id: number) => { name: string; id: number; } ->"Hello" : string ->5 : number +>"Hello" : "Hello" +>5 : 5 var person2: { name: string } = bar("Hello", 5); >person2 : { name: string; } >name : string >bar("Hello", 5) : { name: string; id: number; } >bar : (name: string, id: number) => { name: string; id: number; } ->"Hello" : string ->5 : number +>"Hello" : "Hello" +>5 : 5 var person3: { name: string; id:number } = bar("Hello", 5); >person3 : { name: string; id: number; } @@ -71,6 +71,6 @@ var person3: { name: string; id:number } = bar("Hello", 5); >id : number >bar("Hello", 5) : { name: string; id: number; } >bar : (name: string, id: number) => { name: string; id: number; } ->"Hello" : string ->5 : number +>"Hello" : "Hello" +>5 : 5 diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.types b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.types index 710fc430339..527c9c5fb6c 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.types +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesAssignmentES6.types @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesAssignmentES6.ts === var id: number = 10000; >id : number ->10000 : number +>10000 : 10000 var name: string = "my name"; >name : string ->"my name" : string +>"my name" : "my name" var person: { name: string; id: number } = { name, id }; >person : { name: string; id: number; } @@ -54,16 +54,16 @@ var person1 = bar("Hello", 5); >person1 : { name: string; id: number; } >bar("Hello", 5) : { name: string; id: number; } >bar : (name: string, id: number) => { name: string; id: number; } ->"Hello" : string ->5 : number +>"Hello" : "Hello" +>5 : 5 var person2: { name: string } = bar("Hello", 5); >person2 : { name: string; } >name : string >bar("Hello", 5) : { name: string; id: number; } >bar : (name: string, id: number) => { name: string; id: number; } ->"Hello" : string ->5 : number +>"Hello" : "Hello" +>5 : 5 var person3: { name: string; id: number } = bar("Hello", 5); >person3 : { name: string; id: number; } @@ -71,6 +71,6 @@ var person3: { name: string; id: number } = bar("Hello", 5); >id : number >bar("Hello", 5) : { name: string; id: number; } >bar : (name: string, id: number) => { name: string; id: number; } ->"Hello" : string ->5 : number +>"Hello" : "Hello" +>5 : 5 diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types b/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types index 5c36262f695..1565be04625 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesES6.types @@ -27,7 +27,7 @@ var x3 = { a: 0, >a : number ->0 : number +>0 : 0 b, >b : any diff --git a/tests/baselines/reference/objectLiteralShorthandPropertiesFunctionArgument.types b/tests/baselines/reference/objectLiteralShorthandPropertiesFunctionArgument.types index 083d4118128..fe67e59dd7b 100644 --- a/tests/baselines/reference/objectLiteralShorthandPropertiesFunctionArgument.types +++ b/tests/baselines/reference/objectLiteralShorthandPropertiesFunctionArgument.types @@ -1,11 +1,11 @@ === tests/cases/conformance/es6/shorthandPropertyAssignment/objectLiteralShorthandPropertiesFunctionArgument.ts === var id: number = 10000; >id : number ->10000 : number +>10000 : 10000 var name: string = "my name"; >name : string ->"my name" : string +>"my name" : "my name" var person = { name, id }; >person : { name: string; id: number; } diff --git a/tests/baselines/reference/objectTypePropertyAccess.types b/tests/baselines/reference/objectTypePropertyAccess.types index 5fc03bd86ed..6f9bffaf0de 100644 --- a/tests/baselines/reference/objectTypePropertyAccess.types +++ b/tests/baselines/reference/objectTypePropertyAccess.types @@ -23,7 +23,7 @@ var r2 = c['toString'](); >c['toString']() : string >c['toString'] : () => string >c : C ->'toString' : string +>'toString' : "toString" var r3 = c.foo; >r3 : string @@ -35,7 +35,7 @@ var r4 = c['foo']; >r4 : string >c['foo'] : string >c : C ->'foo' : string +>'foo' : "foo" interface I { >I : I @@ -59,7 +59,7 @@ var r5 = i['toString'](); >i['toString']() : string >i['toString'] : () => string >i : I ->'toString' : string +>'toString' : "toString" var r6 = i.bar; >r6 : string @@ -71,7 +71,7 @@ var r7 = i['bar']; >r7 : string >i['bar'] : string >i : I ->'bar' : string +>'bar' : "bar" var a = { >a : { foo: string; } @@ -79,7 +79,7 @@ var a = { foo: '' >foo : string ->'' : string +>'' : "" } var r8 = a.toString(); @@ -94,7 +94,7 @@ var r9 = a['toString'](); >a['toString']() : string >a['toString'] : () => string >a : { foo: string; } ->'toString' : string +>'toString' : "toString" var r10 = a.foo; >r10 : string @@ -106,5 +106,5 @@ var r11 = a['foo']; >r11 : string >a['foo'] : string >a : { foo: string; } ->'foo' : string +>'foo' : "foo" diff --git a/tests/baselines/reference/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.types b/tests/baselines/reference/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.types index 93caca61bfa..ea0ee84b575 100644 --- a/tests/baselines/reference/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.types +++ b/tests/baselines/reference/objectTypeWithCallSignatureHidingMembersOfExtendedFunction.types @@ -64,7 +64,7 @@ var r1e = i['hm']; // should be Object >r1e : any >i['hm'] : any >i : I ->'hm' : string +>'hm' : "hm" var x: { >x : { (): void; apply(a: any, b?: any): void; call(thisArg: number, ...argArray: number[]): any; } @@ -113,5 +113,5 @@ var r2e = x['hm']; // should be Object >r2e : any >x['hm'] : any >x : { (): void; apply(a: any, b?: any): void; call(thisArg: number, ...argArray: number[]): any; } ->'hm' : string +>'hm' : "hm" diff --git a/tests/baselines/reference/objectTypeWithConstructSignatureHidingMembersOfExtendedFunction.types b/tests/baselines/reference/objectTypeWithConstructSignatureHidingMembersOfExtendedFunction.types index 427b700fb59..c0b5c9d5a77 100644 --- a/tests/baselines/reference/objectTypeWithConstructSignatureHidingMembersOfExtendedFunction.types +++ b/tests/baselines/reference/objectTypeWithConstructSignatureHidingMembersOfExtendedFunction.types @@ -61,7 +61,7 @@ var r1e = i['hm']; // should be Object >r1e : any >i['hm'] : any >i : I ->'hm' : string +>'hm' : "hm" var x: { >x : { new (): number; apply(a: any, b?: any): void; call(thisArg: number, ...argArray: number[]): any; } @@ -110,5 +110,5 @@ var r2e = x['hm']; // should be Object >r2e : any >x['hm'] : any >x : { new (): number; apply(a: any, b?: any): void; call(thisArg: number, ...argArray: number[]): any; } ->'hm' : string +>'hm' : "hm" diff --git a/tests/baselines/reference/objectTypeWithNumericProperty.types b/tests/baselines/reference/objectTypeWithNumericProperty.types index 32efd3398fb..52a27ea09af 100644 --- a/tests/baselines/reference/objectTypeWithNumericProperty.types +++ b/tests/baselines/reference/objectTypeWithNumericProperty.types @@ -16,25 +16,25 @@ var r1 = c[1]; >r1 : number >c[1] : number >c : C ->1 : number +>1 : 1 var r2 = c[1.1]; >r2 : string >c[1.1] : string >c : C ->1.1 : number +>1.1 : 1.1 var r3 = c['1']; >r3 : number >c['1'] : number >c : C ->'1' : string +>'1' : "1" var r4 = c['1.1']; >r4 : string >c['1.1'] : string >c : C ->'1.1' : string +>'1.1' : "1.1" interface I { >I : I @@ -51,25 +51,25 @@ var r1 = i[1]; >r1 : number >i[1] : number >i : I ->1 : number +>1 : 1 var r2 = i[1.1]; >r2 : string >i[1.1] : string >i : I ->1.1 : number +>1.1 : 1.1 var r3 = i['1']; >r3 : number >i['1'] : number >i : I ->'1' : string +>'1' : "1" var r4 = i['1.1']; >r4 : string >i['1.1'] : string >i : I ->'1.1' : string +>'1.1' : "1.1" var a: { >a : { 1: number; 1.1: string; } @@ -82,58 +82,58 @@ var r1 = a[1]; >r1 : number >a[1] : number >a : { 1: number; 1.1: string; } ->1 : number +>1 : 1 var r2 = a[1.1]; >r2 : string >a[1.1] : string >a : { 1: number; 1.1: string; } ->1.1 : number +>1.1 : 1.1 var r3 = a['1']; >r3 : number >a['1'] : number >a : { 1: number; 1.1: string; } ->'1' : string +>'1' : "1" var r4 = a['1.1']; >r4 : string >a['1.1'] : string >a : { 1: number; 1.1: string; } ->'1.1' : string +>'1.1' : "1.1" var b = { >b : { 1: number; 1.1: string; } >{ 1: 1, 1.1: ""} : { 1: number; 1.1: string; } 1: 1, ->1 : number +>1 : 1 1.1: "" ->"" : string +>"" : "" } var r1 = b[1]; >r1 : number >b[1] : number >b : { 1: number; 1.1: string; } ->1 : number +>1 : 1 var r2 = b[1.1]; >r2 : string >b[1.1] : string >b : { 1: number; 1.1: string; } ->1.1 : number +>1.1 : 1.1 var r3 = b['1']; >r3 : number >b['1'] : number >b : { 1: number; 1.1: string; } ->'1' : string +>'1' : "1" var r4 = b['1.1']; >r4 : string >b['1.1'] : string >b : { 1: number; 1.1: string; } ->'1.1' : string +>'1.1' : "1.1" diff --git a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types index 490f3101751..5e664fadd20 100644 --- a/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types +++ b/tests/baselines/reference/objectTypeWithStringNamedNumericProperty.types @@ -32,108 +32,108 @@ var r1 = c['0.1']; >r1 : void >c['0.1'] : void >c : C ->'0.1' : string +>'0.1' : "0.1" var r2 = c['.1']; >r2 : Object >c['.1'] : Object >c : C ->'.1' : string +>'.1' : ".1" var r3 = c['1']; >r3 : number >c['1'] : number >c : C ->'1' : string +>'1' : "1" var r3 = c[1]; >r3 : number >c[1] : number >c : C ->1 : number +>1 : 1 var r4 = c['1.']; >r4 : string >c['1.'] : string >c : C ->'1.' : string +>'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically >r3 : number >c[1.] : number >c : C ->1. : number +>1. : 1 var r5 = c['1..']; >r5 : boolean >c['1..'] : boolean >c : C ->'1..' : string +>'1..' : "1.." var r6 = c['1.0']; >r6 : Date >c['1.0'] : Date >c : C ->'1.0' : string +>'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically >r3 : number >c[1.0] : number >c : C ->1.0 : number +>1.0 : 1 // BUG 823822 var r7 = i[-1]; >r7 : any >i[-1] : any >i : I ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 var r7 = i[-1.0]; >r7 : any >i[-1.0] : any >i : I ->-1.0 : number ->1.0 : number +>-1.0 : -1 +>1.0 : 1 var r8 = i["-1.0"]; >r8 : RegExp >i["-1.0"] : RegExp >i : I ->"-1.0" : string +>"-1.0" : "-1.0" var r9 = i["-1"]; >r9 : Date >i["-1"] : Date >i : I ->"-1" : string +>"-1" : "-1" var r10 = i[0x1] >r10 : number >i[0x1] : number >i : I ->0x1 : number +>0x1 : 1 var r11 = i[-0x1] >r11 : any >i[-0x1] : any >i : I ->-0x1 : number ->0x1 : number +>-0x1 : -1 +>0x1 : 1 var r12 = i[01] >r12 : number >i[01] : number >i : I ->01 : number +>01 : 1 var r13 = i[-01] >r13 : any >i[-01] : any >i : I ->-01 : number ->01 : number +>-01 : -1 +>01 : 1 interface I { >I : I @@ -163,108 +163,108 @@ var r1 = i['0.1']; >r1 : void >i['0.1'] : void >i : I ->'0.1' : string +>'0.1' : "0.1" var r2 = i['.1']; >r2 : Object >i['.1'] : Object >i : I ->'.1' : string +>'.1' : ".1" var r3 = i['1']; >r3 : number >i['1'] : number >i : I ->'1' : string +>'1' : "1" var r3 = c[1]; >r3 : number >c[1] : number >c : C ->1 : number +>1 : 1 var r4 = i['1.']; >r4 : string >i['1.'] : string >i : I ->'1.' : string +>'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically >r3 : number >c[1.] : number >c : C ->1. : number +>1. : 1 var r5 = i['1..']; >r5 : boolean >i['1..'] : boolean >i : I ->'1..' : string +>'1..' : "1.." var r6 = i['1.0']; >r6 : Date >i['1.0'] : Date >i : I ->'1.0' : string +>'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically >r3 : number >c[1.0] : number >c : C ->1.0 : number +>1.0 : 1 // BUG 823822 var r7 = i[-1]; >r7 : any >i[-1] : any >i : I ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 var r7 = i[-1.0]; >r7 : any >i[-1.0] : any >i : I ->-1.0 : number ->1.0 : number +>-1.0 : -1 +>1.0 : 1 var r8 = i["-1.0"]; >r8 : RegExp >i["-1.0"] : RegExp >i : I ->"-1.0" : string +>"-1.0" : "-1.0" var r9 = i["-1"]; >r9 : Date >i["-1"] : Date >i : I ->"-1" : string +>"-1" : "-1" var r10 = i[0x1] >r10 : number >i[0x1] : number >i : I ->0x1 : number +>0x1 : 1 var r11 = i[-0x1] >r11 : any >i[-0x1] : any >i : I ->-0x1 : number ->0x1 : number +>-0x1 : -1 +>0x1 : 1 var r12 = i[01] >r12 : number >i[01] : number >i : I ->01 : number +>01 : 1 var r13 = i[-01] >r13 : any >i[-01] : any >i : I ->-01 : number ->01 : number +>-01 : -1 +>01 : 1 var a: { >a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } @@ -290,108 +290,108 @@ var r1 = a['0.1']; >r1 : void >a['0.1'] : void >a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } ->'0.1' : string +>'0.1' : "0.1" var r2 = a['.1']; >r2 : Object >a['.1'] : Object >a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } ->'.1' : string +>'.1' : ".1" var r3 = a['1']; >r3 : number >a['1'] : number >a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } ->'1' : string +>'1' : "1" var r3 = c[1]; >r3 : number >c[1] : number >c : C ->1 : number +>1 : 1 var r4 = a['1.']; >r4 : string >a['1.'] : string >a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } ->'1.' : string +>'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically >r3 : number >c[1.] : number >c : C ->1. : number +>1. : 1 var r5 = a['1..']; >r5 : boolean >a['1..'] : boolean >a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } ->'1..' : string +>'1..' : "1.." var r6 = a['1.0']; >r6 : Date >a['1.0'] : Date >a : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": Date; } ->'1.0' : string +>'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically >r3 : number >c[1.0] : number >c : C ->1.0 : number +>1.0 : 1 // BUG 823822 var r7 = i[-1]; >r7 : any >i[-1] : any >i : I ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 var r7 = i[-1.0]; >r7 : any >i[-1.0] : any >i : I ->-1.0 : number ->1.0 : number +>-1.0 : -1 +>1.0 : 1 var r8 = i["-1.0"]; >r8 : RegExp >i["-1.0"] : RegExp >i : I ->"-1.0" : string +>"-1.0" : "-1.0" var r9 = i["-1"]; >r9 : Date >i["-1"] : Date >i : I ->"-1" : string +>"-1" : "-1" var r10 = i[0x1] >r10 : number >i[0x1] : number >i : I ->0x1 : number +>0x1 : 1 var r11 = i[-0x1] >r11 : any >i[-0x1] : any >i : I ->-0x1 : number ->0x1 : number +>-0x1 : -1 +>0x1 : 1 var r12 = i[01] >r12 : number >i[01] : number >i : I ->01 : number +>01 : 1 var r13 = i[-01] >r13 : any >i[-01] : any >i : I ->-01 : number ->01 : number +>-01 : -1 +>01 : 1 var b = { >b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } @@ -406,13 +406,13 @@ var b = { >Object : ObjectConstructor "1": 1, ->1 : number +>1 : 1 "1.": "", ->"" : string +>"" : "" "1..": true, ->true : boolean +>true : true "1.0": new Date(), >new Date() : Date @@ -430,106 +430,106 @@ var r1 = b['0.1']; >r1 : void >b['0.1'] : void >b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->'0.1' : string +>'0.1' : "0.1" var r2 = b['.1']; >r2 : Object >b['.1'] : Object >b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->'.1' : string +>'.1' : ".1" var r3 = b['1']; >r3 : number >b['1'] : number >b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->'1' : string +>'1' : "1" var r3 = c[1]; >r3 : number >c[1] : number >c : C ->1 : number +>1 : 1 var r4 = b['1.']; >r4 : string >b['1.'] : string >b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->'1.' : string +>'1.' : "1." var r3 = c[1.]; // same as indexing by 1 when done numerically >r3 : number >c[1.] : number >c : C ->1. : number +>1. : 1 var r5 = b['1..']; >r5 : boolean >b['1..'] : boolean >b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->'1..' : string +>'1..' : "1.." var r6 = b['1.0']; >r6 : Date >b['1.0'] : Date >b : { "1": number; "0.1": void; ".1": Object; "1.": string; "1..": boolean; "1.0": Date; "-1.0": RegExp; "-1": DateConstructor; } ->'1.0' : string +>'1.0' : "1.0" var r3 = c[1.0]; // same as indexing by 1 when done numerically >r3 : number >c[1.0] : number >c : C ->1.0 : number +>1.0 : 1 // BUG 823822 var r7 = i[-1]; >r7 : any >i[-1] : any >i : I ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 var r7 = i[-1.0]; >r7 : any >i[-1.0] : any >i : I ->-1.0 : number ->1.0 : number +>-1.0 : -1 +>1.0 : 1 var r8 = i["-1.0"]; >r8 : RegExp >i["-1.0"] : RegExp >i : I ->"-1.0" : string +>"-1.0" : "-1.0" var r9 = i["-1"]; >r9 : Date >i["-1"] : Date >i : I ->"-1" : string +>"-1" : "-1" var r10 = i[0x1] >r10 : number >i[0x1] : number >i : I ->0x1 : number +>0x1 : 1 var r11 = i[-0x1] >r11 : any >i[-0x1] : any >i : I ->-0x1 : number ->0x1 : number +>-0x1 : -1 +>0x1 : 1 var r12 = i[01] >r12 : number >i[01] : number >i : I ->01 : number +>01 : 1 var r13 = i[-01] >r13 : any >i[-01] : any >i : I ->-01 : number ->01 : number +>-01 : -1 +>01 : 1 diff --git a/tests/baselines/reference/objectTypeWithStringNamedPropertyOfIllegalCharacters.types b/tests/baselines/reference/objectTypeWithStringNamedPropertyOfIllegalCharacters.types index b676d284e70..ca200efcebf 100644 --- a/tests/baselines/reference/objectTypeWithStringNamedPropertyOfIllegalCharacters.types +++ b/tests/baselines/reference/objectTypeWithStringNamedPropertyOfIllegalCharacters.types @@ -17,26 +17,26 @@ var r = c[" "]; >r : number >c[" "] : number >c : C ->" " : string +>" " : " " var r2 = c[" "]; >r2 : any >c[" "] : any >c : C ->" " : string +>" " : " " var r3 = c["a b"]; >r3 : string >c["a b"] : string >c : C ->"a b" : string +>"a b" : "a b" // BUG 817263 var r4 = c["~!@#$%^&*()_+{}|:'<>?\/.,`"]; >r4 : number >c["~!@#$%^&*()_+{}|:'<>?\/.,`"] : number >c : C ->"~!@#$%^&*()_+{}|:'<>?\/.,`" : string +>"~!@#$%^&*()_+{}|:'<>?\/.,`" : "~!@#$%^&*()_+{}|:'<>?/.,`" interface I { >I : I @@ -54,26 +54,26 @@ var r = i[" "]; >r : number >i[" "] : number >i : I ->" " : string +>" " : " " var r2 = i[" "]; >r2 : any >i[" "] : any >i : I ->" " : string +>" " : " " var r3 = i["a b"]; >r3 : string >i["a b"] : string >i : I ->"a b" : string +>"a b" : "a b" // BUG 817263 var r4 = i["~!@#$%^&*()_+{}|:'<>?\/.,`"]; >r4 : number >i["~!@#$%^&*()_+{}|:'<>?\/.,`"] : number >i : I ->"~!@#$%^&*()_+{}|:'<>?\/.,`" : string +>"~!@#$%^&*()_+{}|:'<>?\/.,`" : "~!@#$%^&*()_+{}|:'<>?/.,`" var a: { @@ -88,63 +88,63 @@ var r = a[" "]; >r : number >a[" "] : number >a : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } ->" " : string +>" " : " " var r2 = a[" "]; >r2 : any >a[" "] : any >a : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } ->" " : string +>" " : " " var r3 = a["a b"]; >r3 : string >a["a b"] : string >a : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } ->"a b" : string +>"a b" : "a b" // BUG 817263 var r4 = a["~!@#$%^&*()_+{}|:'<>?\/.,`"]; >r4 : number >a["~!@#$%^&*()_+{}|:'<>?\/.,`"] : number >a : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } ->"~!@#$%^&*()_+{}|:'<>?\/.,`" : string +>"~!@#$%^&*()_+{}|:'<>?\/.,`" : "~!@#$%^&*()_+{}|:'<>?/.,`" var b = { >b : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } >{ " ": 1, "a b": "", "~!@#$%^&*()_+{}|:'<>?\/.,`": 1,} : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } " ": 1, ->1 : number +>1 : 1 "a b": "", ->"" : string +>"" : "" "~!@#$%^&*()_+{}|:'<>?\/.,`": 1, ->1 : number +>1 : 1 } var r = b[" "]; >r : number >b[" "] : number >b : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } ->" " : string +>" " : " " var r2 = b[" "]; >r2 : any >b[" "] : any >b : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } ->" " : string +>" " : " " var r3 = b["a b"]; >r3 : string >b["a b"] : string >b : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } ->"a b" : string +>"a b" : "a b" // BUG 817263 var r4 = b["~!@#$%^&*()_+{}|:'<>?\/.,`"]; >r4 : number >b["~!@#$%^&*()_+{}|:'<>?\/.,`"] : number >b : { " ": number; "a b": string; "~!@#$%^&*()_+{}|:'<>?\/.,`": number; } ->"~!@#$%^&*()_+{}|:'<>?\/.,`" : string +>"~!@#$%^&*()_+{}|:'<>?\/.,`" : "~!@#$%^&*()_+{}|:'<>?/.,`" diff --git a/tests/baselines/reference/objectTypesIdentity.types b/tests/baselines/reference/objectTypesIdentity.types index 3491682954a..af9957f9aee 100644 --- a/tests/baselines/reference/objectTypesIdentity.types +++ b/tests/baselines/reference/objectTypesIdentity.types @@ -39,7 +39,7 @@ var b = { foo: '' }; >b : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithCallSignatures.types b/tests/baselines/reference/objectTypesIdentityWithCallSignatures.types index 545e2376bb3..86a2ebec7c9 100644 --- a/tests/baselines/reference/objectTypesIdentityWithCallSignatures.types +++ b/tests/baselines/reference/objectTypesIdentityWithCallSignatures.types @@ -60,7 +60,7 @@ var b = { foo(x: string) { return ''; } }; >{ foo(x: string) { return ''; } } : { foo(x: string): string; } >foo : (x: string) => string >x : string ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithCallSignatures2.types b/tests/baselines/reference/objectTypesIdentityWithCallSignatures2.types index 378c5c4fa0c..12ebec233aa 100644 --- a/tests/baselines/reference/objectTypesIdentityWithCallSignatures2.types +++ b/tests/baselines/reference/objectTypesIdentityWithCallSignatures2.types @@ -62,7 +62,7 @@ var b = { foo(x: RegExp) { return ''; } }; >foo : (x: RegExp) => string >x : RegExp >RegExp : RegExp ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithCallSignaturesDifferingParamCounts.types b/tests/baselines/reference/objectTypesIdentityWithCallSignaturesDifferingParamCounts.types index 62426cb0333..7808037fd70 100644 --- a/tests/baselines/reference/objectTypesIdentityWithCallSignaturesDifferingParamCounts.types +++ b/tests/baselines/reference/objectTypesIdentityWithCallSignaturesDifferingParamCounts.types @@ -64,7 +64,7 @@ var b = { foo(x: string) { return ''; } }; >{ foo(x: string) { return ''; } } : { foo(x: string): string; } >foo : (x: string) => string >x : string ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithCallSignaturesWithOverloads.types b/tests/baselines/reference/objectTypesIdentityWithCallSignaturesWithOverloads.types index edaad51b32e..ea89bbc059e 100644 --- a/tests/baselines/reference/objectTypesIdentityWithCallSignaturesWithOverloads.types +++ b/tests/baselines/reference/objectTypesIdentityWithCallSignaturesWithOverloads.types @@ -110,7 +110,7 @@ var b = { >foo : (x: any) => any >x : any >'' : any ->'' : string +>'' : "" }; diff --git a/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.types b/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.types index 2e5e7231721..4dd31ec26d3 100644 --- a/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.types +++ b/tests/baselines/reference/objectTypesIdentityWithConstructSignatures2.types @@ -47,7 +47,7 @@ var b = { new(x: RegExp) { return ''; } }; // not a construct signature, functio >new : (x: RegExp) => string >x : RegExp >RegExp : RegExp ->'' : string +>'' : "" function foo1b(x: B); >foo1b : { (x: B): any; (x: B): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.types b/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.types index b7f59953959..b7d4b42a83e 100644 --- a/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.types +++ b/tests/baselines/reference/objectTypesIdentityWithConstructSignaturesDifferingParamCounts.types @@ -49,7 +49,7 @@ var b = { new(x: string) { return ''; } }; // not a construct signature, functio >{ new(x: string) { return ''; } } : { new(x: string): string; } >new : (x: string) => string >x : string ->'' : string +>'' : "" function foo1b(x: B); >foo1b : { (x: B): any; (x: B): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.types b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.types index 90ed7fd0945..33598fe815f 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.types +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints.types @@ -77,7 +77,7 @@ var b = { foo(x: T) { return ''; } }; >RegExp : RegExp >x : T >T : T ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.types b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.types index 4974b0874eb..265dd91784b 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.types +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints2.types @@ -121,7 +121,7 @@ var b = { foo(x: T, y: U) { return ''; } }; >T : T >y : U >U : U ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.types b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.types index b5c2f6bdef0..89d0ceb2c73 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.types +++ b/tests/baselines/reference/objectTypesIdentityWithGenericCallSignaturesDifferingByConstraints3.types @@ -155,7 +155,7 @@ var b = { foo(x: T, y: U) { return ''; } }; >T : T >y : U >U : U ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.types b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.types index ef3ec91f479..40c1733a1e1 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.types +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints.types @@ -60,7 +60,7 @@ var b = { new(x: T) { return ''; } }; // not a construct signa >RegExp : RegExp >x : T >T : T ->'' : string +>'' : "" function foo1b(x: B>); >foo1b : { (x: B): any; (x: B): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.types b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.types index b1d1d79ac05..2c214565809 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.types +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints2.types @@ -99,7 +99,7 @@ var b = { new(x: T, y: U) { return ''; } }; // no >T : T >y : U >U : U ->'' : string +>'' : "" function foo1b(x: B, Array>); >foo1b : { (x: B): any; (x: B): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.types b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.types index d8109a6a826..6b3dab83ded 100644 --- a/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.types +++ b/tests/baselines/reference/objectTypesIdentityWithGenericConstructSignaturesDifferingByConstraints3.types @@ -133,7 +133,7 @@ var b = { new(x: T, y: U) { return ''; } }; // not a >T : T >y : U >U : U ->'' : string +>'' : "" function foo1b(x: B); >foo1b : { (x: B): any; (x: B): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types index 78c69f0cdd3..8ac7b807cba 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers1.types @@ -51,7 +51,7 @@ var b: { [x: number]: string; } = { 0: '' }; >b : { [x: number]: string; } >x : number >{ 0: '' } : { 0: string; } ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types index a6ea5a292e5..bcf2ef6d733 100644 --- a/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types +++ b/tests/baselines/reference/objectTypesIdentityWithNumericIndexers3.types @@ -51,7 +51,7 @@ var b: { [x: number]: string; } = { 0: '' }; >b : { [x: number]: string; } >x : number >{ 0: '' } : { 0: string; } ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithOptionality.types b/tests/baselines/reference/objectTypesIdentityWithOptionality.types index bab319f3598..0e02350de9a 100644 --- a/tests/baselines/reference/objectTypesIdentityWithOptionality.types +++ b/tests/baselines/reference/objectTypesIdentityWithOptionality.types @@ -39,7 +39,7 @@ var b = { foo: '' }; >b : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" function foo2(x: I); >foo2 : { (x: I): any; (x: I): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithPrivates.types b/tests/baselines/reference/objectTypesIdentityWithPrivates.types index c828f45ac5a..6a0cf84850f 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPrivates.types +++ b/tests/baselines/reference/objectTypesIdentityWithPrivates.types @@ -49,7 +49,7 @@ var b = { foo: '' }; >b : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithPublics.types b/tests/baselines/reference/objectTypesIdentityWithPublics.types index daae624a7d1..5fe82c099ef 100644 --- a/tests/baselines/reference/objectTypesIdentityWithPublics.types +++ b/tests/baselines/reference/objectTypesIdentityWithPublics.types @@ -39,7 +39,7 @@ var b = { foo: '' }; >b : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.types b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.types index 8393eaf68a0..4028835a9c4 100644 --- a/tests/baselines/reference/objectTypesIdentityWithStringIndexers.types +++ b/tests/baselines/reference/objectTypesIdentityWithStringIndexers.types @@ -52,7 +52,7 @@ var b: { [x: string]: string; } = { foo: '' }; >x : string >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" function foo1(x: A); >foo1 : { (x: A): any; (x: A): any; } diff --git a/tests/baselines/reference/octalIntegerLiteral.types b/tests/baselines/reference/octalIntegerLiteral.types index 8352e5fac0c..f8f07da9a4b 100644 --- a/tests/baselines/reference/octalIntegerLiteral.types +++ b/tests/baselines/reference/octalIntegerLiteral.types @@ -1,30 +1,30 @@ === tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/octalIntegerLiteral.ts === var oct1 = 0o45436; >oct1 : number ->0o45436 : number +>0o45436 : 19230 var oct2 = 0O45436; >oct2 : number ->0O45436 : number +>0O45436 : 19230 var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct3 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : number +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : Infinity var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct4 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : number +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : 5.462437423415177e+244 var obj1 = { >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } >{ 0o45436: "Hello", a: 0o45436, b: oct1, oct1, 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: true} : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } 0o45436: "Hello", ->"Hello" : string +>"Hello" : "Hello" a: 0o45436, >a : number ->0o45436 : number +>0o45436 : 19230 b: oct1, >b : number @@ -34,7 +34,7 @@ var obj1 = { >oct1 : number 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: true ->true : boolean +>true : true } var obj2 = { @@ -42,11 +42,11 @@ var obj2 = { >{ 0O45436: "hi", a: 0O45436, b: oct2, oct2, 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: false,} : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } 0O45436: "hi", ->"hi" : string +>"hi" : "hi" a: 0O45436, >a : number ->0O45436 : number +>0O45436 : 19230 b: oct2, >b : number @@ -56,96 +56,96 @@ var obj2 = { >oct2 : number 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: false, ->false : boolean +>false : false } obj1[0o45436]; // string >obj1[0o45436] : string >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->0o45436 : number +>0o45436 : 19230 obj1["0o45436"]; // any >obj1["0o45436"] : any >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"0o45436" : string +>"0o45436" : "0o45436" obj1["19230"]; // string >obj1["19230"] : string >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"19230" : string +>"19230" : "19230" obj1[19230]; // string >obj1[19230] : string >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->19230 : number +>19230 : 19230 obj1["a"]; // number >obj1["a"] : number >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"a" : string +>"a" : "a" obj1["b"]; // number >obj1["b"] : number >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"b" : string +>"b" : "b" obj1["oct1"]; // number >obj1["oct1"] : number >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"oct1" : string +>"oct1" : "oct1" obj1["Infinity"]; // boolean >obj1["Infinity"] : boolean >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"Infinity" : string +>"Infinity" : "Infinity" obj2[0O45436]; // string >obj2[0O45436] : string >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->0O45436 : number +>0O45436 : 19230 obj2["0O45436"]; // any >obj2["0O45436"] : any >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"0O45436" : string +>"0O45436" : "0O45436" obj2["19230"]; // string >obj2["19230"] : string >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"19230" : string +>"19230" : "19230" obj2[19230]; // string >obj2[19230] : string >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->19230 : number +>19230 : 19230 obj2["a"]; // number >obj2["a"] : number >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"a" : string +>"a" : "a" obj2["b"]; // number >obj2["b"] : number >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"b" : string +>"b" : "b" obj2["oct2"]; // number >obj2["oct2"] : number >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"oct2" : string +>"oct2" : "oct2" obj2[5.462437423415177e+244]; // boolean >obj2[5.462437423415177e+244] : boolean >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->5.462437423415177e+244 : number +>5.462437423415177e+244 : 5.462437423415177e+244 obj2["5.462437423415177e+244"]; // boolean >obj2["5.462437423415177e+244"] : boolean >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"5.462437423415177e+244" : string +>"5.462437423415177e+244" : "5.462437423415177e+244" obj2["Infinity"]; // any >obj2["Infinity"] : any >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"Infinity" : string +>"Infinity" : "Infinity" diff --git a/tests/baselines/reference/octalIntegerLiteralES6.types b/tests/baselines/reference/octalIntegerLiteralES6.types index 7ef32b49289..06061be5d58 100644 --- a/tests/baselines/reference/octalIntegerLiteralES6.types +++ b/tests/baselines/reference/octalIntegerLiteralES6.types @@ -1,30 +1,30 @@ === tests/cases/conformance/es6/binaryAndOctalIntegerLiteral/octalIntegerLiteralES6.ts === var oct1 = 0o45436; >oct1 : number ->0o45436 : number +>0o45436 : 19230 var oct2 = 0O45436; >oct2 : number ->0O45436 : number +>0O45436 : 19230 var oct3 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct3 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : number +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : Infinity var oct4 = 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777; >oct4 : number ->0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : number +>0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 : 5.462437423415177e+244 var obj1 = { >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } >{ 0o45436: "Hello", a: 0o45436, b: oct1, oct1, 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: true} : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } 0o45436: "Hello", ->"Hello" : string +>"Hello" : "Hello" a: 0o45436, >a : number ->0o45436 : number +>0o45436 : 19230 b: oct1, >b : number @@ -34,7 +34,7 @@ var obj1 = { >oct1 : number 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: true ->true : boolean +>true : true } var obj2 = { @@ -42,11 +42,11 @@ var obj2 = { >{ 0O45436: "hi", a: 0O45436, b: oct2, oct2, 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: false,} : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } 0O45436: "hi", ->"hi" : string +>"hi" : "hi" a: 0O45436, >a : number ->0O45436 : number +>0O45436 : 19230 b: oct2, >b : number @@ -56,96 +56,96 @@ var obj2 = { >oct2 : number 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: false, ->false : boolean +>false : false } obj1[0o45436]; // string >obj1[0o45436] : string >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->0o45436 : number +>0o45436 : 19230 obj1["0o45436"]; // any >obj1["0o45436"] : any >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"0o45436" : string +>"0o45436" : "0o45436" obj1["19230"]; // string >obj1["19230"] : string >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"19230" : string +>"19230" : "19230" obj1[19230]; // string >obj1[19230] : string >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->19230 : number +>19230 : 19230 obj1["a"]; // number >obj1["a"] : number >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"a" : string +>"a" : "a" obj1["b"]; // number >obj1["b"] : number >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"b" : string +>"b" : "b" obj1["oct1"]; // number >obj1["oct1"] : number >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"oct1" : string +>"oct1" : "oct1" obj1["Infinity"]; // boolean >obj1["Infinity"] : boolean >obj1 : { 0o45436: string; a: number; b: number; oct1: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"Infinity" : string +>"Infinity" : "Infinity" obj2[0O45436]; // string >obj2[0O45436] : string >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->0O45436 : number +>0O45436 : 19230 obj2["0O45436"]; // any >obj2["0O45436"] : any >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"0O45436" : string +>"0O45436" : "0O45436" obj2["19230"]; // string >obj2["19230"] : string >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"19230" : string +>"19230" : "19230" obj2[19230]; // string >obj2[19230] : string >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->19230 : number +>19230 : 19230 obj2["a"]; // number >obj2["a"] : number >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"a" : string +>"a" : "a" obj2["b"]; // number >obj2["b"] : number >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"b" : string +>"b" : "b" obj2["oct2"]; // number >obj2["oct2"] : number >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"oct2" : string +>"oct2" : "oct2" obj2[5.462437423415177e+244]; // boolean >obj2[5.462437423415177e+244] : boolean >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->5.462437423415177e+244 : number +>5.462437423415177e+244 : 5.462437423415177e+244 obj2["5.462437423415177e+244"]; // boolean >obj2["5.462437423415177e+244"] : boolean >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"5.462437423415177e+244" : string +>"5.462437423415177e+244" : "5.462437423415177e+244" obj2["Infinity"]; // any >obj2["Infinity"] : any >obj2 : { 0O45436: string; a: number; b: number; oct2: number; 0o7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777: boolean; } ->"Infinity" : string +>"Infinity" : "Infinity" diff --git a/tests/baselines/reference/operatorsAndIntersectionTypes.types b/tests/baselines/reference/operatorsAndIntersectionTypes.types index b955059fea6..7c594b08812 100644 --- a/tests/baselines/reference/operatorsAndIntersectionTypes.types +++ b/tests/baselines/reference/operatorsAndIntersectionTypes.types @@ -12,7 +12,7 @@ function createGuid() { return "21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid; >"21EC2020-3AEA-4069-A2DD-08002B30309D" as Guid : Guid ->"21EC2020-3AEA-4069-A2DD-08002B30309D" : string +>"21EC2020-3AEA-4069-A2DD-08002B30309D" : "21EC2020-3AEA-4069-A2DD-08002B30309D" >Guid : Guid } @@ -21,7 +21,7 @@ function createSerialNo() { return 12345 as SerialNo; >12345 as SerialNo : SerialNo ->12345 : number +>12345 : 12345 >SerialNo : SerialNo } @@ -36,11 +36,11 @@ let guid = createGuid(); >createGuid : () => Guid map1[guid] = 123; // Can with tagged string ->map1[guid] = 123 : number +>map1[guid] = 123 : 123 >map1[guid] : number >map1 : { [x: string]: number; } >guid : Guid ->123 : number +>123 : 123 let map2: { [x: number]: string } = {}; >map2 : { [x: number]: string; } @@ -53,19 +53,19 @@ let serialNo = createSerialNo(); >createSerialNo : () => SerialNo map2[serialNo] = "hello"; // Can index with tagged number ->map2[serialNo] = "hello" : string +>map2[serialNo] = "hello" : "hello" >map2[serialNo] : string >map2 : { [x: number]: string; } >serialNo : SerialNo ->"hello" : string +>"hello" : "hello" const s1 = "{" + guid + "}"; >s1 : string >"{" + guid + "}" : string >"{" + guid : string ->"{" : string +>"{" : "{" >guid : Guid ->"}" : string +>"}" : "}" const s2 = guid.toLowerCase(); >s2 : string @@ -92,13 +92,13 @@ const s5 = serialNo.toPrecision(0); >serialNo.toPrecision : (precision?: number) => string >serialNo : SerialNo >toPrecision : (precision?: number) => string ->0 : number +>0 : 0 const n1 = serialNo * 3; >n1 : number >serialNo * 3 : number >serialNo : SerialNo ->3 : number +>3 : 3 const n2 = serialNo + serialNo; >n2 : number diff --git a/tests/baselines/reference/optionalAccessorsInInterface1.types b/tests/baselines/reference/optionalAccessorsInInterface1.types index d030849e554..d8751c252c3 100644 --- a/tests/baselines/reference/optionalAccessorsInInterface1.types +++ b/tests/baselines/reference/optionalAccessorsInInterface1.types @@ -21,11 +21,11 @@ defineMyProperty({}, "name", { get: function () { return 5; } }); >defineMyProperty({}, "name", { get: function () { return 5; } }) : any >defineMyProperty : (o: any, p: string, attributes: MyPropertyDescriptor) => any >{} : {} ->"name" : string ->{ get: function () { return 5; } } : { get: () => number; } ->get : () => number ->function () { return 5; } : () => number ->5 : number +>"name" : "name" +>{ get: function () { return 5; } } : { get: () => 5; } +>get : () => 5 +>function () { return 5; } : () => 5 +>5 : 5 interface MyPropertyDescriptor2 { >MyPropertyDescriptor2 : MyPropertyDescriptor2 @@ -49,9 +49,9 @@ defineMyProperty2({}, "name", { get: function () { return 5; } }); >defineMyProperty2({}, "name", { get: function () { return 5; } }) : any >defineMyProperty2 : (o: any, p: string, attributes: MyPropertyDescriptor2) => any >{} : {} ->"name" : string ->{ get: function () { return 5; } } : { get: () => number; } ->get : () => number ->function () { return 5; } : () => number ->5 : number +>"name" : "name" +>{ get: function () { return 5; } } : { get: () => 5; } +>get : () => 5 +>function () { return 5; } : () => 5 +>5 : 5 diff --git a/tests/baselines/reference/optionalBindingParameters1.errors.txt b/tests/baselines/reference/optionalBindingParameters1.errors.txt index 0780c626baf..66256edf727 100644 --- a/tests/baselines/reference/optionalBindingParameters1.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters1.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(2,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): error TS2345: Argument of type '[boolean, number, ""]' is not assignable to parameter of type '[string, number, boolean]'. Type 'boolean' is not assignable to type 'string'. @@ -15,5 +15,5 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): er foo([false, 0, ""]); ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. +!!! error TS2345: Argument of type '[boolean, number, ""]' is not assignable to parameter of type '[string, number, boolean]'. !!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParameters2.errors.txt b/tests/baselines/reference/optionalBindingParameters2.errors.txt index e67687722d0..34f36d32380 100644 --- a/tests/baselines/reference/optionalBindingParameters2.errors.txt +++ b/tests/baselines/reference/optionalBindingParameters2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(2,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature. -tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. +tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: ""; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. Types of property 'x' are incompatible. Type 'boolean' is not assignable to type 'string'. @@ -16,6 +16,6 @@ tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(8,5): er foo({ x: false, y: 0, z: "" }); ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. +!!! error TS2345: Argument of type '{ x: boolean; y: number; z: ""; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. !!! error TS2345: Types of property 'x' are incompatible. !!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt index 30ec4037c88..771ada1a464 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt +++ b/tests/baselines/reference/optionalBindingParametersInOverloads1.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(9,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(9,5): error TS2345: Argument of type '[boolean, number, ""]' is not assignable to parameter of type '[string, number, boolean]'. Type 'boolean' is not assignable to type 'string'. @@ -13,5 +13,5 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1. foo([false, 0, ""]); ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'. +!!! error TS2345: Argument of type '[boolean, number, ""]' is not assignable to parameter of type '[string, number, boolean]'. !!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt b/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt index 765fd5e3de6..e2546aff724 100644 --- a/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt +++ b/tests/baselines/reference/optionalBindingParametersInOverloads2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(9,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. +tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(9,5): error TS2345: Argument of type '{ x: boolean; y: number; z: ""; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. Types of property 'x' are incompatible. Type 'boolean' is not assignable to type 'string'. @@ -14,6 +14,6 @@ tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2. foo({ x: false, y: 0, z: "" }); ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. +!!! error TS2345: Argument of type '{ x: boolean; y: number; z: ""; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'. !!! error TS2345: Types of property 'x' are incompatible. !!! error TS2345: Type 'boolean' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/optionalMethods.types b/tests/baselines/reference/optionalMethods.types index 70fda27c012..cf545eda509 100644 --- a/tests/baselines/reference/optionalMethods.types +++ b/tests/baselines/reference/optionalMethods.types @@ -69,7 +69,7 @@ function test1(x: Foo) { >x.g : () => number >x : Foo >g : () => number ->0 : number +>0 : 0 } class Bar { @@ -83,18 +83,18 @@ class Bar { c? = 2; >c : number | undefined ->2 : number +>2 : 2 constructor(public d?: number, public e = 10) {} >d : number | undefined >e : number ->10 : number +>10 : 10 f() { >f : () => number return 1; ->1 : number +>1 : 1 } g?(): number; // Body of optional method can be omitted >g : (() => number) | undefined @@ -103,7 +103,7 @@ class Bar { >h : (() => number) | undefined return 2; ->2 : number +>2 : 2 } } @@ -175,7 +175,7 @@ function test2(x: Bar) { >x.g : () => number >x : Bar >g : () => number ->0 : number +>0 : 0 let h1 = x.h && x.h(); >h1 : number | undefined @@ -198,7 +198,7 @@ function test2(x: Bar) { >x.h : () => number >x : Bar >h : () => number ->0 : number +>0 : 0 } class Base { @@ -217,10 +217,10 @@ class Derived extends Base { a = 1; >a : number ->1 : number +>1 : 1 f(): number { return 1; } >f : () => number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/optionalParamReferencingOtherParams1.types b/tests/baselines/reference/optionalParamReferencingOtherParams1.types index 5a8963b8b33..ed8f0472191 100644 --- a/tests/baselines/reference/optionalParamReferencingOtherParams1.types +++ b/tests/baselines/reference/optionalParamReferencingOtherParams1.types @@ -5,7 +5,7 @@ function strange(x: number, y = x * 1, z = x + y) { >y : number >x * 1 : number >x : number ->1 : number +>1 : 1 >z : number >x + y : number >x : number diff --git a/tests/baselines/reference/optionalParamterAndVariableDeclaration.types b/tests/baselines/reference/optionalParamterAndVariableDeclaration.types index 36c74bf00b9..ad153779039 100644 --- a/tests/baselines/reference/optionalParamterAndVariableDeclaration.types +++ b/tests/baselines/reference/optionalParamterAndVariableDeclaration.types @@ -10,7 +10,7 @@ class C { >(options || 0) : number >options || 0 : number >options : number ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/optionsInlineSourceMapSourceRoot.types b/tests/baselines/reference/optionsInlineSourceMapSourceRoot.types index 1f6a5fc9dc6..a1a47c3f975 100644 --- a/tests/baselines/reference/optionsInlineSourceMapSourceRoot.types +++ b/tests/baselines/reference/optionsInlineSourceMapSourceRoot.types @@ -2,5 +2,5 @@ var a = 10; >a : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/optionsSourcemapInlineSources.types b/tests/baselines/reference/optionsSourcemapInlineSources.types index 42fa1839371..1c9865777bb 100644 --- a/tests/baselines/reference/optionsSourcemapInlineSources.types +++ b/tests/baselines/reference/optionsSourcemapInlineSources.types @@ -2,5 +2,5 @@ var a = 10; >a : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/optionsSourcemapInlineSourcesMapRoot.types b/tests/baselines/reference/optionsSourcemapInlineSourcesMapRoot.types index 77abb6f7b11..cfe881d34f5 100644 --- a/tests/baselines/reference/optionsSourcemapInlineSourcesMapRoot.types +++ b/tests/baselines/reference/optionsSourcemapInlineSourcesMapRoot.types @@ -2,5 +2,5 @@ var a = 10; >a : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.types b/tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.types index 3689afc382c..02226ff945a 100644 --- a/tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.types +++ b/tests/baselines/reference/optionsSourcemapInlineSourcesSourceRoot.types @@ -2,5 +2,5 @@ var a = 10; >a : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/out-flag.types b/tests/baselines/reference/out-flag.types index b182e4e53d9..f1dee2d3c4a 100644 --- a/tests/baselines/reference/out-flag.types +++ b/tests/baselines/reference/out-flag.types @@ -10,7 +10,7 @@ class MyClass >Count : () => number { return 42; ->42 : number +>42 : 42 } public SetCount(value: number) diff --git a/tests/baselines/reference/overload1.errors.txt b/tests/baselines/reference/overload1.errors.txt index a1d8c5a6232..a88b4f81519 100644 --- a/tests/baselines/reference/overload1.errors.txt +++ b/tests/baselines/reference/overload1.errors.txt @@ -3,7 +3,7 @@ tests/cases/compiler/overload1.ts(29,1): error TS2322: Type 'number' is not assi tests/cases/compiler/overload1.ts(31,3): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/overload1.ts(32,3): error TS2346: Supplied parameters do not match any signature of call target. 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 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/overload1.ts(34,9): error TS2345: Argument of type '2' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/overload1.ts (6 errors) ==== @@ -52,7 +52,7 @@ tests/cases/compiler/overload1.ts(34,9): error TS2345: Argument of type 'number' !!! error TS2322: Type 'C' is not assignable to type 'string'. z=x.h(2,2); // no match ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '2' is not assignable to parameter of type 'string'. z=x.h("hello",0); // good var v=x.g; diff --git a/tests/baselines/reference/overloadCallTest.types b/tests/baselines/reference/overloadCallTest.types index bd719311975..8b35c56bf57 100644 --- a/tests/baselines/reference/overloadCallTest.types +++ b/tests/baselines/reference/overloadCallTest.types @@ -13,13 +13,13 @@ class foo { function bar(foo?: string) { return "foo" }; >bar : { (): string; (s: string): any; } >foo : string ->"foo" : string +>"foo" : "foo" var test = bar("test"); >test : any >bar("test") : any >bar : { (): string; (s: string): any; } ->"test" : string +>"test" : "test" var goo = bar(); >goo : string @@ -31,7 +31,7 @@ class foo { >goo : string >bar("test") : any >bar : { (): string; (s: string): any; } ->"test" : string +>"test" : "test" } } diff --git a/tests/baselines/reference/overloadOnConstAsTypeAnnotation.types b/tests/baselines/reference/overloadOnConstAsTypeAnnotation.types index 10a185708d4..ab0dd2ae8ae 100644 --- a/tests/baselines/reference/overloadOnConstAsTypeAnnotation.types +++ b/tests/baselines/reference/overloadOnConstAsTypeAnnotation.types @@ -3,7 +3,7 @@ var f: (x: 'hi') => number = (x: 'hi') => { return 1; }; >f : (x: "hi") => number >x : "hi" ->(x: 'hi') => { return 1; } : (x: "hi") => number +>(x: 'hi') => { return 1; } : (x: "hi") => 1 >x : "hi" ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks3.types b/tests/baselines/reference/overloadOnConstConstraintChecks3.types index 0348d3d4b79..293d92d4674 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks3.types +++ b/tests/baselines/reference/overloadOnConstConstraintChecks3.types @@ -2,7 +2,7 @@ class A { private x = 1} >A : A >x : number ->1 : number +>1 : 1 class B extends A {} >B : B diff --git a/tests/baselines/reference/overloadOnConstConstraintChecks4.types b/tests/baselines/reference/overloadOnConstConstraintChecks4.types index 6ca7288ead9..7b3900038d4 100644 --- a/tests/baselines/reference/overloadOnConstConstraintChecks4.types +++ b/tests/baselines/reference/overloadOnConstConstraintChecks4.types @@ -6,7 +6,7 @@ class A extends Z { private x = 1 } >A : A >Z : Z >x : number ->1 : number +>1 : 1 class B extends A {} >B : B diff --git a/tests/baselines/reference/overloadOnConstInCallback1.types b/tests/baselines/reference/overloadOnConstInCallback1.types index c8c123df1e8..c9d954aa282 100644 --- a/tests/baselines/reference/overloadOnConstInCallback1.types +++ b/tests/baselines/reference/overloadOnConstInCallback1.types @@ -17,16 +17,16 @@ class C { callback('hi'); >callback('hi') : number >callback : (x: any) => number ->'hi' : string +>'hi' : "hi" callback('bye'); >callback('bye') : number >callback : (x: any) => number ->'bye' : string +>'bye' : "bye" var hm = "hm"; >hm : string ->"hm" : string +>"hm" : "hm" callback(hm); >callback(hm) : number diff --git a/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt b/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt index fe5219606ff..0573c6ed79e 100644 --- a/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt +++ b/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(9,8): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(9,8): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/overloadOnConstNoAnyImplementation.ts (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(9,8): error TS2345: A cb('uh'); cb(1); // error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. } var cb: (number) => number = (x: number) => 1; diff --git a/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt b/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt index 8723a79d474..e09e6ef46f6 100644 --- a/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt +++ b/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt @@ -1,8 +1,8 @@ -tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(12,18): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(18,9): error TS2345: Argument of type '(x: "bye") => number' is not assignable to parameter of type '(x: "hi") => number'. +tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(12,18): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. +tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(18,9): error TS2345: Argument of type '(x: "bye") => 1' is not assignable to parameter of type '(x: "hi") => number'. Types of parameters 'x' and 'x' are incompatible. Type '"hi"' is not assignable to type '"bye"'. -tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(21,9): error TS2345: Argument of type '(x: number) => number' is not assignable to parameter of type '(x: "hi") => number'. +tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(21,9): error TS2345: Argument of type '(x: number) => 1' is not assignable to parameter of type '(x: "hi") => number'. Types of parameters 'x' and 'x' are incompatible. Type '"hi"' is not assignable to type 'number'. @@ -21,7 +21,7 @@ tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(21,9): error TS2345: callback(hm); callback(1); // error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. } } @@ -29,13 +29,13 @@ tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(21,9): error TS2345: c.x1(1, (x: 'hi') => { return 1; } ); c.x1(1, (x: 'bye') => { return 1; } ); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: "bye") => number' is not assignable to parameter of type '(x: "hi") => number'. +!!! error TS2345: Argument of type '(x: "bye") => 1' is not assignable to parameter of type '(x: "hi") => number'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type '"hi"' is not assignable to type '"bye"'. c.x1(1, (x) => { return 1; } ); c.x1(1, (x: number) => { return 1; } ); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: number) => number' is not assignable to parameter of type '(x: "hi") => number'. +!!! error TS2345: Argument of type '(x: number) => 1' is not assignable to parameter of type '(x: "hi") => number'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type '"hi"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/overloadOnConstNoStringImplementation.types b/tests/baselines/reference/overloadOnConstNoStringImplementation.types index 9161620841f..a4d13ef06a3 100644 --- a/tests/baselines/reference/overloadOnConstNoStringImplementation.types +++ b/tests/baselines/reference/overloadOnConstNoStringImplementation.types @@ -20,16 +20,16 @@ function x2(a: number, cb: (x: any) => number) { cb('hi'); >cb('hi') : number >cb : (x: any) => number ->'hi' : string +>'hi' : "hi" cb('bye'); >cb('bye') : number >cb : (x: any) => number ->'bye' : string +>'bye' : "bye" var hm = 'hm'; >hm : string ->'hm' : string +>'hm' : "hm" cb(hm); // should this work without a string definition? >cb(hm) : number @@ -39,40 +39,40 @@ function x2(a: number, cb: (x: any) => number) { cb('uh'); >cb('uh') : number >cb : (x: any) => number ->'uh' : string +>'uh' : "uh" cb(1); >cb(1) : number >cb : (x: any) => number ->1 : number +>1 : 1 } var cb: (number) => number = (x: number) => 1; >cb : (number: any) => number >number : any ->(x: number) => 1 : (x: number) => number +>(x: number) => 1 : (x: number) => 1 >x : number ->1 : number +>1 : 1 x2(1, cb); // error >x2(1, cb) : any >x2 : { (a: number, cb: (x: "hi") => number): any; (a: number, cb: (x: "bye") => number): any; } ->1 : number +>1 : 1 >cb : (number: any) => number x2(1, (x: 'hi') => 1); // error >x2(1, (x: 'hi') => 1) : any >x2 : { (a: number, cb: (x: "hi") => number): any; (a: number, cb: (x: "bye") => number): any; } ->1 : number ->(x: 'hi') => 1 : (x: "hi") => number +>1 : 1 +>(x: 'hi') => 1 : (x: "hi") => 1 >x : "hi" ->1 : number +>1 : 1 x2(1, (x: string) => 1); >x2(1, (x: string) => 1) : any >x2 : { (a: number, cb: (x: "hi") => number): any; (a: number, cb: (x: "bye") => number): any; } ->1 : number ->(x: string) => 1 : (x: string) => number +>1 : 1 +>(x: string) => 1 : (x: string) => 1 >x : string ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/overloadOnConstNoStringImplementation2.errors.txt b/tests/baselines/reference/overloadOnConstNoStringImplementation2.errors.txt index e7ac72eb052..90081d9259b 100644 --- a/tests/baselines/reference/overloadOnConstNoStringImplementation2.errors.txt +++ b/tests/baselines/reference/overloadOnConstNoStringImplementation2.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/overloadOnConstNoStringImplementation2.ts(18,9): error TS2345: Argument of type '(x: "bye") => number' is not assignable to parameter of type '(x: "hi") => number'. +tests/cases/compiler/overloadOnConstNoStringImplementation2.ts(18,9): error TS2345: Argument of type '(x: "bye") => 1' is not assignable to parameter of type '(x: "hi") => number'. Types of parameters 'x' and 'x' are incompatible. Type '"hi"' is not assignable to type '"bye"'. -tests/cases/compiler/overloadOnConstNoStringImplementation2.ts(20,9): error TS2345: Argument of type '(x: number) => number' is not assignable to parameter of type '(x: "hi") => number'. +tests/cases/compiler/overloadOnConstNoStringImplementation2.ts(20,9): error TS2345: Argument of type '(x: number) => 1' is not assignable to parameter of type '(x: "hi") => number'. Types of parameters 'x' and 'x' are incompatible. Type '"hi"' is not assignable to type 'number'. @@ -26,12 +26,12 @@ tests/cases/compiler/overloadOnConstNoStringImplementation2.ts(20,9): error TS23 c.x1(1, (x: 'hi') => { return 1; } ); c.x1(1, (x: 'bye') => { return 1; } ); ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: "bye") => number' is not assignable to parameter of type '(x: "hi") => number'. +!!! error TS2345: Argument of type '(x: "bye") => 1' is not assignable to parameter of type '(x: "hi") => number'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type '"hi"' is not assignable to type '"bye"'. c.x1(1, (x: string) => { return 1; } ); c.x1(1, (x: number) => { return 1; } ); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: number) => number' is not assignable to parameter of type '(x: "hi") => number'. +!!! error TS2345: Argument of type '(x: number) => 1' is not assignable to parameter of type '(x: "hi") => number'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type '"hi"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/overloadResolution.errors.txt b/tests/baselines/reference/overloadResolution.errors.txt index e0a65f7475e..b8b2cdfe888 100644 --- a/tests/baselines/reference/overloadResolution.errors.txt +++ b/tests/baselines/reference/overloadResolution.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(27,5): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(41,11): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(41,11): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(63,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(70,21): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(71,21): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(70,21): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(71,21): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(81,5): error TS2344: Type 'boolean' does not satisfy the constraint 'number'. -tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(84,5): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(85,11): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(84,5): error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(85,11): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(91,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'n' must be of type 'number', but here has type 'string'. tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(91,22): error TS2339: Property 'toFixed' does not exist on type 'string'. @@ -55,7 +55,7 @@ tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(91,22): // Generic and non - generic overload where non - generic overload is the only candidate when called with type arguments fn2('', 0); // Error ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. // Generic and non - generic overload where non - generic overload is the only candidate when called without type arguments fn2('', 0); // OK @@ -88,10 +88,10 @@ tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(91,22): fn4('', 3); fn4(3, ''); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. fn4('', 3); // Error ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. fn4(3, ''); // Generic overloads with constraints called without type arguments but with types that satisfy the constraints @@ -108,10 +108,10 @@ tests/cases/conformance/expressions/functionCalls/overloadResolution.ts(91,22): // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints fn4(true, null); // Error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. fn4(null, true); // Error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. // Non - generic overloads where contextual typing of function arguments has errors function fn5(f: (n: string) => void): string; diff --git a/tests/baselines/reference/overloadResolutionClassConstructors.errors.txt b/tests/baselines/reference/overloadResolutionClassConstructors.errors.txt index c6737c3d792..4c8e9b2513a 100644 --- a/tests/baselines/reference/overloadResolutionClassConstructors.errors.txt +++ b/tests/baselines/reference/overloadResolutionClassConstructors.errors.txt @@ -2,14 +2,14 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstru tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(60,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(61,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(65,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(73,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(73,25): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(74,9): error TS2344: Type 'number' does not satisfy the constraint 'string'. tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(75,9): error TS2344: Type 'number' does not satisfy the constraint 'string'. -tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(79,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(80,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(79,9): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(80,9): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(84,9): error TS2344: Type 'boolean' does not satisfy the constraint 'string'. -tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(87,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(88,15): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(87,9): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(88,15): error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(96,18): error TS2339: Property 'toFixed' does not exist on type 'string'. tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstructors.ts(98,18): error TS2339: Property 'blah' does not exist on type 'string'. @@ -97,7 +97,7 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstru new fn4('', 3); new fn4(3, ''); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. new fn4('', 3); // Error ~~~~~~ !!! error TS2344: Type 'number' does not satisfy the constraint 'string'. @@ -109,10 +109,10 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstru new fn4('', 3); new fn4(3, ''); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. new fn4(3, undefined); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. new fn4('', null); // Generic overloads with constraints called with type arguments that do not satisfy the constraints @@ -123,10 +123,10 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionClassConstru // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints new fn4(true, null); // Error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. new fn4(null, true); // Error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. // Non - generic overloads where contextual typing of function arguments has errors class fn5 { diff --git a/tests/baselines/reference/overloadResolutionConstructors.errors.txt b/tests/baselines/reference/overloadResolutionConstructors.errors.txt index 540e12774c7..9a112eaf2ef 100644 --- a/tests/baselines/reference/overloadResolutionConstructors.errors.txt +++ b/tests/baselines/reference/overloadResolutionConstructors.errors.txt @@ -1,11 +1,11 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(27,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(43,15): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(43,15): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(67,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(77,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(78,25): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(77,25): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(78,25): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(88,9): error TS2344: Type 'boolean' does not satisfy the constraint 'number'. -tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(91,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. -tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(92,15): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(91,9): error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. +tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(92,15): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(100,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'n' must be of type 'number', but here has type 'string'. tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors.ts(100,26): error TS2339: Property 'toFixed' does not exist on type 'string'. @@ -57,7 +57,7 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors // Generic and non - generic overload where non - generic overload is the only candidate when called with type arguments new fn2('', 0); // Error ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. // Generic and non - generic overload where non - generic overload is the only candidate when called without type arguments new fn2('', 0); // OK @@ -95,10 +95,10 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors new fn4('', 3); new fn4(3, ''); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. new fn4('', 3); // Error ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. new fn4(3, ''); // Generic overloads with constraints called without type arguments but with types that satisfy the constraints @@ -115,10 +115,10 @@ tests/cases/conformance/expressions/functionCalls/overloadResolutionConstructors // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints new fn4(true, null); // Error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. new fn4(null, true); // Error ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. // Non - generic overloads where contextual typing of function arguments has errors interface fn5 { diff --git a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types index 4cf7b0b086f..ee5c336ba9c 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTLambdas.types @@ -27,7 +27,7 @@ module Bugs { >index : any >rest[0] : any >rest : any[] ->0 : number +>0 : 0 return typeof args[index] !== 'undefined' >typeof args[index] !== 'undefined' ? args[index] : match : any @@ -58,7 +58,7 @@ function bug3(f:(x:string)=>string) { return f("s") } >x : string >f("s") : string >f : (x: string) => string ->"s" : string +>"s" : "s" function fprime(x:string):string { return x; } >fprime : (x: string) => string diff --git a/tests/baselines/reference/overloadResolutionOverNonCTObjectLit.types b/tests/baselines/reference/overloadResolutionOverNonCTObjectLit.types index e6ff0cda468..d5a06781eec 100644 --- a/tests/baselines/reference/overloadResolutionOverNonCTObjectLit.types +++ b/tests/baselines/reference/overloadResolutionOverNonCTObjectLit.types @@ -46,11 +46,11 @@ module Bugs { >push : (...items: IToken[]) => number >{ startIndex: 1, type: '', bracket: 3 } : { startIndex: number; type: string; bracket: number; } >startIndex : number ->1 : number +>1 : 1 >type : string ->'' : string +>'' : "" >bracket : number ->3 : number +>3 : 3 tokens.push(({ startIndex: 1, type: '', bracket: 3, state: null, length: 10 })); >tokens.push(({ startIndex: 1, type: '', bracket: 3, state: null, length: 10 })) : number @@ -62,14 +62,14 @@ module Bugs { >({ startIndex: 1, type: '', bracket: 3, state: null, length: 10 }) : { startIndex: number; type: string; bracket: number; state: null; length: number; } >{ startIndex: 1, type: '', bracket: 3, state: null, length: 10 } : { startIndex: number; type: string; bracket: number; state: null; length: number; } >startIndex : number ->1 : number +>1 : 1 >type : string ->'' : string +>'' : "" >bracket : number ->3 : number +>3 : 3 >state : null >null : null >length : number ->10 : number +>10 : 10 } } diff --git a/tests/baselines/reference/overloadResolutionTest1.errors.txt b/tests/baselines/reference/overloadResolutionTest1.errors.txt index 9f51c0fa10b..1bb1fb2041a 100644 --- a/tests/baselines/reference/overloadResolutionTest1.errors.txt +++ b/tests/baselines/reference/overloadResolutionTest1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/overloadResolutionTest1.ts(8,16): error TS2345: Argument of type '{ a: string; }[]' is not assignable to parameter of type '{ a: boolean; }[]'. - Type '{ a: string; }' is not assignable to type '{ a: boolean; }'. +tests/cases/compiler/overloadResolutionTest1.ts(8,16): error TS2345: Argument of type '{ a: "s"; }[]' is not assignable to parameter of type '{ a: boolean; }[]'. + Type '{ a: "s"; }' is not assignable to type '{ a: boolean; }'. Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'boolean'. -tests/cases/compiler/overloadResolutionTest1.ts(19,15): error TS2345: Argument of type '{ a: string; }' is not assignable to parameter of type '{ a: boolean; }'. + Type '"s"' is not assignable to type 'boolean'. +tests/cases/compiler/overloadResolutionTest1.ts(19,15): error TS2345: Argument of type '{ a: "s"; }' is not assignable to parameter of type '{ a: boolean; }'. Types of property 'a' are incompatible. - Type 'string' is not assignable to type 'boolean'. + Type '"s"' is not assignable to type 'boolean'. tests/cases/compiler/overloadResolutionTest1.ts(25,14): error TS2345: Argument of type '{ a: boolean; }' is not assignable to parameter of type '{ a: string; }'. Types of property 'a' are incompatible. Type 'boolean' is not assignable to type 'string'. @@ -20,10 +20,10 @@ tests/cases/compiler/overloadResolutionTest1.ts(25,14): error TS2345: Argument o var x11 = foo([{a:0}]); // works var x111 = foo([{a:"s"}]); // error - does not match any signature ~~~~~~~~~ -!!! error TS2345: Argument of type '{ a: string; }[]' is not assignable to parameter of type '{ a: boolean; }[]'. -!!! error TS2345: Type '{ a: string; }' is not assignable to type '{ a: boolean; }'. +!!! error TS2345: Argument of type '{ a: "s"; }[]' is not assignable to parameter of type '{ a: boolean; }[]'. +!!! error TS2345: Type '{ a: "s"; }' is not assignable to type '{ a: boolean; }'. !!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. +!!! error TS2345: Type '"s"' is not assignable to type 'boolean'. var x1111 = foo([{a:null}]); // works - ambiguous call is resolved to be the first in the overload set so this returns a string @@ -36,9 +36,9 @@ tests/cases/compiler/overloadResolutionTest1.ts(25,14): error TS2345: Argument o var x3 = foo2({a:true}); // works var x4 = foo2({a:"s"}); // error ~~~~~~~ -!!! error TS2345: Argument of type '{ a: string; }' is not assignable to parameter of type '{ a: boolean; }'. +!!! error TS2345: Argument of type '{ a: "s"; }' is not assignable to parameter of type '{ a: boolean; }'. !!! error TS2345: Types of property 'a' are incompatible. -!!! error TS2345: Type 'string' is not assignable to type 'boolean'. +!!! error TS2345: Type '"s"' is not assignable to type 'boolean'. function foo4(bar:{a:number;}):number; diff --git a/tests/baselines/reference/overloadResolutionWithAny.types b/tests/baselines/reference/overloadResolutionWithAny.types index e66368d3554..362c70f6162 100644 --- a/tests/baselines/reference/overloadResolutionWithAny.types +++ b/tests/baselines/reference/overloadResolutionWithAny.types @@ -13,12 +13,12 @@ var func: { func(""); // number >func("") : number >func : { (s: string): number; (s: any): string; } ->"" : string +>"" : "" func(3); // string >func(3) : string >func : { (s: string): number; (s: any): string; } ->3 : number +>3 : 3 var x: any; >x : any @@ -58,18 +58,18 @@ func2(x, x); // string func2("", ""); // number >func2("", "") : number >func2 : { (s: string, t: string): number; (s: any, t: string): boolean; (s: string, t: any): RegExp; (s: any, t: any): string; } ->"" : string ->"" : string +>"" : "" +>"" : "" func2(x, ""); // boolean >func2(x, "") : boolean >func2 : { (s: string, t: string): number; (s: any, t: string): boolean; (s: string, t: any): RegExp; (s: any, t: any): string; } >x : any ->"" : string +>"" : "" func2("", x); // RegExp >func2("", x) : RegExp >func2 : { (s: string, t: string): number; (s: any, t: string): boolean; (s: string, t: any): RegExp; (s: any, t: any): string; } ->"" : string +>"" : "" >x : any diff --git a/tests/baselines/reference/overloadReturnTypes.types b/tests/baselines/reference/overloadReturnTypes.types index e8d1b7905dc..c0f573fb980 100644 --- a/tests/baselines/reference/overloadReturnTypes.types +++ b/tests/baselines/reference/overloadReturnTypes.types @@ -38,7 +38,7 @@ function attr(nameOrMap: any, value?: string): any { else { // handle string case return "s"; ->"s" : string +>"s" : "s" } } diff --git a/tests/baselines/reference/overloadWithCallbacksWithDifferingOptionalityOnArgs.types b/tests/baselines/reference/overloadWithCallbacksWithDifferingOptionalityOnArgs.types index b9ea7d98270..5cf070df0fe 100644 --- a/tests/baselines/reference/overloadWithCallbacksWithDifferingOptionalityOnArgs.types +++ b/tests/baselines/reference/overloadWithCallbacksWithDifferingOptionalityOnArgs.types @@ -17,13 +17,13 @@ function x2(callback: (x: any) => number) { } x2(() => 1); >x2(() => 1) : any >x2 : { (callback: (x?: number) => number): any; (callback: (x: string) => number): any; } ->() => 1 : () => number ->1 : number +>() => 1 : () => 1 +>1 : 1 x2((x) => 1 ); >x2((x) => 1 ) : any >x2 : { (callback: (x?: number) => number): any; (callback: (x: string) => number): any; } ->(x) => 1 : (x: number) => number +>(x) => 1 : (x: number) => 1 >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/overloadsAndTypeArgumentArity.types b/tests/baselines/reference/overloadsAndTypeArgumentArity.types index b69f394e83d..bd86c19beb9 100644 --- a/tests/baselines/reference/overloadsAndTypeArgumentArity.types +++ b/tests/baselines/reference/overloadsAndTypeArgumentArity.types @@ -24,10 +24,10 @@ declare function Callbacks(flags?: string): void; Callbacks('s'); // no error >Callbacks('s') : void >Callbacks : { (flags?: string): void; (flags?: string): void; (flags?: string): void; (flags?: string): void; } ->'s' : string +>'s' : "s" new Callbacks('s'); // no error >new Callbacks('s') : any >Callbacks : { (flags?: string): void; (flags?: string): void; (flags?: string): void; (flags?: string): void; } ->'s' : string +>'s' : "s" diff --git a/tests/baselines/reference/overloadsWithConstraints.types b/tests/baselines/reference/overloadsWithConstraints.types index b045904ece5..87974482f43 100644 --- a/tests/baselines/reference/overloadsWithConstraints.types +++ b/tests/baselines/reference/overloadsWithConstraints.types @@ -19,5 +19,5 @@ var v = f(""); >v : string >f("") : string >f : { (x: T): T; (x: T): T; } ->"" : string +>"" : "" diff --git a/tests/baselines/reference/parenthesizedContexualTyping1.types b/tests/baselines/reference/parenthesizedContexualTyping1.types index 61ec1a24ec5..387e80d349f 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping1.types +++ b/tests/baselines/reference/parenthesizedContexualTyping1.types @@ -50,7 +50,7 @@ var a = fun(x => x, 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var b = fun((x => x), 10); >b : number @@ -60,7 +60,7 @@ var b = fun((x => x), 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var c = fun(((x => x)), 10); >c : number @@ -71,7 +71,7 @@ var c = fun(((x => x)), 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var d = fun((((x => x))), 10); >d : number @@ -83,7 +83,7 @@ var d = fun((((x => x))), 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var e = fun(x => x, x => x, 10); >e : number @@ -95,7 +95,7 @@ var e = fun(x => x, x => x, 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var f = fun((x => x), (x => x), 10); >f : number @@ -109,7 +109,7 @@ var f = fun((x => x), (x => x), 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var g = fun(((x => x)), ((x => x)), 10); >g : number @@ -125,7 +125,7 @@ var g = fun(((x => x)), ((x => x)), 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var h = fun((((x => x))), ((x => x)), 10); >h : number @@ -142,7 +142,7 @@ var h = fun((((x => x))), ((x => x)), 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 // Ternaries in parens var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); @@ -156,14 +156,14 @@ var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10); >Math.random : () => number >Math : Math >random : () => number ->0.5 : number +>0.5 : 0.5 >x => x : (x: number) => number >x : number >x : number >x => undefined : (x: number) => any >x : number >undefined : undefined ->10 : number +>10 : 10 var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >j : number @@ -176,7 +176,7 @@ var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >Math.random : () => number >Math : Math >random : () => number ->0.5 : number +>0.5 : 0.5 >(x => x) : (x: number) => number >x => x : (x: number) => number >x : number @@ -185,7 +185,7 @@ var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10); >x => undefined : (x: number) => any >x : number >undefined : undefined ->10 : number +>10 : 10 var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >k : number @@ -198,7 +198,7 @@ var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >Math.random : () => number >Math : Math >random : () => number ->0.5 : number +>0.5 : 0.5 >(x => x) : (x: number) => number >x => x : (x: number) => number >x : number @@ -210,7 +210,7 @@ var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10); >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10); >l : number @@ -224,7 +224,7 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >Math.random : () => number >Math : Math >random : () => number ->0.5 : number +>0.5 : 0.5 >((x => x)) : (x: number) => number >(x => x) : (x: number) => number >x => x : (x: number) => number @@ -240,7 +240,7 @@ var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x) >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var lambda1: (x: number) => number = x => x; >lambda1 : (x: number) => number diff --git a/tests/baselines/reference/parenthesizedContexualTyping2.types b/tests/baselines/reference/parenthesizedContexualTyping2.types index aa6e1916f81..ffca8ede3d9 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping2.types +++ b/tests/baselines/reference/parenthesizedContexualTyping2.types @@ -54,7 +54,7 @@ var a = fun(x => { x(undefined); return x; }, 10); >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var b = fun((x => { x(undefined); return x; }), 10); >b : number @@ -67,7 +67,7 @@ var b = fun((x => { x(undefined); return x; }), 10); >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var c = fun(((x => { x(undefined); return x; })), 10); >c : number @@ -81,7 +81,7 @@ var c = fun(((x => { x(undefined); return x; })), 10); >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var d = fun((((x => { x(undefined); return x; }))), 10); >d : number @@ -96,7 +96,7 @@ var d = fun((((x => { x(undefined); return x; }))), 10); >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var e = fun(x => { x(undefined); return x; }, x => { x(undefined); return x; }, 10); >e : number @@ -114,7 +114,7 @@ var e = fun(x => { x(undefined); return x; }, x => { x(undefined >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var f = fun((x => { x(undefined); return x; }),(x => { x(undefined); return x; }), 10); >f : number @@ -134,7 +134,7 @@ var f = fun((x => { x(undefined); return x; }),(x => { x(undefin >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var g = fun(((x => { x(undefined); return x; })),((x => { x(undefined); return x; })), 10); >g : number @@ -156,7 +156,7 @@ var g = fun(((x => { x(undefined); return x; })),((x => { x(unde >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var h = fun((((x => { x(undefined); return x; }))),((x => { x(undefined); return x; })), 10); >h : number @@ -179,7 +179,7 @@ var h = fun((((x => { x(undefined); return x; }))),((x => { x(un >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 // Ternaries in parens var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x => undefined), 10); @@ -193,7 +193,7 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >Math.random : () => number >Math : Math >random : () => number ->0.5 : number +>0.5 : 0.5 >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T >x : (p: T) => T >x(undefined) : number @@ -203,7 +203,7 @@ var i = fun((Math.random() < 0.5 ? x => { x(undefined); return x; } : x >x => undefined : (x: (p: T) => T) => any >x : (p: T) => T >undefined : undefined ->10 : number +>10 : 10 var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), 10); >j : number @@ -216,7 +216,7 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >Math.random : () => number >Math : Math >random : () => number ->0.5 : number +>0.5 : 0.5 >(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T >x : (p: T) => T @@ -228,7 +228,7 @@ var j = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >x => undefined : (x: (p: T) => T) => any >x : (p: T) => T >undefined : undefined ->10 : number +>10 : 10 var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : (x => undefined)), x => { x(undefined); return x; }, 10); >k : number @@ -241,7 +241,7 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >Math.random : () => number >Math : Math >random : () => number ->0.5 : number +>0.5 : 0.5 >(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T >x : (p: T) => T @@ -259,7 +259,7 @@ var k = fun((Math.random() < 0.5 ? (x => { x(undefined); return x; }) : >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) : ((x => undefined)))),((x => { x(undefined); return x; })), 10); >l : number @@ -273,7 +273,7 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >Math.random : () => number >Math : Math >random : () => number ->0.5 : number +>0.5 : 0.5 >((x => { x(undefined); return x; })) : (x: (p: T) => T) => (p: T) => T >(x => { x(undefined); return x; }) : (x: (p: T) => T) => (p: T) => T >x => { x(undefined); return x; } : (x: (p: T) => T) => (p: T) => T @@ -295,7 +295,7 @@ var l = fun(((Math.random() < 0.5 ? ((x => { x(undefined); return x; })) >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 var lambda1: FuncType = x => { x(undefined); return x; }; >lambda1 : FuncType diff --git a/tests/baselines/reference/parenthesizedContexualTyping3.types b/tests/baselines/reference/parenthesizedContexualTyping3.types index 5d424e5a7b0..522228b260d 100644 --- a/tests/baselines/reference/parenthesizedContexualTyping3.types +++ b/tests/baselines/reference/parenthesizedContexualTyping3.types @@ -62,7 +62,7 @@ var a = tempFun `${ x => x } ${ 10 }` >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var b = tempFun `${ (x => x) } ${ 10 }` >b : number @@ -73,7 +73,7 @@ var b = tempFun `${ (x => x) } ${ 10 }` >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var c = tempFun `${ ((x => x)) } ${ 10 }` >c : number @@ -85,7 +85,7 @@ var c = tempFun `${ ((x => x)) } ${ 10 }` >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var d = tempFun `${ x => x } ${ x => x } ${ 10 }` >d : number @@ -98,7 +98,7 @@ var d = tempFun `${ x => x } ${ x => x } ${ 10 }` >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }` >e : number @@ -112,7 +112,7 @@ var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }` >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }` >f : number @@ -127,7 +127,7 @@ var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }` >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }` >g : number @@ -144,7 +144,7 @@ var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }` >x => x : (x: number) => number >x : number >x : number ->10 : number +>10 : 10 var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }` >h : any diff --git a/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt index 6f45030a650..16eb82ecb34 100644 --- a/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt +++ b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt @@ -1,7 +1,7 @@ tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(4,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(5,17): error TS1210: Invalid use of 'eval'. Class definitions are automatically in strict mode. tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS2322: Type 'string' is not assignable to type 'IArguments'. +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS2322: Type '"hello"' is not assignable to type 'IArguments'. ==== tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts (4 errors) ==== @@ -18,6 +18,6 @@ tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeBy ~~~~~~~~~ !!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. ~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'IArguments'. +!!! error TS2322: Type '"hello"' is not assignable to type 'IArguments'. } } \ No newline at end of file diff --git a/tests/baselines/reference/parser509546_2.types b/tests/baselines/reference/parser509546_2.types index 211553286a5..819b972254d 100644 --- a/tests/baselines/reference/parser509546_2.types +++ b/tests/baselines/reference/parser509546_2.types @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/RegressionTests/parser509546_2.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" export class Logger { >Logger : Logger diff --git a/tests/baselines/reference/parser630933.types b/tests/baselines/reference/parser630933.types index 3f991f58d30..9a0ba9e7205 100644 --- a/tests/baselines/reference/parser630933.types +++ b/tests/baselines/reference/parser630933.types @@ -1,7 +1,7 @@ === tests/cases/conformance/parser/ecmascript5/RegressionTests/parser630933.ts === var a = "Hello"; >a : string ->"Hello" : string +>"Hello" : "Hello" var b = a.match(/\/ver=([^/]+)/); >b : RegExpMatchArray diff --git a/tests/baselines/reference/parser768531.types b/tests/baselines/reference/parser768531.types index 434535b5cc9..17bae7161fa 100644 --- a/tests/baselines/reference/parser768531.types +++ b/tests/baselines/reference/parser768531.types @@ -2,7 +2,7 @@ {a: 3} >a : any ->3 : number +>3 : 3 /x/ >/x/ : RegExp diff --git a/tests/baselines/reference/parserAccessibilityAfterStatic3.types b/tests/baselines/reference/parserAccessibilityAfterStatic3.types index c85c5077392..3bf87f8807f 100644 --- a/tests/baselines/reference/parserAccessibilityAfterStatic3.types +++ b/tests/baselines/reference/parserAccessibilityAfterStatic3.types @@ -4,6 +4,6 @@ class Outer { static public = 1; >public : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/parserAmbiguityWithBinaryOperator1.types b/tests/baselines/reference/parserAmbiguityWithBinaryOperator1.types index bdeb5ab7bbc..234375fb46d 100644 --- a/tests/baselines/reference/parserAmbiguityWithBinaryOperator1.types +++ b/tests/baselines/reference/parserAmbiguityWithBinaryOperator1.types @@ -17,5 +17,5 @@ function f1() { >(c + 1) : any >c + 1 : any >c : any ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/parserAmbiguityWithBinaryOperator2.types b/tests/baselines/reference/parserAmbiguityWithBinaryOperator2.types index 79eb212163e..ed3b4b903bb 100644 --- a/tests/baselines/reference/parserAmbiguityWithBinaryOperator2.types +++ b/tests/baselines/reference/parserAmbiguityWithBinaryOperator2.types @@ -17,5 +17,5 @@ function f() { >(c + 1) : any >c + 1 : any >c : any ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/parserAmbiguityWithBinaryOperator3.types b/tests/baselines/reference/parserAmbiguityWithBinaryOperator3.types index aba5f4872d8..61601d8bdf6 100644 --- a/tests/baselines/reference/parserAmbiguityWithBinaryOperator3.types +++ b/tests/baselines/reference/parserAmbiguityWithBinaryOperator3.types @@ -17,6 +17,6 @@ function f() { >(c + 1) : any >c + 1 : any >c : any ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/parserArrayLiteralExpression10.types b/tests/baselines/reference/parserArrayLiteralExpression10.types index 370e9fb6c9d..7960490e7cf 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression10.types +++ b/tests/baselines/reference/parserArrayLiteralExpression10.types @@ -2,6 +2,6 @@ var v = [1,1,]; >v : number[] >[1,1,] : number[] ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression11.types b/tests/baselines/reference/parserArrayLiteralExpression11.types index aba6e30a291..36491c96655 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression11.types +++ b/tests/baselines/reference/parserArrayLiteralExpression11.types @@ -2,7 +2,7 @@ var v = [1,,1]; >v : number[] >[1,,1] : number[] ->1 : number +>1 : 1 > : undefined ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression12.types b/tests/baselines/reference/parserArrayLiteralExpression12.types index 7d9e4c38976..cd861667501 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression12.types +++ b/tests/baselines/reference/parserArrayLiteralExpression12.types @@ -2,8 +2,8 @@ var v = [1,,,1]; >v : number[] >[1,,,1] : number[] ->1 : number +>1 : 1 > : undefined > : undefined ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression13.types b/tests/baselines/reference/parserArrayLiteralExpression13.types index 62fb9aea5f7..7d377e9ac5a 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression13.types +++ b/tests/baselines/reference/parserArrayLiteralExpression13.types @@ -2,9 +2,9 @@ var v = [1,,1,,1]; >v : number[] >[1,,1,,1] : number[] ->1 : number +>1 : 1 > : undefined ->1 : number +>1 : 1 > : undefined ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression14.types b/tests/baselines/reference/parserArrayLiteralExpression14.types index 9d3a029aed2..aa08d2b13d0 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression14.types +++ b/tests/baselines/reference/parserArrayLiteralExpression14.types @@ -4,13 +4,13 @@ var v = [,,1,1,,1,,1,1,,1]; >[,,1,1,,1,,1,1,,1] : number[] > : undefined > : undefined ->1 : number ->1 : number +>1 : 1 +>1 : 1 > : undefined ->1 : number +>1 : 1 > : undefined ->1 : number ->1 : number +>1 : 1 +>1 : 1 > : undefined ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression15.types b/tests/baselines/reference/parserArrayLiteralExpression15.types index 75afab3731c..7f7b855a007 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression15.types +++ b/tests/baselines/reference/parserArrayLiteralExpression15.types @@ -4,13 +4,13 @@ var v = [,,1,1,,1,,1,1,,1,]; >[,,1,1,,1,,1,1,,1,] : number[] > : undefined > : undefined ->1 : number ->1 : number +>1 : 1 +>1 : 1 > : undefined ->1 : number +>1 : 1 > : undefined ->1 : number ->1 : number +>1 : 1 +>1 : 1 > : undefined ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression5.types b/tests/baselines/reference/parserArrayLiteralExpression5.types index 48fdaa024fc..b1b2e59b8d4 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression5.types +++ b/tests/baselines/reference/parserArrayLiteralExpression5.types @@ -2,5 +2,5 @@ var v = [1]; >v : number[] >[1] : number[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression6.types b/tests/baselines/reference/parserArrayLiteralExpression6.types index 66df1cda219..f13db817901 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression6.types +++ b/tests/baselines/reference/parserArrayLiteralExpression6.types @@ -3,5 +3,5 @@ var v = [,1]; >v : number[] >[,1] : number[] > : undefined ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression7.types b/tests/baselines/reference/parserArrayLiteralExpression7.types index 65225500eb2..35d786ea67b 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression7.types +++ b/tests/baselines/reference/parserArrayLiteralExpression7.types @@ -2,5 +2,5 @@ var v = [1,]; >v : number[] >[1,] : number[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression8.types b/tests/baselines/reference/parserArrayLiteralExpression8.types index e14c99f3b57..7ea2b3b8e5c 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression8.types +++ b/tests/baselines/reference/parserArrayLiteralExpression8.types @@ -3,5 +3,5 @@ var v = [,1,]; >v : number[] >[,1,] : number[] > : undefined ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserArrayLiteralExpression9.types b/tests/baselines/reference/parserArrayLiteralExpression9.types index 96bb1595326..3dc1326c812 100644 --- a/tests/baselines/reference/parserArrayLiteralExpression9.types +++ b/tests/baselines/reference/parserArrayLiteralExpression9.types @@ -2,6 +2,6 @@ var v = [1,1]; >v : number[] >[1,1] : number[] ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/parserDoStatement2.types b/tests/baselines/reference/parserDoStatement2.types index 5affaa958d6..9e83f6ad6d2 100644 --- a/tests/baselines/reference/parserDoStatement2.types +++ b/tests/baselines/reference/parserDoStatement2.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/Statements/parserDoStatement2.ts === do{;}while(false)false ->false : boolean ->false : boolean +>false : false +>false : false diff --git a/tests/baselines/reference/parserEmptyStatement1.types b/tests/baselines/reference/parserEmptyStatement1.types index a581dd6e871..1cb1e33b2b8 100644 --- a/tests/baselines/reference/parserEmptyStatement1.types +++ b/tests/baselines/reference/parserEmptyStatement1.types @@ -2,7 +2,7 @@ ; ; var a = 1; >a : number ->1 : number +>1 : 1 ; diff --git a/tests/baselines/reference/parserEnum1.types b/tests/baselines/reference/parserEnum1.types index 34d11a1858d..42161656a1e 100644 --- a/tests/baselines/reference/parserEnum1.types +++ b/tests/baselines/reference/parserEnum1.types @@ -6,21 +6,21 @@ None = 0, >None : SignatureFlags ->0 : number +>0 : 0 IsIndexer = 1, >IsIndexer : SignatureFlags ->1 : number +>1 : 1 IsStringIndexer = 1 << 1, >IsStringIndexer : SignatureFlags >1 << 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 IsNumberIndexer = 1 << 2, >IsNumberIndexer : SignatureFlags >1 << 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 } diff --git a/tests/baselines/reference/parserEnum2.types b/tests/baselines/reference/parserEnum2.types index 6d119d8f079..5c0a8fec2d4 100644 --- a/tests/baselines/reference/parserEnum2.types +++ b/tests/baselines/reference/parserEnum2.types @@ -6,21 +6,21 @@ None = 0, >None : SignatureFlags ->0 : number +>0 : 0 IsIndexer = 1, >IsIndexer : SignatureFlags ->1 : number +>1 : 1 IsStringIndexer = 1 << 1, >IsStringIndexer : SignatureFlags >1 << 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 IsNumberIndexer = 1 << 2 >IsNumberIndexer : SignatureFlags >1 << 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 } diff --git a/tests/baselines/reference/parserEnumDeclaration1.types b/tests/baselines/reference/parserEnumDeclaration1.types index de99855b310..cd58d5dc89a 100644 --- a/tests/baselines/reference/parserEnumDeclaration1.types +++ b/tests/baselines/reference/parserEnumDeclaration1.types @@ -3,9 +3,9 @@ enum E { >E : E Foo = 1, ->Foo : E ->1 : number +>Foo : E.Foo +>1 : 1 Bar ->Bar : E +>Bar : E.Bar } diff --git a/tests/baselines/reference/parserEnumDeclaration3.types b/tests/baselines/reference/parserEnumDeclaration3.types index b427a795eb6..027f837229f 100644 --- a/tests/baselines/reference/parserEnumDeclaration3.types +++ b/tests/baselines/reference/parserEnumDeclaration3.types @@ -4,5 +4,5 @@ declare enum E { A = 1 >A : E ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/parserEnumDeclaration5.types b/tests/baselines/reference/parserEnumDeclaration5.types index bbb596b7b0f..4068eed0a4b 100644 --- a/tests/baselines/reference/parserEnumDeclaration5.types +++ b/tests/baselines/reference/parserEnumDeclaration5.types @@ -3,16 +3,16 @@ enum E { >E : E A = 1, ->A : E ->1 : number +>A : E.A +>1 : 1 B, ->B : E +>B : E.B C = 2, ->C : E ->2 : number +>C : E.B +>2 : 2 D ->D : E +>D : E.D } diff --git a/tests/baselines/reference/parserEnumDeclaration6.types b/tests/baselines/reference/parserEnumDeclaration6.types index c13d66db41c..53d1e636750 100644 --- a/tests/baselines/reference/parserEnumDeclaration6.types +++ b/tests/baselines/reference/parserEnumDeclaration6.types @@ -4,7 +4,7 @@ enum E { A = 1, >A : E ->1 : number +>1 : 1 B, >B : E @@ -12,8 +12,8 @@ enum E { C = 1 << 1, >C : E >1 << 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 D, >D : E diff --git a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types index b38bbbfe64d..161824e512d 100644 --- a/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types +++ b/tests/baselines/reference/parserErrorRecovery_IncompleteMemberVariable1.types @@ -52,8 +52,8 @@ module Shapes { >origin : Point >new Point(0, 0) : Point >Point : typeof Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 } } @@ -66,8 +66,8 @@ var p: IPoint = new Shapes.Point(3, 4); >Shapes.Point : typeof Shapes.Point >Shapes : typeof Shapes >Point : typeof Shapes.Point ->3 : number ->4 : number +>3 : 3 +>4 : 4 var dist = p.getDist(); >dist : number diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity1.types b/tests/baselines/reference/parserGreaterThanTokenAmbiguity1.types index 0449fdda85a..1c82fb807d8 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity1.types +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity1.types @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity1.ts === 1 >> 2; >1 >> 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity10.types b/tests/baselines/reference/parserGreaterThanTokenAmbiguity10.types index 8b3d5dd2ba3..cda7a97701e 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity10.types +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity10.types @@ -1,10 +1,10 @@ === tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity10.ts === 1 >1 // before>>> // after2 : number ->1 : number +>1 : 1 // before >>> // after 2; ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity2.errors.txt b/tests/baselines/reference/parserGreaterThanTokenAmbiguity2.errors.txt index 30ede342a85..ee2d3666682 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity2.errors.txt +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity2.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity2.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity2.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity2.ts(1,5): error TS1109: Expression expected. ==== tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity2.ts (2 errors) ==== 1 > > 2; ~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.errors.txt b/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.errors.txt index baebfd81304..1651009bf0d 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.errors.txt +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity3.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity3.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity3.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity3.ts(1,8): error TS1109: Expression expected. ==== tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity3.ts (2 errors) ==== 1 >/**/> 2; ~~~~~~~~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity4.errors.txt b/tests/baselines/reference/parserGreaterThanTokenAmbiguity4.errors.txt index 924c9440d16..dff69b37612 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity4.errors.txt +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity4.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. +tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity4.ts(1,1): error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity4.ts(2,1): error TS1109: Expression expected. @@ -7,6 +7,6 @@ tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbigu ~~~ > 2; ~~~ -!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and 'number'. +!!! error TS2365: Operator '>' cannot be applied to types 'boolean' and '2'. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity5.types b/tests/baselines/reference/parserGreaterThanTokenAmbiguity5.types index 609901bfdd5..0dc774103aa 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity5.types +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity5.types @@ -1,10 +1,10 @@ === tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity5.ts === 1 >1 // before>> // after2 : number ->1 : number +>1 : 1 // before >> // after 2; ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/parserGreaterThanTokenAmbiguity6.types b/tests/baselines/reference/parserGreaterThanTokenAmbiguity6.types index e7aa311113c..171211bfbab 100644 --- a/tests/baselines/reference/parserGreaterThanTokenAmbiguity6.types +++ b/tests/baselines/reference/parserGreaterThanTokenAmbiguity6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/Generics/parserGreaterThanTokenAmbiguity6.ts === 1 >>> 2; >1 >>> 2 : number ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/parserInterfaceKeywordInEnum1.types b/tests/baselines/reference/parserInterfaceKeywordInEnum1.types index f6b613f3f60..57c4ef2ebec 100644 --- a/tests/baselines/reference/parserInterfaceKeywordInEnum1.types +++ b/tests/baselines/reference/parserInterfaceKeywordInEnum1.types @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/EnumDeclarations/parserInterfaceKeywordInEnum1.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" enum Bar { >Bar : Bar diff --git a/tests/baselines/reference/parserKeywordsAsIdentifierName1.types b/tests/baselines/reference/parserKeywordsAsIdentifierName1.types index bc586e8a4bb..74b9e0b30de 100644 --- a/tests/baselines/reference/parserKeywordsAsIdentifierName1.types +++ b/tests/baselines/reference/parserKeywordsAsIdentifierName1.types @@ -5,14 +5,14 @@ var big = { break : 0, >break : number ->0 : number +>0 : 0 super : 0, >super : number ->0 : number +>0 : 0 const : 0 >const : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/parserModule1.types b/tests/baselines/reference/parserModule1.types index 2d3b670aaa6..b32651a71a4 100644 --- a/tests/baselines/reference/parserModule1.types +++ b/tests/baselines/reference/parserModule1.types @@ -4,7 +4,7 @@ export var debug = false; >debug : boolean ->false : boolean +>false : false export interface IDiagnosticWriter { >IDiagnosticWriter : IDiagnosticWriter @@ -21,7 +21,7 @@ export var analysisPass: number = 0; >analysisPass : number ->0 : number +>0 : 0 export function Alert(output: string) { >Alert : (output: string) => void diff --git a/tests/baselines/reference/parserModuleDeclaration11.types b/tests/baselines/reference/parserModuleDeclaration11.types index 98075a505f7..21d9f0803ea 100644 --- a/tests/baselines/reference/parserModuleDeclaration11.types +++ b/tests/baselines/reference/parserModuleDeclaration11.types @@ -14,7 +14,7 @@ string.foo("abc"); >string.foo : (s: string) => any >string : typeof string >foo : (s: string) => any ->"abc" : string +>"abc" : "abc" var x: string.X; >x : string.X diff --git a/tests/baselines/reference/parserObjectLiterals1.types b/tests/baselines/reference/parserObjectLiterals1.types index b6bca18e360..fb85352747f 100644 --- a/tests/baselines/reference/parserObjectLiterals1.types +++ b/tests/baselines/reference/parserObjectLiterals1.types @@ -3,7 +3,7 @@ var v = { a: 1, b: 2 }; >v : { a: number; b: number; } >{ a: 1, b: 2 } : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/parserSbp_7.9_A9_T3.types b/tests/baselines/reference/parserSbp_7.9_A9_T3.types index 5e1eed4dd98..58147a37a67 100644 --- a/tests/baselines/reference/parserSbp_7.9_A9_T3.types +++ b/tests/baselines/reference/parserSbp_7.9_A9_T3.types @@ -13,7 +13,7 @@ do { ; } while (false) true ->false : boolean ->true : boolean +>false : false +>true : true diff --git a/tests/baselines/reference/parserStrictMode16.types b/tests/baselines/reference/parserStrictMode16.types index a7a68ab7811..fbe701f374b 100644 --- a/tests/baselines/reference/parserStrictMode16.types +++ b/tests/baselines/reference/parserStrictMode16.types @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode16.ts === "use strict"; ->"use strict" : string +>"use strict" : "use strict" delete this; >delete this : boolean @@ -8,7 +8,7 @@ delete this; delete 1; >delete 1 : boolean ->1 : number +>1 : 1 delete null; >delete null : boolean @@ -16,5 +16,5 @@ delete null; delete "a"; >delete "a" : boolean ->"a" : string +>"a" : "a" diff --git a/tests/baselines/reference/parserStrictMode5.errors.txt b/tests/baselines/reference/parserStrictMode5.errors.txt index 4b3dc48f2b4..e541963a1fb 100644 --- a/tests/baselines/reference/parserStrictMode5.errors.txt +++ b/tests/baselines/reference/parserStrictMode5.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode5.ts(2,1): error TS1100: Invalid use of 'eval' in strict mode. -tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode5.ts(2,1): error TS2365: Operator '+=' cannot be applied to types '(x: string) => any' and 'number'. +tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode5.ts(2,1): error TS2365: Operator '+=' cannot be applied to types '(x: string) => any' and '1'. ==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode5.ts (2 errors) ==== @@ -8,4 +8,4 @@ tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode5.ts(2,1): ~~~~ !!! error TS1100: Invalid use of 'eval' in strict mode. ~~~~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types '(x: string) => any' and 'number'. \ No newline at end of file +!!! error TS2365: Operator '+=' cannot be applied to types '(x: string) => any' and '1'. \ No newline at end of file diff --git a/tests/baselines/reference/parserSymbolProperty6.types b/tests/baselines/reference/parserSymbolProperty6.types index a802765cb4f..13553eb27c6 100644 --- a/tests/baselines/reference/parserSymbolProperty6.types +++ b/tests/baselines/reference/parserSymbolProperty6.types @@ -6,5 +6,5 @@ class C { >Symbol.toStringTag : symbol >Symbol : SymbolConstructor >toStringTag : symbol ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/parserUnicode2.types b/tests/baselines/reference/parserUnicode2.types index 1051b23905f..5e25bef8306 100644 --- a/tests/baselines/reference/parserUnicode2.types +++ b/tests/baselines/reference/parserUnicode2.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/parserUnicode2.ts === var 才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123 = 1; >才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüß才能ソЫⅨ蒤郳र्क्ड्राüışğİliيونيكودöÄüßAbcd123 : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/parserVoidExpression1.types b/tests/baselines/reference/parserVoidExpression1.types index a2d9988eee3..a4495f987e6 100644 --- a/tests/baselines/reference/parserVoidExpression1.types +++ b/tests/baselines/reference/parserVoidExpression1.types @@ -1,5 +1,5 @@ === tests/cases/conformance/parser/ecmascript5/parserVoidExpression1.ts === void 0; >void 0 : undefined ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/parser_breakInIterationOrSwitchStatement1.types b/tests/baselines/reference/parser_breakInIterationOrSwitchStatement1.types index 6688f334a86..d00c1e6f708 100644 --- a/tests/baselines/reference/parser_breakInIterationOrSwitchStatement1.types +++ b/tests/baselines/reference/parser_breakInIterationOrSwitchStatement1.types @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/Statements/BreakStatements/parser_breakInIterationOrSwitchStatement1.ts === while (true) { ->true : boolean +>true : true break; } diff --git a/tests/baselines/reference/parser_breakInIterationOrSwitchStatement2.types b/tests/baselines/reference/parser_breakInIterationOrSwitchStatement2.types index 7def75c322a..1d490ef1040 100644 --- a/tests/baselines/reference/parser_breakInIterationOrSwitchStatement2.types +++ b/tests/baselines/reference/parser_breakInIterationOrSwitchStatement2.types @@ -3,5 +3,5 @@ do { break; } while (true); ->true : boolean +>true : true diff --git a/tests/baselines/reference/parser_breakTarget2.types b/tests/baselines/reference/parser_breakTarget2.types index 8a1e7a991db..550a3d39de3 100644 --- a/tests/baselines/reference/parser_breakTarget2.types +++ b/tests/baselines/reference/parser_breakTarget2.types @@ -3,7 +3,7 @@ target: >target : any while (true) { ->true : boolean +>true : true break target; >target : any diff --git a/tests/baselines/reference/parser_breakTarget3.types b/tests/baselines/reference/parser_breakTarget3.types index b1ce9f8d94d..eb5c2cf68a5 100644 --- a/tests/baselines/reference/parser_breakTarget3.types +++ b/tests/baselines/reference/parser_breakTarget3.types @@ -7,7 +7,7 @@ target2: >target2 : any while (true) { ->true : boolean +>true : true break target1; >target1 : any diff --git a/tests/baselines/reference/parser_breakTarget4.types b/tests/baselines/reference/parser_breakTarget4.types index 04bb129c919..3a368eeb6c9 100644 --- a/tests/baselines/reference/parser_breakTarget4.types +++ b/tests/baselines/reference/parser_breakTarget4.types @@ -7,7 +7,7 @@ target2: >target2 : any while (true) { ->true : boolean +>true : true break target2; >target2 : any diff --git a/tests/baselines/reference/parser_continueInIterationStatement1.types b/tests/baselines/reference/parser_continueInIterationStatement1.types index c6819ba2c18..0e1bd38266c 100644 --- a/tests/baselines/reference/parser_continueInIterationStatement1.types +++ b/tests/baselines/reference/parser_continueInIterationStatement1.types @@ -1,6 +1,6 @@ === tests/cases/conformance/parser/ecmascript5/Statements/ContinueStatements/parser_continueInIterationStatement1.ts === while (true) { ->true : boolean +>true : true continue; } diff --git a/tests/baselines/reference/parser_continueInIterationStatement2.types b/tests/baselines/reference/parser_continueInIterationStatement2.types index ead70157de4..701f5e5ffaf 100644 --- a/tests/baselines/reference/parser_continueInIterationStatement2.types +++ b/tests/baselines/reference/parser_continueInIterationStatement2.types @@ -3,5 +3,5 @@ do { continue; } while (true); ->true : boolean +>true : true diff --git a/tests/baselines/reference/parser_continueLabel.types b/tests/baselines/reference/parser_continueLabel.types index a8a240ac18b..24f1ed509de 100644 --- a/tests/baselines/reference/parser_continueLabel.types +++ b/tests/baselines/reference/parser_continueLabel.types @@ -2,10 +2,10 @@ label1: for(var i = 0; i < 1; i++) { >label1 : any >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/parser_continueTarget2.types b/tests/baselines/reference/parser_continueTarget2.types index ba01f3b8927..0dc073fda3f 100644 --- a/tests/baselines/reference/parser_continueTarget2.types +++ b/tests/baselines/reference/parser_continueTarget2.types @@ -3,7 +3,7 @@ target: >target : any while (true) { ->true : boolean +>true : true continue target; >target : any diff --git a/tests/baselines/reference/parser_continueTarget3.types b/tests/baselines/reference/parser_continueTarget3.types index fd8aedc357f..273c47f97cf 100644 --- a/tests/baselines/reference/parser_continueTarget3.types +++ b/tests/baselines/reference/parser_continueTarget3.types @@ -7,7 +7,7 @@ target2: >target2 : any while (true) { ->true : boolean +>true : true continue target1; >target1 : any diff --git a/tests/baselines/reference/parser_continueTarget4.types b/tests/baselines/reference/parser_continueTarget4.types index be1e5458f4b..21381823e7c 100644 --- a/tests/baselines/reference/parser_continueTarget4.types +++ b/tests/baselines/reference/parser_continueTarget4.types @@ -7,7 +7,7 @@ target2: >target2 : any while (true) { ->true : boolean +>true : true continue target2; >target2 : any diff --git a/tests/baselines/reference/parser_duplicateLabel3.types b/tests/baselines/reference/parser_duplicateLabel3.types index 88ea435bf3e..8d62ee2a14d 100644 --- a/tests/baselines/reference/parser_duplicateLabel3.types +++ b/tests/baselines/reference/parser_duplicateLabel3.types @@ -4,7 +4,7 @@ target: >target : any while (true) { ->true : boolean +>true : true function f() { >f : () => void @@ -13,7 +13,7 @@ while (true) { >target : any while (true) { ->true : boolean +>true : true } } } diff --git a/tests/baselines/reference/parser_duplicateLabel4.types b/tests/baselines/reference/parser_duplicateLabel4.types index b70dd12c695..483cf8a0051 100644 --- a/tests/baselines/reference/parser_duplicateLabel4.types +++ b/tests/baselines/reference/parser_duplicateLabel4.types @@ -4,12 +4,12 @@ target: >target : any while (true) { ->true : boolean +>true : true } target: >target : any while (true) { ->true : boolean +>true : true } diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution3_classic.types b/tests/baselines/reference/pathMappingBasedModuleResolution3_classic.types index 359811ff3b2..17f93932265 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution3_classic.types +++ b/tests/baselines/reference/pathMappingBasedModuleResolution3_classic.types @@ -35,10 +35,10 @@ export var x = a + b; === c:/root/folder2/file3.ts === export var x = 1; >x : number ->1 : number +>1 : 1 === c:/file4.ts === export var y = 100; >y : number ->100 : number +>100 : 100 diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.types b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.types index 78597cf50ef..2c85b8ebcbd 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution3_node.types +++ b/tests/baselines/reference/pathMappingBasedModuleResolution3_node.types @@ -35,7 +35,7 @@ export var x = a + b; === c:/root/folder2/file3.ts === export var x = 1; >x : number ->1 : number +>1 : 1 === c:/node_modules/file4/index.d.ts === export var y: number; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution4_classic.types b/tests/baselines/reference/pathMappingBasedModuleResolution4_classic.types index d225246e2f9..6cb2db1bc5c 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution4_classic.types +++ b/tests/baselines/reference/pathMappingBasedModuleResolution4_classic.types @@ -32,10 +32,10 @@ export var x = a + b; === c:/root/folder2/file3.ts === export var x = 1; >x : number ->1 : number +>1 : 1 === c:/file4.ts === export var y = 100; >y : number ->100 : number +>100 : 100 diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.types b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.types index 5478a601f02..871446b5ebb 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution4_node.types +++ b/tests/baselines/reference/pathMappingBasedModuleResolution4_node.types @@ -32,7 +32,7 @@ export var x = a + b; === c:/root/folder2/file3.ts === export var x = 1; >x : number ->1 : number +>1 : 1 === c:/node_modules/file4/index.d.ts === export var y: number; diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.types b/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.types index 32a1f42bc0f..7a15355b157 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.types +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_classic.types @@ -50,20 +50,20 @@ use(z1.toExponential()); === c:/root/folder2/file1.ts === export var x = 1; >x : number ->1 : number +>1 : 1 === c:/root/generated/folder3/file2.ts === export var y = 1; >y : number ->1 : number +>1 : 1 === c:/root/shared/components/file3.ts === export var z = 1; >z : number ->1 : number +>1 : 1 === c:/file4.ts === export var z1 = 1; >z1 : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.types b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.types index 1b96e3f4f22..2cdc99dcd8c 100644 --- a/tests/baselines/reference/pathMappingBasedModuleResolution5_node.types +++ b/tests/baselines/reference/pathMappingBasedModuleResolution5_node.types @@ -50,12 +50,12 @@ use(z1.toExponential()); === c:/root/folder2/file1.ts === export var x = 1; >x : number ->1 : number +>1 : 1 === c:/root/generated/folder3/file2.ts === export var y = 1; >y : number ->1 : number +>1 : 1 === c:/root/shared/components/file3/index.d.ts === export var z: number; @@ -64,5 +64,5 @@ export var z: number; === c:/node_modules/file4.ts === export var z1 = 1; >z1 : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/plusOperatorWithBooleanType.types b/tests/baselines/reference/plusOperatorWithBooleanType.types index f688706c2e5..8fd2ee350eb 100644 --- a/tests/baselines/reference/plusOperatorWithBooleanType.types +++ b/tests/baselines/reference/plusOperatorWithBooleanType.types @@ -15,7 +15,7 @@ class A { static foo() { return false; } >foo : () => boolean ->false : boolean +>false : false } module M { >M : typeof M @@ -39,16 +39,16 @@ var ResultIsNumber1 = +BOOLEAN; var ResultIsNumber2 = +true; >ResultIsNumber2 : number >+true : number ->true : boolean +>true : true var ResultIsNumber3 = +{ x: true, y: false }; >ResultIsNumber3 : number >+{ x: true, y: false } : number >{ x: true, y: false } : { x: boolean; y: boolean; } >x : boolean ->true : boolean +>true : true >y : boolean ->false : boolean +>false : false // boolean type expressions var ResultIsNumber4 = +objA.a; @@ -82,7 +82,7 @@ var ResultIsNumber7 = +A.foo(); // miss assignment operators +true; >+true : number ->true : boolean +>true : true +BOOLEAN; >+BOOLEAN : number @@ -94,10 +94,10 @@ var ResultIsNumber7 = +A.foo(); >foo : () => boolean +true, false; ->+true, false : boolean +>+true, false : false >+true : number ->true : boolean ->false : boolean +>true : true +>false : false +objA.a; >+objA.a : number diff --git a/tests/baselines/reference/plusOperatorWithEnumType.types b/tests/baselines/reference/plusOperatorWithEnumType.types index e6dd769900e..f0b7df10756 100644 --- a/tests/baselines/reference/plusOperatorWithEnumType.types +++ b/tests/baselines/reference/plusOperatorWithEnumType.types @@ -6,8 +6,8 @@ enum ENUM { }; enum ENUM1 { A, B, "" }; >ENUM1 : ENUM1 ->A : ENUM1 ->B : ENUM1 +>A : ENUM1.A +>B : ENUM1.B // enum type var var ResultIsNumber1 = +ENUM; @@ -24,9 +24,9 @@ var ResultIsNumber2 = +ENUM1; var ResultIsNumber3 = +ENUM1["A"]; >ResultIsNumber3 : number >+ENUM1["A"] : number ->ENUM1["A"] : ENUM1 +>ENUM1["A"] : ENUM1.A >ENUM1 : typeof ENUM1 ->"A" : string +>"A" : "A" var ResultIsNumber4 = +(ENUM[0] + ENUM1["B"]); >ResultIsNumber4 : number @@ -35,10 +35,10 @@ var ResultIsNumber4 = +(ENUM[0] + ENUM1["B"]); >ENUM[0] + ENUM1["B"] : string >ENUM[0] : string >ENUM : typeof ENUM ->0 : number ->ENUM1["B"] : ENUM1 +>0 : 0 +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" // miss assignment operators +ENUM; @@ -51,9 +51,9 @@ var ResultIsNumber4 = +(ENUM[0] + ENUM1["B"]); +ENUM1.B; >+ENUM1.B : number ->ENUM1.B : ENUM1 +>ENUM1.B : ENUM1.B >ENUM1 : typeof ENUM1 ->B : ENUM1 +>B : ENUM1.B +ENUM, ENUM1; >+ENUM, ENUM1 : typeof ENUM1 diff --git a/tests/baselines/reference/plusOperatorWithNumberType.types b/tests/baselines/reference/plusOperatorWithNumberType.types index 2db1288de4a..f24785ffa06 100644 --- a/tests/baselines/reference/plusOperatorWithNumberType.types +++ b/tests/baselines/reference/plusOperatorWithNumberType.types @@ -6,12 +6,12 @@ var NUMBER: number; var NUMBER1: number[] = [1, 2]; >NUMBER1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 function foo(): number { return 1; } >foo : () => number ->1 : number +>1 : 1 class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsNumber2 = +NUMBER1; var ResultIsNumber3 = +1; >ResultIsNumber3 : number >+1 : number ->1 : number +>1 : 1 var ResultIsNumber4 = +{ x: 1, y: 2}; >ResultIsNumber4 : number >+{ x: 1, y: 2} : number >{ x: 1, y: 2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 var ResultIsNumber5 = +{ x: 1, y: (n: number) => { return n; } }; >ResultIsNumber5 : number >+{ x: 1, y: (n: number) => { return n; } } : number >{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; } >x : number ->1 : number +>1 : 1 >y : (n: number) => number >(n: number) => { return n; } : (n: number) => number >n : number @@ -92,7 +92,7 @@ var ResultIsNumber8 = +NUMBER1[0]; >+NUMBER1[0] : number >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 var ResultIsNumber9 = +foo(); >ResultIsNumber9 : number @@ -119,7 +119,7 @@ var ResultIsNumber11 = +(NUMBER + NUMBER); // miss assignment operators +1; >+1 : number ->1 : number +>1 : 1 +NUMBER; >+NUMBER : number diff --git a/tests/baselines/reference/plusOperatorWithStringType.types b/tests/baselines/reference/plusOperatorWithStringType.types index c285a88c5d9..ec19aaed497 100644 --- a/tests/baselines/reference/plusOperatorWithStringType.types +++ b/tests/baselines/reference/plusOperatorWithStringType.types @@ -6,12 +6,12 @@ var STRING: string; var STRING1: string[] = ["", "abc"]; >STRING1 : string[] >["", "abc"] : string[] ->"" : string ->"abc" : string +>"" : "" +>"abc" : "abc" function foo(): string { return "abc"; } >foo : () => string ->"abc" : string +>"abc" : "abc" class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return ""; } >foo : () => string ->"" : string +>"" : "" } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsNumber2 = +STRING1; var ResultIsNumber3 = +""; >ResultIsNumber3 : number >+"" : number ->"" : string +>"" : "" var ResultIsNumber4 = +{ x: "", y: "" }; >ResultIsNumber4 : number >+{ x: "", y: "" } : number >{ x: "", y: "" } : { x: string; y: string; } >x : string ->"" : string +>"" : "" >y : string ->"" : string +>"" : "" var ResultIsNumber5 = +{ x: "", y: (s: string) => { return s; } }; >ResultIsNumber5 : number >+{ x: "", y: (s: string) => { return s; } } : number >{ x: "", y: (s: string) => { return s; } } : { x: string; y: (s: string) => string; } >x : string ->"" : string +>"" : "" >y : (s: string) => string >(s: string) => { return s; } : (s: string) => string >s : string @@ -92,7 +92,7 @@ var ResultIsNumber8 = +STRING1[0]; >+STRING1[0] : number >STRING1[0] : string >STRING1 : string[] ->0 : number +>0 : 0 var ResultIsNumber9 = +foo(); >ResultIsNumber9 : number @@ -123,12 +123,12 @@ var ResultIsNumber12 = +STRING.charAt(0); >STRING.charAt : (pos: number) => string >STRING : string >charAt : (pos: number) => string ->0 : number +>0 : 0 // miss assignment operators +""; >+"" : number ->"" : string +>"" : "" +STRING; >+STRING : number diff --git a/tests/baselines/reference/prefixIncrementAsOperandOfPlusExpression.types b/tests/baselines/reference/prefixIncrementAsOperandOfPlusExpression.types index d5c9b03cc56..8e041acda38 100644 --- a/tests/baselines/reference/prefixIncrementAsOperandOfPlusExpression.types +++ b/tests/baselines/reference/prefixIncrementAsOperandOfPlusExpression.types @@ -1,11 +1,11 @@ === tests/cases/compiler/prefixIncrementAsOperandOfPlusExpression.ts === var x = 1; >x : number ->1 : number +>1 : 1 var y = 1; >y : number ->1 : number +>1 : 1 + ++x; >+ ++x : number diff --git a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types index c75ba492c31..4e4dbe93372 100644 --- a/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types +++ b/tests/baselines/reference/prefixUnaryOperatorsOnExportedVariables.types @@ -2,45 +2,45 @@ export var x = false; >x : boolean ->false : boolean +>false : false export var y = 1; >y : number ->1 : number +>1 : 1 if (!x) { ->!x : boolean ->x : boolean +>!x : true +>x : false } if (+x) { >+x : number ->x : boolean +>x : false } if (-x) { >-x : number ->x : boolean +>x : false } if (~x) { >~x : number ->x : boolean +>x : false } if (void x) { >void x : undefined ->x : boolean +>x : false } if (typeof x) { >typeof x : string ->x : boolean +>x : false } diff --git a/tests/baselines/reference/preserveConstEnums.types b/tests/baselines/reference/preserveConstEnums.types index f128b4a831b..9f2d30a3604 100644 --- a/tests/baselines/reference/preserveConstEnums.types +++ b/tests/baselines/reference/preserveConstEnums.types @@ -4,7 +4,7 @@ const enum E { Value = 1, Value2 = Value >Value : E ->1 : number +>1 : 1 >Value2 : E >Value : E } diff --git a/tests/baselines/reference/primitiveConstraints2.errors.txt b/tests/baselines/reference/primitiveConstraints2.errors.txt index e571ee73417..822846540f7 100644 --- a/tests/baselines/reference/primitiveConstraints2.errors.txt +++ b/tests/baselines/reference/primitiveConstraints2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/primitiveConstraints2.ts(8,11): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/compiler/primitiveConstraints2.ts(8,11): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/compiler/primitiveConstraints2.ts(9,8): error TS2344: Type 'string' does not satisfy the constraint 'number'. @@ -12,7 +12,7 @@ tests/cases/compiler/primitiveConstraints2.ts(9,8): error TS2344: Type 'string' var x = new C(); x.bar2(2, ""); // should error ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. x.bar2(2, ""); // should error ~~~~~~ !!! error TS2344: Type 'string' does not satisfy the constraint 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.types b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.types index fd5cafc037b..0c025ceaee3 100644 --- a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.types +++ b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter.types @@ -1,7 +1,7 @@ === tests/cases/compiler/privacyCheckAnonymousFunctionParameter.ts === export var x = 1; // Makes this an external module >x : number ->1 : number +>1 : 1 interface Iterator { >Iterator : Iterator diff --git a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter2.types b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter2.types index 445e318c0fb..de05ac5f740 100644 --- a/tests/baselines/reference/privacyCheckAnonymousFunctionParameter2.types +++ b/tests/baselines/reference/privacyCheckAnonymousFunctionParameter2.types @@ -1,7 +1,7 @@ === tests/cases/compiler/privacyCheckAnonymousFunctionParameter2.ts === export var x = 1; // Makes this an external module >x : number ->1 : number +>1 : 1 interface Iterator { x: T } >Iterator : Iterator diff --git a/tests/baselines/reference/privacyCheckExportAssignmentOnExportedGenericInterface2.types b/tests/baselines/reference/privacyCheckExportAssignmentOnExportedGenericInterface2.types index ce785983ce8..fcb0a27388b 100644 --- a/tests/baselines/reference/privacyCheckExportAssignmentOnExportedGenericInterface2.types +++ b/tests/baselines/reference/privacyCheckExportAssignmentOnExportedGenericInterface2.types @@ -24,6 +24,6 @@ module Foo { export var x = "hello"; >x : string ->"hello" : string +>"hello" : "hello" } diff --git a/tests/baselines/reference/privateVisibles.types b/tests/baselines/reference/privateVisibles.types index 71e26d7e264..95f60839fc1 100644 --- a/tests/baselines/reference/privateVisibles.types +++ b/tests/baselines/reference/privateVisibles.types @@ -4,7 +4,7 @@ class Foo { private pvar = 0; >pvar : number ->0 : number +>0 : 0 constructor() { var n = this.pvar; diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt b/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt index 68a1ef3b7c9..8b4e11eb606 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt +++ b/tests/baselines/reference/project/nodeModulesImportHigher/amd/nodeModulesImportHigher.errors.txt @@ -1,4 +1,4 @@ -importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type 'number'. +importHigher/root.ts(6,1): error TS2322: Type '"10"' is not assignable to type 'number'. ==== entry.js (0 errors) ==== @@ -36,5 +36,5 @@ importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type m1.f2.a = 10; m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). ~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"10"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt b/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt index 68a1ef3b7c9..8b4e11eb606 100644 --- a/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt +++ b/tests/baselines/reference/project/nodeModulesImportHigher/node/nodeModulesImportHigher.errors.txt @@ -1,4 +1,4 @@ -importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type 'number'. +importHigher/root.ts(6,1): error TS2322: Type '"10"' is not assignable to type 'number'. ==== entry.js (0 errors) ==== @@ -36,5 +36,5 @@ importHigher/root.ts(6,1): error TS2322: Type 'string' is not assignable to type m1.f2.a = 10; m1.f2.person.age = "10"; // Error: Should be number (if direct import of m2 made the m3 module visible). ~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"10"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt index 7099c05d577..6d95ac42c8f 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/amd/nodeModulesMaxDepthExceeded.errors.txt @@ -1,5 +1,5 @@ -maxDepthExceeded/root.ts(3,1): error TS2322: Type 'string' is not assignable to type 'number'. -maxDepthExceeded/root.ts(4,1): error TS2322: Type 'number' is not assignable to type 'boolean'. +maxDepthExceeded/root.ts(3,1): error TS2322: Type '"10"' is not assignable to type 'number'. +maxDepthExceeded/root.ts(4,1): error TS2322: Type '42' is not assignable to type 'true'. ==== entry.js (0 errors) ==== @@ -34,10 +34,10 @@ maxDepthExceeded/root.ts(4,1): error TS2322: Type 'number' is not assignable to m1.f1("test"); m1.f2.a = "10"; // Error: Should be number ~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"10"' is not assignable to type 'number'. m1.rel = 42; // Error: Should be boolean ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. +!!! error TS2322: Type '42' is not assignable to type 'true'. m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt index 7099c05d577..6d95ac42c8f 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthExceeded/node/nodeModulesMaxDepthExceeded.errors.txt @@ -1,5 +1,5 @@ -maxDepthExceeded/root.ts(3,1): error TS2322: Type 'string' is not assignable to type 'number'. -maxDepthExceeded/root.ts(4,1): error TS2322: Type 'number' is not assignable to type 'boolean'. +maxDepthExceeded/root.ts(3,1): error TS2322: Type '"10"' is not assignable to type 'number'. +maxDepthExceeded/root.ts(4,1): error TS2322: Type '42' is not assignable to type 'true'. ==== entry.js (0 errors) ==== @@ -34,10 +34,10 @@ maxDepthExceeded/root.ts(4,1): error TS2322: Type 'number' is not assignable to m1.f1("test"); m1.f2.a = "10"; // Error: Should be number ~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"10"' is not assignable to type 'number'. m1.rel = 42; // Error: Should be boolean ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'boolean'. +!!! error TS2322: Type '42' is not assignable to type 'true'. m1.f2.person.age = "10"; // OK if stopped at 2 modules: person will be "any". \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt index f511000d5ac..684821d60a2 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/amd/nodeModulesMaxDepthIncreased.errors.txt @@ -1,4 +1,4 @@ -maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(7,1): error TS2322: Type '"10"' is not assignable to type 'number'. ==== index.js (0 errors) ==== @@ -40,7 +40,7 @@ maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"10"' is not assignable to type 'number'. let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt index f511000d5ac..684821d60a2 100644 --- a/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt +++ b/tests/baselines/reference/project/nodeModulesMaxDepthIncreased/node/nodeModulesMaxDepthIncreased.errors.txt @@ -1,4 +1,4 @@ -maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to type 'number'. +maxDepthIncreased/root.ts(7,1): error TS2322: Type '"10"' is not assignable to type 'number'. ==== index.js (0 errors) ==== @@ -40,7 +40,7 @@ maxDepthIncreased/root.ts(7,1): error TS2322: Type 'string' is not assignable to m1.f2.person.age = "10"; // Should error if loaded the .js files correctly ~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"10"' is not assignable to type 'number'. let r2 = 3 + m4.foo; // Should be OK if correctly using the @types .d.ts file \ No newline at end of file diff --git a/tests/baselines/reference/promiseChaining.types b/tests/baselines/reference/promiseChaining.types index 23a8b276fdc..eb0c56ee99d 100644 --- a/tests/baselines/reference/promiseChaining.types +++ b/tests/baselines/reference/promiseChaining.types @@ -40,9 +40,9 @@ class Chain { >x : T >result : S >then : (cb: (x: S) => S) => Chain ->x => "abc" : (x: S) => string +>x => "abc" : (x: S) => "abc" >x : S ->"abc" : string +>"abc" : "abc" >then : (cb: (x: string) => S) => Chain >x => x.length : (x: string) => number >x : string diff --git a/tests/baselines/reference/promiseChaining1.errors.txt b/tests/baselines/reference/promiseChaining1.errors.txt index 7396d03059a..bc6602feb31 100644 --- a/tests/baselines/reference/promiseChaining1.errors.txt +++ b/tests/baselines/reference/promiseChaining1.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/promiseChaining1.ts(7,50): error TS2345: Argument of type '(x: S) => string' is not assignable to parameter of type '(x: S) => Function'. - Type 'string' is not assignable to type 'Function'. +tests/cases/compiler/promiseChaining1.ts(7,50): error TS2345: Argument of type '(x: S) => "abc"' is not assignable to parameter of type '(x: S) => Function'. + Type '"abc"' is not assignable to type 'Function'. ==== tests/cases/compiler/promiseChaining1.ts (1 errors) ==== @@ -11,8 +11,8 @@ tests/cases/compiler/promiseChaining1.ts(7,50): error TS2345: Argument of type ' // should get a fresh type parameter which each then call var z = this.then(x => result)/*S*/.then(x => "abc")/*Function*/.then(x => x.length)/*number*/; // Should error on "abc" because it is not a Function ~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: S) => string' is not assignable to parameter of type '(x: S) => Function'. -!!! error TS2345: Type 'string' is not assignable to type 'Function'. +!!! error TS2345: Argument of type '(x: S) => "abc"' is not assignable to parameter of type '(x: S) => Function'. +!!! error TS2345: Type '"abc"' is not assignable to type 'Function'. return new Chain2(result); } } \ No newline at end of file diff --git a/tests/baselines/reference/promiseChaining2.errors.txt b/tests/baselines/reference/promiseChaining2.errors.txt index a31c4335da7..83c4de1a7dc 100644 --- a/tests/baselines/reference/promiseChaining2.errors.txt +++ b/tests/baselines/reference/promiseChaining2.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/promiseChaining2.ts(7,45): error TS2345: Argument of type '(x: S) => string' is not assignable to parameter of type '(x: S) => Function'. - Type 'string' is not assignable to type 'Function'. +tests/cases/compiler/promiseChaining2.ts(7,45): error TS2345: Argument of type '(x: S) => "abc"' is not assignable to parameter of type '(x: S) => Function'. + Type '"abc"' is not assignable to type 'Function'. ==== tests/cases/compiler/promiseChaining2.ts (1 errors) ==== @@ -11,8 +11,8 @@ tests/cases/compiler/promiseChaining2.ts(7,45): error TS2345: Argument of type ' // should get a fresh type parameter which each then call var z = this.then(x => result).then(x => "abc").then(x => x.length); ~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: S) => string' is not assignable to parameter of type '(x: S) => Function'. -!!! error TS2345: Type 'string' is not assignable to type 'Function'. +!!! error TS2345: Argument of type '(x: S) => "abc"' is not assignable to parameter of type '(x: S) => Function'. +!!! error TS2345: Type '"abc"' is not assignable to type 'Function'. return new Chain2(result); } } \ No newline at end of file diff --git a/tests/baselines/reference/promiseType.types b/tests/baselines/reference/promiseType.types index 1608182d6e9..26f33d161cf 100644 --- a/tests/baselines/reference/promiseType.types +++ b/tests/baselines/reference/promiseType.types @@ -16,9 +16,9 @@ const b = p.then(b => 1); >p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } >p : Promise >then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } ->b => 1 : (b: boolean) => number +>b => 1 : (b: boolean) => 1 >b : boolean ->1 : number +>1 : 1 const c = p.then(b => 1, e => 'error'); >c : Promise @@ -26,12 +26,12 @@ const c = p.then(b => 1, e => 'error'); >p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } >p : Promise >then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } ->b => 1 : (b: boolean) => number +>b => 1 : (b: boolean) => 1 >b : boolean ->1 : number ->e => 'error' : (e: any) => string +>1 : 1 +>e => 'error' : (e: any) => "error" >e : any ->'error' : string +>'error' : "error" const d = p.then(b => 1, e => { }); >d : Promise @@ -39,9 +39,9 @@ const d = p.then(b => 1, e => { }); >p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } >p : Promise >then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } ->b => 1 : (b: boolean) => number +>b => 1 : (b: boolean) => 1 >b : boolean ->1 : number +>1 : 1 >e => { } : (e: any) => void >e : any @@ -51,9 +51,9 @@ const e = p.then(b => 1, e => { throw Error(); }); >p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } >p : Promise >then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } ->b => 1 : (b: boolean) => number +>b => 1 : (b: boolean) => 1 >b : boolean ->1 : number +>1 : 1 >e => { throw Error(); } : (e: any) => never >e : any >Error() : Error @@ -65,9 +65,9 @@ const f = p.then(b => 1, e => Promise.reject(Error())); >p.then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } >p : Promise >then : { (onfulfilled: (value: boolean) => TResult1 | PromiseLike, onrejected: (reason: any) => TResult2 | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike, onrejected: (reason: any) => TResult | PromiseLike): Promise; (onfulfilled: (value: boolean) => TResult | PromiseLike): Promise; (): Promise; } ->b => 1 : (b: boolean) => number +>b => 1 : (b: boolean) => 1 >b : boolean ->1 : number +>1 : 1 >e => Promise.reject(Error()) : (e: any) => Promise >e : any >Promise.reject(Error()) : Promise @@ -83,9 +83,9 @@ const g = p.catch(e => 'error'); >p.catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } >p : Promise >catch : { (onrejected: (reason: any) => TResult | PromiseLike): Promise; (onrejected: (reason: any) => boolean | PromiseLike): Promise; } ->e => 'error' : (e: any) => string +>e => 'error' : (e: any) => "error" >e : any ->'error' : string +>'error' : "error" const h = p.catch(e => { }); >h : Promise @@ -143,7 +143,7 @@ async function B() { >p : Promise return 1; ->1 : number +>1 : 1 } // NOTE: This reports a "No best comment type exists among return expressions." error, and is @@ -168,7 +168,7 @@ async function D() { >p : Promise return 1; ->1 : number +>1 : 1 } catch (e) { >e : any @@ -185,7 +185,7 @@ async function E() { >p : Promise return 1; ->1 : number +>1 : 1 } catch (e) { >e : any @@ -206,7 +206,7 @@ async function F() { >p : Promise return 1; ->1 : number +>1 : 1 } catch (e) { >e : any diff --git a/tests/baselines/reference/promiseTypeInference.types b/tests/baselines/reference/promiseTypeInference.types index 2789f710876..f3026c68f21 100644 --- a/tests/baselines/reference/promiseTypeInference.types +++ b/tests/baselines/reference/promiseTypeInference.types @@ -45,7 +45,7 @@ var $$x = load("something").then(s => convert(s)); >load("something").then : (success?: (value: string) => Promise) => Promise >load("something") : Promise >load : (name: string) => Promise ->"something" : string +>"something" : "something" >then : (success?: (value: string) => Promise) => Promise >s => convert(s) : (s: string) => IPromise >s : string diff --git a/tests/baselines/reference/promiseVoidErrorCallback.types b/tests/baselines/reference/promiseVoidErrorCallback.types index 94773394ade..cd3c67bc813 100644 --- a/tests/baselines/reference/promiseVoidErrorCallback.types +++ b/tests/baselines/reference/promiseVoidErrorCallback.types @@ -32,7 +32,7 @@ function f1(): Promise { >resolve : { (value: T | PromiseLike): Promise; (): Promise; } >{ __t1: "foo_t1" } : { __t1: string; } >__t1 : string ->"foo_t1" : string +>"foo_t1" : "foo_t1" } function f2(x: T1): T2 { @@ -48,7 +48,7 @@ function f2(x: T1): T2 { >x.__t1 : string >x : T1 >__t1 : string ->":foo_21" : string +>":foo_21" : ":foo_21" } var x3 = f1() @@ -84,6 +84,6 @@ var x3 = f1() >x.__t2 : string >x : T2 >__t2 : string ->"bar" : string +>"bar" : "bar" }); diff --git a/tests/baselines/reference/propagationOfPromiseInitialization.types b/tests/baselines/reference/propagationOfPromiseInitialization.types index bd100f75b3e..62abe2c09de 100644 --- a/tests/baselines/reference/propagationOfPromiseInitialization.types +++ b/tests/baselines/reference/propagationOfPromiseInitialization.types @@ -28,16 +28,16 @@ foo.then((x) => { >foo.then : (successCallback: (promiseValue: number) => TResult, errorCallback?: (reason: any) => TResult) => IPromise >foo : IPromise >then : (successCallback: (promiseValue: number) => TResult, errorCallback?: (reason: any) => TResult) => IPromise ->(x) => { // x is inferred to be a number return "asdf";} : (x: number) => string +>(x) => { // x is inferred to be a number return "asdf";} : (x: number) => "asdf" >x : number // x is inferred to be a number return "asdf"; ->"asdf" : string +>"asdf" : "asdf" }).then((x) => { >then : (successCallback: (promiseValue: string) => TResult, errorCallback?: (reason: any) => TResult) => IPromise ->(x) => { // x is inferred to be string x.length; return 123;} : (x: string) => number +>(x) => { // x is inferred to be string x.length; return 123;} : (x: string) => 123 >x : string // x is inferred to be string @@ -47,7 +47,7 @@ foo.then((x) => { >length : number return 123; ->123 : number +>123 : 123 }); diff --git a/tests/baselines/reference/properties.types b/tests/baselines/reference/properties.types index d51ab4a95d2..99ff875a087 100644 --- a/tests/baselines/reference/properties.types +++ b/tests/baselines/reference/properties.types @@ -7,7 +7,7 @@ class MyClass >Count : number { return 42; ->42 : number +>42 : 42 } public set Count(value: number) diff --git a/tests/baselines/reference/propertyAccess6.types b/tests/baselines/reference/propertyAccess6.types index 18f39f447c5..b899f4c53ec 100644 --- a/tests/baselines/reference/propertyAccess6.types +++ b/tests/baselines/reference/propertyAccess6.types @@ -3,9 +3,9 @@ var foo: any; >foo : any foo.bar = 4; ->foo.bar = 4 : number +>foo.bar = 4 : 4 >foo.bar : any >foo : any >bar : any ->4 : number +>4 : 4 diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints.types b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints.types index d808cddef83..5faaf4d0216 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints.types +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints.types @@ -19,7 +19,7 @@ class C { >x['getDate']() : number >x['getDate'] : () => number >x : T ->'getDate' : string +>'getDate' : "getDate" return a + x.getDate(); >a + x.getDate() : number @@ -71,7 +71,7 @@ var r2b = i.foo['getDate'](); >i.foo : Date >i : I >foo : Date ->'getDate' : string +>'getDate' : "getDate" var a: { >a : () => T @@ -96,7 +96,7 @@ var r3b = a()['getDate'](); >a()['getDate'] : () => number >a() : Date >a : () => T ->'getDate' : string +>'getDate' : "getDate" var b = { >b : { foo: (x: T) => number; } @@ -115,7 +115,7 @@ var b = { >x['getDate']() : number >x['getDate'] : () => number >x : T ->'getDate' : string +>'getDate' : "getDate" return a + x.getDate(); >a + x.getDate() : number diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.types b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.types index 9ea015cc9ce..ad2ba3e829d 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.types +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints2.types @@ -6,7 +6,7 @@ class A { foo(): string { return ''; } >foo : () => string ->'' : string +>'' : "" } class B extends A { @@ -17,7 +17,7 @@ class B extends A { >bar : () => string return ''; ->'' : string +>'' : "" } } @@ -40,7 +40,7 @@ class C { >x['foo']() : string >x['foo'] : () => string >x : U ->'foo' : string +>'foo' : "foo" return a + x.foo(); >a + x.foo() : string @@ -61,7 +61,7 @@ class C { >x['foo']() : string >x['foo'] : () => string >x : U ->'foo' : string +>'foo' : "foo" return a + x.foo(); >a + x.foo() : string @@ -145,7 +145,7 @@ var r2b = i.foo['foo'](); >i.foo : B >i : I >foo : B ->'foo' : string +>'foo' : "foo" var a: { >a : { (): U; (x: U): U; (x: U, y: T): U; } @@ -198,7 +198,7 @@ var r3b = a()['foo'](); >a()['foo'] : () => string >a() : A >a : { (): U; (x: U): U; (x: U, y: T): U; } ->'foo' : string +>'foo' : "foo" // parameter supplied for type argument inference to succeed var aB = new B(); @@ -224,7 +224,7 @@ var r3d = a(aB, aB)['foo'](); >a : { (): U; (x: U): U; (x: U, y: T): U; } >aB : B >aB : B ->'foo' : string +>'foo' : "foo" var b = { >b : { foo: (x: U, y: T) => string; } @@ -247,7 +247,7 @@ var b = { >x['foo']() : string >x['foo'] : () => string >x : U ->'foo' : string +>'foo' : "foo" return a + x.foo(); >a + x.foo() : string diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.types b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.types index f2423f2bff8..30a17935fc1 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.types +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithConstraints3.types @@ -6,7 +6,7 @@ class A { foo(): string { return ''; } >foo : () => string ->'' : string +>'' : "" } class B extends A { @@ -17,7 +17,7 @@ class B extends A { >bar : () => string return ''; ->'' : string +>'' : "" } } @@ -41,7 +41,7 @@ class C { >x['foo']() : string >x['foo'] : () => string >x : T ->'foo' : string +>'foo' : "foo" return a + x.foo(); >a + x.foo() : string @@ -63,7 +63,7 @@ class C { >x['foo']() : string >x['foo'] : () => string >x : U ->'foo' : string +>'foo' : "foo" return a + x.foo(); >a + x.foo() : string @@ -132,7 +132,7 @@ var r2b = i.foo['foo'](); >i.foo : B >i : I >foo : B ->'foo' : string +>'foo' : "foo" var a: { >a : { (): T; (x: U): U; } @@ -167,7 +167,7 @@ var r3b = a()['foo'](); >a()['foo'] : () => string >a() : A >a : { (): T; (x: U): U; } ->'foo' : string +>'foo' : "foo" // parameter supplied for type argument inference for U var r3c = a(new B()).foo(); // valid call to an invalid function, U is inferred as B, which has a foo @@ -188,7 +188,7 @@ var r3d = a(new B())['foo'](); // valid call to an invalid function, U is inferr >a : { (): T; (x: U): U; } >new B() : B >B : typeof B ->'foo' : string +>'foo' : "foo" var b = { >b : { foo: (x: T) => string; } @@ -210,7 +210,7 @@ var b = { >x['foo']() : string >x['foo'] : () => string >x : T ->'foo' : string +>'foo' : "foo" return a + x.foo(); >a + x.foo() : string diff --git a/tests/baselines/reference/propertyAccessOnTypeParameterWithoutConstraints.types b/tests/baselines/reference/propertyAccessOnTypeParameterWithoutConstraints.types index 9d25bebea37..2946b88b432 100644 --- a/tests/baselines/reference/propertyAccessOnTypeParameterWithoutConstraints.types +++ b/tests/baselines/reference/propertyAccessOnTypeParameterWithoutConstraints.types @@ -15,7 +15,7 @@ class C { >x['toString']() : string >x['toString'] : () => string >x : T ->'toString' : string +>'toString' : "toString" return a + x.toString(); >a + x.toString() : string @@ -64,7 +64,7 @@ var r2b = i.foo['toString'](); >i.foo : number >i : I >foo : number ->'toString' : string +>'toString' : "toString" var a: { >a : () => T @@ -87,7 +87,7 @@ var r3b: string = a()['toString'](); >a()['toString'] : () => string >a() : {} >a : () => T ->'toString' : string +>'toString' : "toString" var b = { >b : { foo: (x: T) => string; } @@ -105,7 +105,7 @@ var b = { >x['toString']() : string >x['toString'] : () => string >x : T ->'toString' : string +>'toString' : "toString" return a + x.toString(); >a + x.toString() : string @@ -123,5 +123,5 @@ var r4 = b.foo(1); >b.foo : (x: T) => string >b : { foo: (x: T) => string; } >foo : (x: T) => string ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/propertyNamesOfReservedWords.types b/tests/baselines/reference/propertyNamesOfReservedWords.types index 2554a7f61dd..82780db2250 100644 --- a/tests/baselines/reference/propertyNamesOfReservedWords.types +++ b/tests/baselines/reference/propertyNamesOfReservedWords.types @@ -625,204 +625,204 @@ enum E { >E : E abstract, ->abstract : E +>abstract : E.abstract as, ->as : E +>as : E.as boolean, ->boolean : E +>boolean : E.boolean break, ->break : E +>break : E.break byte, ->byte : E +>byte : E.byte case, ->case : E +>case : E.case catch, ->catch : E +>catch : E.catch char, ->char : E +>char : E.char class, ->class : E +>class : E.class continue, ->continue : E +>continue : E.continue const, ->const : E +>const : E.const debugger, ->debugger : E +>debugger : E.debugger default, ->default : E +>default : E.default delete, ->delete : E +>delete : E.delete do, ->do : E +>do : E.do double, ->double : E +>double : E.double else, ->else : E +>else : E.else enum, ->enum : E +>enum : E.enum export, ->export : E +>export : E.export extends, ->extends : E +>extends : E.extends false, ->false : E +>false : E.false final, ->final : E +>final : E.final finally, ->finally : E +>finally : E.finally float, ->float : E +>float : E.float for, ->for : E +>for : E.for function, ->function : E +>function : E.function goto, ->goto : E +>goto : E.goto if, ->if : E +>if : E.if implements, ->implements : E +>implements : E.implements import, ->import : E +>import : E.import in, ->in : E +>in : E.in instanceof, ->instanceof : E +>instanceof : E.instanceof int, ->int : E +>int : E.int interface, ->interface : E +>interface : E.interface is, ->is : E +>is : E.is long, ->long : E +>long : E.long namespace, ->namespace : E +>namespace : E.namespace native, ->native : E +>native : E.native new, ->new : E +>new : E.new null, ->null : E +>null : E.null package, ->package : E +>package : E.package private, ->private : E +>private : E.private protected, ->protected : E +>protected : E.protected public, ->public : E +>public : E.public return, ->return : E +>return : E.return short, ->short : E +>short : E.short static, ->static : E +>static : E.static super, ->super : E +>super : E.super switch, ->switch : E +>switch : E.switch synchronized, ->synchronized : E +>synchronized : E.synchronized this, ->this : E +>this : E.this throw, ->throw : E +>throw : E.throw throws, ->throws : E +>throws : E.throws transient, ->transient : E +>transient : E.transient true, ->true : E +>true : E.true try, ->try : E +>try : E.try typeof, ->typeof : E +>typeof : E.typeof use, ->use : E +>use : E.use var, ->var : E +>var : E.var void, ->void : E +>void : E.void volatile, ->volatile : E +>volatile : E.volatile while, ->while : E +>while : E.while with, ->with : E +>with : E.with } var r7 = E.abstract; >r7 : E ->E.abstract : E +>E.abstract : E.abstract >E : typeof E ->abstract : E +>abstract : E.abstract var r8 = E.as; >r8 : E ->E.as : E +>E.as : E.as >E : typeof E ->as : E +>as : E.as diff --git a/tests/baselines/reference/propertyNamesWithStringLiteral.types b/tests/baselines/reference/propertyNamesWithStringLiteral.types index 9c3eb5f2015..4e3c9c6080c 100644 --- a/tests/baselines/reference/propertyNamesWithStringLiteral.types +++ b/tests/baselines/reference/propertyNamesWithStringLiteral.types @@ -35,7 +35,7 @@ var a = Color.namedColors["azure"]; >Color.namedColors : NamedColors >Color : typeof Color >namedColors : NamedColors ->"azure" : string +>"azure" : "azure" var a = Color.namedColors.blue; // Should not error >a : _Color @@ -51,5 +51,5 @@ var a = Color.namedColors["pale blue"]; // should not error >Color.namedColors : NamedColors >Color : typeof Color >namedColors : NamedColors ->"pale blue" : string +>"pale blue" : "pale blue" diff --git a/tests/baselines/reference/protoAsIndexInIndexExpression.types b/tests/baselines/reference/protoAsIndexInIndexExpression.types index 56650cbf4eb..b761aa2c7a7 100644 --- a/tests/baselines/reference/protoAsIndexInIndexExpression.types +++ b/tests/baselines/reference/protoAsIndexInIndexExpression.types @@ -17,7 +17,7 @@ WorkspacePrototype['__proto__'] = EntityPrototype; >WorkspacePrototype['__proto__'] = EntityPrototype : any >WorkspacePrototype['__proto__'] : any >WorkspacePrototype : { serialize: () => any; } ->'__proto__' : string +>'__proto__' : "___proto__" >EntityPrototype : any var o = { @@ -25,14 +25,14 @@ var o = { >{ "__proto__": 0} : { "__proto__": number; } "__proto__": 0 ->0 : number +>0 : 0 }; class C { >C : C "__proto__" = 0; ->0 : number +>0 : 0 } === tests/cases/compiler/protoAsIndexInIndexExpression_0.ts === export var x; diff --git a/tests/baselines/reference/protoInIndexer.types b/tests/baselines/reference/protoInIndexer.types index bfafc56404a..27f1f721fd3 100644 --- a/tests/baselines/reference/protoInIndexer.types +++ b/tests/baselines/reference/protoInIndexer.types @@ -7,7 +7,7 @@ class X { >this['__proto__'] = null : null >this['__proto__'] : any >this : this ->'__proto__' : string +>'__proto__' : "___proto__" >null : null } } diff --git a/tests/baselines/reference/prototypeOnConstructorFunctions.types b/tests/baselines/reference/prototypeOnConstructorFunctions.types index 8d1b16e7a21..949cb4d7499 100644 --- a/tests/baselines/reference/prototypeOnConstructorFunctions.types +++ b/tests/baselines/reference/prototypeOnConstructorFunctions.types @@ -15,7 +15,7 @@ var i: I1; i.const.prototype.prop = "yo"; ->i.const.prototype.prop = "yo" : string +>i.const.prototype.prop = "yo" : "yo" >i.const.prototype.prop : any >i.const.prototype : any >i.const : new (options?: any, element?: any) => any @@ -23,5 +23,5 @@ i.const.prototype.prop = "yo"; >const : new (options?: any, element?: any) => any >prototype : any >prop : any ->"yo" : string +>"yo" : "yo" diff --git a/tests/baselines/reference/qualifiedName_ImportDeclarations-entity-names-referencing-a-var.types b/tests/baselines/reference/qualifiedName_ImportDeclarations-entity-names-referencing-a-var.types index 7c05f6a1006..d507fb42323 100644 --- a/tests/baselines/reference/qualifiedName_ImportDeclarations-entity-names-referencing-a-var.types +++ b/tests/baselines/reference/qualifiedName_ImportDeclarations-entity-names-referencing-a-var.types @@ -4,7 +4,7 @@ module Alpha { export var x = 100; >x : number ->100 : number +>100 : 100 } module Beta { diff --git a/tests/baselines/reference/qualify.errors.txt b/tests/baselines/reference/qualify.errors.txt index c3447664c96..53c9927737f 100644 --- a/tests/baselines/reference/qualify.errors.txt +++ b/tests/baselines/reference/qualify.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/qualify.ts(21,13): error TS2322: Type 'number' is not assignable to type 'I'. -tests/cases/compiler/qualify.ts(30,13): error TS2322: Type 'number' is not assignable to type 'I2'. +tests/cases/compiler/qualify.ts(21,13): error TS2322: Type '3' is not assignable to type 'I'. +tests/cases/compiler/qualify.ts(30,13): error TS2322: Type '3' is not assignable to type 'I2'. tests/cases/compiler/qualify.ts(45,13): error TS2322: Type 'I4' is not assignable to type 'I3'. Property 'zeep' is missing in type 'I4'. tests/cases/compiler/qualify.ts(46,13): error TS2322: Type 'I4' is not assignable to type 'I3[]'. @@ -37,7 +37,7 @@ tests/cases/compiler/qualify.ts(58,5): error TS2322: Type 'I' is not assignable export module U { var z:I=3; ~ -!!! error TS2322: Type 'number' is not assignable to type 'I'. +!!! error TS2322: Type '3' is not assignable to type 'I'. export interface I2 { q; } @@ -48,7 +48,7 @@ tests/cases/compiler/qualify.ts(58,5): error TS2322: Type 'I' is not assignable export module U2 { var z:T.U.I2=3; ~ -!!! error TS2322: Type 'number' is not assignable to type 'I2'. +!!! error TS2322: Type '3' is not assignable to type 'I2'. } } diff --git a/tests/baselines/reference/quotedPropertyName1.types b/tests/baselines/reference/quotedPropertyName1.types index 4a4e73529b3..a142d607a75 100644 --- a/tests/baselines/reference/quotedPropertyName1.types +++ b/tests/baselines/reference/quotedPropertyName1.types @@ -3,5 +3,5 @@ class Test1 { >Test1 : Test1 "prop1" = 0; ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/quotedPropertyName2.types b/tests/baselines/reference/quotedPropertyName2.types index fe737758e3e..16b116a5e22 100644 --- a/tests/baselines/reference/quotedPropertyName2.types +++ b/tests/baselines/reference/quotedPropertyName2.types @@ -3,5 +3,5 @@ class Test1 { >Test1 : Test1 static "prop1" = 0; ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/quotedPropertyName3.types b/tests/baselines/reference/quotedPropertyName3.types index 7c957372e0d..f5f1d47bbc8 100644 --- a/tests/baselines/reference/quotedPropertyName3.types +++ b/tests/baselines/reference/quotedPropertyName3.types @@ -11,7 +11,7 @@ class Test { >() => this["prop1"] : () => number >this["prop1"] : number >this : this ->"prop1" : string +>"prop1" : "prop1" var y: number = x(); >y : number diff --git a/tests/baselines/reference/randomSemicolons1.types b/tests/baselines/reference/randomSemicolons1.types index 48a7c307314..4a246eeed21 100644 --- a/tests/baselines/reference/randomSemicolons1.types +++ b/tests/baselines/reference/randomSemicolons1.types @@ -2,7 +2,7 @@ ; ; var a = 1; >a : number ->1 : number +>1 : 1 ; diff --git a/tests/baselines/reference/reachabilityCheckWithEmptyDefault.types b/tests/baselines/reference/reachabilityCheckWithEmptyDefault.types index 37a6d11b598..72c23eae972 100644 --- a/tests/baselines/reference/reachabilityCheckWithEmptyDefault.types +++ b/tests/baselines/reference/reachabilityCheckWithEmptyDefault.types @@ -18,5 +18,5 @@ function foo(x: any) { print('1'); >print('1') : void >print : (s: string) => void ->'1' : string +>'1' : "1" } diff --git a/tests/baselines/reference/reactNamespaceJSXEmit.types b/tests/baselines/reference/reactNamespaceJSXEmit.types index 06c803ef7fd..d2bd88e8fbd 100644 --- a/tests/baselines/reference/reactNamespaceJSXEmit.types +++ b/tests/baselines/reference/reactNamespaceJSXEmit.types @@ -37,5 +37,5 @@ declare var x: any; >Bar : any >x : any >y : any ->2 : number +>2 : 2 diff --git a/tests/baselines/reference/readonlyInDeclarationFile.types b/tests/baselines/reference/readonlyInDeclarationFile.types index 7a3e11577c8..ca83a0a4c01 100644 --- a/tests/baselines/reference/readonlyInDeclarationFile.types +++ b/tests/baselines/reference/readonlyInDeclarationFile.types @@ -29,19 +29,19 @@ class C { private get b1() { return 1 } >b1 : number ->1 : number +>1 : 1 protected get b2() { return 1 } >b2 : number ->1 : number +>1 : 1 public get b3() { return 1 } >b3 : number ->1 : number +>1 : 1 private get c1() { return 1 } >c1 : number ->1 : number +>1 : 1 private set c1(value) { } >c1 : number @@ -49,7 +49,7 @@ class C { protected get c2() { return 1 } >c2 : number ->1 : number +>1 : 1 protected set c2(value) { } >c2 : number @@ -57,7 +57,7 @@ class C { public get c3() { return 1 } >c3 : number ->1 : number +>1 : 1 public set c3(value) { } >c3 : number @@ -74,19 +74,19 @@ class C { private static get t1() { return 1 } >t1 : number ->1 : number +>1 : 1 protected static get t2() { return 1 } >t2 : number ->1 : number +>1 : 1 public static get t3() { return 1 } >t3 : number ->1 : number +>1 : 1 private static get u1() { return 1 } >u1 : number ->1 : number +>1 : 1 private static set u1(value) { } >u1 : number @@ -94,7 +94,7 @@ class C { protected static get u2() { return 1 } >u2 : number ->1 : number +>1 : 1 protected static set u2(value) { } >u2 : number @@ -102,7 +102,7 @@ class C { public static get u3() { return 1 } >u3 : number ->1 : number +>1 : 1 public static set u3(value) { } >u3 : number @@ -128,11 +128,11 @@ function f() { get x() { return 1; }, >x : number ->1 : number +>1 : 1 get y() { return 1; }, >y : number ->1 : number +>1 : 1 set y(value) { } >y : number diff --git a/tests/baselines/reference/reboundBaseClassSymbol.types b/tests/baselines/reference/reboundBaseClassSymbol.types index 9c62d838f42..602907cb5b3 100644 --- a/tests/baselines/reference/reboundBaseClassSymbol.types +++ b/tests/baselines/reference/reboundBaseClassSymbol.types @@ -8,7 +8,7 @@ module Foo { var A = 1; >A : number ->1 : number +>1 : 1 interface B extends A { b: string; } >B : B diff --git a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types index 482ec707e49..3e74ba7f57b 100644 --- a/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types +++ b/tests/baselines/reference/recursiveClassInstantiationsWithDefaultConstructors.types @@ -14,7 +14,7 @@ export class MemberName { public prefix: string = ""; >prefix : string ->"" : string +>"" : "" } export class MemberNameArray extends MemberName { >MemberNameArray : MemberNameArray diff --git a/tests/baselines/reference/recursiveComplicatedClasses.types b/tests/baselines/reference/recursiveComplicatedClasses.types index 1bb48a3c0c9..ea590daca5a 100644 --- a/tests/baselines/reference/recursiveComplicatedClasses.types +++ b/tests/baselines/reference/recursiveComplicatedClasses.types @@ -14,7 +14,7 @@ function aEnclosesB(a: Symbol) { >Symbol : Symbol return true; ->true : boolean +>true : true } class Symbol { diff --git a/tests/baselines/reference/recursiveFunctionTypes.errors.txt b/tests/baselines/reference/recursiveFunctionTypes.errors.txt index 8d5303c0669..8614f747016 100644 --- a/tests/baselines/reference/recursiveFunctionTypes.errors.txt +++ b/tests/baselines/reference/recursiveFunctionTypes.errors.txt @@ -1,23 +1,23 @@ -tests/cases/compiler/recursiveFunctionTypes.ts(1,35): error TS2322: Type 'number' is not assignable to type '() => typeof fn'. +tests/cases/compiler/recursiveFunctionTypes.ts(1,35): error TS2322: Type '1' is not assignable to type '() => typeof fn'. tests/cases/compiler/recursiveFunctionTypes.ts(3,5): error TS2322: Type '() => typeof fn' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(4,5): error TS2322: Type '() => typeof fn' is not assignable to type '() => number'. Type '() => typeof fn' is not assignable to type 'number'. tests/cases/compiler/recursiveFunctionTypes.ts(11,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/recursiveFunctionTypes.ts(12,16): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value. tests/cases/compiler/recursiveFunctionTypes.ts(17,5): error TS2322: Type '() => I' is not assignable to type 'number'. -tests/cases/compiler/recursiveFunctionTypes.ts(22,5): error TS2345: Argument of type 'number' is not assignable to parameter of type '(t: typeof g) => void'. -tests/cases/compiler/recursiveFunctionTypes.ts(25,1): error TS2322: Type 'number' is not assignable to type '() => any'. +tests/cases/compiler/recursiveFunctionTypes.ts(22,5): error TS2345: Argument of type '3' is not assignable to parameter of type '(t: typeof g) => void'. +tests/cases/compiler/recursiveFunctionTypes.ts(25,1): error TS2322: Type '3' is not assignable to type '() => any'. tests/cases/compiler/recursiveFunctionTypes.ts(30,10): error TS2394: Overload signature is not compatible with function implementation. tests/cases/compiler/recursiveFunctionTypes.ts(33,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/recursiveFunctionTypes.ts(34,4): error TS2345: Argument of type 'string' is not assignable to parameter of type '{ (): typeof f6; (a: typeof f6): () => number; }'. +tests/cases/compiler/recursiveFunctionTypes.ts(34,4): error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f6; (a: typeof f6): () => number; }'. tests/cases/compiler/recursiveFunctionTypes.ts(42,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of type 'string' is not assignable to parameter of type '{ (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; }'. +tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; }'. ==== tests/cases/compiler/recursiveFunctionTypes.ts (13 errors) ==== function fn(): typeof fn { return 1; } ~ -!!! error TS2322: Type 'number' is not assignable to type '() => typeof fn'. +!!! error TS2322: Type '1' is not assignable to type '() => typeof fn'. var x: number = fn; // error ~ @@ -51,12 +51,12 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of } C.g(3); // error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type '(t: typeof g) => void'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type '(t: typeof g) => void'. var f4: () => typeof f4; f4 = 3; // error ~~ -!!! error TS2322: Type 'number' is not assignable to type '() => any'. +!!! error TS2322: Type '3' is not assignable to type '() => any'. function f5() { return f5; } @@ -71,7 +71,7 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of !!! error TS2346: Supplied parameters do not match any signature of call target. f6(""); // ok (function takes an any param) ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '{ (): typeof f6; (a: typeof f6): () => number; }'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f6; (a: typeof f6): () => number; }'. f6(); // ok declare function f7(): typeof f7; @@ -84,5 +84,5 @@ tests/cases/compiler/recursiveFunctionTypes.ts(43,4): error TS2345: Argument of !!! error TS2346: Supplied parameters do not match any signature of call target. f7(""); // ok (function takes an any param) ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '{ (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; }'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type '{ (): typeof f7; (a: typeof f7): () => number; (a: number): number; (a?: typeof f7): typeof f7; }'. f7(); // ok \ No newline at end of file diff --git a/tests/baselines/reference/recursiveInference1.types b/tests/baselines/reference/recursiveInference1.types index 58bb13d18e7..7144dd17abe 100644 --- a/tests/baselines/reference/recursiveInference1.types +++ b/tests/baselines/reference/recursiveInference1.types @@ -5,23 +5,23 @@ function fib(x:number) { return x <= 1 ? x : fib(x - 1) + fib(x - 2); } >x <= 1 ? x : fib(x - 1) + fib(x - 2) : any >x <= 1 : boolean >x : number ->1 : number +>1 : 1 >x : number >fib(x - 1) + fib(x - 2) : any >fib(x - 1) : any >fib : (x: number) => any >x - 1 : number >x : number ->1 : number +>1 : 1 >fib(x - 2) : any >fib : (x: number) => any >x - 2 : number >x : number ->2 : number +>2 : 2 var result = fib(5); >result : any >fib(5) : any >fib : (x: number) => any ->5 : number +>5 : 5 diff --git a/tests/baselines/reference/recursiveInitializer.types b/tests/baselines/reference/recursiveInitializer.types index f5bc2338902..ad6b8059b6c 100644 --- a/tests/baselines/reference/recursiveInitializer.types +++ b/tests/baselines/reference/recursiveInitializer.types @@ -22,7 +22,7 @@ var s1 = s1 + ''; >s1 : any >s1 + '' : string >s1 : any ->'' : string +>'' : "" var s2 /* any */ = s2 + s2; >s2 : any @@ -39,7 +39,7 @@ var s3 : string = s3 + s3; var s4 = '' + s4; >s4 : any >'' + s4 : string ->'' : string +>'' : "" >s4 : any // boolean unless otherwise specified diff --git a/tests/baselines/reference/recursiveMods.types b/tests/baselines/reference/recursiveMods.types index d4db816daf7..45e803fee1e 100644 --- a/tests/baselines/reference/recursiveMods.types +++ b/tests/baselines/reference/recursiveMods.types @@ -15,7 +15,7 @@ export module Foo { >C : C if (true) { return Bar();} ->true : boolean +>true : true >Bar() : C >Bar : () => C diff --git a/tests/baselines/reference/regExpWithSlashInCharClass.types b/tests/baselines/reference/regExpWithSlashInCharClass.types index fafe6e1be69..e866f2bc229 100644 --- a/tests/baselines/reference/regExpWithSlashInCharClass.types +++ b/tests/baselines/reference/regExpWithSlashInCharClass.types @@ -3,26 +3,26 @@ var foo1 = "a/".replace(/.[/]/, ""); >foo1 : string >"a/".replace(/.[/]/, "") : string >"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } ->"a/" : string +>"a/" : "a/" >replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/]/ : RegExp ->"" : string +>"" : "" var foo2 = "a//".replace(/.[//]/g, ""); >foo2 : string >"a//".replace(/.[//]/g, "") : string >"a//".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } ->"a//" : string +>"a//" : "a//" >replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[//]/g : RegExp ->"" : string +>"" : "" var foo3 = "a/".replace(/.[/no sleep /till/]/, "bugfix"); >foo3 : string >"a/".replace(/.[/no sleep /till/]/, "bugfix") : string >"a/".replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } ->"a/" : string +>"a/" : "a/" >replace : { (searchValue: string, replaceValue: string): string; (searchValue: string, replacer: (substring: string, ...args: any[]) => string): string; (searchValue: RegExp, replaceValue: string): string; (searchValue: RegExp, replacer: (substring: string, ...args: any[]) => string): string; } >/.[/no sleep /till/]/ : RegExp ->"bugfix" : string +>"bugfix" : "bugfix" diff --git a/tests/baselines/reference/relativeModuleWithoutSlash.types b/tests/baselines/reference/relativeModuleWithoutSlash.types index 796ef714dd9..f17185e1e18 100644 --- a/tests/baselines/reference/relativeModuleWithoutSlash.types +++ b/tests/baselines/reference/relativeModuleWithoutSlash.types @@ -3,13 +3,13 @@ export default { a: 0 }; >{ a: 0 } : { a: number; } >a : number ->0 : number +>0 : 0 === /a/index.ts === export default { aIndex: 0 }; >{ aIndex: 0 } : { aIndex: number; } >aIndex : number ->0 : number +>0 : 0 === /a/test.ts === import a from "."; diff --git a/tests/baselines/reference/relativePathToDeclarationFile.types b/tests/baselines/reference/relativePathToDeclarationFile.types index ef77acc85b4..0c196814b08 100644 --- a/tests/baselines/reference/relativePathToDeclarationFile.types +++ b/tests/baselines/reference/relativePathToDeclarationFile.types @@ -27,7 +27,7 @@ if(foo.M2.x){ >M2 : typeof other.M2 >x : string >charCodeAt : (index: number) => number ->0 : number +>0 : 0 } === tests/cases/conformance/externalModules/test/foo.d.ts === diff --git a/tests/baselines/reference/requireEmitSemicolon.types b/tests/baselines/reference/requireEmitSemicolon.types index 43ca9ef29c8..541cd67cb85 100644 --- a/tests/baselines/reference/requireEmitSemicolon.types +++ b/tests/baselines/reference/requireEmitSemicolon.types @@ -23,7 +23,7 @@ export module Database { >P : typeof P >Models : typeof P.Models >Person : typeof P.Models.Person ->"Rock" : string +>"Rock" : "Rock" } } } diff --git a/tests/baselines/reference/requiredInitializedParameter3.types b/tests/baselines/reference/requiredInitializedParameter3.types index aa37f5e13dd..92b35e2c83c 100644 --- a/tests/baselines/reference/requiredInitializedParameter3.types +++ b/tests/baselines/reference/requiredInitializedParameter3.types @@ -13,6 +13,6 @@ class C1 implements I1 { method(a = 0, b?) { } >method : (a?: number, b?: any) => void >a : number ->0 : number +>0 : 0 >b : any } diff --git a/tests/baselines/reference/requiredInitializedParameter4.types b/tests/baselines/reference/requiredInitializedParameter4.types index c483146a1ba..5465c9d1820 100644 --- a/tests/baselines/reference/requiredInitializedParameter4.types +++ b/tests/baselines/reference/requiredInitializedParameter4.types @@ -5,6 +5,6 @@ class C1 { method(a = 0, b) { } >method : (a: number, b: any) => void >a : number ->0 : number +>0 : 0 >b : any } diff --git a/tests/baselines/reference/reservedWords.types b/tests/baselines/reference/reservedWords.types index 4c76e056ce2..ae5a391bc58 100644 --- a/tests/baselines/reference/reservedWords.types +++ b/tests/baselines/reference/reservedWords.types @@ -5,19 +5,19 @@ var obj = { if: 0, >if : number ->0 : number +>0 : 0 debugger: 2, >debugger : number ->2 : number +>2 : 2 break: 3, >break : number ->3 : number +>3 : 3 function: 4 >function : number ->4 : number +>4 : 4 } //This compiles. @@ -28,22 +28,22 @@ var obj2 = { if: 0, >if : number ->0 : number +>0 : 0 while: 1, >while : number ->1 : number +>1 : 1 debugger: 2, >debugger : number ->2 : number +>2 : 2 break: 3, >break : number ->3 : number +>3 : 3 function: 4 >function : number ->4 : number +>4 : 4 } diff --git a/tests/baselines/reference/restElementWithAssignmentPattern5.types b/tests/baselines/reference/restElementWithAssignmentPattern5.types index c5cbc9ad206..298bc2e4363 100644 --- a/tests/baselines/reference/restElementWithAssignmentPattern5.types +++ b/tests/baselines/reference/restElementWithAssignmentPattern5.types @@ -11,6 +11,6 @@ var s: string, s2: string; >s : string >s2 : string >["", ""] : string[] ->"" : string ->"" : string +>"" : "" +>"" : "" diff --git a/tests/baselines/reference/restParameterNoTypeAnnotation.types b/tests/baselines/reference/restParameterNoTypeAnnotation.types index eed17802d57..e4944ec32cf 100644 --- a/tests/baselines/reference/restParameterNoTypeAnnotation.types +++ b/tests/baselines/reference/restParameterNoTypeAnnotation.types @@ -7,7 +7,7 @@ function foo(...rest) { >x : number >rest[0] : any >rest : any[] ->0 : number +>0 : 0 return x; >x : number diff --git a/tests/baselines/reference/returnInConstructor1.errors.txt b/tests/baselines/reference/returnInConstructor1.errors.txt index 30f629f9f8a..a7d3fd05204 100644 --- a/tests/baselines/reference/returnInConstructor1.errors.txt +++ b/tests/baselines/reference/returnInConstructor1.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2322: Type 'number' is not assignable to type 'B'. +tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2322: Type '1' is not assignable to type 'B'. tests/cases/compiler/returnInConstructor1.ts(11,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class -tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2322: Type 'string' is not assignable to type 'D'. +tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2322: Type '"test"' is not assignable to type 'D'. tests/cases/compiler/returnInConstructor1.ts(25,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/compiler/returnInConstructor1.ts(39,16): error TS2322: Type '{ foo: number; }' is not assignable to type 'F'. Types of property 'foo' are incompatible. @@ -25,7 +25,7 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o constructor() { return 1; // error ~ -!!! error TS2322: Type 'number' is not assignable to type 'B'. +!!! error TS2322: Type '1' is not assignable to type 'B'. ~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } @@ -43,7 +43,7 @@ tests/cases/compiler/returnInConstructor1.ts(55,16): error TS2409: Return type o constructor() { return "test"; // error ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'D'. +!!! error TS2322: Type '"test"' is not assignable to type 'D'. ~~~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } diff --git a/tests/baselines/reference/returnStatement1.types b/tests/baselines/reference/returnStatement1.types index b7e166ffa75..0c909551043 100644 --- a/tests/baselines/reference/returnStatement1.types +++ b/tests/baselines/reference/returnStatement1.types @@ -13,6 +13,6 @@ function f() { }; ("harmless extra line"); ->("harmless extra line") : string ->"harmless extra line" : string +>("harmless extra line") : "harmless extra line" +>"harmless extra line" : "harmless extra line" } diff --git a/tests/baselines/reference/returnStatements.types b/tests/baselines/reference/returnStatements.types index d64e7beb39f..b75104dd666 100644 --- a/tests/baselines/reference/returnStatements.types +++ b/tests/baselines/reference/returnStatements.types @@ -2,11 +2,11 @@ // all the following should be valid function fn1(): number { return 1; } >fn1 : () => number ->1 : number +>1 : 1 function fn2(): string { return ''; } >fn2 : () => string ->'' : string +>'' : "" function fn3(): void { return undefined; } >fn3 : () => void @@ -24,7 +24,7 @@ function fn6(): Date { return new Date(12); } >Date : Date >new Date(12) : Date >Date : DateConstructor ->12 : number +>12 : 12 function fn7(): any { return null; } >fn7 : () => any @@ -59,7 +59,7 @@ function fn10(): I { return { id: 12 }; } >I : I >{ id: 12 } : { id: number; } >id : number ->12 : number +>12 : 12 function fn11(): I { return new C(); } >fn11 : () => I diff --git a/tests/baselines/reference/reverseInferenceInContextualInstantiation.types b/tests/baselines/reference/reverseInferenceInContextualInstantiation.types index 881f6c6941f..d4a0b43919c 100644 --- a/tests/baselines/reference/reverseInferenceInContextualInstantiation.types +++ b/tests/baselines/reference/reverseInferenceInContextualInstantiation.types @@ -6,7 +6,7 @@ function compare(a: T, b: T): number { return 0; } >T : T >b : T >T : T ->0 : number +>0 : 0 var x: number[]; >x : number[] diff --git a/tests/baselines/reference/reversedRecusiveTypeInstantiation.types b/tests/baselines/reference/reversedRecusiveTypeInstantiation.types index fcbdab34e5a..2b647369cf4 100644 --- a/tests/baselines/reference/reversedRecusiveTypeInstantiation.types +++ b/tests/baselines/reference/reversedRecusiveTypeInstantiation.types @@ -24,12 +24,12 @@ var a : A >A : A a.zPos2Pos1.xPos1 = 1 ->a.zPos2Pos1.xPos1 = 1 : number +>a.zPos2Pos1.xPos1 = 1 : 1 >a.zPos2Pos1.xPos1 : number >a.zPos2Pos1 : A >a : A >zPos2Pos1 : A >xPos1 : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/scannerES3NumericLiteral1.types b/tests/baselines/reference/scannerES3NumericLiteral1.types index 0a1108c7ca9..99b10d56ad6 100644 --- a/tests/baselines/reference/scannerES3NumericLiteral1.types +++ b/tests/baselines/reference/scannerES3NumericLiteral1.types @@ -1,4 +1,4 @@ === tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral1.ts === 0 ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/scannerES3NumericLiteral2.types b/tests/baselines/reference/scannerES3NumericLiteral2.types index 8fae044c217..802e9fb7f33 100644 --- a/tests/baselines/reference/scannerES3NumericLiteral2.types +++ b/tests/baselines/reference/scannerES3NumericLiteral2.types @@ -1,4 +1,4 @@ === tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral2.ts === 01 ->01 : number +>01 : 1 diff --git a/tests/baselines/reference/scannerES3NumericLiteral5.types b/tests/baselines/reference/scannerES3NumericLiteral5.types index 2a5367e5b17..8e0d45c8085 100644 --- a/tests/baselines/reference/scannerES3NumericLiteral5.types +++ b/tests/baselines/reference/scannerES3NumericLiteral5.types @@ -1,4 +1,4 @@ === tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral5.ts === 1e0 ->1e0 : number +>1e0 : 1 diff --git a/tests/baselines/reference/scannerES3NumericLiteral7.types b/tests/baselines/reference/scannerES3NumericLiteral7.types index d5ffa0ea131..b39a4c58be9 100644 --- a/tests/baselines/reference/scannerES3NumericLiteral7.types +++ b/tests/baselines/reference/scannerES3NumericLiteral7.types @@ -1,4 +1,4 @@ === tests/cases/conformance/scanner/ecmascript3/scannerES3NumericLiteral7.ts === 1e+0 ->1e+0 : number +>1e+0 : 1 diff --git a/tests/baselines/reference/scannerEnum1.types b/tests/baselines/reference/scannerEnum1.types index d75899a75f1..c0b195db637 100644 --- a/tests/baselines/reference/scannerEnum1.types +++ b/tests/baselines/reference/scannerEnum1.types @@ -3,10 +3,10 @@ >CodeGenTarget : CodeGenTarget ES3 = 0, ->ES3 : CodeGenTarget ->0 : number +>ES3 : CodeGenTarget.ES3 +>0 : 0 ES5 = 1, ->ES5 : CodeGenTarget ->1 : number +>ES5 : CodeGenTarget.ES5 +>1 : 1 } diff --git a/tests/baselines/reference/scannerNumericLiteral1.types b/tests/baselines/reference/scannerNumericLiteral1.types index a3eebc411fa..06663789f3f 100644 --- a/tests/baselines/reference/scannerNumericLiteral1.types +++ b/tests/baselines/reference/scannerNumericLiteral1.types @@ -1,4 +1,4 @@ === tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral1.ts === 0 ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/scannerNumericLiteral5.types b/tests/baselines/reference/scannerNumericLiteral5.types index 86ab1a903e0..31fe2e5149d 100644 --- a/tests/baselines/reference/scannerNumericLiteral5.types +++ b/tests/baselines/reference/scannerNumericLiteral5.types @@ -1,4 +1,4 @@ === tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral5.ts === 1e0 ->1e0 : number +>1e0 : 1 diff --git a/tests/baselines/reference/scannerNumericLiteral7.types b/tests/baselines/reference/scannerNumericLiteral7.types index 25ce9275290..e2824f8cf94 100644 --- a/tests/baselines/reference/scannerNumericLiteral7.types +++ b/tests/baselines/reference/scannerNumericLiteral7.types @@ -1,4 +1,4 @@ === tests/cases/conformance/scanner/ecmascript5/scannerNumericLiteral7.ts === 1e+0 ->1e+0 : number +>1e+0 : 1 diff --git a/tests/baselines/reference/scannerStringLiteralWithContainingNullCharacter1.types b/tests/baselines/reference/scannerStringLiteralWithContainingNullCharacter1.types index 43eadd8c2918d41dbe14a88bc9f0895ee1368afc..9d17f416c39e001ffb0ce706beaec89019300423 100644 GIT binary patch delta 17 YcmZo+Y+;;G#igVWW1yhK%f-tD04AveT>t<8 delta 17 YcmZo+Y+;;G#Z_EVl$n>#%f-tD05UTKx : string ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/selfInCallback.types b/tests/baselines/reference/selfInCallback.types index 6010a64d80f..2d3385e3be6 100644 --- a/tests/baselines/reference/selfInCallback.types +++ b/tests/baselines/reference/selfInCallback.types @@ -4,7 +4,7 @@ class C { public p1 = 0; >p1 : number ->0 : number +>0 : 0 public callback(cb:()=>void) {cb();} >callback : (cb: () => void) => void @@ -25,6 +25,6 @@ class C { >this.p1 : number >this : this >p1 : number ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/selfInLambdas.types b/tests/baselines/reference/selfInLambdas.types index 3addf07c75a..614ebc16e68 100644 --- a/tests/baselines/reference/selfInLambdas.types +++ b/tests/baselines/reference/selfInLambdas.types @@ -28,7 +28,7 @@ var o = { counter: 0, >counter : number ->0 : number +>0 : 0 start: function() { >start : () => void @@ -67,7 +67,7 @@ class X { private value = "value"; >value : string ->"value" : string +>"value" : "value" public foo() { >foo : () => void diff --git a/tests/baselines/reference/shebang.types b/tests/baselines/reference/shebang.types index 5fd6f0533ec..b1a175d53dc 100644 --- a/tests/baselines/reference/shebang.types +++ b/tests/baselines/reference/shebang.types @@ -2,5 +2,5 @@ #!/usr/bin/env node var foo = 'I wish the generated JS to be executed in node'; >foo : string ->'I wish the generated JS to be executed in node' : string +>'I wish the generated JS to be executed in node' : "I wish the generated JS to be executed in node" diff --git a/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.js b/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.js index 9e057951b3a..df23dba8776 100644 --- a/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.js +++ b/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.js @@ -17,5 +17,5 @@ exports.foo = foo; //// [shorthandOfExportedEntity01_targetES2015_CommonJS.d.ts] -export declare const test: string; +export declare const test: "test"; export declare function foo(): void; diff --git a/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.types b/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.types index dcc04015993..f299632b3ef 100644 --- a/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.types +++ b/tests/baselines/reference/shorthandOfExportedEntity01_targetES2015_CommonJS.types @@ -1,8 +1,8 @@ === tests/cases/compiler/shorthandOfExportedEntity01_targetES2015_CommonJS.ts === export const test = "test"; ->test : string ->"test" : string +>test : "test" +>"test" : "test" export function foo () { >foo : () => void @@ -10,6 +10,6 @@ export function foo () { const x = { test }; >x : { test: string; } >{ test } : { test: string; } ->test : string +>test : "test" } diff --git a/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.js b/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.js index 764739705c4..a594a1b6de5 100644 --- a/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.js +++ b/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.js @@ -17,5 +17,5 @@ exports.foo = foo; //// [shorthandOfExportedEntity02_targetES5_CommonJS.d.ts] -export declare const test: string; +export declare const test: "test"; export declare function foo(): void; diff --git a/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.types b/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.types index 27d16e2166f..effe8e89da4 100644 --- a/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.types +++ b/tests/baselines/reference/shorthandOfExportedEntity02_targetES5_CommonJS.types @@ -1,8 +1,8 @@ === tests/cases/compiler/shorthandOfExportedEntity02_targetES5_CommonJS.ts === export const test = "test"; ->test : string ->"test" : string +>test : "test" +>"test" : "test" export function foo () { >foo : () => void @@ -10,6 +10,6 @@ export function foo () { const x = { test }; >x : { test: string; } >{ test } : { test: string; } ->test : string +>test : "test" } diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt index 7ac5fe9a26c..ce029a49f18 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring.errors.txt @@ -1,13 +1,15 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(16,9): error TS2459: Type '{}' has no property 's1' and no string index signature. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(22,9): error TS2459: Type '{}' has no property 's1' and no string index signature. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(40,9): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(46,12): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(72,5): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(40,9): error TS2322: Type '5' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(46,12): error TS2322: Type '5' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(72,5): error TS2322: Type '5' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(77,8): error TS2322: Type '5' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(77,8): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(82,5): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(82,5): error TS2322: Type '5' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(82,13): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. Types of property 'x' are incompatible. Type 'number' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(87,8): error TS2322: Type '5' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(87,8): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(87,19): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. Types of property 'x' are incompatible. @@ -16,7 +18,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,12): err tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,14): error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. -==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts (12 errors) ==== +==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts (14 errors) ==== (function() { @@ -62,7 +64,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,14): err var s3: string; for ({ s3 = 5 } of [{ s3: "" }]) { ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. } }); @@ -70,7 +72,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,14): err var s3: string; for ({ s3:s3 = 5 } of [{ s3: "" }]) { ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. } }); @@ -98,13 +100,15 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,14): err let y1: string; ({ y1 = 5 } = {}) ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. }); (function() { let y1: string; ({ y1:y1 = 5 } = {}) ~~ +!!! error TS2322: Type '5' is not assignable to type 'string'. + ~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. }); @@ -112,7 +116,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,14): err let y2: string, y3: { x: string }; ({ y2 = 5, y3 = { x: 1 } } = {}) ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. ~~ !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. !!! error TS2322: Types of property 'x' are incompatible. @@ -123,6 +127,8 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring.ts(113,14): err let y2: string, y3: { x: string }; ({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) ~~ +!!! error TS2322: Type '5' is not assignable to type 'string'. + ~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. ~~ !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. diff --git a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt index 7e6b6b35d7f..0a61eed7326 100644 --- a/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt +++ b/tests/baselines/reference/shorthandPropertyAssignmentsInDestructuring_ES6.errors.txt @@ -1,13 +1,15 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(16,9): error TS2459: Type '{}' has no property 's1' and no string index signature. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(22,9): error TS2459: Type '{}' has no property 's1' and no string index signature. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(40,9): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(46,12): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(72,5): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(40,9): error TS2322: Type '5' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(46,12): error TS2322: Type '5' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(72,5): error TS2322: Type '5' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(77,8): error TS2322: Type '5' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(77,8): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(82,5): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(82,5): error TS2322: Type '5' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(82,13): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. Types of property 'x' are incompatible. Type 'number' is not assignable to type 'string'. +tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(87,8): error TS2322: Type '5' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(87,8): error TS2322: Type 'number' is not assignable to type 'string'. tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(87,19): error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. Types of property 'x' are incompatible. @@ -16,7 +18,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,12): tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,14): error TS1312: '=' can only be used in an object literal property inside a destructuring assignment. -==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts (12 errors) ==== +==== tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts (14 errors) ==== (function() { @@ -62,7 +64,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,14): var s3: string; for ({ s3 = 5 } of [{ s3: "" }]) { ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. } }); @@ -70,7 +72,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,14): var s3: string; for ({ s3:s3 = 5 } of [{ s3: "" }]) { ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. } }); @@ -98,13 +100,15 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,14): let y1: string; ({ y1 = 5 } = {}) ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. }); (function() { let y1: string; ({ y1:y1 = 5 } = {}) ~~ +!!! error TS2322: Type '5' is not assignable to type 'string'. + ~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. }); @@ -112,7 +116,7 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,14): let y2: string, y3: { x: string }; ({ y2 = 5, y3 = { x: 1 } } = {}) ~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. ~~ !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. !!! error TS2322: Types of property 'x' are incompatible. @@ -123,6 +127,8 @@ tests/cases/compiler/shorthandPropertyAssignmentsInDestructuring_ES6.ts(113,14): let y2: string, y3: { x: string }; ({ y2:y2 = 5, y3:y3 = { x: 1 } } = {}) ~~ +!!! error TS2322: Type '5' is not assignable to type 'string'. + ~~ !!! error TS2322: Type 'number' is not assignable to type 'string'. ~~ !!! error TS2322: Type '{ x: number; }' is not assignable to type '{ x: string; }'. diff --git a/tests/baselines/reference/signaturesUseJSDocForOptionalParameters.types b/tests/baselines/reference/signaturesUseJSDocForOptionalParameters.types index 48d44bb5406..f8822397306 100644 --- a/tests/baselines/reference/signaturesUseJSDocForOptionalParameters.types +++ b/tests/baselines/reference/signaturesUseJSDocForOptionalParameters.types @@ -40,7 +40,7 @@ let c1 = pInst.optionalParam('hello') >pInst.optionalParam : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } >pInst : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } >optionalParam : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } ->'hello' : string +>'hello' : "hello" let c2 = pInst.optionalParam('hello', null) >c2 : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } @@ -48,6 +48,6 @@ let c2 = pInst.optionalParam('hello', null) >pInst.optionalParam : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } >pInst : { prop: null; optionalParam: (required: string, notRequired?: string) => typeof MyClass; } >optionalParam : (required: string, notRequired?: string) => { prop: null; optionalParam: any; } ->'hello' : string +>'hello' : "hello" >null : null diff --git a/tests/baselines/reference/singleLineCommentInConciseArrowFunctionES3.types b/tests/baselines/reference/singleLineCommentInConciseArrowFunctionES3.types index e8c449e7bb8..09efdfa2fec 100644 --- a/tests/baselines/reference/singleLineCommentInConciseArrowFunctionES3.types +++ b/tests/baselines/reference/singleLineCommentInConciseArrowFunctionES3.types @@ -7,5 +7,5 @@ function test() { // some comments here; 123; ->123 : number +>123 : 123 } diff --git a/tests/baselines/reference/sourceMap-Comments.types b/tests/baselines/reference/sourceMap-Comments.types index b1681c05aad..088be00e43d 100644 --- a/tests/baselines/reference/sourceMap-Comments.types +++ b/tests/baselines/reference/sourceMap-Comments.types @@ -11,7 +11,7 @@ module sas.tools { let f: number = 2; >f : number ->2 : number +>2 : 2 switch (f) { >f : number diff --git a/tests/baselines/reference/sourceMap-FileWithComments.types b/tests/baselines/reference/sourceMap-FileWithComments.types index 6f9ca201085..2198fa9a590 100644 --- a/tests/baselines/reference/sourceMap-FileWithComments.types +++ b/tests/baselines/reference/sourceMap-FileWithComments.types @@ -50,14 +50,14 @@ module Shapes { >origin : Point >new Point(0, 0) : Point >Point : typeof Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 } // Variable comment after class var a = 10; >a : number ->10 : number +>10 : 10 export function foo() { >foo : () => void @@ -68,7 +68,7 @@ module Shapes { */ var b = 10; >b : number ->10 : number +>10 : 10 } /** Local Variable */ @@ -79,8 +79,8 @@ var p: IPoint = new Shapes.Point(3, 4); >Shapes.Point : typeof Shapes.Point >Shapes : typeof Shapes >Point : typeof Shapes.Point ->3 : number ->4 : number +>3 : 3 +>4 : 4 var dist = p.getDist(); >dist : number diff --git a/tests/baselines/reference/sourceMap-InterfacePrecedingVariableDeclaration1.types b/tests/baselines/reference/sourceMap-InterfacePrecedingVariableDeclaration1.types index fb361a53bd5..5faca1a4ddb 100644 --- a/tests/baselines/reference/sourceMap-InterfacePrecedingVariableDeclaration1.types +++ b/tests/baselines/reference/sourceMap-InterfacePrecedingVariableDeclaration1.types @@ -5,5 +5,5 @@ interface I {} var x = 0; >x : number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/sourceMap-LineBreaks.types b/tests/baselines/reference/sourceMap-LineBreaks.types index 1e0220906da..41dc77a36bf 100644 --- a/tests/baselines/reference/sourceMap-LineBreaks.types +++ b/tests/baselines/reference/sourceMap-LineBreaks.types @@ -1,40 +1,40 @@ === tests/cases/compiler/sourceMap-LineBreaks.ts === var endsWithlineSeparator = 10; 
var endsWithParagraphSeparator = 10; 
var endsWithNextLine = 1;…var endsWithLineFeed = 1; >endsWithlineSeparator : number ->10 : number +>10 : 10 var endsWithCarriageReturnLineFeed = 1; >endsWithParagraphSeparator : number ->10 : number +>10 : 10 var endsWithCarriageReturn = 1; var endsWithLineFeedCarriageReturn = 1; >endsWithNextLine : number ->1 : number +>1 : 1 >endsWithLineFeed : number ->1 : number +>1 : 1 var endsWithLineFeedCarriageReturnLineFeed = 1; >endsWithCarriageReturnLineFeed : number ->1 : number +>1 : 1 >endsWithCarriageReturn : number ->1 : number +>1 : 1 var stringLiteralWithLineFeed = "line 1\ >endsWithLineFeedCarriageReturn : number ->1 : number +>1 : 1 line 2"; var stringLiteralWithCarriageReturnLineFeed = "line 1\ >endsWithLineFeedCarriageReturnLineFeed : number ->1 : number +>1 : 1 line 2"; var stringLiteralWithCarriageReturn = "line 1\ line 2"; >stringLiteralWithLineFeed : string ->"line 1\line 2" : string +>"line 1\line 2" : "line 1line 2" var stringLiteralWithLineSeparator = "line 1\
line 2";
var stringLiteralWithParagraphSeparator = "line 1\
line 2";
var stringLiteralWithNextLine = "line 1\…line 2"; >stringLiteralWithCarriageReturnLineFeed : string ->"line 1\line 2" : string +>"line 1\line 2" : "line 1line 2" diff --git a/tests/baselines/reference/sourceMap-StringLiteralWithNewLine.types b/tests/baselines/reference/sourceMap-StringLiteralWithNewLine.types index 827f523e277..26bfd605b95 100644 --- a/tests/baselines/reference/sourceMap-StringLiteralWithNewLine.types +++ b/tests/baselines/reference/sourceMap-StringLiteralWithNewLine.types @@ -19,11 +19,11 @@ module Foo { var x = "test1"; >x : string ->"test1" : string +>"test1" : "test1" var y = "test 2\ >y : string ->"test 2\isn't this a lot of fun" : string +>"test 2\isn't this a lot of fun" : "test 2isn't this a lot of fun" isn't this a lot of fun"; var z = window.document; diff --git a/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.types b/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.types index db4f2c320b4..1c28536dafc 100644 --- a/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.types +++ b/tests/baselines/reference/sourceMapForFunctionInInternalModuleWithCommentPrecedingStatement01.types @@ -8,6 +8,6 @@ module Q { // Test this var a = 1; >a : number ->1 : number +>1 : 1 } } diff --git a/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.types b/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.types index 5e3d01a6b5b..c4625f115dd 100644 --- a/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.types +++ b/tests/baselines/reference/sourceMapForFunctionWithCommentPrecedingStatement01.types @@ -5,5 +5,5 @@ function P() { // Test this var a = 1; >a : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/sourceMapValidationClass.types b/tests/baselines/reference/sourceMapValidationClass.types index 3e5234b0d6e..f6d80f39416 100644 --- a/tests/baselines/reference/sourceMapValidationClass.types +++ b/tests/baselines/reference/sourceMapValidationClass.types @@ -12,18 +12,18 @@ class Greeter { return "

" + this.greeting + "

"; >"

" + this.greeting + "

" : string >"

" + this.greeting : string ->"

" : string +>"

" : "

" >this.greeting : string >this : this >greeting : string ->"

" : string +>"" : "" } private x: string; >x : string private x1: number = 10; >x1 : number ->10 : number +>10 : 10 private fn() { >fn : () => string diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructor.types b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructor.types index 5cca47a0a41..a50677684dc 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructor.types +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructor.types @@ -4,9 +4,9 @@ class Greeter { public a = 10; >a : number ->10 : number +>10 : 10 public nameA = "Ten"; >nameA : string ->"Ten" : string +>"Ten" : "Ten" } diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.types b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.types index a20410aa842..7c686c48059 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.types +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndCapturedThisStatement.types @@ -4,7 +4,7 @@ class Greeter { public a = 10; >a : number ->10 : number +>10 : 10 public returnA = () => this.a; >returnA : () => number diff --git a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.types b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.types index 12d8d56cf6e..2ff310b28f6 100644 --- a/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.types +++ b/tests/baselines/reference/sourceMapValidationClassWithDefaultConstructorAndExtendsClause.types @@ -9,9 +9,9 @@ class Greeter extends AbstractGreeter { public a = 10; >a : number ->10 : number +>10 : 10 public nameA = "Ten"; >nameA : string ->"Ten" : string +>"Ten" : "Ten" } diff --git a/tests/baselines/reference/sourceMapValidationClasses.types b/tests/baselines/reference/sourceMapValidationClasses.types index 5b3512c06c1..590f6d07c16 100644 --- a/tests/baselines/reference/sourceMapValidationClasses.types +++ b/tests/baselines/reference/sourceMapValidationClasses.types @@ -4,7 +4,7 @@ module Foo.Bar { >Bar : typeof Bar "use strict"; ->"use strict" : string +>"use strict" : "use strict" class Greeter { >Greeter : Greeter @@ -19,11 +19,11 @@ module Foo.Bar { return "

" + this.greeting + "

"; >"

" + this.greeting + "

" : string >"

" + this.greeting : string ->"

" : string +>"

" : "

" >this.greeting : string >this : this >greeting : string ->"

" : string +>"" : "" } } @@ -43,7 +43,7 @@ module Foo.Bar { >greeter : Greeter >new Greeter("Hello, world!") : Greeter >Greeter : typeof Greeter ->"Hello, world!" : string +>"Hello, world!" : "Hello, world!" var str = greeter.greet(); >str : string @@ -66,14 +66,14 @@ module Foo.Bar { >greeters[0] = new Greeter(greeting) : Greeter >greeters[0] : Greeter >greeters : Greeter[] ->0 : number +>0 : 0 >new Greeter(greeting) : Greeter >Greeter : typeof Greeter >greeting : string for (var i = 0; i < restGreetings.length; i++) { >i : number ->0 : number +>0 : 0 >i < restGreetings.length : boolean >i : number >restGreetings.length : number @@ -102,14 +102,14 @@ module Foo.Bar { >b : Greeter[] >foo2("Hello", "World", "!") : Greeter[] >foo2 : (greeting: string, ...restGreetings: string[]) => Greeter[] ->"Hello" : string ->"World" : string ->"!" : string +>"Hello" : "Hello" +>"World" : "World" +>"!" : "!" // This is simple signle line comment for (var j = 0; j < b.length; j++) { >j : number ->0 : number +>0 : 0 >j < b.length : boolean >j : number >b.length : number diff --git a/tests/baselines/reference/sourceMapValidationDecorators.types b/tests/baselines/reference/sourceMapValidationDecorators.types index 2fc05972307..8e807786e78 100644 --- a/tests/baselines/reference/sourceMapValidationDecorators.types +++ b/tests/baselines/reference/sourceMapValidationDecorators.types @@ -48,7 +48,7 @@ declare function ParameterDecorator2(x: number): (target: Object, key: string | @ClassDecorator2(10) >ClassDecorator2(10) : (target: Function) => void >ClassDecorator2 : (x: number) => (target: Function) => void ->10 : number +>10 : 10 class Greeter { >Greeter : Greeter @@ -60,7 +60,7 @@ class Greeter { @ParameterDecorator2(20) >ParameterDecorator2(20) : (target: Object, key: string | symbol, paramIndex: number) => void >ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void ->20 : number +>20 : 20 public greeting: string, >greeting : string @@ -71,7 +71,7 @@ class Greeter { @ParameterDecorator2(30) >ParameterDecorator2(30) : (target: Object, key: string | symbol, paramIndex: number) => void >ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void ->30 : number +>30 : 30 ...b: string[]) { >b : string[] @@ -83,7 +83,7 @@ class Greeter { @PropertyDecorator2(40) >PropertyDecorator2(40) : (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void >PropertyDecorator2 : (x: number) => (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void ->40 : number +>40 : 40 greet() { >greet : () => string @@ -91,11 +91,11 @@ class Greeter { return "

" + this.greeting + "

"; >"

" + this.greeting + "

" : string >"

" + this.greeting : string ->"

" : string +>"

" : "

" >this.greeting : string >this : this >greeting : string ->"

" : string +>"" : "" } @PropertyDecorator1 @@ -104,7 +104,7 @@ class Greeter { @PropertyDecorator2(50) >PropertyDecorator2(50) : (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void >PropertyDecorator2 : (x: number) => (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void ->50 : number +>50 : 50 private x: string; >x : string @@ -115,11 +115,11 @@ class Greeter { @PropertyDecorator2(60) >PropertyDecorator2(60) : (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void >PropertyDecorator2 : (x: number) => (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void ->60 : number +>60 : 60 private static x1: number = 10; >x1 : number ->10 : number +>10 : 10 private fn( >fn : (x: number) => string @@ -130,7 +130,7 @@ class Greeter { @ParameterDecorator2(70) >ParameterDecorator2(70) : (target: Object, key: string | symbol, paramIndex: number) => void >ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void ->70 : number +>70 : 70 x: number) { >x : number @@ -147,7 +147,7 @@ class Greeter { @PropertyDecorator2(80) >PropertyDecorator2(80) : (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void >PropertyDecorator2 : (x: number) => (target: Object, key: string | symbol, descriptor?: PropertyDescriptor) => void ->80 : number +>80 : 80 get greetings() { >greetings : string @@ -167,7 +167,7 @@ class Greeter { @ParameterDecorator2(90) >ParameterDecorator2(90) : (target: Object, key: string | symbol, paramIndex: number) => void >ParameterDecorator2 : (x: number) => (target: Object, key: string | symbol, paramIndex: number) => void ->90 : number +>90 : 90 greetings: string) { >greetings : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern.types index c2a88a68838..00ecd2659ee 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern.types @@ -16,9 +16,9 @@ let robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" function getRobot() { >getRobot : () => [number, string, string] @@ -31,19 +31,19 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" function getMultiRobot() { >getMultiRobot : () => [string, [string, string]] @@ -57,10 +57,10 @@ for (let [, nameA] = robotA, i = 0; i < 1; i++) { >nameA : string >robotA : [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -77,10 +77,10 @@ for (let [, nameA] = getRobot(), i = 0; i < 1; i++) { >getRobot() : [number, string, string] >getRobot : () => [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -95,14 +95,14 @@ for (let [, nameA] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { > : undefined >nameA : string >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -119,10 +119,10 @@ for (let [, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) >secondarySkillA : string >multiRobotA : [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -140,10 +140,10 @@ for (let [, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -159,15 +159,15 @@ for (let [, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging >primarySkillA : string >secondarySkillA : string >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -183,10 +183,10 @@ for (let [numberB] = robotA, i = 0; i < 1; i++) { >numberB : number >robotA : [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -202,10 +202,10 @@ for (let [numberB] = getRobot(), i = 0; i < 1; i++) { >getRobot() : [number, string, string] >getRobot : () => [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -219,14 +219,14 @@ for (let [numberB] = getRobot(), i = 0; i < 1; i++) { for (let [numberB] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >numberB : number >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -241,10 +241,10 @@ for (let [nameB] = multiRobotA, i = 0; i < 1; i++) { >nameB : string >multiRobotA : [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -260,10 +260,10 @@ for (let [nameB] = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -277,15 +277,15 @@ for (let [nameB] = getMultiRobot(), i = 0; i < 1; i++) { for (let [nameB] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { >nameB : string >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -303,10 +303,10 @@ for (let [numberA2, nameA2, skillA2] = robotA, i = 0; i < 1; i++) { >skillA2 : string >robotA : [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -324,10 +324,10 @@ for (let [numberA2, nameA2, skillA2] = getRobot(), i = 0; i < 1; i++) { >getRobot() : [number, string, string] >getRobot : () => [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -343,14 +343,14 @@ for (let [numberA2, nameA2, skillA2] = [2, "trimmer", "trimming"], i = 0; i < 1; >nameA2 : string >skillA2 : string >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -367,10 +367,10 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; >secondarySkillA : string >multiRobotA : [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -388,10 +388,10 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -407,15 +407,15 @@ for (let [nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", " >primarySkillA : string >secondarySkillA : string >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -432,10 +432,10 @@ for (let [numberA3, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >robotAInfo : (string | number)[] >robotA : [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -452,10 +452,10 @@ for (let [numberA3, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >getRobot() : [number, string, string] >getRobot : () => [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -470,14 +470,14 @@ for (let [numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1; i >numberA3 : string | number >robotAInfo : (string | number)[] >[2, "trimmer", "trimming"] : (string | number)[] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -492,10 +492,10 @@ for (let [...multiRobotAInfo] = multiRobotA, i = 0; i < 1; i++) { >multiRobotAInfo : (string | [string, string])[] >multiRobotA : [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -511,10 +511,10 @@ for (let [...multiRobotAInfo] = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -528,15 +528,15 @@ for (let [...multiRobotAInfo] = getMultiRobot(), i = 0; i < 1; i++) { for (let [...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { >multiRobotAInfo : (string | string[])[] >["trimmer", ["trimming", "edging"]] : (string | string[])[] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern2.types index e9f7a0a7406..f317fa2a83c 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPattern2.types @@ -16,9 +16,9 @@ let robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" function getRobot() { >getRobot : () => [number, string, string] @@ -31,19 +31,19 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" function getMultiRobot() { >getMultiRobot : () => [string, [string, string]] @@ -76,18 +76,18 @@ let i: number; >i : number for ([, nameA] = robotA, i = 0; i < 1; i++) { ->[, nameA] = robotA, i = 0 : number +>[, nameA] = robotA, i = 0 : 0 >[, nameA] = robotA : [number, string, string] >[, nameA] : [undefined, string] > : undefined >nameA : string >robotA : [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -99,19 +99,19 @@ for ([, nameA] = robotA, i = 0; i < 1; i++) { >nameA : string } for ([, nameA] = getRobot(), i = 0; i < 1; i++) { ->[, nameA] = getRobot(), i = 0 : number +>[, nameA] = getRobot(), i = 0 : 0 >[, nameA] = getRobot() : [number, string, string] >[, nameA] : [undefined, string] > : undefined >nameA : string >getRobot() : [number, string, string] >getRobot : () => [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -123,21 +123,21 @@ for ([, nameA] = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ([, nameA] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { ->[, nameA] = [2, "trimmer", "trimming"], i = 0 : number +>[, nameA] = [2, "trimmer", "trimming"], i = 0 : 0 >[, nameA] = [2, "trimmer", "trimming"] : [number, string, string] >[, nameA] : [undefined, string] > : undefined >nameA : string >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string ->i = 0 : number +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -149,7 +149,7 @@ for ([, nameA] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >nameA : string } for ([, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { ->[, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0 : number +>[, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0 : 0 >[, [primarySkillA, secondarySkillA]] = multiRobotA : [string, [string, string]] >[, [primarySkillA, secondarySkillA]] : [undefined, [string, string]] > : undefined @@ -157,12 +157,12 @@ for ([, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { >primarySkillA : string >secondarySkillA : string >multiRobotA : [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -174,7 +174,7 @@ for ([, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { >primarySkillA : string } for ([, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i++) { ->[, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0 : number +>[, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0 : 0 >[, [primarySkillA, secondarySkillA]] = getMultiRobot() : [string, [string, string]] >[, [primarySkillA, secondarySkillA]] : [undefined, [string, string]] > : undefined @@ -183,12 +183,12 @@ for ([, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i++) >secondarySkillA : string >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -200,7 +200,7 @@ for ([, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i++) >primarySkillA : string } for ([, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { ->[, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], i = 0 : number +>[, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], i = 0 : 0 >[, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] >[, [primarySkillA, secondarySkillA]] : [undefined, [string, string]] > : undefined @@ -208,16 +208,16 @@ for ([, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], >primarySkillA : string >secondarySkillA : string >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string ->i = 0 : number +>"trimming" : "trimming" +>"edging" : "edging" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -230,17 +230,17 @@ for ([, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], } for ([numberB] = robotA, i = 0; i < 1; i++) { ->[numberB] = robotA, i = 0 : number +>[numberB] = robotA, i = 0 : 0 >[numberB] = robotA : [number, string, string] >[numberB] : [number] >numberB : number >robotA : [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -252,18 +252,18 @@ for ([numberB] = robotA, i = 0; i < 1; i++) { >numberB : number } for ([numberB] = getRobot(), i = 0; i < 1; i++) { ->[numberB] = getRobot(), i = 0 : number +>[numberB] = getRobot(), i = 0 : 0 >[numberB] = getRobot() : [number, string, string] >[numberB] : [number] >numberB : number >getRobot() : [number, string, string] >getRobot : () => [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -275,20 +275,20 @@ for ([numberB] = getRobot(), i = 0; i < 1; i++) { >numberB : number } for ([numberB] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { ->[numberB] = [2, "trimmer", "trimming"], i = 0 : number +>[numberB] = [2, "trimmer", "trimming"], i = 0 : 0 >[numberB] = [2, "trimmer", "trimming"] : [number, string, string] >[numberB] : [number] >numberB : number >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string ->i = 0 : number +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -300,17 +300,17 @@ for ([numberB] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >numberB : number } for ([nameB] = multiRobotA, i = 0; i < 1; i++) { ->[nameB] = multiRobotA, i = 0 : number +>[nameB] = multiRobotA, i = 0 : 0 >[nameB] = multiRobotA : [string, [string, string]] >[nameB] : [string] >nameB : string >multiRobotA : [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -322,18 +322,18 @@ for ([nameB] = multiRobotA, i = 0; i < 1; i++) { >nameB : string } for ([nameB] = getMultiRobot(), i = 0; i < 1; i++) { ->[nameB] = getMultiRobot(), i = 0 : number +>[nameB] = getMultiRobot(), i = 0 : 0 >[nameB] = getMultiRobot() : [string, [string, string]] >[nameB] : [string] >nameB : string >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -345,21 +345,21 @@ for ([nameB] = getMultiRobot(), i = 0; i < 1; i++) { >nameB : string } for ([nameB] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { ->[nameB] = ["trimmer", ["trimming", "edging"]], i = 0 : number +>[nameB] = ["trimmer", ["trimming", "edging"]], i = 0 : 0 >[nameB] = ["trimmer", ["trimming", "edging"]] : [string, string[]] >[nameB] : [string] >nameB : string >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string ->i = 0 : number +>"trimming" : "trimming" +>"edging" : "edging" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -372,19 +372,19 @@ for ([nameB] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { } for ([numberA2, nameA2, skillA2] = robotA, i = 0; i < 1; i++) { ->[numberA2, nameA2, skillA2] = robotA, i = 0 : number +>[numberA2, nameA2, skillA2] = robotA, i = 0 : 0 >[numberA2, nameA2, skillA2] = robotA : [number, string, string] >[numberA2, nameA2, skillA2] : [number, string, string] >numberA2 : number >nameA2 : string >skillA2 : string >robotA : [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -396,7 +396,7 @@ for ([numberA2, nameA2, skillA2] = robotA, i = 0; i < 1; i++) { >nameA2 : string } for ([numberA2, nameA2, skillA2] = getRobot(), i = 0; i < 1; i++) { ->[numberA2, nameA2, skillA2] = getRobot(), i = 0 : number +>[numberA2, nameA2, skillA2] = getRobot(), i = 0 : 0 >[numberA2, nameA2, skillA2] = getRobot() : [number, string, string] >[numberA2, nameA2, skillA2] : [number, string, string] >numberA2 : number @@ -404,12 +404,12 @@ for ([numberA2, nameA2, skillA2] = getRobot(), i = 0; i < 1; i++) { >skillA2 : string >getRobot() : [number, string, string] >getRobot : () => [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -421,22 +421,22 @@ for ([numberA2, nameA2, skillA2] = getRobot(), i = 0; i < 1; i++) { >nameA2 : string } for ([numberA2, nameA2, skillA2] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { ->[numberA2, nameA2, skillA2] = [2, "trimmer", "trimming"], i = 0 : number +>[numberA2, nameA2, skillA2] = [2, "trimmer", "trimming"], i = 0 : 0 >[numberA2, nameA2, skillA2] = [2, "trimmer", "trimming"] : [number, string, string] >[numberA2, nameA2, skillA2] : [number, string, string] >numberA2 : number >nameA2 : string >skillA2 : string >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string ->i = 0 : number +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -448,7 +448,7 @@ for ([numberA2, nameA2, skillA2] = [2, "trimmer", "trimming"], i = 0; i < 1; i++ >nameA2 : string } for ([nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++) { ->[nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0 : number +>[nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0 : 0 >[nameMA, [primarySkillA, secondarySkillA]] = multiRobotA : [string, [string, string]] >[nameMA, [primarySkillA, secondarySkillA]] : [string, [string, string]] >nameMA : string @@ -456,12 +456,12 @@ for ([nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++ >primarySkillA : string >secondarySkillA : string >multiRobotA : [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -473,7 +473,7 @@ for ([nameMA, [primarySkillA, secondarySkillA]] = multiRobotA, i = 0; i < 1; i++ >nameMA : string } for ([nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; i++) { ->[nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0 : number +>[nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0 : 0 >[nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot() : [string, [string, string]] >[nameMA, [primarySkillA, secondarySkillA]] : [string, [string, string]] >nameMA : string @@ -482,12 +482,12 @@ for ([nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; >secondarySkillA : string >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -499,7 +499,7 @@ for ([nameMA, [primarySkillA, secondarySkillA]] = getMultiRobot(), i = 0; i < 1; >nameMA : string } for ([nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { ->[nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], i = 0 : number +>[nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]], i = 0 : 0 >[nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] >[nameMA, [primarySkillA, secondarySkillA]] : [string, [string, string]] >nameMA : string @@ -507,16 +507,16 @@ for ([nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edgi >primarySkillA : string >secondarySkillA : string >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string ->i = 0 : number +>"trimming" : "trimming" +>"edging" : "edging" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -529,19 +529,19 @@ for ([nameMA, [primarySkillA, secondarySkillA]] = ["trimmer", ["trimming", "edgi } for ([numberA3, ...robotAInfo] = robotA, i = 0; i < 1; i++) { ->[numberA3, ...robotAInfo] = robotA, i = 0 : number +>[numberA3, ...robotAInfo] = robotA, i = 0 : 0 >[numberA3, ...robotAInfo] = robotA : [number, string, string] >[numberA3, ...robotAInfo] : (string | number)[] >numberA3 : number >...robotAInfo : string | number >robotAInfo : (string | number)[] >robotA : [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -553,7 +553,7 @@ for ([numberA3, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >numberA3 : number } for ([numberA3, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { ->[numberA3, ...robotAInfo] = getRobot(), i = 0 : number +>[numberA3, ...robotAInfo] = getRobot(), i = 0 : 0 >[numberA3, ...robotAInfo] = getRobot() : [number, string, string] >[numberA3, ...robotAInfo] : (string | number)[] >numberA3 : number @@ -561,12 +561,12 @@ for ([numberA3, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >robotAInfo : (string | number)[] >getRobot() : [number, string, string] >getRobot : () => [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -578,7 +578,7 @@ for ([numberA3, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >numberA3 : number } for ([numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { ->[numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0 : number +>[numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0 : 0 >[numberA3, ...robotAInfo] = [2, "trimmer", "trimming"] : [number, string, string] >[numberA3, ...robotAInfo] : (string | number)[] >numberA3 : number @@ -587,15 +587,15 @@ for ([numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1 >[2, "trimmer", "trimming"] : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string ->i = 0 : number +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -607,18 +607,18 @@ for ([numberA3, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1 >numberA3 : number } for ([...multiRobotAInfo] = multiRobotA, i = 0; i < 1; i++) { ->[...multiRobotAInfo] = multiRobotA, i = 0 : number +>[...multiRobotAInfo] = multiRobotA, i = 0 : 0 >[...multiRobotAInfo] = multiRobotA : [string, [string, string]] >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] >multiRobotA : [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -630,19 +630,19 @@ for ([...multiRobotAInfo] = multiRobotA, i = 0; i < 1; i++) { >multiRobotAInfo : (string | [string, string])[] } for ([...multiRobotAInfo] = getMultiRobot(), i = 0; i < 1; i++) { ->[...multiRobotAInfo] = getMultiRobot(), i = 0 : number +>[...multiRobotAInfo] = getMultiRobot(), i = 0 : 0 >[...multiRobotAInfo] = getMultiRobot() : [string, [string, string]] >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -654,7 +654,7 @@ for ([...multiRobotAInfo] = getMultiRobot(), i = 0; i < 1; i++) { >multiRobotAInfo : (string | [string, string])[] } for ([...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { ->[...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]], i = 0 : number +>[...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]], i = 0 : 0 >[...multiRobotAInfo] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] >[...multiRobotAInfo] : (string | [string, string])[] >...multiRobotAInfo : string | [string, string] @@ -662,16 +662,16 @@ for ([...multiRobotAInfo] = ["trimmer", ["trimming", "edging" >["trimmer", ["trimming", "edging"]] : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string ->i = 0 : number +>"trimming" : "trimming" +>"edging" : "edging" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.types index 700e7b9f863..443f22bbab8 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues.types @@ -16,9 +16,9 @@ let robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" function getRobot() { >getRobot : () => [number, string, string] @@ -31,19 +31,19 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, string[]] >MultiSkilledRobot : [string, string[]] >["mower", ["mowing", ""]] : [string, string[]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : string[] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, string[]] >MultiSkilledRobot : [string, string[]] >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" function getMultiRobot() { >getMultiRobot : () => [string, string[]] @@ -55,13 +55,13 @@ function getMultiRobot() { for (let [, nameA ="name"] = robotA, i = 0; i < 1; i++) { > : undefined >nameA : string ->"name" : string +>"name" : "name" >robotA : [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -75,14 +75,14 @@ for (let [, nameA ="name"] = robotA, i = 0; i < 1; i++) { for (let [, nameA = "name"] = getRobot(), i = 0; i < 1; i++) { > : undefined >nameA : string ->"name" : string +>"name" : "name" >getRobot() : [number, string, string] >getRobot : () => [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -96,16 +96,16 @@ for (let [, nameA = "name"] = getRobot(), i = 0; i < 1; i++) { for (let [, nameA = "name"] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { > : undefined >nameA : string ->"name" : string +>"name" : "name" >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -121,22 +121,22 @@ for (let [, [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"]] = multiRobotA, i = 0; i < 1; i++) { >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" >multiRobotA : [string, string[]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -152,23 +152,23 @@ for (let [, [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"]] = getMultiRobot(), i = 0; i < 1; i++) { >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" >getMultiRobot() : [string, string[]] >getMultiRobot : () => [string, string[]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -184,26 +184,26 @@ for (let [, [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -217,14 +217,14 @@ for (let [, [ for (let [numberB = -1] = robotA, i = 0; i < 1; i++) { >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotA : [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -237,15 +237,15 @@ for (let [numberB = -1] = robotA, i = 0; i < 1; i++) { } for (let [numberB = -1] = getRobot(), i = 0; i < 1; i++) { >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >getRobot() : [number, string, string] >getRobot : () => [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -258,17 +258,17 @@ for (let [numberB = -1] = getRobot(), i = 0; i < 1; i++) { } for (let [numberB = -1] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -281,13 +281,13 @@ for (let [numberB = -1] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { } for (let [nameB = "name"] = multiRobotA, i = 0; i < 1; i++) { >nameB : string ->"name" : string +>"name" : "name" >multiRobotA : [string, string[]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -300,14 +300,14 @@ for (let [nameB = "name"] = multiRobotA, i = 0; i < 1; i++) { } for (let [nameB = "name"] = getMultiRobot(), i = 0; i < 1; i++) { >nameB : string ->"name" : string +>"name" : "name" >getMultiRobot() : [string, string[]] >getMultiRobot : () => [string, string[]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -320,17 +320,17 @@ for (let [nameB = "name"] = getMultiRobot(), i = 0; i < 1; i++) { } for (let [nameB = "name"] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { >nameB : string ->"name" : string +>"name" : "name" >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -344,18 +344,18 @@ for (let [nameB = "name"] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i for (let [numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i < 1; i++) { >numberA2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameA2 : string ->"name" : string +>"name" : "name" >skillA2 : string ->"skill" : string +>"skill" : "skill" >robotA : [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -368,19 +368,19 @@ for (let [numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i } for (let [numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0; i < 1; i++) { >numberA2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameA2 : string ->"name" : string +>"name" : "name" >skillA2 : string ->"skill" : string +>"skill" : "skill" >getRobot() : [number, string, string] >getRobot : () => [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -393,21 +393,21 @@ for (let [numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0 } for (let [numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >numberA2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameA2 : string ->"name" : string +>"name" : "name" >skillA2 : string ->"skill" : string +>"skill" : "skill" >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -421,29 +421,29 @@ for (let [numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = [2, "trimmer", "t for (let [nameMA = "noName", >nameMA : string ->"noName" : string +>"noName" : "noName" [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"] >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" ] = multiRobotA, i = 0; i < 1; i++) { >multiRobotA : [string, string[]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -456,30 +456,30 @@ for (let } for (let [nameMA = "noName", >nameMA : string ->"noName" : string +>"noName" : "noName" [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"] >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" ] = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : [string, string[]] >getMultiRobot : () => [string, string[]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -492,33 +492,33 @@ for (let [nameMA = "noName", } for (let [nameMA = "noName", >nameMA : string ->"noName" : string +>"noName" : "noName" [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"] >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" ] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -532,15 +532,15 @@ for (let [nameMA = "noName", for (let [numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotAInfo : (string | number)[] >robotA : [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -553,16 +553,16 @@ for (let [numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) { } for (let [numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotAInfo : (string | number)[] >getRobot() : [number, string, string] >getRobot : () => [number, string, string] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -575,18 +575,18 @@ for (let [numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { } for (let [numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >numberA3 : string | number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotAInfo : (string | number)[] >[2, "trimmer", "trimming"] : (string | number)[] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.types index 93d149a6bde..0795142c677 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForArrayBindingPatternDefaultValues2.types @@ -16,9 +16,9 @@ let robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" function getRobot() { >getRobot : () => [number, string, string] @@ -31,19 +31,19 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" function getMultiRobot() { >getMultiRobot : () => [string, [string, string]] @@ -76,20 +76,20 @@ let i: number; >i : number for ([, nameA = "name"] = robotA, i = 0; i < 1; i++) { ->[, nameA = "name"] = robotA, i = 0 : number +>[, nameA = "name"] = robotA, i = 0 : 0 >[, nameA = "name"] = robotA : [number, string, string] >[, nameA = "name"] : [undefined, string] > : undefined ->nameA = "name" : string +>nameA = "name" : "name" >nameA : string ->"name" : string +>"name" : "name" >robotA : [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -101,21 +101,21 @@ for ([, nameA = "name"] = robotA, i = 0; i < 1; i++) { >nameA : string } for ([, nameA = "name"] = getRobot(), i = 0; i < 1; i++) { ->[, nameA = "name"] = getRobot(), i = 0 : number +>[, nameA = "name"] = getRobot(), i = 0 : 0 >[, nameA = "name"] = getRobot() : [number, string, string] >[, nameA = "name"] : [undefined, string] > : undefined ->nameA = "name" : string +>nameA = "name" : "name" >nameA : string ->"name" : string +>"name" : "name" >getRobot() : [number, string, string] >getRobot : () => [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -127,23 +127,23 @@ for ([, nameA = "name"] = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ([, nameA = "name"] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { ->[, nameA = "name"] = [2, "trimmer", "trimming"], i = 0 : number +>[, nameA = "name"] = [2, "trimmer", "trimming"], i = 0 : 0 >[, nameA = "name"] = [2, "trimmer", "trimming"] : [number, string, string] >[, nameA = "name"] : [undefined, string] > : undefined ->nameA = "name" : string +>nameA = "name" : "name" >nameA : string ->"name" : string +>"name" : "name" >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string ->i = 0 : number +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -155,7 +155,7 @@ for ([, nameA = "name"] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >nameA : string } for ([, [ ->[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = multiRobotA, i = 0 : number +>[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = multiRobotA, i = 0 : 0 >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = multiRobotA : [string, [string, string]] >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] : [undefined, [string, string]] > : undefined @@ -163,26 +163,26 @@ for ([, [ >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"]] = multiRobotA, i = 0; i < 1; i++) { >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" >multiRobotA : [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -194,7 +194,7 @@ for ([, [ >primarySkillA : string } for ([, [ ->[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = getMultiRobot(), i = 0 : number +>[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = getMultiRobot(), i = 0 : 0 >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = getMultiRobot() : [string, [string, string]] >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] : [undefined, [string, string]] > : undefined @@ -202,27 +202,27 @@ for ([, [ >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"]] = getMultiRobot(), i = 0; i < 1; i++) { >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -234,7 +234,7 @@ for ([, [ >primarySkillA : string } for ([, [ ->[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]], i = 0 : number +>[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]], i = 0 : 0 >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] >[, [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["none", "none"]] : [undefined, [string, string]] > : undefined @@ -242,30 +242,30 @@ for ([, [ >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string ->i = 0 : number +>"trimming" : "trimming" +>"edging" : "edging" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -278,20 +278,20 @@ for ([, [ } for ([numberB = -1] = robotA, i = 0; i < 1; i++) { ->[numberB = -1] = robotA, i = 0 : number +>[numberB = -1] = robotA, i = 0 : 0 >[numberB = -1] = robotA : [number, string, string] >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotA : [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -303,21 +303,21 @@ for ([numberB = -1] = robotA, i = 0; i < 1; i++) { >numberB : number } for ([numberB = -1] = getRobot(), i = 0; i < 1; i++) { ->[numberB = -1] = getRobot(), i = 0 : number +>[numberB = -1] = getRobot(), i = 0 : 0 >[numberB = -1] = getRobot() : [number, string, string] >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >getRobot() : [number, string, string] >getRobot : () => [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -329,23 +329,23 @@ for ([numberB = -1] = getRobot(), i = 0; i < 1; i++) { >numberB : number } for ([numberB = -1] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { ->[numberB = -1] = [2, "trimmer", "trimming"], i = 0 : number +>[numberB = -1] = [2, "trimmer", "trimming"], i = 0 : 0 >[numberB = -1] = [2, "trimmer", "trimming"] : [number, string, string] >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string ->i = 0 : number +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -357,19 +357,19 @@ for ([numberB = -1] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { >numberB : number } for ([nameB = "name"] = multiRobotA, i = 0; i < 1; i++) { ->[nameB = "name"] = multiRobotA, i = 0 : number +>[nameB = "name"] = multiRobotA, i = 0 : 0 >[nameB = "name"] = multiRobotA : [string, [string, string]] >[nameB = "name"] : [string] ->nameB = "name" : string +>nameB = "name" : "name" >nameB : string ->"name" : string +>"name" : "name" >multiRobotA : [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -381,20 +381,20 @@ for ([nameB = "name"] = multiRobotA, i = 0; i < 1; i++) { >nameB : string } for ([nameB = "name"] = getMultiRobot(), i = 0; i < 1; i++) { ->[nameB = "name"] = getMultiRobot(), i = 0 : number +>[nameB = "name"] = getMultiRobot(), i = 0 : 0 >[nameB = "name"] = getMultiRobot() : [string, [string, string]] >[nameB = "name"] : [string] ->nameB = "name" : string +>nameB = "name" : "name" >nameB : string ->"name" : string +>"name" : "name" >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -406,23 +406,23 @@ for ([nameB = "name"] = getMultiRobot(), i = 0; i < 1; i++) { >nameB : string } for ([nameB = "name"] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { ->[nameB = "name"] = ["trimmer", ["trimming", "edging"]], i = 0 : number +>[nameB = "name"] = ["trimmer", ["trimming", "edging"]], i = 0 : 0 >[nameB = "name"] = ["trimmer", ["trimming", "edging"]] : [string, string[]] >[nameB = "name"] : [string] ->nameB = "name" : string +>nameB = "name" : "name" >nameB : string ->"name" : string +>"name" : "name" >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string ->i = 0 : number +>"trimming" : "trimming" +>"edging" : "edging" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -435,26 +435,26 @@ for ([nameB = "name"] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) } for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i < 1; i++) { ->[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0 : number +>[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0 : 0 >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA : [number, string, string] >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] : [number, string, string] ->numberA2 = -1 : number +>numberA2 = -1 : -1 >numberA2 : number ->-1 : number ->1 : number ->nameA2 = "name" : string +>-1 : -1 +>1 : 1 +>nameA2 = "name" : "name" >nameA2 : string ->"name" : string ->skillA2 = "skill" : string +>"name" : "name" +>skillA2 = "skill" : "skill" >skillA2 : string ->"skill" : string +>"skill" : "skill" >robotA : [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -466,27 +466,27 @@ for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = robotA, i = 0; i < 1; >nameA2 : string } for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0; i < 1; i++) { ->[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0 : number +>[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0 : 0 >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot() : [number, string, string] >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] : [number, string, string] ->numberA2 = -1 : number +>numberA2 = -1 : -1 >numberA2 : number ->-1 : number ->1 : number ->nameA2 = "name" : string +>-1 : -1 +>1 : 1 +>nameA2 = "name" : "name" >nameA2 : string ->"name" : string ->skillA2 = "skill" : string +>"name" : "name" +>skillA2 = "skill" : "skill" >skillA2 : string ->"skill" : string +>"skill" : "skill" >getRobot() : [number, string, string] >getRobot : () => [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -498,29 +498,29 @@ for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = getRobot(), i = 0; i >nameA2 : string } for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { ->[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = [2, "trimmer", "trimming"], i = 0 : number +>[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = [2, "trimmer", "trimming"], i = 0 : 0 >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = [2, "trimmer", "trimming"] : [number, string, string] >[numberA2 = -1, nameA2 = "name", skillA2 = "skill"] : [number, string, string] ->numberA2 = -1 : number +>numberA2 = -1 : -1 >numberA2 : number ->-1 : number ->1 : number ->nameA2 = "name" : string +>-1 : -1 +>1 : 1 +>nameA2 = "name" : "name" >nameA2 : string ->"name" : string ->skillA2 = "skill" : string +>"name" : "name" +>skillA2 = "skill" : "skill" >skillA2 : string ->"skill" : string +>"skill" : "skill" >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string ->i = 0 : number +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -534,29 +534,29 @@ for ([numberA2 = -1, nameA2 = "name", skillA2 = "skill"] = [2, "trimmer", "trimm for (let [nameMA = "noName", >nameMA : string ->"noName" : string +>"noName" : "noName" [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"] >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" ] = multiRobotA, i = 0; i < 1; i++) { >multiRobotA : [string, [string, string]] >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -568,41 +568,41 @@ for (let >nameMA : string } for ([nameMA = "noName", ->[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = getMultiRobot(), i = 0 : number +>[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = getMultiRobot(), i = 0 : 0 >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = getMultiRobot() : [string, [string, string]] >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] : [string, [string, string]] ->nameMA = "noName" : string +>nameMA = "noName" : "noName" >nameMA : string ->"noName" : string +>"noName" : "noName" [ >[ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"] : [string, string] >[ primarySkillA = "primary", secondarySkillA = "secondary" ] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"] >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" ] = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : [string, [string, string]] >getMultiRobot : () => [string, [string, string]] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -614,44 +614,44 @@ for ([nameMA = "noName", >nameMA : string } for ([nameMA = "noName", ->[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]], i = 0 : number +>[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]], i = 0 : 0 >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"]] : [string, [string, string]] ->nameMA = "noName" : string +>nameMA = "noName" : "noName" >nameMA : string ->"noName" : string +>"noName" : "noName" [ >[ primarySkillA = "primary", secondarySkillA = "secondary" ] = ["none", "none"] : [string, string] >[ primarySkillA = "primary", secondarySkillA = "secondary" ] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["none", "none"] >["none", "none"] : [string, string] ->"none" : string ->"none" : string +>"none" : "none" +>"none" : "none" ] = ["trimmer", ["trimming", "edging"]], i = 0; i < 1; i++) { >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string ->i = 0 : number +>"trimming" : "trimming" +>"edging" : "edging" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -664,22 +664,22 @@ for ([nameMA = "noName", } for ([numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) { ->[numberA3 = -1, ...robotAInfo] = robotA, i = 0 : number +>[numberA3 = -1, ...robotAInfo] = robotA, i = 0 : 0 >[numberA3 = -1, ...robotAInfo] = robotA : [number, string, string] >[numberA3 = -1, ...robotAInfo] : (string | number)[] ->numberA3 = -1 : number +>numberA3 = -1 : -1 >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >robotA : [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -691,23 +691,23 @@ for ([numberA3 = -1, ...robotAInfo] = robotA, i = 0; i < 1; i++) { >numberA3 : number } for ([numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { ->[numberA3 = -1, ...robotAInfo] = getRobot(), i = 0 : number +>[numberA3 = -1, ...robotAInfo] = getRobot(), i = 0 : 0 >[numberA3 = -1, ...robotAInfo] = getRobot() : [number, string, string] >[numberA3 = -1, ...robotAInfo] : (string | number)[] ->numberA3 = -1 : number +>numberA3 = -1 : -1 >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >getRobot() : [number, string, string] >getRobot : () => [number, string, string] ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -719,27 +719,27 @@ for ([numberA3 = -1, ...robotAInfo] = getRobot(), i = 0; i < 1; i++) { >numberA3 : number } for ([numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0; i < 1; i++) { ->[numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0 : number +>[numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"], i = 0 : 0 >[numberA3 = -1, ...robotAInfo] = [2, "trimmer", "trimming"] : [number, string, string] >[numberA3 = -1, ...robotAInfo] : (string | number)[] ->numberA3 = -1 : number +>numberA3 = -1 : -1 >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >[2, "trimmer", "trimming"] : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string ->i = 0 : number +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.types index 21a7122e564..3a78d92033b 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern.types @@ -39,22 +39,22 @@ let robot: Robot = { name: "mower", skill: "mowing" }; >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" let multiRobot: MultiRobot = { name: "mower", skills: { primary: "mowing", secondary: "none" } }; >multiRobot : MultiRobot >MultiRobot : MultiRobot >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" function getRobot() { >getRobot : () => Robot @@ -74,10 +74,10 @@ for (let {name: nameA } = robot, i = 0; i < 1; i++) { >nameA : string >robot : Robot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -94,10 +94,10 @@ for (let {name: nameA } = getRobot(), i = 0; i < 1; i++) { >getRobot() : Robot >getRobot : () => Robot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -115,14 +115,14 @@ for (let {name: nameA } = { name: "trimmer", skill: "trimming" }, i = 0; >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -141,10 +141,10 @@ for (let { skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, >secondaryA : string >multiRobot : MultiRobot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -164,10 +164,10 @@ for (let { skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobo >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -190,20 +190,20 @@ for (let { skills: { primary: primaryA, secondary: secondaryA } } = >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -222,10 +222,10 @@ for (let {name: nameA, skill: skillA } = robot, i = 0; i < 1; i++) { >skillA : string >robot : Robot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -244,10 +244,10 @@ for (let {name: nameA, skill: skillA } = getRobot(), i = 0; i < 1; i++) { >getRobot() : Robot >getRobot : () => Robot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -267,14 +267,14 @@ for (let {name: nameA, skill: skillA } = { name: "trimmer", skill: "trimm >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -295,10 +295,10 @@ for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = >secondaryA : string >multiRobot : MultiRobot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -320,10 +320,10 @@ for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -348,20 +348,20 @@ for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern2.types index 81beb06d3d7..49ae5c61944 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPattern2.types @@ -39,22 +39,22 @@ let robot: Robot = { name: "mower", skill: "mowing" }; >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" let multiRobot: MultiRobot = { name: "mower", skills: { primary: "mowing", secondary: "none" } }; >multiRobot : MultiRobot >MultiRobot : MultiRobot >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" function getRobot() { >getRobot : () => Robot @@ -83,18 +83,18 @@ let name: string, primary: string, secondary: string, skill: string; >skill : string for ({ name: nameA } = robot, i = 0; i < 1; i++) { ->{ name: nameA } = robot, i = 0 : number +>{ name: nameA } = robot, i = 0 : 0 >{ name: nameA } = robot : Robot >{ name: nameA } : { name: string; } >name : string >nameA : string >robot : Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -106,19 +106,19 @@ for ({ name: nameA } = robot, i = 0; i < 1; i++) { >nameA : string } for ({ name: nameA } = getRobot(), i = 0; i < 1; i++) { ->{ name: nameA } = getRobot(), i = 0 : number +>{ name: nameA } = getRobot(), i = 0 : 0 >{ name: nameA } = getRobot() : Robot >{ name: nameA } : { name: string; } >name : string >nameA : string >getRobot() : Robot >getRobot : () => Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -130,7 +130,7 @@ for ({ name: nameA } = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ({ name: nameA } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { ->{ name: nameA } = { name: "trimmer", skill: "trimming" }, i = 0 : number +>{ name: nameA } = { name: "trimmer", skill: "trimming" }, i = 0 : 0 >{ name: nameA } = { name: "trimmer", skill: "trimming" } : Robot >{ name: nameA } : { name: string; } >name : string @@ -139,15 +139,15 @@ for ({ name: nameA } = { name: "trimmer", skill: "trimming" }, i = 0; i < >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string ->i = 0 : number +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -159,7 +159,7 @@ for ({ name: nameA } = { name: "trimmer", skill: "trimming" }, i = 0; i < >nameA : string } for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { ->{ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0 : number +>{ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0 : 0 >{ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot : MultiRobot >{ skills: { primary: primaryA, secondary: secondaryA } } : { skills: { primary: string; secondary: string; }; } >skills : { primary: string; secondary: string; } @@ -169,12 +169,12 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = >secondary : string >secondaryA : string >multiRobot : MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -186,7 +186,7 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = >primaryA : string } for ({ skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), i = 0; i < 1; i++) { ->{ skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), i = 0 : number +>{ skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), i = 0 : 0 >{ skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot() : MultiRobot >{ skills: { primary: primaryA, secondary: secondaryA } } : { skills: { primary: string; secondary: string; }; } >skills : { primary: string; secondary: string; } @@ -197,12 +197,12 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), >secondaryA : string >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -214,7 +214,7 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), >primaryA : string } for ({ skills: { primary: primaryA, secondary: secondaryA } } = ->{ skills: { primary: primaryA, secondary: secondaryA } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : number +>{ skills: { primary: primaryA, secondary: secondaryA } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : 0 >{ skills: { primary: primaryA, secondary: secondaryA } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >{ skills: { primary: primaryA, secondary: secondaryA } } : { skills: { primary: string; secondary: string; }; } >skills : { primary: string; secondary: string; } @@ -229,21 +229,21 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } = >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -255,17 +255,17 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } = >primaryA : string } for ({ name } = robot, i = 0; i < 1; i++) { ->{ name } = robot, i = 0 : number +>{ name } = robot, i = 0 : 0 >{ name } = robot : Robot >{ name } : { name: string; } >name : string >robot : Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -277,18 +277,18 @@ for ({ name } = robot, i = 0; i < 1; i++) { >nameA : string } for ({ name } = getRobot(), i = 0; i < 1; i++) { ->{ name } = getRobot(), i = 0 : number +>{ name } = getRobot(), i = 0 : 0 >{ name } = getRobot() : Robot >{ name } : { name: string; } >name : string >getRobot() : Robot >getRobot : () => Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -300,7 +300,7 @@ for ({ name } = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ({ name } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { ->{ name } = { name: "trimmer", skill: "trimming" }, i = 0 : number +>{ name } = { name: "trimmer", skill: "trimming" }, i = 0 : 0 >{ name } = { name: "trimmer", skill: "trimming" } : Robot >{ name } : { name: string; } >name : string @@ -308,15 +308,15 @@ for ({ name } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++ >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string ->i = 0 : number +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -328,7 +328,7 @@ for ({ name } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++ >nameA : string } for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { ->{ skills: { primary, secondary } } = multiRobot, i = 0 : number +>{ skills: { primary, secondary } } = multiRobot, i = 0 : 0 >{ skills: { primary, secondary } } = multiRobot : MultiRobot >{ skills: { primary, secondary } } : { skills: { primary: string; secondary: string; }; } >skills : { primary: string; secondary: string; } @@ -336,12 +336,12 @@ for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { >primary : string >secondary : string >multiRobot : MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -353,7 +353,7 @@ for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { >primaryA : string } for ({ skills: { primary, secondary } } = getMultiRobot(), i = 0; i < 1; i++) { ->{ skills: { primary, secondary } } = getMultiRobot(), i = 0 : number +>{ skills: { primary, secondary } } = getMultiRobot(), i = 0 : 0 >{ skills: { primary, secondary } } = getMultiRobot() : MultiRobot >{ skills: { primary, secondary } } : { skills: { primary: string; secondary: string; }; } >skills : { primary: string; secondary: string; } @@ -362,12 +362,12 @@ for ({ skills: { primary, secondary } } = getMultiRobot(), i = 0; i < 1; i++) { >secondary : string >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -379,7 +379,7 @@ for ({ skills: { primary, secondary } } = getMultiRobot(), i = 0; i < 1; i++) { >primaryA : string } for ({ skills: { primary, secondary } } = ->{ skills: { primary, secondary } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : number +>{ skills: { primary, secondary } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : 0 >{ skills: { primary, secondary } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >{ skills: { primary, secondary } } : { skills: { primary: string; secondary: string; }; } >skills : { primary: string; secondary: string; } @@ -392,21 +392,21 @@ for ({ skills: { primary, secondary } } = >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -420,7 +420,7 @@ for ({ skills: { primary, secondary } } = for ({ name: nameA, skill: skillA } = robot, i = 0; i < 1; i++) { ->{ name: nameA, skill: skillA } = robot, i = 0 : number +>{ name: nameA, skill: skillA } = robot, i = 0 : 0 >{ name: nameA, skill: skillA } = robot : Robot >{ name: nameA, skill: skillA } : { name: string; skill: string; } >name : string @@ -428,12 +428,12 @@ for ({ name: nameA, skill: skillA } = robot, i = 0; i < 1; i++) { >skill : string >skillA : string >robot : Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -445,7 +445,7 @@ for ({ name: nameA, skill: skillA } = robot, i = 0; i < 1; i++) { >nameA : string } for ({ name: nameA, skill: skillA } = getRobot(), i = 0; i < 1; i++) { ->{ name: nameA, skill: skillA } = getRobot(), i = 0 : number +>{ name: nameA, skill: skillA } = getRobot(), i = 0 : 0 >{ name: nameA, skill: skillA } = getRobot() : Robot >{ name: nameA, skill: skillA } : { name: string; skill: string; } >name : string @@ -454,12 +454,12 @@ for ({ name: nameA, skill: skillA } = getRobot(), i = 0; i < 1; i++) { >skillA : string >getRobot() : Robot >getRobot : () => Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -471,7 +471,7 @@ for ({ name: nameA, skill: skillA } = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ({ name: nameA, skill: skillA } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { ->{ name: nameA, skill: skillA } = { name: "trimmer", skill: "trimming" }, i = 0 : number +>{ name: nameA, skill: skillA } = { name: "trimmer", skill: "trimming" }, i = 0 : 0 >{ name: nameA, skill: skillA } = { name: "trimmer", skill: "trimming" } : Robot >{ name: nameA, skill: skillA } : { name: string; skill: string; } >name : string @@ -482,15 +482,15 @@ for ({ name: nameA, skill: skillA } = { name: "trimmer", skill: "trimming >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string ->i = 0 : number +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -502,7 +502,7 @@ for ({ name: nameA, skill: skillA } = { name: "trimmer", skill: "trimming >nameA : string } for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0; i < 1; i++) { ->{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0 : number +>{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = multiRobot, i = 0 : 0 >{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = multiRobot : MultiRobot >{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string @@ -514,12 +514,12 @@ for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = mul >secondary : string >secondaryA : string >multiRobot : MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -531,7 +531,7 @@ for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = mul >primaryA : string } for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), i = 0; i < 1; i++) { ->{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), i = 0 : number +>{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot(), i = 0 : 0 >{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = getMultiRobot() : MultiRobot >{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string @@ -544,12 +544,12 @@ for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = get >secondaryA : string >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -561,7 +561,7 @@ for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = get >primaryA : string } for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = ->{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : number +>{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : 0 >{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >{ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string @@ -578,21 +578,21 @@ for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -604,18 +604,18 @@ for ({ name: nameA, skills: { primary: primaryA, secondary: secondaryA } } = >primaryA : string } for ({ name, skill } = robot, i = 0; i < 1; i++) { ->{ name, skill } = robot, i = 0 : number +>{ name, skill } = robot, i = 0 : 0 >{ name, skill } = robot : Robot >{ name, skill } : { name: string; skill: string; } >name : string >skill : string >robot : Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -627,19 +627,19 @@ for ({ name, skill } = robot, i = 0; i < 1; i++) { >nameA : string } for ({ name, skill } = getRobot(), i = 0; i < 1; i++) { ->{ name, skill } = getRobot(), i = 0 : number +>{ name, skill } = getRobot(), i = 0 : 0 >{ name, skill } = getRobot() : Robot >{ name, skill } : { name: string; skill: string; } >name : string >skill : string >getRobot() : Robot >getRobot : () => Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -651,7 +651,7 @@ for ({ name, skill } = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ({ name, skill } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { ->{ name, skill } = { name: "trimmer", skill: "trimming" }, i = 0 : number +>{ name, skill } = { name: "trimmer", skill: "trimming" }, i = 0 : 0 >{ name, skill } = { name: "trimmer", skill: "trimming" } : Robot >{ name, skill } : { name: string; skill: string; } >name : string @@ -660,15 +660,15 @@ for ({ name, skill } = { name: "trimmer", skill: "trimming" }, i = 0; i < >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string ->i = 0 : number +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -680,7 +680,7 @@ for ({ name, skill } = { name: "trimmer", skill: "trimming" }, i = 0; i < >nameA : string } for ({ name, skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { ->{ name, skills: { primary, secondary } } = multiRobot, i = 0 : number +>{ name, skills: { primary, secondary } } = multiRobot, i = 0 : 0 >{ name, skills: { primary, secondary } } = multiRobot : MultiRobot >{ name, skills: { primary, secondary } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string @@ -689,12 +689,12 @@ for ({ name, skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { >primary : string >secondary : string >multiRobot : MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -706,7 +706,7 @@ for ({ name, skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { >primaryA : string } for ({ name, skills: { primary, secondary } } = getMultiRobot(), i = 0; i < 1; i++) { ->{ name, skills: { primary, secondary } } = getMultiRobot(), i = 0 : number +>{ name, skills: { primary, secondary } } = getMultiRobot(), i = 0 : 0 >{ name, skills: { primary, secondary } } = getMultiRobot() : MultiRobot >{ name, skills: { primary, secondary } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string @@ -716,12 +716,12 @@ for ({ name, skills: { primary, secondary } } = getMultiRobot(), i = 0; i < 1; i >secondary : string >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -733,7 +733,7 @@ for ({ name, skills: { primary, secondary } } = getMultiRobot(), i = 0; i < 1; i >primaryA : string } for ({ name, skills: { primary, secondary } } = ->{ name, skills: { primary, secondary } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : number +>{ name, skills: { primary, secondary } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : 0 >{ name, skills: { primary, secondary } } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >{ name, skills: { primary, secondary } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string @@ -747,21 +747,21 @@ for ({ name, skills: { primary, secondary } } = >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.types index c9e76f88581..261ccd36396 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues.types @@ -39,22 +39,22 @@ let robot: Robot = { name: "mower", skill: "mowing" }; >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" let multiRobot: MultiRobot = { name: "mower", skills: { primary: "mowing", secondary: "none" } }; >multiRobot : MultiRobot >MultiRobot : MultiRobot >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" function getRobot() { >getRobot : () => Robot @@ -72,13 +72,13 @@ function getMultiRobot() { for (let {name: nameA= "noName" } = robot, i = 0; i < 1; i++) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >robot : Robot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -92,14 +92,14 @@ for (let {name: nameA= "noName" } = robot, i = 0; i < 1; i++) { for (let {name: nameA = "noName" } = getRobot(), i = 0; i < 1; i++) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >getRobot() : Robot >getRobot : () => Robot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -113,19 +113,19 @@ for (let {name: nameA = "noName" } = getRobot(), i = 0; i < 1; i++) { for (let {name: nameA = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >{ name: "trimmer", skill: "trimming" } : Robot >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -143,27 +143,27 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = multiRobot, i = 0; i < 1; i++) { >multiRobot : MultiRobot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -181,28 +181,28 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -220,39 +220,39 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -267,16 +267,16 @@ for (let { for (let {name: nameA = "noName", skill: skillA = "skill" } = robot, i = 0; i < 1; i++) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >skill : any >skillA : string ->"skill" : string +>"skill" : "skill" >robot : Robot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -290,17 +290,17 @@ for (let {name: nameA = "noName", skill: skillA = "skill" } = robot, i = 0; i < for (let {name: nameA = "noName", skill: skillA = "skill" } = getRobot(), i = 0; i < 1; i++) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >skill : any >skillA : string ->"skill" : string +>"skill" : "skill" >getRobot() : Robot >getRobot : () => Robot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -314,22 +314,22 @@ for (let {name: nameA = "noName", skill: skillA = "skill" } = getRobot(), i = 0; for (let {name: nameA = "noName", skill: skillA = "skill" } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >skill : any >skillA : string ->"skill" : string +>"skill" : "skill" >{ name: "trimmer", skill: "trimming" } : Robot >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -344,7 +344,7 @@ for (let { name: nameA = "noName", >name : any >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : any @@ -352,27 +352,27 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = multiRobot, i = 0; i < 1; i++) { >multiRobot : MultiRobot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -387,7 +387,7 @@ for (let { name: nameA = "noName", >name : any >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : any @@ -395,28 +395,28 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -431,7 +431,7 @@ for (let { name: nameA = "noName", >name : any >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : any @@ -439,39 +439,39 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues2.types index aa8c95bae01..c5f2c806def 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForObjectBindingPatternDefaultValues2.types @@ -39,22 +39,22 @@ let robot: Robot = { name: "mower", skill: "mowing" }; >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" let multiRobot: MultiRobot = { name: "mower", skills: { primary: "mowing", secondary: "none" } }; >multiRobot : MultiRobot >MultiRobot : MultiRobot >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" function getRobot() { >getRobot : () => Robot @@ -83,20 +83,20 @@ let name: string, primary: string, secondary: string, skill: string; >skill : string for ({name: nameA = "noName" } = robot, i = 0; i < 1; i++) { ->{name: nameA = "noName" } = robot, i = 0 : number +>{name: nameA = "noName" } = robot, i = 0 : 0 >{name: nameA = "noName" } = robot : Robot >{name: nameA = "noName" } : { name?: string; } >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >robot : Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -108,21 +108,21 @@ for ({name: nameA = "noName" } = robot, i = 0; i < 1; i++) { >nameA : string } for ({name: nameA = "noName" } = getRobot(), i = 0; i < 1; i++) { ->{name: nameA = "noName" } = getRobot(), i = 0 : number +>{name: nameA = "noName" } = getRobot(), i = 0 : 0 >{name: nameA = "noName" } = getRobot() : Robot >{name: nameA = "noName" } : { name?: string; } >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >getRobot() : Robot >getRobot : () => Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -134,26 +134,26 @@ for ({name: nameA = "noName" } = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ({name: nameA = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { ->{name: nameA = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0 : number +>{name: nameA = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0 : 0 >{name: nameA = "noName" } = { name: "trimmer", skill: "trimming" } : Robot >{name: nameA = "noName" } : { name?: string; } >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >{ name: "trimmer", skill: "trimming" } : Robot >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string ->i = 0 : number +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -165,7 +165,7 @@ for ({name: nameA = "noName" } = { name: "trimmer", skill: "trimming" }, >nameA : string } for ({ ->{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot, i = 0 : number +>{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot, i = 0 : 0 >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot : MultiRobot >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} : { skills?: { primary?: string; secondary?: string; }; } @@ -176,31 +176,31 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = multiRobot, i = 0; i < 1; i++) { >multiRobot : MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -212,7 +212,7 @@ for ({ >primaryA : string } for ({ ->{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot(), i = 0 : number +>{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot(), i = 0 : 0 >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot() : MultiRobot >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} : { skills?: { primary?: string; secondary?: string; }; } @@ -223,32 +223,32 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -260,7 +260,7 @@ for ({ >primaryA : string } for ({ ->{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : number +>{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : 0 >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >{ skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} : { skills?: { primary?: string; secondary?: string; }; } @@ -271,43 +271,43 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -320,17 +320,17 @@ for ({ } for ({ name = "noName" } = robot, i = 0; i < 1; i++) { ->{ name = "noName" } = robot, i = 0 : number +>{ name = "noName" } = robot, i = 0 : 0 >{ name = "noName" } = robot : Robot >{ name = "noName" } : { name?: string; } >name : string >robot : Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -342,18 +342,18 @@ for ({ name = "noName" } = robot, i = 0; i < 1; i++) { >nameA : string } for ({ name = "noName" } = getRobot(), i = 0; i < 1; i++) { ->{ name = "noName" } = getRobot(), i = 0 : number +>{ name = "noName" } = getRobot(), i = 0 : 0 >{ name = "noName" } = getRobot() : Robot >{ name = "noName" } : { name?: string; } >name : string >getRobot() : Robot >getRobot : () => Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -365,7 +365,7 @@ for ({ name = "noName" } = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ({ name = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { ->{ name = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0 : number +>{ name = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0 : 0 >{ name = "noName" } = { name: "trimmer", skill: "trimming" } : Robot >{ name = "noName" } : { name?: string; } >name : string @@ -373,15 +373,15 @@ for ({ name = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0; >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string ->i = 0 : number +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -393,7 +393,7 @@ for ({ name = "noName" } = { name: "trimmer", skill: "trimming" }, i = 0; >nameA : string } for ({ ->{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot, i = 0 : number +>{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot, i = 0 : 0 >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot : MultiRobot >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} : { skills?: { primary?: string; secondary?: string; }; } @@ -411,18 +411,18 @@ for ({ } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = multiRobot, i = 0; i < 1; i++) { >multiRobot : MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -434,7 +434,7 @@ for ({ >primaryA : string } for ({ ->{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot(), i = 0 : number +>{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot(), i = 0 : 0 >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot() : MultiRobot >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} : { skills?: { primary?: string; secondary?: string; }; } @@ -452,19 +452,19 @@ for ({ } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -476,7 +476,7 @@ for ({ >primaryA : string } for ({ ->{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : number +>{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : 0 >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >{ skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} : { skills?: { primary?: string; secondary?: string; }; } @@ -494,30 +494,30 @@ for ({ } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -531,24 +531,24 @@ for ({ for ({name: nameA = "noName", skill: skillA = "skill" } = robot, i = 0; i < 1; i++) { ->{name: nameA = "noName", skill: skillA = "skill" } = robot, i = 0 : number +>{name: nameA = "noName", skill: skillA = "skill" } = robot, i = 0 : 0 >{name: nameA = "noName", skill: skillA = "skill" } = robot : Robot >{name: nameA = "noName", skill: skillA = "skill" } : { name?: string; skill?: string; } >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >skill : string ->skillA = "skill" : string +>skillA = "skill" : "skill" >skillA : string ->"skill" : string +>"skill" : "skill" >robot : Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -560,25 +560,25 @@ for ({name: nameA = "noName", skill: skillA = "skill" } = robot, i = 0; i < 1; i >nameA : string } for ({name: nameA = "noName", skill: skillA = "skill" } = getRobot(), i = 0; i < 1; i++) { ->{name: nameA = "noName", skill: skillA = "skill" } = getRobot(), i = 0 : number +>{name: nameA = "noName", skill: skillA = "skill" } = getRobot(), i = 0 : 0 >{name: nameA = "noName", skill: skillA = "skill" } = getRobot() : Robot >{name: nameA = "noName", skill: skillA = "skill" } : { name?: string; skill?: string; } >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >skill : string ->skillA = "skill" : string +>skillA = "skill" : "skill" >skillA : string ->"skill" : string +>"skill" : "skill" >getRobot() : Robot >getRobot : () => Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -590,30 +590,30 @@ for ({name: nameA = "noName", skill: skillA = "skill" } = getRobot(), i = 0; i < >nameA : string } for ({name: nameA = "noName", skill: skillA = "skill" } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { ->{name: nameA = "noName", skill: skillA = "skill" } = { name: "trimmer", skill: "trimming" }, i = 0 : number +>{name: nameA = "noName", skill: skillA = "skill" } = { name: "trimmer", skill: "trimming" }, i = 0 : 0 >{name: nameA = "noName", skill: skillA = "skill" } = { name: "trimmer", skill: "trimming" } : Robot >{name: nameA = "noName", skill: skillA = "skill" } : { name?: string; skill?: string; } >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >skill : string ->skillA = "skill" : string +>skillA = "skill" : "skill" >skillA : string ->"skill" : string +>"skill" : "skill" >{ name: "trimmer", skill: "trimming" } : Robot >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string ->i = 0 : number +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -625,15 +625,15 @@ for ({name: nameA = "noName", skill: skillA = "skill" } = { name: "trimme >nameA : string } for ({ ->{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot, i = 0 : number +>{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot, i = 0 : 0 >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot : MultiRobot >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name: nameA = "noName", >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : { primary?: string; secondary?: string; } @@ -642,31 +642,31 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = multiRobot, i = 0; i < 1; i++) { >multiRobot : MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -678,15 +678,15 @@ for ({ >primaryA : string } for ({ ->{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot(), i = 0 : number +>{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot(), i = 0 : 0 >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot() : MultiRobot >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name: nameA = "noName", >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : { primary?: string; secondary?: string; } @@ -695,32 +695,32 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -732,15 +732,15 @@ for ({ >primaryA : string } for ({ ->{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : number +>{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : 0 >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >{ name: nameA = "noName", skills: { primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "none", secondary: "none" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } name: nameA = "noName", >name : string ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : { primary?: string; secondary?: string; } @@ -749,43 +749,43 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -798,18 +798,18 @@ for ({ } for ({ name = "noName", skill = "skill" } = robot, i = 0; i < 1; i++) { ->{ name = "noName", skill = "skill" } = robot, i = 0 : number +>{ name = "noName", skill = "skill" } = robot, i = 0 : 0 >{ name = "noName", skill = "skill" } = robot : Robot >{ name = "noName", skill = "skill" } : { name?: string; skill?: string; } >name : string >skill : string >robot : Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -821,19 +821,19 @@ for ({ name = "noName", skill = "skill" } = robot, i = 0; i < 1; i++) { >nameA : string } for ({ name = "noName", skill = "skill" } = getRobot(), i = 0; i < 1; i++) { ->{ name = "noName", skill = "skill" } = getRobot(), i = 0 : number +>{ name = "noName", skill = "skill" } = getRobot(), i = 0 : 0 >{ name = "noName", skill = "skill" } = getRobot() : Robot >{ name = "noName", skill = "skill" } : { name?: string; skill?: string; } >name : string >skill : string >getRobot() : Robot >getRobot : () => Robot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -845,7 +845,7 @@ for ({ name = "noName", skill = "skill" } = getRobot(), i = 0; i < 1; i++) { >nameA : string } for ({ name = "noName", skill = "skill" } = { name: "trimmer", skill: "trimming" }, i = 0; i < 1; i++) { ->{ name = "noName", skill = "skill" } = { name: "trimmer", skill: "trimming" }, i = 0 : number +>{ name = "noName", skill = "skill" } = { name: "trimmer", skill: "trimming" }, i = 0 : 0 >{ name = "noName", skill = "skill" } = { name: "trimmer", skill: "trimming" } : Robot >{ name = "noName", skill = "skill" } : { name?: string; skill?: string; } >name : string @@ -854,15 +854,15 @@ for ({ name = "noName", skill = "skill" } = { name: "trimmer", skill: "tr >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string ->i = 0 : number +>"trimming" : "trimming" +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -874,7 +874,7 @@ for ({ name = "noName", skill = "skill" } = { name: "trimmer", skill: "tr >nameA : string } for ({ ->{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot, i = 0 : number +>{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot, i = 0 : 0 >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = multiRobot : MultiRobot >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } @@ -895,18 +895,18 @@ for ({ } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = multiRobot, i = 0; i < 1; i++) { >multiRobot : MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -918,7 +918,7 @@ for ({ >primaryA : string } for ({ ->{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot(), i = 0 : number +>{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot(), i = 0 : 0 >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = getMultiRobot() : MultiRobot >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } @@ -939,19 +939,19 @@ for ({ } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = getMultiRobot(), i = 0; i < 1; i++) { >getMultiRobot() : MultiRobot >getMultiRobot : () => MultiRobot ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number @@ -963,7 +963,7 @@ for ({ >primaryA : string } for ({ ->{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : number +>{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, i = 0 : 0 >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >{ name = "noName", skills: { primary = "primary", secondary = "secondary" } = { primary: "none", secondary: "none" }} : { name?: string; skills?: { primary?: string; secondary?: string; }; } @@ -984,30 +984,30 @@ for ({ } = { primary: "none", secondary: "none" } >{ primary: "none", secondary: "none" } : { primary?: string; secondary?: string; } >primary : string ->"none" : string +>"none" : "none" >secondary : string ->"none" : string +>"none" : "none" } = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }, >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : MultiRobot >MultiRobot : MultiRobot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" i = 0; i < 1; i++) { ->i = 0 : number +>i = 0 : 0 >i : number ->0 : number +>0 : 0 >i < 1 : boolean >i : number ->1 : number +>1 : 1 >i++ : number >i : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern.types index aebfe16dcde..41dc32d2648 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern.types @@ -16,17 +16,17 @@ let robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" let robotB: Robot = [2, "trimmer", "trimming"]; >robotB : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" let robots = [robotA, robotB]; >robots : [number, string, string][] @@ -45,19 +45,19 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" let multiRobots = [multiRobotA, multiRobotB]; >multiRobots : [string, [string, string]][] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.types index be84bbe3459..abc08ee63d4 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPattern2.types @@ -16,17 +16,17 @@ let robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" let robotB: Robot = [2, "trimmer", "trimming"]; >robotB : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" let robots = [robotA, robotB]; >robots : [number, string, string][] @@ -45,19 +45,19 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" let multiRobots = [multiRobotA, multiRobotB]; >multiRobots : [string, [string, string]][] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues.types index 80ba5df531f..e82c981033e 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues.types @@ -16,17 +16,17 @@ let robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" let robotB: Robot = [2, "trimmer", "trimming"]; >robotB : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" let robots = [robotA, robotB]; >robots : [number, string, string][] @@ -45,19 +45,19 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" let multiRobots = [multiRobotA, multiRobotB]; >multiRobots : [string, [string, string]][] @@ -75,7 +75,7 @@ function getMultiRobots() { for (let [, nameA = "noName"] of robots) { > : undefined >nameA : string ->"noName" : string +>"noName" : "noName" >robots : [number, string, string][] console.log(nameA); @@ -88,7 +88,7 @@ for (let [, nameA = "noName"] of robots) { for (let [, nameA = "noName"] of getRobots()) { > : undefined >nameA : string ->"noName" : string +>"noName" : "noName" >getRobots() : [number, string, string][] >getRobots : () => [number, string, string][] @@ -102,7 +102,7 @@ for (let [, nameA = "noName"] of getRobots()) { for (let [, nameA = "noName"] of [robotA, robotB]) { > : undefined >nameA : string ->"noName" : string +>"noName" : "noName" >[robotA, robotB] : [number, string, string][] >robotA : [number, string, string] >robotB : [number, string, string] @@ -119,16 +119,16 @@ for (let [, [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of multiRobots) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >multiRobots : [string, [string, string]][] console.log(primarySkillA); @@ -143,16 +143,16 @@ for (let [, [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of getMultiRobots()) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >getMultiRobots() : [string, [string, string]][] >getMultiRobots : () => [string, [string, string]][] @@ -168,16 +168,16 @@ for (let [, [ primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of [multiRobotA, multiRobotB]) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >[multiRobotA, multiRobotB] : [string, [string, string]][] >multiRobotA : [string, [string, string]] >multiRobotB : [string, [string, string]] @@ -192,8 +192,8 @@ for (let [, [ for (let [numberB = -1] of robots) { >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robots : [number, string, string][] console.log(numberB); @@ -205,8 +205,8 @@ for (let [numberB = -1] of robots) { } for (let [numberB = -1] of getRobots()) { >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >getRobots() : [number, string, string][] >getRobots : () => [number, string, string][] @@ -219,8 +219,8 @@ for (let [numberB = -1] of getRobots()) { } for (let [numberB = -1] of [robotA, robotB]) { >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >[robotA, robotB] : [number, string, string][] >robotA : [number, string, string] >robotB : [number, string, string] @@ -234,7 +234,7 @@ for (let [numberB = -1] of [robotA, robotB]) { } for (let [nameB = "noName"] of multiRobots) { >nameB : string ->"noName" : string +>"noName" : "noName" >multiRobots : [string, [string, string]][] console.log(nameB); @@ -246,7 +246,7 @@ for (let [nameB = "noName"] of multiRobots) { } for (let [nameB = "noName"] of getMultiRobots()) { >nameB : string ->"noName" : string +>"noName" : "noName" >getMultiRobots() : [string, [string, string]][] >getMultiRobots : () => [string, [string, string]][] @@ -259,7 +259,7 @@ for (let [nameB = "noName"] of getMultiRobots()) { } for (let [nameB = "noName"] of [multiRobotA, multiRobotB]) { >nameB : string ->"noName" : string +>"noName" : "noName" >[multiRobotA, multiRobotB] : [string, [string, string]][] >multiRobotA : [string, [string, string]] >multiRobotB : [string, [string, string]] @@ -274,12 +274,12 @@ for (let [nameB = "noName"] of [multiRobotA, multiRobotB]) { for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of robots) { >numberA2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameA2 : string ->"noName" : string +>"noName" : "noName" >skillA2 : string ->"skill" : string +>"skill" : "skill" >robots : [number, string, string][] console.log(nameA2); @@ -291,12 +291,12 @@ for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of robots) { } for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of getRobots()) { >numberA2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameA2 : string ->"noName" : string +>"noName" : "noName" >skillA2 : string ->"skill" : string +>"skill" : "skill" >getRobots() : [number, string, string][] >getRobots : () => [number, string, string][] @@ -309,12 +309,12 @@ for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of getRobots()) { } for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of [robotA, robotB]) { >numberA2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameA2 : string ->"noName" : string +>"noName" : "noName" >skillA2 : string ->"skill" : string +>"skill" : "skill" >[robotA, robotB] : [number, string, string][] >robotA : [number, string, string] >robotB : [number, string, string] @@ -328,20 +328,20 @@ for (let [numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of [robotA, robot } for (let [nameMA = "noName", [ >nameMA : string ->"noName" : string +>"noName" : "noName" primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of multiRobots) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >multiRobots : [string, [string, string]][] console.log(nameMA); @@ -353,20 +353,20 @@ for (let [nameMA = "noName", [ } for (let [nameMA = "noName", [ >nameMA : string ->"noName" : string +>"noName" : "noName" primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of getMultiRobots()) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >getMultiRobots() : [string, [string, string]][] >getMultiRobots : () => [string, [string, string]][] @@ -379,20 +379,20 @@ for (let [nameMA = "noName", [ } for (let [nameMA = "noName", [ >nameMA : string ->"noName" : string +>"noName" : "noName" primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of [multiRobotA, multiRobotB]) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >[multiRobotA, multiRobotB] : [string, [string, string]][] >multiRobotA : [string, [string, string]] >multiRobotB : [string, [string, string]] @@ -407,8 +407,8 @@ for (let [nameMA = "noName", [ for (let [numberA3 = -1, ...robotAInfo] of robots) { >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotAInfo : (string | number)[] >robots : [number, string, string][] @@ -421,8 +421,8 @@ for (let [numberA3 = -1, ...robotAInfo] of robots) { } for (let [numberA3 = -1, ...robotAInfo] of getRobots()) { >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotAInfo : (string | number)[] >getRobots() : [number, string, string][] >getRobots : () => [number, string, string][] @@ -436,8 +436,8 @@ for (let [numberA3 = -1, ...robotAInfo] of getRobots()) { } for (let [numberA3 = -1, ...robotAInfo] of [robotA, robotB]) { >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotAInfo : (string | number)[] >[robotA, robotB] : [number, string, string][] >robotA : [number, string, string] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.types index 257663d7fe3..dad997dac4f 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfArrayBindingPatternDefaultValues2.types @@ -16,17 +16,17 @@ let robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" let robotB: Robot = [2, "trimmer", "trimming"]; >robotB : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" let robots = [robotA, robotB]; >robots : [number, string, string][] @@ -45,19 +45,19 @@ let multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" let multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" let multiRobots = [multiRobotA, multiRobotB]; >multiRobots : [string, [string, string]][] @@ -95,9 +95,9 @@ let numberA3: number, robotAInfo: (number | string)[], multiRobotAInfo: (string for ([, nameA = "noName"] of robots) { >[, nameA = "noName"] : [undefined, string] > : undefined ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >robots : [number, string, string][] console.log(nameA); @@ -110,9 +110,9 @@ for ([, nameA = "noName"] of robots) { for ([, nameA = "noName"] of getRobots()) { >[, nameA = "noName"] : [undefined, string] > : undefined ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >getRobots() : [number, string, string][] >getRobots : () => [number, string, string][] @@ -126,9 +126,9 @@ for ([, nameA = "noName"] of getRobots()) { for ([, nameA = "noName"] of [robotA, robotB]) { >[, nameA = "noName"] : [undefined, string] > : undefined ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >[robotA, robotB] : [number, string, string][] >robotA : [number, string, string] >robotB : [number, string, string] @@ -147,19 +147,19 @@ for ([, [ >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of multiRobots) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >multiRobots : [string, [string, string]][] console.log(primarySkillA); @@ -176,19 +176,19 @@ for ([, [ >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of getMultiRobots()) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >getMultiRobots() : [string, [string, string]][] >getMultiRobots : () => [string, [string, string]][] @@ -206,19 +206,19 @@ for ([, [ >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of [multiRobotA, multiRobotB]) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >[multiRobotA, multiRobotB] : [string, [string, string]][] >multiRobotA : [string, [string, string]] >multiRobotB : [string, [string, string]] @@ -233,10 +233,10 @@ for ([, [ for ([numberB = -1] of robots) { >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robots : [number, string, string][] console.log(numberB); @@ -248,10 +248,10 @@ for ([numberB = -1] of robots) { } for ([numberB = -1] of getRobots()) { >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >getRobots() : [number, string, string][] >getRobots : () => [number, string, string][] @@ -264,10 +264,10 @@ for ([numberB = -1] of getRobots()) { } for ([numberB = -1] of [robotA, robotB]) { >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >[robotA, robotB] : [number, string, string][] >robotA : [number, string, string] >robotB : [number, string, string] @@ -281,9 +281,9 @@ for ([numberB = -1] of [robotA, robotB]) { } for ([nameB = "noName"] of multiRobots) { >[nameB = "noName"] : [string] ->nameB = "noName" : string +>nameB = "noName" : "noName" >nameB : string ->"noName" : string +>"noName" : "noName" >multiRobots : [string, [string, string]][] console.log(nameB); @@ -295,9 +295,9 @@ for ([nameB = "noName"] of multiRobots) { } for ([nameB = "noName"] of getMultiRobots()) { >[nameB = "noName"] : [string] ->nameB = "noName" : string +>nameB = "noName" : "noName" >nameB : string ->"noName" : string +>"noName" : "noName" >getMultiRobots() : [string, [string, string]][] >getMultiRobots : () => [string, [string, string]][] @@ -310,9 +310,9 @@ for ([nameB = "noName"] of getMultiRobots()) { } for ([nameB = "noName"] of [multiRobotA, multiRobotB]) { >[nameB = "noName"] : [string] ->nameB = "noName" : string +>nameB = "noName" : "noName" >nameB : string ->"noName" : string +>"noName" : "noName" >[multiRobotA, multiRobotB] : [string, [string, string]][] >multiRobotA : [string, [string, string]] >multiRobotB : [string, [string, string]] @@ -327,16 +327,16 @@ for ([nameB = "noName"] of [multiRobotA, multiRobotB]) { for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of robots) { >[numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] : [number, string, string] ->numberA2 = -1 : number +>numberA2 = -1 : -1 >numberA2 : number ->-1 : number ->1 : number ->nameA2 = "noName" : string +>-1 : -1 +>1 : 1 +>nameA2 = "noName" : "noName" >nameA2 : string ->"noName" : string ->skillA2 = "skill" : string +>"noName" : "noName" +>skillA2 = "skill" : "skill" >skillA2 : string ->"skill" : string +>"skill" : "skill" >robots : [number, string, string][] console.log(nameA2); @@ -348,16 +348,16 @@ for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of robots) { } for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of getRobots()) { >[numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] : [number, string, string] ->numberA2 = -1 : number +>numberA2 = -1 : -1 >numberA2 : number ->-1 : number ->1 : number ->nameA2 = "noName" : string +>-1 : -1 +>1 : 1 +>nameA2 = "noName" : "noName" >nameA2 : string ->"noName" : string ->skillA2 = "skill" : string +>"noName" : "noName" +>skillA2 = "skill" : "skill" >skillA2 : string ->"skill" : string +>"skill" : "skill" >getRobots() : [number, string, string][] >getRobots : () => [number, string, string][] @@ -370,16 +370,16 @@ for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of getRobots()) { } for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of [robotA, robotB]) { >[numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] : [number, string, string] ->numberA2 = -1 : number +>numberA2 = -1 : -1 >numberA2 : number ->-1 : number ->1 : number ->nameA2 = "noName" : string +>-1 : -1 +>1 : 1 +>nameA2 = "noName" : "noName" >nameA2 : string ->"noName" : string ->skillA2 = "skill" : string +>"noName" : "noName" +>skillA2 = "skill" : "skill" >skillA2 : string ->"skill" : string +>"skill" : "skill" >[robotA, robotB] : [number, string, string][] >robotA : [number, string, string] >robotB : [number, string, string] @@ -393,26 +393,26 @@ for ([numberA2 = -1, nameA2 = "noName", skillA2 = "skill"] of [robotA, robotB]) } for ([nameMA = "noName", [ >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["skill1", "skill2"]] : [string, [string, string]] ->nameMA = "noName" : string +>nameMA = "noName" : "noName" >nameMA : string ->"noName" : string +>"noName" : "noName" >[ primarySkillA = "primary", secondarySkillA = "secondary"] = ["skill1", "skill2"] : [string, string] >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of multiRobots) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >multiRobots : [string, [string, string]][] console.log(nameMA); @@ -424,26 +424,26 @@ for ([nameMA = "noName", [ } for ([nameMA = "noName", [ >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["skill1", "skill2"]] : [string, [string, string]] ->nameMA = "noName" : string +>nameMA = "noName" : "noName" >nameMA : string ->"noName" : string +>"noName" : "noName" >[ primarySkillA = "primary", secondarySkillA = "secondary"] = ["skill1", "skill2"] : [string, string] >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of getMultiRobots()) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >getMultiRobots() : [string, [string, string]][] >getMultiRobots : () => [string, [string, string]][] @@ -456,26 +456,26 @@ for ([nameMA = "noName", [ } for ([nameMA = "noName", [ >[nameMA = "noName", [ primarySkillA = "primary", secondarySkillA = "secondary"] = ["skill1", "skill2"]] : [string, [string, string]] ->nameMA = "noName" : string +>nameMA = "noName" : "noName" >nameMA : string ->"noName" : string +>"noName" : "noName" >[ primarySkillA = "primary", secondarySkillA = "secondary"] = ["skill1", "skill2"] : [string, string] >[ primarySkillA = "primary", secondarySkillA = "secondary"] : [string, string] primarySkillA = "primary", ->primarySkillA = "primary" : string +>primarySkillA = "primary" : "primary" >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" ->secondarySkillA = "secondary" : string +>secondarySkillA = "secondary" : "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["skill1", "skill2"]] of [multiRobotA, multiRobotB]) { >["skill1", "skill2"] : [string, string] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" >[multiRobotA, multiRobotB] : [string, [string, string]][] >multiRobotA : [string, [string, string]] >multiRobotB : [string, [string, string]] @@ -490,10 +490,10 @@ for ([nameMA = "noName", [ for ([numberA3 = -1, ...robotAInfo] of robots) { >[numberA3 = -1, ...robotAInfo] : (string | number)[] ->numberA3 = -1 : number +>numberA3 = -1 : -1 >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >robots : [number, string, string][] @@ -507,10 +507,10 @@ for ([numberA3 = -1, ...robotAInfo] of robots) { } for ([numberA3 = -1, ...robotAInfo] of getRobots()) { >[numberA3 = -1, ...robotAInfo] : (string | number)[] ->numberA3 = -1 : number +>numberA3 = -1 : -1 >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >getRobots() : [number, string, string][] @@ -525,10 +525,10 @@ for ([numberA3 = -1, ...robotAInfo] of getRobots()) { } for ([numberA3 = -1, ...robotAInfo] of [robotA, robotB]) { >[numberA3 = -1, ...robotAInfo] : (string | number)[] ->numberA3 = -1 : number +>numberA3 = -1 : -1 >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >[robotA, robotB] : [number, string, string][] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern.types index 17c060225dc..26d570974df 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern.types @@ -40,14 +40,14 @@ let robots: Robot[] = [{ name: "mower", skill: "mowing" }, { name: "trimmer", sk >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >multiRobots : MultiRobot[] @@ -55,24 +55,24 @@ let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", s >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]; >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" function getRobots() { >getRobots : () => Robot[] @@ -119,14 +119,14 @@ for (let {name: nameA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -175,24 +175,24 @@ for (let { skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "m >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(primaryA); >console.log(primaryA) : void @@ -239,14 +239,14 @@ for (let {name: nameA, skill: skillA } of [{ name: "mower", skill: "mowing" }, { >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -301,24 +301,24 @@ for (let {name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(nameA); >console.log(nameA) : void diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern2.types index 1f292542545..64680d66001 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPattern2.types @@ -40,14 +40,14 @@ let robots: Robot[] = [{ name: "mower", skill: "mowing" }, { name: "trimmer", sk >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >multiRobots : MultiRobot[] @@ -55,24 +55,24 @@ let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", s >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]; >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" function getRobots() { >getRobots : () => Robot[] @@ -135,14 +135,14 @@ for ({name: nameA } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", s >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -197,24 +197,24 @@ for ({ skills: { primary: primaryA, secondary: secondaryA } } of [{ name: "mower >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(primaryA); >console.log(primaryA) : void @@ -254,14 +254,14 @@ for ({name } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: " >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -310,24 +310,24 @@ for ({ skills: { primary, secondary } } of [{ name: "mower", skills: { primary: >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(primaryA); >console.log(primaryA) : void @@ -378,14 +378,14 @@ for ({name: nameA, skill: skillA } of [{ name: "mower", skill: "mowing" }, { nam >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -446,24 +446,24 @@ for ({name: nameA, skills: { primary: primaryA, secondary: secondaryA } } of [{ >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(nameA); >console.log(nameA) : void @@ -506,14 +506,14 @@ for ({name, skill } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", s >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -565,24 +565,24 @@ for ({name, skills: { primary, secondary } } of [{ name: "mower", skills: { prim >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(nameA); >console.log(nameA) : void diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues.types index 36f67f946f0..d55ab46cbd2 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues.types @@ -40,14 +40,14 @@ let robots: Robot[] = [{ name: "mower", skill: "mowing" }, { name: "trimmer", sk >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >multiRobots : MultiRobot[] @@ -55,24 +55,24 @@ let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", s >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]; >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" function getRobots() { >getRobots : () => Robot[] @@ -91,7 +91,7 @@ function getMultiRobots() { for (let {name: nameA = "noName" } of robots) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >robots : Robot[] console.log(nameA); @@ -104,7 +104,7 @@ for (let {name: nameA = "noName" } of robots) { for (let {name: nameA = "noName" } of getRobots()) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >getRobots() : Robot[] >getRobots : () => Robot[] @@ -118,18 +118,18 @@ for (let {name: nameA = "noName" } of getRobots()) { for (let {name: nameA = "noName" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -142,17 +142,17 @@ for (let { skills: { primary: primaryA = "primary", secondary: secondaryA = "sec >skills : any >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" { primary: "nosKill", secondary: "noSkill" } } of multiRobots) { >{ primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"nosKill" : string +>"nosKill" : "nosKill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" >multiRobots : MultiRobot[] console.log(primaryA); @@ -166,17 +166,17 @@ for (let { skills: { primary: primaryA = "primary", secondary: secondaryA = "sec >skills : any >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" { primary: "nosKill", secondary: "noSkill" } } of getMultiRobots()) { >{ primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"nosKill" : string +>"nosKill" : "nosKill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" >getMultiRobots() : MultiRobot[] >getMultiRobots : () => MultiRobot[] @@ -191,17 +191,17 @@ for (let { skills: { primary: primaryA = "primary", secondary: secondaryA = "sec >skills : any >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" { primary: "nosKill", secondary: "noSkill" } } of >{ primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"nosKill" : string +>"nosKill" : "nosKill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : MultiRobot[] @@ -209,24 +209,24 @@ for (let { skills: { primary: primaryA = "primary", secondary: secondaryA = "sec >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(primaryA); >console.log(primaryA) : void @@ -239,10 +239,10 @@ for (let { skills: { primary: primaryA = "primary", secondary: secondaryA = "sec for (let {name: nameA = "noName", skill: skillA = "noSkill" } of robots) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >skill : any >skillA : string ->"noSkill" : string +>"noSkill" : "noSkill" >robots : Robot[] console.log(nameA); @@ -255,10 +255,10 @@ for (let {name: nameA = "noName", skill: skillA = "noSkill" } of robots) { for (let {name: nameA = "noName", skill: skillA = "noSkill" } of getRobots()) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >skill : any >skillA : string ->"noSkill" : string +>"noSkill" : "noSkill" >getRobots() : Robot[] >getRobots : () => Robot[] @@ -272,21 +272,21 @@ for (let {name: nameA = "noName", skill: skillA = "noSkill" } of getRobots()) { for (let {name: nameA = "noName", skill: skillA = "noSkill" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >name : any >nameA : string ->"noName" : string +>"noName" : "noName" >skill : any >skillA : string ->"noSkill" : string +>"noSkill" : "noSkill" >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -299,7 +299,7 @@ for (let { name: nameA = "noName", >name : any >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : any @@ -307,19 +307,19 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of multiRobots) { >multiRobots : MultiRobot[] @@ -335,7 +335,7 @@ for (let { name: nameA = "noName", >name : any >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : any @@ -343,19 +343,19 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of getMultiRobots()) { >getMultiRobots() : MultiRobot[] @@ -372,7 +372,7 @@ for (let { name: nameA = "noName", >name : any >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : any @@ -380,19 +380,19 @@ for (let { primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : MultiRobot[] @@ -400,24 +400,24 @@ for (let { >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(nameA); >console.log(nameA) : void diff --git a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.types index adb5d515fe4..6119665124d 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringForOfObjectBindingPatternDefaultValues2.types @@ -40,14 +40,14 @@ let robots: Robot[] = [{ name: "mower", skill: "mowing" }, { name: "trimmer", sk >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >multiRobots : MultiRobot[] @@ -55,24 +55,24 @@ let multiRobots: MultiRobot[] = [{ name: "mower", skills: { primary: "mowing", s >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]; >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" function getRobots() { >getRobots : () => Robot[] @@ -104,9 +104,9 @@ let name: string, primary: string, secondary: string, skill: string; for ({name: nameA = "noName" } of robots) { >{name: nameA = "noName" } : { name?: string; } >name : Robot ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >robots : Robot[] console.log(nameA); @@ -119,9 +119,9 @@ for ({name: nameA = "noName" } of robots) { for ({name: nameA = "noName" } of getRobots()) { >{name: nameA = "noName" } : { name?: string; } >name : Robot ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >getRobots() : Robot[] >getRobots : () => Robot[] @@ -135,20 +135,20 @@ for ({name: nameA = "noName" } of getRobots()) { for ({name: nameA = "noName" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{name: nameA = "noName" } : { name?: string; } >name : { name: string; skill: string; } ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -163,20 +163,20 @@ for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "seconda >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" { primary: "nosKill", secondary: "noSkill" } } of multiRobots) { >{ primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"nosKill" : string +>"nosKill" : "nosKill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" >multiRobots : MultiRobot[] console.log(primaryA); @@ -192,20 +192,20 @@ for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "seconda >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" { primary: "nosKill", secondary: "noSkill" } } of getMultiRobots()) { >{ primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"nosKill" : string +>"nosKill" : "nosKill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" >getMultiRobots() : MultiRobot[] >getMultiRobots : () => MultiRobot[] @@ -222,20 +222,20 @@ for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "seconda >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } = { primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >{ primary: primaryA = "primary", secondary: secondaryA = "secondary" } : { primary?: string; secondary?: string; } >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" { primary: "nosKill", secondary: "noSkill" } } of >{ primary: "nosKill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"nosKill" : string +>"nosKill" : "nosKill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : MultiRobot[] @@ -243,24 +243,24 @@ for ({ skills: { primary: primaryA = "primary", secondary: secondaryA = "seconda >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(primaryA); >console.log(primaryA) : void @@ -301,14 +301,14 @@ for ({ name = "noName" } of [{ name: "mower", skill: "mowing" }, { name: "trimme >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -334,9 +334,9 @@ for ({ } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of multiRobots) { >multiRobots : MultiRobot[] @@ -365,9 +365,9 @@ for ({ } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of getMultiRobots()) { >getMultiRobots() : MultiRobot[] @@ -397,32 +397,32 @@ for ({ } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(primaryA); >console.log(primaryA) : void @@ -436,13 +436,13 @@ for ({ for ({name: nameA = "noName", skill: skillA = "noSkill" } of robots) { >{name: nameA = "noName", skill: skillA = "noSkill" } : { name?: string; skill?: string; } >name : Robot ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >skill : Robot ->skillA = "noSkill" : string +>skillA = "noSkill" : "noSkill" >skillA : string ->"noSkill" : string +>"noSkill" : "noSkill" >robots : Robot[] console.log(nameA); @@ -455,13 +455,13 @@ for ({name: nameA = "noName", skill: skillA = "noSkill" } of robots) { for ({name: nameA = "noName", skill: skillA = "noSkill" } of getRobots()) { >{name: nameA = "noName", skill: skillA = "noSkill" } : { name?: string; skill?: string; } >name : Robot ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >skill : Robot ->skillA = "noSkill" : string +>skillA = "noSkill" : "noSkill" >skillA : string ->"noSkill" : string +>"noSkill" : "noSkill" >getRobots() : Robot[] >getRobots : () => Robot[] @@ -475,24 +475,24 @@ for ({name: nameA = "noName", skill: skillA = "noSkill" } of getRobots()) { for ({name: nameA = "noName", skill: skillA = "noSkill" } of [{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }]) { >{name: nameA = "noName", skill: skillA = "noSkill" } : { name?: string; skill?: string; } >name : { name: string; skill: string; } ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" >skill : { name: string; skill: string; } ->skillA = "noSkill" : string +>skillA = "noSkill" : "noSkill" >skillA : string ->"noSkill" : string +>"noSkill" : "noSkill" >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -506,9 +506,9 @@ for ({ name: nameA = "noName", >name : MultiRobot ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : MultiRobot @@ -517,22 +517,22 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of multiRobots) { >multiRobots : MultiRobot[] @@ -549,9 +549,9 @@ for ({ name: nameA = "noName", >name : MultiRobot ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : MultiRobot @@ -560,22 +560,22 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of getMultiRobots()) { >getMultiRobots() : MultiRobot[] @@ -593,9 +593,9 @@ for ({ name: nameA = "noName", >name : MultiRobot ->nameA = "noName" : string +>nameA = "noName" : "noName" >nameA : string ->"noName" : string +>"noName" : "noName" skills: { >skills : MultiRobot @@ -604,22 +604,22 @@ for ({ primary: primaryA = "primary", >primary : string ->primaryA = "primary" : string +>primaryA = "primary" : "primary" >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : string ->secondaryA = "secondary" : string +>secondaryA = "secondary" : "secondary" >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : MultiRobot[] @@ -627,24 +627,24 @@ for ({ >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(nameA); >console.log(nameA) : void @@ -688,14 +688,14 @@ for ({ name = "noName", skill = "noSkill" } of [{ name: "mower", skill: "mowing >[{ name: "mower", skill: "mowing" }, { name: "trimmer", skill: "trimming" }] : { name: string; skill: string; }[] >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" console.log(nameA); >console.log(nameA) : void @@ -724,9 +724,9 @@ for ({ } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of multiRobots) { >multiRobots : MultiRobot[] @@ -758,9 +758,9 @@ for ({ } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of getMultiRobots()) { >getMultiRobots() : MultiRobot[] @@ -793,32 +793,32 @@ for ({ } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } of [{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, >[{ name: "mower", skills: { primary: "mowing", secondary: "none" } }, { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }] : { name: string; skills: { primary: string; secondary: string; }; }[] >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }]) { >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" console.log(nameA); >console.log(nameA) : void diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types index af27c32d15b..eef87d57c45 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPattern.types @@ -28,13 +28,13 @@ var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "no >Robot : Robot >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" function foo1({ skills: { primary: primaryA, secondary: secondaryA } }: Robot) { >foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}: Robot) => void @@ -95,13 +95,13 @@ foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" >foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skills : { primary: string; secondary: string; } >{ primary: "edging", secondary: "branch trimming" } : { primary: string; secondary: string; } >primary : string ->"edging" : string +>"edging" : "edging" >secondary : string ->"branch trimming" : string +>"branch trimming" : "branch trimming" foo2(robotA); >foo2(robotA) : void @@ -113,13 +113,13 @@ foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" >foo2 : ({name: nameC, skills: {primary: primaryB, secondary: secondaryB}}: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skills : { primary: string; secondary: string; } >{ primary: "edging", secondary: "branch trimming" } : { primary: string; secondary: string; } >primary : string ->"edging" : string +>"edging" : "edging" >secondary : string ->"branch trimming" : string +>"branch trimming" : "branch trimming" foo3(robotA); >foo3(robotA) : void @@ -131,11 +131,11 @@ foo3({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" >foo3 : ({skills}: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skills : { primary: string; secondary: string; } >{ primary: "edging", secondary: "branch trimming" } : { primary: string; secondary: string; } >primary : string ->"edging" : string +>"edging" : "edging" >secondary : string ->"branch trimming" : string +>"branch trimming" : "branch trimming" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types index 1115931feef..9f5b16407ca 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterNestedObjectBindingPatternDefaultValues.types @@ -28,13 +28,13 @@ var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "no >Robot : Robot >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" function foo1( >foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}?: Robot) => void @@ -45,19 +45,19 @@ function foo1( primary: primaryA = "primary", >primary : any >primaryA : string ->"primary" : string +>"primary" : "primary" secondary: secondaryA = "secondary" >secondary : any >secondaryA : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "SomeSkill", secondary: "someSkill" } >{ primary: "SomeSkill", secondary: "someSkill" } : { primary?: string; secondary?: string; } >primary : string ->"SomeSkill" : string +>"SomeSkill" : "SomeSkill" >secondary : string ->"someSkill" : string +>"someSkill" : "someSkill" }: Robot = robotA) { >Robot : Robot @@ -76,7 +76,7 @@ function foo2( name: nameC = "name", >name : any >nameC : string ->"name" : string +>"name" : "name" skills: { >skills : any @@ -84,19 +84,19 @@ function foo2( primary: primaryB = "primary", >primary : any >primaryB : string ->"primary" : string +>"primary" : "primary" secondary: secondaryB = "secondary" >secondary : any >secondaryB : string ->"secondary" : string +>"secondary" : "secondary" } = { primary: "SomeSkill", secondary: "someSkill" } >{ primary: "SomeSkill", secondary: "someSkill" } : { primary?: string; secondary?: string; } >primary : string ->"SomeSkill" : string +>"SomeSkill" : "SomeSkill" >secondary : string ->"someSkill" : string +>"someSkill" : "someSkill" }: Robot = robotA) { >Robot : Robot @@ -114,9 +114,9 @@ function foo3({ skills = { primary: "SomeSkill", secondary: "someSkill" } }: Ro >skills : { primary?: string; secondary?: string; } >{ primary: "SomeSkill", secondary: "someSkill" } : { primary: string; secondary: string; } >primary : string ->"SomeSkill" : string +>"SomeSkill" : "SomeSkill" >secondary : string ->"someSkill" : string +>"someSkill" : "someSkill" >Robot : Robot >robotA : Robot @@ -140,13 +140,13 @@ foo1({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" >foo1 : ({skills: {primary: primaryA, secondary: secondaryA}}?: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skills : { primary: string; secondary: string; } >{ primary: "edging", secondary: "branch trimming" } : { primary: string; secondary: string; } >primary : string ->"edging" : string +>"edging" : "edging" >secondary : string ->"branch trimming" : string +>"branch trimming" : "branch trimming" foo2(robotA); >foo2(robotA) : void @@ -158,13 +158,13 @@ foo2({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" >foo2 : ({name: nameC, skills: {primary: primaryB, secondary: secondaryB}}?: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skills : { primary: string; secondary: string; } >{ primary: "edging", secondary: "branch trimming" } : { primary: string; secondary: string; } >primary : string ->"edging" : string +>"edging" : "edging" >secondary : string ->"branch trimming" : string +>"branch trimming" : "branch trimming" foo3(robotA); >foo3(robotA) : void @@ -176,11 +176,11 @@ foo3({ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" >foo3 : ({skills}?: Robot) => void >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skills : { primary: string; secondary: string; } >{ primary: "edging", secondary: "branch trimming" } : { primary: string; secondary: string; } >primary : string ->"edging" : string +>"edging" : "edging" >secondary : string ->"branch trimming" : string +>"branch trimming" : "branch trimming" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types index 6b8f26acf43..225071a3d2e 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPattern.types @@ -17,16 +17,16 @@ declare var console: { } var hello = "hello"; >hello : string ->"hello" : string +>"hello" : "hello" var robotA: Robot = { name: "mower", skill: "mowing" }; >robotA : Robot >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" function foo1({ name: nameA }: Robot) { >foo1 : ({name: nameA}: Robot) => void @@ -79,9 +79,9 @@ foo1({ name: "Edger", skill: "cutting edges" }); >foo1 : ({name: nameA}: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" foo2(robotA); >foo2(robotA) : void @@ -93,9 +93,9 @@ foo2({ name: "Edger", skill: "cutting edges" }); >foo2 : ({name: nameB, skill: skillB}: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" foo3(robotA); >foo3(robotA) : void @@ -107,7 +107,7 @@ foo3({ name: "Edger", skill: "cutting edges" }); >foo3 : ({name}: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types index 253c5feae8f..db6a8bcab29 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParameterObjectBindingPatternDefaultValues.types @@ -17,22 +17,22 @@ declare var console: { } var hello = "hello"; >hello : string ->"hello" : string +>"hello" : "hello" var robotA: Robot = { name: "mower", skill: "mowing" }; >robotA : Robot >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" function foo1({ name: nameA = "" }: Robot = { }) { >foo1 : ({name: nameA}?: Robot) => void >name : any >nameA : string ->"" : string +>"" : "" >Robot : Robot >{ } : {} @@ -47,10 +47,10 @@ function foo2({ name: nameB = "", skill: skillB = "noSkill" }: Robot = { >foo2 : ({name: nameB, skill: skillB}?: Robot) => void >name : any >nameB : string ->"" : string +>"" : "" >skill : any >skillB : string ->"noSkill" : string +>"noSkill" : "noSkill" >Robot : Robot >{} : {} @@ -64,7 +64,7 @@ function foo2({ name: nameB = "", skill: skillB = "noSkill" }: Robot = { function foo3({ name = "" }: Robot = {}) { >foo3 : ({name}?: Robot) => void >name : string ->"" : string +>"" : "" >Robot : Robot >{} : {} @@ -86,9 +86,9 @@ foo1({ name: "Edger", skill: "cutting edges" }); >foo1 : ({name: nameA}?: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" foo2(robotA); >foo2(robotA) : void @@ -100,9 +100,9 @@ foo2({ name: "Edger", skill: "cutting edges" }); >foo2 : ({name: nameB, skill: skillB}?: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" foo3(robotA); >foo3(robotA) : void @@ -114,7 +114,7 @@ foo3({ name: "Edger", skill: "cutting edges" }); >foo3 : ({name}?: Robot) => void >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types index aab0b3cf5c7..d7aed64a232 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern.types @@ -13,9 +13,9 @@ var robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" function foo1([, nameA]: Robot) { >foo1 : ([, nameA]: [number, string, string]) => void @@ -82,9 +82,9 @@ foo1([2, "trimmer", "trimming"]); >foo1([2, "trimmer", "trimming"]) : void >foo1 : ([, nameA]: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" foo2(robotA); >foo2(robotA) : void @@ -95,9 +95,9 @@ foo2([2, "trimmer", "trimming"]); >foo2([2, "trimmer", "trimming"]) : void >foo2 : ([numberB]: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" foo3(robotA); >foo3(robotA) : void @@ -108,9 +108,9 @@ foo3([2, "trimmer", "trimming"]); >foo3([2, "trimmer", "trimming"]) : void >foo3 : ([numberA2, nameA2, skillA2]: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" foo4(robotA); >foo4(robotA) : void @@ -121,7 +121,7 @@ foo4([2, "trimmer", "trimming"]); >foo4([2, "trimmer", "trimming"]) : void >foo4 : ([numberA3, ...robotAInfo]: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types index b3e09d962c3..00809184d3b 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPattern2.types @@ -13,10 +13,10 @@ var robotA: Robot = ["trimmer", ["trimming", "edging"]]; >robotA : [string, [string, string]] >Robot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" function foo1([, skillA]: Robot) { >foo1 : ([, skillA]: [string, [string, string]]) => void @@ -82,10 +82,10 @@ foo1(["roomba", ["vaccum", "mopping"]]); >foo1(["roomba", ["vaccum", "mopping"]]) : void >foo1 : ([, skillA]: [string, [string, string]]) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" foo2(robotA); >foo2(robotA) : void @@ -96,10 +96,10 @@ foo2(["roomba", ["vaccum", "mopping"]]); >foo2(["roomba", ["vaccum", "mopping"]]) : void >foo2 : ([nameMB]: [string, [string, string]]) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" foo3(robotA); >foo3(robotA) : void @@ -110,10 +110,10 @@ foo3(["roomba", ["vaccum", "mopping"]]); >foo3(["roomba", ["vaccum", "mopping"]]) : void >foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, [string, string]]) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" foo4(robotA); >foo4(robotA) : void @@ -124,8 +124,8 @@ foo4(["roomba", ["vaccum", "mopping"]]); >foo4(["roomba", ["vaccum", "mopping"]]) : void >foo4 : ([...multiRobotAInfo]: [string, [string, string]]) => void >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types index 43420fdd587..a9d1013c136 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues.types @@ -13,21 +13,21 @@ var robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" function foo1([, nameA = "noName"]: Robot = [-1, "name", "skill"]) { >foo1 : ([, nameA]?: [number, string, string]) => void > : undefined >nameA : string ->"noName" : string +>"noName" : "noName" >Robot : [number, string, string] >[-1, "name", "skill"] : [number, string, string] ->-1 : number ->1 : number ->"name" : string ->"skill" : string +>-1 : -1 +>1 : 1 +>"name" : "name" +>"skill" : "skill" console.log(nameA); >console.log(nameA) : void @@ -40,14 +40,14 @@ function foo1([, nameA = "noName"]: Robot = [-1, "name", "skill"]) { function foo2([numberB = -1]: Robot = [-1, "name", "skill"]) { >foo2 : ([numberB]?: [number, string, string]) => void >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >Robot : [number, string, string] >[-1, "name", "skill"] : [number, string, string] ->-1 : number ->1 : number ->"name" : string ->"skill" : string +>-1 : -1 +>1 : 1 +>"name" : "name" +>"skill" : "skill" console.log(numberB); >console.log(numberB) : void @@ -60,18 +60,18 @@ function foo2([numberB = -1]: Robot = [-1, "name", "skill"]) { function foo3([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]: Robot = [-1, "name", "skill"]) { >foo3 : ([numberA2, nameA2, skillA2]?: [number, string, string]) => void >numberA2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameA2 : string ->"name" : string +>"name" : "name" >skillA2 : string ->"skill" : string +>"skill" : "skill" >Robot : [number, string, string] >[-1, "name", "skill"] : [number, string, string] ->-1 : number ->1 : number ->"name" : string ->"skill" : string +>-1 : -1 +>1 : 1 +>"name" : "name" +>"skill" : "skill" console.log(nameA2); >console.log(nameA2) : void @@ -84,15 +84,15 @@ function foo3([numberA2 = -1, nameA2 = "name", skillA2 = "skill"]: Robot = [-1, function foo4([numberA3 = -1, ...robotAInfo]: Robot = [-1, "name", "skill"]) { >foo4 : ([numberA3, ...robotAInfo]?: [number, string, string]) => void >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotAInfo : (string | number)[] >Robot : [number, string, string] >[-1, "name", "skill"] : [number, string, string] ->-1 : number ->1 : number ->"name" : string ->"skill" : string +>-1 : -1 +>1 : 1 +>"name" : "name" +>"skill" : "skill" console.log(robotAInfo); >console.log(robotAInfo) : void @@ -111,9 +111,9 @@ foo1([2, "trimmer", "trimming"]); >foo1([2, "trimmer", "trimming"]) : void >foo1 : ([, nameA]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" foo2(robotA); >foo2(robotA) : void @@ -124,9 +124,9 @@ foo2([2, "trimmer", "trimming"]); >foo2([2, "trimmer", "trimming"]) : void >foo2 : ([numberB]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" foo3(robotA); >foo3(robotA) : void @@ -137,9 +137,9 @@ foo3([2, "trimmer", "trimming"]); >foo3([2, "trimmer", "trimming"]) : void >foo3 : ([numberA2, nameA2, skillA2]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" foo4(robotA); >foo4(robotA) : void @@ -150,7 +150,7 @@ foo4([2, "trimmer", "trimming"]); >foo4([2, "trimmer", "trimming"]) : void >foo4 : ([numberA3, ...robotAInfo]?: [number, string, string]) => void >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types index bd140d6a232..b3569bb58b7 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringParametertArrayBindingPatternDefaultValues2.types @@ -13,24 +13,24 @@ var robotA: Robot = ["trimmer", ["trimming", "edging"]]; >robotA : [string, string[]] >Robot : [string, string[]] >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "skill2"]]) { >foo1 : ([, skillA]?: [string, string[]]) => void > : undefined >skillA : string[] >["noSkill", "noSkill"] : string[] ->"noSkill" : string ->"noSkill" : string +>"noSkill" : "noSkill" +>"noSkill" : "noSkill" >Robot : [string, string[]] >["name", ["skill1", "skill2"]] : [string, string[]] ->"name" : string +>"name" : "name" >["skill1", "skill2"] : string[] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" console.log(skillA); >console.log(skillA) : void @@ -43,13 +43,13 @@ function foo1([, skillA = ["noSkill", "noSkill"]]: Robot= ["name", ["skill1", "s function foo2([nameMB = "noName"]: Robot = ["name", ["skill1", "skill2"]]) { >foo2 : ([nameMB]?: [string, string[]]) => void >nameMB : string ->"noName" : string +>"noName" : "noName" >Robot : [string, string[]] >["name", ["skill1", "skill2"]] : [string, string[]] ->"name" : string +>"name" : "name" >["skill1", "skill2"] : string[] ->"skill1" : string ->"skill2" : string +>"skill1" : "skill1" +>"skill2" : "skill2" console.log(nameMB); >console.log(nameMB) : void @@ -62,20 +62,20 @@ function foo2([nameMB = "noName"]: Robot = ["name", ["skill1", "skill2"]]) { function foo3([nameMA = "noName", [ >foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, string[]]) => void >nameMA : string ->"noName" : string +>"noName" : "noName" primarySkillA = "primary", >primarySkillA : string ->"primary" : string +>"primary" : "primary" secondarySkillA = "secondary" >secondarySkillA : string ->"secondary" : string +>"secondary" : "secondary" ] = ["noSkill", "noSkill"]]: Robot) { >["noSkill", "noSkill"] : [string, string] ->"noSkill" : string ->"noSkill" : string +>"noSkill" : "noSkill" +>"noSkill" : "noSkill" >Robot : [string, string[]] console.log(nameMA); @@ -95,10 +95,10 @@ foo1(["roomba", ["vaccum", "mopping"]]); >foo1(["roomba", ["vaccum", "mopping"]]) : void >foo1 : ([, skillA]?: [string, string[]]) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : string[] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" foo2(robotA); >foo2(robotA) : void @@ -109,10 +109,10 @@ foo2(["roomba", ["vaccum", "mopping"]]); >foo2(["roomba", ["vaccum", "mopping"]]) : void >foo2 : ([nameMB]?: [string, string[]]) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : string[] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" foo3(robotA); >foo3(robotA) : void @@ -123,8 +123,8 @@ foo3(["roomba", ["vaccum", "mopping"]]); >foo3(["roomba", ["vaccum", "mopping"]]) : void >foo3 : ([nameMA, [primarySkillA, secondarySkillA]]: [string, string[]]) => void >["roomba", ["vaccum", "mopping"]] : [string, string[]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : string[] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.types index 82a2ffe88f6..5d61294b568 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement.types @@ -17,25 +17,25 @@ declare var console: { } var hello = "hello"; >hello : string ->"hello" : string +>"hello" : "hello" var robotA: Robot = { name: "mower", skill: "mowing" }; >robotA : Robot >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" var robotB: Robot = { name: "trimmer", skill: "trimming" }; >robotB : Robot >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" var { name: nameA } = robotA; >name : any @@ -56,9 +56,9 @@ var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" }; >skillC : string >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" if (nameA == nameB) { >nameA == nameB : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.types index 9d8023f5f74..9ed1df0f533 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatement1.types @@ -17,25 +17,25 @@ declare var console: { } var hello = "hello"; >hello : string ->"hello" : string +>"hello" : "hello" var robotA: Robot = { name: "mower", skill: "mowing" }; >robotA : Robot >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" var robotB: Robot = { name: "trimmer", skill: "trimming" }; >robotB : Robot >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" var a: string, { name: nameA } = robotA; >a : string @@ -59,9 +59,9 @@ var c: string, { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting >skillC : string >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" var { name: nameA } = robotA, a = hello; >name : any @@ -77,7 +77,7 @@ var { name: nameB, skill: skillB } = robotB, b = " hello"; >skillB : string >robotB : Robot >b : string ->" hello" : string +>" hello" : " hello" var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" }, c = hello; >name : any @@ -86,9 +86,9 @@ var { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" }, >skillC : string >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" >c : string >hello : string @@ -99,7 +99,7 @@ var a = hello, { name: nameA } = robotA, a1= "hello"; >nameA : string >robotA : Robot >a1 : string ->"hello" : string +>"hello" : "hello" var b = hello, { name: nameB, skill: skillB } = robotB, b1 = "hello"; >b : string @@ -110,7 +110,7 @@ var b = hello, { name: nameB, skill: skillB } = robotB, b1 = "hello"; >skillB : string >robotB : Robot >b1 : string ->"hello" : string +>"hello" : "hello" var c = hello, { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting edges" }, c1 = hello; >c : string @@ -121,9 +121,9 @@ var c = hello, { name: nameC, skill: skillC } = { name: "Edger", skill: "cutting >skillC : string >{ name: "Edger", skill: "cutting edges" } : { name: string; skill: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" >c1 : string >hello : string diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.types index db6e57258d7..46bdfec4b06 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern.types @@ -13,17 +13,17 @@ var robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" var robotB: Robot = [2, "trimmer", "trimming"]; >robotB : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" let [, nameA] = robotA; @@ -44,18 +44,18 @@ let [numberA2, nameA2, skillA2] = robotA; let [numberC2] = [3, "edging", "Trimming edges"]; >numberC2 : number >[3, "edging", "Trimming edges"] : [number, string, string] ->3 : number ->"edging" : string ->"Trimming edges" : string +>3 : 3 +>"edging" : "edging" +>"Trimming edges" : "Trimming edges" let [numberC, nameC, skillC] = [3, "edging", "Trimming edges"]; >numberC : number >nameC : string >skillC : string >[3, "edging", "Trimming edges"] : [number, string, string] ->3 : number ->"edging" : string ->"Trimming edges" : string +>3 : 3 +>"edging" : "edging" +>"Trimming edges" : "Trimming edges" let [numberA3, ...robotAInfo] = robotA; >numberA3 : number diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.types index 57d4b271c2f..99f280985b5 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern2.types @@ -13,19 +13,19 @@ var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" let [, skillA] = multiRobotA; > : undefined @@ -45,20 +45,20 @@ let [nameMA, [primarySkillA, secondarySkillA]] = multiRobotA; let [nameMC] = ["roomba", ["vaccum", "mopping"]]; >nameMC : string >["roomba", ["vaccum", "mopping"]] : [string, string[]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : string[] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" let [nameMC2, [primarySkillC, secondarySkillC]] = ["roomba", ["vaccum", "mopping"]]; >nameMC2 : string >primarySkillC : string >secondarySkillC : string >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" let [...multiRobotAInfo] = multiRobotA; >multiRobotAInfo : (string | [string, string])[] @@ -77,8 +77,8 @@ if (nameMB == nameMA) { >skillA[0] + skillA[1] : string >skillA[0] : string >skillA : [string, string] ->0 : number +>0 : 0 >skillA[1] : string >skillA : [string, string] ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.types index 14a8c18c051..bdd2059b863 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern3.types @@ -16,35 +16,35 @@ var robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" var robotB: Robot = [2, "trimmer", "trimming"]; >robotB : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["mower", ["mowing", ""]] : [string, [string, string]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : [string, string] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, [string, string]] >MultiSkilledRobot : [string, [string, string]] >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" let nameA: string, numberB: number, nameB: string, skillB: string; >nameA : string @@ -85,9 +85,9 @@ let multiRobotAInfo: (string | [string, string])[]; > : undefined >nameB : string >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" [, multiSkillB] = multiRobotB; >[, multiSkillB] = multiRobotB : [string, [string, string]] @@ -110,10 +110,10 @@ let multiRobotAInfo: (string | [string, string])[]; > : undefined >multiSkillB : [string, string] >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" [numberB] = robotB; >[numberB] = robotB : [number, string, string] @@ -133,9 +133,9 @@ let multiRobotAInfo: (string | [string, string])[]; >[numberB] : [number] >numberB : number >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" [nameMB] = multiRobotB; >[nameMB] = multiRobotB : [string, [string, string]] @@ -155,10 +155,10 @@ let multiRobotAInfo: (string | [string, string])[]; >[nameMB] : [string] >nameMB : string >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" [numberB, nameB, skillB] = robotB; >[numberB, nameB, skillB] = robotB : [number, string, string] @@ -184,9 +184,9 @@ let multiRobotAInfo: (string | [string, string])[]; >nameB : string >skillB : string >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" [nameMB, [primarySkillB, secondarySkillB]] = multiRobotB; >[nameMB, [primarySkillB, secondarySkillB]] = multiRobotB : [string, [string, string]] @@ -215,10 +215,10 @@ let multiRobotAInfo: (string | [string, string])[]; >primarySkillB : string >secondarySkillB : string >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" [numberB, ...robotAInfo] = robotB; >[numberB, ...robotAInfo] = robotB : [number, string, string] @@ -246,9 +246,9 @@ let multiRobotAInfo: (string | [string, string])[]; >[2, "trimmer", "trimming"] : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" [...multiRobotAInfo] = multiRobotA; >[...multiRobotAInfo] = multiRobotA : [string, [string, string]] @@ -271,10 +271,10 @@ let multiRobotAInfo: (string | [string, string])[]; >...multiRobotAInfo : string | [string, string] >multiRobotAInfo : (string | [string, string])[] >["trimmer", ["trimming", "edging"]] : (string | [string, string])[] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" if (nameA == nameB) { >nameA == nameB : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.types index 461939a11aa..4f61c672b81 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern4.types @@ -3,6 +3,6 @@ var [x] = [1, 2]; >x : number >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.types index 1ef747517e4..908e566ca71 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern5.types @@ -3,13 +3,13 @@ var [x] = [1, 2]; >x : number >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var [y, z] = [1, 2]; >y : number >z : number >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.types index 1b94874ae7c..166a6192bb7 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern6.types @@ -2,8 +2,8 @@ var [x = 20] = [1, 2]; >x : number ->20 : number +>20 : 20 >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.types index 9b369e410a4..da537c6e109 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPattern7.types @@ -2,9 +2,9 @@ var [x = 20, j] = [1, 2]; >x : number ->20 : number +>20 : 20 >j : number >[1, 2] : [number, number] ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.types index be5b47f2eaa..fae55a6cabf 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues.types @@ -13,66 +13,66 @@ var robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" var robotB: Robot = [2, "trimmer", "trimming"]; >robotB : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" let [, nameA = "noName"] = robotA; > : undefined >nameA : string ->"noName" : string +>"noName" : "noName" >robotA : [number, string, string] let [numberB = -1] = robotB; >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotB : [number, string, string] let [numberA2 = -1, nameA2 = "noName", skillA2 = "noSkill"] = robotA; >numberA2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameA2 : string ->"noName" : string +>"noName" : "noName" >skillA2 : string ->"noSkill" : string +>"noSkill" : "noSkill" >robotA : [number, string, string] let [numberC2 = -1] = [3, "edging", "Trimming edges"]; >numberC2 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >[3, "edging", "Trimming edges"] : [number, string, string] ->3 : number ->"edging" : string ->"Trimming edges" : string +>3 : 3 +>"edging" : "edging" +>"Trimming edges" : "Trimming edges" let [numberC = -1, nameC = "noName", skillC = "noSkill"] = [3, "edging", "Trimming edges"]; >numberC : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >nameC : string ->"noName" : string +>"noName" : "noName" >skillC : string ->"noSkill" : string +>"noSkill" : "noSkill" >[3, "edging", "Trimming edges"] : [number, string, string] ->3 : number ->"edging" : string ->"Trimming edges" : string +>3 : 3 +>"edging" : "edging" +>"Trimming edges" : "Trimming edges" let [numberA3 = -1, ...robotAInfo] = robotA; >numberA3 : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotAInfo : (string | number)[] >robotA : [number, string, string] diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.types index 12215507d4a..21d75479c6d 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues2.types @@ -13,69 +13,69 @@ var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, string[]] >MultiSkilledRobot : [string, string[]] >["mower", ["mowing", ""]] : [string, string[]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : string[] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, string[]] >MultiSkilledRobot : [string, string[]] >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" let [, skillA = ["noSkill", "noSkill"]] = multiRobotA; > : undefined >skillA : string[] >["noSkill", "noSkill"] : string[] ->"noSkill" : string ->"noSkill" : string +>"noSkill" : "noSkill" +>"noSkill" : "noSkill" >multiRobotA : [string, string[]] let [nameMB = "noName" ] = multiRobotB; >nameMB : string ->"noName" : string +>"noName" : "noName" >multiRobotB : [string, string[]] let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"]] = multiRobotA; >nameMA : string ->"noName" : string +>"noName" : "noName" >primarySkillA : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondarySkillA : string ->"noSkill" : string +>"noSkill" : "noSkill" >["noSkill", "noSkill"] : [string, string] ->"noSkill" : string ->"noSkill" : string +>"noSkill" : "noSkill" +>"noSkill" : "noSkill" >multiRobotA : [string, string[]] let [nameMC = "noName" ] = ["roomba", ["vaccum", "mopping"]]; >nameMC : string ->"noName" : string +>"noName" : "noName" >["roomba", ["vaccum", "mopping"]] : [string, string[]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : string[] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" let [nameMC2 = "noName", [primarySkillC = "noSkill", secondarySkillC = "noSkill"] = ["noSkill", "noSkill"]] = ["roomba", ["vaccum", "mopping"]]; >nameMC2 : string ->"noName" : string +>"noName" : "noName" >primarySkillC : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondarySkillC : string ->"noSkill" : string +>"noSkill" : "noSkill" >["noSkill", "noSkill"] : [string, string] ->"noSkill" : string ->"noSkill" : string +>"noSkill" : "noSkill" +>"noSkill" : "noSkill" >["roomba", ["vaccum", "mopping"]] : [string, [string, string]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : [string, string] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" if (nameMB == nameMA) { >nameMB == nameMA : boolean @@ -90,8 +90,8 @@ if (nameMB == nameMA) { >skillA[0] + skillA[1] : string >skillA[0] : string >skillA : string[] ->0 : number +>0 : 0 >skillA[1] : string >skillA : string[] ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.types index 0b1454bdf3b..35c458f4310 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementArrayBindingPatternDefaultValues3.types @@ -16,35 +16,35 @@ var robotA: Robot = [1, "mower", "mowing"]; >robotA : [number, string, string] >Robot : [number, string, string] >[1, "mower", "mowing"] : [number, string, string] ->1 : number ->"mower" : string ->"mowing" : string +>1 : 1 +>"mower" : "mower" +>"mowing" : "mowing" var robotB: Robot = [2, "trimmer", "trimming"]; >robotB : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" var multiRobotA: MultiSkilledRobot = ["mower", ["mowing", ""]]; >multiRobotA : [string, string[]] >MultiSkilledRobot : [string, string[]] >["mower", ["mowing", ""]] : [string, string[]] ->"mower" : string +>"mower" : "mower" >["mowing", ""] : string[] ->"mowing" : string ->"" : string +>"mowing" : "mowing" +>"" : "" var multiRobotB: MultiSkilledRobot = ["trimmer", ["trimming", "edging"]]; >multiRobotB : [string, string[]] >MultiSkilledRobot : [string, string[]] >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" let nameA: string, numberB: number, nameB: string, skillB: string; >nameA : string @@ -68,18 +68,18 @@ let multiRobotAInfo: (string | string[])[]; >[, nameA = "helloNoName"] = robotA : [number, string, string] >[, nameA = "helloNoName"] : [undefined, string] > : undefined ->nameA = "helloNoName" : string +>nameA = "helloNoName" : "helloNoName" >nameA : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >robotA : [number, string, string] [, nameB = "helloNoName"] = getRobotB(); >[, nameB = "helloNoName"] = getRobotB() : [number, string, string] >[, nameB = "helloNoName"] : [undefined, string] > : undefined ->nameB = "helloNoName" : string +>nameB = "helloNoName" : "helloNoName" >nameB : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >getRobotB() : [number, string, string] >getRobotB : () => [number, string, string] @@ -87,13 +87,13 @@ let multiRobotAInfo: (string | string[])[]; >[, nameB = "helloNoName"] = [2, "trimmer", "trimming"] : [number, string, string] >[, nameB = "helloNoName"] : [undefined, string] > : undefined ->nameB = "helloNoName" : string +>nameB = "helloNoName" : "helloNoName" >nameB : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" [, multiSkillB = []] = multiRobotB; >[, multiSkillB = []] = multiRobotB : [string, string[]] @@ -122,151 +122,151 @@ let multiRobotAInfo: (string | string[])[]; >multiSkillB : string[] >[] : undefined[] >["roomba", ["vaccum", "mopping"]] : [string, string[]] ->"roomba" : string +>"roomba" : "roomba" >["vaccum", "mopping"] : string[] ->"vaccum" : string ->"mopping" : string +>"vaccum" : "vaccum" +>"mopping" : "mopping" [numberB = -1] = robotB; >[numberB = -1] = robotB : [number, string, string] >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >robotB : [number, string, string] [numberB = -1] = getRobotB(); >[numberB = -1] = getRobotB() : [number, string, string] >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >getRobotB() : [number, string, string] >getRobotB : () => [number, string, string] [numberB = -1] = [2, "trimmer", "trimming"]; >[numberB = -1] = [2, "trimmer", "trimming"] : [number, string, string] >[numberB = -1] : [number] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" [nameMB = "helloNoName"] = multiRobotB; >[nameMB = "helloNoName"] = multiRobotB : [string, string[]] >[nameMB = "helloNoName"] : [string] ->nameMB = "helloNoName" : string +>nameMB = "helloNoName" : "helloNoName" >nameMB : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >multiRobotB : [string, string[]] [nameMB = "helloNoName"] = getMultiRobotB(); >[nameMB = "helloNoName"] = getMultiRobotB() : [string, string[]] >[nameMB = "helloNoName"] : [string] ->nameMB = "helloNoName" : string +>nameMB = "helloNoName" : "helloNoName" >nameMB : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >getMultiRobotB() : [string, string[]] >getMultiRobotB : () => [string, string[]] [nameMB = "helloNoName"] = ["trimmer", ["trimming", "edging"]]; >[nameMB = "helloNoName"] = ["trimmer", ["trimming", "edging"]] : [string, string[]] >[nameMB = "helloNoName"] : [string] ->nameMB = "helloNoName" : string +>nameMB = "helloNoName" : "helloNoName" >nameMB : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >["trimmer", ["trimming", "edging"]] : [string, string[]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : string[] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" [numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = robotB; >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = robotB : [number, string, string] >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] : [number, string, string] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number ->nameB = "helloNoName" : string +>-1 : -1 +>1 : 1 +>nameB = "helloNoName" : "helloNoName" >nameB : string ->"helloNoName" : string ->skillB = "noSkill" : string +>"helloNoName" : "helloNoName" +>skillB = "noSkill" : "noSkill" >skillB : string ->"noSkill" : string +>"noSkill" : "noSkill" >robotB : [number, string, string] [numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = getRobotB(); >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = getRobotB() : [number, string, string] >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] : [number, string, string] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number ->nameB = "helloNoName" : string +>-1 : -1 +>1 : 1 +>nameB = "helloNoName" : "helloNoName" >nameB : string ->"helloNoName" : string ->skillB = "noSkill" : string +>"helloNoName" : "helloNoName" +>skillB = "noSkill" : "noSkill" >skillB : string ->"noSkill" : string +>"noSkill" : "noSkill" >getRobotB() : [number, string, string] >getRobotB : () => [number, string, string] [numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = [2, "trimmer", "trimming"]; >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] = [2, "trimmer", "trimming"] : [number, string, string] >[numberB = -1, nameB = "helloNoName", skillB = "noSkill"] : [number, string, string] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number ->nameB = "helloNoName" : string +>-1 : -1 +>1 : 1 +>nameB = "helloNoName" : "helloNoName" >nameB : string ->"helloNoName" : string ->skillB = "noSkill" : string +>"helloNoName" : "helloNoName" +>skillB = "noSkill" : "noSkill" >skillB : string ->"noSkill" : string +>"noSkill" : "noSkill" >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" [nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = multiRobotB; >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = multiRobotB : [string, string[]] >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] : [string, [string, string]] ->nameMB = "helloNoName" : string +>nameMB = "helloNoName" : "helloNoName" >nameMB : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >[primarySkillB = "noSkill", secondarySkillB = "noSkill"] = [] : [string, string] >[primarySkillB = "noSkill", secondarySkillB = "noSkill"] : [string, string] ->primarySkillB = "noSkill" : string +>primarySkillB = "noSkill" : "noSkill" >primarySkillB : string ->"noSkill" : string ->secondarySkillB = "noSkill" : string +>"noSkill" : "noSkill" +>secondarySkillB = "noSkill" : "noSkill" >secondarySkillB : string ->"noSkill" : string +>"noSkill" : "noSkill" >[] : [string, string] >multiRobotB : [string, string[]] [nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = getMultiRobotB(); >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = getMultiRobotB() : [string, string[]] >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] : [string, [string, string]] ->nameMB = "helloNoName" : string +>nameMB = "helloNoName" : "helloNoName" >nameMB : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >[primarySkillB = "noSkill", secondarySkillB = "noSkill"] = [] : [string, string] >[primarySkillB = "noSkill", secondarySkillB = "noSkill"] : [string, string] ->primarySkillB = "noSkill" : string +>primarySkillB = "noSkill" : "noSkill" >primarySkillB : string ->"noSkill" : string ->secondarySkillB = "noSkill" : string +>"noSkill" : "noSkill" +>secondarySkillB = "noSkill" : "noSkill" >secondarySkillB : string ->"noSkill" : string +>"noSkill" : "noSkill" >[] : [string, string] >getMultiRobotB() : [string, string[]] >getMultiRobotB : () => [string, string[]] @@ -274,33 +274,33 @@ let multiRobotAInfo: (string | string[])[]; [nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] = ["trimmer", ["trimming", "edging"]] : [string, [string, string]] >[nameMB = "helloNoName", [primarySkillB = "noSkill", secondarySkillB = "noSkill"] = []] : [string, [string, string]] ->nameMB = "helloNoName" : string +>nameMB = "helloNoName" : "helloNoName" >nameMB : string ->"helloNoName" : string +>"helloNoName" : "helloNoName" >[primarySkillB = "noSkill", secondarySkillB = "noSkill"] = [] : [string, string] >[primarySkillB = "noSkill", secondarySkillB = "noSkill"] : [string, string] ->primarySkillB = "noSkill" : string +>primarySkillB = "noSkill" : "noSkill" >primarySkillB : string ->"noSkill" : string ->secondarySkillB = "noSkill" : string +>"noSkill" : "noSkill" +>secondarySkillB = "noSkill" : "noSkill" >secondarySkillB : string ->"noSkill" : string +>"noSkill" : "noSkill" >[] : [string, string] ["trimmer", ["trimming", "edging"]]; >["trimmer", ["trimming", "edging"]] : [string, [string, string]] ->"trimmer" : string +>"trimmer" : "trimmer" >["trimming", "edging"] : [string, string] ->"trimming" : string ->"edging" : string +>"trimming" : "trimming" +>"edging" : "edging" [numberB = -1, ...robotAInfo] = robotB; >[numberB = -1, ...robotAInfo] = robotB : [number, string, string] >[numberB = -1, ...robotAInfo] : (string | number)[] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >robotB : [number, string, string] @@ -308,10 +308,10 @@ let multiRobotAInfo: (string | string[])[]; [numberB = -1, ...robotAInfo] = getRobotB(); >[numberB = -1, ...robotAInfo] = getRobotB() : [number, string, string] >[numberB = -1, ...robotAInfo] : (string | number)[] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >getRobotB() : [number, string, string] @@ -320,18 +320,18 @@ let multiRobotAInfo: (string | string[])[]; [numberB = -1, ...robotAInfo] = [2, "trimmer", "trimming"]; >[numberB = -1, ...robotAInfo] = [2, "trimmer", "trimming"] : [number, string, string] >[numberB = -1, ...robotAInfo] : (string | number)[] ->numberB = -1 : number +>numberB = -1 : -1 >numberB : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 >...robotAInfo : string | number >robotAInfo : (string | number)[] >[2, "trimmer", "trimming"] : [number, string, string] >Robot : [number, string, string] >[2, "trimmer", "trimming"] : [number, string, string] ->2 : number ->"trimmer" : string ->"trimming" : string +>2 : 2 +>"trimmer" : "trimmer" +>"trimming" : "trimming" if (nameA == nameB) { >nameA == nameB : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.types index 0ad3330e867..fbce7dedef1 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementDefaultValues.types @@ -17,53 +17,53 @@ declare var console: { } var hello = "hello"; >hello : string ->"hello" : string +>"hello" : "hello" var robotA: Robot = { name: "mower", skill: "mowing" }; >robotA : Robot >Robot : Robot >{ name: "mower", skill: "mowing" } : { name: string; skill: string; } >name : string ->"mower" : string +>"mower" : "mower" >skill : string ->"mowing" : string +>"mowing" : "mowing" var robotB: Robot = { name: "trimmer", skill: "trimming" }; >robotB : Robot >Robot : Robot >{ name: "trimmer", skill: "trimming" } : { name: string; skill: string; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skill : string ->"trimming" : string +>"trimming" : "trimming" var { name: nameA = "" } = robotA; >name : any >nameA : string ->"" : string +>"" : "" >robotA : Robot var { name: nameB = "", skill: skillB = "" } = robotB; >name : any >nameB : string ->"" : string +>"" : "" >skill : any >skillB : string ->"" : string +>"" : "" >robotB : Robot var { name: nameC = "", skill: skillC = "" } = { name: "Edger", skill: "cutting edges" }; >name : any >nameC : string ->"" : string +>"" : "" >skill : any >skillC : string ->"" : string +>"" : "" >{ name: "Edger", skill: "cutting edges" } : { name?: string; skill?: string; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skill : string ->"cutting edges" : string +>"cutting edges" : "cutting edges" if (nameA == nameB) { >nameA == nameB : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.types index 1101b01b1a7..cf60c4a515f 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPattern.types @@ -28,26 +28,26 @@ var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "no >Robot : Robot >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" var robotB: Robot = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }; >robotB : Robot >Robot : Robot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" var { skills: { primary: primaryA, secondary: secondaryA } } = robotA; >skills : any @@ -77,13 +77,13 @@ var { name: nameC, skills: { primary: primaryB, secondary: secondaryB } } = { na >secondaryB : string >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skills : { primary: string; secondary: string; } >{ primary: "edging", secondary: "branch trimming" } : { primary: string; secondary: string; } >primary : string ->"edging" : string +>"edging" : "edging" >secondary : string ->"branch trimming" : string +>"branch trimming" : "branch trimming" if (nameB == nameB) { >nameB == nameB : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.types index e3fdec19339..fa007d9a2fc 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementNestedObjectBindingPatternWithDefaultValues.types @@ -28,26 +28,26 @@ var robotA: Robot = { name: "mower", skills: { primary: "mowing", secondary: "no >Robot : Robot >{ name: "mower", skills: { primary: "mowing", secondary: "none" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"mower" : string +>"mower" : "mower" >skills : { primary: string; secondary: string; } >{ primary: "mowing", secondary: "none" } : { primary: string; secondary: string; } >primary : string ->"mowing" : string +>"mowing" : "mowing" >secondary : string ->"none" : string +>"none" : "none" var robotB: Robot = { name: "trimmer", skills: { primary: "trimming", secondary: "edging" } }; >robotB : Robot >Robot : Robot >{ name: "trimmer", skills: { primary: "trimming", secondary: "edging" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"trimmer" : string +>"trimmer" : "trimmer" >skills : { primary: string; secondary: string; } >{ primary: "trimming", secondary: "edging" } : { primary: string; secondary: string; } >primary : string ->"trimming" : string +>"trimming" : "trimming" >secondary : string ->"edging" : string +>"edging" : "edging" var { skills: { @@ -56,19 +56,19 @@ var { primary: primaryA = "noSkill", >primary : any >primaryA : string ->"noSkill" : string +>"noSkill" : "noSkill" secondary: secondaryA = "noSkill" >secondary : any >secondaryA : string ->"noSkill" : string +>"noSkill" : "noSkill" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } = robotA; >robotA : Robot @@ -77,7 +77,7 @@ var { name: nameB = "noNameSpecified", >name : any >nameB : string ->"noNameSpecified" : string +>"noNameSpecified" : "noNameSpecified" skills: { >skills : any @@ -85,19 +85,19 @@ var { primary: primaryB = "noSkill", >primary : any >primaryB : string ->"noSkill" : string +>"noSkill" : "noSkill" secondary: secondaryB = "noSkill" >secondary : any >secondaryB : string ->"noSkill" : string +>"noSkill" : "noSkill" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } = robotB; >robotB : Robot @@ -106,7 +106,7 @@ var { name: nameC = "noNameSpecified", >name : any >nameC : string ->"noNameSpecified" : string +>"noNameSpecified" : "noNameSpecified" skills: { >skills : any @@ -114,32 +114,32 @@ var { primary: primaryB = "noSkill", >primary : any >primaryB : string ->"noSkill" : string +>"noSkill" : "noSkill" secondary: secondaryB = "noSkill" >secondary : any >secondaryB : string ->"noSkill" : string +>"noSkill" : "noSkill" } = { primary: "noSkill", secondary: "noSkill" } >{ primary: "noSkill", secondary: "noSkill" } : { primary?: string; secondary?: string; } >primary : string ->"noSkill" : string +>"noSkill" : "noSkill" >secondary : string ->"noSkill" : string +>"noSkill" : "noSkill" } = { name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } }; >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : Robot >Robot : Robot >{ name: "Edger", skills: { primary: "edging", secondary: "branch trimming" } } : { name: string; skills: { primary: string; secondary: string; }; } >name : string ->"Edger" : string +>"Edger" : "Edger" >skills : { primary: string; secondary: string; } >{ primary: "edging", secondary: "branch trimming" } : { primary: string; secondary: string; } >primary : string ->"edging" : string +>"edging" : "edging" >secondary : string ->"branch trimming" : string +>"branch trimming" : "branch trimming" if (nameB == nameB) { >nameB == nameB : boolean diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.types index c975a9eaae5..14995bbe1c9 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern1.types @@ -4,5 +4,5 @@ var {x} = { x: 20 }; >x : number >{ x: 20 } : { x: number; } >x : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.types index a694d4ecd29..52a5484052c 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern2.types @@ -4,14 +4,14 @@ var {x} = { x: 20 }; >x : number >{ x: 20 } : { x: number; } >x : number ->20 : number +>20 : 20 var { a, b } = { a: 30, b: 40 }; >a : number >b : number >{ a: 30, b: 40 } : { a: number; b: number; } >a : number ->30 : number +>30 : 30 >b : number ->40 : number +>40 : 40 diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.types index bec1b195c98..4b70fa8aa8d 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern3.types @@ -2,8 +2,8 @@ var {x = 500} = { x: 20 }; >x : number ->500 : number +>500 : 500 >{ x: 20 } : { x?: number; } >x : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.types b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.types index 1d00ac2d56b..1bd508ef2e5 100644 --- a/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.types +++ b/tests/baselines/reference/sourceMapValidationDestructuringVariableStatementObjectBindingPattern4.types @@ -2,13 +2,13 @@ var {x = 500, >x : number ->500 : number +>500 : 500 y} = { x: 20, y: "hi" }; >y : string >{ x: 20, y: "hi" } : { x?: number; y: string; } >x : number ->20 : number +>20 : 20 >y : string ->"hi" : string +>"hi" : "hi" diff --git a/tests/baselines/reference/sourceMapValidationDo.types b/tests/baselines/reference/sourceMapValidationDo.types index 7623a483fd1..85716b8f8b8 100644 --- a/tests/baselines/reference/sourceMapValidationDo.types +++ b/tests/baselines/reference/sourceMapValidationDo.types @@ -1,7 +1,7 @@ === tests/cases/compiler/sourceMapValidationDo.ts === var i = 0; >i : number ->0 : number +>0 : 0 do { @@ -12,7 +12,7 @@ do } while (i < 10); >i < 10 : boolean >i : number ->10 : number +>10 : 10 do { i++; @@ -22,5 +22,5 @@ do { } while (i < 20); >i < 20 : boolean >i : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/sourceMapValidationFunctionExpressions.types b/tests/baselines/reference/sourceMapValidationFunctionExpressions.types index 9ddfd93b89d..d51798c084f 100644 --- a/tests/baselines/reference/sourceMapValidationFunctionExpressions.types +++ b/tests/baselines/reference/sourceMapValidationFunctionExpressions.types @@ -1,7 +1,7 @@ === tests/cases/compiler/sourceMapValidationFunctionExpressions.ts === var greetings = 0; >greetings : number ->0 : number +>0 : 0 var greet = (greeting: string): number => { >greet : (greeting: string) => number @@ -18,7 +18,7 @@ var greet = (greeting: string): number => { greet("Hello"); >greet("Hello") : number >greet : (greeting: string) => number ->"Hello" : string +>"Hello" : "Hello" var incrGreetings = () => greetings++; >incrGreetings : () => number diff --git a/tests/baselines/reference/sourceMapValidationFunctions.types b/tests/baselines/reference/sourceMapValidationFunctions.types index 82cb550a8aa..6a085996c5c 100644 --- a/tests/baselines/reference/sourceMapValidationFunctions.types +++ b/tests/baselines/reference/sourceMapValidationFunctions.types @@ -1,7 +1,7 @@ === tests/cases/compiler/sourceMapValidationFunctions.ts === var greetings = 0; >greetings : number ->0 : number +>0 : 0 function greet(greeting: string): number { >greet : (greeting: string) => number @@ -18,7 +18,7 @@ function greet2(greeting: string, n = 10, x?: string, ...restParams: string[]): >greet2 : (greeting: string, n?: number, x?: string, ...restParams: string[]) => number >greeting : string >n : number ->10 : number +>10 : 10 >x : string >restParams : string[] @@ -33,7 +33,7 @@ function foo(greeting: string, n = 10, x?: string, ...restParams: string[]) >foo : (greeting: string, n?: number, x?: string, ...restParams: string[]) => void >greeting : string >n : number ->10 : number +>10 : 10 >x : string >restParams : string[] { diff --git a/tests/baselines/reference/sourceMapValidationIfElse.types b/tests/baselines/reference/sourceMapValidationIfElse.types index 2b195983f21..b4a76d55647 100644 --- a/tests/baselines/reference/sourceMapValidationIfElse.types +++ b/tests/baselines/reference/sourceMapValidationIfElse.types @@ -1,7 +1,7 @@ === tests/cases/compiler/sourceMapValidationIfElse.ts === var i = 10; >i : number ->10 : number +>10 : 10 if (i == 10) { >i == 10 : boolean @@ -41,7 +41,7 @@ else if (i == 20) { i += 70; >i += 70 : number >i : number ->70 : number +>70 : 70 } else { i--; diff --git a/tests/baselines/reference/sourceMapValidationLabeled.types b/tests/baselines/reference/sourceMapValidationLabeled.types index 7af624ac93b..6756494a5c7 100644 --- a/tests/baselines/reference/sourceMapValidationLabeled.types +++ b/tests/baselines/reference/sourceMapValidationLabeled.types @@ -5,5 +5,5 @@ x: var b = 10; >b : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/sourceMapValidationModule.types b/tests/baselines/reference/sourceMapValidationModule.types index 2c653270650..45651200300 100644 --- a/tests/baselines/reference/sourceMapValidationModule.types +++ b/tests/baselines/reference/sourceMapValidationModule.types @@ -4,7 +4,7 @@ module m2 { var a = 10; >a : number ->10 : number +>10 : 10 a++; >a++ : number @@ -18,7 +18,7 @@ module m3 { export var x = 30; >x : number ->30 : number +>30 : 30 } export function foo() { diff --git a/tests/baselines/reference/sourceMapValidationSwitch.types b/tests/baselines/reference/sourceMapValidationSwitch.types index 1c0a73c1bbe..9df86ee2132 100644 --- a/tests/baselines/reference/sourceMapValidationSwitch.types +++ b/tests/baselines/reference/sourceMapValidationSwitch.types @@ -1,7 +1,7 @@ === tests/cases/compiler/sourceMapValidationSwitch.ts === var x = 10; >x : number ->10 : number +>10 : 10 switch (x) { >x : number @@ -29,7 +29,7 @@ switch (x) { >x : number >x *10 : number >x : number ->10 : number +>10 : 10 } switch (x) >x : number @@ -58,6 +58,6 @@ switch (x) >x : number >x * 10 : number >x : number ->10 : number +>10 : 10 } } diff --git a/tests/baselines/reference/sourceMapValidationTryCatchFinally.types b/tests/baselines/reference/sourceMapValidationTryCatchFinally.types index 9159ee5aa45..7d7fb1d3aa9 100644 --- a/tests/baselines/reference/sourceMapValidationTryCatchFinally.types +++ b/tests/baselines/reference/sourceMapValidationTryCatchFinally.types @@ -1,7 +1,7 @@ === tests/cases/compiler/sourceMapValidationTryCatchFinally.ts === var x = 10; >x : number ->10 : number +>10 : 10 try { x = x + 1; @@ -9,7 +9,7 @@ try { >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 } catch (e) { >e : any @@ -19,7 +19,7 @@ try { >x : number >x - 1 : number >x : number ->1 : number +>1 : 1 } finally { x = x * 10; @@ -27,7 +27,7 @@ try { >x : number >x * 10 : number >x : number ->10 : number +>10 : 10 } try { @@ -36,7 +36,7 @@ try >x : number >x + 1 : number >x : number ->1 : number +>1 : 1 throw new Error(); >new Error() : Error @@ -50,7 +50,7 @@ catch (e) >x : number >x - 1 : number >x : number ->1 : number +>1 : 1 } finally { @@ -59,5 +59,5 @@ finally >x : number >x * 10 : number >x : number ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/sourceMapValidationVariables.types b/tests/baselines/reference/sourceMapValidationVariables.types index 2bacc7b526f..5dc46f5e792 100644 --- a/tests/baselines/reference/sourceMapValidationVariables.types +++ b/tests/baselines/reference/sourceMapValidationVariables.types @@ -1,19 +1,19 @@ === tests/cases/compiler/sourceMapValidationVariables.ts === var a = 10; >a : number ->10 : number +>10 : 10 var b; >b : any var c = 10, d, e; >c : number ->10 : number +>10 : 10 >d : any >e : any var c2, d2 = 10; >c2 : any >d2 : number ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/sourceMapValidationWhile.types b/tests/baselines/reference/sourceMapValidationWhile.types index 86cf0216276..71b50d86736 100644 --- a/tests/baselines/reference/sourceMapValidationWhile.types +++ b/tests/baselines/reference/sourceMapValidationWhile.types @@ -1,7 +1,7 @@ === tests/cases/compiler/sourceMapValidationWhile.ts === var a = 10; >a : number ->10 : number +>10 : 10 while (a == 10) { >a == 10 : boolean diff --git a/tests/baselines/reference/sourceMapValidationWithComments.types b/tests/baselines/reference/sourceMapValidationWithComments.types index 26971f0aaab..3e4b4639754 100644 --- a/tests/baselines/reference/sourceMapValidationWithComments.types +++ b/tests/baselines/reference/sourceMapValidationWithComments.types @@ -8,7 +8,7 @@ class DebugClass { // Start Debugger Test Code var i = 0; >i : number ->0 : number +>0 : 0 i++; >i++ : number @@ -50,6 +50,6 @@ class DebugClass { return true; ->true : boolean +>true : true } } diff --git a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.types b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.types index 8e9cda7377a..7c7cbc4e599 100644 --- a/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.types +++ b/tests/baselines/reference/sourceMapWithMultipleFilesWithCopyright.types @@ -19,11 +19,11 @@ var x = { a: 10, >a : number ->10 : number +>10 : 10 b: 20 >b : number ->20 : number +>20 : 20 }; diff --git a/tests/baselines/reference/sourceMapWithMultipleFilesWithFileEndingWithInterface.types b/tests/baselines/reference/sourceMapWithMultipleFilesWithFileEndingWithInterface.types index 561be8ce783..d3a26c4114e 100644 --- a/tests/baselines/reference/sourceMapWithMultipleFilesWithFileEndingWithInterface.types +++ b/tests/baselines/reference/sourceMapWithMultipleFilesWithFileEndingWithInterface.types @@ -4,7 +4,7 @@ module M { export var X = 1; >X : number ->1 : number +>1 : 1 } interface Navigator { >Navigator : Navigator diff --git a/tests/baselines/reference/sourcemapValidationDuplicateNames.types b/tests/baselines/reference/sourcemapValidationDuplicateNames.types index ccc6caa23b4..3798144f3af 100644 --- a/tests/baselines/reference/sourcemapValidationDuplicateNames.types +++ b/tests/baselines/reference/sourcemapValidationDuplicateNames.types @@ -4,7 +4,7 @@ module m1 { var x = 10; >x : number ->10 : number +>10 : 10 export class c { >c : c diff --git a/tests/baselines/reference/specializeVarArgs1.types b/tests/baselines/reference/specializeVarArgs1.types index 97b46876e66..68e1be49d5e 100644 --- a/tests/baselines/reference/specializeVarArgs1.types +++ b/tests/baselines/reference/specializeVarArgs1.types @@ -41,5 +41,5 @@ a.push('Some Value'); >a.push : (...values: string[]) => any >a : ObservableArray >push : (...values: string[]) => any ->'Some Value' : string +>'Some Value' : "Some Value" diff --git a/tests/baselines/reference/specializedSignatureAsCallbackParameter1.errors.txt b/tests/baselines/reference/specializedSignatureAsCallbackParameter1.errors.txt index 61b499e0aee..cf294de7780 100644 --- a/tests/baselines/reference/specializedSignatureAsCallbackParameter1.errors.txt +++ b/tests/baselines/reference/specializedSignatureAsCallbackParameter1.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/specializedSignatureAsCallbackParameter1.ts(7,4): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/compiler/specializedSignatureAsCallbackParameter1.ts(8,4): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/specializedSignatureAsCallbackParameter1.ts(7,4): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. +tests/cases/compiler/specializedSignatureAsCallbackParameter1.ts(8,4): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. ==== tests/cases/compiler/specializedSignatureAsCallbackParameter1.ts (2 errors) ==== @@ -11,7 +11,7 @@ tests/cases/compiler/specializedSignatureAsCallbackParameter1.ts(8,4): error TS2 // both are errors x3(1, (x: string) => 1); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. x3(1, (x: 'hm') => 1); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. \ No newline at end of file +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types index ba720d78612..f2bd83674cd 100644 --- a/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types +++ b/tests/baselines/reference/staticAnonymousTypeNotReferencingTypeParameter.types @@ -24,7 +24,7 @@ let y: number = outer(5).y; >outer(5).y : number >outer(5) : typeof Inner >outer : (x: T) => typeof Inner ->5 : number +>5 : 5 >y : number class ListWrapper2 { @@ -42,7 +42,7 @@ class ListWrapper2 { >array.slice : (start?: number, end?: number) => T[] >array : T[] >slice : (start?: number, end?: number) => T[] ->0 : number +>0 : 0 static reversed(dit: typeof ListWrapper2, array: T[]): T[] { >reversed : (dit: typeof ListWrapper2, array: T[]) => T[] @@ -92,7 +92,7 @@ namespace tessst { for (let i = 0, len = array.length; i < len; i++) { >i : number ->0 : number +>0 : 0 >len : number >array.length : number >array : T[] @@ -171,7 +171,7 @@ class ListWrapper { >array.slice : (start?: number, end?: number) => T[] >array : T[] >slice : (start?: number, end?: number) => T[] ->0 : number +>0 : 0 static forEachWithIndex(dit: typeof ListWrapper, array: T[], fn: (t: T, n: number) => void) { >forEachWithIndex : (dit: typeof ListWrapper, array: T[], fn: (t: T, n: number) => void) => void @@ -187,7 +187,7 @@ class ListWrapper { for (var i = 0; i < array.length; i++) { >i : number ->0 : number +>0 : 0 >i < array.length : boolean >i : number >array.length : number @@ -222,7 +222,7 @@ class ListWrapper { return array[0]; >array[0] : T >array : T[] ->0 : number +>0 : 0 } static last(dit: typeof ListWrapper, array: T[]): T { >last : (dit: typeof ListWrapper, array: T[]) => T @@ -251,7 +251,7 @@ class ListWrapper { >array.length : number >array : T[] >length : number ->1 : number +>1 : 1 } static indexOf(dit: typeof ListWrapper, array: T[], value: T, startIndex: number = 0): number { >indexOf : (dit: typeof ListWrapper, array: T[], value: T, startIndex?: number) => number @@ -263,7 +263,7 @@ class ListWrapper { >value : T >T : T >startIndex : number ->0 : number +>0 : 0 return array.indexOf(value, startIndex); >array.indexOf(value, startIndex) : number @@ -289,7 +289,7 @@ class ListWrapper { >indexOf : (searchElement: T, fromIndex?: number) => number >el : T >-1 : -1 ->1 : number +>1 : 1 static reversed(dit: typeof ListWrapper, array: T[]): T[] { >reversed : (dit: typeof ListWrapper, array: T[]) => T[] @@ -318,8 +318,8 @@ class ListWrapper { >scanner.scanRange : (start: number, length: number, callback: () => T) => T >scanner : Scanner >scanRange : (start: number, length: number, callback: () => T) => T ->3 : number ->5 : number +>3 : 3 +>5 : 5 >() => { } : () => void return tessst.funkyFor(array, t => t.toString()) ? a.reverse() : a; @@ -368,7 +368,7 @@ class ListWrapper { >list : T[] >splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number ->0 : number +>0 : 0 >value : T static removeAt(dit: typeof ListWrapper, list: T[], index: number): T { @@ -393,7 +393,7 @@ class ListWrapper { >list : T[] >splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number ->1 : number +>1 : 1 return res; >res : T @@ -410,7 +410,7 @@ class ListWrapper { for (var i = 0; i < items.length; ++i) { >i : number ->0 : number +>0 : 0 >i < items.length : boolean >i : number >items.length : number @@ -435,7 +435,7 @@ class ListWrapper { >list : T[] >splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number ->1 : number +>1 : 1 } } static remove(dit: typeof ListWrapper, list: T[], el: T): boolean { @@ -459,8 +459,8 @@ class ListWrapper { if (index > -1) { >index > -1 : boolean >index : number ->-1 : number ->1 : number +>-1 : -1 +>1 : 1 list.splice(index, 1); >list.splice(index, 1) : T[] @@ -468,7 +468,7 @@ class ListWrapper { >list : T[] >splice : { (start: number): T[]; (start: number, deleteCount: number, ...items: T[]): T[]; } >index : number ->1 : number +>1 : 1 return true; >true : true @@ -481,11 +481,11 @@ class ListWrapper { >dit : typeof ListWrapper >ListWrapper : typeof ListWrapper >list : any[] ->list.length = 0 : number +>list.length = 0 : 0 >list.length : number >list : any[] >length : number ->0 : number +>0 : 0 static isEmpty(dit: typeof ListWrapper, list: any[]): boolean { return list.length == 0; } >isEmpty : (dit: typeof ListWrapper, list: any[]) => boolean @@ -505,7 +505,7 @@ class ListWrapper { >list : any[] >value : any >start : number ->0 : number +>0 : 0 >end : number >null : null @@ -544,7 +544,7 @@ class ListWrapper { for (var i = 0; i < a.length; ++i) { >i : number ->0 : number +>0 : 0 >i < a.length : boolean >i : number >a.length : number @@ -574,7 +574,7 @@ class ListWrapper { >l : T[] >T : T >from : number ->0 : number +>0 : 0 >to : number >null : null >T : T @@ -701,7 +701,7 @@ class ListWrapper { for (var index = 0; index < list.length; index++) { >index : number ->0 : number +>0 : 0 >index < list.length : boolean >index : number >list.length : number @@ -757,10 +757,10 @@ let cloned = ListWrapper.clone(ListWrapper, [1,2,3,4]); >clone : (dit: typeof ListWrapper, array: T[]) => T[] >ListWrapper : typeof ListWrapper >[1,2,3,4] : number[] ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 declare function isBlank(x: any): boolean; >isBlank : (x: any) => boolean diff --git a/tests/baselines/reference/staticFactory1.types b/tests/baselines/reference/staticFactory1.types index 538728de2df..941dc614559 100644 --- a/tests/baselines/reference/staticFactory1.types +++ b/tests/baselines/reference/staticFactory1.types @@ -4,7 +4,7 @@ class Base { foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 static create() { >create : () => Base @@ -21,7 +21,7 @@ class Derived extends Base { foo() { return 2; } >foo : () => number ->2 : number +>2 : 2 } var d = Derived.create(); >d : Base diff --git a/tests/baselines/reference/staticInstanceResolution.types b/tests/baselines/reference/staticInstanceResolution.types index 255242252e3..1eb555487da 100644 --- a/tests/baselines/reference/staticInstanceResolution.types +++ b/tests/baselines/reference/staticInstanceResolution.types @@ -18,7 +18,7 @@ class Comment { >comments[0].getDocCommentText : () => void >comments[0] : Comment >comments : Comment[] ->0 : number +>0 : 0 >getDocCommentText : () => void var c: Comment; diff --git a/tests/baselines/reference/staticInstanceResolution2.types b/tests/baselines/reference/staticInstanceResolution2.types index 200e3336a28..68abb3a08ce 100644 --- a/tests/baselines/reference/staticInstanceResolution2.types +++ b/tests/baselines/reference/staticInstanceResolution2.types @@ -7,7 +7,7 @@ A.hasOwnProperty('foo'); >A.hasOwnProperty : (v: string) => boolean >A : typeof A >hasOwnProperty : (v: string) => boolean ->'foo' : string +>'foo' : "foo" class B { >B : B @@ -19,7 +19,7 @@ B.hasOwnProperty('foo'); >B.hasOwnProperty : (v: string) => boolean >B : typeof B >hasOwnProperty : (v: string) => boolean ->'foo' : string +>'foo' : "foo" diff --git a/tests/baselines/reference/staticInstanceResolution3.types b/tests/baselines/reference/staticInstanceResolution3.types index fe50c659f6d..2bc480b0ac8 100644 --- a/tests/baselines/reference/staticInstanceResolution3.types +++ b/tests/baselines/reference/staticInstanceResolution3.types @@ -10,7 +10,7 @@ WinJS.Promise.timeout(10); >WinJS : typeof WinJS >Promise : typeof WinJS.Promise >timeout : (delay: number) => WinJS.Promise ->10 : number +>10 : 10 === tests/cases/compiler/staticInstanceResolution3_0.ts === export class Promise { diff --git a/tests/baselines/reference/staticMemberAccessOffDerivedType1.types b/tests/baselines/reference/staticMemberAccessOffDerivedType1.types index 55b9c83969b..8eaba4abb98 100644 --- a/tests/baselines/reference/staticMemberAccessOffDerivedType1.types +++ b/tests/baselines/reference/staticMemberAccessOffDerivedType1.types @@ -6,7 +6,7 @@ class SomeBase { >GetNumber : () => number return 2; ->2 : number +>2 : 2 } } class P extends SomeBase { diff --git a/tests/baselines/reference/staticMemberInitialization.types b/tests/baselines/reference/staticMemberInitialization.types index 518b2fce25f..cb2c37f3fe0 100644 --- a/tests/baselines/reference/staticMemberInitialization.types +++ b/tests/baselines/reference/staticMemberInitialization.types @@ -4,7 +4,7 @@ class C { static x = 1; >x : number ->1 : number +>1 : 1 } var c = new C(); diff --git a/tests/baselines/reference/staticMemberWithStringAndNumberNames.types b/tests/baselines/reference/staticMemberWithStringAndNumberNames.types index e23ac90d59a..b0826343d20 100644 --- a/tests/baselines/reference/staticMemberWithStringAndNumberNames.types +++ b/tests/baselines/reference/staticMemberWithStringAndNumberNames.types @@ -3,44 +3,44 @@ class C { >C : C static "foo" = 0; ->0 : number +>0 : 0 static 0 = 1; ->1 : number +>1 : 1 x = C['foo']; >x : number >C['foo'] : number >C : typeof C ->'foo' : string +>'foo' : "foo" x2 = C['0']; >x2 : number >C['0'] : number >C : typeof C ->'0' : string +>'0' : "0" x3 = C[0]; >x3 : number >C[0] : number >C : typeof C ->0 : number +>0 : 0 static s = C['foo']; >s : number >C['foo'] : number >C : typeof C ->'foo' : string +>'foo' : "foo" static s2 = C['0']; >s2 : number >C['0'] : number >C : typeof C ->'0' : string +>'0' : "0" static s3 = C[0]; >s3 : number >C[0] : number >C : typeof C ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/stradac.types b/tests/baselines/reference/stradac.types index acdb54f45bd..b0b0cb895a2 100644 --- a/tests/baselines/reference/stradac.types +++ b/tests/baselines/reference/stradac.types @@ -1,7 +1,7 @@ === tests/cases/compiler/stradac.ts === var x = 10; >x : number ->10 : number +>10 : 10 // C++-style comment diff --git a/tests/baselines/reference/strictModeUseContextualKeyword.types b/tests/baselines/reference/strictModeUseContextualKeyword.types index a13e3d16ef8..9c6a89a7321 100644 --- a/tests/baselines/reference/strictModeUseContextualKeyword.types +++ b/tests/baselines/reference/strictModeUseContextualKeyword.types @@ -1,10 +1,10 @@ === tests/cases/compiler/strictModeUseContextualKeyword.ts === "use strict" ->"use strict" : string +>"use strict" : "use strict" var as = 0; >as : number ->0 : number +>0 : 0 function foo(as: string) { } >foo : (as: string) => void @@ -29,6 +29,6 @@ function H() { >as : number >{ as: 1 } : { as: number; } >as : number ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/strictModeWordInExportDeclaration.types b/tests/baselines/reference/strictModeWordInExportDeclaration.types index aa5f8e84f82..5064280bd31 100644 --- a/tests/baselines/reference/strictModeWordInExportDeclaration.types +++ b/tests/baselines/reference/strictModeWordInExportDeclaration.types @@ -1,10 +1,10 @@ === tests/cases/compiler/strictModeWordInExportDeclaration.ts === "use strict" ->"use strict" : string +>"use strict" : "use strict" var x = 1; >x : number ->1 : number +>1 : 1 export { x as foo } >x : number diff --git a/tests/baselines/reference/strictNullChecksNoWidening.types b/tests/baselines/reference/strictNullChecksNoWidening.types index 6dd2ee3fb4c..a544f9cef94 100644 --- a/tests/baselines/reference/strictNullChecksNoWidening.types +++ b/tests/baselines/reference/strictNullChecksNoWidening.types @@ -11,7 +11,7 @@ var a2 = undefined; var a3 = void 0; >a3 : undefined >void 0 : undefined ->0 : number +>0 : 0 var b1 = []; >b1 : never[] diff --git a/tests/baselines/reference/strictNullLogicalAndOr.types b/tests/baselines/reference/strictNullLogicalAndOr.types index ba25c57fe1d..50eb6586a0f 100644 --- a/tests/baselines/reference/strictNullLogicalAndOr.types +++ b/tests/baselines/reference/strictNullLogicalAndOr.types @@ -9,7 +9,7 @@ let sinOrCos = Math.random() < .5; >Math.random : () => number >Math : Math >random : () => number ->.5 : number +>.5 : 0.5 let choice = sinOrCos && Math.sin || Math.cos; >choice : (x: number) => number @@ -44,7 +44,7 @@ function sq(n?: number): number { >n*n : number >n : number >n : number ->0 : number +>0 : 0 return r; >r : number @@ -53,5 +53,5 @@ function sq(n?: number): number { sq(3); >sq(3) : number >sq : (n?: number | undefined) => number ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/stringHasStringValuedNumericIndexer.types b/tests/baselines/reference/stringHasStringValuedNumericIndexer.types index ce9504358eb..01f086ebbf4 100644 --- a/tests/baselines/reference/stringHasStringValuedNumericIndexer.types +++ b/tests/baselines/reference/stringHasStringValuedNumericIndexer.types @@ -2,6 +2,6 @@ var str: string = ""[0]; >str : string >""[0] : string ->"" : string ->0 : number +>"" : "" +>0 : 0 diff --git a/tests/baselines/reference/stringIncludes.types b/tests/baselines/reference/stringIncludes.types index 0d1e5ffea4d..1dce85fcec7 100644 --- a/tests/baselines/reference/stringIncludes.types +++ b/tests/baselines/reference/stringIncludes.types @@ -8,17 +8,17 @@ includes = "abcde".includes("cd"); >includes : boolean >"abcde".includes("cd") : boolean >"abcde".includes : (searchString: string, position?: number) => boolean ->"abcde" : string +>"abcde" : "abcde" >includes : (searchString: string, position?: number) => boolean ->"cd" : string +>"cd" : "cd" includes = "abcde".includes("cd", 2); >includes = "abcde".includes("cd", 2) : boolean >includes : boolean >"abcde".includes("cd", 2) : boolean >"abcde".includes : (searchString: string, position?: number) => boolean ->"abcde" : string +>"abcde" : "abcde" >includes : (searchString: string, position?: number) => boolean ->"cd" : string ->2 : number +>"cd" : "cd" +>2 : 2 diff --git a/tests/baselines/reference/stringIndexingResults.types b/tests/baselines/reference/stringIndexingResults.types index 1fdc580b1a2..9d7c19f49cc 100644 --- a/tests/baselines/reference/stringIndexingResults.types +++ b/tests/baselines/reference/stringIndexingResults.types @@ -7,7 +7,7 @@ class C { y = ''; >y : string ->'' : string +>'' : "" } var c: C; @@ -18,19 +18,19 @@ var r1 = c['y']; >r1 : string >c['y'] : string >c : C ->'y' : string +>'y' : "y" var r2 = c['a']; >r2 : string >c['a'] : string >c : C ->'a' : string +>'a' : "a" var r3 = c[1]; >r3 : string >c[1] : string >c : C ->1 : number +>1 : 1 interface I { >I : I @@ -50,19 +50,19 @@ var r4 = i['y']; >r4 : string >i['y'] : string >i : I ->'y' : string +>'y' : "y" var r5 = i['a']; >r5 : string >i['a'] : string >i : I ->'a' : string +>'a' : "a" var r6 = i[1]; >r6 : string >i[1] : string >i : I ->1 : number +>1 : 1 var a: { >a : { [x: string]: string; y: string; } @@ -78,42 +78,42 @@ var r7 = a['y']; >r7 : string >a['y'] : string >a : { [x: string]: string; y: string; } ->'y' : string +>'y' : "y" var r8 = a['a']; >r8 : string >a['a'] : string >a : { [x: string]: string; y: string; } ->'a' : string +>'a' : "a" var r9 = a[1]; >r9 : string >a[1] : string >a : { [x: string]: string; y: string; } ->1 : number +>1 : 1 var b: { [x: string]: string } = { y: '' } >b : { [x: string]: string; } >x : string >{ y: '' } : { y: string; } >y : string ->'' : string +>'' : "" var r10 = b['y']; >r10 : string >b['y'] : string >b : { [x: string]: string; } ->'y' : string +>'y' : "y" var r11 = b['a']; >r11 : string >b['a'] : string >b : { [x: string]: string; } ->'a' : string +>'a' : "a" var r12 = b[1]; >r12 : string >b[1] : string >b : { [x: string]: string; } ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/stringLiteralCheckedInIf01.types b/tests/baselines/reference/stringLiteralCheckedInIf01.types index bbf83ebdaa6..2505870f9a9 100644 --- a/tests/baselines/reference/stringLiteralCheckedInIf01.types +++ b/tests/baselines/reference/stringLiteralCheckedInIf01.types @@ -36,6 +36,6 @@ function f(foo: T) { >foo as S[] : S[] >foo : S[] >S : S ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/stringLiteralCheckedInIf02.types b/tests/baselines/reference/stringLiteralCheckedInIf02.types index d8e0be2f0d9..6589c85222a 100644 --- a/tests/baselines/reference/stringLiteralCheckedInIf02.types +++ b/tests/baselines/reference/stringLiteralCheckedInIf02.types @@ -42,6 +42,6 @@ function f(foo: T) { return foo[0]; >foo[0] : S >foo : S[] ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/stringLiteralMatchedInSwitch01.types b/tests/baselines/reference/stringLiteralMatchedInSwitch01.types index a0147779fd0..5f2d68d47cd 100644 --- a/tests/baselines/reference/stringLiteralMatchedInSwitch01.types +++ b/tests/baselines/reference/stringLiteralMatchedInSwitch01.types @@ -31,7 +31,7 @@ switch (foo) { >foo as S[] : S[] >foo : S[] >S : S ->0 : number +>0 : 0 break; } diff --git a/tests/baselines/reference/stringLiteralObjectLiteralDeclaration1.types b/tests/baselines/reference/stringLiteralObjectLiteralDeclaration1.types index 3f06c5eaa75..7c4ea1c86bb 100644 --- a/tests/baselines/reference/stringLiteralObjectLiteralDeclaration1.types +++ b/tests/baselines/reference/stringLiteralObjectLiteralDeclaration1.types @@ -5,6 +5,6 @@ module m1 { export var n = { 'foo bar': 4 }; >n : { 'foo bar': number; } >{ 'foo bar': 4 } : { 'foo bar': number; } ->4 : number +>4 : 4 } diff --git a/tests/baselines/reference/stringLiteralPropertyNameWithLineContinuation1.types b/tests/baselines/reference/stringLiteralPropertyNameWithLineContinuation1.types index ee5b5b27b54..c5022b5463b 100644 --- a/tests/baselines/reference/stringLiteralPropertyNameWithLineContinuation1.types +++ b/tests/baselines/reference/stringLiteralPropertyNameWithLineContinuation1.types @@ -6,13 +6,13 @@ var x = {'text\ ': string; } ':'hello'} ->'hello' : string +>'hello' : "hello" x.text = "bar" ->x.text = "bar" : string +>x.text = "bar" : "bar" >x.text : string >x : { 'text\ ': string; } >text : string ->"bar" : string +>"bar" : "bar" diff --git a/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.errors.txt b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.errors.txt new file mode 100644 index 00000000000..3a884d2d1c4 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.errors.txt @@ -0,0 +1,18 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndLogicalOrExpressions01.ts(6,5): error TS2322: Type 'string' is not assignable to type '"foo"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndLogicalOrExpressions01.ts(8,5): error TS2322: Type 'string' is not assignable to type '"foo" | "bar"'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesAndLogicalOrExpressions01.ts (2 errors) ==== + + declare function myRandBool(): boolean; + + let a: "foo" = "foo"; + let b = a || "foo"; + let c: "foo" = b; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"foo"'. + let d = b || "bar"; + let e: "foo" | "bar" = d; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"foo" | "bar"'. + \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.js b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.js index 479256b18b7..b6bcaf7c887 100644 --- a/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.js +++ b/tests/baselines/reference/stringLiteralTypesAndLogicalOrExpressions01.js @@ -20,7 +20,7 @@ var e = d; //// [stringLiteralTypesAndLogicalOrExpressions01.d.ts] declare function myRandBool(): boolean; declare let a: "foo"; -declare let b: "foo"; +declare let b: string; declare let c: "foo"; -declare let d: "foo" | "bar"; +declare let d: string; declare let e: "foo" | "bar"; diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.js b/tests/baselines/reference/stringLiteralTypesAndTuples01.js index b887213c8f6..4700cc65730 100644 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.js +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.js @@ -39,4 +39,4 @@ function rawr(dino) { declare let hello: string, brave: string, newish: string, world: string; declare type RexOrRaptor = "t-rex" | "raptor"; declare let im: "I'm", a: "a", dinosaur: RexOrRaptor; -declare function rawr(dino: RexOrRaptor): string; +declare function rawr(dino: RexOrRaptor): "ROAAAAR!" | "yip yip!"; diff --git a/tests/baselines/reference/stringLiteralTypesAndTuples01.types b/tests/baselines/reference/stringLiteralTypesAndTuples01.types index 10a30a6d75c..f69e36cf541 100644 --- a/tests/baselines/reference/stringLiteralTypesAndTuples01.types +++ b/tests/baselines/reference/stringLiteralTypesAndTuples01.types @@ -7,10 +7,10 @@ let [hello, brave, newish, world] = ["Hello", "Brave", "New", "World"]; >newish : string >world : string >["Hello", "Brave", "New", "World"] : [string, string, string, string] ->"Hello" : string ->"Brave" : string ->"New" : string ->"World" : string +>"Hello" : "Hello" +>"Brave" : "Brave" +>"New" : "New" +>"World" : "World" type RexOrRaptor = "t-rex" | "raptor" >RexOrRaptor : RexOrRaptor @@ -26,12 +26,12 @@ let [im, a, dinosaur]: ["I'm", "a", RexOrRaptor] = ['I\'m', 'a', 't-rex']; >'t-rex' : "t-rex" rawr(dinosaur); ->rawr(dinosaur) : string ->rawr : (dino: RexOrRaptor) => string +>rawr(dinosaur) : "ROAAAAR!" | "yip yip!" +>rawr : (dino: RexOrRaptor) => "ROAAAAR!" | "yip yip!" >dinosaur : "t-rex" function rawr(dino: RexOrRaptor) { ->rawr : (dino: RexOrRaptor) => string +>rawr : (dino: RexOrRaptor) => "ROAAAAR!" | "yip yip!" >dino : RexOrRaptor >RexOrRaptor : RexOrRaptor @@ -41,7 +41,7 @@ function rawr(dino: RexOrRaptor) { >"t-rex" : "t-rex" return "ROAAAAR!"; ->"ROAAAAR!" : string +>"ROAAAAR!" : "ROAAAAR!" } if (dino === "raptor") { >dino === "raptor" : boolean @@ -49,11 +49,11 @@ function rawr(dino: RexOrRaptor) { >"raptor" : "raptor" return "yip yip!"; ->"yip yip!" : string +>"yip yip!" : "yip yip!" } throw "Unexpected " + dino; >"Unexpected " + dino : string ->"Unexpected " : string +>"Unexpected " : "Unexpected " >dino : never } diff --git a/tests/baselines/reference/stringLiteralTypesAsTags01.types b/tests/baselines/reference/stringLiteralTypesAsTags01.types index e95a7364f93..ad53fb01c79 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags01.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags01.types @@ -79,12 +79,12 @@ let x: A = { >{ kind: "A", a: 100,} : { kind: "A"; a: number; } kind: "A", ->kind : "A" +>kind : string >"A" : "A" a: 100, >a : number ->100 : number +>100 : 100 } if (hasKind(x, "A")) { diff --git a/tests/baselines/reference/stringLiteralTypesAsTags02.types b/tests/baselines/reference/stringLiteralTypesAsTags02.types index c984b8a78f9..2e2cb2831b6 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags02.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags02.types @@ -73,12 +73,12 @@ let x: A = { >{ kind: "A", a: 100,} : { kind: "A"; a: number; } kind: "A", ->kind : "A" +>kind : string >"A" : "A" a: 100, >a : number ->100 : number +>100 : 100 } if (hasKind(x, "A")) { diff --git a/tests/baselines/reference/stringLiteralTypesAsTags03.types b/tests/baselines/reference/stringLiteralTypesAsTags03.types index fbe71ff07c1..17507c1036f 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTags03.types +++ b/tests/baselines/reference/stringLiteralTypesAsTags03.types @@ -76,12 +76,12 @@ let x: A = { >{ kind: "A", a: 100,} : { kind: "A"; a: number; } kind: "A", ->kind : "A" +>kind : string >"A" : "A" a: 100, >a : number ->100 : number +>100 : 100 } if (hasKind(x, "A")) { diff --git a/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint01.js b/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint01.js index 4f49d326ec0..805f16228ba 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint01.js +++ b/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint01.js @@ -38,8 +38,8 @@ hResult = h("bar"); declare function foo(f: (x: T) => T): (x: T) => T; declare function bar(f: (x: T) => T): (x: T) => T; declare let f: (x: "foo") => "foo"; -declare let fResult: "foo"; +declare let fResult: string; declare let g: (x: "foo") => "foo"; -declare let gResult: "foo"; +declare let gResult: string; declare let h: (x: "foo" | "bar") => "foo" | "bar"; -declare let hResult: "foo" | "bar"; +declare let hResult: string; diff --git a/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint01.types b/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint01.types index fe9163fc819..e213faf3b69 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint01.types +++ b/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint01.types @@ -33,7 +33,7 @@ let f = foo(x => x); >x : "foo" let fResult = f("foo"); ->fResult : "foo" +>fResult : string >f("foo") : "foo" >f : (x: "foo") => "foo" >"foo" : "foo" @@ -48,7 +48,7 @@ let g = foo((x => x)); >x : "foo" let gResult = g("foo"); ->gResult : "foo" +>gResult : string >g("foo") : "foo" >g : (x: "foo") => "foo" >"foo" : "foo" @@ -62,14 +62,14 @@ let h = bar(x => x); >x : "foo" | "bar" let hResult = h("foo"); ->hResult : "foo" | "bar" +>hResult : string >h("foo") : "foo" | "bar" >h : (x: "foo" | "bar") => "foo" | "bar" >"foo" : "foo" hResult = h("bar"); >hResult = h("bar") : "foo" | "bar" ->hResult : "foo" | "bar" +>hResult : string >h("bar") : "foo" | "bar" >h : (x: "foo" | "bar") => "foo" | "bar" >"bar" : "bar" diff --git a/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint02.js b/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint02.js index 173e74a6eef..06ee42b68ad 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint02.js +++ b/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint02.js @@ -18,4 +18,4 @@ var fResult = f("foo"); //// [stringLiteralTypesAsTypeParameterConstraint02.d.ts] declare function foo(f: (x: T) => T): (x: T) => T; declare let f: (x: "foo") => "foo"; -declare let fResult: "foo"; +declare let fResult: string; diff --git a/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint02.types b/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint02.types index 3a1b8fdc05c..75ba54cf6c2 100644 --- a/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint02.types +++ b/tests/baselines/reference/stringLiteralTypesAsTypeParameterConstraint02.types @@ -26,7 +26,7 @@ let f = foo((y: "foo" | "bar") => y === "foo" ? y : "foo"); >"foo" : "foo" let fResult = f("foo"); ->fResult : "foo" +>fResult : string >f("foo") : "foo" >f : (x: "foo") => "foo" >"foo" : "foo" diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt new file mode 100644 index 00000000000..39b2b154cc8 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes01.errors.txt @@ -0,0 +1,26 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts(16,9): error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes01.ts (1 errors) ==== + + type T = "foo" | "bar" | "baz"; + + var x: "foo" | "bar" | "baz" = undefined; + var y: T = undefined; + + if (x === "foo") { + let a = x; + } + else if (x !== "bar") { + let b = x || y; + } + else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; + ~ +!!! error TS2322: Type 'string' is not assignable to type '"foo" | "bar" | "baz"'. + } + + x = y; + y = x; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types index ab63a9e2fab..40b34796e72 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes02.types @@ -18,7 +18,7 @@ if (x === "foo") { >"foo" : "foo" let a = x; ->a : string | "foo" +>a : string >x : string | "foo" } else if (x !== "bar") { @@ -34,11 +34,11 @@ else if (x !== "bar") { } else { let c = x; ->c : string | "bar" +>c : string >x : string | "bar" let d = y; ->d : string | "foo" | "bar" | "baz" +>d : string >y : string | "foo" | "bar" | "baz" let e: (typeof x) | (typeof y) = c || d; @@ -46,8 +46,8 @@ else { >x : string | "bar" >y : string | "foo" | "bar" | "baz" >c || d : string ->c : string | "bar" ->d : string | "foo" | "bar" | "baz" +>c : string +>d : string } x = y; diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt new file mode 100644 index 00000000000..784f368c164 --- /dev/null +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes03.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts(16,9): error TS2322: Type 'string | number' is not assignable to type 'number | "foo" | "bar"'. + Type 'string' is not assignable to type 'number | "foo" | "bar"'. + + +==== tests/cases/conformance/types/stringLiteral/stringLiteralTypesInUnionTypes03.ts (1 errors) ==== + + type T = number | "foo" | "bar"; + + var x: "foo" | "bar" | number; + var y: T = undefined; + + if (x === "foo") { + let a = x; + } + else if (x !== "bar") { + let b = x || y; + } + else { + let c = x; + let d = y; + let e: (typeof x) | (typeof y) = c || d; + ~ +!!! error TS2322: Type 'string | number' is not assignable to type 'number | "foo" | "bar"'. +!!! error TS2322: Type 'string' is not assignable to type 'number | "foo" | "bar"'. + } + + x = y; + y = x; \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types index 05b6b9b9b7a..3d2a41ec5c9 100644 --- a/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types +++ b/tests/baselines/reference/stringLiteralTypesInUnionTypes04.types @@ -19,7 +19,7 @@ if (x === "") { >"" : "" let a = x; ->a : "" +>a : string >x : "" } @@ -29,7 +29,7 @@ if (x !== "") { >"" : "" let b = x; ->b : "foo" +>b : string >x : "foo" } @@ -39,7 +39,7 @@ if (x == "") { >"" : "" let c = x; ->c : "" +>c : string >x : "" } @@ -49,7 +49,7 @@ if (x != "") { >"" : "" let d = x; ->d : "foo" +>d : string >x : "foo" } @@ -57,7 +57,7 @@ if (x) { >x : T let e = x; ->e : "foo" +>e : string >x : "foo" } @@ -66,7 +66,7 @@ if (!x) { >x : T let f = x; ->f : T +>f : string >x : T } @@ -76,7 +76,7 @@ if (!!x) { >x : T let g = x; ->g : "foo" +>g : string >x : "foo" } @@ -87,6 +87,6 @@ if (!!!x) { >x : T let h = x; ->h : T +>h : string >x : T } diff --git a/tests/baselines/reference/stringLiteralTypesOverloadAssignability03.types b/tests/baselines/reference/stringLiteralTypesOverloadAssignability03.types index 8150eedd7b8..00af8e68373 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloadAssignability03.types +++ b/tests/baselines/reference/stringLiteralTypesOverloadAssignability03.types @@ -9,7 +9,7 @@ function f(x: string): number { >x : string return 0; ->0 : number +>0 : 0 } function g(x: "foo"): number; @@ -21,7 +21,7 @@ function g(x: string): number { >x : string return 0; ->0 : number +>0 : 0 } let a = f; diff --git a/tests/baselines/reference/stringLiteralTypesOverloadAssignability04.types b/tests/baselines/reference/stringLiteralTypesOverloadAssignability04.types index 7187e276fe4..694a300d3d3 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloadAssignability04.types +++ b/tests/baselines/reference/stringLiteralTypesOverloadAssignability04.types @@ -9,7 +9,7 @@ function f(x: "foo"): number { >x : "foo" return 0; ->0 : number +>0 : 0 } function g(x: "foo"): number; @@ -21,7 +21,7 @@ function g(x: "foo"): number { >x : "foo" return 0; ->0 : number +>0 : 0 } let a = f; diff --git a/tests/baselines/reference/stringLiteralTypesOverloadAssignability05.types b/tests/baselines/reference/stringLiteralTypesOverloadAssignability05.types index b7dd9262a67..925d2547411 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloadAssignability05.types +++ b/tests/baselines/reference/stringLiteralTypesOverloadAssignability05.types @@ -13,7 +13,7 @@ function f(x: string): number { >x : string return 0; ->0 : number +>0 : 0 } function g(x: "foo"): number; @@ -25,7 +25,7 @@ function g(x: string): number { >x : string return 0; ->0 : number +>0 : 0 } let a = f; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads01.types b/tests/baselines/reference/stringLiteralTypesOverloads01.types index 6a46c7676f7..2a0bc61f3e8 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads01.types +++ b/tests/baselines/reference/stringLiteralTypesOverloads01.types @@ -42,7 +42,7 @@ function getFalsyPrimitive(x: PrimitiveName): number | string | boolean { >"string" : "string" return ""; ->"" : string +>"" : "" } if (x === "number") { >x === "number" : boolean @@ -50,7 +50,7 @@ function getFalsyPrimitive(x: PrimitiveName): number | string | boolean { >"number" : "number" return 0; ->0 : number +>0 : 0 } if (x === "boolean") { >x === "boolean" : boolean @@ -63,7 +63,7 @@ function getFalsyPrimitive(x: PrimitiveName): number | string | boolean { // Should be unreachable. throw "Invalid value"; ->"Invalid value" : string +>"Invalid value" : "Invalid value" } namespace Consts1 { diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.js b/tests/baselines/reference/stringLiteralTypesOverloads02.js index 45443ea6a8f..0e7bd8c82c8 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads02.js +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.js @@ -7,7 +7,7 @@ function getFalsyPrimitive(x: "boolean" | "string"): boolean | string; function getFalsyPrimitive(x: "boolean" | "number"): boolean | number; function getFalsyPrimitive(x: "number" | "string"): number | string; function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string | boolean; -function getFalsyPrimitive(x: string) { +function getFalsyPrimitive(x: string): string | number | boolean { if (x === "string") { return ""; } @@ -28,9 +28,9 @@ namespace Consts1 { const FALSE = getFalsyPrimitive("boolean"); } -const string: "string" = "string" -const number: "number" = "number" -const boolean: "boolean" = "boolean" +const string = "string" +const number = "number" +const boolean = "boolean" const stringOrNumber = string || number; const stringOrBoolean = string || boolean; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.symbols b/tests/baselines/reference/stringLiteralTypesOverloads02.symbols index 7c95a42b10f..1bbedacf8a5 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads02.symbols +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.symbols @@ -28,7 +28,7 @@ function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string >getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) >x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 7, 27)) -function getFalsyPrimitive(x: string) { +function getFalsyPrimitive(x: string): string | number | boolean { >getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) >x : Symbol(x, Decl(stringLiteralTypesOverloads02.ts, 8, 27)) @@ -68,13 +68,13 @@ namespace Consts1 { >getFalsyPrimitive : Symbol(getFalsyPrimitive, Decl(stringLiteralTypesOverloads02.ts, 0, 0), Decl(stringLiteralTypesOverloads02.ts, 1, 48), Decl(stringLiteralTypesOverloads02.ts, 2, 48), Decl(stringLiteralTypesOverloads02.ts, 3, 50), Decl(stringLiteralTypesOverloads02.ts, 4, 70), Decl(stringLiteralTypesOverloads02.ts, 5, 70), Decl(stringLiteralTypesOverloads02.ts, 6, 68), Decl(stringLiteralTypesOverloads02.ts, 7, 90)) } -const string: "string" = "string" +const string = "string" >string : Symbol(string, Decl(stringLiteralTypesOverloads02.ts, 29, 5)) -const number: "number" = "number" +const number = "number" >number : Symbol(number, Decl(stringLiteralTypesOverloads02.ts, 30, 5)) -const boolean: "boolean" = "boolean" +const boolean = "boolean" >boolean : Symbol(boolean, Decl(stringLiteralTypesOverloads02.ts, 31, 5)) const stringOrNumber = string || number; diff --git a/tests/baselines/reference/stringLiteralTypesOverloads02.types b/tests/baselines/reference/stringLiteralTypesOverloads02.types index 91eaea1dca3..7122929e85d 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads02.types +++ b/tests/baselines/reference/stringLiteralTypesOverloads02.types @@ -28,7 +28,7 @@ function getFalsyPrimitive(x: "number" | "string" | "boolean"): number | string >getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } >x : "string" | "number" | "boolean" -function getFalsyPrimitive(x: string) { +function getFalsyPrimitive(x: string): string | number | boolean { >getFalsyPrimitive : { (x: "string"): string; (x: "number"): number; (x: "boolean"): boolean; (x: "string" | "boolean"): string | boolean; (x: "number" | "boolean"): number | boolean; (x: "string" | "number"): string | number; (x: "string" | "number" | "boolean"): string | number | boolean; } >x : string @@ -38,7 +38,7 @@ function getFalsyPrimitive(x: string) { >"string" : "string" return ""; ->"" : string +>"" : "" } if (x === "number") { >x === "number" : boolean @@ -46,7 +46,7 @@ function getFalsyPrimitive(x: string) { >"number" : "number" return 0; ->0 : number +>0 : 0 } if (x === "boolean") { >x === "boolean" : boolean @@ -54,12 +54,12 @@ function getFalsyPrimitive(x: string) { >"boolean" : "boolean" return false; ->false : boolean +>false : false } // Should be unreachable. throw "Invalid value"; ->"Invalid value" : string +>"Invalid value" : "Invalid value" } namespace Consts1 { @@ -84,15 +84,15 @@ namespace Consts1 { >"boolean" : "boolean" } -const string: "string" = "string" +const string = "string" >string : "string" >"string" : "string" -const number: "number" = "number" +const number = "number" >number : "number" >"number" : "number" -const boolean: "boolean" = "boolean" +const boolean = "boolean" >boolean : "boolean" >"boolean" : "boolean" diff --git a/tests/baselines/reference/stringLiteralTypesOverloads04.js b/tests/baselines/reference/stringLiteralTypesOverloads04.js index fd10ac986a9..81e123c3e57 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads04.js +++ b/tests/baselines/reference/stringLiteralTypesOverloads04.js @@ -3,7 +3,7 @@ declare function f(x: (p: "foo" | "bar") => "foo"); f(y => { - let z = y = "foo"; + const z = y = "foo"; return z; }) diff --git a/tests/baselines/reference/stringLiteralTypesOverloads04.symbols b/tests/baselines/reference/stringLiteralTypesOverloads04.symbols index 9f468b8bd95..de1951d325a 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads04.symbols +++ b/tests/baselines/reference/stringLiteralTypesOverloads04.symbols @@ -9,11 +9,11 @@ f(y => { >f : Symbol(f, Decl(stringLiteralTypesOverloads04.ts, 0, 0)) >y : Symbol(y, Decl(stringLiteralTypesOverloads04.ts, 3, 2)) - let z = y = "foo"; ->z : Symbol(z, Decl(stringLiteralTypesOverloads04.ts, 4, 7)) + const z = y = "foo"; +>z : Symbol(z, Decl(stringLiteralTypesOverloads04.ts, 4, 9)) >y : Symbol(y, Decl(stringLiteralTypesOverloads04.ts, 3, 2)) return z; ->z : Symbol(z, Decl(stringLiteralTypesOverloads04.ts, 4, 7)) +>z : Symbol(z, Decl(stringLiteralTypesOverloads04.ts, 4, 9)) }) diff --git a/tests/baselines/reference/stringLiteralTypesOverloads04.types b/tests/baselines/reference/stringLiteralTypesOverloads04.types index 32d316494ca..8cb8b2a7cea 100644 --- a/tests/baselines/reference/stringLiteralTypesOverloads04.types +++ b/tests/baselines/reference/stringLiteralTypesOverloads04.types @@ -6,12 +6,12 @@ declare function f(x: (p: "foo" | "bar") => "foo"); >p : "foo" | "bar" f(y => { ->f(y => { let z = y = "foo"; return z;}) : any +>f(y => { const z = y = "foo"; return z;}) : any >f : (x: (p: "foo" | "bar") => "foo") => any ->y => { let z = y = "foo"; return z;} : (y: "foo" | "bar") => "foo" +>y => { const z = y = "foo"; return z;} : (y: "foo" | "bar") => "foo" >y : "foo" | "bar" - let z = y = "foo"; + const z = y = "foo"; >z : "foo" >y = "foo" : "foo" >y : "foo" | "bar" diff --git a/tests/baselines/reference/stringLiteralTypesTypePredicates01.types b/tests/baselines/reference/stringLiteralTypesTypePredicates01.types index 822103b86f5..0a87ffad865 100644 --- a/tests/baselines/reference/stringLiteralTypesTypePredicates01.types +++ b/tests/baselines/reference/stringLiteralTypesTypePredicates01.types @@ -42,12 +42,12 @@ if (kindIs(x, "A")) { >"A" : "A" let a = x; ->a : "A" +>a : string >x : "A" } else { let b = x; ->b : "B" +>b : string >x : "B" } @@ -59,11 +59,11 @@ if (!kindIs(x, "B")) { >"B" : "B" let c = x; ->c : "A" +>c : string >x : "A" } else { let d = x; ->d : "B" +>d : string >x : "B" } diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types index d55d5ab9294..46dfef010a0 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators01.types @@ -16,33 +16,33 @@ let abcOrXyz: "ABC" | "XYZ" = abc || xyz; let abcOrXyzOrNumber: "ABC" | "XYZ" | number = abcOrXyz || 100; >abcOrXyzOrNumber : number | "ABC" | "XYZ" ->abcOrXyz || 100 : number | "ABC" | "XYZ" +>abcOrXyz || 100 : "ABC" | "XYZ" | 100 >abcOrXyz : "ABC" | "XYZ" ->100 : number +>100 : 100 let a = "" + abc; >a : string >"" + abc : string ->"" : string +>"" : "" >abc : "ABC" let b = abc + ""; >b : string >abc + "" : string >abc : "ABC" ->"" : string +>"" : "" let c = 10 + abc; >c : string >10 + abc : string ->10 : number +>10 : 10 >abc : "ABC" let d = abc + 10; >d : string >abc + 10 : string >abc : "ABC" ->10 : number +>10 : 10 let e = xyz + abc; >e : string @@ -59,14 +59,14 @@ let f = abc + xyz; let g = true + abc; >g : string >true + abc : string ->true : boolean +>true : true >abc : "ABC" let h = abc + true; >h : string >abc + true : string >abc : "ABC" ->true : boolean +>true : true let i = abc + abcOrXyz + xyz; >i : string @@ -96,12 +96,12 @@ let m = abcOrXyzOrNumber + ""; >m : string >abcOrXyzOrNumber + "" : string >abcOrXyzOrNumber : number | "ABC" | "XYZ" ->"" : string +>"" : "" let n = "" + abcOrXyzOrNumber; >n : string >"" + abcOrXyzOrNumber : string ->"" : string +>"" : "" >abcOrXyzOrNumber : number | "ABC" | "XYZ" let o = abcOrXyzOrNumber + abcOrXyz; diff --git a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt index ad02604cc4c..a51469baa93 100644 --- a/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt +++ b/tests/baselines/reference/stringLiteralTypesWithVariousOperators02.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(7,9): error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and 'number'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(8,9): error TS2365: Operator '+' cannot be applied to types 'number' and 'number | "ABC" | "XYZ"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(7,9): error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and '100'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(8,9): error TS2365: Operator '+' cannot be applied to types '100' and 'number | "ABC" | "XYZ"'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(9,9): error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and 'number | "ABC" | "XYZ"'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(10,9): error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and 'boolean'. -tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(11,9): error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number | "ABC" | "XYZ"'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(10,9): error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and 'true'. +tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(11,9): error TS2365: Operator '+' cannot be applied to types 'false' and 'number | "ABC" | "XYZ"'. tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(12,9): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(13,11): error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperators02.ts(14,9): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -21,19 +21,19 @@ tests/cases/conformance/types/stringLiteral/stringLiteralTypesWithVariousOperato let a = abcOrXyzOrNumber + 100; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and 'number'. +!!! error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and '100'. let b = 100 + abcOrXyzOrNumber; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'number | "ABC" | "XYZ"'. +!!! error TS2365: Operator '+' cannot be applied to types '100' and 'number | "ABC" | "XYZ"'. let c = abcOrXyzOrNumber + abcOrXyzOrNumber; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and 'number | "ABC" | "XYZ"'. let d = abcOrXyzOrNumber + true; ~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and 'boolean'. +!!! error TS2365: Operator '+' cannot be applied to types 'number | "ABC" | "XYZ"' and 'true'. let e = false + abcOrXyzOrNumber; ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'boolean' and 'number | "ABC" | "XYZ"'. +!!! error TS2365: Operator '+' cannot be applied to types 'false' and 'number | "ABC" | "XYZ"'. let f = abcOrXyzOrNumber++; ~~~~~~~~~~~~~~~~ !!! error TS2356: An arithmetic operand must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons01.types b/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons01.types index 17a835a2461..71cfd959f5e 100644 --- a/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons01.types +++ b/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons01.types @@ -4,7 +4,7 @@ var a = "foo" === "bar" as string; >"foo" === "bar" as string : boolean >"foo" : "foo" >"bar" as string : string ->"bar" : string +>"bar" : "bar" var b = "foo" !== ("bar" as string); >b : boolean @@ -12,7 +12,7 @@ var b = "foo" !== ("bar" as string); >"foo" : "foo" >("bar" as string) : string >"bar" as string : string ->"bar" : string +>"bar" : "bar" var c = "foo" == ("bar"); >c : boolean @@ -20,5 +20,5 @@ var c = "foo" == ("bar"); >"foo" : "foo" >("bar") : any >"bar" : any ->"bar" : string +>"bar" : "bar" diff --git a/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt b/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt index 5daeab5dbed..fd92af4e84f 100644 --- a/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt +++ b/tests/baselines/reference/stringLiteralsAssertionsInEqualityComparisons02.errors.txt @@ -1,21 +1,15 @@ tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(3,9): error TS2365: Operator '===' cannot be applied to types '"foo"' and '"baz"'. -tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(3,19): error TS2352: Type '"bar"' cannot be converted to type '"baz"'. -tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(4,20): error TS2352: Type '"bar"' cannot be converted to type '"foo"'. tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(5,9): error TS2365: Operator '==' cannot be applied to types 'string' and 'number'. tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts(5,19): error TS2352: Type 'string' cannot be converted to type 'number'. -==== tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts (5 errors) ==== +==== tests/cases/conformance/types/literal/stringLiteralsAssertionsInEqualityComparisons02.ts (3 errors) ==== type EnhancedString = string & { enhancements: any }; var a = "foo" === "bar" as "baz"; ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '===' cannot be applied to types '"foo"' and '"baz"'. - ~~~~~~~~~~~~~~ -!!! error TS2352: Type '"bar"' cannot be converted to type '"baz"'. var b = "foo" !== ("bar" as "foo"); - ~~~~~~~~~~~~~~ -!!! error TS2352: Type '"bar"' cannot be converted to type '"foo"'. var c = "foo" == ("bar"); ~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2365: Operator '==' cannot be applied to types 'string' and 'number'. diff --git a/tests/baselines/reference/stringLiteralsWithSwitchStatements03.errors.txt b/tests/baselines/reference/stringLiteralsWithSwitchStatements03.errors.txt index b2cbc96501f..c5aedb81334 100644 --- a/tests/baselines/reference/stringLiteralsWithSwitchStatements03.errors.txt +++ b/tests/baselines/reference/stringLiteralsWithSwitchStatements03.errors.txt @@ -1,11 +1,16 @@ tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts(10,10): error TS2678: Type '"bar" | "baz"' is not comparable to type '"foo"'. Type '"baz"' is not comparable to type '"foo"'. tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts(12,10): error TS2678: Type '"bar"' is not comparable to type '"foo"'. +tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts(14,10): error TS2678: Type '"baz"' is not comparable to type '"foo"'. +tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts(20,10): error TS2678: Type '"bar" | "baz"' is not comparable to type '"foo"'. + Type '"baz"' is not comparable to type '"foo"'. tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts(22,10): error TS2678: Type '"bar" | "baz"' is not comparable to type '"foo"'. Type '"baz"' is not comparable to type '"foo"'. +tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts(23,10): error TS2678: Type '"bar" | "baz"' is not comparable to type '"foo"'. + Type '"baz"' is not comparable to type '"foo"'. -==== tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts (3 errors) ==== +==== tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts (6 errors) ==== let x: "foo"; let y: "foo" | "bar"; let z: "bar"; @@ -25,18 +30,26 @@ tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements03.ts(22 !!! error TS2678: Type '"bar"' is not comparable to type '"foo"'. break; case (x, y, ("baz")): + ~~~~~~~~~~~~~~~ +!!! error TS2678: Type '"baz"' is not comparable to type '"foo"'. x; y; break; case (("foo" || ("bar"))): break; case (("bar" || ("baz"))): + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2678: Type '"bar" | "baz"' is not comparable to type '"foo"'. +!!! error TS2678: Type '"baz"' is not comparable to type '"foo"'. break; case z || "baz": ~~~~~~~~~~ !!! error TS2678: Type '"bar" | "baz"' is not comparable to type '"foo"'. !!! error TS2678: Type '"baz"' is not comparable to type '"foo"'. case "baz" || z: + ~~~~~~~~~~ +!!! error TS2678: Type '"bar" | "baz"' is not comparable to type '"foo"'. +!!! error TS2678: Type '"baz"' is not comparable to type '"foo"'. z; break; } diff --git a/tests/baselines/reference/stringLiteralsWithSwitchStatements04.errors.txt b/tests/baselines/reference/stringLiteralsWithSwitchStatements04.errors.txt new file mode 100644 index 00000000000..10a461c753a --- /dev/null +++ b/tests/baselines/reference/stringLiteralsWithSwitchStatements04.errors.txt @@ -0,0 +1,28 @@ +tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements04.ts(11,10): error TS2678: Type '"baz"' is not comparable to type '"foo" | "bar"'. + + +==== tests/cases/conformance/types/literal/stringLiteralsWithSwitchStatements04.ts (1 errors) ==== + let x: "foo"; + let y: "foo" | "bar"; + + declare function randBool(): boolean; + + switch (y) { + case "foo", x: + break; + case x, "foo": + break; + case x, "baz": + ~~~~~~~~ +!!! error TS2678: Type '"baz"' is not comparable to type '"foo" | "bar"'. + break; + case "baz", x: + break; + case "baz" && "bar": + break; + case "baz" && ("foo" || "bar"): + break; + case "bar" && ("baz" || "bar"): + break; + } + \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralsWithTypeAssertions01.errors.txt b/tests/baselines/reference/stringLiteralsWithTypeAssertions01.errors.txt deleted file mode 100644 index d9d465c7afc..00000000000 --- a/tests/baselines/reference/stringLiteralsWithTypeAssertions01.errors.txt +++ /dev/null @@ -1,25 +0,0 @@ -tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts(3,9): error TS2352: Type '"foo"' cannot be converted to type '"bar"'. -tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts(4,9): error TS2352: Type '"bar"' cannot be converted to type '"foo"'. -tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts(7,9): error TS2352: Type '"foo" | "bar"' cannot be converted to type '"baz"'. - Type '"bar"' is not comparable to type '"baz"'. -tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts(8,9): error TS2352: Type '"baz"' cannot be converted to type '"foo" | "bar"'. - - -==== tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts (4 errors) ==== - let fooOrBar: "foo" | "bar"; - - let a = "foo" as "bar"; - ~~~~~~~~~~~~~~ -!!! error TS2352: Type '"foo"' cannot be converted to type '"bar"'. - let b = "bar" as "foo"; - ~~~~~~~~~~~~~~ -!!! error TS2352: Type '"bar"' cannot be converted to type '"foo"'. - let c = fooOrBar as "foo"; - let d = fooOrBar as "bar"; - let e = fooOrBar as "baz"; - ~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '"foo" | "bar"' cannot be converted to type '"baz"'. -!!! error TS2352: Type '"bar"' is not comparable to type '"baz"'. - let f = "baz" as typeof fooOrBar; - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2352: Type '"baz"' cannot be converted to type '"foo" | "bar"'. \ No newline at end of file diff --git a/tests/baselines/reference/stringLiteralsWithTypeAssertions01.symbols b/tests/baselines/reference/stringLiteralsWithTypeAssertions01.symbols new file mode 100644 index 00000000000..915432deca3 --- /dev/null +++ b/tests/baselines/reference/stringLiteralsWithTypeAssertions01.symbols @@ -0,0 +1,26 @@ +=== tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts === +let fooOrBar: "foo" | "bar"; +>fooOrBar : Symbol(fooOrBar, Decl(stringLiteralsWithTypeAssertions01.ts, 0, 3)) + +let a = "foo" as "bar"; +>a : Symbol(a, Decl(stringLiteralsWithTypeAssertions01.ts, 2, 3)) + +let b = "bar" as "foo"; +>b : Symbol(b, Decl(stringLiteralsWithTypeAssertions01.ts, 3, 3)) + +let c = fooOrBar as "foo"; +>c : Symbol(c, Decl(stringLiteralsWithTypeAssertions01.ts, 4, 3)) +>fooOrBar : Symbol(fooOrBar, Decl(stringLiteralsWithTypeAssertions01.ts, 0, 3)) + +let d = fooOrBar as "bar"; +>d : Symbol(d, Decl(stringLiteralsWithTypeAssertions01.ts, 5, 3)) +>fooOrBar : Symbol(fooOrBar, Decl(stringLiteralsWithTypeAssertions01.ts, 0, 3)) + +let e = fooOrBar as "baz"; +>e : Symbol(e, Decl(stringLiteralsWithTypeAssertions01.ts, 6, 3)) +>fooOrBar : Symbol(fooOrBar, Decl(stringLiteralsWithTypeAssertions01.ts, 0, 3)) + +let f = "baz" as typeof fooOrBar; +>f : Symbol(f, Decl(stringLiteralsWithTypeAssertions01.ts, 7, 3)) +>fooOrBar : Symbol(fooOrBar, Decl(stringLiteralsWithTypeAssertions01.ts, 0, 3)) + diff --git a/tests/baselines/reference/stringLiteralsWithTypeAssertions01.types b/tests/baselines/reference/stringLiteralsWithTypeAssertions01.types new file mode 100644 index 00000000000..4cd85990702 --- /dev/null +++ b/tests/baselines/reference/stringLiteralsWithTypeAssertions01.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/types/literal/stringLiteralsWithTypeAssertions01.ts === +let fooOrBar: "foo" | "bar"; +>fooOrBar : "foo" | "bar" + +let a = "foo" as "bar"; +>a : string +>"foo" as "bar" : "bar" +>"foo" : "foo" + +let b = "bar" as "foo"; +>b : string +>"bar" as "foo" : "foo" +>"bar" : "bar" + +let c = fooOrBar as "foo"; +>c : string +>fooOrBar as "foo" : "foo" +>fooOrBar : "foo" | "bar" + +let d = fooOrBar as "bar"; +>d : string +>fooOrBar as "bar" : "bar" +>fooOrBar : "foo" | "bar" + +let e = fooOrBar as "baz"; +>e : string +>fooOrBar as "baz" : "baz" +>fooOrBar : "foo" | "bar" + +let f = "baz" as typeof fooOrBar; +>f : string +>"baz" as typeof fooOrBar : "foo" | "bar" +>"baz" : "baz" +>fooOrBar : "foo" | "bar" + diff --git a/tests/baselines/reference/stringNamedPropertyAccess.types b/tests/baselines/reference/stringNamedPropertyAccess.types index 2d0b585f828..1b3d56abc10 100644 --- a/tests/baselines/reference/stringNamedPropertyAccess.types +++ b/tests/baselines/reference/stringNamedPropertyAccess.types @@ -13,13 +13,13 @@ var r1 = c["a b"]; >r1 : number >c["a b"] : number >c : C ->"a b" : string +>"a b" : "a b" var r1b = C['c d']; >r1b : number >C['c d'] : number >C : typeof C ->'c d' : string +>'c d' : "c d" interface I { >I : I @@ -34,7 +34,7 @@ var r2 = i["a b"]; >r2 : number >i["a b"] : number >i : I ->"a b" : string +>"a b" : "a b" var a: { >a : { "a b": number; } @@ -45,18 +45,18 @@ var r3 = a["a b"]; >r3 : number >a["a b"] : number >a : { "a b": number; } ->"a b" : string +>"a b" : "a b" var b = { >b : { "a b": number; } >{ "a b": 1} : { "a b": number; } "a b": 1 ->1 : number +>1 : 1 } var r4 = b["a b"]; >r4 : number >b["a b"] : number >b : { "a b": number; } ->"a b" : string +>"a b" : "a b" diff --git a/tests/baselines/reference/stringPropCodeGen.types b/tests/baselines/reference/stringPropCodeGen.types index 9b061a510e1..184718982fa 100644 --- a/tests/baselines/reference/stringPropCodeGen.types +++ b/tests/baselines/reference/stringPropCodeGen.types @@ -7,7 +7,7 @@ var a = { >function() { } : () => void "bar" : 5 ->5 : number +>5 : 5 }; diff --git a/tests/baselines/reference/stringPropertyAccess.types b/tests/baselines/reference/stringPropertyAccess.types index 05409140353..fd2ec13da74 100644 --- a/tests/baselines/reference/stringPropertyAccess.types +++ b/tests/baselines/reference/stringPropertyAccess.types @@ -1,7 +1,7 @@ === tests/cases/conformance/types/primitives/string/stringPropertyAccess.ts === var x = ''; >x : string ->'' : string +>'' : "" var a = x.charAt(0); >a : string @@ -9,7 +9,7 @@ var a = x.charAt(0); >x.charAt : (pos: number) => string >x : string >charAt : (pos: number) => string ->0 : number +>0 : 0 var b = x.hasOwnProperty('charAt'); >b : boolean @@ -17,21 +17,21 @@ var b = x.hasOwnProperty('charAt'); >x.hasOwnProperty : (v: string) => boolean >x : string >hasOwnProperty : (v: string) => boolean ->'charAt' : string +>'charAt' : "charAt" var c = x['charAt'](0); >c : string >x['charAt'](0) : string >x['charAt'] : (pos: number) => string >x : string ->'charAt' : string ->0 : number +>'charAt' : "charAt" +>0 : 0 var e = x['hasOwnProperty']('toFixed'); >e : boolean >x['hasOwnProperty']('toFixed') : boolean >x['hasOwnProperty'] : (v: string) => boolean >x : string ->'hasOwnProperty' : string ->'toFixed' : string +>'hasOwnProperty' : "hasOwnProperty" +>'toFixed' : "toFixed" diff --git a/tests/baselines/reference/stringPropertyAccessWithError.errors.txt b/tests/baselines/reference/stringPropertyAccessWithError.errors.txt index fef1613bc5f..7cff28ee85d 100644 --- a/tests/baselines/reference/stringPropertyAccessWithError.errors.txt +++ b/tests/baselines/reference/stringPropertyAccessWithError.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/types/primitives/string/stringPropertyAccessWithError.ts(2,21): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/primitives/string/stringPropertyAccessWithError.ts(2,21): error TS2345: Argument of type '"invalid"' is not assignable to parameter of type 'number'. ==== tests/cases/conformance/types/primitives/string/stringPropertyAccessWithError.ts (1 errors) ==== var x = ''; var d = x['charAt']('invalid'); // error ~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. \ No newline at end of file +!!! error TS2345: Argument of type '"invalid"' is not assignable to parameter of type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/structural1.types b/tests/baselines/reference/structural1.types index 8ad3c679286..12dfb25d91d 100644 --- a/tests/baselines/reference/structural1.types +++ b/tests/baselines/reference/structural1.types @@ -23,8 +23,8 @@ module M { >f : (i: I) => void >{salt:2,pepper:0} : { salt: number; pepper: number; } >salt : number ->2 : number +>2 : 2 >pepper : number ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/styleOptions.types b/tests/baselines/reference/styleOptions.types index f0c0e93161c..fca394ed9af 100644 --- a/tests/baselines/reference/styleOptions.types +++ b/tests/baselines/reference/styleOptions.types @@ -3,11 +3,11 @@ var x = 1; >x : number ->1 : number +>1 : 1 var y = 1; >y : number ->1 : number +>1 : 1 var t = x == y; >t : boolean diff --git a/tests/baselines/reference/subtypeRelationForNever.types b/tests/baselines/reference/subtypeRelationForNever.types index c577ee07862..67c92b9b079 100644 --- a/tests/baselines/reference/subtypeRelationForNever.types +++ b/tests/baselines/reference/subtypeRelationForNever.types @@ -27,13 +27,13 @@ function withFew(values: a[], haveFew: (values: a[]) => r, haveNone: (reas >values.length : number >values : a[] >length : number ->0 : number +>0 : 0 >haveFew(values) : r >haveFew : (values: a[]) => r >values : a[] >haveNone('No values.') : r >haveNone : (reason: string) => r ->'No values.' : string +>'No values.' : "No values." } function id(value: a) : a { return value; } >id : (value: a) => a @@ -48,9 +48,9 @@ const result = withFew([1, 2, 3], id, fail); // expected result is number[] >withFew([1, 2, 3], id, fail) : number[] >withFew : (values: a[], haveFew: (values: a[]) => r, haveNone: (reason: string) => r) => r >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >id : (value: a) => a >fail : (message: string) => never diff --git a/tests/baselines/reference/subtypesOfAny.types b/tests/baselines/reference/subtypesOfAny.types index efa9fd1cd82..aebe77df12e 100644 --- a/tests/baselines/reference/subtypesOfAny.types +++ b/tests/baselines/reference/subtypesOfAny.types @@ -187,7 +187,7 @@ module f { export var bar = 1; >bar : number ->1 : number +>1 : 1 } interface I15 { >I15 : I15 @@ -210,7 +210,7 @@ module c { export var bar = 1; >bar : number ->1 : number +>1 : 1 } interface I16 { >I16 : I16 diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.types b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.types index 4059a1b0b51..99aef9e95f6 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.types +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints2.types @@ -14,14 +14,14 @@ function f1(x: T, y: U) { var r = true ? x : y; >r : U >true ? x : y : U ->true : boolean +>true : true >x : T >y : U var r = true ? y : x; >r : U >true ? y : x : U ->true : boolean +>true : true >y : U >x : T } @@ -44,14 +44,14 @@ function f2(x: T, y: U, z: V) { var r = true ? x : y; >r : U >true ? x : y : U ->true : boolean +>true : true >x : T >y : U var r = true ? y : x; >r : U >true ? y : x : U ->true : boolean +>true : true >y : U >x : T @@ -59,14 +59,14 @@ function f2(x: T, y: U, z: V) { var r2 = true ? z : y; >r2 : V >true ? z : y : V ->true : boolean +>true : true >z : V >y : U var r2 = true ? y : z; >r2 : V >true ? y : z : V ->true : boolean +>true : true >y : U >z : V @@ -74,14 +74,14 @@ function f2(x: T, y: U, z: V) { var r2a = true ? z : x; >r2a : V >true ? z : x : V ->true : boolean +>true : true >z : V >x : T var r2b = true ? x : z; >r2b : V >true ? x : z : V ->true : boolean +>true : true >x : T >z : V } @@ -101,14 +101,14 @@ function f3(x: T, y: U) { var r = true ? x : y; >r : U >true ? x : y : U ->true : boolean +>true : true >x : T >y : U var r = true ? y : x; >r : U >true ? y : x : U ->true : boolean +>true : true >y : U >x : T @@ -116,7 +116,7 @@ function f3(x: T, y: U) { var r2 = true ? x : new Date(); >r2 : Date >true ? x : new Date() : Date ->true : boolean +>true : true >x : T >new Date() : Date >Date : DateConstructor @@ -124,7 +124,7 @@ function f3(x: T, y: U) { var r2 = true ? new Date() : x; >r2 : Date >true ? new Date() : x : Date ->true : boolean +>true : true >new Date() : Date >Date : DateConstructor >x : T @@ -133,7 +133,7 @@ function f3(x: T, y: U) { var r3 = true ? y : new Date(); >r3 : Date >true ? y : new Date() : Date ->true : boolean +>true : true >y : U >new Date() : Date >Date : DateConstructor @@ -141,7 +141,7 @@ function f3(x: T, y: U) { var r3 = true ? new Date() : y; >r3 : Date >true ? new Date() : y : Date ->true : boolean +>true : true >new Date() : Date >Date : DateConstructor >y : U @@ -174,7 +174,7 @@ module f { export var bar = 1; >bar : number ->1 : number +>1 : 1 } class c { baz: string } >c : c @@ -185,7 +185,7 @@ module c { export var bar = 1; >bar : number ->1 : number +>1 : 1 } function f4(x: T) { @@ -198,14 +198,14 @@ function f4(x: T) { var r0 = true ? x : null; // ok >r0 : T >true ? x : null : T ->true : boolean +>true : true >x : T >null : null var r0 = true ? null : x; // ok >r0 : T >true ? null : x : T ->true : boolean +>true : true >null : null >x : T @@ -216,14 +216,14 @@ function f4(x: T) { var r0b = true ? u : x; // ok >r0b : any >true ? u : x : any ->true : boolean +>true : true >u : any >x : T var r0b = true ? x : u; // ok >r0b : any >true ? x : u : any ->true : boolean +>true : true >x : T >u : any } @@ -237,17 +237,17 @@ function f5(x: T) { var r1 = true ? 1 : x; // ok >r1 : number | T ->true ? 1 : x : number | T ->true : boolean ->1 : number +>true ? 1 : x : 1 | T +>true : true +>1 : 1 >x : T var r1 = true ? x : 1; // ok >r1 : number | T ->true ? x : 1 : number | T ->true : boolean +>true ? x : 1 : 1 | T +>true : true >x : T ->1 : number +>1 : 1 } function f6(x: T) { @@ -259,17 +259,17 @@ function f6(x: T) { var r2 = true ? '' : x; // ok >r2 : string | T ->true ? '' : x : string | T ->true : boolean ->'' : string +>true ? '' : x : "" | T +>true : true +>'' : "" >x : T var r2 = true ? x : ''; // ok >r2 : string | T ->true ? x : '' : string | T ->true : boolean +>true ? x : '' : "" | T +>true : true >x : T ->'' : string +>'' : "" } function f7(x: T) { @@ -281,17 +281,17 @@ function f7(x: T) { var r3 = true ? true : x; // ok >r3 : boolean | T ->true ? true : x : boolean | T ->true : boolean ->true : boolean +>true ? true : x : true | T +>true : true +>true : true >x : T var r3 = true ? x : true; // ok >r3 : boolean | T ->true ? x : true : boolean | T ->true : boolean +>true ? x : true : true | T +>true : true >x : T ->true : boolean +>true : true } function f8(x: T) { @@ -304,7 +304,7 @@ function f8(x: T) { var r4 = true ? new Date() : x; // ok >r4 : Date >true ? new Date() : x : Date ->true : boolean +>true : true >new Date() : Date >Date : DateConstructor >x : T @@ -312,7 +312,7 @@ function f8(x: T) { var r4 = true ? x : new Date(); // ok >r4 : Date >true ? x : new Date() : Date ->true : boolean +>true : true >x : T >new Date() : Date >Date : DateConstructor @@ -328,14 +328,14 @@ function f9(x: T) { var r5 = true ? /1/ : x; // ok >r5 : RegExp >true ? /1/ : x : RegExp ->true : boolean +>true : true >/1/ : RegExp >x : T var r5 = true ? x : /1/; // ok >r5 : RegExp >true ? x : /1/ : RegExp ->true : boolean +>true : true >x : T >/1/ : RegExp } @@ -350,20 +350,20 @@ function f10(x: T) { var r6 = true ? { foo: 1 } : x; // ok >r6 : { foo: number; } >true ? { foo: 1 } : x : { foo: number; } ->true : boolean +>true : true >{ foo: 1 } : { foo: number; } >foo : number ->1 : number +>1 : 1 >x : T var r6 = true ? x : { foo: 1 }; // ok >r6 : { foo: number; } >true ? x : { foo: 1 } : { foo: number; } ->true : boolean +>true : true >x : T >{ foo: 1 } : { foo: number; } >foo : number ->1 : number +>1 : 1 } function f11 void>(x: T) { @@ -375,14 +375,14 @@ function f11 void>(x: T) { var r7 = true ? () => { } : x; // ok >r7 : () => void >true ? () => { } : x : () => void ->true : boolean +>true : true >() => { } : () => void >x : T var r7 = true ? x : () => { }; // ok >r7 : () => void >true ? x : () => { } : () => void ->true : boolean +>true : true >x : T >() => { } : () => void } @@ -400,7 +400,7 @@ function f12(x: U) => U>(x: T) { var r8 = true ? (x: T) => { return x } : x; // ok >r8 : (x: T) => T >true ? (x: T) => { return x } : x : (x: T) => T ->true : boolean +>true : true >(x: T) => { return x } : (x: T) => T >T : T >x : T @@ -411,7 +411,7 @@ function f12(x: U) => U>(x: T) { var r8b = true ? x : (x: T) => { return x }; // ok, type parameters not identical across declarations >r8b : (x: T) => T >true ? x : (x: T) => { return x } : (x: T) => T ->true : boolean +>true : true >x : T >(x: T) => { return x } : (x: T) => T >T : T @@ -434,14 +434,14 @@ function f13(x: T) { var r9 = true ? i1 : x; // ok >r9 : I1 >true ? i1 : x : I1 ->true : boolean +>true : true >i1 : I1 >x : T var r9 = true ? x : i1; // ok >r9 : I1 >true ? x : i1 : I1 ->true : boolean +>true : true >x : T >i1 : I1 } @@ -460,14 +460,14 @@ function f14(x: T) { var r10 = true ? c1 : x; // ok >r10 : C1 >true ? c1 : x : C1 ->true : boolean +>true : true >c1 : C1 >x : T var r10 = true ? x : c1; // ok >r10 : C1 >true ? x : c1 : C1 ->true : boolean +>true : true >x : T >c1 : C1 } @@ -486,14 +486,14 @@ function f15>(x: T) { var r12 = true ? c2 : x; // ok >r12 : C2 >true ? c2 : x : C2 ->true : boolean +>true : true >c2 : C2 >x : T var r12 = true ? x : c2; // ok >r12 : C2 >true ? x : c2 : C2 ->true : boolean +>true : true >x : T >c2 : C2 } @@ -508,21 +508,21 @@ function f16(x: T) { var r13 = true ? E : x; // ok >r13 : T | typeof E >true ? E : x : T | typeof E ->true : boolean +>true : true >E : typeof E >x : T var r13 = true ? x : E; // ok >r13 : T | typeof E >true ? x : E : T | typeof E ->true : boolean +>true : true >x : T >E : typeof E var r14 = true ? E.A : x; // ok >r14 : E >true ? E.A : x : E ->true : boolean +>true : true >E.A : E >E : typeof E >A : E @@ -531,7 +531,7 @@ function f16(x: T) { var r14 = true ? x : E.A; // ok >r14 : E >true ? x : E.A : E ->true : boolean +>true : true >x : T >E.A : E >E : typeof E @@ -552,14 +552,14 @@ function f17(x: T) { var r15 = true ? af : x; // ok >r15 : typeof f >true ? af : x : typeof f ->true : boolean +>true : true >af : typeof f >x : T var r15 = true ? x : af; // ok >r15 : typeof f >true ? x : af : typeof f ->true : boolean +>true : true >x : T >af : typeof f } @@ -578,14 +578,14 @@ function f18(x: T) { var r16 = true ? ac : x; // ok >r16 : typeof c >true ? ac : x : typeof c ->true : boolean +>true : true >ac : typeof c >x : T var r16 = true ? x : ac; // ok >r16 : typeof c >true ? x : ac : typeof c ->true : boolean +>true : true >x : T >ac : typeof c } @@ -606,14 +606,14 @@ function f19(x: T) { var r17 = true ? x : a; // ok >r17 : T >true ? x : a : T ->true : boolean +>true : true >x : T >a : U var r17 = true ? a : x; // ok >r17 : T >true ? a : x : T ->true : boolean +>true : true >a : U >x : T } @@ -630,14 +630,14 @@ function f19(x: T) { var r18 = true ? x : a; // ok >r18 : T >true ? x : a : T ->true : boolean +>true : true >x : T >a : V var r18 = true ? a : x; // ok >r18 : T >true ? a : x : T ->true : boolean +>true : true >a : V >x : T } @@ -653,7 +653,7 @@ function f20(x: T) { var r19 = true ? new Object() : x; // ok >r19 : Object >true ? new Object() : x : Object ->true : boolean +>true : true >new Object() : Object >Object : ObjectConstructor >x : T @@ -661,7 +661,7 @@ function f20(x: T) { var r19 = true ? x : new Object(); // ok >r19 : Object >true ? x : new Object() : Object ->true : boolean +>true : true >x : T >new Object() : Object >Object : ObjectConstructor @@ -677,14 +677,14 @@ function f21(x: T) { var r20 = true ? {} : x; // ok >r20 : {} >true ? {} : x : {} ->true : boolean +>true : true >{} : {} >x : T var r20 = true ? x : {}; // ok >r20 : {} >true ? x : {} : {} ->true : boolean +>true : true >x : T >{} : {} } diff --git a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.types b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.types index f0f075a37ce..598fec51bc0 100644 --- a/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.types +++ b/tests/baselines/reference/subtypesOfTypeParameterWithConstraints3.types @@ -18,14 +18,14 @@ function f(t: T, u: U, v: V) { var r = true ? t : u; >r : U >true ? t : u : U ->true : boolean +>true : true >t : T >u : U var r = true ? u : t; >r : U >true ? u : t : U ->true : boolean +>true : true >u : U >t : T @@ -33,14 +33,14 @@ function f(t: T, u: U, v: V) { var r2 = true ? t : v; >r2 : T | V >true ? t : v : T | V ->true : boolean +>true : true >t : T >v : V var r2 = true ? v : t; >r2 : T | V >true ? v : t : T | V ->true : boolean +>true : true >v : V >t : T @@ -48,14 +48,14 @@ function f(t: T, u: U, v: V) { var r3 = true ? v : u; >r3 : U | V >true ? v : u : U | V ->true : boolean +>true : true >v : V >u : U var r3 = true ? u : v; >r3 : U | V >true ? u : v : U | V ->true : boolean +>true : true >u : U >v : V } diff --git a/tests/baselines/reference/subtypingTransitivity.types b/tests/baselines/reference/subtypingTransitivity.types index 0a41e045d98..8aabf635313 100644 --- a/tests/baselines/reference/subtypingTransitivity.types +++ b/tests/baselines/reference/subtypingTransitivity.types @@ -35,11 +35,11 @@ var d2: D2; >D2 : D2 d.x = ''; ->d.x = '' : string +>d.x = '' : "" >d.x : string >d : D >x : string ->'' : string +>'' : "" b = d; >b = d : D @@ -47,9 +47,9 @@ b = d; >d : D b.x = 1; // assigned number to string ->b.x = 1 : number +>b.x = 1 : 1 >b.x : Object >b : B >x : Object ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/subtypingWithCallSignatures.types b/tests/baselines/reference/subtypingWithCallSignatures.types index 50e773882d0..1dce48378c5 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures.types +++ b/tests/baselines/reference/subtypingWithCallSignatures.types @@ -16,19 +16,19 @@ module CallSignature { >r : (x: number) => void >foo1((x: number) => 1) : (x: number) => void >foo1 : { (cb: (x: number) => void): (x: number) => void; (cb: any): any; } ->(x: number) => 1 : (x: number) => number +>(x: number) => 1 : (x: number) => 1 >x : number ->1 : number +>1 : 1 var r2 = foo1((x: T) => ''); // ok because base returns void >r2 : (x: number) => void >foo1((x: T) => '') : (x: number) => void >foo1 : { (cb: (x: number) => void): (x: number) => void; (cb: any): any; } ->(x: T) => '' : (x: T) => string +>(x: T) => '' : (x: T) => "" >T : T >x : T >T : T ->'' : string +>'' : "" declare function foo2(cb: (x: number, y: number) => void): typeof cb; >foo2 : { (cb: (x: number, y: number) => void): (x: number, y: number) => void; (cb: any): any; } @@ -45,18 +45,18 @@ module CallSignature { >r3 : (x: number, y: number) => void >foo2((x: number, y: number) => 1) : (x: number, y: number) => void >foo2 : { (cb: (x: number, y: number) => void): (x: number, y: number) => void; (cb: any): any; } ->(x: number, y: number) => 1 : (x: number, y: number) => number +>(x: number, y: number) => 1 : (x: number, y: number) => 1 >x : number >y : number ->1 : number +>1 : 1 var r4 = foo2((x: T) => ''); // ok because base returns void >r4 : (x: number, y: number) => void >foo2((x: T) => '') : (x: number, y: number) => void >foo2 : { (cb: (x: number, y: number) => void): (x: number, y: number) => void; (cb: any): any; } ->(x: T) => '' : (x: T) => string +>(x: T) => '' : (x: T) => "" >T : T >x : T >T : T ->'' : string +>'' : "" } diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 8a56e05a9c2..8ce4b566b86 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -322,7 +322,7 @@ var r1arg2 = (x: number) => [1]; >(x: number) => [1] : (x: number) => number[] >x : number >[1] : number[] ->1 : number +>1 : 1 var r1 = foo1(r1arg1); // any, return types are not subtype of first overload >r1 : any @@ -349,14 +349,14 @@ var r2arg1 = (x: T) => ['']; >x : T >T : T >[''] : string[] ->'' : string +>'' : "" var r2arg2 = (x: number) => ['']; >r2arg2 : (x: number) => string[] >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] ->'' : string +>'' : "" var r2 = foo2(r2arg1); >r2 : (x: number) => string[] @@ -423,7 +423,7 @@ var r4arg2 = (x: string, y: number) => ''; >(x: string, y: number) => '' : (x: string, y: number) => string >x : string >y : number ->'' : string +>'' : "" var r4 = foo4(r4arg1); // any >r4 : any @@ -461,7 +461,7 @@ var r5arg2 = (x: (arg: string) => number) => ''; >(x: (arg: string) => number) => '' : (x: (arg: string) => number) => string >x : (arg: string) => number >arg : string ->'' : string +>'' : "" var r5 = foo5(r5arg1); // any >r5 : any @@ -701,7 +701,7 @@ var r10arg1 = (...x: T[]) => x[0]; >T : T >x[0] : T >x : T[] ->0 : number +>0 : 0 var r10arg2 = (...x: Derived[]) => null; >r10arg2 : (...x: Derived[]) => Derived @@ -929,7 +929,7 @@ var r16arg1 = (x: T) => [1]; >x : T >T : T >[1] : number[] ->1 : number +>1 : 1 var r16 = foo16(r16arg1); >r16 : { (x: T): number[]; (x: U): number[]; } diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 379810b2541..6abc7567efb 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -224,7 +224,7 @@ module Errors { >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] ->'' : string +>'' : "" >(x: T) => null : (x: T) => U[] >T : T >U : U @@ -248,7 +248,7 @@ module Errors { >(x: number) => [''] : (x: number) => string[] >x : number >[''] : string[] ->'' : string +>'' : "" var r2arg = (x: (arg: T) => U) => (r: T) => null; >r2arg : (x: (arg: T) => U) => (r: T) => V @@ -508,7 +508,7 @@ module Errors { >x : { a: string; b: number; } >a : string >b : number ->1 : number +>1 : 1 var r7 = foo15(r7arg); // any >r7 : any @@ -538,7 +538,7 @@ module Errors { >T : T >b : T >T : T ->1 : number +>1 : 1 var r7c = foo15(r7arg3); // (x: { a: string; b: number }) => number): number; >r7c : (x: { a: string; b: number; }) => number @@ -617,7 +617,7 @@ module WithGenericSignaturesInBaseType { >x : T >T : T >[''] : string[] ->'' : string +>'' : "" var r2 = foo2(r2arg2); // (x:T) => T[] since we can infer from generic signatures now >r2 : (x: T) => T[] diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index e76d36114e9..5926636289a 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -264,7 +264,7 @@ var r2arg = (x: T) => ['']; >x : T >T : T >[''] : string[] ->'' : string +>'' : "" var r2arg2 = (x: T) => ['']; >r2arg2 : (x: T) => string[] @@ -273,7 +273,7 @@ var r2arg2 = (x: T) => ['']; >x : T >T : T >[''] : string[] ->'' : string +>'' : "" var r2 = foo2(r2arg); >r2 : any @@ -337,7 +337,7 @@ var r4arg = (x: T, y: U) => ''; >T : T >y : U >U : U ->'' : string +>'' : "" var r4arg2 = (x: T, y: U) => ''; >r4arg2 : (x: T, y: U) => string @@ -348,7 +348,7 @@ var r4arg2 = (x: T, y: U) => ''; >T : T >y : U >U : U ->'' : string +>'' : "" var r4 = foo4(r4arg); >r4 : any diff --git a/tests/baselines/reference/subtypingWithCallSignaturesA.errors.txt b/tests/baselines/reference/subtypingWithCallSignaturesA.errors.txt index 3821c707f4b..7990c67e82e 100644 --- a/tests/baselines/reference/subtypingWithCallSignaturesA.errors.txt +++ b/tests/baselines/reference/subtypingWithCallSignaturesA.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesA.ts(2,15): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => number'. - Type 'string' is not assignable to type 'number'. +tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesA.ts(2,15): error TS2345: Argument of type '(x: number) => ""' is not assignable to parameter of type '(x: number) => number'. + Type '""' is not assignable to type 'number'. ==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithCallSignaturesA.ts (1 errors) ==== declare function foo3(cb: (x: number) => number): typeof cb; var r5 = foo3((x: number) => ''); // error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => number'. -!!! error TS2345: Type 'string' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2345: Argument of type '(x: number) => ""' is not assignable to parameter of type '(x: number) => number'. +!!! error TS2345: Type '""' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types index 815f2d60740..e0198e31d28 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality.types @@ -87,7 +87,7 @@ var b = { Foo: null }; var r = true ? a : b; >r : { Foo?: Base; } >true ? a : b : { Foo?: Base; } ->true : boolean +>true : true >a : { Foo?: Base; } >b : { Foo: Derived; } @@ -158,7 +158,7 @@ module TwoLevels { var r = true ? a : b; >r : { Foo?: Base; } >true ? a : b : { Foo?: Base; } ->true : boolean +>true : true >a : { Foo?: Base; } >b : { Foo: Derived2; } } diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality3.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality3.types index 6490b0abd9b..7f93418506f 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality3.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality3.types @@ -71,7 +71,7 @@ var b: { Foo2: Derived; } var r = true ? a : b; // ok >r : { Foo?: Base; } >true ? a : b : { Foo?: Base; } ->true : boolean +>true : true >a : { Foo?: Base; } >b : { Foo2: Derived; } diff --git a/tests/baselines/reference/subtypingWithObjectMembersOptionality4.types b/tests/baselines/reference/subtypingWithObjectMembersOptionality4.types index ee636be020b..d1d00e8e1bc 100644 --- a/tests/baselines/reference/subtypingWithObjectMembersOptionality4.types +++ b/tests/baselines/reference/subtypingWithObjectMembersOptionality4.types @@ -71,7 +71,7 @@ var b: { Foo2?: Derived; } var r = true ? a : b; // ok >r : { Foo2?: Derived; } >true ? a : b : { Foo2?: Derived; } ->true : boolean +>true : true >a : { Foo: Base; } >b : { Foo2?: Derived; } diff --git a/tests/baselines/reference/super2.types b/tests/baselines/reference/super2.types index a3807f03099..2ff73710080 100644 --- a/tests/baselines/reference/super2.types +++ b/tests/baselines/reference/super2.types @@ -7,14 +7,14 @@ class Base5 { >x : () => string return "BaseX"; ->"BaseX" : string +>"BaseX" : "BaseX" } public y() { >y : () => string return "BaseY"; ->"BaseY" : string +>"BaseY" : "BaseY" } } @@ -26,7 +26,7 @@ class Sub5 extends Base5 { >x : () => string return "SubX"; ->"SubX" : string +>"SubX" : "SubX" } } @@ -62,7 +62,7 @@ class Base6 { >x : () => string return "BaseX"; ->"BaseX" : string +>"BaseX" : "BaseX" } } @@ -74,7 +74,7 @@ class Sub6 extends Base6 { >y : () => string return "SubY"; ->"SubY" : string +>"SubY" : "SubY" } } diff --git a/tests/baselines/reference/superCallArgsMustMatch.errors.txt b/tests/baselines/reference/superCallArgsMustMatch.errors.txt index 06758b44fe6..f5724a710d1 100644 --- a/tests/baselines/reference/superCallArgsMustMatch.errors.txt +++ b/tests/baselines/reference/superCallArgsMustMatch.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/superCallArgsMustMatch.ts(17,15): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/compiler/superCallArgsMustMatch.ts(17,15): error TS2345: Argument of type '"hi"' is not assignable to parameter of type 'number'. ==== tests/cases/compiler/superCallArgsMustMatch.ts (1 errors) ==== @@ -20,7 +20,7 @@ tests/cases/compiler/superCallArgsMustMatch.ts(17,15): error TS2345: Argument of // which is instantiated with 'number' in the extends clause super("hi"); ~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"hi"' is not assignable to parameter of type 'number'. var x: number = this.foo; diff --git a/tests/baselines/reference/superCallAssignResult.errors.txt b/tests/baselines/reference/superCallAssignResult.errors.txt index bc9e2a0dc55..524866f28f1 100644 --- a/tests/baselines/reference/superCallAssignResult.errors.txt +++ b/tests/baselines/reference/superCallAssignResult.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/superCallAssignResult.ts(8,9): error TS2322: Type 'number' is not assignable to type 'void'. +tests/cases/compiler/superCallAssignResult.ts(8,9): error TS2322: Type '5' is not assignable to type 'void'. ==== tests/cases/compiler/superCallAssignResult.ts (1 errors) ==== @@ -11,6 +11,6 @@ tests/cases/compiler/superCallAssignResult.ts(8,9): error TS2322: Type 'number' var x = super(5); // Should be of type void, not E. x = 5; ~ -!!! error TS2322: Type 'number' is not assignable to type 'void'. +!!! error TS2322: Type '5' is not assignable to type 'void'. } } \ No newline at end of file diff --git a/tests/baselines/reference/superCalls.types b/tests/baselines/reference/superCalls.types index ce5353df329..ad5f0806c44 100644 --- a/tests/baselines/reference/superCalls.types +++ b/tests/baselines/reference/superCalls.types @@ -4,7 +4,7 @@ class Base { x = 43; >x : number ->43 : number +>43 : 43 constructor(n: string) { >n : string @@ -26,14 +26,14 @@ class Derived extends Base { super(''); >super('') : void >super : typeof Base ->'' : string +>'' : "" //type of super call expression is void var p = super(''); >p : void >super('') : void >super : typeof Base ->'' : string +>'' : "" var p = v(); >p : void @@ -54,7 +54,7 @@ class OtherDerived extends OtherBase { constructor() { var p = ''; >p : string ->'' : string +>'' : "" super(); >super() : void diff --git a/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.types b/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.types index d435bff69b5..78af8fdf0b9 100644 --- a/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.types +++ b/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES5.types @@ -4,7 +4,7 @@ class A { foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } class B extends A { @@ -13,7 +13,7 @@ class B extends A { foo() { return 2; } >foo : () => number ->2 : number +>2 : 2 bar() { >bar : () => typeof (Anonymous class) @@ -28,7 +28,7 @@ class B extends A { >foo : () => number return 100; ->100 : number +>100 : 100 } } } diff --git a/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES6.types b/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES6.types index 817e3b73ba4..0e3d295fc88 100644 --- a/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES6.types +++ b/tests/baselines/reference/superPropertyAccessInComputedPropertiesOfNestedType_ES6.types @@ -4,7 +4,7 @@ class A { foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } class B extends A { @@ -13,7 +13,7 @@ class B extends A { foo() { return 2; } >foo : () => number ->2 : number +>2 : 2 bar() { >bar : () => typeof (Anonymous class) @@ -28,7 +28,7 @@ class B extends A { >foo : () => number return 100; ->100 : number +>100 : 100 } } } diff --git a/tests/baselines/reference/superPropertyAccessNoError.types b/tests/baselines/reference/superPropertyAccessNoError.types index b982b2ab694..f1e6101c421 100644 --- a/tests/baselines/reference/superPropertyAccessNoError.types +++ b/tests/baselines/reference/superPropertyAccessNoError.types @@ -14,14 +14,14 @@ class SomeBaseClass { >func : () => string return ''; ->'' : string +>'' : "" } static func() { >func : () => number return 3; ->3 : number +>3 : 3 } returnThis() { diff --git a/tests/baselines/reference/superPropertyAccess_ES6.types b/tests/baselines/reference/superPropertyAccess_ES6.types index b10b1944a44..bb4082a73cf 100644 --- a/tests/baselines/reference/superPropertyAccess_ES6.types +++ b/tests/baselines/reference/superPropertyAccess_ES6.types @@ -5,11 +5,11 @@ class MyBase { getValue(): number { return 1; } >getValue : () => number ->1 : number +>1 : 1 get value(): number { return 1; } >value : number ->1 : number +>1 : 1 } class MyDerived extends MyBase { @@ -84,6 +84,6 @@ class B extends A { >property : string >value + " addition" : string >value : string ->" addition" : string +>" addition" : " addition" } } diff --git a/tests/baselines/reference/superSymbolIndexedAccess1.types b/tests/baselines/reference/superSymbolIndexedAccess1.types index af2c6cab156..ab09528b04b 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess1.types +++ b/tests/baselines/reference/superSymbolIndexedAccess1.types @@ -5,7 +5,7 @@ var symbol = Symbol.for('myThing'); >Symbol.for : (key: string) => symbol >Symbol : SymbolConstructor >for : (key: string) => symbol ->'myThing' : string +>'myThing' : "myThing" class Foo { >Foo : Foo @@ -14,7 +14,7 @@ class Foo { >symbol : symbol return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/superSymbolIndexedAccess2.types b/tests/baselines/reference/superSymbolIndexedAccess2.types index 72bb6914d3e..61c760dfac7 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess2.types +++ b/tests/baselines/reference/superSymbolIndexedAccess2.types @@ -9,7 +9,7 @@ class Foo { >isConcatSpreadable : symbol return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/superSymbolIndexedAccess5.types b/tests/baselines/reference/superSymbolIndexedAccess5.types index abc3ba364b0..745fd81b8f8 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess5.types +++ b/tests/baselines/reference/superSymbolIndexedAccess5.types @@ -9,7 +9,7 @@ class Foo { >symbol : any return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/superSymbolIndexedAccess6.types b/tests/baselines/reference/superSymbolIndexedAccess6.types index 830ade0c685..11c4a0e553b 100644 --- a/tests/baselines/reference/superSymbolIndexedAccess6.types +++ b/tests/baselines/reference/superSymbolIndexedAccess6.types @@ -9,7 +9,7 @@ class Foo { >symbol : any return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/switchAssignmentCompat.errors.txt b/tests/baselines/reference/switchAssignmentCompat.errors.txt index 747a1035b68..46c89fa5b52 100644 --- a/tests/baselines/reference/switchAssignmentCompat.errors.txt +++ b/tests/baselines/reference/switchAssignmentCompat.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/switchAssignmentCompat.ts(4,10): error TS2678: Type 'typeof Foo' is not comparable to type 'number'. +tests/cases/compiler/switchAssignmentCompat.ts(4,10): error TS2678: Type 'typeof Foo' is not comparable to type '0'. ==== tests/cases/compiler/switchAssignmentCompat.ts (1 errors) ==== @@ -7,6 +7,6 @@ tests/cases/compiler/switchAssignmentCompat.ts(4,10): error TS2678: Type 'typeof switch (0) { case Foo: break; // Error expected ~~~ -!!! error TS2678: Type 'typeof Foo' is not comparable to type 'number'. +!!! error TS2678: Type 'typeof Foo' is not comparable to type '0'. } \ No newline at end of file diff --git a/tests/baselines/reference/switchBreakStatements.errors.txt b/tests/baselines/reference/switchBreakStatements.errors.txt new file mode 100644 index 00000000000..229c42068c3 --- /dev/null +++ b/tests/baselines/reference/switchBreakStatements.errors.txt @@ -0,0 +1,92 @@ +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(3,10): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(9,10): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(16,10): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(22,10): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(25,18): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(31,10): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(34,18): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(41,10): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(43,18): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(45,26): error TS2678: Type '"a"' is not comparable to type '""'. +tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts(49,34): error TS2678: Type '"a"' is not comparable to type '""'. + + +==== tests/cases/conformance/statements/breakStatements/switchBreakStatements.ts (11 errors) ==== + + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + break; + } + + ONE: + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + break ONE; + } + + TWO: + THREE: + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + break THREE; + } + + FOUR: + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + FIVE: + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + break FOUR; + } + } + + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + SIX: + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + break SIX; + } + } + + SEVEN: + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + break SEVEN; + EIGHT: + switch ('') { + case 'a': + ~~~ +!!! error TS2678: Type '"a"' is not comparable to type '""'. + var fn = function () { } + break EIGHT; + } + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/switchCases.errors.txt b/tests/baselines/reference/switchCases.errors.txt new file mode 100644 index 00000000000..205f8aae8c7 --- /dev/null +++ b/tests/baselines/reference/switchCases.errors.txt @@ -0,0 +1,11 @@ +tests/cases/compiler/switchCases.ts(2,7): error TS2678: Type '1' is not comparable to type '0'. + + +==== tests/cases/compiler/switchCases.ts (1 errors) ==== + switch(0) { + case 1: + ~ +!!! error TS2678: Type '1' is not comparable to type '0'. + break; + } + \ No newline at end of file diff --git a/tests/baselines/reference/switchCasesExpressionTypeMismatch.errors.txt b/tests/baselines/reference/switchCasesExpressionTypeMismatch.errors.txt index e430b33097c..3ea12e2460f 100644 --- a/tests/baselines/reference/switchCasesExpressionTypeMismatch.errors.txt +++ b/tests/baselines/reference/switchCasesExpressionTypeMismatch.errors.txt @@ -1,22 +1,25 @@ -tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(4,10): error TS2678: Type 'typeof Foo' is not comparable to type 'number'. -tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(5,10): error TS2678: Type '"sss"' is not comparable to type 'number'. -tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(7,10): error TS2678: Type 'true' is not comparable to type 'number'. +tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(4,10): error TS2678: Type 'typeof Foo' is not comparable to type '0'. +tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(5,10): error TS2678: Type '"sss"' is not comparable to type '0'. +tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(6,10): error TS2678: Type '123' is not comparable to type '0'. +tests/cases/compiler/switchCasesExpressionTypeMismatch.ts(7,10): error TS2678: Type 'true' is not comparable to type '0'. -==== tests/cases/compiler/switchCasesExpressionTypeMismatch.ts (3 errors) ==== +==== tests/cases/compiler/switchCasesExpressionTypeMismatch.ts (4 errors) ==== class Foo { } switch (0) { case Foo: break; // Error ~~~ -!!! error TS2678: Type 'typeof Foo' is not comparable to type 'number'. +!!! error TS2678: Type 'typeof Foo' is not comparable to type '0'. case "sss": break; // Error ~~~~~ -!!! error TS2678: Type '"sss"' is not comparable to type 'number'. +!!! error TS2678: Type '"sss"' is not comparable to type '0'. case 123: break; // No Error + ~~~ +!!! error TS2678: Type '123' is not comparable to type '0'. case true: break; // Error ~~~~ -!!! error TS2678: Type 'true' is not comparable to type 'number'. +!!! error TS2678: Type 'true' is not comparable to type '0'. } var s: any = 0; diff --git a/tests/baselines/reference/switchFallThroughs.types b/tests/baselines/reference/switchFallThroughs.types index cd0af6693eb..3e0f0276846 100644 --- a/tests/baselines/reference/switchFallThroughs.types +++ b/tests/baselines/reference/switchFallThroughs.types @@ -17,7 +17,7 @@ function R1(index: number) { var a = 'a'; >a : string ->'a' : string +>'a' : "a" return a; >a : string @@ -29,14 +29,14 @@ function R1(index: number) { >4 : 4 return 'b'; ->'b' : string +>'b' : "b" } case 5: >5 : 5 default: return 'c'; ->'c' : string +>'c' : "c" } } diff --git a/tests/baselines/reference/symbolDeclarationEmit10.types b/tests/baselines/reference/symbolDeclarationEmit10.types index 0d8d54c28de..d7f5c861e89 100644 --- a/tests/baselines/reference/symbolDeclarationEmit10.types +++ b/tests/baselines/reference/symbolDeclarationEmit10.types @@ -7,7 +7,7 @@ var obj = { >Symbol.isConcatSpreadable : symbol >Symbol : SymbolConstructor >isConcatSpreadable : symbol ->'' : string +>'' : "" set [Symbol.isConcatSpreadable](x) { } >Symbol.isConcatSpreadable : symbol diff --git a/tests/baselines/reference/symbolDeclarationEmit11.types b/tests/baselines/reference/symbolDeclarationEmit11.types index 30f92266eb2..d75c3683e97 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.types +++ b/tests/baselines/reference/symbolDeclarationEmit11.types @@ -6,7 +6,7 @@ class C { >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->0 : number +>0 : 0 static [Symbol.isConcatSpreadable]() { } >Symbol.isConcatSpreadable : symbol @@ -17,7 +17,7 @@ class C { >Symbol.toPrimitive : symbol >Symbol : SymbolConstructor >toPrimitive : symbol ->"" : string +>"" : "" static set [Symbol.toPrimitive](x) { } >Symbol.toPrimitive : symbol diff --git a/tests/baselines/reference/symbolDeclarationEmit13.types b/tests/baselines/reference/symbolDeclarationEmit13.types index ce77ec9b38b..9fa17acdc10 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.types +++ b/tests/baselines/reference/symbolDeclarationEmit13.types @@ -6,7 +6,7 @@ class C { >Symbol.toPrimitive : symbol >Symbol : SymbolConstructor >toPrimitive : symbol ->"" : string +>"" : "" set [Symbol.toStringTag](x) { } >Symbol.toStringTag : symbol diff --git a/tests/baselines/reference/symbolDeclarationEmit14.types b/tests/baselines/reference/symbolDeclarationEmit14.types index 5e975a6eae4..daf7b6d5731 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.types +++ b/tests/baselines/reference/symbolDeclarationEmit14.types @@ -6,11 +6,11 @@ class C { >Symbol.toPrimitive : symbol >Symbol : SymbolConstructor >toPrimitive : symbol ->"" : string +>"" : "" get [Symbol.toStringTag]() { return ""; } >Symbol.toStringTag : symbol >Symbol : SymbolConstructor >toStringTag : symbol ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/symbolDeclarationEmit2.types b/tests/baselines/reference/symbolDeclarationEmit2.types index 10727836712..23d2fac2de8 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.types +++ b/tests/baselines/reference/symbolDeclarationEmit2.types @@ -6,5 +6,5 @@ class C { >Symbol.toPrimitive : symbol >Symbol : SymbolConstructor >toPrimitive : symbol ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/symbolDeclarationEmit4.types b/tests/baselines/reference/symbolDeclarationEmit4.types index 51e4135b498..f9fa6dc581c 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.types +++ b/tests/baselines/reference/symbolDeclarationEmit4.types @@ -6,7 +6,7 @@ class C { >Symbol.toPrimitive : symbol >Symbol : SymbolConstructor >toPrimitive : symbol ->"" : string +>"" : "" set [Symbol.toPrimitive](x) { } >Symbol.toPrimitive : symbol diff --git a/tests/baselines/reference/symbolDeclarationEmit8.types b/tests/baselines/reference/symbolDeclarationEmit8.types index e14bc5c395b..4e8bfc9a9af 100644 --- a/tests/baselines/reference/symbolDeclarationEmit8.types +++ b/tests/baselines/reference/symbolDeclarationEmit8.types @@ -7,5 +7,5 @@ var obj = { >Symbol.isConcatSpreadable : symbol >Symbol : SymbolConstructor >isConcatSpreadable : symbol ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/symbolProperty1.types b/tests/baselines/reference/symbolProperty1.types index 667e51fda8a..4af154f7b27 100644 --- a/tests/baselines/reference/symbolProperty1.types +++ b/tests/baselines/reference/symbolProperty1.types @@ -8,7 +8,7 @@ var x = { [s]: 0, >s : symbol ->0 : number +>0 : 0 [s]() { }, >s : symbol @@ -17,6 +17,6 @@ var x = { >s : symbol return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/symbolProperty18.types b/tests/baselines/reference/symbolProperty18.types index 681f86af117..97b4de9897c 100644 --- a/tests/baselines/reference/symbolProperty18.types +++ b/tests/baselines/reference/symbolProperty18.types @@ -7,13 +7,13 @@ var i = { >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->0 : number +>0 : 0 [Symbol.toStringTag]() { return "" }, >Symbol.toStringTag : symbol >Symbol : SymbolConstructor >toStringTag : symbol ->"" : string +>"" : "" set [Symbol.toPrimitive](p: boolean) { } >Symbol.toPrimitive : symbol diff --git a/tests/baselines/reference/symbolProperty2.types b/tests/baselines/reference/symbolProperty2.types index 7584c6461e8..18aafb5afb5 100644 --- a/tests/baselines/reference/symbolProperty2.types +++ b/tests/baselines/reference/symbolProperty2.types @@ -10,7 +10,7 @@ var x = { [s]: 0, >s : symbol ->0 : number +>0 : 0 [s]() { }, >s : symbol @@ -19,6 +19,6 @@ var x = { >s : symbol return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/symbolProperty22.types b/tests/baselines/reference/symbolProperty22.types index 29d16b1553e..628164f3929 100644 --- a/tests/baselines/reference/symbolProperty22.types +++ b/tests/baselines/reference/symbolProperty22.types @@ -28,7 +28,7 @@ declare function foo(p1: T, p2: I): U; foo("", { [Symbol.unscopables]: s => s.length }); >foo("", { [Symbol.unscopables]: s => s.length }) : number >foo : (p1: T, p2: I) => U ->"" : string +>"" : "" >{ [Symbol.unscopables]: s => s.length } : { [Symbol.unscopables]: (s: string) => number; } >Symbol.unscopables : symbol >Symbol : SymbolConstructor diff --git a/tests/baselines/reference/symbolProperty23.types b/tests/baselines/reference/symbolProperty23.types index b34a208a907..c4a9d6765dd 100644 --- a/tests/baselines/reference/symbolProperty23.types +++ b/tests/baselines/reference/symbolProperty23.types @@ -18,6 +18,6 @@ class C implements I { >toPrimitive : symbol return true; ->true : boolean +>true : true } } diff --git a/tests/baselines/reference/symbolProperty26.types b/tests/baselines/reference/symbolProperty26.types index 386761c98f9..cde412000db 100644 --- a/tests/baselines/reference/symbolProperty26.types +++ b/tests/baselines/reference/symbolProperty26.types @@ -8,7 +8,7 @@ class C1 { >toStringTag : symbol return ""; ->"" : string +>"" : "" } } @@ -22,6 +22,6 @@ class C2 extends C1 { >toStringTag : symbol return ""; ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/symbolProperty27.types b/tests/baselines/reference/symbolProperty27.types index d8ff2f2f116..2c138b5a9d0 100644 --- a/tests/baselines/reference/symbolProperty27.types +++ b/tests/baselines/reference/symbolProperty27.types @@ -22,6 +22,6 @@ class C2 extends C1 { >toStringTag : symbol return ""; ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/symbolProperty28.types b/tests/baselines/reference/symbolProperty28.types index 6eddebf44d8..2a7b5fabf79 100644 --- a/tests/baselines/reference/symbolProperty28.types +++ b/tests/baselines/reference/symbolProperty28.types @@ -10,7 +10,7 @@ class C1 { return { x: "" }; >{ x: "" } : { x: string; } >x : string ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/symbolProperty4.types b/tests/baselines/reference/symbolProperty4.types index 7bcf3f23397..abcf4451b03 100644 --- a/tests/baselines/reference/symbolProperty4.types +++ b/tests/baselines/reference/symbolProperty4.types @@ -6,7 +6,7 @@ var x = { [Symbol()]: 0, >Symbol() : symbol >Symbol : SymbolConstructor ->0 : number +>0 : 0 [Symbol()]() { }, >Symbol() : symbol @@ -17,6 +17,6 @@ var x = { >Symbol : SymbolConstructor return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/symbolProperty40.types b/tests/baselines/reference/symbolProperty40.types index c349a705a29..efe6600d535 100644 --- a/tests/baselines/reference/symbolProperty40.types +++ b/tests/baselines/reference/symbolProperty40.types @@ -37,7 +37,7 @@ c[Symbol.iterator](""); >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->"" : string +>"" : "" c[Symbol.iterator](0); >c[Symbol.iterator](0) : number @@ -46,5 +46,5 @@ c[Symbol.iterator](0); >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/symbolProperty41.types b/tests/baselines/reference/symbolProperty41.types index f312481ac04..5eebd107659 100644 --- a/tests/baselines/reference/symbolProperty41.types +++ b/tests/baselines/reference/symbolProperty41.types @@ -40,7 +40,7 @@ c[Symbol.iterator](""); >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->"" : string +>"" : "" c[Symbol.iterator]("hello"); >c[Symbol.iterator]("hello") : { x: string; hello: string; } diff --git a/tests/baselines/reference/symbolProperty45.types b/tests/baselines/reference/symbolProperty45.types index 946ceeb9ea1..cb0fbdffc53 100644 --- a/tests/baselines/reference/symbolProperty45.types +++ b/tests/baselines/reference/symbolProperty45.types @@ -8,7 +8,7 @@ class C { >hasInstance : symbol return ""; ->"" : string +>"" : "" } get [Symbol.toPrimitive]() { >Symbol.toPrimitive : symbol @@ -16,6 +16,6 @@ class C { >toPrimitive : symbol return ""; ->"" : string +>"" : "" } } diff --git a/tests/baselines/reference/symbolProperty46.errors.txt b/tests/baselines/reference/symbolProperty46.errors.txt index 68f86afc315..3756f2c5271 100644 --- a/tests/baselines/reference/symbolProperty46.errors.txt +++ b/tests/baselines/reference/symbolProperty46.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/Symbols/symbolProperty46.ts(10,1): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/es6/Symbols/symbolProperty46.ts(10,1): error TS2322: Type '0' is not assignable to type 'string'. ==== tests/cases/conformance/es6/Symbols/symbolProperty46.ts (1 errors) ==== @@ -13,5 +13,5 @@ tests/cases/conformance/es6/Symbols/symbolProperty46.ts(10,1): error TS2322: Typ (new C)[Symbol.hasInstance] = 0; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '0' is not assignable to type 'string'. (new C)[Symbol.hasInstance] = ""; \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty47.errors.txt b/tests/baselines/reference/symbolProperty47.errors.txt index b35650f94bb..2e15085eb24 100644 --- a/tests/baselines/reference/symbolProperty47.errors.txt +++ b/tests/baselines/reference/symbolProperty47.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/es6/Symbols/symbolProperty47.ts(3,16): error TS2322: Type 'string' is not assignable to type 'number'. -tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty47.ts(3,16): error TS2322: Type '""' is not assignable to type 'number'. +tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Type '""' is not assignable to type 'number'. ==== tests/cases/conformance/es6/Symbols/symbolProperty47.ts (2 errors) ==== @@ -7,7 +7,7 @@ tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Typ get [Symbol.hasInstance]() { return ""; ~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '""' is not assignable to type 'number'. } // Should take a string set [Symbol.hasInstance](x: number) { @@ -17,4 +17,4 @@ tests/cases/conformance/es6/Symbols/symbolProperty47.ts(11,1): error TS2322: Typ (new C)[Symbol.hasInstance] = 0; (new C)[Symbol.hasInstance] = ""; ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type '""' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/symbolProperty5.types b/tests/baselines/reference/symbolProperty5.types index b338f94f6d3..833b6aa525d 100644 --- a/tests/baselines/reference/symbolProperty5.types +++ b/tests/baselines/reference/symbolProperty5.types @@ -7,7 +7,7 @@ var x = { >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->0 : number +>0 : 0 [Symbol.toPrimitive]() { }, >Symbol.toPrimitive : symbol @@ -20,6 +20,6 @@ var x = { >toStringTag : symbol return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/symbolProperty55.types b/tests/baselines/reference/symbolProperty55.types index 8c438bbf445..3d56c268267 100644 --- a/tests/baselines/reference/symbolProperty55.types +++ b/tests/baselines/reference/symbolProperty55.types @@ -7,7 +7,7 @@ var obj = { >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->0 : number +>0 : 0 }; diff --git a/tests/baselines/reference/symbolProperty56.types b/tests/baselines/reference/symbolProperty56.types index 87998908745..63f6317e219 100644 --- a/tests/baselines/reference/symbolProperty56.types +++ b/tests/baselines/reference/symbolProperty56.types @@ -7,7 +7,7 @@ var obj = { >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->0 : number +>0 : 0 }; @@ -24,5 +24,5 @@ module M { >obj : { [Symbol.iterator]: number; } >Symbol["iterator"] : any >Symbol : {} ->"iterator" : string +>"iterator" : "iterator" } diff --git a/tests/baselines/reference/symbolProperty57.types b/tests/baselines/reference/symbolProperty57.types index b0c02052e58..6a4920b8e2f 100644 --- a/tests/baselines/reference/symbolProperty57.types +++ b/tests/baselines/reference/symbolProperty57.types @@ -7,7 +7,7 @@ var obj = { >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->0 : number +>0 : 0 }; @@ -17,5 +17,5 @@ obj[Symbol["nonsense"]]; >obj : { [Symbol.iterator]: number; } >Symbol["nonsense"] : any >Symbol : SymbolConstructor ->"nonsense" : string +>"nonsense" : "nonsense" diff --git a/tests/baselines/reference/symbolProperty6.types b/tests/baselines/reference/symbolProperty6.types index a378acf1bbe..a9fe1178e07 100644 --- a/tests/baselines/reference/symbolProperty6.types +++ b/tests/baselines/reference/symbolProperty6.types @@ -6,7 +6,7 @@ class C { >Symbol.iterator : symbol >Symbol : SymbolConstructor >iterator : symbol ->0 : number +>0 : 0 [Symbol.unscopables]: number; >Symbol.unscopables : symbol @@ -24,6 +24,6 @@ class C { >toStringTag : symbol return 0; ->0 : number +>0 : 0 } } diff --git a/tests/baselines/reference/symbolType11.types b/tests/baselines/reference/symbolType11.types index 903c4ec0ecc..ec474dcdb54 100644 --- a/tests/baselines/reference/symbolType11.types +++ b/tests/baselines/reference/symbolType11.types @@ -5,7 +5,7 @@ var s = Symbol.for("logical"); >Symbol.for : (key: string) => symbol >Symbol : SymbolConstructor >for : (key: string) => symbol ->"logical" : string +>"logical" : "logical" s && s; >s && s : symbol @@ -18,8 +18,8 @@ s && []; >[] : undefined[] 0 && s; ->0 && s : symbol ->0 : number +>0 && s : 0 +>0 : 0 >s : symbol s || s; @@ -28,9 +28,9 @@ s || s; >s : symbol s || 1; ->s || 1 : number | symbol +>s || 1 : symbol | 1 >s : symbol ->1 : number +>1 : 1 ({}) || s; >({}) || s : {} diff --git a/tests/baselines/reference/symbolType12.errors.txt b/tests/baselines/reference/symbolType12.errors.txt index adceb58ae56..b6034c62eec 100644 --- a/tests/baselines/reference/symbolType12.errors.txt +++ b/tests/baselines/reference/symbolType12.errors.txt @@ -8,7 +8,7 @@ tests/cases/conformance/es6/Symbols/symbolType12.ts(7,1): error TS2362: The left tests/cases/conformance/es6/Symbols/symbolType12.ts(7,6): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType12.ts(8,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType12.ts(9,1): error TS2365: Operator '+=' cannot be applied to types 'symbol' and 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType12.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'symbol' and 'number'. +tests/cases/conformance/es6/Symbols/symbolType12.ts(10,1): error TS2365: Operator '+=' cannot be applied to types 'symbol' and '0'. tests/cases/conformance/es6/Symbols/symbolType12.ts(11,1): error TS2469: The '+=' operator cannot be applied to type 'symbol'. tests/cases/conformance/es6/Symbols/symbolType12.ts(12,8): error TS2469: The '+=' operator cannot be applied to type 'symbol'. tests/cases/conformance/es6/Symbols/symbolType12.ts(13,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. @@ -67,7 +67,7 @@ tests/cases/conformance/es6/Symbols/symbolType12.ts(28,8): error TS2469: The '+= !!! error TS2365: Operator '+=' cannot be applied to types 'symbol' and 'symbol'. s += 0; ~~~~~~ -!!! error TS2365: Operator '+=' cannot be applied to types 'symbol' and 'number'. +!!! error TS2365: Operator '+=' cannot be applied to types 'symbol' and '0'. s += ""; ~ !!! error TS2469: The '+=' operator cannot be applied to type 'symbol'. diff --git a/tests/baselines/reference/symbolType6.errors.txt b/tests/baselines/reference/symbolType6.errors.txt index 29d894c2afb..42940ac1961 100644 --- a/tests/baselines/reference/symbolType6.errors.txt +++ b/tests/baselines/reference/symbolType6.errors.txt @@ -3,10 +3,10 @@ tests/cases/conformance/es6/Symbols/symbolType6.ts(4,1): error TS2362: The left- tests/cases/conformance/es6/Symbols/symbolType6.ts(4,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType6.ts(5,1): error TS2469: The '+' operator cannot be applied to type 'symbol'. tests/cases/conformance/es6/Symbols/symbolType6.ts(6,1): error TS2469: The '+' operator cannot be applied to type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType6.ts(7,1): error TS2365: Operator '+' cannot be applied to types 'symbol' and 'number'. +tests/cases/conformance/es6/Symbols/symbolType6.ts(7,1): error TS2365: Operator '+' cannot be applied to types 'symbol' and '0'. tests/cases/conformance/es6/Symbols/symbolType6.ts(8,6): error TS2469: The '+' operator cannot be applied to type 'symbol'. tests/cases/conformance/es6/Symbols/symbolType6.ts(9,5): error TS2469: The '+' operator cannot be applied to type 'symbol'. -tests/cases/conformance/es6/Symbols/symbolType6.ts(10,1): error TS2365: Operator '+' cannot be applied to types 'number' and 'symbol'. +tests/cases/conformance/es6/Symbols/symbolType6.ts(10,1): error TS2365: Operator '+' cannot be applied to types '0' and 'symbol'. tests/cases/conformance/es6/Symbols/symbolType6.ts(11,1): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType6.ts(12,5): error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. tests/cases/conformance/es6/Symbols/symbolType6.ts(14,1): error TS2469: The '+' operator cannot be applied to type 'symbol'. @@ -32,7 +32,7 @@ tests/cases/conformance/es6/Symbols/symbolType6.ts(15,6): error TS2469: The '+' !!! error TS2469: The '+' operator cannot be applied to type 'symbol'. s + 0; ~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'symbol' and 'number'. +!!! error TS2365: Operator '+' cannot be applied to types 'symbol' and '0'. "" + s; ~ !!! error TS2469: The '+' operator cannot be applied to type 'symbol'. @@ -41,7 +41,7 @@ tests/cases/conformance/es6/Symbols/symbolType6.ts(15,6): error TS2469: The '+' !!! error TS2469: The '+' operator cannot be applied to type 'symbol'. 0 + s; ~~~~~ -!!! error TS2365: Operator '+' cannot be applied to types 'number' and 'symbol'. +!!! error TS2365: Operator '+' cannot be applied to types '0' and 'symbol'. s - 0; ~ !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type. diff --git a/tests/baselines/reference/systemModule1.types b/tests/baselines/reference/systemModule1.types index 2adf73d116f..927b88f4b54 100644 --- a/tests/baselines/reference/systemModule1.types +++ b/tests/baselines/reference/systemModule1.types @@ -2,5 +2,5 @@ export var x = 1; >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/systemModule13.types b/tests/baselines/reference/systemModule13.types index f31b0825416..ec85746d2bb 100644 --- a/tests/baselines/reference/systemModule13.types +++ b/tests/baselines/reference/systemModule13.types @@ -5,9 +5,9 @@ export let [x,y,z] = [1, 2, 3]; >y : number >z : number >[1, 2, 3] : [number, number, number] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; >a : any @@ -17,16 +17,16 @@ export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; >z1 : string >{a: true, b: {c: "123"}} : { a: boolean; b: { c: string; }; } >a : boolean ->true : boolean +>true : true >b : { c: string; } >{c: "123"} : { c: string; } >c : string ->"123" : string +>"123" : "123" for ([x] of [[1]]) {} >[x] : [number] >x : number >[[1]] : number[][] >[1] : number[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/systemModule15.types b/tests/baselines/reference/systemModule15.types index 502638dab93..b3f5c043404 100644 --- a/tests/baselines/reference/systemModule15.types +++ b/tests/baselines/reference/systemModule15.types @@ -58,7 +58,7 @@ export { export var value = "youpi"; >value : string ->"youpi" : string +>"youpi" : "youpi" export default value; >value : string @@ -67,5 +67,5 @@ export default value; export var value2 = "v"; >value2 : string ->"v" : string +>"v" : "v" diff --git a/tests/baselines/reference/systemModule17.types b/tests/baselines/reference/systemModule17.types index 1f0b1b51842..c0a0a7dc584 100644 --- a/tests/baselines/reference/systemModule17.types +++ b/tests/baselines/reference/systemModule17.types @@ -11,7 +11,7 @@ export interface I {} var x = 1; >x : number ->1 : number +>1 : 1 interface I { } >I : I @@ -21,7 +21,7 @@ namespace N { export var x = 1; >x : number ->1 : number +>1 : 1 export interface I { } >I : I diff --git a/tests/baselines/reference/systemModule4.types b/tests/baselines/reference/systemModule4.types index 2029cdb88d7..8a871a987a7 100644 --- a/tests/baselines/reference/systemModule4.types +++ b/tests/baselines/reference/systemModule4.types @@ -2,7 +2,7 @@ export var x = 1; >x : number ->1 : number +>1 : 1 export var y; >y : any diff --git a/tests/baselines/reference/systemModule7.types b/tests/baselines/reference/systemModule7.types index 650e2d6cdb1..33003f5fa37 100644 --- a/tests/baselines/reference/systemModule7.types +++ b/tests/baselines/reference/systemModule7.types @@ -6,7 +6,7 @@ export module M { var x = 1; >x : number ->1 : number +>1 : 1 } // filename: nonInstantiatedModule.ts diff --git a/tests/baselines/reference/systemModule8.types b/tests/baselines/reference/systemModule8.types index 940067c5653..f31e77c346d 100644 --- a/tests/baselines/reference/systemModule8.types +++ b/tests/baselines/reference/systemModule8.types @@ -4,9 +4,9 @@ export var x; >x : any x = 1; ->x = 1 : number +>x = 1 : 1 >x : any ->1 : number +>1 : 1 x++; >x++ : number @@ -27,98 +27,98 @@ x--; x += 1; >x += 1 : any >x : any ->1 : number +>1 : 1 x -= 1; >x -= 1 : number >x : any ->1 : number +>1 : 1 x *= 1; >x *= 1 : number >x : any ->1 : number +>1 : 1 x /= 1; >x /= 1 : number >x : any ->1 : number +>1 : 1 x |= 1; >x |= 1 : number >x : any ->1 : number +>1 : 1 x &= 1; >x &= 1 : number >x : any ->1 : number +>1 : 1 x + 1; >x + 1 : any >x : any ->1 : number +>1 : 1 x - 1; >x - 1 : number >x : any ->1 : number +>1 : 1 x & 1; >x & 1 : number >x : any ->1 : number +>1 : 1 x | 1; >x | 1 : number >x : any ->1 : number +>1 : 1 for (x = 5;;x++) {} ->x = 5 : number +>x = 5 : 5 >x : any ->5 : number +>5 : 5 >x++ : number >x : any for (x = 8;;x--) {} ->x = 8 : number +>x = 8 : 8 >x : any ->8 : number +>8 : 8 >x-- : number >x : any for (x = 15;;++x) {} ->x = 15 : number +>x = 15 : 15 >x : any ->15 : number +>15 : 15 >++x : number >x : any for (x = 18;;--x) {} ->x = 18 : number +>x = 18 : 18 >x : any ->18 : number +>18 : 18 >--x : number >x : any for (let x = 50;;) {} >x : number ->50 : number +>50 : 50 function foo() { >foo : () => void x = 100; ->x = 100 : number +>x = 100 : 100 >x : any ->100 : number +>100 : 100 } export let [y] = [1]; >y : number >[1] : [number] ->1 : number +>1 : 1 export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; >a : any @@ -128,16 +128,16 @@ export const {a: z0, b: {c: z1}} = {a: true, b: {c: "123"}}; >z1 : string >{a: true, b: {c: "123"}} : { a: boolean; b: { c: string; }; } >a : boolean ->true : boolean +>true : true >b : { c: string; } >{c: "123"} : { c: string; } >c : string ->"123" : string +>"123" : "123" for ([x] of [[1]]) {} >[x] : [any] >x : any >[[1]] : number[][] >[1] : number[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/systemModuleAmbientDeclarations.types b/tests/baselines/reference/systemModuleAmbientDeclarations.types index 3633f922881..04c4f2d49df 100644 --- a/tests/baselines/reference/systemModuleAmbientDeclarations.types +++ b/tests/baselines/reference/systemModuleAmbientDeclarations.types @@ -12,7 +12,7 @@ declare class C {} declare enum E {X = 1}; >E : E >X : E ->1 : number +>1 : 1 export var promise = Promise; >promise : typeof Promise @@ -46,7 +46,7 @@ export declare var v: number; export declare enum E {X = 1} >E : E >X : E ->1 : number +>1 : 1 === tests/cases/compiler/file6.ts === export declare module M { var v: number; } diff --git a/tests/baselines/reference/systemModuleTargetES6.types b/tests/baselines/reference/systemModuleTargetES6.types index 5a9801a5d89..193507fca89 100644 --- a/tests/baselines/reference/systemModuleTargetES6.types +++ b/tests/baselines/reference/systemModuleTargetES6.types @@ -7,7 +7,7 @@ export class MyClass2 { static value = 42; >value : number ->42 : number +>42 : 42 static getInstance() { return MyClass2.value; } >getInstance : () => number diff --git a/tests/baselines/reference/taggedTemplateContextualTyping1.types b/tests/baselines/reference/taggedTemplateContextualTyping1.types index 2ccf8798dfd..a6b2d3862ca 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping1.types +++ b/tests/baselines/reference/taggedTemplateContextualTyping1.types @@ -57,7 +57,7 @@ tempTag1 `${ x => { x(undefined); return x; } }${ 10 } >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->10 : number +>10 : 10 tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }`; >tempTag1 `${ x => { x(undefined); return x; } }${ y => { y(undefined); return y; } }${ 10 }` : number @@ -75,7 +75,7 @@ tempTag1 `${ x => { x(undefined); return x; } }${ y => >y : (p: T) => T >undefined : undefined >y : (p: T) => T ->10 : number +>10 : 10 tempTag1 `${ x => { x(undefined); return x; } }${ (y: (p: T) => T) => { y(undefined); return y } }${ undefined }`; >tempTag1 `${ x => { x(undefined); return x; } }${ (y: (p: T) => T) => { y(undefined); return y } }${ undefined }` : any diff --git a/tests/baselines/reference/taggedTemplateContextualTyping2.types b/tests/baselines/reference/taggedTemplateContextualTyping2.types index 02dcbd22753..2dbf2c53c8b 100644 --- a/tests/baselines/reference/taggedTemplateContextualTyping2.types +++ b/tests/baselines/reference/taggedTemplateContextualTyping2.types @@ -59,7 +59,7 @@ tempTag2 `${ x => { x(undefined); return x; } }${ 0 }`; >x : (p: T) => T >undefined : undefined >x : (p: T) => T ->0 : number +>0 : 0 tempTag2 `${ x => { x(undefined); return x; } }${ y => { y(null); return y; } }${ "hello" }`; >tempTag2 `${ x => { x(undefined); return x; } }${ y => { y(null); return y; } }${ "hello" }` : string @@ -77,7 +77,7 @@ tempTag2 `${ x => { x(undefined); return x; } }${ y => { yy : (p: T) => T >null : null >y : (p: T) => T ->"hello" : string +>"hello" : "hello" tempTag2 `${ x => { x(undefined); return x; } }${ undefined }${ "hello" }`; >tempTag2 `${ x => { x(undefined); return x; } }${ undefined }${ "hello" }` : string @@ -90,5 +90,5 @@ tempTag2 `${ x => { x(undefined); return x; } }${ undefined }${ >undefined : undefined >x : (p: T) => T >undefined : undefined ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.types b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.types index 329ce9c3b21..e42bf52c005 100644 --- a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.types +++ b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapes.types @@ -8,5 +8,5 @@ f `\x0D${ "Interrupted CRLF" }\x0A`; >f `\x0D${ "Interrupted CRLF" }\x0A` : void >f : (...args: any[]) => void >`\x0D${ "Interrupted CRLF" }\x0A` : string ->"Interrupted CRLF" : string +>"Interrupted CRLF" : "Interrupted CRLF" diff --git a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.types b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.types index f350b6137a7..1b5fefe9c9e 100644 --- a/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.types +++ b/tests/baselines/reference/taggedTemplateStringsHexadecimalEscapesES6.types @@ -8,5 +8,5 @@ f `\x0D${ "Interrupted CRLF" }\x0A`; >f `\x0D${ "Interrupted CRLF" }\x0A` : void >f : (...args: any[]) => void >`\x0D${ "Interrupted CRLF" }\x0A` : string ->"Interrupted CRLF" : string +>"Interrupted CRLF" : "Interrupted CRLF" diff --git a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02.types b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02.types index 9b02e0d3fb3..6619696bb39 100644 --- a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02.types +++ b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02.types @@ -3,33 +3,33 @@ `0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n` >`0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n` : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " diff --git a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.types b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.types index ed229126283..2fae6446989 100644 --- a/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.types +++ b/tests/baselines/reference/taggedTemplateStringsPlainCharactersThatArePartsOfEscapes02_ES6.types @@ -10,33 +10,33 @@ f `0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " >f `0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n` : void >f : (...x: any[]) => void >`0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n` : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt index 44b30fb535f..06343389868 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTags.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(14,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(18,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(22,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(24,25): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(26,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts(28,57): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTags.ts (6 errors) ==== @@ -22,31 +22,31 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped f `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc`.member f `abc${1}def${2}ghi`.member; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc`[0].member `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f.thisIsNotATag(`abc`); diff --git a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.errors.txt index c2825c19e63..9d1ee541e4f 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithIncompatibleTypedTagsES6.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(14,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(18,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(22,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(24,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(26,9): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(28,57): error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(14,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(18,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(22,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(24,25): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(26,9): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts(28,57): error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTypedTagsES6.ts (6 errors) ==== @@ -22,31 +22,31 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithIncompatibleTyped f `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc`.member f `abc${1}def${2}ghi`.member; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc`["member"]; f `abc${1}def${2}ghi`["member"]; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc`[0].member `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f `abc${ true }def${ true }ghi`["member"].member `abc${ 1 }def${ 2 }ghi`; ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'boolean'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'boolean'. f.thisIsNotATag(`abc`); diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.types b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.types index 34d9e71dcab..f10c493dbd9 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.types +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressions.types @@ -36,10 +36,10 @@ var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; >f `abc${ 0 }def` : I >f : I >`abc${ 0 }def` : string ->0 : number +>0 : 0 >member : new (s: string) => new (n: number) => new () => boolean ->"hello" : string ->42 : number +>"hello" : "hello" +>42 : 42 >true : true diff --git a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.types b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.types index b57b1ba40aa..23923ab7180 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.types +++ b/tests/baselines/reference/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.types @@ -36,10 +36,10 @@ var x = new new new f `abc${ 0 }def`.member("hello")(42) === true; >f `abc${ 0 }def` : I >f : I >`abc${ 0 }def` : string ->0 : number +>0 : 0 >member : new (s: string) => new (n: number) => new () => boolean ->"hello" : string ->42 : number +>"hello" : "hello" +>42 : 42 >true : true diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt index 426eef8ce7f..e9c9e0ed6e0 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(12,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(13,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(19,20): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target. @@ -43,7 +43,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio var w = foo `${1}${2}`; // boolean var x = foo `${1}${true}`; // boolean (with error) ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. var y = foo `${1}${"2"}`; // {} var z = foo `${1}${2}${3}`; // any (with error) ~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1_ES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1_ES6.errors.txt index 73adc0c0302..d7817e32ee0 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1_ES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution1_ES6.errors.txt @@ -5,7 +5,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(12,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(13,13): error TS2345: Argument of type 'undefined[]' is not assignable to parameter of type 'TemplateStringsArray'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(14,9): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(19,20): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(19,20): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution1_ES6.ts(21,9): error TS2346: Supplied parameters do not match any signature of call target. @@ -43,7 +43,7 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio var w = foo `${1}${2}`; // boolean var x = foo `${1}${true}`; // boolean (with error) ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. var y = foo `${1}${"2"}`; // {} var z = foo `${1}${2}${3}`; // any (with error) ~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.types b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.types index 3c35974ddec..38b2087ccbf 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.types +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2.types @@ -24,14 +24,14 @@ var a = foo1 `${1}`; >foo1 `${1}` : string >foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } >`${1}` : string ->1 : number +>1 : 1 var b = foo1([], 1); >b : number >foo1([], 1) : number >foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } >[] : undefined[] ->1 : number +>1 : 1 function foo2(strs: string[], x: number): number; >foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } @@ -57,12 +57,12 @@ var c = foo2 `${1}`; >foo2 `${1}` : string >foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } >`${1}` : string ->1 : number +>1 : 1 var d = foo2([], 1); >d : number >foo2([], 1) : number >foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } >[] : undefined[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2_ES6.types b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2_ES6.types index 7faeec19c4a..41caabef752 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2_ES6.types +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution2_ES6.types @@ -23,14 +23,14 @@ var a = foo1 `${1}`; >foo1 `${1}` : string >foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } >`${1}` : string ->1 : number +>1 : 1 var b = foo1([], 1); >b : number >foo1([], 1) : number >foo1 : { (strs: TemplateStringsArray, x: number): string; (strs: string[], x: number): number; } >[] : undefined[] ->1 : number +>1 : 1 function foo2(strs: string[], x: number): number; >foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } @@ -56,12 +56,12 @@ var c = foo2 `${1}`; >foo2 `${1}` : string >foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } >`${1}` : string ->1 : number +>1 : 1 var d = foo2([], 1); >d : number >foo2([], 1) : number >foo2 : { (strs: string[], x: number): number; (strs: TemplateStringsArray, x: number): string; } >[] : undefined[] ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt index 0d65c3fd13b..2248fee5ceb 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(10,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(19,4): error TS2339: Property 'foo' does not exist on type 'Date'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(45,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,18): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(63,9): error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(64,18): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3.ts(70,18): error TS2339: Property 'toFixed' does not exist on type 'string'. @@ -77,10 +77,10 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints fn4 `${ true }${ null }`; ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. fn4 `${ null }${ true }`; ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. // Non - generic overloads where contextual typing of function arguments has errors function fn5(strs: TemplateStringsArray, f: (n: string) => void): string; diff --git a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt index e65acdee835..7329ade1b64 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithOverloadResolution3_ES6.errors.txt @@ -1,8 +1,8 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(9,9): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(18,4): error TS2339: Property 'foo' does not exist on type 'Date'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(44,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(62,9): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. -tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(63,18): error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(62,9): error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(63,18): error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolution3_ES6.ts(69,18): error TS2339: Property 'toFixed' does not exist on type 'string'. @@ -76,10 +76,10 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithOverloadResolutio // Generic overloads with constraints called without type arguments but with types that do not satisfy the constraints fn4 `${ true }${ null }`; ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'number'. fn4 `${ null }${ true }`; ~~~~ -!!! error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type 'true' is not assignable to parameter of type 'string'. // Non - generic overloads where contextual typing of function arguments has errors function fn5(strs: TemplateStringsArray, f: (n: string) => void): string; diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagNamedDeclare.types b/tests/baselines/reference/taggedTemplateStringsWithTagNamedDeclare.types index d1f56f387d6..b0accf616af 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTagNamedDeclare.types +++ b/tests/baselines/reference/taggedTemplateStringsWithTagNamedDeclare.types @@ -11,5 +11,5 @@ declare `Hello ${0} world!`; >declare `Hello ${0} world!` : void >declare : (x: any, ...ys: any[]) => void >`Hello ${0} world!` : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagNamedDeclareES6.types b/tests/baselines/reference/taggedTemplateStringsWithTagNamedDeclareES6.types index e2274f82ff7..6e474bf3474 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTagNamedDeclareES6.types +++ b/tests/baselines/reference/taggedTemplateStringsWithTagNamedDeclareES6.types @@ -10,5 +10,5 @@ declare `Hello ${0} world!`; >declare `Hello ${0} world!` : void >declare : (x: any, ...ys: any[]) => void >`Hello ${0} world!` : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.types b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.types index 0db2a3bb963..9e894240c93 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.types +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAny.types @@ -11,8 +11,8 @@ f `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi` : any >f : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f.g.h `abc` >f.g.h `abc` : any @@ -31,8 +31,8 @@ f.g.h `abc${1}def${2}ghi`; >g : any >h : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f `abc`.member >f `abc`.member : any @@ -46,8 +46,8 @@ f `abc${1}def${2}ghi`.member; >f `abc${1}def${2}ghi` : any >f : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 >member : any f `abc`["member"]; @@ -55,16 +55,16 @@ f `abc`["member"]; >f `abc` : any >f : any >`abc` : string ->"member" : string +>"member" : "member" f `abc${1}def${2}ghi`["member"]; >f `abc${1}def${2}ghi`["member"] : any >f `abc${1}def${2}ghi` : any >f : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number ->"member" : string +>1 : 1 +>2 : 2 +>"member" : "member" f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; >f `abc`["member"].someOtherTag `abc${1}def${2}ghi` : any @@ -73,11 +73,11 @@ f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; >f `abc` : any >f : any >`abc` : string ->"member" : string +>"member" : "member" >someOtherTag : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi` : any @@ -86,13 +86,13 @@ f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi` : any >f : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number ->"member" : string +>1 : 1 +>2 : 2 +>"member" : "member" >someOtherTag : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f.thisIsNotATag(`abc`); >f.thisIsNotATag(`abc`) : any @@ -107,6 +107,6 @@ f.thisIsNotATag(`abc${1}def${2}ghi`); >f : any >thisIsNotATag : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.types b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.types index 1a6ffb5eba0..99bb10f3546 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.types +++ b/tests/baselines/reference/taggedTemplateStringsWithTagsTypedAsAnyES6.types @@ -11,8 +11,8 @@ f `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi` : any >f : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f.g.h `abc` >f.g.h `abc` : any @@ -31,8 +31,8 @@ f.g.h `abc${1}def${2}ghi`; >g : any >h : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f `abc`.member >f `abc`.member : any @@ -46,8 +46,8 @@ f `abc${1}def${2}ghi`.member; >f `abc${1}def${2}ghi` : any >f : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 >member : any f `abc`["member"]; @@ -55,16 +55,16 @@ f `abc`["member"]; >f `abc` : any >f : any >`abc` : string ->"member" : string +>"member" : "member" f `abc${1}def${2}ghi`["member"]; >f `abc${1}def${2}ghi`["member"] : any >f `abc${1}def${2}ghi` : any >f : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number ->"member" : string +>1 : 1 +>2 : 2 +>"member" : "member" f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; >f `abc`["member"].someOtherTag `abc${1}def${2}ghi` : any @@ -73,11 +73,11 @@ f `abc`["member"].someOtherTag `abc${1}def${2}ghi`; >f `abc` : any >f : any >`abc` : string ->"member" : string +>"member" : "member" >someOtherTag : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi` : any @@ -86,13 +86,13 @@ f `abc${1}def${2}ghi`["member"].someOtherTag `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi` : any >f : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number ->"member" : string +>1 : 1 +>2 : 2 +>"member" : "member" >someOtherTag : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f.thisIsNotATag(`abc`); >f.thisIsNotATag(`abc`) : any @@ -107,6 +107,6 @@ f.thisIsNotATag(`abc${1}def${2}ghi`); >f : any >thisIsNotATag : any >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt index 88bfac23211..6da8d2ffce3 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,31): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(6,31): error TS2322: Type '"bad"' is not assignable to type 'number'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ==== @@ -9,4 +9,4 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFuncti foo `${function (x: number) { x = "bad"; } }`; ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type '"bad"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt index 6b0f4b642ff..c1d18cd6f91 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt +++ b/tests/baselines/reference/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(5,31): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(5,31): error TS2322: Type '"bad"' is not assignable to type 'number'. ==== tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ==== @@ -8,4 +8,4 @@ tests/cases/conformance/es6/templates/taggedTemplateStringsWithTypeErrorInFuncti foo `${function (x: number) { x = "bad"; } }`; ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type '"bad"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.types b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.types index c7c521154c7..69b9368f765 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypedTags.types +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTags.types @@ -42,8 +42,8 @@ f `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi` : I >f : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f `abc`.member >f `abc`.member : I @@ -57,8 +57,8 @@ f `abc${1}def${2}ghi`.member; >f `abc${1}def${2}ghi` : I >f : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 >member : I f `abc`["member"]; @@ -66,16 +66,16 @@ f `abc`["member"]; >f `abc` : I >f : I >`abc` : string ->"member" : string +>"member" : "member" f `abc${1}def${2}ghi`["member"]; >f `abc${1}def${2}ghi`["member"] : I >f `abc${1}def${2}ghi` : I >f : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number ->"member" : string +>1 : 1 +>2 : 2 +>"member" : "member" f `abc`[0].member `abc${1}def${2}ghi`; >f `abc`[0].member `abc${1}def${2}ghi` : I @@ -84,11 +84,11 @@ f `abc`[0].member `abc${1}def${2}ghi`; >f `abc` : I >f : I >`abc` : string ->0 : number +>0 : 0 >member : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi` : I @@ -97,13 +97,13 @@ f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi` : I >f : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number ->"member" : string +>1 : 1 +>2 : 2 +>"member" : "member" >member : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f.thisIsNotATag(`abc`); >f.thisIsNotATag(`abc`) : void @@ -118,6 +118,6 @@ f.thisIsNotATag(`abc${1}def${2}ghi`); >f : I >thisIsNotATag : (x: string) => void >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.types b/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.types index bf45144c329..97e2f011ca6 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.types +++ b/tests/baselines/reference/taggedTemplateStringsWithTypedTagsES6.types @@ -42,8 +42,8 @@ f `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi` : I >f : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f `abc`.member >f `abc`.member : I @@ -57,8 +57,8 @@ f `abc${1}def${2}ghi`.member; >f `abc${1}def${2}ghi` : I >f : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 >member : I f `abc`["member"]; @@ -66,16 +66,16 @@ f `abc`["member"]; >f `abc` : I >f : I >`abc` : string ->"member" : string +>"member" : "member" f `abc${1}def${2}ghi`["member"]; >f `abc${1}def${2}ghi`["member"] : I >f `abc${1}def${2}ghi` : I >f : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number ->"member" : string +>1 : 1 +>2 : 2 +>"member" : "member" f `abc`[0].member `abc${1}def${2}ghi`; >f `abc`[0].member `abc${1}def${2}ghi` : I @@ -84,11 +84,11 @@ f `abc`[0].member `abc${1}def${2}ghi`; >f `abc` : I >f : I >`abc` : string ->0 : number +>0 : 0 >member : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi` : I @@ -97,13 +97,13 @@ f `abc${1}def${2}ghi`["member"].member `abc${1}def${2}ghi`; >f `abc${1}def${2}ghi` : I >f : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number ->"member" : string +>1 : 1 +>2 : 2 +>"member" : "member" >member : I >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 f.thisIsNotATag(`abc`); >f.thisIsNotATag(`abc`) : void @@ -118,6 +118,6 @@ f.thisIsNotATag(`abc${1}def${2}ghi`); >f : I >thisIsNotATag : (x: string) => void >`abc${1}def${2}ghi` : string ->1 : number ->2 : number +>1 : 1 +>2 : 2 diff --git a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.types b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.types index 7b09b5c5746..4b9b447d32a 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.types +++ b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapes.types @@ -8,5 +8,5 @@ f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; >f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'` : void >f : (...args: any[]) => void >`'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'` : string ->" should be converted to " : string +>" should be converted to " : " should be converted to " diff --git a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.types b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.types index ad4c5cc67a9..36a298c5a38 100644 --- a/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.types +++ b/tests/baselines/reference/taggedTemplateStringsWithUnicodeEscapesES6.types @@ -8,5 +8,5 @@ f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'`; >f `'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'` : void >f : (...args: any[]) => void >`'\u{1f4a9}'${ " should be converted to " }'\uD83D\uDCA9'` : string ->" should be converted to " : string +>" should be converted to " : " should be converted to " diff --git a/tests/baselines/reference/taggedTemplatesWithIncompleteTemplateExpressions3.errors.txt b/tests/baselines/reference/taggedTemplatesWithIncompleteTemplateExpressions3.errors.txt index 33d93b43f13..ca306a8ad8b 100644 --- a/tests/baselines/reference/taggedTemplatesWithIncompleteTemplateExpressions3.errors.txt +++ b/tests/baselines/reference/taggedTemplatesWithIncompleteTemplateExpressions3.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions3.ts(6,18): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions3.ts(6,18): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions3.ts(6,23): error TS1109: Expression expected. @@ -10,6 +10,6 @@ tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions3.ts(6,23): // Incomplete call, not enough parameters. f `123qdawdrqw${ 1 }${ ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/taggedTemplatesWithIncompleteTemplateExpressions6.errors.txt b/tests/baselines/reference/taggedTemplatesWithIncompleteTemplateExpressions6.errors.txt index c577896aec7..a5d3f132b69 100644 --- a/tests/baselines/reference/taggedTemplatesWithIncompleteTemplateExpressions6.errors.txt +++ b/tests/baselines/reference/taggedTemplatesWithIncompleteTemplateExpressions6.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions6.ts(6,18): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions6.ts(6,18): error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions6.ts(6,23): error TS1109: Expression expected. @@ -10,6 +10,6 @@ tests/cases/compiler/taggedTemplatesWithIncompleteTemplateExpressions6.ts(6,23): // Incomplete call, not enough parameters, at EOF. f `123qdawdrqw${ 1 }${ ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/targetTypeArgs.types b/tests/baselines/reference/targetTypeArgs.types index 48dd35401b4..84985316aa2 100644 --- a/tests/baselines/reference/targetTypeArgs.types +++ b/tests/baselines/reference/targetTypeArgs.types @@ -7,7 +7,7 @@ function foo(callback: (x: string) => void) { callback("hello"); >callback("hello") : void >callback : (x: string) => void ->"hello" : string +>"hello" : "hello" } foo(function(x) { x }); @@ -21,7 +21,7 @@ foo(function(x) { x }); >[1].forEach(function(v,i,a) { v }) : void >[1].forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void >[1] : number[] ->1 : number +>1 : 1 >forEach : (callbackfn: (value: number, index: number, array: number[]) => void, thisArg?: any) => void >function(v,i,a) { v } : (v: number, i: number, a: number[]) => void >v : number @@ -33,7 +33,7 @@ foo(function(x) { x }); >["hello"].every(function(v,i,a) {return true;}) : boolean >["hello"].every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean >["hello"] : string[] ->"hello" : string +>"hello" : "hello" >every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean >function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true >v : string @@ -45,7 +45,7 @@ foo(function(x) { x }); >[1].every(function(v,i,a) {return true;}) : boolean >[1].every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean >[1] : number[] ->1 : number +>1 : 1 >every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean >function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true >v : number @@ -57,7 +57,7 @@ foo(function(x) { x }); >[1].every(function(v,i,a) {return true;}) : boolean >[1].every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean >[1] : number[] ->1 : number +>1 : 1 >every : (callbackfn: (value: number, index: number, array: number[]) => boolean, thisArg?: any) => boolean >function(v,i,a) {return true;} : (v: number, i: number, a: number[]) => true >v : number @@ -69,7 +69,7 @@ foo(function(x) { x }); >["s"].every(function(v,i,a) {return true;}) : boolean >["s"].every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean >["s"] : string[] ->"s" : string +>"s" : "s" >every : (callbackfn: (value: string, index: number, array: string[]) => boolean, thisArg?: any) => boolean >function(v,i,a) {return true;} : (v: string, i: number, a: string[]) => true >v : string @@ -81,7 +81,7 @@ foo(function(x) { x }); >["s"].forEach(function(v,i,a) { v }) : void >["s"].forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void >["s"] : string[] ->"s" : string +>"s" : "s" >forEach : (callbackfn: (value: string, index: number, array: string[]) => void, thisArg?: any) => void >function(v,i,a) { v } : (v: string, i: number, a: string[]) => void >v : string diff --git a/tests/baselines/reference/targetTypeBaseCalls.errors.txt b/tests/baselines/reference/targetTypeBaseCalls.errors.txt index 37a00c9798d..0ff253d1389 100644 --- a/tests/baselines/reference/targetTypeBaseCalls.errors.txt +++ b/tests/baselines/reference/targetTypeBaseCalls.errors.txt @@ -1,6 +1,6 @@ -tests/cases/compiler/targetTypeBaseCalls.ts(9,19): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/targetTypeBaseCalls.ts(13,23): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/compiler/targetTypeBaseCalls.ts(17,61): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/targetTypeBaseCalls.ts(9,19): error TS2322: Type '5' is not assignable to type 'string'. +tests/cases/compiler/targetTypeBaseCalls.ts(13,23): error TS2322: Type '5' is not assignable to type 'string'. +tests/cases/compiler/targetTypeBaseCalls.ts(17,61): error TS2322: Type '5' is not assignable to type 'string'. ==== tests/cases/compiler/targetTypeBaseCalls.ts (3 errors) ==== @@ -14,17 +14,17 @@ tests/cases/compiler/targetTypeBaseCalls.ts(17,61): error TS2322: Type 'number' foo(function(s) { s = 5 }); // Error, can’t assign number to string ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. new Foo(function(s) { s = 5 }); // error, if types are applied correctly ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. class Bar extends Foo { constructor() { super(function(s) { s = 5 }) } } // error, if types are applied correctly ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '5' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/targetTypeCalls.types b/tests/baselines/reference/targetTypeCalls.types index 6e9c1ca190d..1ceb86a3a09 100644 --- a/tests/baselines/reference/targetTypeCalls.types +++ b/tests/baselines/reference/targetTypeCalls.types @@ -14,7 +14,7 @@ var fra2: (v:any)=>number = function() { return function () { return 0; } }() // >function() { return function () { return 0; } }() : () => number >function() { return function () { return 0; } } : () => () => number >function () { return 0; } : () => number ->0 : number +>0 : 0 var fra3: (v:any)=>string = function() { return function() { return function(v) {return v;};}(); }() // should work >fra3 : (v: any) => string diff --git a/tests/baselines/reference/targetTypeObjectLiteral.types b/tests/baselines/reference/targetTypeObjectLiteral.types index 8f77c11f7b6..3d38ccd22ba 100644 --- a/tests/baselines/reference/targetTypeObjectLiteral.types +++ b/tests/baselines/reference/targetTypeObjectLiteral.types @@ -4,19 +4,19 @@ var z: { x: number; y: (w:string)=>number;} = { >x : number >y : (w: string) => number >w : string ->{ x: 12, y: function(w) { return 0; }} : { x: number; y: (w: string) => number; } +>{ x: 12, y: function(w) { return 0; }} : { x: number; y: (w: string) => 0; } x: 12, >x : number ->12 : number +>12 : 12 y: function(w) { ->y : (w: string) => number ->function(w) { return 0; } : (w: string) => number +>y : (w: string) => 0 +>function(w) { return 0; } : (w: string) => 0 >w : string return 0; ->0 : number +>0 : 0 } diff --git a/tests/baselines/reference/targetTypeObjectLiteralToAny.types b/tests/baselines/reference/targetTypeObjectLiteralToAny.types index b6bd1e91051..1dd81b33603 100644 --- a/tests/baselines/reference/targetTypeObjectLiteralToAny.types +++ b/tests/baselines/reference/targetTypeObjectLiteralToAny.types @@ -25,7 +25,7 @@ function suggest(){ >text : string >keyword : string >type : string ->"keyword" : string +>"keyword" : "keyword" }); } diff --git a/tests/baselines/reference/targetTypeTest2.types b/tests/baselines/reference/targetTypeTest2.types index 25b36f948c6..d3a4bc66dbb 100644 --- a/tests/baselines/reference/targetTypeTest2.types +++ b/tests/baselines/reference/targetTypeTest2.types @@ -5,9 +5,9 @@ var a : any[] = [1,2,"3"]; >a : any[] >[1,2,"3"] : (string | number)[] ->1 : number ->2 : number ->"3" : string +>1 : 1 +>2 : 2 +>"3" : "3" function func1(stuff:any[]) { return stuff; } diff --git a/tests/baselines/reference/templateStringBinaryOperations.types b/tests/baselines/reference/templateStringBinaryOperations.types index d4b8c531ef4..01d306487ee 100644 --- a/tests/baselines/reference/templateStringBinaryOperations.types +++ b/tests/baselines/reference/templateStringBinaryOperations.types @@ -2,440 +2,440 @@ var a = 1 + `${ 3 }`; >a : string >1 + `${ 3 }` : string ->1 : number +>1 : 1 >`${ 3 }` : string ->3 : number +>3 : 3 var b = 1 + `2${ 3 }`; >b : string >1 + `2${ 3 }` : string ->1 : number +>1 : 1 >`2${ 3 }` : string ->3 : number +>3 : 3 var c = 1 + `${ 3 }4`; >c : string >1 + `${ 3 }4` : string ->1 : number +>1 : 1 >`${ 3 }4` : string ->3 : number +>3 : 3 var d = 1 + `2${ 3 }4`; >d : string >1 + `2${ 3 }4` : string ->1 : number +>1 : 1 >`2${ 3 }4` : string ->3 : number +>3 : 3 var e = `${ 3 }` + 5; >e : string >`${ 3 }` + 5 : string >`${ 3 }` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var f = `2${ 3 }` + 5; >f : string >`2${ 3 }` + 5 : string >`2${ 3 }` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var g = `${ 3 }4` + 5; >g : string >`${ 3 }4` + 5 : string >`${ 3 }4` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var h = `2${ 3 }4` + 5; >h : string >`2${ 3 }4` + 5 : string >`2${ 3 }4` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var i = 1 + `${ 3 }` + 5; >i : string >1 + `${ 3 }` + 5 : string >1 + `${ 3 }` : string ->1 : number +>1 : 1 >`${ 3 }` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var j = 1 + `2${ 3 }` + 5; >j : string >1 + `2${ 3 }` + 5 : string >1 + `2${ 3 }` : string ->1 : number +>1 : 1 >`2${ 3 }` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var k = 1 + `${ 3 }4` + 5; >k : string >1 + `${ 3 }4` + 5 : string >1 + `${ 3 }4` : string ->1 : number +>1 : 1 >`${ 3 }4` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var l = 1 + `2${ 3 }4` + 5; >l : string >1 + `2${ 3 }4` + 5 : string >1 + `2${ 3 }4` : string ->1 : number +>1 : 1 >`2${ 3 }4` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var a2 = 1 + `${ 3 - 4 }`; >a2 : string >1 + `${ 3 - 4 }` : string ->1 : number +>1 : 1 >`${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var b2 = 1 + `2${ 3 - 4 }`; >b2 : string >1 + `2${ 3 - 4 }` : string ->1 : number +>1 : 1 >`2${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var c2 = 1 + `${ 3 - 4 }5`; >c2 : string >1 + `${ 3 - 4 }5` : string ->1 : number +>1 : 1 >`${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var d2 = 1 + `2${ 3 - 4 }5`; >d2 : string >1 + `2${ 3 - 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var e2 = `${ 3 - 4 }` + 6; >e2 : string >`${ 3 - 4 }` + 6 : string >`${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var f2 = `2${ 3 - 4 }` + 6; >f2 : string >`2${ 3 - 4 }` + 6 : string >`2${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var g2 = `${ 3 - 4 }5` + 6; >g2 : string >`${ 3 - 4 }5` + 6 : string >`${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var h2 = `2${ 3 - 4 }5` + 6; >h2 : string >`2${ 3 - 4 }5` + 6 : string >`2${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var i2 = 1 + `${ 3 - 4 }` + 6; >i2 : string >1 + `${ 3 - 4 }` + 6 : string >1 + `${ 3 - 4 }` : string ->1 : number +>1 : 1 >`${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var j2 = 1 + `2${ 3 - 4 }` + 6; >j2 : string >1 + `2${ 3 - 4 }` + 6 : string >1 + `2${ 3 - 4 }` : string ->1 : number +>1 : 1 >`2${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var k2 = 1 + `${ 3 - 4 }5` + 6; >k2 : string >1 + `${ 3 - 4 }5` + 6 : string >1 + `${ 3 - 4 }5` : string ->1 : number +>1 : 1 >`${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var l2 = 1 + `2${ 3 - 4 }5` + 6; >l2 : string >1 + `2${ 3 - 4 }5` + 6 : string >1 + `2${ 3 - 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var a3 = 1 + `${ 3 * 4 }`; >a3 : string >1 + `${ 3 * 4 }` : string ->1 : number +>1 : 1 >`${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var b3 = 1 + `2${ 3 * 4 }`; >b3 : string >1 + `2${ 3 * 4 }` : string ->1 : number +>1 : 1 >`2${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var c3 = 1 + `${ 3 * 4 }5`; >c3 : string >1 + `${ 3 * 4 }5` : string ->1 : number +>1 : 1 >`${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var d3 = 1 + `2${ 3 * 4 }5`; >d3 : string >1 + `2${ 3 * 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var e3 = `${ 3 * 4 }` + 6; >e3 : string >`${ 3 * 4 }` + 6 : string >`${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var f3 = `2${ 3 * 4 }` + 6; >f3 : string >`2${ 3 * 4 }` + 6 : string >`2${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var g3 = `${ 3 * 4 }5` + 6; >g3 : string >`${ 3 * 4 }5` + 6 : string >`${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var h3 = `2${ 3 * 4 }5` + 6; >h3 : string >`2${ 3 * 4 }5` + 6 : string >`2${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var i3 = 1 + `${ 3 * 4 }` + 6; >i3 : string >1 + `${ 3 * 4 }` + 6 : string >1 + `${ 3 * 4 }` : string ->1 : number +>1 : 1 >`${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var j3 = 1 + `2${ 3 * 4 }` + 6; >j3 : string >1 + `2${ 3 * 4 }` + 6 : string >1 + `2${ 3 * 4 }` : string ->1 : number +>1 : 1 >`2${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var k3 = 1 + `${ 3 * 4 }5` + 6; >k3 : string >1 + `${ 3 * 4 }5` + 6 : string >1 + `${ 3 * 4 }5` : string ->1 : number +>1 : 1 >`${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var l3 = 1 + `2${ 3 * 4 }5` + 6; >l3 : string >1 + `2${ 3 * 4 }5` + 6 : string >1 + `2${ 3 * 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var a4 = 1 + `${ 3 & 4 }`; >a4 : string >1 + `${ 3 & 4 }` : string ->1 : number +>1 : 1 >`${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var b4 = 1 + `2${ 3 & 4 }`; >b4 : string >1 + `2${ 3 & 4 }` : string ->1 : number +>1 : 1 >`2${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var c4 = 1 + `${ 3 & 4 }5`; >c4 : string >1 + `${ 3 & 4 }5` : string ->1 : number +>1 : 1 >`${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var d4 = 1 + `2${ 3 & 4 }5`; >d4 : string >1 + `2${ 3 & 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var e4 = `${ 3 & 4 }` + 6; >e4 : string >`${ 3 & 4 }` + 6 : string >`${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var f4 = `2${ 3 & 4 }` + 6; >f4 : string >`2${ 3 & 4 }` + 6 : string >`2${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var g4 = `${ 3 & 4 }5` + 6; >g4 : string >`${ 3 & 4 }5` + 6 : string >`${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var h4 = `2${ 3 & 4 }5` + 6; >h4 : string >`2${ 3 & 4 }5` + 6 : string >`2${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var i4 = 1 + `${ 3 & 4 }` + 6; >i4 : string >1 + `${ 3 & 4 }` + 6 : string >1 + `${ 3 & 4 }` : string ->1 : number +>1 : 1 >`${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var j4 = 1 + `2${ 3 & 4 }` + 6; >j4 : string >1 + `2${ 3 & 4 }` + 6 : string >1 + `2${ 3 & 4 }` : string ->1 : number +>1 : 1 >`2${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var k4 = 1 + `${ 3 & 4 }5` + 6; >k4 : string >1 + `${ 3 & 4 }5` + 6 : string >1 + `${ 3 & 4 }5` : string ->1 : number +>1 : 1 >`${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var l4 = 1 + `2${ 3 & 4 }5` + 6; >l4 : string >1 + `2${ 3 & 4 }5` + 6 : string >1 + `2${ 3 & 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 diff --git a/tests/baselines/reference/templateStringBinaryOperationsES6.types b/tests/baselines/reference/templateStringBinaryOperationsES6.types index a20da835a81..0ac9775a655 100644 --- a/tests/baselines/reference/templateStringBinaryOperationsES6.types +++ b/tests/baselines/reference/templateStringBinaryOperationsES6.types @@ -2,440 +2,440 @@ var a = 1 + `${ 3 }`; >a : string >1 + `${ 3 }` : string ->1 : number +>1 : 1 >`${ 3 }` : string ->3 : number +>3 : 3 var b = 1 + `2${ 3 }`; >b : string >1 + `2${ 3 }` : string ->1 : number +>1 : 1 >`2${ 3 }` : string ->3 : number +>3 : 3 var c = 1 + `${ 3 }4`; >c : string >1 + `${ 3 }4` : string ->1 : number +>1 : 1 >`${ 3 }4` : string ->3 : number +>3 : 3 var d = 1 + `2${ 3 }4`; >d : string >1 + `2${ 3 }4` : string ->1 : number +>1 : 1 >`2${ 3 }4` : string ->3 : number +>3 : 3 var e = `${ 3 }` + 5; >e : string >`${ 3 }` + 5 : string >`${ 3 }` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var f = `2${ 3 }` + 5; >f : string >`2${ 3 }` + 5 : string >`2${ 3 }` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var g = `${ 3 }4` + 5; >g : string >`${ 3 }4` + 5 : string >`${ 3 }4` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var h = `2${ 3 }4` + 5; >h : string >`2${ 3 }4` + 5 : string >`2${ 3 }4` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var i = 1 + `${ 3 }` + 5; >i : string >1 + `${ 3 }` + 5 : string >1 + `${ 3 }` : string ->1 : number +>1 : 1 >`${ 3 }` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var j = 1 + `2${ 3 }` + 5; >j : string >1 + `2${ 3 }` + 5 : string >1 + `2${ 3 }` : string ->1 : number +>1 : 1 >`2${ 3 }` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var k = 1 + `${ 3 }4` + 5; >k : string >1 + `${ 3 }4` + 5 : string >1 + `${ 3 }4` : string ->1 : number +>1 : 1 >`${ 3 }4` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var l = 1 + `2${ 3 }4` + 5; >l : string >1 + `2${ 3 }4` + 5 : string >1 + `2${ 3 }4` : string ->1 : number +>1 : 1 >`2${ 3 }4` : string ->3 : number ->5 : number +>3 : 3 +>5 : 5 var a2 = 1 + `${ 3 - 4 }`; >a2 : string >1 + `${ 3 - 4 }` : string ->1 : number +>1 : 1 >`${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var b2 = 1 + `2${ 3 - 4 }`; >b2 : string >1 + `2${ 3 - 4 }` : string ->1 : number +>1 : 1 >`2${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var c2 = 1 + `${ 3 - 4 }5`; >c2 : string >1 + `${ 3 - 4 }5` : string ->1 : number +>1 : 1 >`${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var d2 = 1 + `2${ 3 - 4 }5`; >d2 : string >1 + `2${ 3 - 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var e2 = `${ 3 - 4 }` + 6; >e2 : string >`${ 3 - 4 }` + 6 : string >`${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var f2 = `2${ 3 - 4 }` + 6; >f2 : string >`2${ 3 - 4 }` + 6 : string >`2${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var g2 = `${ 3 - 4 }5` + 6; >g2 : string >`${ 3 - 4 }5` + 6 : string >`${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var h2 = `2${ 3 - 4 }5` + 6; >h2 : string >`2${ 3 - 4 }5` + 6 : string >`2${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var i2 = 1 + `${ 3 - 4 }` + 6; >i2 : string >1 + `${ 3 - 4 }` + 6 : string >1 + `${ 3 - 4 }` : string ->1 : number +>1 : 1 >`${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var j2 = 1 + `2${ 3 - 4 }` + 6; >j2 : string >1 + `2${ 3 - 4 }` + 6 : string >1 + `2${ 3 - 4 }` : string ->1 : number +>1 : 1 >`2${ 3 - 4 }` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var k2 = 1 + `${ 3 - 4 }5` + 6; >k2 : string >1 + `${ 3 - 4 }5` + 6 : string >1 + `${ 3 - 4 }5` : string ->1 : number +>1 : 1 >`${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var l2 = 1 + `2${ 3 - 4 }5` + 6; >l2 : string >1 + `2${ 3 - 4 }5` + 6 : string >1 + `2${ 3 - 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 - 4 }5` : string >3 - 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var a3 = 1 + `${ 3 * 4 }`; >a3 : string >1 + `${ 3 * 4 }` : string ->1 : number +>1 : 1 >`${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var b3 = 1 + `2${ 3 * 4 }`; >b3 : string >1 + `2${ 3 * 4 }` : string ->1 : number +>1 : 1 >`2${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var c3 = 1 + `${ 3 * 4 }5`; >c3 : string >1 + `${ 3 * 4 }5` : string ->1 : number +>1 : 1 >`${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var d3 = 1 + `2${ 3 * 4 }5`; >d3 : string >1 + `2${ 3 * 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var e3 = `${ 3 * 4 }` + 6; >e3 : string >`${ 3 * 4 }` + 6 : string >`${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var f3 = `2${ 3 * 4 }` + 6; >f3 : string >`2${ 3 * 4 }` + 6 : string >`2${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var g3 = `${ 3 * 4 }5` + 6; >g3 : string >`${ 3 * 4 }5` + 6 : string >`${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var h3 = `2${ 3 * 4 }5` + 6; >h3 : string >`2${ 3 * 4 }5` + 6 : string >`2${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var i3 = 1 + `${ 3 * 4 }` + 6; >i3 : string >1 + `${ 3 * 4 }` + 6 : string >1 + `${ 3 * 4 }` : string ->1 : number +>1 : 1 >`${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var j3 = 1 + `2${ 3 * 4 }` + 6; >j3 : string >1 + `2${ 3 * 4 }` + 6 : string >1 + `2${ 3 * 4 }` : string ->1 : number +>1 : 1 >`2${ 3 * 4 }` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var k3 = 1 + `${ 3 * 4 }5` + 6; >k3 : string >1 + `${ 3 * 4 }5` + 6 : string >1 + `${ 3 * 4 }5` : string ->1 : number +>1 : 1 >`${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var l3 = 1 + `2${ 3 * 4 }5` + 6; >l3 : string >1 + `2${ 3 * 4 }5` + 6 : string >1 + `2${ 3 * 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 * 4 }5` : string >3 * 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var a4 = 1 + `${ 3 & 4 }`; >a4 : string >1 + `${ 3 & 4 }` : string ->1 : number +>1 : 1 >`${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var b4 = 1 + `2${ 3 & 4 }`; >b4 : string >1 + `2${ 3 & 4 }` : string ->1 : number +>1 : 1 >`2${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var c4 = 1 + `${ 3 & 4 }5`; >c4 : string >1 + `${ 3 & 4 }5` : string ->1 : number +>1 : 1 >`${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var d4 = 1 + `2${ 3 & 4 }5`; >d4 : string >1 + `2${ 3 & 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number +>3 : 3 +>4 : 4 var e4 = `${ 3 & 4 }` + 6; >e4 : string >`${ 3 & 4 }` + 6 : string >`${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var f4 = `2${ 3 & 4 }` + 6; >f4 : string >`2${ 3 & 4 }` + 6 : string >`2${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var g4 = `${ 3 & 4 }5` + 6; >g4 : string >`${ 3 & 4 }5` + 6 : string >`${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var h4 = `2${ 3 & 4 }5` + 6; >h4 : string >`2${ 3 & 4 }5` + 6 : string >`2${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var i4 = 1 + `${ 3 & 4 }` + 6; >i4 : string >1 + `${ 3 & 4 }` + 6 : string >1 + `${ 3 & 4 }` : string ->1 : number +>1 : 1 >`${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var j4 = 1 + `2${ 3 & 4 }` + 6; >j4 : string >1 + `2${ 3 & 4 }` + 6 : string >1 + `2${ 3 & 4 }` : string ->1 : number +>1 : 1 >`2${ 3 & 4 }` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var k4 = 1 + `${ 3 & 4 }5` + 6; >k4 : string >1 + `${ 3 & 4 }5` + 6 : string >1 + `${ 3 & 4 }5` : string ->1 : number +>1 : 1 >`${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 var l4 = 1 + `2${ 3 & 4 }5` + 6; >l4 : string >1 + `2${ 3 & 4 }5` + 6 : string >1 + `2${ 3 & 4 }5` : string ->1 : number +>1 : 1 >`2${ 3 & 4 }5` : string >3 & 4 : number ->3 : number ->4 : number ->6 : number +>3 : 3 +>4 : 4 +>6 : 6 diff --git a/tests/baselines/reference/templateStringInArray.types b/tests/baselines/reference/templateStringInArray.types index 04cc09a1005..03271a5dcd7 100644 --- a/tests/baselines/reference/templateStringInArray.types +++ b/tests/baselines/reference/templateStringInArray.types @@ -2,8 +2,8 @@ var x = [1, 2, `abc${ 123 }def`]; >x : (string | number)[] >[1, 2, `abc${ 123 }def`] : (string | number)[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 >`abc${ 123 }def` : string ->123 : number +>123 : 123 diff --git a/tests/baselines/reference/templateStringInConditional.types b/tests/baselines/reference/templateStringInConditional.types index bb5de339533..a375d572a5d 100644 --- a/tests/baselines/reference/templateStringInConditional.types +++ b/tests/baselines/reference/templateStringInConditional.types @@ -3,9 +3,9 @@ var x = `abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def`; >x : string >`abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def` : string >`abc${ " " }def` : string ->" " : string +>" " : " " >`abc${ " " }def` : string ->" " : string +>" " : " " >`abc${ " " }def` : string ->" " : string +>" " : " " diff --git a/tests/baselines/reference/templateStringInConditionalES6.types b/tests/baselines/reference/templateStringInConditionalES6.types index 060b81b2ab7..0f65ab22977 100644 --- a/tests/baselines/reference/templateStringInConditionalES6.types +++ b/tests/baselines/reference/templateStringInConditionalES6.types @@ -3,9 +3,9 @@ var x = `abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def`; >x : string >`abc${ " " }def` ? `abc${ " " }def` : `abc${ " " }def` : string >`abc${ " " }def` : string ->" " : string +>" " : " " >`abc${ " " }def` : string ->" " : string +>" " : " " >`abc${ " " }def` : string ->" " : string +>" " : " " diff --git a/tests/baselines/reference/templateStringInDeleteExpression.types b/tests/baselines/reference/templateStringInDeleteExpression.types index ff950555fb9..1ae84e4e2ff 100644 --- a/tests/baselines/reference/templateStringInDeleteExpression.types +++ b/tests/baselines/reference/templateStringInDeleteExpression.types @@ -2,5 +2,5 @@ delete `abc${0}abc`; >delete `abc${0}abc` : boolean >`abc${0}abc` : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/templateStringInDeleteExpressionES6.types b/tests/baselines/reference/templateStringInDeleteExpressionES6.types index a182754dc68..80569e533e4 100644 --- a/tests/baselines/reference/templateStringInDeleteExpressionES6.types +++ b/tests/baselines/reference/templateStringInDeleteExpressionES6.types @@ -2,5 +2,5 @@ delete `abc${0}abc`; >delete `abc${0}abc` : boolean >`abc${0}abc` : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/templateStringInEqualityChecks.types b/tests/baselines/reference/templateStringInEqualityChecks.types index 2f1b2cf987b..dd78aa131d4 100644 --- a/tests/baselines/reference/templateStringInEqualityChecks.types +++ b/tests/baselines/reference/templateStringInEqualityChecks.types @@ -4,7 +4,7 @@ var x = `abc${0}abc` === `abc` || >`abc${0}abc` === `abc` || `abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" && "abc0abc" !== `abc${0}abc` : boolean >`abc${0}abc` === `abc` : boolean >`abc${0}abc` : string ->0 : number +>0 : 0 >`abc` : string `abc` !== `abc${0}abc` && @@ -13,17 +13,17 @@ var x = `abc${0}abc` === `abc` || >`abc` !== `abc${0}abc` : boolean >`abc` : string >`abc${0}abc` : string ->0 : number +>0 : 0 `abc${0}abc` == "abc0abc" && >`abc${0}abc` == "abc0abc" : boolean >`abc${0}abc` : string ->0 : number +>0 : 0 >"abc0abc" : "abc0abc" "abc0abc" !== `abc${0}abc`; >"abc0abc" !== `abc${0}abc` : boolean >"abc0abc" : "abc0abc" >`abc${0}abc` : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/templateStringInEqualityChecksES6.types b/tests/baselines/reference/templateStringInEqualityChecksES6.types index ce552da09ea..b3ef2b89720 100644 --- a/tests/baselines/reference/templateStringInEqualityChecksES6.types +++ b/tests/baselines/reference/templateStringInEqualityChecksES6.types @@ -4,7 +4,7 @@ var x = `abc${0}abc` === `abc` || >`abc${0}abc` === `abc` || `abc` !== `abc${0}abc` && `abc${0}abc` == "abc0abc" && "abc0abc" !== `abc${0}abc` : boolean >`abc${0}abc` === `abc` : boolean >`abc${0}abc` : string ->0 : number +>0 : 0 >`abc` : string `abc` !== `abc${0}abc` && @@ -13,17 +13,17 @@ var x = `abc${0}abc` === `abc` || >`abc` !== `abc${0}abc` : boolean >`abc` : string >`abc${0}abc` : string ->0 : number +>0 : 0 `abc${0}abc` == "abc0abc" && >`abc${0}abc` == "abc0abc" : boolean >`abc${0}abc` : string ->0 : number +>0 : 0 >"abc0abc" : "abc0abc" "abc0abc" !== `abc${0}abc`; >"abc0abc" !== `abc${0}abc` : boolean >"abc0abc" : "abc0abc" >`abc${0}abc` : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/templateStringInFunctionExpression.types b/tests/baselines/reference/templateStringInFunctionExpression.types index 62e34b5fc2d..af92d867acd 100644 --- a/tests/baselines/reference/templateStringInFunctionExpression.types +++ b/tests/baselines/reference/templateStringInFunctionExpression.types @@ -6,10 +6,10 @@ var x = function y() { `abc${ 0 }def` >`abc${ 0 }def` : string ->0 : number +>0 : 0 return `abc${ 0 }def`; >`abc${ 0 }def` : string ->0 : number +>0 : 0 }; diff --git a/tests/baselines/reference/templateStringInFunctionExpressionES6.types b/tests/baselines/reference/templateStringInFunctionExpressionES6.types index 268928125c5..2ab90b9e374 100644 --- a/tests/baselines/reference/templateStringInFunctionExpressionES6.types +++ b/tests/baselines/reference/templateStringInFunctionExpressionES6.types @@ -6,10 +6,10 @@ var x = function y() { `abc${ 0 }def` >`abc${ 0 }def` : string ->0 : number +>0 : 0 return `abc${ 0 }def`; >`abc${ 0 }def` : string ->0 : number +>0 : 0 }; diff --git a/tests/baselines/reference/templateStringInInOperator.types b/tests/baselines/reference/templateStringInInOperator.types index 881f37221fe..5ed944af496 100644 --- a/tests/baselines/reference/templateStringInInOperator.types +++ b/tests/baselines/reference/templateStringInInOperator.types @@ -3,10 +3,10 @@ var x = `${ "hi" }` in { hi: 10, hello: 20}; >x : boolean >`${ "hi" }` in { hi: 10, hello: 20} : boolean >`${ "hi" }` : string ->"hi" : string +>"hi" : "hi" >{ hi: 10, hello: 20} : { hi: number; hello: number; } >hi : number ->10 : number +>10 : 10 >hello : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/templateStringInInOperatorES6.types b/tests/baselines/reference/templateStringInInOperatorES6.types index 4297338ba56..335b77380c2 100644 --- a/tests/baselines/reference/templateStringInInOperatorES6.types +++ b/tests/baselines/reference/templateStringInInOperatorES6.types @@ -3,10 +3,10 @@ var x = `${ "hi" }` in { hi: 10, hello: 20}; >x : boolean >`${ "hi" }` in { hi: 10, hello: 20} : boolean >`${ "hi" }` : string ->"hi" : string +>"hi" : "hi" >{ hi: 10, hello: 20} : { hi: number; hello: number; } >hi : number ->10 : number +>10 : 10 >hello : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/templateStringInIndexExpression.types b/tests/baselines/reference/templateStringInIndexExpression.types index ff5461158ab..b453c37f4c5 100644 --- a/tests/baselines/reference/templateStringInIndexExpression.types +++ b/tests/baselines/reference/templateStringInIndexExpression.types @@ -2,6 +2,6 @@ `abc${0}abc`[`0`]; >`abc${0}abc`[`0`] : any >`abc${0}abc` : string ->0 : number +>0 : 0 >`0` : string diff --git a/tests/baselines/reference/templateStringInIndexExpressionES6.types b/tests/baselines/reference/templateStringInIndexExpressionES6.types index 153bed9f97a..b7be602e893 100644 --- a/tests/baselines/reference/templateStringInIndexExpressionES6.types +++ b/tests/baselines/reference/templateStringInIndexExpressionES6.types @@ -2,6 +2,6 @@ `abc${0}abc`[`0`]; >`abc${0}abc`[`0`] : any >`abc${0}abc` : string ->0 : number +>0 : 0 >`0` : string diff --git a/tests/baselines/reference/templateStringInParentheses.types b/tests/baselines/reference/templateStringInParentheses.types index 29436a32d2a..ca9b328d5b5 100644 --- a/tests/baselines/reference/templateStringInParentheses.types +++ b/tests/baselines/reference/templateStringInParentheses.types @@ -3,5 +3,5 @@ var x = (`abc${0}abc`); >x : string >(`abc${0}abc`) : string >`abc${0}abc` : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/templateStringInParenthesesES6.types b/tests/baselines/reference/templateStringInParenthesesES6.types index 0d4d89ef3a9..518ad880918 100644 --- a/tests/baselines/reference/templateStringInParenthesesES6.types +++ b/tests/baselines/reference/templateStringInParenthesesES6.types @@ -3,5 +3,5 @@ var x = (`abc${0}abc`); >x : string >(`abc${0}abc`) : string >`abc${0}abc` : string ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/templateStringInPropertyAssignment.types b/tests/baselines/reference/templateStringInPropertyAssignment.types index a8ba0351311..c47a921e941 100644 --- a/tests/baselines/reference/templateStringInPropertyAssignment.types +++ b/tests/baselines/reference/templateStringInPropertyAssignment.types @@ -6,6 +6,6 @@ var x = { a: `abc${ 123 }def${ 456 }ghi` >a : string >`abc${ 123 }def${ 456 }ghi` : string ->123 : number ->456 : number +>123 : 123 +>456 : 456 } diff --git a/tests/baselines/reference/templateStringInPropertyAssignmentES6.types b/tests/baselines/reference/templateStringInPropertyAssignmentES6.types index 5da8d9ac6f9..43a9e0f5507 100644 --- a/tests/baselines/reference/templateStringInPropertyAssignmentES6.types +++ b/tests/baselines/reference/templateStringInPropertyAssignmentES6.types @@ -6,6 +6,6 @@ var x = { a: `abc${ 123 }def${ 456 }ghi` >a : string >`abc${ 123 }def${ 456 }ghi` : string ->123 : number ->456 : number +>123 : 123 +>456 : 456 } diff --git a/tests/baselines/reference/templateStringInSwitchAndCase.types b/tests/baselines/reference/templateStringInSwitchAndCase.types index 0949aa21fde..a0f8602167a 100644 --- a/tests/baselines/reference/templateStringInSwitchAndCase.types +++ b/tests/baselines/reference/templateStringInSwitchAndCase.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/templates/templateStringInSwitchAndCase.ts === switch (`abc${0}abc`) { >`abc${0}abc` : string ->0 : number +>0 : 0 case `abc`: >`abc` : string @@ -11,9 +11,9 @@ switch (`abc${0}abc`) { case `abc${0}abc`: >`abc${0}abc` : string ->0 : number +>0 : 0 `def${1}def`; >`def${1}def` : string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/templateStringInSwitchAndCaseES6.types b/tests/baselines/reference/templateStringInSwitchAndCaseES6.types index a9ba35c8599..0cde7e58756 100644 --- a/tests/baselines/reference/templateStringInSwitchAndCaseES6.types +++ b/tests/baselines/reference/templateStringInSwitchAndCaseES6.types @@ -1,7 +1,7 @@ === tests/cases/conformance/es6/templates/templateStringInSwitchAndCaseES6.ts === switch (`abc${0}abc`) { >`abc${0}abc` : string ->0 : number +>0 : 0 case `abc`: >`abc` : string @@ -11,9 +11,9 @@ switch (`abc${0}abc`) { case `abc${0}abc`: >`abc${0}abc` : string ->0 : number +>0 : 0 `def${1}def`; >`def${1}def` : string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/templateStringInTypeAssertion.types b/tests/baselines/reference/templateStringInTypeAssertion.types index 73ed437adb3..c8950634a36 100644 --- a/tests/baselines/reference/templateStringInTypeAssertion.types +++ b/tests/baselines/reference/templateStringInTypeAssertion.types @@ -3,5 +3,5 @@ var x = `abc${ 123 }def`; >x : any >`abc${ 123 }def` : any >`abc${ 123 }def` : string ->123 : number +>123 : 123 diff --git a/tests/baselines/reference/templateStringInTypeAssertionES6.types b/tests/baselines/reference/templateStringInTypeAssertionES6.types index 26d4689f939..becccd73738 100644 --- a/tests/baselines/reference/templateStringInTypeAssertionES6.types +++ b/tests/baselines/reference/templateStringInTypeAssertionES6.types @@ -3,5 +3,5 @@ var x = `abc${ 123 }def`; >x : any >`abc${ 123 }def` : any >`abc${ 123 }def` : string ->123 : number +>123 : 123 diff --git a/tests/baselines/reference/templateStringInTypeOf.types b/tests/baselines/reference/templateStringInTypeOf.types index 550828b3a47..0d7d26a82b2 100644 --- a/tests/baselines/reference/templateStringInTypeOf.types +++ b/tests/baselines/reference/templateStringInTypeOf.types @@ -3,5 +3,5 @@ var x = typeof `abc${ 123 }def`; >x : string >typeof `abc${ 123 }def` : string >`abc${ 123 }def` : string ->123 : number +>123 : 123 diff --git a/tests/baselines/reference/templateStringInTypeOfES6.types b/tests/baselines/reference/templateStringInTypeOfES6.types index b04e37426a4..ad142d13fe5 100644 --- a/tests/baselines/reference/templateStringInTypeOfES6.types +++ b/tests/baselines/reference/templateStringInTypeOfES6.types @@ -3,5 +3,5 @@ var x = typeof `abc${ 123 }def`; >x : string >typeof `abc${ 123 }def` : string >`abc${ 123 }def` : string ->123 : number +>123 : 123 diff --git a/tests/baselines/reference/templateStringInUnaryPlus.types b/tests/baselines/reference/templateStringInUnaryPlus.types index bab86198433..aa2b4fe4f2d 100644 --- a/tests/baselines/reference/templateStringInUnaryPlus.types +++ b/tests/baselines/reference/templateStringInUnaryPlus.types @@ -3,5 +3,5 @@ var x = +`abc${ 123 }def`; >x : number >+`abc${ 123 }def` : number >`abc${ 123 }def` : string ->123 : number +>123 : 123 diff --git a/tests/baselines/reference/templateStringInUnaryPlusES6.types b/tests/baselines/reference/templateStringInUnaryPlusES6.types index d632e8e2965..8286fa8b6c1 100644 --- a/tests/baselines/reference/templateStringInUnaryPlusES6.types +++ b/tests/baselines/reference/templateStringInUnaryPlusES6.types @@ -3,5 +3,5 @@ var x = +`abc${ 123 }def`; >x : number >+`abc${ 123 }def` : number >`abc${ 123 }def` : string ->123 : number +>123 : 123 diff --git a/tests/baselines/reference/templateStringInWhile.types b/tests/baselines/reference/templateStringInWhile.types index fe4931455e2..c0914ee771c 100644 --- a/tests/baselines/reference/templateStringInWhile.types +++ b/tests/baselines/reference/templateStringInWhile.types @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/templates/templateStringInWhile.ts === while (`abc${0}abc`) { >`abc${0}abc` : string ->0 : number +>0 : 0 `def${1}def`; >`def${1}def` : string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/templateStringInWhileES6.types b/tests/baselines/reference/templateStringInWhileES6.types index ef2c3d02cae..29119d7f77e 100644 --- a/tests/baselines/reference/templateStringInWhileES6.types +++ b/tests/baselines/reference/templateStringInWhileES6.types @@ -1,9 +1,9 @@ === tests/cases/conformance/es6/templates/templateStringInWhileES6.ts === while (`abc${0}abc`) { >`abc${0}abc` : string ->0 : number +>0 : 0 `def${1}def`; >`def${1}def` : string ->1 : number +>1 : 1 } diff --git a/tests/baselines/reference/templateStringPlainCharactersThatArePartsOfEscapes02.types b/tests/baselines/reference/templateStringPlainCharactersThatArePartsOfEscapes02.types index e7cc81af06c..62d0190586a 100644 --- a/tests/baselines/reference/templateStringPlainCharactersThatArePartsOfEscapes02.types +++ b/tests/baselines/reference/templateStringPlainCharactersThatArePartsOfEscapes02.types @@ -3,33 +3,33 @@ `0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n` >`0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n` : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " diff --git a/tests/baselines/reference/templateStringPlainCharactersThatArePartsOfEscapes02_ES6.types b/tests/baselines/reference/templateStringPlainCharactersThatArePartsOfEscapes02_ES6.types index 9b91b5db72c..cf07cae5b93 100644 --- a/tests/baselines/reference/templateStringPlainCharactersThatArePartsOfEscapes02_ES6.types +++ b/tests/baselines/reference/templateStringPlainCharactersThatArePartsOfEscapes02_ES6.types @@ -2,33 +2,33 @@ `0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n` >`0${ " " }1${ " " }2${ " " }3${ " " }4${ " " }5${ " " }6${ " " }7${ " " }8${ " " }9${ " " }10${ " " }11${ " " }12${ " " }13${ " " }14${ " " }15${ " " }16${ " " }17${ " " }18${ " " }19${ " " }20${ " " }2028${ " " }2029${ " " }0085${ " " }t${ " " }v${ " " }f${ " " }b${ " " }r${ " " }n` : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string ->" " : string +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " +>" " : " " diff --git a/tests/baselines/reference/templateStringWithEmbeddedAddition.types b/tests/baselines/reference/templateStringWithEmbeddedAddition.types index 02173dc026f..56bc197c377 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedAddition.types +++ b/tests/baselines/reference/templateStringWithEmbeddedAddition.types @@ -3,6 +3,6 @@ var x = `abc${ 10 + 10 }def`; >x : string >`abc${ 10 + 10 }def` : string >10 + 10 : number ->10 : number ->10 : number +>10 : 10 +>10 : 10 diff --git a/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.types b/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.types index ec33cee95f1..6ee46c39f57 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedAdditionES6.types @@ -3,6 +3,6 @@ var x = `abc${ 10 + 10 }def`; >x : string >`abc${ 10 + 10 }def` : string >10 + 10 : number ->10 : number ->10 : number +>10 : 10 +>10 : 10 diff --git a/tests/baselines/reference/templateStringWithEmbeddedArray.types b/tests/baselines/reference/templateStringWithEmbeddedArray.types index 2842936c502..b82fa26d400 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedArray.types +++ b/tests/baselines/reference/templateStringWithEmbeddedArray.types @@ -3,7 +3,7 @@ var x = `abc${ [1,2,3] }def`; >x : string >`abc${ [1,2,3] }def` : string >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 diff --git a/tests/baselines/reference/templateStringWithEmbeddedArrayES6.types b/tests/baselines/reference/templateStringWithEmbeddedArrayES6.types index 2f8e67f0539..e8701a7f4c3 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedArrayES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedArrayES6.types @@ -3,7 +3,7 @@ var x = `abc${ [1,2,3] }def`; >x : string >`abc${ [1,2,3] }def` : string >[1,2,3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 diff --git a/tests/baselines/reference/templateStringWithEmbeddedComments.types b/tests/baselines/reference/templateStringWithEmbeddedComments.types index 46a5fd3b091..f948a8bdaaf 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedComments.types +++ b/tests/baselines/reference/templateStringWithEmbeddedComments.types @@ -3,7 +3,7 @@ >`head${ // single line comment10}middle${/* Multi- * line * comment */ 20 // closing comment}tail` : string 10 ->10 : number +>10 : 10 } middle${ /* Multi- @@ -11,7 +11,7 @@ middle${ * comment */ 20 ->20 : number +>20 : 20 // closing comment } diff --git a/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.types b/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.types index 0eaf40cafac..cd2e0b23441 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedCommentsES6.types @@ -3,7 +3,7 @@ >`head${ // single line comment10}middle${/* Multi- * line * comment */ 20 // closing comment}tail` : string 10 ->10 : number +>10 : 10 } middle${ /* Multi- @@ -11,7 +11,7 @@ middle${ * comment */ 20 ->20 : number +>20 : 20 // closing comment } diff --git a/tests/baselines/reference/templateStringWithEmbeddedConditional.types b/tests/baselines/reference/templateStringWithEmbeddedConditional.types index 7ec1ef97a30..d79433e7b8a 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedConditional.types +++ b/tests/baselines/reference/templateStringWithEmbeddedConditional.types @@ -2,8 +2,8 @@ var x = `abc${ true ? false : " " }def`; >x : string >`abc${ true ? false : " " }def` : string ->true ? false : " " : string | boolean ->true : boolean ->false : boolean ->" " : string +>true ? false : " " : false | " " +>true : true +>false : false +>" " : " " diff --git a/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types b/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types index 5453880ce16..1ddc81a19e7 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedConditionalES6.types @@ -2,8 +2,8 @@ var x = `abc${ true ? false : " " }def`; >x : string >`abc${ true ? false : " " }def` : string ->true ? false : " " : string | boolean ->true : boolean ->false : boolean ->" " : string +>true ? false : " " : false | " " +>true : true +>false : false +>" " : " " diff --git a/tests/baselines/reference/templateStringWithEmbeddedDivision.types b/tests/baselines/reference/templateStringWithEmbeddedDivision.types index 440d162933b..6f891375624 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedDivision.types +++ b/tests/baselines/reference/templateStringWithEmbeddedDivision.types @@ -3,6 +3,6 @@ var x = `abc${ 1 / 1 }def`; >x : string >`abc${ 1 / 1 }def` : string >1 / 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.types b/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.types index 7a5980bae9e..f91b3a27639 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedDivisionES6.types @@ -3,6 +3,6 @@ var x = `abc${ 1 / 1 }def`; >x : string >`abc${ 1 / 1 }def` : string >1 / 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/templateStringWithEmbeddedInOperator.types b/tests/baselines/reference/templateStringWithEmbeddedInOperator.types index d693dd276d1..f97ca55b633 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedInOperator.types +++ b/tests/baselines/reference/templateStringWithEmbeddedInOperator.types @@ -3,10 +3,10 @@ var x = `abc${ "hi" in { hi: 10, hello: 20} }def`; >x : string >`abc${ "hi" in { hi: 10, hello: 20} }def` : string >"hi" in { hi: 10, hello: 20} : boolean ->"hi" : string +>"hi" : "hi" >{ hi: 10, hello: 20} : { hi: number; hello: number; } >hi : number ->10 : number +>10 : 10 >hello : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.types index ff5be5f4d82..a1346c2ce6d 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedInOperatorES6.types @@ -3,10 +3,10 @@ var x = `abc${ "hi" in { hi: 10, hello: 20} }def`; >x : string >`abc${ "hi" in { hi: 10, hello: 20} }def` : string >"hi" in { hi: 10, hello: 20} : boolean ->"hi" : string +>"hi" : "hi" >{ hi: 10, hello: 20} : { hi: number; hello: number; } >hi : number ->10 : number +>10 : 10 >hello : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/templateStringWithEmbeddedModulo.types b/tests/baselines/reference/templateStringWithEmbeddedModulo.types index fc5d3d2560d..c4711809563 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedModulo.types +++ b/tests/baselines/reference/templateStringWithEmbeddedModulo.types @@ -3,6 +3,6 @@ var x = `abc${ 1 % 1 }def`; >x : string >`abc${ 1 % 1 }def` : string >1 % 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/templateStringWithEmbeddedModuloES6.types b/tests/baselines/reference/templateStringWithEmbeddedModuloES6.types index 35ae5473bef..2a1e6b602e2 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedModuloES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedModuloES6.types @@ -3,6 +3,6 @@ var x = `abc${ 1 % 1 }def`; >x : string >`abc${ 1 % 1 }def` : string >1 % 1 : number ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/templateStringWithEmbeddedMultiplication.types b/tests/baselines/reference/templateStringWithEmbeddedMultiplication.types index 6d81cabc169..f442ab3165b 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedMultiplication.types +++ b/tests/baselines/reference/templateStringWithEmbeddedMultiplication.types @@ -3,6 +3,6 @@ var x = `abc${ 7 * 6 }def`; >x : string >`abc${ 7 * 6 }def` : string >7 * 6 : number ->7 : number ->6 : number +>7 : 7 +>6 : 6 diff --git a/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.types b/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.types index c4235f8535e..3e9f15773ef 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedMultiplicationES6.types @@ -3,6 +3,6 @@ var x = `abc${ 7 * 6 }def`; >x : string >`abc${ 7 * 6 }def` : string >7 * 6 : number ->7 : number ->6 : number +>7 : 7 +>6 : 6 diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types b/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types index bcc90c42c74..1e358a571b3 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperator.types @@ -4,5 +4,5 @@ var x = `abc${ new String("Hi") }def`; >`abc${ new String("Hi") }def` : string >new String("Hi") : String >String : StringConstructor ->"Hi" : string +>"Hi" : "Hi" diff --git a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types index be58edbe4d8..4939c6f867f 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedNewOperatorES6.types @@ -4,5 +4,5 @@ var x = `abc${ new String("Hi") }def`; >`abc${ new String("Hi") }def` : string >new String("Hi") : String >String : StringConstructor ->"Hi" : string +>"Hi" : "Hi" diff --git a/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.types b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.types index 0ff7fc140bb..9854e4e9056 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.types +++ b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteral.types @@ -4,7 +4,7 @@ var x = `abc${ { x: 10, y: 20 } }def`; >`abc${ { x: 10, y: 20 } }def` : string >{ x: 10, y: 20 } : { x: number; y: number; } >x : number ->10 : number +>10 : 10 >y : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.types b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.types index 4a5df4707b7..db086517791 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedObjectLiteralES6.types @@ -4,7 +4,7 @@ var x = `abc${ { x: 10, y: 20 } }def`; >`abc${ { x: 10, y: 20 } }def` : string >{ x: 10, y: 20 } : { x: number; y: number; } >x : number ->10 : number +>10 : 10 >y : number ->20 : number +>20 : 20 diff --git a/tests/baselines/reference/templateStringWithEmbeddedTemplateString.types b/tests/baselines/reference/templateStringWithEmbeddedTemplateString.types index acda0c7a7ec..cef4f69c0a9 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTemplateString.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTemplateString.types @@ -3,7 +3,7 @@ var x = `123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321`; >x : string >`123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321` : string >`456 ${ " | " } 654` : string ->" | " : string +>" | " : " | " >`456 ${ " | " } 654` : string ->" | " : string +>" | " : " | " diff --git a/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.types b/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.types index 252765cb7c0..12532c8402e 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTemplateStringES6.types @@ -3,7 +3,7 @@ var x = `123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321`; >x : string >`123${ `456 ${ " | " } 654` }321 123${ `456 ${ " | " } 654` }321` : string >`456 ${ " | " } 654` : string ->" | " : string +>" | " : " | " >`456 ${ " | " } 654` : string ->" | " : string +>" | " : " | " diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.types b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.types index 98254cad8b7..898263825af 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAddition.types @@ -5,6 +5,6 @@ var x = `abc${ (10 + 10) }def`; >(10 + 10) : any >(10 + 10) : number >10 + 10 : number ->10 : number ->10 : number +>10 : 10 +>10 : 10 diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.types b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.types index ac74625f57a..e9e81a2d097 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeAssertionOnAdditionES6.types @@ -5,6 +5,6 @@ var x = `abc${ (10 + 10) }def`; >(10 + 10) : any >(10 + 10) : number >10 + 10 : number ->10 : number ->10 : number +>10 : 10 +>10 : 10 diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types index e63ea3aac69..48330140ad3 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperator.types @@ -3,5 +3,5 @@ var x = `abc${ typeof "hi" }def`; >x : string >`abc${ typeof "hi" }def` : string >typeof "hi" : string ->"hi" : string +>"hi" : "hi" diff --git a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types index 0692eaccb5e..3d7eba45c19 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedTypeOfOperatorES6.types @@ -3,5 +3,5 @@ var x = `abc${ typeof "hi" }def`; >x : string >`abc${ typeof "hi" }def` : string >typeof "hi" : string ->"hi" : string +>"hi" : "hi" diff --git a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types index 3a6f5d16726..e4496aa4e8b 100644 --- a/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types +++ b/tests/baselines/reference/templateStringWithEmbeddedYieldKeywordES6.types @@ -1,12 +1,12 @@ === tests/cases/conformance/es6/templates/templateStringWithEmbeddedYieldKeywordES6.ts === function* gen() { ->gen : () => IterableIterator +>gen : () => IterableIterator<10> // Once this is supported, yield *must* be parenthesized. var x = `abc${ yield 10 }def`; >x : string >`abc${ yield 10 }def` : string >yield 10 : any ->10 : number +>10 : 10 } diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types index f88ca5e7493..f20ab1552e3 100644 --- a/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortions.types @@ -6,68 +6,68 @@ var a = ``; var b = `${ 0 }`; >b : string >`${ 0 }` : string ->0 : number +>0 : 0 var c = `1${ 0 }`; >c : string >`1${ 0 }` : string ->0 : number +>0 : 0 var d = `${ 0 }2`; >d : string >`${ 0 }2` : string ->0 : number +>0 : 0 var e = `1${ 0 }2`; >e : string >`1${ 0 }2` : string ->0 : number +>0 : 0 var f = `${ 0 }${ 0 }`; >f : string >`${ 0 }${ 0 }` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var g = `1${ 0 }${ 0 }`; >g : string >`1${ 0 }${ 0 }` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var h = `${ 0 }2${ 0 }`; >h : string >`${ 0 }2${ 0 }` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var i = `1${ 0 }2${ 0 }`; >i : string >`1${ 0 }2${ 0 }` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var j = `${ 0 }${ 0 }3`; >j : string >`${ 0 }${ 0 }3` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var k = `1${ 0 }${ 0 }3`; >k : string >`1${ 0 }${ 0 }3` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var l = `${ 0 }2${ 0 }3`; >l : string >`${ 0 }2${ 0 }3` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var m = `1${ 0 }2${ 0 }3`; >m : string >`1${ 0 }2${ 0 }3` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 diff --git a/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types index 068da7f9484..73eeeaae045 100644 --- a/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types +++ b/tests/baselines/reference/templateStringWithEmptyLiteralPortionsES6.types @@ -6,68 +6,68 @@ var a = ``; var b = `${ 0 }`; >b : string >`${ 0 }` : string ->0 : number +>0 : 0 var c = `1${ 0 }`; >c : string >`1${ 0 }` : string ->0 : number +>0 : 0 var d = `${ 0 }2`; >d : string >`${ 0 }2` : string ->0 : number +>0 : 0 var e = `1${ 0 }2`; >e : string >`1${ 0 }2` : string ->0 : number +>0 : 0 var f = `${ 0 }${ 0 }`; >f : string >`${ 0 }${ 0 }` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var g = `1${ 0 }${ 0 }`; >g : string >`1${ 0 }${ 0 }` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var h = `${ 0 }2${ 0 }`; >h : string >`${ 0 }2${ 0 }` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var i = `1${ 0 }2${ 0 }`; >i : string >`1${ 0 }2${ 0 }` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var j = `${ 0 }${ 0 }3`; >j : string >`${ 0 }${ 0 }3` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var k = `1${ 0 }${ 0 }3`; >k : string >`1${ 0 }${ 0 }3` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var l = `${ 0 }2${ 0 }3`; >l : string >`${ 0 }2${ 0 }3` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 var m = `1${ 0 }2${ 0 }3`; >m : string >`1${ 0 }2${ 0 }3` : string ->0 : number ->0 : number +>0 : 0 +>0 : 0 diff --git a/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.types b/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.types index 9adee375396..8c6d4dc2e79 100644 --- a/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.types +++ b/tests/baselines/reference/templateStringWithOpenCommentInStringPortion.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortion.ts === ` /**head ${ 10 } // still middle ${ 20 } /* still tail ` >` /**head ${ 10 } // still middle ${ 20 } /* still tail ` : string ->10 : number ->20 : number +>10 : 10 +>20 : 20 diff --git a/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.types b/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.types index ea1513756de..fa9ede6976b 100644 --- a/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.types +++ b/tests/baselines/reference/templateStringWithOpenCommentInStringPortionES6.types @@ -1,6 +1,6 @@ === tests/cases/conformance/es6/templates/templateStringWithOpenCommentInStringPortionES6.ts === ` /**head ${ 10 } // still middle ${ 20 } /* still tail ` >` /**head ${ 10 } // still middle ${ 20 } /* still tail ` : string ->10 : number ->20 : number +>10 : 10 +>20 : 20 diff --git a/tests/baselines/reference/templateStringWithPropertyAccess.types b/tests/baselines/reference/templateStringWithPropertyAccess.types index 6afb7402970..21749c848da 100644 --- a/tests/baselines/reference/templateStringWithPropertyAccess.types +++ b/tests/baselines/reference/templateStringWithPropertyAccess.types @@ -3,7 +3,7 @@ >`abc${0}abc`.indexOf(`abc`) : number >`abc${0}abc`.indexOf : (searchString: string, position?: number) => number >`abc${0}abc` : string ->0 : number +>0 : 0 >indexOf : (searchString: string, position?: number) => number >`abc` : string diff --git a/tests/baselines/reference/templateStringWithPropertyAccessES6.types b/tests/baselines/reference/templateStringWithPropertyAccessES6.types index bdbded8be4a..3e297e6bf07 100644 --- a/tests/baselines/reference/templateStringWithPropertyAccessES6.types +++ b/tests/baselines/reference/templateStringWithPropertyAccessES6.types @@ -3,7 +3,7 @@ >`abc${0}abc`.indexOf(`abc`) : number >`abc${0}abc`.indexOf : (searchString: string, position?: number) => number >`abc${0}abc` : string ->0 : number +>0 : 0 >indexOf : (searchString: string, position?: number) => number >`abc` : string diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt index 7204f32dba2..6b11fdb661a 100644 --- a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt +++ b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(3,27): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts(3,27): error TS2322: Type '"bad"' is not assignable to type 'number'. ==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpression.ts (1 errors) ==== @@ -6,4 +6,4 @@ tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpr `${function (x: number) { x = "bad"; } }`; ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type '"bad"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt index 9fece57ef5e..8d5a8bb4885 100644 --- a/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt +++ b/tests/baselines/reference/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(2,27): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts(2,27): error TS2322: Type '"bad"' is not assignable to type 'number'. ==== tests/cases/conformance/es6/templates/templateStringsWithTypeErrorInFunctionExpressionsInSubstitutionExpressionES6.ts (1 errors) ==== `${function (x: number) { x = "bad"; } }`; ~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. \ No newline at end of file +!!! error TS2322: Type '"bad"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/ternaryExpressionSourceMap.types b/tests/baselines/reference/ternaryExpressionSourceMap.types index d74a175635a..d6d17091b43 100644 --- a/tests/baselines/reference/ternaryExpressionSourceMap.types +++ b/tests/baselines/reference/ternaryExpressionSourceMap.types @@ -2,14 +2,14 @@ var x = 1; >x : number ->1 : number +>1 : 1 var foo = x ? () => 0 : () => 0; >foo : () => number >x ? () => 0 : () => 0 : () => number >x : number >() => 0 : () => number ->0 : number +>0 : 0 >() => 0 : () => number ->0 : number +>0 : 0 diff --git a/tests/baselines/reference/thisBinding2.types b/tests/baselines/reference/thisBinding2.types index 99668ca4901..dbd9f83c741 100644 --- a/tests/baselines/reference/thisBinding2.types +++ b/tests/baselines/reference/thisBinding2.types @@ -17,7 +17,7 @@ class C { var x = 1; >x : number ->1 : number +>1 : 1 return this.x; >this.x : number @@ -35,7 +35,7 @@ class C { var x = 1; >x : number ->1 : number +>1 : 1 return this.x; >this.x : any @@ -57,7 +57,7 @@ var messenger = { message: "Hello World", >message : string ->"Hello World" : string +>"Hello World" : "Hello World" start: function () { >start : () => number @@ -71,7 +71,7 @@ var messenger = { >this.message : any >this : any >message : any ->3000 : number +>3000 : 3000 } }; diff --git a/tests/baselines/reference/thisCapture1.types b/tests/baselines/reference/thisCapture1.types index eb4501203ca..ff9e9e3b9fe 100644 --- a/tests/baselines/reference/thisCapture1.types +++ b/tests/baselines/reference/thisCapture1.types @@ -4,7 +4,7 @@ class X { private y = 0; >y : number ->0 : number +>0 : 0 public getSettings(keys: string[]): any { >getSettings : (keys: string[]) => any @@ -23,11 +23,11 @@ class X { >() => { this.y = 0; } : () => void this.y = 0; ->this.y = 0 : number +>this.y = 0 : 0 >this.y : number >this : this >y : number ->0 : number +>0 : 0 }).promise(); >promise : any diff --git a/tests/baselines/reference/thisInGenericStaticMembers.types b/tests/baselines/reference/thisInGenericStaticMembers.types index 8d4aabe2812..082ffb588a5 100644 --- a/tests/baselines/reference/thisInGenericStaticMembers.types +++ b/tests/baselines/reference/thisInGenericStaticMembers.types @@ -30,7 +30,7 @@ class A { >one : (source: T, value: number) => T >T : T >source : T ->42 : number +>42 : 42 } } @@ -60,7 +60,7 @@ class B { >this : typeof B >one : (source: B, value: number) => B >source : B ->42 : number +>42 : 42 } } diff --git a/tests/baselines/reference/thisInInnerFunctions.types b/tests/baselines/reference/thisInInnerFunctions.types index 2d0c3363b18..e6c6d2b834c 100644 --- a/tests/baselines/reference/thisInInnerFunctions.types +++ b/tests/baselines/reference/thisInInnerFunctions.types @@ -4,7 +4,7 @@ class Foo { x = "hello"; >x : string ->"hello" : string +>"hello" : "hello" bar() { >bar : () => void @@ -13,11 +13,11 @@ class Foo { >inner : () => void this.y = "hi"; // 'this' should be not type to 'Foo' either ->this.y = "hi" : string +>this.y = "hi" : "hi" >this.y : any >this : any >y : any ->"hi" : string +>"hi" : "hi" var f = () => this.y; // 'this' should be not type to 'Foo' either >f : () => any diff --git a/tests/baselines/reference/thisInLambda.types b/tests/baselines/reference/thisInLambda.types index aea7fb08bd6..a9d5b695750 100644 --- a/tests/baselines/reference/thisInLambda.types +++ b/tests/baselines/reference/thisInLambda.types @@ -4,7 +4,7 @@ class Foo { x = "hello"; >x : string ->"hello" : string +>"hello" : "hello" bar() { >bar : () => void diff --git a/tests/baselines/reference/thisInPropertyBoundDeclarations.types b/tests/baselines/reference/thisInPropertyBoundDeclarations.types index f871e78d219..b783c5c1b5f 100644 --- a/tests/baselines/reference/thisInPropertyBoundDeclarations.types +++ b/tests/baselines/reference/thisInPropertyBoundDeclarations.types @@ -131,14 +131,14 @@ class B { >' ' + function() { } + ' ' + (() => () => () => this) : string >' ' + function() { } + ' ' : string >' ' + function() { } : string ->' ' : string +>' ' : " " function() { >function() { } : () => void } + ' ' + ->' ' : string +>' ' : " " (() => () => () => this); >(() => () => () => this) : () => () => () => this diff --git a/tests/baselines/reference/thisInStaticMethod1.types b/tests/baselines/reference/thisInStaticMethod1.types index fdee20c21bf..6e922737ca9 100644 --- a/tests/baselines/reference/thisInStaticMethod1.types +++ b/tests/baselines/reference/thisInStaticMethod1.types @@ -4,7 +4,7 @@ class foo { static x = 3; >x : number ->3 : number +>3 : 3 static bar() { >bar : () => number diff --git a/tests/baselines/reference/thisTypeInAccessors.types b/tests/baselines/reference/thisTypeInAccessors.types index 998658c5d58..4bf21861051 100644 --- a/tests/baselines/reference/thisTypeInAccessors.types +++ b/tests/baselines/reference/thisTypeInAccessors.types @@ -15,7 +15,7 @@ const explicit = { n: 12, >n : number ->12 : number +>12 : 12 get x(this: Foo): number { return this.n; }, >x : number @@ -42,7 +42,7 @@ const copiedFromGetter = { n: 14, >n : number ->14 : number +>14 : 14 get x(this: Foo): number { return this.n; }, >x : number @@ -67,7 +67,7 @@ const copiedFromSetter = { n: 15, >n : number ->15 : number +>15 : 15 get x() { return this.n }, >x : number @@ -92,7 +92,7 @@ const copiedFromGetterUnannotated = { n: 16, >n : number ->16 : number +>16 : 16 get x(this: Foo) { return this.n }, >x : number @@ -118,7 +118,7 @@ class Explicit { n = 17; >n : number ->17 : number +>17 : 17 get x(this: Foo): number { return this.n; } >x : number @@ -144,7 +144,7 @@ class Contextual { n = 21; >n : number ->21 : number +>21 : 21 get x() { return this.n } // inside a class, so already correct >x : number diff --git a/tests/baselines/reference/thisTypeInFunctions.types b/tests/baselines/reference/thisTypeInFunctions.types index 863ecbce628..e77505835e5 100644 --- a/tests/baselines/reference/thisTypeInFunctions.types +++ b/tests/baselines/reference/thisTypeInFunctions.types @@ -58,7 +58,7 @@ class C { return m + 1; >m + 1 : number >m : number ->1 : number +>1 : 1 } } class D extends C { } @@ -127,16 +127,16 @@ function implicitThis(n: number): number { >this : any >m : any >n : number ->12 : number +>12 : 12 } let impl: I = { >impl : I >I : I ->{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; },} : { a: number; explicitVoid2: () => any; explicitVoid1(this: void): number; explicitStructural(this: { a: number; }): number; explicitInterface(this: I): number; explicitThis(this: I): number; } +>{ a: 12, explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) explicitVoid1() { return 12; }, explicitStructural() { return this.a; }, explicitInterface() { return this.a; }, explicitThis() { return this.a; },} : { a: number; explicitVoid2: () => any; explicitVoid1(this: void): 12; explicitStructural(this: { a: number; }): number; explicitInterface(this: I): number; explicitThis(this: I): number; } a: 12, >a : number ->12 : number +>12 : 12 explicitVoid2: () => this.a, // ok, this: any because it refers to some outer object (window?) >explicitVoid2 : () => any @@ -146,8 +146,8 @@ let impl: I = { >a : any explicitVoid1() { return 12; }, ->explicitVoid1 : (this: void) => number ->12 : number +>explicitVoid1 : (this: void) => 12 +>12 : 12 explicitStructural() { >explicitStructural : (this: { a: number; }) => number @@ -178,20 +178,20 @@ let impl: I = { }, } impl.explicitVoid1 = function () { return 12; }; ->impl.explicitVoid1 = function () { return 12; } : (this: void) => number +>impl.explicitVoid1 = function () { return 12; } : (this: void) => 12 >impl.explicitVoid1 : (this: void) => number >impl : I >explicitVoid1 : (this: void) => number ->function () { return 12; } : (this: void) => number ->12 : number +>function () { return 12; } : (this: void) => 12 +>12 : 12 impl.explicitVoid2 = () => 12; ->impl.explicitVoid2 = () => 12 : () => number +>impl.explicitVoid2 = () => 12 : () => 12 >impl.explicitVoid2 : (this: void) => number >impl : I >explicitVoid2 : (this: void) => number ->() => 12 : () => number ->12 : number +>() => 12 : () => 12 +>12 : 12 impl.explicitStructural = function() { return this.a; }; >impl.explicitStructural = function() { return this.a; } : (this: { a: number; }) => number @@ -214,20 +214,20 @@ impl.explicitInterface = function() { return this.a; }; >a : number impl.explicitStructural = () => 12; ->impl.explicitStructural = () => 12 : () => number +>impl.explicitStructural = () => 12 : () => 12 >impl.explicitStructural : (this: { a: number; }) => number >impl : I >explicitStructural : (this: { a: number; }) => number ->() => 12 : () => number ->12 : number +>() => 12 : () => 12 +>12 : 12 impl.explicitInterface = () => 12; ->impl.explicitInterface = () => 12 : () => number +>impl.explicitInterface = () => 12 : () => 12 >impl.explicitInterface : (this: I) => number >impl : I >explicitInterface : (this: I) => number ->() => 12 : () => number ->12 : number +>() => 12 : () => 12 +>12 : 12 impl.explicitThis = function () { return this.a; }; >impl.explicitThis = function () { return this.a; } : (this: I) => number @@ -249,7 +249,7 @@ let ok: {y: number, f: (this: { y: number }, x: number) => number} = { y: 12, f: >x : number >{ y: 12, f: explicitStructural } : { y: number; f: (this: { y: number; }, x: number) => number; } >y : number ->12 : number +>12 : 12 >f : (this: { y: number; }, x: number) => number >explicitStructural : (this: { y: number; }, x: number) => number @@ -260,7 +260,7 @@ let implicitAnyOk: {notSpecified: number, f: (x: number) => number} = { notSpeci >x : number >{ notSpecified: 12, f: implicitThis } : { notSpecified: number; f: (n: number) => number; } >notSpecified : number ->12 : number +>12 : 12 >f : (n: number) => number >implicitThis : (n: number) => number @@ -269,19 +269,19 @@ ok.f(13); >ok.f : (this: { y: number; }, x: number) => number >ok : { y: number; f: (this: { y: number; }, x: number) => number; } >f : (this: { y: number; }, x: number) => number ->13 : number +>13 : 13 implicitThis(12); >implicitThis(12) : number >implicitThis : (n: number) => number ->12 : number +>12 : 12 implicitAnyOk.f(12); >implicitAnyOk.f(12) : number >implicitAnyOk.f : (x: number) => number >implicitAnyOk : { notSpecified: number; f: (x: number) => number; } >f : (x: number) => number ->12 : number +>12 : 12 let c = new C(); >c : C @@ -304,42 +304,42 @@ c.explicitC(12); >c.explicitC : (this: C, m: number) => number >c : C >explicitC : (this: C, m: number) => number ->12 : number +>12 : 12 c.explicitProperty(12); >c.explicitProperty(12) : number >c.explicitProperty : (this: { n: number; }, m: number) => number >c : C >explicitProperty : (this: { n: number; }, m: number) => number ->12 : number +>12 : 12 c.explicitThis(12); >c.explicitThis(12) : number >c.explicitThis : (this: C, m: number) => number >c : C >explicitThis : (this: C, m: number) => number ->12 : number +>12 : 12 d.explicitC(12); >d.explicitC(12) : number >d.explicitC : (this: C, m: number) => number >d : D >explicitC : (this: C, m: number) => number ->12 : number +>12 : 12 d.explicitProperty(12); >d.explicitProperty(12) : number >d.explicitProperty : (this: { n: number; }, m: number) => number >d : D >explicitProperty : (this: { n: number; }, m: number) => number ->12 : number +>12 : 12 d.explicitThis(12); >d.explicitThis(12) : number >d.explicitThis : (this: D, m: number) => number >d : D >explicitThis : (this: D, m: number) => number ->12 : number +>12 : 12 let reconstructed: { >reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } @@ -375,7 +375,7 @@ let reconstructed: { n: 12, >n : number ->12 : number +>12 : 12 explicitThis: c.explicitThis, >explicitThis : (this: C, m: number) => number @@ -407,14 +407,14 @@ reconstructed.explicitThis(10); >reconstructed.explicitThis : (this: C, m: number) => number >reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >explicitThis : (this: C, m: number) => number ->10 : number +>10 : 10 reconstructed.explicitProperty(11); >reconstructed.explicitProperty(11) : number >reconstructed.explicitProperty : (this: { n: number; }, m: number) => number >reconstructed : { n: number; explicitThis(this: C, m: number): number; explicitC(this: C, m: number): number; explicitProperty: (this: { n: number; }, m: number) => number; explicitVoid(this: void, m: number): number; } >explicitProperty : (this: { n: number; }, m: number) => number ->11 : number +>11 : 11 let explicitVoid = reconstructed.explicitVoid; >explicitVoid : (this: void, m: number) => number @@ -425,7 +425,7 @@ let explicitVoid = reconstructed.explicitVoid; explicitVoid(12); >explicitVoid(12) : number >explicitVoid : (this: void, m: number) => number ->12 : number +>12 : 12 // assignment checking let unboundToSpecified: (this: { y: number }, x: number) => number = x => x + this.y; // ok, this:any @@ -457,7 +457,7 @@ let anyToSpecified: (this: { y: number }, x: number) => number = function(x: num >x : number >x + 12 : number >x : number ->12 : number +>12 : 12 let unspecifiedLambda: (x: number) => number = x => x + 12; >unspecifiedLambda : (x: number) => number @@ -466,7 +466,7 @@ let unspecifiedLambda: (x: number) => number = x => x + 12; >x : number >x + 12 : number >x : number ->12 : number +>12 : 12 let specifiedLambda: (this: void, x: number) => number = x => x + 12; >specifiedLambda : (this: void, x: number) => number @@ -476,7 +476,7 @@ let specifiedLambda: (this: void, x: number) => number = x => x + 12; >x : number >x + 12 : number >x : number ->12 : number +>12 : 12 let unspecifiedLambdaToSpecified: (this: {y: number}, x: number) => number = unspecifiedLambda; >unspecifiedLambdaToSpecified : (this: { y: number; }, x: number) => number @@ -881,11 +881,11 @@ function InterfaceThis(this: I) { >I : I this.a = 12; ->this.a = 12 : number +>this.a = 12 : 12 >this.a : number >this : I >a : number ->12 : number +>12 : 12 } function LiteralTypeThis(this: {x: string}) { >LiteralTypeThis : (this: { x: string; }) => void @@ -893,22 +893,22 @@ function LiteralTypeThis(this: {x: string}) { >x : string this.x = "ok"; ->this.x = "ok" : string +>this.x = "ok" : "ok" >this.x : string >this : { x: string; } >x : string ->"ok" : string +>"ok" : "ok" } function AnyThis(this: any) { >AnyThis : (this: any) => void >this : any this.x = "ok"; ->this.x = "ok" : string +>this.x = "ok" : "ok" >this.x : any >this : any >x : any ->"ok" : string +>"ok" : "ok" } let interfaceThis = new InterfaceThis(); >interfaceThis : any @@ -949,7 +949,7 @@ let n: number = f.call(12); >f.call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U >f : { (this: void, x: number): number; call(this: (...argArray: any[]) => U, ...argArray: any[]): U; } >call : (this: (...argArray: any[]) => U, ...argArray: any[]) => U ->12 : number +>12 : 12 function missingTypeIsImplicitAny(this, a: number) { return this.anything + a; } >missingTypeIsImplicitAny : (this: any, a: number) => any diff --git a/tests/baselines/reference/thisTypeInFunctions2.types b/tests/baselines/reference/thisTypeInFunctions2.types index 25fb2f28a60..bff71dd4450 100644 --- a/tests/baselines/reference/thisTypeInFunctions2.types +++ b/tests/baselines/reference/thisTypeInFunctions2.types @@ -58,7 +58,7 @@ declare function simple(arg: SimpleInterface): void; extend1({ >extend1({ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }}) : void >extend1 : (args: IndexedWithThis) => void ->{ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }} : { init(this: IndexedWithThis): void; mine: number; foo(this: any): void; } +>{ init() { this // this: IndexedWithThis because of contextual typing. // this.mine this.willDestroy }, mine: 12, foo() { this.url; // this: any because 'foo' matches the string indexer this.willDestroy; }} : { init(this: IndexedWithThis): void; mine: 12; foo(this: any): void; } init() { >init : (this: IndexedWithThis) => void @@ -75,7 +75,7 @@ extend1({ }, mine: 12, >mine : number ->12 : number +>12 : 12 foo() { >foo : (this: any) => void @@ -115,7 +115,7 @@ extend2({ }, mine: 13, >mine : number ->13 : number +>13 : 13 foo() { >foo : () => void @@ -138,7 +138,7 @@ extend2({ simple({ >simple({ foo(n) { return n.length + this.bar(); }, bar() { return 14; }}) : void >simple : (arg: SimpleInterface) => void ->{ foo(n) { return n.length + this.bar(); }, bar() { return 14; }} : { foo(n: string): any; bar(): number; } +>{ foo(n) { return n.length + this.bar(); }, bar() { return 14; }} : { foo(n: string): any; bar(): 14; } foo(n) { >foo : (n: string) => any @@ -156,10 +156,10 @@ simple({ }, bar() { ->bar : () => number +>bar : () => 14 return 14; ->14 : number +>14 : 14 } }) diff --git a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt index 564aa2ed926..e88f4c1ca96 100644 --- a/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt +++ b/tests/baselines/reference/thisTypeInFunctionsNegative.errors.txt @@ -11,7 +11,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(62,97): er 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 TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(66,6): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +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,1): error TS2346: Supplied parameters do not match any signature of call target. 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; }'. Types of property 'y' are incompatible. @@ -19,16 +19,16 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(68,1): err 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; }'. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(72,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(73,13): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +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,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(75,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(76,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +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,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(78,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(79,16): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +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,1): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(81,1): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(82,20): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +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,1): error TS2346: Supplied parameters do not match any signature of call target. 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'. The 'this' types of each signature are incompatible. @@ -190,7 +190,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. ok.f('wrong type'); ~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"wrong type"' is not assignable to parameter of type 'number'. ok.f(13, 'too many arguments'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. @@ -210,7 +210,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. c.explicitC('wrong type'); ~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"wrong type"' is not assignable to parameter of type 'number'. c.explicitC(13, 'too many arguments'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. @@ -219,7 +219,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. c.explicitThis('wrong type 2'); ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"wrong type 2"' is not assignable to parameter of type 'number'. c.explicitThis(14, 'too many arguments 2'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. @@ -228,7 +228,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. c.implicitThis('wrong type 2'); ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"wrong type 2"' is not assignable to parameter of type 'number'. c.implicitThis(14, 'too many arguments 2'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. @@ -237,7 +237,7 @@ tests/cases/conformance/types/thisType/thisTypeInFunctionsNegative.ts(175,35): e !!! error TS2346: Supplied parameters do not match any signature of call target. c.explicitProperty('wrong type 3'); ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '"wrong type 3"' is not assignable to parameter of type 'number'. c.explicitProperty(15, 'too many arguments 3'); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/thisTypeInObjectLiterals.types b/tests/baselines/reference/thisTypeInObjectLiterals.types index 91d95d5f0a8..240cfaa54f9 100644 --- a/tests/baselines/reference/thisTypeInObjectLiterals.types +++ b/tests/baselines/reference/thisTypeInObjectLiterals.types @@ -5,7 +5,7 @@ let o = { d: "bar", >d : string ->"bar" : string +>"bar" : "bar" m() { >m : () => any @@ -37,7 +37,7 @@ let mutuallyRecursive = { a: 100, >a : number ->100 : number +>100 : 100 start() { >start : () => any @@ -71,7 +71,7 @@ let mutuallyRecursive = { if (n > 0) { >n > 0 : boolean >n : number ->0 : number +>0 : 0 return this.passthrough(n - 1); >this.passthrough(n - 1) : any @@ -80,7 +80,7 @@ let mutuallyRecursive = { >passthrough : any >n - 1 : number >n : number ->1 : number +>1 : 1 } return n; >n : number diff --git a/tests/baselines/reference/thisTypeInTuples.types b/tests/baselines/reference/thisTypeInTuples.types index d2d70ad8e09..3b6f995840e 100644 --- a/tests/baselines/reference/thisTypeInTuples.types +++ b/tests/baselines/reference/thisTypeInTuples.types @@ -10,8 +10,8 @@ interface Array { let t: [number, string] = [42, "hello"]; >t : [number, string] >[42, "hello"] : [number, string] ->42 : number ->"hello" : string +>42 : 42 +>"hello" : "hello" let a = t.slice(); >a : [number, string] @@ -26,7 +26,7 @@ let b = t.slice(1); >t.slice : { (start?: number, end?: number): (string | number)[]; (): [number, string]; } >t : [number, string] >slice : { (start?: number, end?: number): (string | number)[]; (): [number, string]; } ->1 : number +>1 : 1 let c = t.slice(0, 1); >c : (string | number)[] @@ -34,6 +34,6 @@ let c = t.slice(0, 1); >t.slice : { (start?: number, end?: number): (string | number)[]; (): [number, string]; } >t : [number, string] >slice : { (start?: number, end?: number): (string | number)[]; (): [number, string]; } ->0 : number ->1 : number +>0 : 0 +>1 : 1 diff --git a/tests/baselines/reference/throwInEnclosingStatements.types b/tests/baselines/reference/throwInEnclosingStatements.types index eb127cf28bd..4955b9243ae 100644 --- a/tests/baselines/reference/throwInEnclosingStatements.types +++ b/tests/baselines/reference/throwInEnclosingStatements.types @@ -34,12 +34,12 @@ switch (y) { var z = 0; >z : number ->0 : number +>0 : 0 while (z < 10) { >z < 10 : boolean >z : number ->10 : number +>10 : 10 throw z; >z : number @@ -47,7 +47,7 @@ while (z < 10) { for (var i = 0; ;) { throw i; } >i : number ->0 : number +>0 : 0 >i : number for (var idx in {}) { throw idx; } @@ -57,16 +57,16 @@ for (var idx in {}) { throw idx; } do { throw null; }while(true) >null : null ->true : boolean +>true : true var j = 0; >j : number ->0 : number +>0 : 0 while (j < 0) { throw j; } >j < 0 : boolean >j : number ->0 : number +>0 : 0 >j : number class C { @@ -98,7 +98,7 @@ var aa = { id:12, >id : number ->12 : number +>12 : 12 biz() { >biz : () => void diff --git a/tests/baselines/reference/throwStatements.types b/tests/baselines/reference/throwStatements.types index 5023513ee53..19b8988ed47 100644 --- a/tests/baselines/reference/throwStatements.types +++ b/tests/baselines/reference/throwStatements.types @@ -40,7 +40,7 @@ class D{ function F(x: string): number { return 42; } >F : (x: string) => number >x : string ->42 : number +>42 : 42 module M { >M : typeof M @@ -63,14 +63,14 @@ module M { var aNumber = 9.9; >aNumber : number ->9.9 : number +>9.9 : 9.9 throw aNumber; >aNumber : number var aString = 'this is a string'; >aString : string ->'this is a string' : string +>'this is a string' : "this is a string" throw aString; >aString : string @@ -79,7 +79,7 @@ var aDate = new Date(12); >aDate : Date >new Date(12) : Date >Date : DateConstructor ->12 : number +>12 : 12 throw aDate; >aDate : Date @@ -135,7 +135,7 @@ var anObjectLiteral = { id: 12 }; >anObjectLiteral : { id: number; } >{ id: 12 } : { id: number; } >id : number ->12 : number +>12 : 12 throw anObjectLiteral; >anObjectLiteral : { id: number; } @@ -150,13 +150,13 @@ throw aFunction; throw aFunction(''); >aFunction('') : number >aFunction : (x: string) => number ->'' : string +>'' : "" var aLambda = (x) => 2; >aLambda : (x: any) => number >(x) => 2 : (x: any) => number >x : any ->2 : number +>2 : 2 throw aLambda; >aLambda : (x: any) => number @@ -164,7 +164,7 @@ throw aLambda; throw aLambda(1); >aLambda(1) : number >aLambda : (x: any) => number ->1 : number +>1 : 1 var aModule = M; >aModule : typeof M @@ -205,10 +205,10 @@ throw x; // literals throw 0.0; ->0.0 : number +>0.0 : 0 throw false; ->false : boolean +>false : false throw null; >null : null @@ -217,34 +217,34 @@ throw undefined; >undefined : undefined throw 'a string'; ->'a string' : string +>'a string' : "a string" throw function () { return 'a string' }; >function () { return 'a string' } : () => string ->'a string' : string +>'a string' : "a string" throw (x:T) => 42; >(x:T) => 42 : (x: T) => number >T : T >x : T >T : T ->42 : number +>42 : 42 throw { x: 12, y: 13 }; >{ x: 12, y: 13 } : { x: number; y: number; } >x : number ->12 : number +>12 : 12 >y : number ->13 : number +>13 : 13 throw []; >[] : undefined[] throw ['a', ['b']]; >['a', ['b']] : (string | string[])[] ->'a' : string +>'a' : "a" >['b'] : string[] ->'b' : string +>'b' : "b" throw /[a-z]/; >/[a-z]/ : RegExp diff --git a/tests/baselines/reference/toStringOnPrimitives.types b/tests/baselines/reference/toStringOnPrimitives.types index 4d7227f248a..1b0e320ef6f 100644 --- a/tests/baselines/reference/toStringOnPrimitives.types +++ b/tests/baselines/reference/toStringOnPrimitives.types @@ -2,22 +2,22 @@ true.toString() >true.toString() : string >true.toString : () => string ->true : boolean +>true : true >toString : () => string var aBool = false; >aBool : boolean ->false : boolean +>false : false aBool.toString(); >aBool.toString() : string >aBool.toString : () => string ->aBool : boolean +>aBool : false >toString : () => string 1..toString(); >1..toString() : string >1..toString : (radix?: number) => string ->1. : number +>1. : 1 >toString : (radix?: number) => string diff --git a/tests/baselines/reference/topLevel.types b/tests/baselines/reference/topLevel.types index ac1dd1182b9..72794b6f4e3 100644 --- a/tests/baselines/reference/topLevel.types +++ b/tests/baselines/reference/topLevel.types @@ -48,21 +48,21 @@ class Point implements IPoint { >"("+this.x+","+this.y : string >"("+this.x+"," : string >"("+this.x : string ->"(" : string +>"(" : "(" >this.x : any >this : this >x : any ->"," : string +>"," : "," >this.y : any >this : this >y : any ->")" : string +>")" : ")" } } var result=""; >result : string ->"" : string +>"" : "" result+=(new Point(3,4).move(2,2)); >result+=(new Point(3,4).move(2,2)) : string @@ -72,11 +72,11 @@ result+=(new Point(3,4).move(2,2)); >new Point(3,4).move : (xo: number, yo: number) => Point >new Point(3,4) : Point >Point : typeof Point ->3 : number ->4 : number +>3 : 3 +>4 : 4 >move : (xo: number, yo: number) => Point ->2 : number ->2 : number +>2 : 2 +>2 : 2 module M { >M : typeof M @@ -85,8 +85,8 @@ module M { >origin : Point >new Point(0,0) : Point >Point : typeof Point ->0 : number ->0 : number +>0 : 0 +>0 : 0 } result+=(M.origin.move(1,1)); @@ -99,7 +99,7 @@ result+=(M.origin.move(1,1)); >M : typeof M >origin : Point >move : (xo: number, yo: number) => Point ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/topLevelAmbientModule.types b/tests/baselines/reference/topLevelAmbientModule.types index c5bcfa3a5bf..aef1bb5486f 100644 --- a/tests/baselines/reference/topLevelAmbientModule.types +++ b/tests/baselines/reference/topLevelAmbientModule.types @@ -9,7 +9,7 @@ var z = foo.x + 10; >foo.x : number >foo : typeof foo >x : number ->10 : number +>10 : 10 === tests/cases/conformance/externalModules/foo_0.ts === declare module "foo" { diff --git a/tests/baselines/reference/topLevelExports.types b/tests/baselines/reference/topLevelExports.types index ab156991506..4a27478c08f 100644 --- a/tests/baselines/reference/topLevelExports.types +++ b/tests/baselines/reference/topLevelExports.types @@ -1,7 +1,7 @@ === tests/cases/compiler/topLevelExports.ts === export var foo = 3; >foo : number ->3 : number +>3 : 3 function log(n:number) { return n;} >log : (n: number) => number diff --git a/tests/baselines/reference/trailingCommasES3.types b/tests/baselines/reference/trailingCommasES3.types index 98777c6b37f..21e397a1c46 100644 --- a/tests/baselines/reference/trailingCommasES3.types +++ b/tests/baselines/reference/trailingCommasES3.types @@ -4,23 +4,23 @@ var o1 = { a: 1, b: 2 }; >o1 : { a: number; b: number; } >{ a: 1, b: 2 } : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 var o2 = { a: 1, b: 2, }; >o2 : { a: number; b: number; } >{ a: 1, b: 2, } : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 var o3 = { a: 1, }; >o3 : { a: number; } >{ a: 1, } : { a: number; } >a : number ->1 : number +>1 : 1 var o4 = {}; >o4 : {} @@ -29,19 +29,19 @@ var o4 = {}; var a1 = [1, 2]; >a1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var a2 = [1, 2, ]; >a2 : number[] >[1, 2, ] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var a3 = [1, ]; >a3 : number[] >[1, ] : number[] ->1 : number +>1 : 1 var a4 = []; >a4 : any[] @@ -50,7 +50,7 @@ var a4 = []; var a5 = [1, , ]; >a5 : number[] >[1, , ] : number[] ->1 : number +>1 : 1 > : undefined var a6 = [, , ]; diff --git a/tests/baselines/reference/trailingCommasES5.types b/tests/baselines/reference/trailingCommasES5.types index 498f70df94a..22d4fb37780 100644 --- a/tests/baselines/reference/trailingCommasES5.types +++ b/tests/baselines/reference/trailingCommasES5.types @@ -4,23 +4,23 @@ var o1 = { a: 1, b: 2 }; >o1 : { a: number; b: number; } >{ a: 1, b: 2 } : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 var o2 = { a: 1, b: 2, }; >o2 : { a: number; b: number; } >{ a: 1, b: 2, } : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 var o3 = { a: 1, }; >o3 : { a: number; } >{ a: 1, } : { a: number; } >a : number ->1 : number +>1 : 1 var o4 = {}; >o4 : {} @@ -29,19 +29,19 @@ var o4 = {}; var a1 = [1, 2]; >a1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var a2 = [1, 2, ]; >a2 : number[] >[1, 2, ] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 var a3 = [1, ]; >a3 : number[] >[1, ] : number[] ->1 : number +>1 : 1 var a4 = []; >a4 : any[] @@ -50,7 +50,7 @@ var a4 = []; var a5 = [1, , ]; >a5 : number[] >[1, , ] : number[] ->1 : number +>1 : 1 > : undefined var a6 = [, , ]; diff --git a/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.types b/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.types index 9e2aa0abd8a..00cca0b5e87 100644 --- a/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.types +++ b/tests/baselines/reference/trailingCommasInFunctionParametersAndArguments.types @@ -7,7 +7,7 @@ function f1(x,) {} f1(1,); >f1(1,) : void >f1 : (x: any) => void ->1 : number +>1 : 1 function f2(...args,) {} >f2 : (...args: any[]) => void @@ -33,14 +33,14 @@ declare function f3(x, y,): string; >f3(1,) : number >f3(1,) : number >f3 : { (x: any): number; (x: any, y: any): string; } ->1 : number +>1 : 1 f3(1, 2,); >f3(1, 2,) : string >f3(1, 2,) : string >f3 : { (x: any): number; (x: any, y: any): string; } ->1 : number ->2 : number +>1 : 1 +>2 : 2 // Works for constructors too class X { @@ -67,5 +67,5 @@ interface Y { new X(1,); >new X(1,) : X >X : typeof X ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/tsxAttributeErrors.errors.txt b/tests/baselines/reference/tsxAttributeErrors.errors.txt index 30a897c5163..4a898969363 100644 --- a/tests/baselines/reference/tsxAttributeErrors.errors.txt +++ b/tests/baselines/reference/tsxAttributeErrors.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/jsx/tsxAttributeErrors.tsx(15,6): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/jsx/tsxAttributeErrors.tsx(18,6): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(15,6): error TS2322: Type '42' is not assignable to type 'string'. +tests/cases/conformance/jsx/tsxAttributeErrors.tsx(18,6): error TS2322: Type '"foo"' is not assignable to type 'number'. tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2606: Property 'text' of JSX spread attribute is not assignable to target property. Type 'number' is not assignable to type 'string'. @@ -21,12 +21,12 @@ tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2606: Property // Error, number is not assignable to string
; ~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '42' is not assignable to type 'string'. // Error, string is not assignable to number
; ~~~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"foo"' is not assignable to type 'number'. // Error, number is not assignable to string var attribs = { text: 100 }; diff --git a/tests/baselines/reference/tsxAttributeResolution1.errors.txt b/tests/baselines/reference/tsxAttributeResolution1.errors.txt index 49bb504604e..f7fb114f3e0 100644 --- a/tests/baselines/reference/tsxAttributeResolution1.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution1.errors.txt @@ -1,10 +1,10 @@ -tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/file.tsx(23,8): error TS2322: Type '"0"' is not assignable to type 'number'. tests/cases/conformance/jsx/file.tsx(24,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. tests/cases/conformance/jsx/file.tsx(25,8): error TS2339: Property 'y' does not exist on type 'Attribs1'. -tests/cases/conformance/jsx/file.tsx(26,8): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/file.tsx(26,8): error TS2322: Type '"32"' is not assignable to type 'number'. tests/cases/conformance/jsx/file.tsx(27,8): error TS2339: Property 'var' does not exist on type 'Attribs1'. tests/cases/conformance/jsx/file.tsx(29,1): error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. -tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type '10' is not assignable to type 'string'. ==== tests/cases/conformance/jsx/file.tsx (7 errors) ==== @@ -32,7 +32,7 @@ tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not a // Errors ; // Error, '0' is not number ~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"0"' is not assignable to type 'number'. ; // Error, no property "y" ~ !!! error TS2339: Property 'y' does not exist on type 'Attribs1'. @@ -41,7 +41,7 @@ tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not a !!! error TS2339: Property 'y' does not exist on type 'Attribs1'. ; // Error, "32" is not number ~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"32"' is not assignable to type 'number'. ; // Error, no 'var' property ~~~ !!! error TS2339: Property 'var' does not exist on type 'Attribs1'. @@ -51,7 +51,7 @@ tests/cases/conformance/jsx/file.tsx(30,8): error TS2322: Type 'number' is not a !!! error TS2324: Property 'reqd' is missing in type '{ reqd: string; }'. ; // Error, reqd is not string ~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '10' is not assignable to type 'string'. // Should be OK ; diff --git a/tests/baselines/reference/tsxAttributeResolution10.errors.txt b/tests/baselines/reference/tsxAttributeResolution10.errors.txt index c929756364c..787eb4b5f00 100644 --- a/tests/baselines/reference/tsxAttributeResolution10.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution10.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(11,14): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/jsx/file.tsx(11,14): error TS2322: Type '"world"' is not assignable to type 'boolean'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -25,7 +25,7 @@ tests/cases/conformance/jsx/file.tsx(11,14): error TS2322: Type 'string' is not // Should be an error ; ~~~~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '"world"' is not assignable to type 'boolean'. // Should be OK ; diff --git a/tests/baselines/reference/tsxAttributeResolution14.errors.txt b/tests/baselines/reference/tsxAttributeResolution14.errors.txt index 81d42e49059..9f4e00747f1 100644 --- a/tests/baselines/reference/tsxAttributeResolution14.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution14.errors.txt @@ -1,5 +1,5 @@ -tests/cases/conformance/jsx/file.tsx(14,28): error TS2322: Type 'number' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'boolean' is not assignable to type 'string | number'. +tests/cases/conformance/jsx/file.tsx(14,28): error TS2322: Type '2' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'true' is not assignable to type 'string | number'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -28,11 +28,11 @@ tests/cases/conformance/jsx/file.tsx(16,28): error TS2322: Type 'boolean' is not
// error ~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '2' is not assignable to type 'string'. // ok // error ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'string | number'. +!!! error TS2322: Type 'true' is not assignable to type 'string | number'.
) } \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution3.errors.txt b/tests/baselines/reference/tsxAttributeResolution3.errors.txt index 6513b9879dc..ae8ba7a9a54 100644 --- a/tests/baselines/reference/tsxAttributeResolution3.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution3.errors.txt @@ -3,7 +3,7 @@ tests/cases/conformance/jsx/file.tsx(19,8): error TS2606: Property 'x' of JSX sp tests/cases/conformance/jsx/file.tsx(23,1): error TS2324: Property 'x' is missing in type 'Attribs1'. tests/cases/conformance/jsx/file.tsx(31,15): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(39,8): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(39,8): error TS2322: Type '32' is not assignable to type 'string'. ==== tests/cases/conformance/jsx/file.tsx (4 errors) ==== @@ -55,5 +55,5 @@ tests/cases/conformance/jsx/file.tsx(39,8): error TS2322: Type 'number' is not a var obj7 = { x: 'foo' }; ~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '32' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxAttributeResolution6.errors.txt b/tests/baselines/reference/tsxAttributeResolution6.errors.txt index 732ac9500a9..f3a4d512152 100644 --- a/tests/baselines/reference/tsxAttributeResolution6.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution6.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/jsx/file.tsx(10,8): error TS2322: Type 'boolean' is not assignable to type 'string'. -tests/cases/conformance/jsx/file.tsx(11,8): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/jsx/file.tsx(11,8): error TS2322: Type '"true"' is not assignable to type 'boolean'. tests/cases/conformance/jsx/file.tsx(12,1): error TS2324: Property 'n' is missing in type '{ n: boolean; }'. @@ -18,7 +18,7 @@ tests/cases/conformance/jsx/file.tsx(12,1): error TS2324: Property 'n' is missin !!! error TS2322: Type 'boolean' is not assignable to type 'string'. ; ~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '"true"' is not assignable to type 'boolean'. ; ~~~~~~~~~ !!! error TS2324: Property 'n' is missing in type '{ n: boolean; }'. diff --git a/tests/baselines/reference/tsxAttributeResolution7.errors.txt b/tests/baselines/reference/tsxAttributeResolution7.errors.txt index acbd7f407de..f5af1b48eb2 100644 --- a/tests/baselines/reference/tsxAttributeResolution7.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution7.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(9,8): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(9,8): error TS2322: Type '32' is not assignable to type 'string'. ==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== @@ -12,7 +12,7 @@ tests/cases/conformance/jsx/file.tsx(9,8): error TS2322: Type 'number' is not as // Error ; ~~~~~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '32' is not assignable to type 'string'. // OK ; diff --git a/tests/baselines/reference/tsxAttributeResolution9.errors.txt b/tests/baselines/reference/tsxAttributeResolution9.errors.txt index c25532eaa0a..73571689b1f 100644 --- a/tests/baselines/reference/tsxAttributeResolution9.errors.txt +++ b/tests/baselines/reference/tsxAttributeResolution9.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type '0' is not assignable to type 'string'. ==== tests/cases/conformance/jsx/react.d.ts (0 errors) ==== @@ -27,5 +27,5 @@ tests/cases/conformance/jsx/file.tsx(9,14): error TS2322: Type 'number' is not a ; // ok ; // should be an error ~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '0' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxDynamicTagName1.types b/tests/baselines/reference/tsxDynamicTagName1.types index 005afcf6adb..def9810e052 100644 --- a/tests/baselines/reference/tsxDynamicTagName1.types +++ b/tests/baselines/reference/tsxDynamicTagName1.types @@ -2,7 +2,7 @@ var CustomTag = "h1"; >CustomTag : string ->"h1" : string +>"h1" : "h1" Hello World // No error > Hello World : any diff --git a/tests/baselines/reference/tsxDynamicTagName5.types b/tests/baselines/reference/tsxDynamicTagName5.types index ac4ee31141a..dbc01e89483 100644 --- a/tests/baselines/reference/tsxDynamicTagName5.types +++ b/tests/baselines/reference/tsxDynamicTagName5.types @@ -19,7 +19,7 @@ export class Text extends React.Component<{}, {}> { _tagName: string = 'div'; >_tagName : string ->'div' : string +>'div' : "div" render() { >render : () => any diff --git a/tests/baselines/reference/tsxDynamicTagName6.types b/tests/baselines/reference/tsxDynamicTagName6.types index 5dadf6fe825..b4fbb1ed358 100644 --- a/tests/baselines/reference/tsxDynamicTagName6.types +++ b/tests/baselines/reference/tsxDynamicTagName6.types @@ -18,7 +18,7 @@ const t = {tag:'h1'} >t : { tag: string; } >{tag:'h1'} : { tag: string; } >tag : string ->'h1' : string +>'h1' : "h1" const foo = // No error >foo : JSX.Element diff --git a/tests/baselines/reference/tsxDynamicTagName8.types b/tests/baselines/reference/tsxDynamicTagName8.types index 154e7e33fe0..e2d7956a989 100644 --- a/tests/baselines/reference/tsxDynamicTagName8.types +++ b/tests/baselines/reference/tsxDynamicTagName8.types @@ -19,7 +19,7 @@ export class Text extends React.Component<{}, {}> { _tagName: string = 'div'; >_tagName : string ->'div' : string +>'div' : "div" render() { >render : () => any diff --git a/tests/baselines/reference/tsxElementResolution12.errors.txt b/tests/baselines/reference/tsxElementResolution12.errors.txt index 4a15005f6fb..5367e29e388 100644 --- a/tests/baselines/reference/tsxElementResolution12.errors.txt +++ b/tests/baselines/reference/tsxElementResolution12.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/jsx/file.tsx(17,2): error TS2304: Cannot find name 'Obj2'. tests/cases/conformance/jsx/file.tsx(23,1): error TS2607: JSX element class does not support attributes because it does not have a 'pr' property -tests/cases/conformance/jsx/file.tsx(30,7): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/jsx/file.tsx(30,7): error TS2322: Type '"10"' is not assignable to type 'number'. ==== tests/cases/conformance/jsx/file.tsx (3 errors) ==== @@ -39,5 +39,5 @@ tests/cases/conformance/jsx/file.tsx(30,7): error TS2322: Type 'string' is not a ; // OK ; // Error ~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"10"' is not assignable to type 'number'. \ No newline at end of file diff --git a/tests/baselines/reference/tsxElementResolution13.types b/tests/baselines/reference/tsxElementResolution13.types index 57884f86b56..d55d4705ff4 100644 --- a/tests/baselines/reference/tsxElementResolution13.types +++ b/tests/baselines/reference/tsxElementResolution13.types @@ -25,5 +25,5 @@ var obj1: Obj1; > : JSX.Element >obj1 : Obj1 >x : any ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/tsxElementResolution14.types b/tests/baselines/reference/tsxElementResolution14.types index 2768a6c531d..752a0baafb9 100644 --- a/tests/baselines/reference/tsxElementResolution14.types +++ b/tests/baselines/reference/tsxElementResolution14.types @@ -20,5 +20,5 @@ var obj1: Obj1; > : JSX.Element >obj1 : Obj1 >x : any ->10 : number +>10 : 10 diff --git a/tests/baselines/reference/tsxElementResolution9.types b/tests/baselines/reference/tsxElementResolution9.types index b138aa0509e..c63e61efc07 100644 --- a/tests/baselines/reference/tsxElementResolution9.types +++ b/tests/baselines/reference/tsxElementResolution9.types @@ -68,5 +68,5 @@ var Obj3: Obj3; > : JSX.Element >Obj3 : Obj3 >x : any ->42 : number +>42 : 42 diff --git a/tests/baselines/reference/tsxEmit1.types b/tests/baselines/reference/tsxEmit1.types index e6f92bebd1e..84f00b4758a 100644 --- a/tests/baselines/reference/tsxEmit1.types +++ b/tests/baselines/reference/tsxEmit1.types @@ -45,7 +45,7 @@ var selfClosed5 =
; >
: JSX.Element >div : any >x : any ->0 : number +>0 : 0 >y : any var selfClosed6 =
; @@ -53,7 +53,7 @@ var selfClosed6 =
; >
: JSX.Element >div : any >x : any ->"1" : string +>"1" : "1" >y : any var selfClosed7 =
; diff --git a/tests/baselines/reference/tsxEmit3.types b/tests/baselines/reference/tsxEmit3.types index e70c44d0041..42c31a37720 100644 --- a/tests/baselines/reference/tsxEmit3.types +++ b/tests/baselines/reference/tsxEmit3.types @@ -77,7 +77,7 @@ module M { var M = 100; >M : number ->100 : number +>100 : 100 // Emit M_1.Foo Foo, ; diff --git a/tests/baselines/reference/tsxGenericArrowFunctionParsing.types b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types index d5a9436872a..693f920195d 100644 --- a/tests/baselines/reference/tsxGenericArrowFunctionParsing.types +++ b/tests/baselines/reference/tsxGenericArrowFunctionParsing.types @@ -51,7 +51,7 @@ var x4 = () => {}; >() => {} : JSX.Element >T : any >extends : any ->true : boolean +>true : true >T : any x4.isElement; diff --git a/tests/baselines/reference/tsxReactEmit1.types b/tests/baselines/reference/tsxReactEmit1.types index d837eb007bf..8eb14e91963 100644 --- a/tests/baselines/reference/tsxReactEmit1.types +++ b/tests/baselines/reference/tsxReactEmit1.types @@ -47,7 +47,7 @@ var selfClosed5 =
; >
: JSX.Element >div : any >x : any ->0 : number +>0 : 0 >y : any var selfClosed6 =
; @@ -55,7 +55,7 @@ var selfClosed6 =
; >
: JSX.Element >div : any >x : any ->"1" : string +>"1" : "1" >y : any var selfClosed7 =
; diff --git a/tests/baselines/reference/tsxReactEmitNesting.types b/tests/baselines/reference/tsxReactEmitNesting.types index fff29c11525..7a1b3e82441 100644 --- a/tests/baselines/reference/tsxReactEmitNesting.types +++ b/tests/baselines/reference/tsxReactEmitNesting.types @@ -62,7 +62,7 @@ let render = (ctrl, model) => >style : any >{display:(model.todos && model.todos.length) ? "block" : "none"} : { display: string; } >display : string ->(model.todos && model.todos.length) ? "block" : "none" : string +>(model.todos && model.todos.length) ? "block" : "none" : "block" | "none" >(model.todos && model.todos.length) : any >model.todos && model.todos.length : any >model.todos : any @@ -73,8 +73,8 @@ let render = (ctrl, model) => >model : any >todos : any >length : any ->"block" : string ->"none" : string +>"block" : "block" +>"none" : "none" > : any @@ -111,7 +111,7 @@ let render = (ctrl, model) => >class : any >{todo: true, completed: todo.completed, editing: todo == model.editedTodo} : { todo: boolean; completed: any; editing: boolean; } >todo : boolean ->true : boolean +>true : true >completed : any >todo.completed : any >todo : any diff --git a/tests/baselines/reference/tsxReactEmitWhitespace.types b/tests/baselines/reference/tsxReactEmitWhitespace.types index 824aa5cfdae..f5ae431d342 100644 --- a/tests/baselines/reference/tsxReactEmitWhitespace.types +++ b/tests/baselines/reference/tsxReactEmitWhitespace.types @@ -20,7 +20,7 @@ declare var React: any; var p = 0; >p : number ->0 : number +>0 : 0 // Emit " "
; diff --git a/tests/baselines/reference/tsxStatelessFunctionComponents1.errors.txt b/tests/baselines/reference/tsxStatelessFunctionComponents1.errors.txt index a40aef38e22..e1f7570d9c0 100644 --- a/tests/baselines/reference/tsxStatelessFunctionComponents1.errors.txt +++ b/tests/baselines/reference/tsxStatelessFunctionComponents1.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/jsx/file.tsx(12,9): error TS2324: Property 'name' is missing in type 'IntrinsicAttributes & { name: string; }'. tests/cases/conformance/jsx/file.tsx(12,16): error TS2339: Property 'naaame' does not exist on type 'IntrinsicAttributes & { name: string; }'. -tests/cases/conformance/jsx/file.tsx(19,15): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/conformance/jsx/file.tsx(19,15): error TS2322: Type '42' is not assignable to type 'string'. tests/cases/conformance/jsx/file.tsx(21,15): error TS2339: Property 'naaaaaaame' does not exist on type 'IntrinsicAttributes & { name?: string; }'. @@ -29,7 +29,7 @@ tests/cases/conformance/jsx/file.tsx(21,15): error TS2339: Property 'naaaaaaame' // Error let e = ; ~~~~~~~~~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '42' is not assignable to type 'string'. // Error let f = ; ~~~~~~~~~~ diff --git a/tests/baselines/reference/tsxTypeErrors.types b/tests/baselines/reference/tsxTypeErrors.types index 303c7695dbf..d64781479fa 100644 --- a/tests/baselines/reference/tsxTypeErrors.types +++ b/tests/baselines/reference/tsxTypeErrors.types @@ -19,7 +19,7 @@ var thing = { oops: 100 }; >thing : { oops: number; } >{ oops: 100 } : { oops: number; } >oops : number ->100 : number +>100 : 100 var a3 =
>a3 : any @@ -62,7 +62,7 @@ var b1 = ; > : any >MyClass : typeof MyClass >reqd : any ->true : boolean +>true : true // Mistyped attribute member // sample.tsx(23,22): error TS2322: Type '{ x: number; y: string; }' is not assignable to type '{ x: number; y: number; }'. @@ -75,8 +75,8 @@ var b2 = ; >pt : any >{x: 4, y: 'oops'} : { x: number; y: string; } >x : number ->4 : number +>4 : 4 >y : string ->'oops' : string +>'oops' : "oops" diff --git a/tests/baselines/reference/tupleElementTypes3.types b/tests/baselines/reference/tupleElementTypes3.types index 6f29ba1371a..eee520d4425 100644 --- a/tests/baselines/reference/tupleElementTypes3.types +++ b/tests/baselines/reference/tupleElementTypes3.types @@ -3,6 +3,6 @@ var [a, b] = [0, undefined]; >a : number >b : any >[0, undefined] : [number, undefined] ->0 : number +>0 : 0 >undefined : undefined diff --git a/tests/baselines/reference/tupleElementTypes4.types b/tests/baselines/reference/tupleElementTypes4.types index 06e19ef72bb..72ff071e5e2 100644 --- a/tests/baselines/reference/tupleElementTypes4.types +++ b/tests/baselines/reference/tupleElementTypes4.types @@ -4,6 +4,6 @@ function f([a, b] = [0, undefined]) { } >a : number >b : any >[0, undefined] : [number, undefined] ->0 : number +>0 : 0 >undefined : undefined diff --git a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types index d9702b59954..f7fbf8200b5 100644 --- a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types +++ b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads.types @@ -110,8 +110,8 @@ var r2 = c.foo(1, 2); // number >c.foo : { (x: boolean, y: Date): string; (x: string, y: string): number; (x: W, y: W): W; } >c : C >foo : { (x: boolean, y: Date): string; (x: string, y: string): number; (x: W, y: W): W; } ->1 : number ->2 : number +>1 : 1 +>2 : 2 // add generic overload that would be ambiguous interface D { @@ -163,6 +163,6 @@ var r3 = d.foo(1, 1); // boolean, last definition wins >d.foo : { (x: A, y: A): Date; (x: W, y: W): boolean; } >d : D >foo : { (x: A, y: A): Date; (x: W, y: W): boolean; } ->1 : number ->1 : number +>1 : 1 +>1 : 1 diff --git a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types index a796d65cf61..0ab0cbee68c 100644 --- a/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types +++ b/tests/baselines/reference/twoMergedInterfacesWithDifferingOverloads2.types @@ -28,14 +28,14 @@ var r2 = a(1); >r2 : number >a(1) : number >a : A ->1 : number +>1 : 1 var r3 = a(1, 2); >r3 : boolean >a(1, 2) : boolean >a : A ->1 : number ->2 : number +>1 : 1 +>2 : 2 module G { >G : typeof G @@ -90,12 +90,12 @@ module G { >a(true, 2) : boolean >a : A >true : true ->2 : number +>2 : 2 var r4 = a(1, true); >r4 : number >a(1, true) : number >a : A ->1 : number +>1 : 1 >true : true } diff --git a/tests/baselines/reference/typeAliases.types b/tests/baselines/reference/typeAliases.types index 06dfd402829..1d798bc14a6 100644 --- a/tests/baselines/reference/typeAliases.types +++ b/tests/baselines/reference/typeAliases.types @@ -191,7 +191,7 @@ type Meters = number enum E { x = 10 } >E : E >x : E ->10 : number +>10 : 10 declare function f15(a: string): boolean; >f15 : { (a: string): boolean; (a: number): string; } @@ -232,7 +232,7 @@ var y: StringAndBoolean = ["1", false]; >y : [string, boolean] >StringAndBoolean : [string, boolean] >["1", false] : [string, false] ->"1" : string +>"1" : "1" >false : false y[0].toLowerCase(); @@ -240,6 +240,6 @@ y[0].toLowerCase(); >y[0].toLowerCase : () => string >y[0] : string >y : [string, boolean] ->0 : number +>0 : 0 >toLowerCase : () => string diff --git a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types index d0c881c1c5d..66e35a5a535 100644 --- a/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types +++ b/tests/baselines/reference/typeAnnotationBestCommonTypeInArrayLiteral.types @@ -28,31 +28,31 @@ var menuData: IMenuItem[] = [ >{ "id": "ourLogo", "type": "image", "link": "", "icon": "modules/menu/logo.svg" } : { "id": string; "type": string; "link": string; "icon": string; } "id": "ourLogo", ->"ourLogo" : string +>"ourLogo" : "ourLogo" "type": "image", ->"image" : string +>"image" : "image" "link": "", ->"" : string +>"" : "" "icon": "modules/menu/logo.svg" ->"modules/menu/logo.svg" : string +>"modules/menu/logo.svg" : "modules/menu/logo.svg" }, { >{ "id": "productName", "type": "default", "link": "", "text": "Product Name" } : { "id": string; "type": string; "link": string; "text": string; } "id": "productName", ->"productName" : string +>"productName" : "productName" "type": "default", ->"default" : string +>"default" : "default" "link": "", ->"" : string +>"" : "" "text": "Product Name" ->"Product Name" : string +>"Product Name" : "Product Name" } ]; diff --git a/tests/baselines/reference/typeArgInference.types b/tests/baselines/reference/typeArgInference.types index d553e0fe8d4..e8a2fff80a7 100644 --- a/tests/baselines/reference/typeArgInference.types +++ b/tests/baselines/reference/typeArgInference.types @@ -39,9 +39,9 @@ var o = { a: 3, b: "test" }; >o : { a: number; b: string; } >{ a: 3, b: "test" } : { a: number; b: string; } >a : number ->3 : number +>3 : 3 >b : string ->"test" : string +>"test" : "test" var x: I; >x : I diff --git a/tests/baselines/reference/typeArgInferenceWithNull.types b/tests/baselines/reference/typeArgInferenceWithNull.types index 93ded4267eb..52f656f6890 100644 --- a/tests/baselines/reference/typeArgInferenceWithNull.types +++ b/tests/baselines/reference/typeArgInferenceWithNull.types @@ -48,5 +48,5 @@ fn6({ x: null }, y => { }, { x: "" }); // y has type { x: any }, but ideally wou >y : { x: string; } >{ x: "" } : { x: string; } >x : string ->"" : string +>"" : "" diff --git a/tests/baselines/reference/typeArgumentConstraintResolution1.errors.txt b/tests/baselines/reference/typeArgumentConstraintResolution1.errors.txt index 1131b6e1a68..6f27916eda0 100644 --- a/tests/baselines/reference/typeArgumentConstraintResolution1.errors.txt +++ b/tests/baselines/reference/typeArgumentConstraintResolution1.errors.txt @@ -1,5 +1,5 @@ -tests/cases/compiler/typeArgumentConstraintResolution1.ts(4,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'. -tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'. +tests/cases/compiler/typeArgumentConstraintResolution1.ts(4,12): error TS2345: Argument of type '""' is not assignable to parameter of type 'Date'. +tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,12): error TS2345: Argument of type '""' is not assignable to parameter of type 'Date'. ==== tests/cases/compiler/typeArgumentConstraintResolution1.ts (2 errors) ==== @@ -8,7 +8,7 @@ tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,12): error TS2345: function foo1(test: any) { } foo1(""); // should error ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'Date'. @@ -17,5 +17,5 @@ tests/cases/compiler/typeArgumentConstraintResolution1.ts(11,12): error TS2345: function foo2(test: any): any { return null; } foo2(""); // Type Date does not satisfy the constraint 'Number' for type parameter 'T extends Number' ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'Date'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'Date'. \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentInferenceApparentType1.types b/tests/baselines/reference/typeArgumentInferenceApparentType1.types index 29fd1aeca18..1b25f79d4fc 100644 --- a/tests/baselines/reference/typeArgumentInferenceApparentType1.types +++ b/tests/baselines/reference/typeArgumentInferenceApparentType1.types @@ -14,5 +14,5 @@ var res: string = method("test"); >res : string >method("test") : string >method : (iterable: Iterable) => T ->"test" : string +>"test" : "test" diff --git a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt index da01aa778b6..485017940b5 100644 --- a/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceConstructSignatures.errors.txt @@ -1,9 +1,9 @@ -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(25,35): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(25,35): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(51,19): error TS2304: Cannot find name 'Window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(61,39): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(61,39): error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(71,39): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(71,39): error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstructSignatures.ts(81,45): error TS2345: Argument of type '(n: string) => string' is not assignable to parameter of type '(b: number) => number'. @@ -48,7 +48,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct new someGenerics1(3, 4); new someGenerics1(3, 4); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. new someGenerics1(3, 4); // Generic call with argument of function type whose parameter is of type parameter type @@ -88,7 +88,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct new someGenerics4('', () => 3); new someGenerics4('', (x: string) => ''); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +!!! error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. new someGenerics4(null, null); @@ -102,7 +102,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceConstruct new someGenerics5('', () => 3); new someGenerics5('', (x: string) => ''); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +!!! error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. new someGenerics5(null, null); diff --git a/tests/baselines/reference/typeArgumentInferenceErrors.errors.txt b/tests/baselines/reference/typeArgumentInferenceErrors.errors.txt index 36a17e166a5..80f087df5e1 100644 --- a/tests/baselines/reference/typeArgumentInferenceErrors.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceErrors.errors.txt @@ -1,8 +1,8 @@ -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts(3,31): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts(7,35): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts(3,31): error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts(7,35): error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts(11,35): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts(11,35): error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts(15,41): error TS2345: Argument of type '(n: string) => string' is not assignable to parameter of type '(b: number) => number'. @@ -15,13 +15,13 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts function someGenerics1(n: T, m: number) { } someGenerics1(3, 4); // Error ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '3' is not assignable to parameter of type 'string'. // 2 parameter generic call with argument 1 of type parameter type and argument 2 of function type whose parameter is of type parameter type function someGenerics4(n: T, f: (x: U) => void) { } someGenerics4('', (x: string) => ''); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +!!! error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. @@ -29,7 +29,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceErrors.ts function someGenerics5(n: T, f: (x: U) => void) { } someGenerics5('', (x: string) => ''); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +!!! error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.types b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.types index 63ee1309383..dd434e8bb5d 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.types +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression1.types @@ -18,6 +18,6 @@ foo(class { static prop = "hello" }).length; >foo : (x?: typeof (Anonymous class)) => T >class { static prop = "hello" } : typeof (Anonymous class) >prop : string ->"hello" : string +>"hello" : "hello" >length : number diff --git a/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.types b/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.types index 9a2bddd9296..82764584abd 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.types +++ b/tests/baselines/reference/typeArgumentInferenceWithClassExpression3.types @@ -18,6 +18,6 @@ foo(class { prop = "hello" }).length; >foo : (x?: typeof (Anonymous class)) => T >class { prop = "hello" } : typeof (Anonymous class) >prop : string ->"hello" : string +>"hello" : "hello" >length : number diff --git a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt index 22d18e11eca..881ed1c5ac3 100644 --- a/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt +++ b/tests/baselines/reference/typeArgumentInferenceWithConstraints.errors.txt @@ -3,10 +3,10 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(17,23): error TS2344: Type '{}' does not satisfy the constraint 'number'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(32,34): error TS2304: Cannot find name 'Window'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(34,15): error TS2304: Cannot find name 'Window'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(41,35): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(41,35): error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. -tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(48,35): error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(48,35): error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. Types of parameters 'x' and 'x' are incompatible. Type 'number' is not assignable to type 'string'. tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConstraints.ts(49,15): error TS2344: Type 'string' does not satisfy the constraint 'number'. @@ -79,7 +79,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst someGenerics4('', () => 3); someGenerics4('', (x: string) => ''); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +!!! error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. someGenerics4(null, null); @@ -90,7 +90,7 @@ tests/cases/conformance/expressions/functionCalls/typeArgumentInferenceWithConst someGenerics5('', () => 3); someGenerics5('', (x: string) => ''); // Error ~~~~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: string) => string' is not assignable to parameter of type '(x: number) => void'. +!!! error TS2345: Argument of type '(x: string) => ""' is not assignable to parameter of type '(x: number) => void'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'string'. someGenerics5(null, null); // Error diff --git a/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt b/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt index b529afd4c6a..b2d9e3f8aaf 100644 --- a/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt +++ b/tests/baselines/reference/typeArgumentsOnFunctionsWithNoTypeParameters.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(2,13): error TS2346: Supplied parameters do not match any signature of call target. -tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(3,15): error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(3,15): error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,13): error TS2346: Supplied parameters do not match any signature of call target. @@ -10,7 +10,7 @@ tests/cases/compiler/typeArgumentsOnFunctionsWithNoTypeParameters.ts(4,13): erro !!! error TS2346: Supplied parameters do not match any signature of call target. var r2 = f(1); ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'T'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'T'. var r3 = f(null); ~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt index 48c7efb37e8..2876390758f 100644 --- a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.errors.txt @@ -11,21 +11,17 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(55,43): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(57,52): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(58,43): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(61,5): error TS2322: Type 'string' is not assignable to type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(63,5): error TS2322: Type 'string' is not assignable to type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,5): error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. - Type '"World"' is not assignable to type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(77,5): error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. - Type '"World"' is not assignable to type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(68,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(70,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(75,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(77,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(87,43): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(88,43): error TS2345: Argument of type '"Hello"' is not assignable to parameter of type '"World"'. tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(89,52): error TS2345: Argument of type '"World"' is not assignable to parameter of type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(93,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(97,5): error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(100,25): error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'. - Type '"World"' is not assignable to type '"Hello"'. -tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(104,25): error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'. - Type '"World"' is not assignable to type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(100,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(104,25): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(107,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. +tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts(111,30): error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. ==== tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes01.ts (24 errors) ==== @@ -116,32 +112,30 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 // Assignment from the returned value should cause an error. a = takeReturnString(a); - ~ -!!! error TS2322: Type 'string' is not assignable to type '"Hello"'. b = takeReturnString(b); c = takeReturnString(c); - ~ -!!! error TS2322: Type 'string' is not assignable to type '"Hello"'. d = takeReturnString(d); e = takeReturnString(e); // Should be valid a = takeReturnHello(a); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. b = takeReturnHello(b); c = takeReturnHello(c); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. d = takeReturnHello(d); e = takeReturnHello(e); // Assignment from the returned value should cause an error. a = takeReturnHelloWorld(a); - ~ -!!! error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. -!!! error TS2322: Type '"World"' is not assignable to type '"Hello"'. + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. b = takeReturnHelloWorld(b); c = takeReturnHelloWorld(c); - ~ -!!! error TS2322: Type '"Hello" | "World"' is not assignable to type '"Hello"'. -!!! error TS2322: Type '"World"' is not assignable to type '"Hello"'. + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. d = takeReturnHelloWorld(d); e = takeReturnHelloWorld(e); } @@ -164,32 +158,30 @@ tests/cases/conformance/types/stringLiteral/typeArgumentsWithStringLiteralTypes0 // Assignment from the returned value should cause an error. a = takeReturnString(a); - ~ -!!! error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. b = takeReturnString(b); c = takeReturnString(c); d = takeReturnString(d); e = takeReturnString(e); - ~ -!!! error TS2322: Type 'string' is not assignable to type '"Hello" | "World"'. // Passing these as arguments should cause an error. a = takeReturnHello(a); ~ -!!! error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'. -!!! error TS2345: Type '"World"' is not assignable to type '"Hello"'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. b = takeReturnHello(b); c = takeReturnHello(c); d = takeReturnHello(d); e = takeReturnHello(e); ~ -!!! error TS2345: Argument of type '"Hello" | "World"' is not assignable to parameter of type '"Hello"'. -!!! error TS2345: Type '"World"' is not assignable to type '"Hello"'. +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello"'. // Both should be valid. a = takeReturnHelloWorld(a); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. b = takeReturnHelloWorld(b); c = takeReturnHelloWorld(c); d = takeReturnHelloWorld(d); e = takeReturnHelloWorld(e); + ~ +!!! error TS2345: Argument of type 'string' is not assignable to parameter of type '"Hello" | "World"'. } \ No newline at end of file diff --git a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js index c07dd225396..ca67e358705 100644 --- a/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js +++ b/tests/baselines/reference/typeArgumentsWithStringLiteralTypes01.js @@ -229,16 +229,16 @@ declare namespace n1 { let e: string; } declare namespace n2 { - let a: "Hello"; + let a: string; let b: any; - let c: "Hello"; + let c: string; let d: any; let e: any; } declare namespace n3 { - let a: "Hello" | "World"; + let a: string; let b: any; let c: any; let d: any; - let e: "Hello" | "World"; + let e: string; } diff --git a/tests/baselines/reference/typeAssertionToGenericFunctionType.errors.txt b/tests/baselines/reference/typeAssertionToGenericFunctionType.errors.txt index a404b12701a..7d99934f5ea 100644 --- a/tests/baselines/reference/typeAssertionToGenericFunctionType.errors.txt +++ b/tests/baselines/reference/typeAssertionToGenericFunctionType.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeAssertionToGenericFunctionType.ts(5,13): error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +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 TS2346: Supplied parameters do not match any signature of call target. @@ -9,7 +9,7 @@ tests/cases/compiler/typeAssertionToGenericFunctionType.ts(6,1): error TS2346: S } x.a(1); // bug was that this caused 'Could not find symbol T' on return type T in the type assertion on x.a's definition ~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type 'string'. +!!! error TS2345: Argument of type '1' is not assignable to parameter of type 'string'. x.b(); // error ~~~~~~~~~~~~~ !!! error TS2346: Supplied parameters do not match any signature of call target. \ No newline at end of file diff --git a/tests/baselines/reference/typeCheckingInsideFunctionExpressionInArray.errors.txt b/tests/baselines/reference/typeCheckingInsideFunctionExpressionInArray.errors.txt index e8c9bd6fc20..8df09b66513 100644 --- a/tests/baselines/reference/typeCheckingInsideFunctionExpressionInArray.errors.txt +++ b/tests/baselines/reference/typeCheckingInsideFunctionExpressionInArray.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeCheckingInsideFunctionExpressionInArray.ts(2,7): error TS2322: Type 'number' is not assignable to type 'string'. +tests/cases/compiler/typeCheckingInsideFunctionExpressionInArray.ts(2,7): error TS2322: Type '10' is not assignable to type 'string'. tests/cases/compiler/typeCheckingInsideFunctionExpressionInArray.ts(3,5): error TS2322: Type 'Object' is not assignable to type 'string'. tests/cases/compiler/typeCheckingInsideFunctionExpressionInArray.ts(4,15): error TS2339: Property 'NonexistantMethod' does not exist on type 'number[]'. tests/cases/compiler/typeCheckingInsideFunctionExpressionInArray.ts(5,5): error TS2304: Cannot find name 'derp'. @@ -8,7 +8,7 @@ tests/cases/compiler/typeCheckingInsideFunctionExpressionInArray.ts(5,5): error var functions = [function () { var k: string = 10; ~ -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '10' is not assignable to type 'string'. k = new Object(); ~ !!! error TS2322: Type 'Object' is not assignable to type 'string'. diff --git a/tests/baselines/reference/typeGuardFunction.types b/tests/baselines/reference/typeGuardFunction.types index 00dfc39f04a..a5635d2f31c 100644 --- a/tests/baselines/reference/typeGuardFunction.types +++ b/tests/baselines/reference/typeGuardFunction.types @@ -121,7 +121,7 @@ if (isC_multipleParams(a, 0)) { >isC_multipleParams(a, 0) : boolean >isC_multipleParams : (p1: any, p2: any) => p1 is C >a : A ->0 : number +>0 : 0 a.propC; >a.propC : number diff --git a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt index eac2660df81..88f71cda196 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.errors.txt +++ b/tests/baselines/reference/typeGuardFunctionErrors.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(2,7): error TS2300: Duplicate identifier 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type 'string' is not assignable to type 'boolean'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(15,12): error TS2322: Type '""' is not assignable to type 'boolean'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,55): error TS2304: Cannot find name 'x'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS1144: '{' or ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(18,57): error TS2304: Cannot find name 'is'. @@ -47,7 +47,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,22) tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,25): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(98,27): error TS1005: ';' expected. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(104,25): error TS1228: A type predicate is only allowed in return type position for functions and methods. -tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2322: Type 'boolean' is not assignable to type 'D'. +tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2322: Type 'true' is not assignable to type 'D'. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(105,16): error TS2409: Return type of constructor signature must be assignable to the instance type of the class tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(107,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(110,20): error TS1228: A type predicate is only allowed in return type position for functions and methods. @@ -83,7 +83,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 function hasANonBooleanReturnStatement(x): x is A { return ''; ~~ -!!! error TS2322: Type 'string' is not assignable to type 'boolean'. +!!! error TS2322: Type '""' is not assignable to type 'boolean'. } function hasTypeGuardTypeInsideTypeGuardType(x): x is x is A { @@ -259,7 +259,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardFunctionErrors.ts(137,39 !!! error TS1228: A type predicate is only allowed in return type position for functions and methods. return true; ~~~~ -!!! error TS2322: Type 'boolean' is not assignable to type 'D'. +!!! error TS2322: Type 'true' is not assignable to type 'D'. ~~~~ !!! error TS2409: Return type of constructor signature must be assignable to the instance type of the class } diff --git a/tests/baselines/reference/typeGuardFunctionGenerics.types b/tests/baselines/reference/typeGuardFunctionGenerics.types index c4655e71f0c..9d0fb25f2e8 100644 --- a/tests/baselines/reference/typeGuardFunctionGenerics.types +++ b/tests/baselines/reference/typeGuardFunctionGenerics.types @@ -134,5 +134,5 @@ let test3: B = funE(isB, 1); >funE(isB, 1) : B >funE : (p1: (p1: any) => p1 is T, p2: U) => T >isB : (p1: any) => p1 is B ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/typeGuardNesting.types b/tests/baselines/reference/typeGuardNesting.types index 2417dbe797c..29f6cba10db 100644 --- a/tests/baselines/reference/typeGuardNesting.types +++ b/tests/baselines/reference/typeGuardNesting.types @@ -26,7 +26,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >strOrBool : string | boolean >'string' : "string" >strOrBool : string ->"string" : string +>"string" : "string" let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; >bool : boolean @@ -48,7 +48,7 @@ if ((typeof strOrBool === 'boolean' && !strOrBool) || typeof strOrBool === 'stri >strOrBool : string | boolean >'boolean' : "boolean" >strOrBool : string ->"string" : string +>"string" : "string" let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; >bool2 : boolean @@ -86,7 +86,7 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >strOrBool : string | boolean >'string' : "string" >strOrBool : string ->"string" : string +>"string" : "string" let bool: boolean = (typeof strOrBool === 'boolean') ? strOrBool : false; >bool : boolean @@ -108,7 +108,7 @@ if ((typeof strOrBool !== 'string' && !strOrBool) || typeof strOrBool !== 'boole >strOrBool : string | boolean >'boolean' : "boolean" >strOrBool : string ->"string" : string +>"string" : "string" let bool2: boolean = (typeof strOrBool !== 'string') ? strOrBool : false; >bool2 : boolean diff --git a/tests/baselines/reference/typeGuardOfFormFunctionEquality.types b/tests/baselines/reference/typeGuardOfFormFunctionEquality.types index 55f2e2aac0e..b47dfa94c8c 100644 --- a/tests/baselines/reference/typeGuardOfFormFunctionEquality.types +++ b/tests/baselines/reference/typeGuardOfFormFunctionEquality.types @@ -15,13 +15,13 @@ declare function isString2(a: Object): a is string; switch (isString1(0, "")) { >isString1(0, "") : boolean >isString1 : (a: number, b: Object) => b is string ->0 : number ->"" : string +>0 : 0 +>"" : "" case isString2(""): >isString2("") : boolean >isString2 : (a: Object) => a is string ->"" : string +>"" : "" default: } @@ -31,11 +31,11 @@ var x = isString1(0, "") === isString2(""); >isString1(0, "") === isString2("") : boolean >isString1(0, "") : boolean >isString1 : (a: number, b: Object) => b is string ->0 : number ->"" : string +>0 : 0 +>"" : "" >isString2("") : boolean >isString2 : (a: Object) => a is string ->"" : string +>"" : "" function isString3(a: number, b: number, c: Object): c is string { >isString3 : (a: number, b: number, c: Object) => c is string @@ -48,7 +48,7 @@ function isString3(a: number, b: number, c: Object): c is string { return isString1(0, c); >isString1(0, c) : boolean >isString1 : (a: number, b: Object) => b is string ->0 : number +>0 : 0 >c : Object } diff --git a/tests/baselines/reference/typeGuardsAsAssertions.types b/tests/baselines/reference/typeGuardsAsAssertions.types index 661ce9fbc55..bdda2eafefd 100644 --- a/tests/baselines/reference/typeGuardsAsAssertions.types +++ b/tests/baselines/reference/typeGuardsAsAssertions.types @@ -27,7 +27,7 @@ export const none : None = { none: '' }; >None : None >{ none: '' } : { none: string; } >none : string ->'' : string +>'' : "" export function isSome(value: Optional): value is Some { >isSome : (value: Optional) => value is Some @@ -41,7 +41,7 @@ export function isSome(value: Optional): value is Some { return 'some' in value; >'some' in value : boolean ->'some' : string +>'some' : "some" >value : Optional } @@ -102,7 +102,7 @@ function foo1() { let x: string | number | boolean = 0; >x : string | number | boolean ->0 : number +>0 : 0 x; // number >x : number @@ -125,7 +125,7 @@ function foo1() { >x.slice : (start?: number | undefined, end?: number | undefined) => string >x : string >slice : (start?: number | undefined, end?: number | undefined) => string ->"abc" : string +>"abc" : "abc" x; // string >x : string @@ -139,7 +139,7 @@ function foo2() { let x: string | number | boolean = 0; >x : string | number | boolean ->0 : number +>0 : 0 x; // number >x : number @@ -166,9 +166,9 @@ function foo2() { } else { x = "abc"; ->x = "abc" : string +>x = "abc" : "abc" >x : string | number | boolean ->"abc" : string +>"abc" : "abc" } x; // string >x : string @@ -306,9 +306,9 @@ function f6() { >slice : (start?: number | undefined, end?: number | undefined) => string x = ""; ->x = "" : string +>x = "" : "" >x : string | null | undefined ->"" : string +>"" : "" x!.slice(); >x!.slice() : string @@ -359,7 +359,7 @@ function f6() { >x = "" : string | undefined >x : string | null | undefined >"" : string | undefined ->"" : string +>"" : "" x!.slice(); >x!.slice() : string @@ -373,7 +373,7 @@ function f6() { >x : string | null | undefined >"" : string | null >null : null ->"" : string +>"" : "" x!.slice(); >x!.slice() : string diff --git a/tests/baselines/reference/typeGuardsInConditionalExpression.types b/tests/baselines/reference/typeGuardsInConditionalExpression.types index 8d5da1329e6..165eecd3514 100644 --- a/tests/baselines/reference/typeGuardsInConditionalExpression.types +++ b/tests/baselines/reference/typeGuardsInConditionalExpression.types @@ -40,10 +40,10 @@ function foo2(x: number | string) { ? ((x = "hello") && x) // string >((x = "hello") && x) : string >(x = "hello") && x : string ->(x = "hello") : string ->x = "hello" : string +>(x = "hello") : "hello" +>x = "hello" : "hello" >x : string | number ->"hello" : string +>"hello" : "hello" >x : string : x; // number @@ -63,10 +63,10 @@ function foo3(x: number | string) { ? ((x = 10) && x) // number >((x = 10) && x) : number >(x = 10) && x : number ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number ->10 : number +>10 : 10 >x : number : x; // number @@ -89,10 +89,10 @@ function foo4(x: number | string) { : ((x = 10) && x); // number >((x = 10) && x) : number >(x = 10) && x : number ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number ->10 : number +>10 : 10 >x : number } function foo5(x: number | string) { @@ -112,10 +112,10 @@ function foo5(x: number | string) { : ((x = "hello") && x); // string >((x = "hello") && x) : string >(x = "hello") && x : string ->(x = "hello") : string ->x = "hello" : string +>(x = "hello") : "hello" +>x = "hello" : "hello" >x : string | number ->"hello" : string +>"hello" : "hello" >x : string } function foo6(x: number | string) { @@ -133,19 +133,19 @@ function foo6(x: number | string) { ? ((x = 10) && x) // number >((x = 10) && x) : number >(x = 10) && x : number ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number ->10 : number +>10 : 10 >x : number : ((x = "hello") && x); // string >((x = "hello") && x) : string >(x = "hello") && x : string ->(x = "hello") : string ->x = "hello" : string +>(x = "hello") : "hello" +>x = "hello" : "hello" >x : string | number ->"hello" : string +>"hello" : "hello" >x : string } function foo7(x: number | string | boolean) { @@ -228,7 +228,7 @@ function foo9(x: number | string) { var y = 10; >y : number ->10 : number +>10 : 10 // usage of x or assignment to separate variable shouldn't cause narrowing of type to stop return typeof x === "string" @@ -316,7 +316,7 @@ function foo11(x: number | string | boolean) { : ((b = x) // x is number | boolean >((b = x) // x is number | boolean && typeof x === "number" && (x = 10) // assignment to x && x) : number >(b = x) // x is number | boolean && typeof x === "number" && (x = 10) // assignment to x && x : number ->(b = x) // x is number | boolean && typeof x === "number" && (x = 10) : number +>(b = x) // x is number | boolean && typeof x === "number" && (x = 10) : 0 | 10 >(b = x) // x is number | boolean && typeof x === "number" : boolean >(b = x) : number | boolean >b = x : number | boolean @@ -330,10 +330,10 @@ function foo11(x: number | string | boolean) { >"number" : "number" && (x = 10) // assignment to x ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number | boolean ->10 : number +>10 : 10 && x); // x is number >x : number @@ -356,10 +356,10 @@ function foo12(x: number | string | boolean) { ? ((x = 10) && x.toString().length) // number >((x = 10) && x.toString().length) : number >(x = 10) && x.toString().length : number ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number | boolean ->10 : number +>10 : 10 >x.toString().length : number >x.toString() : string >x.toString : (radix?: number) => string diff --git a/tests/baselines/reference/typeGuardsInDoStatement.types b/tests/baselines/reference/typeGuardsInDoStatement.types index bc1e56bb1e4..fe14cff375f 100644 --- a/tests/baselines/reference/typeGuardsInDoStatement.types +++ b/tests/baselines/reference/typeGuardsInDoStatement.types @@ -64,9 +64,9 @@ function c(x: string | number) { >x : string | number x = ""; ->x = "" : string +>x = "" : "" >x : string | number ->"" : string +>"" : "" do { x; // string diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types index 9d22f63e764..54c1d0270b5 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfAndAndOperator.types @@ -30,10 +30,10 @@ function foo2(x: number | string) { >"string" : "string" >((x = 10) && x) : number >(x = 10) && x : number ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number ->10 : number +>10 : 10 >x : number } function foo3(x: number | string) { @@ -49,10 +49,10 @@ function foo3(x: number | string) { >"string" : "string" >((x = "hello") && x) : string >(x = "hello") && x : string ->(x = "hello") : string ->x = "hello" : string +>(x = "hello") : "hello" +>x = "hello" : "hello" >x : string | number ->"hello" : string +>"hello" : "hello" >x : string } function foo4(x: number | string | boolean) { @@ -174,10 +174,10 @@ function foo7(x: number | string | boolean) { ? ((x = 10) && x.toString()) // x is number >((x = 10) && x.toString()) : string >(x = 10) && x.toString() : string ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number | boolean ->10 : number +>10 : 10 >x.toString() : string >x.toString : (radix?: number) => string >x : number diff --git a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types index 0cb70c8c2d6..e8548ab1ef6 100644 --- a/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types +++ b/tests/baselines/reference/typeGuardsInRightOperandOfOrOrOperator.types @@ -31,10 +31,10 @@ function foo2(x: number | string) { >"string" : "string" >((x = 10) || x) : number >(x = 10) || x : number ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number ->10 : number +>10 : 10 >x : number } function foo3(x: number | string) { @@ -50,10 +50,10 @@ function foo3(x: number | string) { >"string" : "string" >((x = "hello") || x) : string >(x = "hello") || x : string ->(x = "hello") : string ->x = "hello" : string +>(x = "hello") : "hello" +>x = "hello" : "hello" >x : string | number ->"hello" : string +>"hello" : "hello" >x : string } function foo4(x: number | string | boolean) { @@ -175,10 +175,10 @@ function foo7(x: number | string | boolean) { ? ((x = 10) && x.toString()) // number | boolean | string >((x = 10) && x.toString()) : string >(x = 10) && x.toString() : string ->(x = 10) : number ->x = 10 : number +>(x = 10) : 10 +>x = 10 : 10 >x : string | number | boolean ->10 : number +>10 : 10 >x.toString() : string >x.toString : (radix?: number) => string >x : number diff --git a/tests/baselines/reference/typeGuardsNestedAssignments.types b/tests/baselines/reference/typeGuardsNestedAssignments.types index 3b125d4f32c..32ac85e270b 100644 --- a/tests/baselines/reference/typeGuardsNestedAssignments.types +++ b/tests/baselines/reference/typeGuardsNestedAssignments.types @@ -136,7 +136,7 @@ while ((match = re.exec("xxx")) != null) { >re.exec : (string: string) => RegExpExecArray | null >re : RegExp >exec : (string: string) => RegExpExecArray | null ->"xxx" : string +>"xxx" : "xxx" >null : null const length = match[1].length + match[2].length @@ -145,11 +145,11 @@ while ((match = re.exec("xxx")) != null) { >match[1].length : number >match[1] : string >match : RegExpExecArray ->1 : number +>1 : 1 >length : number >match[2].length : number >match[2] : string >match : RegExpExecArray ->2 : number +>2 : 2 >length : number } diff --git a/tests/baselines/reference/typeGuardsOnClassProperty.types b/tests/baselines/reference/typeGuardsOnClassProperty.types index afff0afb03f..1b663ef209f 100644 --- a/tests/baselines/reference/typeGuardsOnClassProperty.types +++ b/tests/baselines/reference/typeGuardsOnClassProperty.types @@ -30,7 +30,7 @@ class D { >data.join : (separator?: string) => string >data : string[] >join : (separator?: string) => string ->" " : string +>" " : " " } getData1() { @@ -53,7 +53,7 @@ class D { >this : this >data : string[] >join : (separator?: string) => string ->" " : string +>" " : " " } } @@ -71,10 +71,10 @@ var o: { prop1: "string" , >prop1 : string ->"string" : string +>"string" : "string" prop2: true ->prop2 : true +>prop2 : boolean >true : true } diff --git a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt index b67f7328856..9c20377e7a6 100644 --- a/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt +++ b/tests/baselines/reference/typeGuardsWithInstanceOfByConstructorSignature.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(12,10): error TS2339: Property 'bar' does not exist on type 'A'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(18,10): error TS2339: Property 'bar' does not exist on type 'A'. -tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(33,5): error TS2322: Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(33,5): error TS2322: Type '"str"' is not assignable to type 'number'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(34,10): error TS2339: Property 'bar' does not exist on type 'B'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(41,10): error TS2339: Property 'bar' does not exist on type 'B'. tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstructorSignature.ts(66,10): error TS2339: Property 'bar2' does not exist on type 'C1'. @@ -59,7 +59,7 @@ tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOfByConstru obj3.foo = 1; obj3.foo = "str"; ~~~~~~~~ -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '"str"' is not assignable to type 'number'. obj3.bar = "str"; ~~~ !!! error TS2339: Property 'bar' does not exist on type 'B'. diff --git a/tests/baselines/reference/typeInferenceFBoundedTypeParams.types b/tests/baselines/reference/typeInferenceFBoundedTypeParams.types index 0ce04aabddf..a6d0a51dd45 100644 --- a/tests/baselines/reference/typeInferenceFBoundedTypeParams.types +++ b/tests/baselines/reference/typeInferenceFBoundedTypeParams.types @@ -61,9 +61,9 @@ fold( [1, 2, 3], >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 [] as [string, string][], >[] as [string, string][] : [string, string][] @@ -81,8 +81,8 @@ fold( ["", ""] >["", ""] : [string, string] ->"" : string ->"" : string +>"" : "" +>"" : "" ) ); diff --git a/tests/baselines/reference/typeInferenceFixEarly.types b/tests/baselines/reference/typeInferenceFixEarly.types index 5c727ca3226..15d8c661c88 100644 --- a/tests/baselines/reference/typeInferenceFixEarly.types +++ b/tests/baselines/reference/typeInferenceFixEarly.types @@ -11,7 +11,7 @@ declare function f(p: (t: T) => T): T; f(n => 3); >f(n => 3) : {} >f : (p: (t: T) => T) => T ->n => 3 : (n: {}) => number +>n => 3 : (n: {}) => 3 >n : {} ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/typeInferenceWithTupleType.types b/tests/baselines/reference/typeInferenceWithTupleType.types index a45e72518e8..a7f8bff6798 100644 --- a/tests/baselines/reference/typeInferenceWithTupleType.types +++ b/tests/baselines/reference/typeInferenceWithTupleType.types @@ -20,20 +20,20 @@ var combineResult = combine("string", 10); >combineResult : [string, number] >combine("string", 10) : [string, number] >combine : (x: T, y: U) => [T, U] ->"string" : string ->10 : number +>"string" : "string" +>10 : 10 var combineEle1 = combineResult[0]; // string >combineEle1 : string >combineResult[0] : string >combineResult : [string, number] ->0 : number +>0 : 0 var combineEle2 = combineResult[1]; // number >combineEle2 : number >combineResult[1] : number >combineResult : [string, number] ->1 : number +>1 : 1 function zip(array1: T[], array2: U[]): [[T, U]] { >zip : (array1: T[], array2: U[]) => [[T, U]] @@ -74,7 +74,7 @@ function zip(array1: T[], array2: U[]): [[T, U]] { for (var i = 0; i < length; ++i) { >i : number ->0 : number +>0 : 0 >i < length : boolean >i : number >length : number @@ -103,24 +103,24 @@ var zipResult = zip(["foo", "bar"], [5, 6]); >zip(["foo", "bar"], [5, 6]) : [[string, number]] >zip : (array1: T[], array2: U[]) => [[T, U]] >["foo", "bar"] : string[] ->"foo" : string ->"bar" : string +>"foo" : "foo" +>"bar" : "bar" >[5, 6] : number[] ->5 : number ->6 : number +>5 : 5 +>6 : 6 var zipResultEle = zipResult[0]; // [string, number] >zipResultEle : [string, number] >zipResult[0] : [string, number] >zipResult : [[string, number]] ->0 : number +>0 : 0 var zipResultEleEle = zipResult[0][0]; // string >zipResultEleEle : string >zipResult[0][0] : string >zipResult[0] : [string, number] >zipResult : [[string, number]] ->0 : number ->0 : number +>0 : 0 +>0 : 0 diff --git a/tests/baselines/reference/typeName1.errors.txt b/tests/baselines/reference/typeName1.errors.txt index 152a5b951e7..3e99a18552f 100644 --- a/tests/baselines/reference/typeName1.errors.txt +++ b/tests/baselines/reference/typeName1.errors.txt @@ -1,19 +1,19 @@ -tests/cases/compiler/typeName1.ts(9,5): error TS2322: Type 'number' is not assignable to type '{ f(s: string): number; f(n: number): string; }'. -tests/cases/compiler/typeName1.ts(10,5): error TS2322: Type 'number' is not assignable to type '{ f(s: string): number; }'. -tests/cases/compiler/typeName1.ts(11,5): error TS2322: Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; }'. -tests/cases/compiler/typeName1.ts(12,5): error TS2322: Type 'number' is not assignable to type '{ x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. -tests/cases/compiler/typeName1.ts(13,5): error TS2322: Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. -tests/cases/compiler/typeName1.ts(14,5): error TS2322: Type 'number' is not assignable to type '{ z: number; f: { (n: number): string; (s: string): number; }; }'. -tests/cases/compiler/typeName1.ts(15,5): error TS2322: Type 'number' is not assignable to type '(s: string) => boolean'. -tests/cases/compiler/typeName1.ts(16,5): error TS2322: Type 'number' is not assignable to type '{ (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }'. +tests/cases/compiler/typeName1.ts(9,5): error TS2322: Type '3' is not assignable to type '{ f(s: string): number; f(n: number): string; }'. +tests/cases/compiler/typeName1.ts(10,5): error TS2322: Type '3' is not assignable to type '{ f(s: string): number; }'. +tests/cases/compiler/typeName1.ts(11,5): error TS2322: Type '3' is not assignable to type '{ (s: string): number; (n: number): string; }'. +tests/cases/compiler/typeName1.ts(12,5): error TS2322: Type '3' is not assignable to type '{ x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. +tests/cases/compiler/typeName1.ts(13,5): error TS2322: Type '3' is not assignable to type '{ (s: string): number; (n: number): string; x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. +tests/cases/compiler/typeName1.ts(14,5): error TS2322: Type '3' is not assignable to type '{ z: number; f: { (n: number): string; (s: string): number; }; }'. +tests/cases/compiler/typeName1.ts(15,5): error TS2322: Type '3' is not assignable to type '(s: string) => boolean'. +tests/cases/compiler/typeName1.ts(16,5): error TS2322: Type '3' is not assignable to type '{ (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }'. tests/cases/compiler/typeName1.ts(16,10): error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. -tests/cases/compiler/typeName1.ts(17,5): error TS2322: Type 'number' is not assignable to type 'I'. -tests/cases/compiler/typeName1.ts(18,5): error TS2322: Type 'number' is not assignable to type 'I[][][][]'. -tests/cases/compiler/typeName1.ts(19,5): error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; }[][]'. -tests/cases/compiler/typeName1.ts(20,5): error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }; }[][]'. +tests/cases/compiler/typeName1.ts(17,5): error TS2322: Type '3' is not assignable to type 'I'. +tests/cases/compiler/typeName1.ts(18,5): error TS2322: Type '3' is not assignable to type 'I[][][][]'. +tests/cases/compiler/typeName1.ts(19,5): error TS2322: Type '3' is not assignable to type '{ z: I; x: boolean; }[][]'. +tests/cases/compiler/typeName1.ts(20,5): error TS2322: Type '3' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }; }[][]'. tests/cases/compiler/typeName1.ts(20,50): error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. -tests/cases/compiler/typeName1.ts(21,5): error TS2322: Type 'number' is not assignable to type '{ (): {}; new (): number; new (n: number): number; x: string; w: { y: number; }; }'. -tests/cases/compiler/typeName1.ts(22,5): error TS2322: Type 'number' is not assignable to type '{ (): string; f(x: number): boolean; p: any; q: any; }'. +tests/cases/compiler/typeName1.ts(21,5): error TS2322: Type '3' is not assignable to type '{ (): {}; new (): number; new (n: number): number; x: string; w: { y: number; }; }'. +tests/cases/compiler/typeName1.ts(22,5): error TS2322: Type '3' is not assignable to type '{ (): string; f(x: number): boolean; p: any; q: any; }'. tests/cases/compiler/typeName1.ts(23,5): error TS2322: Type 'typeof C' is not assignable to type 'number'. @@ -28,50 +28,50 @@ tests/cases/compiler/typeName1.ts(23,5): error TS2322: Type 'typeof C' is not as var x1:{ f(s:string):number;f(n:number):string; }=3; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ f(s: string): number; f(n: number): string; }'. +!!! error TS2322: Type '3' is not assignable to type '{ f(s: string): number; f(n: number): string; }'. var x2:{ f(s:string):number; } =3; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ f(s: string): number; }'. +!!! error TS2322: Type '3' is not assignable to type '{ f(s: string): number; }'. var x3:{ (s:string):number;(n:number):string; }=3; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; }'. +!!! error TS2322: Type '3' is not assignable to type '{ (s: string): number; (n: number): string; }'. var x4:{ x;y;z:number;f(n:number):string;f(s:string):number; }=3; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. +!!! error TS2322: Type '3' is not assignable to type '{ x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. var x5:{ (s:string):number;(n:number):string;x;y;z:number;f(n:number):string;f(s:string):number; }=3; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ (s: string): number; (n: number): string; x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. +!!! error TS2322: Type '3' is not assignable to type '{ (s: string): number; (n: number): string; x: any; y: any; z: number; f(n: number): string; f(s: string): number; }'. var x6:{ z:number;f:{(n:number):string;(s:string):number;}; }=3; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ z: number; f: { (n: number): string; (s: string): number; }; }'. +!!! error TS2322: Type '3' is not assignable to type '{ z: number; f: { (n: number): string; (s: string): number; }; }'. var x7:(s:string)=>boolean=3; ~~ -!!! error TS2322: Type 'number' is not assignable to type '(s: string) => boolean'. +!!! error TS2322: Type '3' is not assignable to type '(s: string) => boolean'. var x8:{ z:I;[s:string]:{ x; y; };[n:number]:{x; y;};():boolean; }=3; ~~ -!!! error TS2322: Type 'number' is not assignable to type '{ (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }'. +!!! error TS2322: Type '3' is not assignable to type '{ (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }'. ~~~~ !!! error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. var x9:I=3; ~~ -!!! error TS2322: Type 'number' is not assignable to type 'I'. +!!! error TS2322: Type '3' is not assignable to type 'I'. var x10:I[][][][]=3; ~~~ -!!! error TS2322: Type 'number' is not assignable to type 'I[][][][]'. +!!! error TS2322: Type '3' is not assignable to type 'I[][][][]'. var x11:{z:I;x:boolean;}[][]=3; ~~~ -!!! error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; }[][]'. +!!! error TS2322: Type '3' is not assignable to type '{ z: I; x: boolean; }[][]'. var x12:{z:I;x:boolean;y:(s:string)=>boolean;w:{ z:I;[s:string]:{ x; y; };[n:number]:{x; y;};():boolean; };}[][]=3; ~~~ -!!! error TS2322: Type 'number' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }; }[][]'. +!!! error TS2322: Type '3' is not assignable to type '{ z: I; x: boolean; y: (s: string) => boolean; w: { (): boolean; [s: string]: { x: any; y: any; }; [n: number]: { x: any; y: any; }; z: I; }; }[][]'. ~~~~ !!! error TS2411: Property 'z' of type 'I' is not assignable to string index type '{ x: any; y: any; }'. var x13:{ new(): number; new(n:number):number; x: string; w: {y: number;}; (): {}; } = 3; ~~~ -!!! error TS2322: Type 'number' is not assignable to type '{ (): {}; new (): number; new (n: number): number; x: string; w: { y: number; }; }'. +!!! error TS2322: Type '3' is not assignable to type '{ (): {}; new (): number; new (n: number): number; x: string; w: { y: number; }; }'. var x14:{ f(x:number):boolean; p; q; ():string; }=3; ~~~ -!!! error TS2322: Type 'number' is not assignable to type '{ (): string; f(x: number): boolean; p: any; q: any; }'. +!!! error TS2322: Type '3' is not assignable to type '{ (): string; f(x: number): boolean; p: any; q: any; }'. var x15:number=C; ~~~ !!! error TS2322: Type 'typeof C' is not assignable to type 'number'. diff --git a/tests/baselines/reference/typeOfEnumAndVarRedeclarations.errors.txt b/tests/baselines/reference/typeOfEnumAndVarRedeclarations.errors.txt index d7410ec04cb..89849d3a614 100644 --- a/tests/baselines/reference/typeOfEnumAndVarRedeclarations.errors.txt +++ b/tests/baselines/reference/typeOfEnumAndVarRedeclarations.errors.txt @@ -1,7 +1,9 @@ +tests/cases/compiler/typeOfEnumAndVarRedeclarations.ts(8,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'typeof E', but here has type '{ readonly [x: number]: string; readonly a: E; readonly b: E; }'. +tests/cases/compiler/typeOfEnumAndVarRedeclarations.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'typeof E', but here has type '{ readonly [x: number]: string; readonly a: E; readonly b: E; }'. tests/cases/compiler/typeOfEnumAndVarRedeclarations.ts(10,70): error TS2375: Duplicate number index signature. -==== tests/cases/compiler/typeOfEnumAndVarRedeclarations.ts (1 errors) ==== +==== tests/cases/compiler/typeOfEnumAndVarRedeclarations.ts (3 errors) ==== enum E { a } @@ -10,7 +12,11 @@ tests/cases/compiler/typeOfEnumAndVarRedeclarations.ts(10,70): error TS2375: Dup } var x = E; var x: { readonly a: E; readonly b: E; readonly [x: number]: string; }; // Shouldnt error + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'typeof E', but here has type '{ readonly [x: number]: string; readonly a: E; readonly b: E; }'. var y = E; var y: { readonly a: E; readonly b: E; readonly [x: number]: string; readonly [x: number]: string } // two errors: the types are not identical and duplicate signatures + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'typeof E', but here has type '{ readonly [x: number]: string; readonly a: E; readonly b: E; }'. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2375: Duplicate number index signature. \ No newline at end of file diff --git a/tests/baselines/reference/typeOfOnTypeArg.errors.txt b/tests/baselines/reference/typeOfOnTypeArg.errors.txt index 46b48983f21..58412a5417f 100644 --- a/tests/baselines/reference/typeOfOnTypeArg.errors.txt +++ b/tests/baselines/reference/typeOfOnTypeArg.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/typeOfOnTypeArg.ts(7,6): error TS2345: Argument of type 'number' is not assignable to parameter of type '{ '': number; }'. +tests/cases/compiler/typeOfOnTypeArg.ts(7,6): error TS2345: Argument of type '32' is not assignable to parameter of type '{ '': number; }'. ==== tests/cases/compiler/typeOfOnTypeArg.ts (1 errors) ==== @@ -10,5 +10,5 @@ tests/cases/compiler/typeOfOnTypeArg.ts(7,6): error TS2345: Argument of type 'nu fill(32); ~~ -!!! error TS2345: Argument of type 'number' is not assignable to parameter of type '{ '': number; }'. +!!! error TS2345: Argument of type '32' is not assignable to parameter of type '{ '': number; }'. \ No newline at end of file diff --git a/tests/baselines/reference/typeOfPrototype.types b/tests/baselines/reference/typeOfPrototype.types index 90466787080..0660b4cd00c 100644 --- a/tests/baselines/reference/typeOfPrototype.types +++ b/tests/baselines/reference/typeOfPrototype.types @@ -4,11 +4,11 @@ class Foo { bar = 3; >bar : number ->3 : number +>3 : 3 static bar = ''; >bar : string ->'' : string +>'' : "" } Foo.prototype.bar = undefined; // Should be OK >Foo.prototype.bar = undefined : undefined diff --git a/tests/baselines/reference/typeOfThisInStaticMembers.types b/tests/baselines/reference/typeOfThisInStaticMembers.types index 72caa4a95a9..55e92bd791c 100644 --- a/tests/baselines/reference/typeOfThisInStaticMembers.types +++ b/tests/baselines/reference/typeOfThisInStaticMembers.types @@ -35,7 +35,7 @@ var r2 = t.foo + 1; >t.foo : number >t : typeof C >foo : number ->1 : number +>1 : 1 var r3 = t.bar(); >r3 : typeof C @@ -48,7 +48,7 @@ var r4 = new t(1); >r4 : C >new t(1) : C >t : typeof C ->1 : number +>1 : 1 class C2 { >C2 : C2 @@ -90,7 +90,7 @@ var r5 = t2.foo + 1; >t2.foo : string >t2 : typeof C2 >foo : string ->1 : number +>1 : 1 var r6 = t2.bar(); >r6 : typeof C2 @@ -103,6 +103,6 @@ var r7 = new t2(''); >r7 : C2<{}> >new t2('') : C2<{}> >t2 : typeof C2 ->'' : string +>'' : "" diff --git a/tests/baselines/reference/typeParameterAndArgumentOfSameName1.types b/tests/baselines/reference/typeParameterAndArgumentOfSameName1.types index 8e476732ded..a8b96275283 100644 --- a/tests/baselines/reference/typeParameterAndArgumentOfSameName1.types +++ b/tests/baselines/reference/typeParameterAndArgumentOfSameName1.types @@ -13,7 +13,7 @@ function f(A: A): A { >A.toExponential : (fractionDigits?: number) => string >A : A >toExponential : (fractionDigits?: number) => string ->123 : number +>123 : 123 return null; >null : null diff --git a/tests/baselines/reference/typeParameterAsElementType.types b/tests/baselines/reference/typeParameterAsElementType.types index 10e6787ae31..b4c3b4f3ec0 100644 --- a/tests/baselines/reference/typeParameterAsElementType.types +++ b/tests/baselines/reference/typeParameterAsElementType.types @@ -11,5 +11,5 @@ function fee() { >arr : (string | T)[] >[t, ""] : (string | T)[] >t : T ->"" : string +>"" : "" } diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraint.types index c5f15f1ba55..cce73bcf0a5 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraint.types +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraint.types @@ -18,15 +18,15 @@ var r = foo(1, 2); >r : number >foo(1, 2) : number >foo : (x: T, y: U) => U ->1 : number ->2 : number +>1 : 1 +>2 : 2 var r = foo({}, 1); >r : number >foo({}, 1) : number >foo : (x: T, y: U) => U >{} : {} ->1 : number +>1 : 1 interface A { >A : A @@ -62,12 +62,12 @@ var r3 = foo({ x: 1 }, { x: 2, y: 3 }); >foo : (x: T, y: U) => U >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 >{ x: 2, y: 3 } : { x: number; y: number; } >x : number ->2 : number +>2 : 2 >y : number ->3 : number +>3 : 3 function foo2(x: T, y: U) { return y; } >foo2 : (x: T, y: U) => U @@ -84,8 +84,8 @@ function foo2(x: T, y: U) { return y; } foo2(1, ''); >foo2(1, '') : string >foo2 : (x: T, y: U) => U ->1 : number ->'' : string +>1 : 1 +>'' : "" foo2({}, { length: 2 }); >foo2({}, { length: 2 }) : { length: number; } @@ -93,28 +93,28 @@ foo2({}, { length: 2 }); >{} : {} >{ length: 2 } : { length: number; } >length : number ->2 : number +>2 : 2 foo2(1, { width: 3, length: 2 }); >foo2(1, { width: 3, length: 2 }) : { width: number; length: number; } >foo2 : (x: T, y: U) => U ->1 : number +>1 : 1 >{ width: 3, length: 2 } : { width: number; length: number; } >width : number ->3 : number +>3 : 3 >length : number ->2 : number +>2 : 2 foo2(1, []); >foo2(1, []) : any[] >foo2 : (x: T, y: U) => U ->1 : number +>1 : 1 >[] : undefined[] foo2(1, ['']); >foo2(1, ['']) : string[] >foo2 : (x: T, y: U) => U ->1 : number +>1 : 1 >[''] : string[] ->'' : string +>'' : "" diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt index 0e148cb5689..08706d095b2 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraint2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(6,8): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(6,8): error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(7,8): error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(13,17): error TS2345: Argument of type 'NumberVariant' is not assignable to parameter of type 'number'. tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTypeParameterConstraint2.ts(16,9): error TS2345: Argument of type '{ length: string; }' is not assignable to parameter of type '{ length: number; }'. @@ -20,7 +20,7 @@ tests/cases/conformance/types/typeParameters/typeArgumentLists/typeParameterAsTy foo(1, ''); ~~ -!!! error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'. +!!! error TS2345: Argument of type '""' is not assignable to parameter of type 'number'. foo(1, {}); ~~ !!! error TS2345: Argument of type '{}' is not assignable to parameter of type 'number'. diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types index 680e86f5c85..12aee1a7408 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively.types @@ -47,27 +47,27 @@ function foo(x: T, y: U, z: V): V { return z; } foo(1, 2, 3); >foo(1, 2, 3) : number >foo : (x: T, y: U, z: V) => V ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: '', z: true }); >foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: '', z: true }) : { x: number; y: string; z: boolean; } >foo : (x: T, y: U, z: V) => V >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 >{ x: 1, y: '' } : { x: number; y: string; } >x : number ->1 : number +>1 : 1 >y : string ->'' : string +>'' : "" >{ x: 2, y: '', z: true } : { x: number; y: string; z: true; } >x : number ->2 : number +>2 : 2 >y : string ->'' : string ->z : true +>'' : "" +>z : boolean >true : true foo(a, b, c); @@ -84,10 +84,10 @@ foo(a, b, { foo: 1, bar: '', hm: true }); >b : B >{ foo: 1, bar: '', hm: true } : { foo: number; bar: string; hm: true; } >foo : number ->1 : number +>1 : 1 >bar : string ->'' : string ->hm : true +>'' : "" +>hm : boolean >true : true foo((x: number, y) => { }, (x) => { }, () => { }); @@ -137,9 +137,9 @@ foo(b, b, { foo: 1, bar: '', hm: '' }); >b : B >{ foo: 1, bar: '', hm: '' } : { foo: number; bar: string; hm: string; } >foo : number ->1 : number +>1 : 1 >bar : string ->'' : string +>'' : "" >hm : string ->'' : string +>'' : "" diff --git a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types index 145bf081b18..45e92008665 100644 --- a/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types +++ b/tests/baselines/reference/typeParameterAsTypeParameterConstraintTransitively2.types @@ -47,27 +47,27 @@ function foo(x: T, y: U, z: V): V { return z; } foo(1, 2, ''); >foo(1, 2, '') : string >foo : (x: T, y: U, z: V) => V ->1 : number ->2 : number ->'' : string +>1 : 1 +>2 : 2 +>'' : "" foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: 2, z: true }); >foo({ x: 1 }, { x: 1, y: '' }, { x: 2, y: 2, z: true }) : { x: number; y: number; z: boolean; } >foo : (x: T, y: U, z: V) => V >{ x: 1 } : { x: number; } >x : number ->1 : number +>1 : 1 >{ x: 1, y: '' } : { x: number; y: string; } >x : number ->1 : number +>1 : 1 >y : string ->'' : string +>'' : "" >{ x: 2, y: 2, z: true } : { x: number; y: number; z: true; } >x : number ->2 : number +>2 : 2 >y : number ->2 : number ->z : true +>2 : 2 +>z : boolean >true : true foo(a, b, a); @@ -83,10 +83,10 @@ foo(a, { foo: 1, bar: '', hm: true }, b); >a : A >{ foo: 1, bar: '', hm: true } : { foo: number; bar: string; hm: true; } >foo : number ->1 : number +>1 : 1 >bar : string ->'' : string ->hm : true +>'' : "" +>hm : boolean >true : true >b : B diff --git a/tests/baselines/reference/typeReferenceDirectives7.types b/tests/baselines/reference/typeReferenceDirectives7.types index dab53a49899..8ef960dd4a9 100644 --- a/tests/baselines/reference/typeReferenceDirectives7.types +++ b/tests/baselines/reference/typeReferenceDirectives7.types @@ -3,7 +3,7 @@ export let $ = 1; >$ : number ->1 : number +>1 : 1 export let x: typeof $; >x : number diff --git a/tests/baselines/reference/typeReferenceDirectives8.types b/tests/baselines/reference/typeReferenceDirectives8.types index 93d80b7988a..54ed0efd6e0 100644 --- a/tests/baselines/reference/typeReferenceDirectives8.types +++ b/tests/baselines/reference/typeReferenceDirectives8.types @@ -22,5 +22,5 @@ export function foo(): Lib { return {x: 1} } >Lib : Lib >{x: 1} : { x: number; } >x : number ->1 : number +>1 : 1 diff --git a/tests/baselines/reference/typeVal.types b/tests/baselines/reference/typeVal.types index d9768a9fbf7..26944f231b2 100644 --- a/tests/baselines/reference/typeVal.types +++ b/tests/baselines/reference/typeVal.types @@ -11,13 +11,13 @@ var I:I = { I: 3}; >I : I >{ I: 3} : { I: number; } >I : number ->3 : number +>3 : 3 I.I=4; ->I.I=4 : number +>I.I=4 : 4 >I.I : number >I : I >I : number ->4 : number +>4 : 4 diff --git a/tests/baselines/reference/typedArrays.types b/tests/baselines/reference/typedArrays.types index f7d3cbdd19f..444d6a74e43 100644 --- a/tests/baselines/reference/typedArrays.types +++ b/tests/baselines/reference/typedArrays.types @@ -11,63 +11,63 @@ function CreateTypedArrayTypes() { >typedArrays[0] = Int8Array : Int8ArrayConstructor >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >Int8Array : Int8ArrayConstructor typedArrays[1] = Uint8Array; >typedArrays[1] = Uint8Array : Uint8ArrayConstructor >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >Uint8Array : Uint8ArrayConstructor typedArrays[2] = Int16Array; >typedArrays[2] = Int16Array : Int16ArrayConstructor >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >Int16Array : Int16ArrayConstructor typedArrays[3] = Uint16Array; >typedArrays[3] = Uint16Array : Uint16ArrayConstructor >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >Uint16Array : Uint16ArrayConstructor typedArrays[4] = Int32Array; >typedArrays[4] = Int32Array : Int32ArrayConstructor >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >Int32Array : Int32ArrayConstructor typedArrays[5] = Uint32Array; >typedArrays[5] = Uint32Array : Uint32ArrayConstructor >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >Uint32Array : Uint32ArrayConstructor typedArrays[6] = Float32Array; >typedArrays[6] = Float32Array : Float32ArrayConstructor >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >Float32Array : Float32ArrayConstructor typedArrays[7] = Float64Array; >typedArrays[7] = Float64Array : Float64ArrayConstructor >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >Float64Array : Float64ArrayConstructor typedArrays[8] = Uint8ClampedArray; >typedArrays[8] = Uint8ClampedArray : Uint8ClampedArrayConstructor >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >Uint8ClampedArray : Uint8ClampedArrayConstructor return typedArrays; @@ -86,7 +86,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[0] = new Int8Array(obj) : Int8Array >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >new Int8Array(obj) : Int8Array >Int8Array : Int8ArrayConstructor >obj : number @@ -95,7 +95,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[1] = new Uint8Array(obj) : Uint8Array >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >new Uint8Array(obj) : Uint8Array >Uint8Array : Uint8ArrayConstructor >obj : number @@ -104,7 +104,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[2] = new Int16Array(obj) : Int16Array >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >new Int16Array(obj) : Int16Array >Int16Array : Int16ArrayConstructor >obj : number @@ -113,7 +113,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[3] = new Uint16Array(obj) : Uint16Array >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >new Uint16Array(obj) : Uint16Array >Uint16Array : Uint16ArrayConstructor >obj : number @@ -122,7 +122,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[4] = new Int32Array(obj) : Int32Array >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >new Int32Array(obj) : Int32Array >Int32Array : Int32ArrayConstructor >obj : number @@ -131,7 +131,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[5] = new Uint32Array(obj) : Uint32Array >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >new Uint32Array(obj) : Uint32Array >Uint32Array : Uint32ArrayConstructor >obj : number @@ -140,7 +140,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[6] = new Float32Array(obj) : Float32Array >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >new Float32Array(obj) : Float32Array >Float32Array : Float32ArrayConstructor >obj : number @@ -149,7 +149,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[7] = new Float64Array(obj) : Float64Array >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >new Float64Array(obj) : Float64Array >Float64Array : Float64ArrayConstructor >obj : number @@ -158,7 +158,7 @@ function CreateTypedArrayInstancesFromLength(obj: number) { >typedArrays[8] = new Uint8ClampedArray(obj) : Uint8ClampedArray >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >new Uint8ClampedArray(obj) : Uint8ClampedArray >Uint8ClampedArray : Uint8ClampedArrayConstructor >obj : number @@ -179,7 +179,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[0] = new Int8Array(obj) : Int8Array >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >new Int8Array(obj) : Int8Array >Int8Array : Int8ArrayConstructor >obj : number[] @@ -188,7 +188,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[1] = new Uint8Array(obj) : Uint8Array >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >new Uint8Array(obj) : Uint8Array >Uint8Array : Uint8ArrayConstructor >obj : number[] @@ -197,7 +197,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[2] = new Int16Array(obj) : Int16Array >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >new Int16Array(obj) : Int16Array >Int16Array : Int16ArrayConstructor >obj : number[] @@ -206,7 +206,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[3] = new Uint16Array(obj) : Uint16Array >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >new Uint16Array(obj) : Uint16Array >Uint16Array : Uint16ArrayConstructor >obj : number[] @@ -215,7 +215,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[4] = new Int32Array(obj) : Int32Array >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >new Int32Array(obj) : Int32Array >Int32Array : Int32ArrayConstructor >obj : number[] @@ -224,7 +224,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[5] = new Uint32Array(obj) : Uint32Array >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >new Uint32Array(obj) : Uint32Array >Uint32Array : Uint32ArrayConstructor >obj : number[] @@ -233,7 +233,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[6] = new Float32Array(obj) : Float32Array >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >new Float32Array(obj) : Float32Array >Float32Array : Float32ArrayConstructor >obj : number[] @@ -242,7 +242,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[7] = new Float64Array(obj) : Float64Array >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >new Float64Array(obj) : Float64Array >Float64Array : Float64ArrayConstructor >obj : number[] @@ -251,7 +251,7 @@ function CreateTypedArrayInstancesFromArray(obj: number[]) { >typedArrays[8] = new Uint8ClampedArray(obj) : Uint8ClampedArray >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >new Uint8ClampedArray(obj) : Uint8ClampedArray >Uint8ClampedArray : Uint8ClampedArrayConstructor >obj : number[] @@ -272,7 +272,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[0] = Int8Array.from(obj) : Int8Array >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >Int8Array.from(obj) : Int8Array >Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor @@ -283,7 +283,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[1] = Uint8Array.from(obj) : Uint8Array >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >Uint8Array.from(obj) : Uint8Array >Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor @@ -294,7 +294,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[2] = Int16Array.from(obj) : Int16Array >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >Int16Array.from(obj) : Int16Array >Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor @@ -305,7 +305,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[3] = Uint16Array.from(obj) : Uint16Array >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >Uint16Array.from(obj) : Uint16Array >Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor @@ -316,7 +316,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[4] = Int32Array.from(obj) : Int32Array >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >Int32Array.from(obj) : Int32Array >Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor @@ -327,7 +327,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[5] = Uint32Array.from(obj) : Uint32Array >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >Uint32Array.from(obj) : Uint32Array >Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor @@ -338,7 +338,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[6] = Float32Array.from(obj) : Float32Array >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >Float32Array.from(obj) : Float32Array >Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor @@ -349,7 +349,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[7] = Float64Array.from(obj) : Float64Array >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >Float64Array.from(obj) : Float64Array >Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor @@ -360,7 +360,7 @@ function CreateIntegerTypedArraysFromArray2(obj:number[]) { >typedArrays[8] = Uint8ClampedArray.from(obj) : Uint8ClampedArray >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray >Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor @@ -384,7 +384,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[0] = Int8Array.from(obj) : Int8Array >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >Int8Array.from(obj) : Int8Array >Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor @@ -395,7 +395,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[1] = Uint8Array.from(obj) : Uint8Array >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >Uint8Array.from(obj) : Uint8Array >Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor @@ -406,7 +406,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[2] = Int16Array.from(obj) : Int16Array >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >Int16Array.from(obj) : Int16Array >Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor @@ -417,7 +417,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[3] = Uint16Array.from(obj) : Uint16Array >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >Uint16Array.from(obj) : Uint16Array >Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor @@ -428,7 +428,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[4] = Int32Array.from(obj) : Int32Array >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >Int32Array.from(obj) : Int32Array >Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor @@ -439,7 +439,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[5] = Uint32Array.from(obj) : Uint32Array >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >Uint32Array.from(obj) : Uint32Array >Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor @@ -450,7 +450,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[6] = Float32Array.from(obj) : Float32Array >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >Float32Array.from(obj) : Float32Array >Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor @@ -461,7 +461,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[7] = Float64Array.from(obj) : Float64Array >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >Float64Array.from(obj) : Float64Array >Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor @@ -472,7 +472,7 @@ function CreateIntegerTypedArraysFromArrayLike(obj:ArrayLike) { >typedArrays[8] = Uint8ClampedArray.from(obj) : Uint8ClampedArray >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >Uint8ClampedArray.from(obj) : Uint8ClampedArray >Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor @@ -495,7 +495,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[0] = Int8Array.of(...obj) : Int8Array >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >Int8Array.of(...obj) : Int8Array >Int8Array.of : (...items: number[]) => Int8Array >Int8Array : Int8ArrayConstructor @@ -507,7 +507,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[1] = Uint8Array.of(...obj) : Uint8Array >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >Uint8Array.of(...obj) : Uint8Array >Uint8Array.of : (...items: number[]) => Uint8Array >Uint8Array : Uint8ArrayConstructor @@ -519,7 +519,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[2] = Int16Array.of(...obj) : Int16Array >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >Int16Array.of(...obj) : Int16Array >Int16Array.of : (...items: number[]) => Int16Array >Int16Array : Int16ArrayConstructor @@ -531,7 +531,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[3] = Uint16Array.of(...obj) : Uint16Array >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >Uint16Array.of(...obj) : Uint16Array >Uint16Array.of : (...items: number[]) => Uint16Array >Uint16Array : Uint16ArrayConstructor @@ -543,7 +543,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[4] = Int32Array.of(...obj) : Int32Array >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >Int32Array.of(...obj) : Int32Array >Int32Array.of : (...items: number[]) => Int32Array >Int32Array : Int32ArrayConstructor @@ -555,7 +555,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[5] = Uint32Array.of(...obj) : Uint32Array >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >Uint32Array.of(...obj) : Uint32Array >Uint32Array.of : (...items: number[]) => Uint32Array >Uint32Array : Uint32ArrayConstructor @@ -567,7 +567,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[6] = Float32Array.of(...obj) : Float32Array >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >Float32Array.of(...obj) : Float32Array >Float32Array.of : (...items: number[]) => Float32Array >Float32Array : Float32ArrayConstructor @@ -579,7 +579,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[7] = Float64Array.of(...obj) : Float64Array >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >Float64Array.of(...obj) : Float64Array >Float64Array.of : (...items: number[]) => Float64Array >Float64Array : Float64ArrayConstructor @@ -591,7 +591,7 @@ function CreateTypedArraysOf(obj) { >typedArrays[8] = Uint8ClampedArray.of(...obj) : Uint8ClampedArray >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >Uint8ClampedArray.of(...obj) : Uint8ClampedArray >Uint8ClampedArray.of : (...items: number[]) => Uint8ClampedArray >Uint8ClampedArray : Uint8ClampedArrayConstructor @@ -614,127 +614,127 @@ function CreateTypedArraysOf2() { >typedArrays[0] = Int8Array.of(1,2,3,4) : Int8Array >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >Int8Array.of(1,2,3,4) : Int8Array >Int8Array.of : (...items: number[]) => Int8Array >Int8Array : Int8ArrayConstructor >of : (...items: number[]) => Int8Array ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 typedArrays[1] = Uint8Array.of(1,2,3,4); >typedArrays[1] = Uint8Array.of(1,2,3,4) : Uint8Array >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >Uint8Array.of(1,2,3,4) : Uint8Array >Uint8Array.of : (...items: number[]) => Uint8Array >Uint8Array : Uint8ArrayConstructor >of : (...items: number[]) => Uint8Array ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 typedArrays[2] = Int16Array.of(1,2,3,4); >typedArrays[2] = Int16Array.of(1,2,3,4) : Int16Array >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >Int16Array.of(1,2,3,4) : Int16Array >Int16Array.of : (...items: number[]) => Int16Array >Int16Array : Int16ArrayConstructor >of : (...items: number[]) => Int16Array ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 typedArrays[3] = Uint16Array.of(1,2,3,4); >typedArrays[3] = Uint16Array.of(1,2,3,4) : Uint16Array >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >Uint16Array.of(1,2,3,4) : Uint16Array >Uint16Array.of : (...items: number[]) => Uint16Array >Uint16Array : Uint16ArrayConstructor >of : (...items: number[]) => Uint16Array ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 typedArrays[4] = Int32Array.of(1,2,3,4); >typedArrays[4] = Int32Array.of(1,2,3,4) : Int32Array >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >Int32Array.of(1,2,3,4) : Int32Array >Int32Array.of : (...items: number[]) => Int32Array >Int32Array : Int32ArrayConstructor >of : (...items: number[]) => Int32Array ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 typedArrays[5] = Uint32Array.of(1,2,3,4); >typedArrays[5] = Uint32Array.of(1,2,3,4) : Uint32Array >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >Uint32Array.of(1,2,3,4) : Uint32Array >Uint32Array.of : (...items: number[]) => Uint32Array >Uint32Array : Uint32ArrayConstructor >of : (...items: number[]) => Uint32Array ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 typedArrays[6] = Float32Array.of(1,2,3,4); >typedArrays[6] = Float32Array.of(1,2,3,4) : Float32Array >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >Float32Array.of(1,2,3,4) : Float32Array >Float32Array.of : (...items: number[]) => Float32Array >Float32Array : Float32ArrayConstructor >of : (...items: number[]) => Float32Array ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 typedArrays[7] = Float64Array.of(1,2,3,4); >typedArrays[7] = Float64Array.of(1,2,3,4) : Float64Array >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >Float64Array.of(1,2,3,4) : Float64Array >Float64Array.of : (...items: number[]) => Float64Array >Float64Array : Float64ArrayConstructor >of : (...items: number[]) => Float64Array ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 typedArrays[8] = Uint8ClampedArray.of(1,2,3,4); >typedArrays[8] = Uint8ClampedArray.of(1,2,3,4) : Uint8ClampedArray >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >Uint8ClampedArray.of(1,2,3,4) : Uint8ClampedArray >Uint8ClampedArray.of : (...items: number[]) => Uint8ClampedArray >Uint8ClampedArray : Uint8ClampedArrayConstructor >of : (...items: number[]) => Uint8ClampedArray ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 return typedArrays; >typedArrays : any[] @@ -756,7 +756,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[0] = Int8Array.from(obj, mapFn) : Int8Array >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >Int8Array.from(obj, mapFn) : Int8Array >Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor @@ -768,7 +768,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[1] = Uint8Array.from(obj, mapFn) : Uint8Array >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >Uint8Array.from(obj, mapFn) : Uint8Array >Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor @@ -780,7 +780,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[2] = Int16Array.from(obj, mapFn) : Int16Array >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >Int16Array.from(obj, mapFn) : Int16Array >Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor @@ -792,7 +792,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[3] = Uint16Array.from(obj, mapFn) : Uint16Array >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >Uint16Array.from(obj, mapFn) : Uint16Array >Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor @@ -804,7 +804,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[4] = Int32Array.from(obj, mapFn) : Int32Array >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >Int32Array.from(obj, mapFn) : Int32Array >Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor @@ -816,7 +816,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[5] = Uint32Array.from(obj, mapFn) : Uint32Array >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >Uint32Array.from(obj, mapFn) : Uint32Array >Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor @@ -828,7 +828,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[6] = Float32Array.from(obj, mapFn) : Float32Array >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >Float32Array.from(obj, mapFn) : Float32Array >Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor @@ -840,7 +840,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[7] = Float64Array.from(obj, mapFn) : Float64Array >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >Float64Array.from(obj, mapFn) : Float64Array >Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor @@ -852,7 +852,7 @@ function CreateTypedArraysFromMapFn(obj:ArrayLike, mapFn: (n:number, v:n >typedArrays[8] = Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >Uint8ClampedArray.from(obj, mapFn) : Uint8ClampedArray >Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor @@ -881,7 +881,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[0] = Int8Array.from(obj, mapFn, thisArg) : Int8Array >typedArrays[0] : any >typedArrays : any[] ->0 : number +>0 : 0 >Int8Array.from(obj, mapFn, thisArg) : Int8Array >Int8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; } >Int8Array : Int8ArrayConstructor @@ -894,7 +894,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[1] = Uint8Array.from(obj, mapFn, thisArg) : Uint8Array >typedArrays[1] : any >typedArrays : any[] ->1 : number +>1 : 1 >Uint8Array.from(obj, mapFn, thisArg) : Uint8Array >Uint8Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; } >Uint8Array : Uint8ArrayConstructor @@ -907,7 +907,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[2] = Int16Array.from(obj, mapFn, thisArg) : Int16Array >typedArrays[2] : any >typedArrays : any[] ->2 : number +>2 : 2 >Int16Array.from(obj, mapFn, thisArg) : Int16Array >Int16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; } >Int16Array : Int16ArrayConstructor @@ -920,7 +920,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[3] = Uint16Array.from(obj, mapFn, thisArg) : Uint16Array >typedArrays[3] : any >typedArrays : any[] ->3 : number +>3 : 3 >Uint16Array.from(obj, mapFn, thisArg) : Uint16Array >Uint16Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; } >Uint16Array : Uint16ArrayConstructor @@ -933,7 +933,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[4] = Int32Array.from(obj, mapFn, thisArg) : Int32Array >typedArrays[4] : any >typedArrays : any[] ->4 : number +>4 : 4 >Int32Array.from(obj, mapFn, thisArg) : Int32Array >Int32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; } >Int32Array : Int32ArrayConstructor @@ -946,7 +946,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[5] = Uint32Array.from(obj, mapFn, thisArg) : Uint32Array >typedArrays[5] : any >typedArrays : any[] ->5 : number +>5 : 5 >Uint32Array.from(obj, mapFn, thisArg) : Uint32Array >Uint32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; } >Uint32Array : Uint32ArrayConstructor @@ -959,7 +959,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[6] = Float32Array.from(obj, mapFn, thisArg) : Float32Array >typedArrays[6] : any >typedArrays : any[] ->6 : number +>6 : 6 >Float32Array.from(obj, mapFn, thisArg) : Float32Array >Float32Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; } >Float32Array : Float32ArrayConstructor @@ -972,7 +972,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[7] = Float64Array.from(obj, mapFn, thisArg) : Float64Array >typedArrays[7] : any >typedArrays : any[] ->7 : number +>7 : 7 >Float64Array.from(obj, mapFn, thisArg) : Float64Array >Float64Array.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; } >Float64Array : Float64ArrayConstructor @@ -985,7 +985,7 @@ function CreateTypedArraysFromThisObj(obj:ArrayLike, mapFn: (n:number, v >typedArrays[8] = Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray >typedArrays[8] : any >typedArrays : any[] ->8 : number +>8 : 8 >Uint8ClampedArray.from(obj, mapFn, thisArg) : Uint8ClampedArray >Uint8ClampedArray.from : { (arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; (arrayLike: Iterable, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; } >Uint8ClampedArray : Uint8ClampedArrayConstructor diff --git a/tests/baselines/reference/typedGenericPrototypeMember.types b/tests/baselines/reference/typedGenericPrototypeMember.types index 9e3f064de0d..b772c3be680 100644 --- a/tests/baselines/reference/typedGenericPrototypeMember.types +++ b/tests/baselines/reference/typedGenericPrototypeMember.types @@ -16,5 +16,5 @@ List.prototype.add("abc"); // Valid because T is instantiated to any >List : typeof List >prototype : List >add : (item: any) => void ->"abc" : string +>"abc" : "abc" diff --git a/tests/baselines/reference/typeofEnum.types b/tests/baselines/reference/typeofEnum.types index 2140bfa175b..9026e664c14 100644 --- a/tests/baselines/reference/typeofEnum.types +++ b/tests/baselines/reference/typeofEnum.types @@ -3,10 +3,10 @@ enum E { >E : E e1, ->e1 : E +>e1 : E.e1 e2 ->e2 : E +>e2 : E.e2 } var e1: typeof E; @@ -14,7 +14,7 @@ var e1: typeof E; >E : typeof E e1.e1; ->e1.e1 : E +>e1.e1 : E.e1 >e1 : typeof E ->e1 : E +>e1 : E.e1 diff --git a/tests/baselines/reference/typeofInterface.types b/tests/baselines/reference/typeofInterface.types index 70e3cfe6926..fad9b029004 100644 --- a/tests/baselines/reference/typeofInterface.types +++ b/tests/baselines/reference/typeofInterface.types @@ -25,5 +25,5 @@ var j: typeof k.foo = { a: "hello" }; >foo : { a: string; } >{ a: "hello" } : { a: string; } >a : string ->"hello" : string +>"hello" : "hello" diff --git a/tests/baselines/reference/typeofModuleWithoutExports.types b/tests/baselines/reference/typeofModuleWithoutExports.types index e0f29156c53..764a6c1df33 100644 --- a/tests/baselines/reference/typeofModuleWithoutExports.types +++ b/tests/baselines/reference/typeofModuleWithoutExports.types @@ -4,7 +4,7 @@ module M { var x = 1; >x : number ->1 : number +>1 : 1 class C { >C : C diff --git a/tests/baselines/reference/typeofOperatorWithBooleanType.types b/tests/baselines/reference/typeofOperatorWithBooleanType.types index edf3c4e0871..a1a01c3f61f 100644 --- a/tests/baselines/reference/typeofOperatorWithBooleanType.types +++ b/tests/baselines/reference/typeofOperatorWithBooleanType.types @@ -16,7 +16,7 @@ class A { static foo() { return false; } >foo : () => boolean ->false : boolean +>false : false } module M { >M : typeof M @@ -40,16 +40,16 @@ var ResultIsString1 = typeof BOOLEAN; var ResultIsString2 = typeof true; >ResultIsString2 : string >typeof true : string ->true : boolean +>true : true var ResultIsString3 = typeof { x: true, y: false }; >ResultIsString3 : string >typeof { x: true, y: false } : string >{ x: true, y: false } : { x: boolean; y: boolean; } >x : boolean ->true : boolean +>true : true >y : boolean ->false : boolean +>false : false // boolean type expressions var ResultIsString4 = typeof objA.a; @@ -90,7 +90,7 @@ var ResultIsString8 = typeof typeof BOOLEAN; // miss assignment operators typeof true; >typeof true : string ->true : boolean +>true : true typeof BOOLEAN; >typeof BOOLEAN : string @@ -102,10 +102,10 @@ typeof foo(); >foo : () => boolean typeof true, false; ->typeof true, false : boolean +>typeof true, false : false >typeof true : string ->true : boolean ->false : boolean +>true : true +>false : false typeof objA.a; >typeof objA.a : string @@ -143,9 +143,9 @@ var y = { a: true, b: false}; >y : { a: boolean; b: boolean; } >{ a: true, b: false} : { a: boolean; b: boolean; } >a : boolean ->true : boolean +>true : true >b : boolean ->false : boolean +>false : false z: typeof y.a; >z : any diff --git a/tests/baselines/reference/typeofOperatorWithEnumType.types b/tests/baselines/reference/typeofOperatorWithEnumType.types index f9224811393..ec147bce889 100644 --- a/tests/baselines/reference/typeofOperatorWithEnumType.types +++ b/tests/baselines/reference/typeofOperatorWithEnumType.types @@ -7,8 +7,8 @@ enum ENUM { }; enum ENUM1 { A, B, "" }; >ENUM1 : ENUM1 ->A : ENUM1 ->B : ENUM1 +>A : ENUM1.A +>B : ENUM1.B // enum type var var ResultIsString1 = typeof ENUM; @@ -25,9 +25,9 @@ var ResultIsString2 = typeof ENUM1; var ResultIsString3 = typeof ENUM1["A"]; >ResultIsString3 : string >typeof ENUM1["A"] : string ->ENUM1["A"] : ENUM1 +>ENUM1["A"] : ENUM1.A >ENUM1 : typeof ENUM1 ->"A" : string +>"A" : "A" var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); >ResultIsString4 : string @@ -36,10 +36,10 @@ var ResultIsString4 = typeof (ENUM[0] + ENUM1["B"]); >ENUM[0] + ENUM1["B"] : string >ENUM[0] : string >ENUM : typeof ENUM ->0 : number ->ENUM1["B"] : ENUM1 +>0 : 0 +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" // multiple typeof operators var ResultIsString5 = typeof typeof ENUM; @@ -57,10 +57,10 @@ var ResultIsString6 = typeof typeof typeof (ENUM[0] + ENUM1.B); >ENUM[0] + ENUM1.B : string >ENUM[0] : string >ENUM : typeof ENUM ->0 : number ->ENUM1.B : ENUM1 +>0 : 0 +>ENUM1.B : ENUM1.B >ENUM1 : typeof ENUM1 ->B : ENUM1 +>B : ENUM1.B // miss assignment operators typeof ENUM; @@ -73,9 +73,9 @@ typeof ENUM1; typeof ENUM1["B"]; >typeof ENUM1["B"] : string ->ENUM1["B"] : ENUM1 +>ENUM1["B"] : ENUM1.B >ENUM1 : typeof ENUM1 ->"B" : string +>"B" : "B" typeof ENUM, ENUM1; >typeof ENUM, ENUM1 : typeof ENUM1 diff --git a/tests/baselines/reference/typeofOperatorWithNumberType.types b/tests/baselines/reference/typeofOperatorWithNumberType.types index b80e6b1d4a8..d497257d636 100644 --- a/tests/baselines/reference/typeofOperatorWithNumberType.types +++ b/tests/baselines/reference/typeofOperatorWithNumberType.types @@ -6,12 +6,12 @@ var NUMBER: number; var NUMBER1: number[] = [1, 2]; >NUMBER1 : number[] >[1, 2] : number[] ->1 : number ->2 : number +>1 : 1 +>2 : 2 function foo(): number { return 1; } >foo : () => number ->1 : number +>1 : 1 class A { >A : A @@ -21,7 +21,7 @@ class A { static foo() { return 1; } >foo : () => number ->1 : number +>1 : 1 } module M { >M : typeof M @@ -50,23 +50,23 @@ var ResultIsString2 = typeof NUMBER1; var ResultIsString3 = typeof 1; >ResultIsString3 : string >typeof 1 : string ->1 : number +>1 : 1 var ResultIsString4 = typeof { x: 1, y: 2}; >ResultIsString4 : string >typeof { x: 1, y: 2} : string >{ x: 1, y: 2} : { x: number; y: number; } >x : number ->1 : number +>1 : 1 >y : number ->2 : number +>2 : 2 var ResultIsString5 = typeof { x: 1, y: (n: number) => { return n; } }; >ResultIsString5 : string >typeof { x: 1, y: (n: number) => { return n; } } : string >{ x: 1, y: (n: number) => { return n; } } : { x: number; y: (n: number) => number; } >x : number ->1 : number +>1 : 1 >y : (n: number) => number >(n: number) => { return n; } : (n: number) => number >n : number @@ -92,7 +92,7 @@ var ResultIsString8 = typeof NUMBER1[0]; >typeof NUMBER1[0] : string >NUMBER1[0] : number >NUMBER1 : number[] ->0 : number +>0 : 0 var ResultIsString9 = typeof foo(); >ResultIsString9 : string @@ -136,7 +136,7 @@ var ResultIsString13 = typeof typeof typeof (NUMBER + NUMBER); // miss assignment operators typeof 1; >typeof 1 : string ->1 : number +>1 : 1 typeof NUMBER; >typeof NUMBER : string @@ -199,9 +199,9 @@ var y = { a: 1, b: 2 }; >y : { a: number; b: number; } >{ a: 1, b: 2 } : { a: number; b: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 z: typeof y.a; >z : any diff --git a/tests/baselines/reference/typesWithOptionalProperty.types b/tests/baselines/reference/typesWithOptionalProperty.types index 89879740732..e69b875a831 100644 --- a/tests/baselines/reference/typesWithOptionalProperty.types +++ b/tests/baselines/reference/typesWithOptionalProperty.types @@ -32,26 +32,26 @@ var b = { foo: '' }; >b : { foo: string; } >{ foo: '' } : { foo: string; } >foo : string ->'' : string +>'' : "" var c = { foo: '', bar: 3 }; >c : { foo: string; bar: number; } >{ foo: '', bar: 3 } : { foo: string; bar: number; } >foo : string ->'' : string +>'' : "" >bar : number ->3 : number +>3 : 3 var d = { foo: '', bar: 3, baz: () => '' }; >d : { foo: string; bar: number; baz: () => string; } >{ foo: '', bar: 3, baz: () => '' } : { foo: string; bar: number; baz: () => string; } >foo : string ->'' : string +>'' : "" >bar : number ->3 : number +>3 : 3 >baz : () => string >() => '' : () => string ->'' : string +>'' : "" var i: I; >i : I diff --git a/tests/baselines/reference/typesWithSpecializedCallSignatures.types b/tests/baselines/reference/typesWithSpecializedCallSignatures.types index b587ee7840e..b2ce825199f 100644 --- a/tests/baselines/reference/typesWithSpecializedCallSignatures.types +++ b/tests/baselines/reference/typesWithSpecializedCallSignatures.types @@ -143,5 +143,5 @@ var r3: Base = c.foo('hm'); >c.foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } >c : C >foo : { (x: "hi"): Derived1; (x: "bye"): Derived2; (x: string): Base; } ->'hm' : string +>'hm' : "hm" diff --git a/tests/baselines/reference/typesWithSpecializedConstructSignatures.types b/tests/baselines/reference/typesWithSpecializedConstructSignatures.types index 3036c0cea71..3829cd5ce21 100644 --- a/tests/baselines/reference/typesWithSpecializedConstructSignatures.types +++ b/tests/baselines/reference/typesWithSpecializedConstructSignatures.types @@ -38,7 +38,7 @@ var c = new C('a'); >c : C >new C('a') : C >C : typeof C ->'a' : string +>'a' : "a" interface I { >I : I @@ -114,5 +114,5 @@ var r3: Base = new a('hm'); >Base : Base >new a('hm') : Base >a : { new (x: "hi"): Derived1; new (x: "bye"): Derived2; new (x: string): Base; } ->'hm' : string +>'hm' : "hm" diff --git a/tests/baselines/reference/typingsLookup4.types b/tests/baselines/reference/typingsLookup4.types index d922c7b1dfa..e3f747ac55d 100644 --- a/tests/baselines/reference/typingsLookup4.types +++ b/tests/baselines/reference/typingsLookup4.types @@ -6,14 +6,14 @@ import { k } from "kquery"; >k : number import { l } from "lquery"; ->l : number +>l : 2 j + k + l; >j + k + l : number >j + k : number >j : number >k : number ->l : number +>l : 2 === /node_modules/@types/jquery/jquery.d.ts === export const j: number; @@ -25,6 +25,6 @@ export const k: number; === /node_modules/@types/lquery/lquery.ts === export const l = 2; ->l : number ->2 : number +>l : 2 +>2 : 2 diff --git a/tests/baselines/reference/umd-augmentation-1.types b/tests/baselines/reference/umd-augmentation-1.types index 59b577141e0..8f759912256 100644 --- a/tests/baselines/reference/umd-augmentation-1.types +++ b/tests/baselines/reference/umd-augmentation-1.types @@ -9,8 +9,8 @@ let v = new m.Vector(3, 2); >m.Vector : typeof m.Vector >m : typeof m >Vector : typeof m.Vector ->3 : number ->2 : number +>3 : 3 +>2 : 2 let magnitude = m.getLength(v); >magnitude : number @@ -28,8 +28,8 @@ let p: m.Point = v.translate(5, 5); >v.translate : (dx: number, dy: number) => m.Vector >v : m.Vector >translate : (dx: number, dy: number) => m.Vector ->5 : number ->5 : number +>5 : 5 +>5 : 5 p = v.reverse(); >p = v.reverse() : m.Point diff --git a/tests/baselines/reference/umd-augmentation-2.types b/tests/baselines/reference/umd-augmentation-2.types index 24fe6df3c3c..98d1d52ba4d 100644 --- a/tests/baselines/reference/umd-augmentation-2.types +++ b/tests/baselines/reference/umd-augmentation-2.types @@ -7,8 +7,8 @@ let v = new Math2d.Vector(3, 2); >Math2d.Vector : typeof Math2d.Vector >Math2d : typeof Math2d >Vector : typeof Math2d.Vector ->3 : number ->2 : number +>3 : 3 +>2 : 2 let magnitude = Math2d.getLength(v); >magnitude : number @@ -26,8 +26,8 @@ let p: Math2d.Point = v.translate(5, 5); >v.translate : (dx: number, dy: number) => Vector >v : Vector >translate : (dx: number, dy: number) => Vector ->5 : number ->5 : number +>5 : 5 +>5 : 5 p = v.reverse(); >p = v.reverse() : Math2d.Point diff --git a/tests/baselines/reference/umd-augmentation-3.types b/tests/baselines/reference/umd-augmentation-3.types index 39bc28cbd24..c62107cc40f 100644 --- a/tests/baselines/reference/umd-augmentation-3.types +++ b/tests/baselines/reference/umd-augmentation-3.types @@ -9,8 +9,8 @@ let v = new m.Vector(3, 2); >m.Vector : typeof m.Vector >m : typeof m >Vector : typeof m.Vector ->3 : number ->2 : number +>3 : 3 +>2 : 2 let magnitude = m.getLength(v); >magnitude : number @@ -28,8 +28,8 @@ let p: m.Point = v.translate(5, 5); >v.translate : (dx: number, dy: number) => m.Vector >v : m.Vector >translate : (dx: number, dy: number) => m.Vector ->5 : number ->5 : number +>5 : 5 +>5 : 5 p = v.reverse(); >p = v.reverse() : m.Point diff --git a/tests/baselines/reference/umd-augmentation-4.types b/tests/baselines/reference/umd-augmentation-4.types index 246270aa5a6..e1283c74a7c 100644 --- a/tests/baselines/reference/umd-augmentation-4.types +++ b/tests/baselines/reference/umd-augmentation-4.types @@ -7,8 +7,8 @@ let v = new Math2d.Vector(3, 2); >Math2d.Vector : typeof Math2d.Vector >Math2d : typeof Math2d >Vector : typeof Math2d.Vector ->3 : number ->2 : number +>3 : 3 +>2 : 2 let magnitude = Math2d.getLength(v); >magnitude : number @@ -26,8 +26,8 @@ let p: Math2d.Point = v.translate(5, 5); >v.translate : (dx: number, dy: number) => Math2d.Vector >v : Math2d.Vector >translate : (dx: number, dy: number) => Math2d.Vector ->5 : number ->5 : number +>5 : 5 +>5 : 5 p = v.reverse(); >p = v.reverse() : Math2d.Point diff --git a/tests/baselines/reference/unaryPlus.types b/tests/baselines/reference/unaryPlus.types index fc7a038ac72..8f92b51a159 100644 --- a/tests/baselines/reference/unaryPlus.types +++ b/tests/baselines/reference/unaryPlus.types @@ -3,40 +3,40 @@ var a = +1; >a : number >+1 : number ->1 : number +>1 : 1 var b = +(""); >b : number >+("") : number >("") : any >"" : any ->"" : string +>"" : "" enum E { some, thing }; >E : E ->some : E ->thing : E +>some : E.some +>thing : E.thing var c = +E.some; >c : number >+E.some : number ->E.some : E +>E.some : E.some >E : typeof E ->some : E +>some : E.some // also allowed, used to be errors var x = +"3"; //should be valid >x : number >+"3" : number ->"3" : string +>"3" : "3" var y = -"3"; // should be valid >y : number >-"3" : number ->"3" : string +>"3" : "3" var z = ~"3"; // should be valid >z : number >~"3" : number ->"3" : string +>"3" : "3" diff --git a/tests/baselines/reference/uncaughtCompilerError1.types b/tests/baselines/reference/uncaughtCompilerError1.types index 83503195f71..d69a52334b3 100644 --- a/tests/baselines/reference/uncaughtCompilerError1.types +++ b/tests/baselines/reference/uncaughtCompilerError1.types @@ -22,7 +22,7 @@ function f() { >'=' : "=" >index > 0 : boolean >index : any ->0 : number +>0 : 0 >token.type === '' : boolean >token.type : any >token : any @@ -34,7 +34,7 @@ function f() { >tokens : any >index - 1 : number >index : any ->1 : number +>1 : 1 >type : any >'attribute.name.html' : "attribute.name.html" @@ -46,14 +46,14 @@ function f() { >tokens.length : any >tokens : any >length : any ->1 : number +>1 : 1 return { appendText: '\"\"', advanceCount: 1 }; >{ appendText: '\"\"', advanceCount: 1 } : { appendText: string; advanceCount: number; } >appendText : string ->'\"\"' : string +>'\"\"' : "\"\"" >advanceCount : number ->1 : number +>1 : 1 } else if (tokens[index + 1].type !== 'attribute.value.html' && tokens[index + 1].type !== '') { >tokens[index + 1].type !== 'attribute.value.html' && tokens[index + 1].type !== '' : boolean @@ -63,7 +63,7 @@ function f() { >tokens : any >index + 1 : any >index : any ->1 : number +>1 : 1 >type : any >'attribute.value.html' : "attribute.value.html" >tokens[index + 1].type !== '' : boolean @@ -72,16 +72,16 @@ function f() { >tokens : any >index + 1 : any >index : any ->1 : number +>1 : 1 >type : any >'' : "" return { appendText: '\"\"', advanceCount: 1 }; >{ appendText: '\"\"', advanceCount: 1 } : { appendText: string; advanceCount: number; } >appendText : string ->'\"\"' : string +>'\"\"' : "\"\"" >advanceCount : number ->1 : number +>1 : 1 } return null; >null : null diff --git a/tests/baselines/reference/undefinedInferentialTyping.types b/tests/baselines/reference/undefinedInferentialTyping.types index 525181f0f4c..3633c30f755 100644 --- a/tests/baselines/reference/undefinedInferentialTyping.types +++ b/tests/baselines/reference/undefinedInferentialTyping.types @@ -17,5 +17,5 @@ var a = f([], 3); // should be number >f([], 3) : number >f : (arr: T[], elemnt: T) => T >[] : undefined[] ->3 : number +>3 : 3 diff --git a/tests/baselines/reference/undefinedIsSubtypeOfEverything.types b/tests/baselines/reference/undefinedIsSubtypeOfEverything.types index d89f032bf29..c52b7b62114 100644 --- a/tests/baselines/reference/undefinedIsSubtypeOfEverything.types +++ b/tests/baselines/reference/undefinedIsSubtypeOfEverything.types @@ -171,7 +171,7 @@ module f { export var bar = 1; >bar : number ->1 : number +>1 : 1 } class D12 extends Base { >D12 : D12 @@ -192,7 +192,7 @@ module c { export var bar = 1; >bar : number ->1 : number +>1 : 1 } class D13 extends Base { >D13 : D13 diff --git a/tests/baselines/reference/underscoreMapFirst.types b/tests/baselines/reference/underscoreMapFirst.types index 60cbcccda2b..4de13891137 100644 --- a/tests/baselines/reference/underscoreMapFirst.types +++ b/tests/baselines/reference/underscoreMapFirst.types @@ -127,7 +127,7 @@ class MyView extends View { >this : this >model : any >get : any ->"data" : string +>"data" : "data" var allSeries: ISeries[][] = _.pluck(data, "series"); >allSeries : ISeries[][] @@ -137,7 +137,7 @@ class MyView extends View { >_ : typeof _ >pluck : (list: _.Collection, propertyName: string) => any[] >data : IData[] ->"series" : string +>"series" : "series" return _.map(allSeries, _.first); >_.map(allSeries, _.first) : ISeries[] diff --git a/tests/baselines/reference/underscoreTest1.types b/tests/baselines/reference/underscoreTest1.types index ac794e1f2f9..d4898d43bed 100644 --- a/tests/baselines/reference/underscoreTest1.types +++ b/tests/baselines/reference/underscoreTest1.types @@ -14,9 +14,9 @@ _.each([1, 2, 3], (num) => alert(num.toString())); >_ : Underscore.Static >each : { (list: T[], iterator: Iterator, context?: any): void; (list: Dictionary, iterator: Iterator, context?: any): void; } >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >(num) => alert(num.toString()) : (num: number) => void >num : number >alert(num.toString()) : void @@ -33,11 +33,11 @@ _.each({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => alert(valu >each : { (list: T[], iterator: Iterator, context?: any): void; (list: Dictionary, iterator: Iterator, context?: any): void; } >{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number ->1 : number +>1 : 1 >two : number ->2 : number +>2 : 2 >three : number ->3 : number +>3 : 3 >(value: number, key?: string) => alert(value.toString()) : (value: number, key?: string) => void >value : number >key : string @@ -54,14 +54,14 @@ _.map([1, 2, 3], (num) => num * 3); >_ : Underscore.Static >map : { (list: T[], iterator: Iterator, context?: any): U[]; (list: Dictionary, iterator: Iterator, context?: any): U[]; } >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >(num) => num * 3 : (num: number) => number >num : number >num * 3 : number >num : number ->3 : number +>3 : 3 _.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3); >_.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3) : number[] @@ -70,17 +70,17 @@ _.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3); >map : { (list: T[], iterator: Iterator, context?: any): U[]; (list: Dictionary, iterator: Iterator, context?: any): U[]; } >{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number ->1 : number +>1 : 1 >two : number ->2 : number +>2 : 2 >three : number ->3 : number +>3 : 3 >(value: number, key?: string) => value * 3 : (value: number, key?: string) => number >value : number >key : string >value * 3 : number >value : number ->3 : number +>3 : 3 var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0); >sum : number @@ -89,29 +89,29 @@ var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0); >_ : Underscore.Static >reduce : { (list: T[], iterator: Reducer, initialValue?: T, context?: any): T; (list: T[], iterator: Reducer, initialValue: U, context?: any): U; (list: Dictionary, iterator: Reducer, initialValue?: T, context?: any): T; (list: Dictionary, iterator: Reducer, initialValue: U, context?: any): U; } >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >(memo, num) => memo + num : (memo: number, num: number) => number >memo : number >num : number >memo + num : number >memo : number >num : number ->0 : number +>0 : 0 var list = [[0, 1], [2, 3], [4, 5]]; >list : number[][] >[[0, 1], [2, 3], [4, 5]] : number[][] >[0, 1] : number[] ->0 : number ->1 : number +>0 : 0 +>1 : 1 >[2, 3] : number[] ->2 : number ->3 : number +>2 : 2 +>3 : 3 >[4, 5] : number[] ->4 : number ->5 : number +>4 : 4 +>5 : 5 var flat = _.reduceRight(list, (a, b) => a.concat(b), []); >flat : number[] @@ -137,18 +137,18 @@ var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); >_ : Underscore.Static >find : { (list: T[], iterator: Iterator, context?: any): T; (list: Dictionary, iterator: Iterator, context?: any): T; } >[1, 2, 3, 4, 5, 6] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number ->6 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>6 : 6 >(num) => num % 2 == 0 : (num: number) => boolean >num : number >num % 2 == 0 : boolean >num % 2 : number >num : number ->2 : number +>2 : 2 >0 : 0 var evens = _.filter([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); @@ -158,18 +158,18 @@ var evens = _.filter([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); >_ : Underscore.Static >filter : { (list: T[], iterator: Iterator, context?: any): T[]; (list: Dictionary, iterator: Iterator, context?: any): T[]; } >[1, 2, 3, 4, 5, 6] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number ->6 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>6 : 6 >(num) => num % 2 == 0 : (num: number) => boolean >num : number >num % 2 == 0 : boolean >num % 2 : number >num : number ->2 : number +>2 : 2 >0 : 0 var listOfPlays = [{ title: "Cymbeline", author: "Shakespeare", year: 1611 }, { title: "The Tempest", author: "Shakespeare", year: 1611 }, { title: "Other", author: "Not Shakespeare", year: 2012 }]; @@ -177,25 +177,25 @@ var listOfPlays = [{ title: "Cymbeline", author: "Shakespeare", year: 1611 }, { >[{ title: "Cymbeline", author: "Shakespeare", year: 1611 }, { title: "The Tempest", author: "Shakespeare", year: 1611 }, { title: "Other", author: "Not Shakespeare", year: 2012 }] : { title: string; author: string; year: number; }[] >{ title: "Cymbeline", author: "Shakespeare", year: 1611 } : { title: string; author: string; year: number; } >title : string ->"Cymbeline" : string +>"Cymbeline" : "Cymbeline" >author : string ->"Shakespeare" : string +>"Shakespeare" : "Shakespeare" >year : number ->1611 : number +>1611 : 1611 >{ title: "The Tempest", author: "Shakespeare", year: 1611 } : { title: string; author: string; year: number; } >title : string ->"The Tempest" : string +>"The Tempest" : "The Tempest" >author : string ->"Shakespeare" : string +>"Shakespeare" : "Shakespeare" >year : number ->1611 : number +>1611 : 1611 >{ title: "Other", author: "Not Shakespeare", year: 2012 } : { title: string; author: string; year: number; } >title : string ->"Other" : string +>"Other" : "Other" >author : string ->"Not Shakespeare" : string +>"Not Shakespeare" : "Not Shakespeare" >year : number ->2012 : number +>2012 : 2012 _.where(listOfPlays, { author: "Shakespeare", year: 1611 }); >_.where(listOfPlays, { author: "Shakespeare", year: 1611 }) : { title: string; author: string; year: number; }[] @@ -205,9 +205,9 @@ _.where(listOfPlays, { author: "Shakespeare", year: 1611 }); >listOfPlays : { title: string; author: string; year: number; }[] >{ author: "Shakespeare", year: 1611 } : { author: string; year: number; } >author : string ->"Shakespeare" : string +>"Shakespeare" : "Shakespeare" >year : number ->1611 : number +>1611 : 1611 var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); >odds : number[] @@ -216,18 +216,18 @@ var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); >_ : Underscore.Static >reject : { (list: T[], iterator: Iterator, context?: any): T[]; (list: Dictionary, iterator: Iterator, context?: any): T[]; } >[1, 2, 3, 4, 5, 6] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number ->6 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>6 : 6 >(num) => num % 2 == 0 : (num: number) => boolean >num : number >num % 2 == 0 : boolean >num % 2 : number >num : number ->2 : number +>2 : 2 >0 : 0 _.all([true, 1, null, 'yes'], _.identity); @@ -235,11 +235,11 @@ _.all([true, 1, null, 'yes'], _.identity); >_.all : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } >_ : Underscore.Static >all : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } ->[true, 1, null, 'yes'] : (string | number | true)[] +>[true, 1, null, 'yes'] : (true | 1 | "yes")[] >true : true ->1 : number +>1 : 1 >null : null ->'yes' : string +>'yes' : "yes" >_.identity : (value: T) => T >_ : Underscore.Static >identity : (value: T) => T @@ -249,10 +249,10 @@ _.any([null, 0, 'yes', false]); >_.any : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } >_ : Underscore.Static >any : { (list: T[], iterator?: Iterator, context?: any): boolean; (list: Dictionary, iterator?: Iterator, context?: any): boolean; } ->[null, 0, 'yes', false] : (string | number | false)[] +>[null, 0, 'yes', false] : (false | 0 | "yes")[] >null : null ->0 : number ->'yes' : string +>0 : 0 +>'yes' : "yes" >false : false _.contains([1, 2, 3], 3); @@ -261,10 +261,10 @@ _.contains([1, 2, 3], 3); >_ : Underscore.Static >contains : { (list: T[], value: T): boolean; (list: Dictionary, value: T): boolean; } >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 +>3 : 3 _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); >_.invoke([[5, 1, 7], [3, 2, 1]], 'sort') : any[] @@ -273,33 +273,33 @@ _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); >invoke : { (list: any[], methodName: string, ...args: any[]): any[]; (list: Dictionary, methodName: string, ...args: any[]): any[]; } >[[5, 1, 7], [3, 2, 1]] : number[][] >[5, 1, 7] : number[] ->5 : number ->1 : number ->7 : number +>5 : 5 +>1 : 1 +>7 : 7 >[3, 2, 1] : number[] ->3 : number ->2 : number ->1 : number ->'sort' : string +>3 : 3 +>2 : 2 +>1 : 1 +>'sort' : "sort" var stooges = [{ name: 'moe', age: 40 }, { name: 'larry', age: 50 }, { name: 'curly', age: 60 }]; >stooges : { name: string; age: number; }[] >[{ name: 'moe', age: 40 }, { name: 'larry', age: 50 }, { name: 'curly', age: 60 }] : { name: string; age: number; }[] >{ name: 'moe', age: 40 } : { name: string; age: number; } >name : string ->'moe' : string +>'moe' : "moe" >age : number ->40 : number +>40 : 40 >{ name: 'larry', age: 50 } : { name: string; age: number; } >name : string ->'larry' : string +>'larry' : "larry" >age : number ->50 : number +>50 : 50 >{ name: 'curly', age: 60 } : { name: string; age: number; } >name : string ->'curly' : string +>'curly' : "curly" >age : number ->60 : number +>60 : 60 _.pluck(stooges, 'name'); >_.pluck(stooges, 'name') : any[] @@ -307,7 +307,7 @@ _.pluck(stooges, 'name'); >_ : Underscore.Static >pluck : { (list: any[], propertyName: string): any[]; (list: Dictionary, propertyName: string): any[]; } >stooges : { name: string; age: number; }[] ->'name' : string +>'name' : "name" _.max(stooges, (stooge) => stooge.age); >_.max(stooges, (stooge) => stooge.age) : { name: string; age: number; } @@ -324,11 +324,11 @@ _.max(stooges, (stooge) => stooge.age); var numbers = [10, 5, 100, 2, 1000]; >numbers : number[] >[10, 5, 100, 2, 1000] : number[] ->10 : number ->5 : number ->100 : number ->2 : number ->1000 : number +>10 : 10 +>5 : 5 +>100 : 100 +>2 : 2 +>1000 : 1000 _.min(numbers); >_.min(numbers) : number @@ -343,12 +343,12 @@ _.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num)); >_ : Underscore.Static >sortBy : { (list: T[], iterator: Iterator, context?: any): T[]; (list: Dictionary, iterator: Iterator, context?: any): T[]; (list: T[], propertyName: string): T[]; (list: Dictionary, propertyName: string): T[]; } >[1, 2, 3, 4, 5, 6] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number ->6 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>6 : 6 >(num) => Math.sin(num) : (num: number) => number >num : number >Math.sin(num) : number @@ -365,9 +365,9 @@ _([1.3, 2.1, 2.4]).groupBy((e: number, i?: number, list?: number[]) => Math.floo >_([1.3, 2.1, 2.4]) : Underscore.WrappedArray >_ : Underscore.Static >[1.3, 2.1, 2.4] : number[] ->1.3 : number ->2.1 : number ->2.4 : number +>1.3 : 1.3 +>2.1 : 2.1 +>2.4 : 2.4 >groupBy : { (iterator?: Iterator, context?: any): Dictionary; (propertyName: string): Dictionary; } >(e: number, i?: number, list?: number[]) => Math.floor(e) : (e: number, i?: number, list?: number[]) => number >e : number @@ -385,9 +385,9 @@ _.groupBy([1.3, 2.1, 2.4], (num: number) => Math.floor(num)); >_ : Underscore.Static >groupBy : { (list: T[], iterator?: Iterator, context?: any): Dictionary; (list: Dictionary, iterator?: Iterator, context?: any): Dictionary; (list: T[], propertyName: string): Dictionary; (list: Dictionary, propertyName: string): Dictionary; } >[1.3, 2.1, 2.4] : number[] ->1.3 : number ->2.1 : number ->2.4 : number +>1.3 : 1.3 +>2.1 : 2.1 +>2.4 : 2.4 >(num: number) => Math.floor(num) : (num: number) => number >num : number >Math.floor(num) : number @@ -402,10 +402,10 @@ _.groupBy(['one', 'two', 'three'], 'length'); >_ : Underscore.Static >groupBy : { (list: T[], iterator?: Iterator, context?: any): Dictionary; (list: Dictionary, iterator?: Iterator, context?: any): Dictionary; (list: T[], propertyName: string): Dictionary; (list: Dictionary, propertyName: string): Dictionary; } >['one', 'two', 'three'] : string[] ->'one' : string ->'two' : string ->'three' : string ->'length' : string +>'one' : "one" +>'two' : "two" +>'three' : "three" +>'length' : "length" _.countBy([1, 2, 3, 4, 5], (num) => num % 2 == 0 ? 'even' : 'odd'); >_.countBy([1, 2, 3, 4, 5], (num) => num % 2 == 0 ? 'even' : 'odd') : Dictionary @@ -413,21 +413,21 @@ _.countBy([1, 2, 3, 4, 5], (num) => num % 2 == 0 ? 'even' : 'odd'); >_ : Underscore.Static >countBy : { (list: T[], iterator?: Iterator, context?: any): Dictionary; (list: Dictionary, iterator?: Iterator, context?: any): Dictionary; (list: T[], propertyName: string): Dictionary; (list: Dictionary, propertyName: string): Dictionary; } >[1, 2, 3, 4, 5] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number ->(num) => num % 2 == 0 ? 'even' : 'odd' : (num: number) => string +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>(num) => num % 2 == 0 ? 'even' : 'odd' : (num: number) => "even" | "odd" >num : number ->num % 2 == 0 ? 'even' : 'odd' : string +>num % 2 == 0 ? 'even' : 'odd' : "even" | "odd" >num % 2 == 0 : boolean >num % 2 : number >num : number ->2 : number +>2 : 2 >0 : 0 ->'even' : string ->'odd' : string +>'even' : "even" +>'odd' : "odd" _.shuffle([1, 2, 3, 4, 5, 6]); >_.shuffle([1, 2, 3, 4, 5, 6]) : number[] @@ -435,12 +435,12 @@ _.shuffle([1, 2, 3, 4, 5, 6]); >_ : Underscore.Static >shuffle : { (list: T[]): T[]; (list: Dictionary): T[]; } >[1, 2, 3, 4, 5, 6] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number ->6 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 +>6 : 6 // (function(){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); @@ -451,11 +451,11 @@ _.size({ one: 1, two: 2, three: 3 }); >size : { (list: T[]): number; (list: Dictionary): number; } >{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number ->1 : number +>1 : 1 >two : number ->2 : number +>2 : 2 >three : number ->3 : number +>3 : 3 /////////////////////////////////////////////////////////////////////////////////////// @@ -465,11 +465,11 @@ _.first([5, 4, 3, 2, 1]); >_ : Underscore.Static >first : { (list: T[]): T; (list: T[], count: number): T[]; } >[5, 4, 3, 2, 1] : number[] ->5 : number ->4 : number ->3 : number ->2 : number ->1 : number +>5 : 5 +>4 : 4 +>3 : 3 +>2 : 2 +>1 : 1 _.initial([5, 4, 3, 2, 1]); >_.initial([5, 4, 3, 2, 1]) : number @@ -477,11 +477,11 @@ _.initial([5, 4, 3, 2, 1]); >_ : Underscore.Static >initial : { (list: T[]): T; (list: T[], count: number): T[]; } >[5, 4, 3, 2, 1] : number[] ->5 : number ->4 : number ->3 : number ->2 : number ->1 : number +>5 : 5 +>4 : 4 +>3 : 3 +>2 : 2 +>1 : 1 _.last([5, 4, 3, 2, 1]); >_.last([5, 4, 3, 2, 1]) : number @@ -489,11 +489,11 @@ _.last([5, 4, 3, 2, 1]); >_ : Underscore.Static >last : { (list: T[]): T; (list: T[], count: number): T[]; } >[5, 4, 3, 2, 1] : number[] ->5 : number ->4 : number ->3 : number ->2 : number ->1 : number +>5 : 5 +>4 : 4 +>3 : 3 +>2 : 2 +>1 : 1 _.rest([5, 4, 3, 2, 1]); >_.rest([5, 4, 3, 2, 1]) : number[] @@ -501,24 +501,24 @@ _.rest([5, 4, 3, 2, 1]); >_ : Underscore.Static >rest : (list: T[], index?: number) => T[] >[5, 4, 3, 2, 1] : number[] ->5 : number ->4 : number ->3 : number ->2 : number ->1 : number +>5 : 5 +>4 : 4 +>3 : 3 +>2 : 2 +>1 : 1 _.compact([0, 1, false, 2, '', 3]); >_.compact([0, 1, false, 2, '', 3]) : (string | number | boolean)[] >_.compact : (list: T[]) => T[] >_ : Underscore.Static >compact : (list: T[]) => T[] ->[0, 1, false, 2, '', 3] : (string | number | false)[] ->0 : number ->1 : number +>[0, 1, false, 2, '', 3] : (false | "" | 0 | 1 | 2 | 3)[] +>0 : 0 +>1 : 1 >false : false ->2 : number ->'' : string ->3 : number +>2 : 2 +>'' : "" +>3 : 3 _.flatten([1, 2, 3, 4]); >_.flatten([1, 2, 3, 4]) : {}[] @@ -526,10 +526,10 @@ _.flatten([1, 2, 3, 4]); >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >[1, 2, 3, 4] : number[] ->1 : number ->2 : number ->3 : number ->4 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 _.flatten([1, [2]]); >_.flatten([1, [2]]) : {}[] @@ -537,9 +537,9 @@ _.flatten([1, [2]]); >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >[1, [2]] : (number | number[])[] ->1 : number +>1 : 1 >[2] : number[] ->2 : number +>2 : 2 // typescript doesn't like the elements being different _.flatten([1, [2], [3, [[4]]]]); @@ -548,14 +548,14 @@ _.flatten([1, [2], [3, [[4]]]]); >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] ->1 : number +>1 : 1 >[2] : number[] ->2 : number +>2 : 2 >[3, [[4]]] : (number | number[][])[] ->3 : number +>3 : 3 >[[4]] : number[][] >[4] : number[] ->4 : number +>4 : 4 _.flatten([1, [2], [3, [[4]]]], true); >_.flatten([1, [2], [3, [[4]]]], true) : {}[] @@ -563,14 +563,14 @@ _.flatten([1, [2], [3, [[4]]]], true); >_ : Underscore.Static >flatten : { (list: T[][]): T[]; (array: any[], shallow?: boolean): T[]; } >[1, [2], [3, [[4]]]] : (number | (number | number[][])[])[] ->1 : number +>1 : 1 >[2] : number[] ->2 : number +>2 : 2 >[3, [[4]]] : (number | number[][])[] ->3 : number +>3 : 3 >[[4]] : number[][] >[4] : number[] ->4 : number +>4 : 4 >true : true _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); @@ -579,15 +579,15 @@ _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); >_ : Underscore.Static >without : (list: T[], ...values: T[]) => T[] >[1, 2, 1, 0, 3, 1, 4] : number[] ->1 : number ->2 : number ->1 : number ->0 : number ->3 : number ->1 : number ->4 : number ->0 : number ->1 : number +>1 : 1 +>2 : 2 +>1 : 1 +>0 : 0 +>3 : 3 +>1 : 1 +>4 : 4 +>0 : 0 +>1 : 1 _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); >_.union([1, 2, 3], [101, 2, 1, 10], [2, 1]) : number[] @@ -595,17 +595,17 @@ _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); >_ : Underscore.Static >union : (...arrays: T[][]) => T[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >[101, 2, 1, 10] : number[] ->101 : number ->2 : number ->1 : number ->10 : number +>101 : 101 +>2 : 2 +>1 : 1 +>10 : 10 >[2, 1] : number[] ->2 : number ->1 : number +>2 : 2 +>1 : 1 _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); >_.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]) : number[] @@ -613,17 +613,17 @@ _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); >_ : Underscore.Static >intersection : (...arrays: T[][]) => T[] >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 >[101, 2, 1, 10] : number[] ->101 : number ->2 : number ->1 : number ->10 : number +>101 : 101 +>2 : 2 +>1 : 1 +>10 : 10 >[2, 1] : number[] ->2 : number ->1 : number +>2 : 2 +>1 : 1 _.difference([1, 2, 3, 4, 5], [5, 2, 10]); >_.difference([1, 2, 3, 4, 5], [5, 2, 10]) : number[] @@ -631,15 +631,15 @@ _.difference([1, 2, 3, 4, 5], [5, 2, 10]); >_ : Underscore.Static >difference : (list: T[], ...others: T[][]) => T[] >[1, 2, 3, 4, 5] : number[] ->1 : number ->2 : number ->3 : number ->4 : number ->5 : number +>1 : 1 +>2 : 2 +>3 : 3 +>4 : 4 +>5 : 5 >[5, 2, 10] : number[] ->5 : number ->2 : number ->10 : number +>5 : 5 +>2 : 2 +>10 : 10 _.uniq([1, 2, 1, 3, 1, 4]); >_.uniq([1, 2, 1, 3, 1, 4]) : number[] @@ -647,12 +647,12 @@ _.uniq([1, 2, 1, 3, 1, 4]); >_ : Underscore.Static >uniq : { (list: T[], isSorted?: boolean): T[]; (list: T[], isSorted: boolean, iterator: Iterator, context?: any): U[]; } >[1, 2, 1, 3, 1, 4] : number[] ->1 : number ->2 : number ->1 : number ->3 : number ->1 : number ->4 : number +>1 : 1 +>2 : 2 +>1 : 1 +>3 : 3 +>1 : 1 +>4 : 4 _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); >_.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]) : Tuple3[] @@ -660,13 +660,13 @@ _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); >_ : Underscore.Static >zip : { (a0: T0[], a1: T1[]): Tuple2[]; (a0: T0[], a1: T1[], a2: T2[]): Tuple3[]; (a0: T0[], a1: T1[], a2: T2[], a3: T3[]): Tuple4[]; (...arrays: any[][]): any[][]; } >['moe', 'larry', 'curly'] : string[] ->'moe' : string ->'larry' : string ->'curly' : string +>'moe' : "moe" +>'larry' : "larry" +>'curly' : "curly" >[30, 40, 50] : number[] ->30 : number ->40 : number ->50 : number +>30 : 30 +>40 : 40 +>50 : 50 >[true, false, false] : boolean[] >true : true >false : false @@ -678,13 +678,13 @@ _.object(['moe', 'larry', 'curly'], [30, 40, 50]); >_ : Underscore.Static >object : { (list: any[][]): any; (keys: string[], values: any[]): any; } >['moe', 'larry', 'curly'] : string[] ->'moe' : string ->'larry' : string ->'curly' : string +>'moe' : "moe" +>'larry' : "larry" +>'curly' : "curly" >[30, 40, 50] : number[] ->30 : number ->40 : number ->50 : number +>30 : 30 +>40 : 40 +>50 : 50 _.object([['moe', 30], ['larry', 40], ['curly', 50]]); >_.object([['moe', 30], ['larry', 40], ['curly', 50]]) : any @@ -693,14 +693,14 @@ _.object([['moe', 30], ['larry', 40], ['curly', 50]]); >object : { (list: any[][]): any; (keys: string[], values: any[]): any; } >[['moe', 30], ['larry', 40], ['curly', 50]] : (string | number)[][] >['moe', 30] : (string | number)[] ->'moe' : string ->30 : number +>'moe' : "moe" +>30 : 30 >['larry', 40] : (string | number)[] ->'larry' : string ->40 : number +>'larry' : "larry" +>40 : 40 >['curly', 50] : (string | number)[] ->'curly' : string ->50 : number +>'curly' : "curly" +>50 : 50 _.indexOf([1, 2, 3], 2); >_.indexOf([1, 2, 3], 2) : number @@ -708,10 +708,10 @@ _.indexOf([1, 2, 3], 2); >_ : Underscore.Static >indexOf : (list: T[], value: T, isSorted?: boolean) => number >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number ->2 : number +>1 : 1 +>2 : 2 +>3 : 3 +>2 : 2 _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); >_.lastIndexOf([1, 2, 3, 1, 2, 3], 2) : number @@ -719,13 +719,13 @@ _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); >_ : Underscore.Static >lastIndexOf : (list: T[], value: T, fromIndex?: number) => number >[1, 2, 3, 1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number ->1 : number ->2 : number ->3 : number ->2 : number +>1 : 1 +>2 : 2 +>3 : 3 +>1 : 1 +>2 : 2 +>3 : 3 +>2 : 2 _.sortedIndex([10, 20, 30, 40, 50], 35); >_.sortedIndex([10, 20, 30, 40, 50], 35) : number @@ -733,52 +733,52 @@ _.sortedIndex([10, 20, 30, 40, 50], 35); >_ : Underscore.Static >sortedIndex : { (list: T[], obj: T, propertyName: string): number; (list: T[], obj: T, iterator?: Iterator, context?: any): number; } >[10, 20, 30, 40, 50] : number[] ->10 : number ->20 : number ->30 : number ->40 : number ->50 : number ->35 : number +>10 : 10 +>20 : 20 +>30 : 30 +>40 : 40 +>50 : 50 +>35 : 35 _.range(10); >_.range(10) : number[] >_.range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } >_ : Underscore.Static >range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } ->10 : number +>10 : 10 _.range(1, 11); >_.range(1, 11) : number[] >_.range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } >_ : Underscore.Static >range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } ->1 : number ->11 : number +>1 : 1 +>11 : 11 _.range(0, 30, 5); >_.range(0, 30, 5) : number[] >_.range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } >_ : Underscore.Static >range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } ->0 : number ->30 : number ->5 : number +>0 : 0 +>30 : 30 +>5 : 5 _.range(0, 30, 5); >_.range(0, 30, 5) : number[] >_.range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } >_ : Underscore.Static >range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } ->0 : number ->30 : number ->5 : number +>0 : 0 +>30 : 30 +>5 : 5 _.range(0); >_.range(0) : number[] >_.range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } >_ : Underscore.Static >range : { (stop: number): number[]; (start: number, stop: number, step?: number): number[]; } ->0 : number +>0 : 0 /////////////////////////////////////////////////////////////////////////////////////// @@ -789,7 +789,7 @@ var func = function (greeting) { return greeting + ': ' + this.name }; >greeting + ': ' + this.name : string >greeting + ': ' : string >greeting : any ->': ' : string +>': ' : ": " >this.name : any >this : any >name : any @@ -805,8 +805,8 @@ var func2 = _.bind(func, { name: 'moe' }, 'hi'); >func : (greeting: any) => string >{ name: 'moe' } : { name: string; } >name : string ->'moe' : string ->'hi' : string +>'moe' : "moe" +>'hi' : "hi" func2(); >func2() : any @@ -818,7 +818,7 @@ var buttonView = { label: 'underscore', >label : string ->'underscore' : string +>'underscore' : "underscore" onClick: function () { alert('clicked: ' + this.label); }, >onClick : () => void @@ -826,7 +826,7 @@ var buttonView = { >alert('clicked: ' + this.label) : void >alert : (x: string) => void >'clicked: ' + this.label : string ->'clicked: ' : string +>'clicked: ' : "clicked: " >this.label : any >this : any >label : any @@ -837,7 +837,7 @@ var buttonView = { >alert('hovering: ' + this.label) : void >alert : (x: string) => void >'hovering: ' + this.label : string ->'hovering: ' : string +>'hovering: ' : "hovering: " >this.label : any >this : any >label : any @@ -855,9 +855,9 @@ $('#underscore_button').bind('click', buttonView.onClick); >$('#underscore_button').bind : any >$('#underscore_button') : any >$ : any ->'#underscore_button' : string +>'#underscore_button' : "#underscore_button" >bind : any ->'click' : string +>'click' : "click" >buttonView.onClick : () => void >buttonView : { label: string; onClick: () => void; onHover: () => void; } >onClick : () => void @@ -875,19 +875,19 @@ var fibonacci = _.memoize(function (n) { >n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2) : any >n < 2 : boolean >n : any ->2 : number +>2 : 2 >n : any >fibonacci(n - 1) + fibonacci(n - 2) : any >fibonacci(n - 1) : any >fibonacci : (n: any) => any >n - 1 : number >n : any ->1 : number +>1 : 1 >fibonacci(n - 2) : any >fibonacci : (n: any) => any >n - 2 : number >n : any ->2 : number +>2 : 2 }); @@ -908,8 +908,8 @@ _.delay(log, 1000, 'logged later'); >_ : Underscore.Static >delay : (func: Function, wait: number, ...args: any[]) => number >log : (message?: string, ...rest: string[]) => void ->1000 : number ->'logged later' : string +>1000 : 1000 +>'logged later' : "logged later" _.defer(function () { alert('deferred'); }); >_.defer(function () { alert('deferred'); }) : number @@ -919,14 +919,14 @@ _.defer(function () { alert('deferred'); }); >function () { alert('deferred'); } : () => void >alert('deferred') : void >alert : (x: string) => void ->'deferred' : string +>'deferred' : "deferred" var updatePosition = () => alert('updating position...'); >updatePosition : () => void >() => alert('updating position...') : () => void >alert('updating position...') : void >alert : (x: string) => void ->'updating position...' : string +>'updating position...' : "updating position..." var throttled = _.throttle(updatePosition, 100); >throttled : () => void @@ -935,7 +935,7 @@ var throttled = _.throttle(updatePosition, 100); >_ : Underscore.Static >throttle : (func: T, wait: number) => T >updatePosition : () => void ->100 : number +>100 : 100 $(null).scroll(throttled); >$(null).scroll(throttled) : any @@ -951,7 +951,7 @@ var calculateLayout = () => alert('calculating layout...'); >() => alert('calculating layout...') : () => void >alert('calculating layout...') : void >alert : (x: string) => void ->'calculating layout...' : string +>'calculating layout...' : "calculating layout..." var lazyLayout = _.debounce(calculateLayout, 300); >lazyLayout : () => void @@ -960,7 +960,7 @@ var lazyLayout = _.debounce(calculateLayout, 300); >_ : Underscore.Static >debounce : (func: T, wait: number, immediate?: boolean) => T >calculateLayout : () => void ->300 : number +>300 : 300 $(null).resize(lazyLayout); >$(null).resize(lazyLayout) : any @@ -976,7 +976,7 @@ var createApplication = () => alert('creating application...'); >() => alert('creating application...') : () => void >alert('creating application...') : void >alert : (x: string) => void ->'creating application...' : string +>'creating application...' : "creating application..." var initialize = _.once(createApplication); >initialize : () => void @@ -1002,7 +1002,7 @@ var render = () => alert("rendering..."); >() => alert("rendering...") : () => void >alert("rendering...") : void >alert : (x: string) => void ->"rendering..." : string +>"rendering..." : "rendering..." var renderNotes = _.after(notes.length, render); >renderNotes : () => void @@ -1036,7 +1036,7 @@ var hello = function (name) { return "hello: " + name; }; >function (name) { return "hello: " + name; } : (name: any) => string >name : any >"hello: " + name : string ->"hello: " : string +>"hello: " : "hello: " >name : any hello = _.wrap(hello, (func, arg) => { return "before, " + func(arg) + ", after"; }); @@ -1052,23 +1052,23 @@ hello = _.wrap(hello, (func, arg) => { return "before, " + func(arg) + ", after" >arg : any >"before, " + func(arg) + ", after" : string >"before, " + func(arg) : string ->"before, " : string +>"before, " : "before, " >func(arg) : string >func : (name: any) => string >arg : any ->", after" : string +>", after" : ", after" hello("moe"); >hello("moe") : string >hello : (name: any) => string ->"moe" : string +>"moe" : "moe" var greet = function (name) { return "hi: " + name; }; >greet : (name: any) => string >function (name) { return "hi: " + name; } : (name: any) => string >name : any >"hi: " + name : string ->"hi: " : string +>"hi: " : "hi: " >name : any var exclaim = function (statement) { return statement + "!"; }; @@ -1077,7 +1077,7 @@ var exclaim = function (statement) { return statement + "!"; }; >statement : any >statement + "!" : string >statement : any ->"!" : string +>"!" : "!" var welcome = _.compose(exclaim, greet); >welcome : Function @@ -1091,7 +1091,7 @@ var welcome = _.compose(exclaim, greet); welcome('moe'); >welcome('moe') : any >welcome : Function ->'moe' : string +>'moe' : "moe" /////////////////////////////////////////////////////////////////////////////////////// @@ -1102,11 +1102,11 @@ _.keys({ one: 1, two: 2, three: 3 }); >keys : (object: any) => string[] >{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number ->1 : number +>1 : 1 >two : number ->2 : number +>2 : 2 >three : number ->3 : number +>3 : 3 _.values({ one: 1, two: 2, three: 3 }); >_.values({ one: 1, two: 2, three: 3 }) : any[] @@ -1115,11 +1115,11 @@ _.values({ one: 1, two: 2, three: 3 }); >values : (object: any) => any[] >{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number ->1 : number +>1 : 1 >two : number ->2 : number +>2 : 2 >three : number ->3 : number +>3 : 3 _.pairs({ one: 1, two: 2, three: 3 }); >_.pairs({ one: 1, two: 2, three: 3 }) : any[][] @@ -1128,11 +1128,11 @@ _.pairs({ one: 1, two: 2, three: 3 }); >pairs : (object: any) => any[][] >{ one: 1, two: 2, three: 3 } : { one: number; two: number; three: number; } >one : number ->1 : number +>1 : 1 >two : number ->2 : number +>2 : 2 >three : number ->3 : number +>3 : 3 _.invert({ Moe: "Moses", Larry: "Louis", Curly: "Jerome" }); >_.invert({ Moe: "Moses", Larry: "Louis", Curly: "Jerome" }) : any @@ -1141,11 +1141,11 @@ _.invert({ Moe: "Moses", Larry: "Louis", Curly: "Jerome" }); >invert : (object: any) => any >{ Moe: "Moses", Larry: "Louis", Curly: "Jerome" } : { Moe: string; Larry: string; Curly: string; } >Moe : string ->"Moses" : string +>"Moses" : "Moses" >Larry : string ->"Louis" : string +>"Louis" : "Louis" >Curly : string ->"Jerome" : string +>"Jerome" : "Jerome" _.functions(_); >_.functions(_) : string[] @@ -1161,10 +1161,10 @@ _.extend({ name: 'moe' }, { age: 50 }); >extend : (destination: T, ...sources: any[]) => T >{ name: 'moe' } : { name: string; } >name : string ->'moe' : string +>'moe' : "moe" >{ age: 50 } : { age: number; } >age : number ->50 : number +>50 : 50 _.pick({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age'); >_.pick({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age') : { name: string; age: number; userid: string; } @@ -1173,13 +1173,13 @@ _.pick({ name: 'moe', age: 50, userid: 'moe1' }, 'name', 'age'); >pick : (object: T, ...keys: string[]) => T >{ name: 'moe', age: 50, userid: 'moe1' } : { name: string; age: number; userid: string; } >name : string ->'moe' : string +>'moe' : "moe" >age : number ->50 : number +>50 : 50 >userid : string ->'moe1' : string ->'name' : string ->'age' : string +>'moe1' : "moe1" +>'name' : "name" +>'age' : "age" _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'userid'); >_.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'userid') : { name: string; age: number; userid: string; } @@ -1188,18 +1188,18 @@ _.omit({ name: 'moe', age: 50, userid: 'moe1' }, 'userid'); >omit : (object: T, ...keys: string[]) => T >{ name: 'moe', age: 50, userid: 'moe1' } : { name: string; age: number; userid: string; } >name : string ->'moe' : string +>'moe' : "moe" >age : number ->50 : number +>50 : 50 >userid : string ->'moe1' : string ->'userid' : string +>'moe1' : "moe1" +>'userid' : "userid" var iceCream = { flavor: "chocolate" }; >iceCream : { flavor: string; } >{ flavor: "chocolate" } : { flavor: string; } >flavor : string ->"chocolate" : string +>"chocolate" : "chocolate" _.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" }); >_.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" }) : { flavor: string; } @@ -1209,9 +1209,9 @@ _.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" }); >iceCream : { flavor: string; } >{ flavor: "vanilla", sprinkles: "lots" } : { flavor: string; sprinkles: string; } >flavor : string ->"vanilla" : string +>"vanilla" : "vanilla" >sprinkles : string ->"lots" : string +>"lots" : "lots" _.clone({ name: 'moe' }); >_.clone({ name: 'moe' }) : { name: string; } @@ -1220,7 +1220,7 @@ _.clone({ name: 'moe' }); >clone : (object: T) => T >{ name: 'moe' } : { name: string; } >name : string ->'moe' : string +>'moe' : "moe" _.chain([1, 2, 3, 200]) >_.chain([1, 2, 3, 200]) .filter(function (num) { return num % 2 == 0; }) .tap(alert) .map(function (num) { return num * num }) .value() : number[] @@ -1236,10 +1236,10 @@ _.chain([1, 2, 3, 200]) >_ : Underscore.Static >chain : { (list: T[]): Underscore.ChainedArray; (list: Dictionary): Underscore.ChainedDictionary; (obj: T): Underscore.ChainedObject; } >[1, 2, 3, 200] : number[] ->1 : number ->2 : number ->3 : number ->200 : number +>1 : 1 +>2 : 2 +>3 : 3 +>200 : 200 .filter(function (num) { return num % 2 == 0; }) >filter : (iterator: Iterator, context?: any) => Underscore.ChainedArray @@ -1248,7 +1248,7 @@ _.chain([1, 2, 3, 200]) >num % 2 == 0 : boolean >num % 2 : number >num : number ->2 : number +>2 : 2 >0 : 0 .tap(alert) @@ -1274,34 +1274,34 @@ _.has({ a: 1, b: 2, c: 3 }, "b"); >has : (object: any, key: string) => boolean >{ a: 1, b: 2, c: 3 } : { a: number; b: number; c: number; } >a : number ->1 : number +>1 : 1 >b : number ->2 : number +>2 : 2 >c : number ->3 : number ->"b" : string +>3 : 3 +>"b" : "b" var moe = { name: 'moe', luckyNumbers: [13, 27, 34] }; >moe : { name: string; luckyNumbers: number[]; } >{ name: 'moe', luckyNumbers: [13, 27, 34] } : { name: string; luckyNumbers: number[]; } >name : string ->'moe' : string +>'moe' : "moe" >luckyNumbers : number[] >[13, 27, 34] : number[] ->13 : number ->27 : number ->34 : number +>13 : 13 +>27 : 27 +>34 : 34 var clone = { name: 'moe', luckyNumbers: [13, 27, 34] }; >clone : { name: string; luckyNumbers: number[]; } >{ name: 'moe', luckyNumbers: [13, 27, 34] } : { name: string; luckyNumbers: number[]; } >name : string ->'moe' : string +>'moe' : "moe" >luckyNumbers : number[] >[13, 27, 34] : number[] ->13 : number ->27 : number ->34 : number +>13 : 13 +>27 : 27 +>34 : 34 moe == clone; >moe == clone : boolean @@ -1322,9 +1322,9 @@ _.isEmpty([1, 2, 3]); >_ : Underscore.Static >isEmpty : (object: any) => boolean >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 _.isEmpty({}); >_.isEmpty({}) : boolean @@ -1341,8 +1341,8 @@ _.isElement($('body')[0]); >$('body')[0] : any >$('body') : any >$ : any ->'body' : string ->0 : number +>'body' : "body" +>0 : 0 (function () { return _.isArray(arguments); })(); >(function () { return _.isArray(arguments); })() : boolean @@ -1360,9 +1360,9 @@ _.isArray([1, 2, 3]); >_ : Underscore.Static >isArray : (object: any) => boolean >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 _.isObject({}); >_.isObject({}) : boolean @@ -1376,7 +1376,7 @@ _.isObject(1); >_.isObject : (value: any) => boolean >_ : Underscore.Static >isObject : (value: any) => boolean ->1 : number +>1 : 1 // (() => { return _.isArguments(arguments); })(1, 2, 3); @@ -1386,9 +1386,9 @@ _.isArguments([1, 2, 3]); >_ : Underscore.Static >isArguments : (object: any) => boolean >[1, 2, 3] : number[] ->1 : number ->2 : number ->3 : number +>1 : 1 +>2 : 2 +>3 : 3 _.isFunction(alert); >_.isFunction(alert) : boolean @@ -1402,7 +1402,7 @@ _.isString("moe"); >_.isString : (object: any) => boolean >_ : Underscore.Static >isString : (object: any) => boolean ->"moe" : string +>"moe" : "moe" _.isNumber(8.4 * 5); >_.isNumber(8.4 * 5) : boolean @@ -1410,16 +1410,16 @@ _.isNumber(8.4 * 5); >_ : Underscore.Static >isNumber : (object: any) => boolean >8.4 * 5 : number ->8.4 : number ->5 : number +>8.4 : 8.4 +>5 : 5 _.isFinite(-101); >_.isFinite(-101) : boolean >_.isFinite : (object: any) => boolean >_ : Underscore.Static >isFinite : (object: any) => boolean ->-101 : number ->101 : number +>-101 : -101 +>101 : 101 _.isFinite(-Infinity); >_.isFinite(-Infinity) : boolean @@ -1508,7 +1508,7 @@ var moe2 = { name: 'moe' }; >moe2 : { name: string; } >{ name: 'moe' } : { name: string; } >name : string ->'moe' : string +>'moe' : "moe" moe2 === _.identity(moe); >moe2 === _.identity(moe) : boolean @@ -1527,7 +1527,7 @@ _.times(3, function (n) { genie.grantWishNumber(n); }); >_.times : (n: number, iterator: Iterator, context?: any) => U[] >_ : Underscore.Static >times : (n: number, iterator: Iterator, context?: any) => U[] ->3 : number +>3 : 3 >function (n) { genie.grantWishNumber(n); } : (n: number) => void >n : number >genie.grantWishNumber(n) : any @@ -1541,8 +1541,8 @@ _.random(0, 100); >_.random : { (max: number): number; (min: number, max: number): number; } >_ : Underscore.Static >random : { (max: number): number; (min: number, max: number): number; } ->0 : number ->100 : number +>0 : 0 +>100 : 100 _.mixin({ >_.mixin({ capitalize: function (string) { return string.charAt(0).toUpperCase() + string.substring(1).toLowerCase(); }}) : void @@ -1564,7 +1564,7 @@ _.mixin({ >string.charAt : any >string : any >charAt : any ->0 : number +>0 : 0 >toUpperCase : any >string.substring(1).toLowerCase() : any >string.substring(1).toLowerCase : any @@ -1572,7 +1572,7 @@ _.mixin({ >string.substring : any >string : any >substring : any ->1 : number +>1 : 1 >toLowerCase : any } }); @@ -1583,7 +1583,7 @@ _.mixin({ >_("fabio") : any >_("fabio") : Underscore.WrappedObject >_ : Underscore.Static ->"fabio" : string +>"fabio" : "fabio" >capitalize : any _.uniqueId('contact_'); @@ -1591,23 +1591,23 @@ _.uniqueId('contact_'); >_.uniqueId : { (): number; (prefix: string): string; } >_ : Underscore.Static >uniqueId : { (): number; (prefix: string): string; } ->'contact_' : string +>'contact_' : "contact_" _.escape('Curly, Larry & Moe'); >_.escape('Curly, Larry & Moe') : string >_.escape : (s: string) => string >_ : Underscore.Static >escape : (s: string) => string ->'Curly, Larry & Moe' : string +>'Curly, Larry & Moe' : "Curly, Larry & Moe" var object = { cheese: 'crumpets', stuff: function () { return 'nonsense'; } }; >object : { cheese: string; stuff: () => string; } >{ cheese: 'crumpets', stuff: function () { return 'nonsense'; } } : { cheese: string; stuff: () => string; } >cheese : string ->'crumpets' : string +>'crumpets' : "crumpets" >stuff : () => string >function () { return 'nonsense'; } : () => string ->'nonsense' : string +>'nonsense' : "nonsense" _.result(object, 'cheese'); >_.result(object, 'cheese') : any @@ -1615,7 +1615,7 @@ _.result(object, 'cheese'); >_ : Underscore.Static >result : (object: any, property: string) => any >object : { cheese: string; stuff: () => string; } ->'cheese' : string +>'cheese' : "cheese" _.result(object, 'stuff'); >_.result(object, 'stuff') : any @@ -1623,7 +1623,7 @@ _.result(object, 'stuff'); >_ : Underscore.Static >result : (object: any, property: string) => any >object : { cheese: string; stuff: () => string; } ->'stuff' : string +>'stuff' : "stuff" var compiled = _.template("hello: <%= name %>"); >compiled : (data: any) => string @@ -1631,18 +1631,18 @@ var compiled = _.template("hello: <%= name %>"); >_.template : { (templateString: string): (data: any) => string; (templateString: string, data: any, settings?: Underscore.TemplateSettings): string; } >_ : Underscore.Static >template : { (templateString: string): (data: any) => string; (templateString: string, data: any, settings?: Underscore.TemplateSettings): string; } ->"hello: <%= name %>" : string +>"hello: <%= name %>" : "hello: <%= name %>" compiled({ name: 'moe' }); >compiled({ name: 'moe' }) : string >compiled : (data: any) => string >{ name: 'moe' } : { name: string; } >name : string ->'moe' : string +>'moe' : "moe" var list2 = "<% _.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>"; >list2 : string ->"<% _.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>" : string +>"<% _.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>" : "<% _.each(people, function(name) { %>
  • <%= name %>
  • <% }); %>" _.template(list2, { people: ['moe', 'curly', 'larry'] }); >_.template(list2, { people: ['moe', 'curly', 'larry'] }) : string @@ -1653,9 +1653,9 @@ _.template(list2, { people: ['moe', 'curly', 'larry'] }); >{ people: ['moe', 'curly', 'larry'] } : { people: string[]; } >people : string[] >['moe', 'curly', 'larry'] : string[] ->'moe' : string ->'curly' : string ->'larry' : string +>'moe' : "moe" +>'curly' : "curly" +>'larry' : "larry" var template = _.template("<%- value %>"); >template : (data: any) => string @@ -1663,14 +1663,14 @@ var template = _.template("<%- value %>"); >_.template : { (templateString: string): (data: any) => string; (templateString: string, data: any, settings?: Underscore.TemplateSettings): string; } >_ : Underscore.Static >template : { (templateString: string): (data: any) => string; (templateString: string, data: any, settings?: Underscore.TemplateSettings): string; } ->"<%- value %>" : string +>"<%- value %>" : "<%- value %>" template({ value: '