From 7a44b9ed574de1f9560462c6c03088b425c576c5 Mon Sep 17 00:00:00 2001 From: Jason Freeman Date: Wed, 25 Mar 2015 19:23:44 -0700 Subject: [PATCH] Make elaborateErrors persist throughout type relation checks --- src/compiler/checker.ts | 10 ++++---- ...ConstrainedToOtherTypeParameter.errors.txt | 4 +++- ...fGenericFunctionTypedArguments1.errors.txt | 2 ++ ...lWithGenericSignatureArguments2.errors.txt | 2 ++ .../reference/genericCombinators2.errors.txt | 2 ++ .../reference/incompatibleTypes.errors.txt | 2 ++ .../interfaceAssignmentCompat.errors.txt | 2 ++ ...nWithConstraintCheckingDeferred.errors.txt | 2 ++ .../overloadsWithProvisionalErrors.errors.txt | 4 ++++ .../reference/promiseChaining1.errors.txt | 2 ++ .../reference/promiseChaining2.errors.txt | 2 ++ .../reference/promisePermutations.errors.txt | 22 +++++++++++++++++ .../reference/promisePermutations2.errors.txt | 22 +++++++++++++++++ .../reference/promisePermutations3.errors.txt | 24 +++++++++++++++++++ ...gWithContextSensitiveArguments2.errors.txt | 4 +++- ...gWithContextSensitiveArguments3.errors.txt | 4 +++- 16 files changed, 103 insertions(+), 7 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6fdaac79cea00..3c0bf39f1fa81 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3872,6 +3872,7 @@ module ts { let expandingFlags: number; let depth = 0; let overflow = false; + let elaborateErrors = false; Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking"); @@ -3886,7 +3887,8 @@ module ts { // where errors were being reported. if (errorInfo.next === undefined) { errorInfo = undefined; - isRelatedTo(source, target, errorNode !== undefined, headMessage, /* elaborateErrors */ true); + elaborateErrors = true; + isRelatedTo(source, target, errorNode !== undefined, headMessage); } if (containingMessageChain) { errorInfo = concatenateDiagnosticMessageChains(containingMessageChain, errorInfo); @@ -3904,7 +3906,7 @@ module ts { // Ternary.True if they are related with no assumptions, // Ternary.Maybe if they are related with assumptions of other relationships, or // Ternary.False if they are not related. - function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage, elaborateErrors = false): Ternary { + function isRelatedTo(source: Type, target: Type, reportErrors?: boolean, headMessage?: DiagnosticMessage): Ternary { let result: Ternary; // both types are the same - covers 'they are the same primitive type or both are Any' or the same type parameter cases if (source === target) return Ternary.True; @@ -3971,7 +3973,7 @@ module ts { // identity relation does not use apparent type let sourceOrApparentType = relation === identityRelation ? source : getApparentType(source); if (sourceOrApparentType.flags & TypeFlags.ObjectType && target.flags & TypeFlags.ObjectType && - (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors, elaborateErrors))) { + (result = objectTypeRelatedTo(sourceOrApparentType, target, reportStructuralErrors))) { errorInfo = saveErrorInfo; return result; } @@ -4068,7 +4070,7 @@ module ts { // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean, elaborateErrors = false): Ternary { + function objectTypeRelatedTo(source: ObjectType, target: ObjectType, reportErrors: boolean): Ternary { if (overflow) { return Ternary.False; } diff --git a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt index f9edcf4eef69e..181bfcc907d54 100644 --- a/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt +++ b/tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,59): error TS2345: Argument of type '(c: C) => B' is not assignable to parameter of type '(x: C) => C'. Type 'B' is not assignable to type 'C'. + Property 'z' is missing in type 'B'. ==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (1 errors) ==== @@ -24,4 +25,5 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete (new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A); ~~~~~~~~~~ !!! error TS2345: Argument of type '(c: C) => B' is not assignable to parameter of type '(x: C) => C'. -!!! error TS2345: Type 'B' is not assignable to type 'C'. \ No newline at end of file +!!! error TS2345: Type 'B' is not assignable to type 'C'. +!!! error TS2345: Property 'z' is missing in type 'B'. \ No newline at end of file diff --git a/tests/baselines/reference/contextualTypingOfGenericFunctionTypedArguments1.errors.txt b/tests/baselines/reference/contextualTypingOfGenericFunctionTypedArguments1.errors.txt index c7b15e8efefec..a11f000901634 100644 --- a/tests/baselines/reference/contextualTypingOfGenericFunctionTypedArguments1.errors.txt +++ b/tests/baselines/reference/contextualTypingOfGenericFunctionTypedArguments1.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(16,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'. Type 'string' is not assignable to type 'Date'. + Property 'toDateString' is missing in type 'String'. tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32): error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'. Type 'string' is not assignable to type 'Date'. @@ -24,6 +25,7 @@ tests/cases/compiler/contextualTypingOfGenericFunctionTypedArguments1.ts(17,32): ~ !!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'. !!! error TS2345: Type 'string' is not assignable to type 'Date'. +!!! error TS2345: Property 'toDateString' is missing in type 'String'. var r6 = _.forEach(c2, (x) => { return x.toFixed() }); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: number) => string' is not assignable to parameter of type '(x: number) => Date'. diff --git a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt index 5b5d4ad66f036..f9f230b577636 100644 --- a/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt +++ b/tests/baselines/reference/genericCallWithGenericSignatureArguments2.errors.txt @@ -5,6 +5,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen 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 'T' is not assignable to type 'Date'. + Property 'toDateString' is missing in type 'RegExp'. 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'. @@ -53,6 +54,7 @@ tests/cases/conformance/types/typeRelationships/typeInference/genericCallWithGen !!! error TS2345: Argument of type '(a: T) => T' is not assignable to parameter of type '(x: Date) => Date'. !!! error TS2345: Types of parameters 'a' and 'x' are incompatible. !!! error TS2345: Type 'T' is not assignable to type 'Date'. +!!! error TS2345: Property 'toDateString' is missing in type 'RegExp'. var r7b = foo2((a) => a, (b) => b); // valid, T is inferred to be Date } diff --git a/tests/baselines/reference/genericCombinators2.errors.txt b/tests/baselines/reference/genericCombinators2.errors.txt index 5be717109c851..d590f1030c316 100644 --- a/tests/baselines/reference/genericCombinators2.errors.txt +++ b/tests/baselines/reference/genericCombinators2.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/genericCombinators2.ts(15,43): error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'. Type 'string' is not assignable to type 'Date'. + Property 'toDateString' is missing in type 'String'. tests/cases/compiler/genericCombinators2.ts(16,43): error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'. Type 'string' is not assignable to type 'Date'. @@ -23,6 +24,7 @@ tests/cases/compiler/genericCombinators2.ts(16,43): error TS2345: Argument of ty ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'. !!! error TS2345: Type 'string' is not assignable to type 'Date'. +!!! error TS2345: Property 'toDateString' is missing in type 'String'. var r5b = _.map(c2, rf1); ~~~ !!! error TS2345: Argument of type '(x: number, y: string) => string' is not assignable to parameter of type '(x: number, y: string) => Date'. diff --git a/tests/baselines/reference/incompatibleTypes.errors.txt b/tests/baselines/reference/incompatibleTypes.errors.txt index 01e4531031a12..504ff0088fa6c 100644 --- a/tests/baselines/reference/incompatibleTypes.errors.txt +++ b/tests/baselines/reference/incompatibleTypes.errors.txt @@ -17,6 +17,7 @@ tests/cases/compiler/incompatibleTypes.ts(33,7): error TS2420: Class 'C4' incorr tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2345: Argument of type 'C1' is not assignable to parameter of type 'IFoo2'. Types of property 'p1' are incompatible. Type '() => string' is not assignable to type '(s: string) => number'. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/incompatibleTypes.ts(49,5): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'. Property 'c' is missing in type '{ e: number; f: number; }'. tests/cases/compiler/incompatibleTypes.ts(66,5): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'. @@ -92,6 +93,7 @@ tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => !!! error TS2345: Argument of type 'C1' is not assignable to parameter of type 'IFoo2'. !!! error TS2345: Types of property 'p1' are incompatible. !!! error TS2345: Type '() => string' is not assignable to type '(s: string) => number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. function of1(n: { a: { a: string; }; b: string; }): number; diff --git a/tests/baselines/reference/interfaceAssignmentCompat.errors.txt b/tests/baselines/reference/interfaceAssignmentCompat.errors.txt index 425aa3b3e9774..237358b42de00 100644 --- a/tests/baselines/reference/interfaceAssignmentCompat.errors.txt +++ b/tests/baselines/reference/interfaceAssignmentCompat.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/interfaceAssignmentCompat.ts(32,18): error TS2345: Argument of type '(a: IFrenchEye, b: IFrenchEye) => number' is not assignable to parameter of type '(a: IEye, b: IEye) => number'. Types of parameters 'a' and 'a' are incompatible. Type 'IFrenchEye' is not assignable to type 'IEye'. + Property 'color' is missing in type 'IFrenchEye'. tests/cases/compiler/interfaceAssignmentCompat.ts(37,29): error TS2339: Property '_map' does not exist on type 'typeof Color'. tests/cases/compiler/interfaceAssignmentCompat.ts(42,13): error TS2322: Type 'IEye' is not assignable to type 'IFrenchEye'. Property 'coleur' is missing in type 'IEye'. @@ -45,6 +46,7 @@ tests/cases/compiler/interfaceAssignmentCompat.ts(44,9): error TS2322: Type 'IEy !!! error TS2345: Argument of type '(a: IFrenchEye, b: IFrenchEye) => number' is not assignable to parameter of type '(a: IEye, b: IEye) => number'. !!! error TS2345: Types of parameters 'a' and 'a' are incompatible. !!! error TS2345: Type 'IFrenchEye' is not assignable to type 'IEye'. +!!! error TS2345: Property 'color' is missing in type 'IFrenchEye'. // type of z inferred from specialized array type var z=x.sort(CompareEyes); // ok diff --git a/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt b/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt index ed504fd410d1f..35837d3233f7a 100644 --- a/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt +++ b/tests/baselines/reference/overloadresolutionWithConstraintCheckingDeferred.errors.txt @@ -6,6 +6,7 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(16,38): tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(18,27): error TS2345: Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. Types of parameters 'x' and 'x' are incompatible. Type 'D' is not assignable to type 'B'. + Property 'x' is missing in type 'D'. tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): error TS2344: Type 'D' does not satisfy the constraint 'A'. @@ -49,4 +50,5 @@ tests/cases/compiler/overloadresolutionWithConstraintCheckingDeferred.ts(19,12): !!! error TS2345: Argument of type '(x: D) => G' is not assignable to parameter of type '(x: B) => any'. !!! error TS2345: Types of parameters 'x' and 'x' are incompatible. !!! error TS2345: Type 'D' is not assignable to type 'B'. +!!! error TS2345: Property 'x' is missing in type 'D'. \ No newline at end of file diff --git a/tests/baselines/reference/overloadsWithProvisionalErrors.errors.txt b/tests/baselines/reference/overloadsWithProvisionalErrors.errors.txt index 55fe8ed4fde86..daf057c9ebd4b 100644 --- a/tests/baselines/reference/overloadsWithProvisionalErrors.errors.txt +++ b/tests/baselines/reference/overloadsWithProvisionalErrors.errors.txt @@ -1,8 +1,10 @@ tests/cases/compiler/overloadsWithProvisionalErrors.ts(6,6): error TS2345: Argument of type '(s: string) => {}' is not assignable to parameter of type '(s: string) => { a: number; b: number; }'. Type '{}' is not assignable to type '{ a: number; b: number; }'. + Property 'a' is missing in type '{}'. tests/cases/compiler/overloadsWithProvisionalErrors.ts(7,17): error TS2304: Cannot find name 'blah'. tests/cases/compiler/overloadsWithProvisionalErrors.ts(8,6): error TS2345: Argument of type '(s: string) => { a: any; }' is not assignable to parameter of type '(s: string) => { a: number; b: number; }'. Type '{ a: any; }' is not assignable to type '{ a: number; b: number; }'. + Property 'b' is missing in type '{ a: any; }'. tests/cases/compiler/overloadsWithProvisionalErrors.ts(8,17): error TS2304: Cannot find name 'blah'. @@ -16,6 +18,7 @@ tests/cases/compiler/overloadsWithProvisionalErrors.ts(8,17): error TS2304: Cann ~~~~~~~~~ !!! error TS2345: Argument of type '(s: string) => {}' is not assignable to parameter of type '(s: string) => { a: number; b: number; }'. !!! error TS2345: Type '{}' is not assignable to type '{ a: number; b: number; }'. +!!! error TS2345: Property 'a' is missing in type '{}'. func(s => ({ a: blah, b: 3 })); // Only error inside the function, but not outside (since it would be applicable if not for the provisional error) ~~~~ !!! error TS2304: Cannot find name 'blah'. @@ -23,5 +26,6 @@ tests/cases/compiler/overloadsWithProvisionalErrors.ts(8,17): error TS2304: Cann ~~~~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(s: string) => { a: any; }' is not assignable to parameter of type '(s: string) => { a: number; b: number; }'. !!! error TS2345: Type '{ a: any; }' is not assignable to type '{ a: number; b: number; }'. +!!! error TS2345: Property 'b' is missing in type '{ a: any; }'. ~~~~ !!! error TS2304: Cannot find name 'blah'. \ No newline at end of file diff --git a/tests/baselines/reference/promiseChaining1.errors.txt b/tests/baselines/reference/promiseChaining1.errors.txt index 7396d03059aca..bd3e52fcc1c54 100644 --- a/tests/baselines/reference/promiseChaining1.errors.txt +++ b/tests/baselines/reference/promiseChaining1.errors.txt @@ -1,5 +1,6 @@ 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'. + Property 'apply' is missing in type 'String'. ==== tests/cases/compiler/promiseChaining1.ts (1 errors) ==== @@ -13,6 +14,7 @@ tests/cases/compiler/promiseChaining1.ts(7,50): error TS2345: Argument of type ' ~~~~~~~~~~ !!! 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: Property 'apply' is missing in type 'String'. 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 a31c4335da712..f12baebd4dca2 100644 --- a/tests/baselines/reference/promiseChaining2.errors.txt +++ b/tests/baselines/reference/promiseChaining2.errors.txt @@ -1,5 +1,6 @@ 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'. + Property 'apply' is missing in type 'String'. ==== tests/cases/compiler/promiseChaining2.ts (1 errors) ==== @@ -13,6 +14,7 @@ tests/cases/compiler/promiseChaining2.ts(7,45): error TS2345: Argument of type ' ~~~~~~~~~~ !!! 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: Property 'apply' is missing in type 'String'. return new Chain2(result); } } \ No newline at end of file diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index 744fd5da90e56..a74938f5dd9df 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/promisePermutations.ts(74,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'IPromise'. + Property 'then' is missing in type 'Number'. tests/cases/compiler/promisePermutations.ts(79,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'string'. @@ -54,6 +55,10 @@ tests/cases/compiler/promisePermutations.ts(152,12): error TS2453: The type argu Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. + Types of parameters 'success' and 'success' are incompatible. + Type '(value: string) => IPromise' is not assignable to type '(value: number) => Promise'. + Types of parameters 'value' and 'value' are incompatible. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations.ts(156,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. Type 'number' is not assignable to type 'string'. @@ -65,6 +70,12 @@ tests/cases/compiler/promisePermutations.ts(159,21): error TS2345: Argument of t Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'Promise' is not assignable to type 'IPromise'. + Types of property 'then' are incompatible. + Type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. + Types of parameters 'success' and 'success' are incompatible. + Type '(value: number) => Promise' is not assignable to type '(value: string) => IPromise'. + Types of parameters 'value' and 'value' are incompatible. + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/promisePermutations.ts (33 errors) ==== @@ -146,6 +157,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t !!! error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. !!! error TS2345: Types of parameters 'x' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'IPromise'. +!!! error TS2345: Property 'then' is missing in type 'Number'. var r4: IPromise; var sIPromise: (x: any) => IPromise; @@ -305,6 +317,10 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t !!! error TS2453: Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. !!! error TS2453: Types of property 'then' are incompatible. !!! error TS2453: Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. +!!! error TS2453: Types of parameters 'success' and 'success' are incompatible. +!!! error TS2453: Type '(value: string) => IPromise' is not assignable to type '(value: number) => Promise'. +!!! error TS2453: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2453: Type 'string' is not assignable to type 'number'. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; @@ -328,6 +344,12 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'Promise' is not assignable to type 'IPromise'. +!!! error TS2345: Types of property 'then' are incompatible. +!!! error TS2345: Type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. +!!! error TS2345: Types of parameters 'success' and 'success' are incompatible. +!!! error TS2345: Type '(value: number) => Promise' is not assignable to type '(value: string) => IPromise'. +!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'string'. var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 5a50b9391baab..8afceeae0fde8 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/promisePermutations2.ts(73,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'IPromise'. + Property 'then' is missing in type 'Number'. tests/cases/compiler/promisePermutations2.ts(78,19): error TS2345: Argument of type '(x: number, y?: string) => IPromise' is not assignable to parameter of type '(value: string) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'string'. @@ -54,6 +55,10 @@ tests/cases/compiler/promisePermutations2.ts(151,12): error TS2453: The type arg Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void) => Promise'. + Types of parameters 'success' and 'success' are incompatible. + Type '(value: string) => IPromise' is not assignable to type '(value: number) => any'. + Types of parameters 'value' and 'value' are incompatible. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations2.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. Type 'number' is not assignable to type 'string'. @@ -65,6 +70,12 @@ tests/cases/compiler/promisePermutations2.ts(158,21): error TS2345: Argument of Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'Promise' is not assignable to type 'IPromise'. + Types of property 'then' are incompatible. + Type '(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void) => Promise' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. + Types of parameters 'success' and 'success' are incompatible. + Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. + Types of parameters 'value' and 'value' are incompatible. + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/promisePermutations2.ts (33 errors) ==== @@ -145,6 +156,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. !!! error TS2345: Types of parameters 'x' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'IPromise'. +!!! error TS2345: Property 'then' is missing in type 'Number'. var r4: IPromise; var sIPromise: (x: any) => IPromise; @@ -304,6 +316,10 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! error TS2453: Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. !!! error TS2453: Types of property 'then' are incompatible. !!! error TS2453: Type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }' is not assignable to type '(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void) => Promise'. +!!! error TS2453: Types of parameters 'success' and 'success' are incompatible. +!!! error TS2453: Type '(value: string) => IPromise' is not assignable to type '(value: number) => any'. +!!! error TS2453: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2453: Type 'string' is not assignable to type 'number'. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; @@ -327,6 +343,12 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'Promise' is not assignable to type 'IPromise'. +!!! error TS2345: Types of property 'then' are incompatible. +!!! error TS2345: Type '(success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void) => Promise' is not assignable to type '{ (success?: (value: string) => IPromise, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => IPromise, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => IPromise, progress?: (progress: any) => void): IPromise; (success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void): IPromise; }'. +!!! error TS2345: Types of parameters 'success' and 'success' are incompatible. +!!! error TS2345: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. +!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'string'. var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index d0874ea7f577e..72276745c41e2 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -1,6 +1,7 @@ tests/cases/compiler/promisePermutations3.ts(68,69): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'IPromise'. + Property 'then' is missing in type 'Number'. tests/cases/compiler/promisePermutations3.ts(73,70): error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. Types of parameters 'x' and 'value' are incompatible. Type 'number' is not assignable to type 'IPromise'. @@ -57,6 +58,10 @@ tests/cases/compiler/promisePermutations3.ts(151,12): error TS2453: The type arg Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Types of property 'then' are incompatible. Type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. + Types of parameters 'success' and 'success' are incompatible. + Type '(value: string) => any' is not assignable to type '(value: number) => Promise'. + Types of parameters 'value' and 'value' are incompatible. + Type 'string' is not assignable to type 'number'. tests/cases/compiler/promisePermutations3.ts(155,21): error TS2345: Argument of type '{ (x: number): IPromise; (x: string): IPromise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'IPromise' is not assignable to type 'IPromise'. Type 'number' is not assignable to type 'string'. @@ -68,8 +73,15 @@ tests/cases/compiler/promisePermutations3.ts(158,21): error TS2345: Argument of Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. Type 'Promise' is not assignable to type 'IPromise'. + Types of property 'then' are incompatible. + Type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise'. + Types of parameters 'success' and 'success' are incompatible. + Type '(value: number) => Promise' is not assignable to type '(value: string) => any'. + Types of parameters 'value' and 'value' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. Type 'IPromise' is not assignable to type 'Promise'. + Property 'done' is optional in type 'IPromise' but required in type 'Promise'. ==== tests/cases/compiler/promisePermutations3.ts (35 errors) ==== @@ -145,6 +157,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2345: Argument of type '(x: number) => IPromise' is not assignable to parameter of type '(value: IPromise) => IPromise'. !!! error TS2345: Types of parameters 'x' and 'value' are incompatible. !!! error TS2345: Type 'number' is not assignable to type 'IPromise'. +!!! error TS2345: Property 'then' is missing in type 'Number'. var s3: Promise; var s3a = s3.then(testFunction3, testFunction3, testFunction3); var s3b = s3.then(testFunction3P, testFunction3P, testFunction3P); @@ -313,6 +326,10 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2453: Type argument candidate 'Promise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. !!! error TS2453: Types of property 'then' are incompatible. !!! error TS2453: Type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise' is not assignable to type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. +!!! error TS2453: Types of parameters 'success' and 'success' are incompatible. +!!! error TS2453: Type '(value: string) => any' is not assignable to type '(value: number) => Promise'. +!!! error TS2453: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2453: Type 'string' is not assignable to type 'number'. var s10g = s10.then(testFunctionP, nIPromise, sIPromise).then(sPromise, sIPromise, sIPromise); // ok var r11: IPromise; @@ -336,6 +353,12 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: number): Promise; (x: string): Promise; }' is not assignable to parameter of type '(value: number) => IPromise'. !!! error TS2345: Type 'Promise' is not assignable to type 'IPromise'. +!!! error TS2345: Types of property 'then' are incompatible. +!!! error TS2345: Type '{ (success?: (value: number) => Promise, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => Promise, error?: (error: any) => U, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => Promise, progress?: (progress: any) => void): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }' is not assignable to type '(success?: (value: string) => U, error?: (error: any) => U, progress?: (progress: any) => void) => IPromise'. +!!! error TS2345: Types of parameters 'success' and 'success' are incompatible. +!!! error TS2345: Type '(value: number) => Promise' is not assignable to type '(value: string) => any'. +!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2345: Type 'number' is not assignable to type 'string'. var r12 = testFunction12(x => x); var r12a = r12.then(testFunction12, testFunction12, testFunction12); // ok @@ -345,4 +368,5 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of ~~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '{ (x: T): IPromise; (x: T, y: T): Promise; }' is not assignable to parameter of type '(value: (x: any) => any) => Promise'. !!! error TS2345: Type 'IPromise' is not assignable to type 'Promise'. +!!! error TS2345: Property 'done' is optional in type 'IPromise' but required in type 'Promise'. var s12c = s12.then(testFunction12P, testFunction12, testFunction12); // ok \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.errors.txt b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.errors.txt index 6a7975b4b6212..5a6047222eee2 100644 --- a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.errors.txt +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments2.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts(7,25): error TS2345: Argument of type '(x: A) => A' is not assignable to parameter of type '(x: A) => B'. Type 'A' is not assignable to type 'B'. + Property 'b' is missing in type 'A'. ==== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts (1 errors) ==== @@ -12,4 +13,5 @@ tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments2.ts(7,25): var d = f(a, b, x => x, x => x); // A => A not assignable to A => B ~~~~~~ !!! error TS2345: Argument of type '(x: A) => A' is not assignable to parameter of type '(x: A) => B'. -!!! error TS2345: Type 'A' is not assignable to type 'B'. \ No newline at end of file +!!! error TS2345: Type 'A' is not assignable to type 'B'. +!!! error TS2345: Property 'b' is missing in type 'A'. \ No newline at end of file diff --git a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.errors.txt b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.errors.txt index 89be3c06c6497..cd0801f7ba991 100644 --- a/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.errors.txt +++ b/tests/baselines/reference/typeParameterFixingWithContextSensitiveArguments3.errors.txt @@ -1,5 +1,6 @@ tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts(7,29): error TS2345: Argument of type '(t2: A) => A' is not assignable to parameter of type '(t2: A) => B'. Type 'A' is not assignable to type 'B'. + Property 'b' is missing in type 'A'. ==== tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts (1 errors) ==== @@ -12,4 +13,5 @@ tests/cases/compiler/typeParameterFixingWithContextSensitiveArguments3.ts(7,29): var d = f(a, b, u2 => u2.b, t2 => t2); ~~~~~~~~ !!! error TS2345: Argument of type '(t2: A) => A' is not assignable to parameter of type '(t2: A) => B'. -!!! error TS2345: Type 'A' is not assignable to type 'B'. \ No newline at end of file +!!! error TS2345: Type 'A' is not assignable to type 'B'. +!!! error TS2345: Property 'b' is missing in type 'A'. \ No newline at end of file