From 22647bbae495678959fcd27b1fc491909673e0d1 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:46:06 -0700 Subject: [PATCH 1/9] Revert "Update tests" This reverts commit 3cda0eac32e265a0f4e4b0814af8b4724bfa889d. --- tests/baselines/reference/covariantCallbacks.js | 1 - .../assignmentCompatibility/covariantCallbacks.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/tests/baselines/reference/covariantCallbacks.js b/tests/baselines/reference/covariantCallbacks.js index 4678c13bf15e4..497a1ff991678 100644 --- a/tests/baselines/reference/covariantCallbacks.js +++ b/tests/baselines/reference/covariantCallbacks.js @@ -72,7 +72,6 @@ function f14(a: AList4, b: BList4) { //// [covariantCallbacks.js] -"use strict"; // Test that callback parameters are related covariantly ; function f1(a, b) { diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts index 4f3e7ecda0d66..462911fb17ac9 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts @@ -1,5 +1,4 @@ // @target: es2015 -// @strict: true // Test that callback parameters are related covariantly From e86512e270ca19bb507e1124a41782d94fad7ed1 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:46:18 -0700 Subject: [PATCH 2/9] Revert "Allow callbacks unioned with null and/or undefined" This reverts commit ec35b800e30ec735be8946842fcfa6ef45649a2c. --- src/compiler/checker.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 57e9d02ddd8cf..0e53b7d6f6ae0 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8233,8 +8233,8 @@ namespace ts { for (let i = 0; i < checkCount; i++) { const sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); const targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); - const sourceSig = getSingleCallSignature(getNonNullableType(sourceType)); - const targetSig = getSingleCallSignature(getNonNullableType(targetType)); + const sourceSig = getSingleCallSignature(sourceType); + const targetSig = getSingleCallSignature(targetType); // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, // they naturally relate only contra-variantly). However, if the source and target parameters both have @@ -8243,9 +8243,7 @@ namespace ts { // similar to return values, callback parameters are output positions. This means that a Promise, // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) // with respect to T. - const callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate && - (getFalsyFlags(sourceType) & TypeFlags.Nullable) === (getFalsyFlags(targetType) & TypeFlags.Nullable); - const related = callbacks ? + const related = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate ? compareSignaturesRelated(targetSig, sourceSig, /*checkAsCallback*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : !checkAsCallback && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { From cf17be2c764c087449e12dde85c14b36a087a16e Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:46:30 -0700 Subject: [PATCH 3/9] Revert "Add another test case" This reverts commit 510bc8196760f9d62b29d2f3e48a8bc6ad0d8d14. --- .../reference/covariantCallbacks.errors.txt | 31 ++----------------- .../baselines/reference/covariantCallbacks.js | 20 +----------- .../covariantCallbacks.ts | 15 +-------- 3 files changed, 4 insertions(+), 62 deletions(-) diff --git a/tests/baselines/reference/covariantCallbacks.errors.txt b/tests/baselines/reference/covariantCallbacks.errors.txt index 55c69c89728f1..3a1ea25b96e46 100644 --- a/tests/baselines/reference/covariantCallbacks.errors.txt +++ b/tests/baselines/reference/covariantCallbacks.errors.txt @@ -18,15 +18,9 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covarian Types of property 'forEach' are incompatible. Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: A, context: any) => void) => void'. Types of parameters 'cb' and 'cb' are incompatible. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(69,5): error TS2322: Type 'AList4' is not assignable to type 'BList4'. - Types of property 'forEach' are incompatible. - Type '(cb: (item: A) => A) => void' is not assignable to type '(cb: (item: B) => B) => void'. - Types of parameters 'cb' and 'cb' are incompatible. - Types of parameters 'item' and 'item' are incompatible. - Type 'A' is not assignable to type 'B'. -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts (6 errors) ==== +==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts (5 errors) ==== // Test that callback parameters are related covariantly interface P { @@ -108,25 +102,4 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covarian !!! error TS2322: Types of property 'forEach' are incompatible. !!! error TS2322: Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: A, context: any) => void) => void'. !!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible. - } - - interface AList4 { - forEach(cb: (item: A) => A): void; - } - - interface BList4 { - forEach(cb: (item: B) => B): void; - } - - function f14(a: AList4, b: BList4) { - a = b; - b = a; // Error - ~ -!!! error TS2322: Type 'AList4' is not assignable to type 'BList4'. -!!! error TS2322: Types of property 'forEach' are incompatible. -!!! error TS2322: Type '(cb: (item: A) => A) => void' is not assignable to type '(cb: (item: B) => B) => void'. -!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible. -!!! error TS2322: Types of parameters 'item' and 'item' are incompatible. -!!! error TS2322: Type 'A' is not assignable to type 'B'. - } - \ No newline at end of file + } \ No newline at end of file diff --git a/tests/baselines/reference/covariantCallbacks.js b/tests/baselines/reference/covariantCallbacks.js index 497a1ff991678..fb2ecfbc3c18e 100644 --- a/tests/baselines/reference/covariantCallbacks.js +++ b/tests/baselines/reference/covariantCallbacks.js @@ -55,21 +55,7 @@ interface BList3 { function f13(a: AList3, b: BList3) { a = b; b = a; // Error -} - -interface AList4 { - forEach(cb: (item: A) => A): void; -} - -interface BList4 { - forEach(cb: (item: B) => B): void; -} - -function f14(a: AList4, b: BList4) { - a = b; - b = a; // Error -} - +} //// [covariantCallbacks.js] // Test that callback parameters are related covariantly @@ -94,7 +80,3 @@ function f13(a, b) { a = b; b = a; // Error } -function f14(a, b) { - a = b; - b = a; // Error -} diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts index 462911fb17ac9..c46f396f414ea 100644 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts +++ b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts @@ -56,17 +56,4 @@ interface BList3 { function f13(a: AList3, b: BList3) { a = b; b = a; // Error -} - -interface AList4 { - forEach(cb: (item: A) => A): void; -} - -interface BList4 { - forEach(cb: (item: B) => B): void; -} - -function f14(a: AList4, b: BList4) { - a = b; - b = a; // Error -} +} \ No newline at end of file From d581bed509e99c487ba0455d3792e59df1fa955a Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:46:43 -0700 Subject: [PATCH 4/9] Revert "Accept new baselines" This reverts commit 33bc9d161685bf41d0072a566b89226543ad0a63. --- ...typeIsAssignableToReadonlyArray.errors.txt | 2 -- .../subtypingWithCallSignatures2.types | 32 +++++++++---------- .../subtypingWithCallSignatures3.types | 8 ++--- .../subtypingWithCallSignatures4.types | 8 ++--- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt index 90dc909b11a93..51a581b7fb392 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -3,7 +3,6 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error T 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[]; }'. @@ -30,7 +29,6 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T !!! 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 diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 86c65702b985c..3d0b212acceb6 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -470,14 +470,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : (x: (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : ((x: (arg: T) => U) => T)[] ->[r5arg1, r5arg2] : ((x: (arg: T) => U) => T)[] +>r5a : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>[r5arg1, r5arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] >r5arg1 : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : ((x: (arg: T) => U) => T)[] ->[r5arg2, r5arg1] : ((x: (arg: T) => U) => T)[] +>r5b : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>[r5arg2, r5arg1] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] >r5arg2 : (x: (arg: string) => number) => string >r5arg1 : (x: (arg: T) => U) => T @@ -514,14 +514,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : (x: (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : ((x: (arg: T) => U) => T)[] ->[r6arg1, r6arg2] : ((x: (arg: T) => U) => T)[] +>r6a : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>[r6arg1, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] >r6arg1 : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : ((x: (arg: T) => U) => T)[] ->[r6arg2, r6arg1] : ((x: (arg: T) => U) => T)[] +>r6b : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>[r6arg2, r6arg1] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] >r6arg2 : (x: (arg: Base) => Derived) => Base >r6arg1 : (x: (arg: T) => U) => T @@ -564,14 +564,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : (x: (arg: T) => U) => (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : ((x: (arg: T) => U) => (r: T) => U)[] ->[r7arg1, r7arg2] : ((x: (arg: T) => U) => (r: T) => U)[] +>r7a : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>[r7arg1, r7arg2] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] >r7arg1 : (x: (arg: T) => U) => (r: T) => U >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : ((x: (arg: T) => U) => (r: T) => U)[] ->[r7arg2, r7arg1] : ((x: (arg: T) => U) => (r: T) => U)[] +>r7b : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>[r7arg2, r7arg1] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived >r7arg1 : (x: (arg: T) => U) => (r: T) => U @@ -622,14 +622,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] ->[r8arg1, r8arg2] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>r8a : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>[r8arg1, r8arg2] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] ->[r8arg2, r8arg1] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>r8b : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>[r8arg2, r8arg1] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index 6abc7567efb2c..d505fc7d3468f 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -291,14 +291,14 @@ module Errors { >r2arg : (x: (arg: T) => U) => (r: T) => V var r2a = [r2arg2, r2arg]; ->r2a : ((x: (arg: T) => U) => (r: T) => V)[] ->[r2arg2, r2arg] : ((x: (arg: T) => U) => (r: T) => V)[] +>r2a : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>[r2arg2, r2arg] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 >r2arg : (x: (arg: T) => U) => (r: T) => V var r2b = [r2arg, r2arg2]; ->r2b : ((x: (arg: T) => U) => (r: T) => V)[] ->[r2arg, r2arg2] : ((x: (arg: T) => U) => (r: T) => V)[] +>r2b : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>[r2arg, r2arg2] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] >r2arg : (x: (arg: T) => U) => (r: T) => V >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index 5926636289abc..a882d07e8ea33 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -447,14 +447,14 @@ var r6 = foo6(r6arg); >r6arg : (x: (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : ((x: (arg: T) => U) => T)[] ->[r6arg, r6arg2] : ((x: (arg: T) => U) => T)[] +>r6a : ((x: (arg: T) => Derived) => T)[] +>[r6arg, r6arg2] : ((x: (arg: T) => Derived) => T)[] >r6arg : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : ((x: (arg: T) => U) => T)[] ->[r6arg2, r6arg] : ((x: (arg: T) => U) => T)[] +>r6b : ((x: (arg: T) => Derived) => T)[] +>[r6arg2, r6arg] : ((x: (arg: T) => Derived) => T)[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T From 42d6a9cac64bd58f3a34f3eb39f8a8b79f2cab08 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:46:55 -0700 Subject: [PATCH 5/9] Revert "Check callback return values bi-variantly" This reverts commit 189fc515796a2612874ea7f74226edc0aacc5088. --- src/compiler/checker.ts | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 0e53b7d6f6ae0..8906ce9401849 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8177,7 +8177,7 @@ namespace ts { function isSignatureAssignableTo(source: Signature, target: Signature, ignoreReturnTypes: boolean): boolean { - return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, ignoreReturnTypes, /*reportErrors*/ false, + return compareSignaturesRelated(source, target, /*strictVariance*/ false, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False; } @@ -8188,7 +8188,7 @@ namespace ts { */ function compareSignaturesRelated(source: Signature, target: Signature, - checkAsCallback: boolean, + strictVariance: boolean, ignoreReturnTypes: boolean, reportErrors: boolean, errorReporter: ErrorReporter, @@ -8235,17 +8235,13 @@ namespace ts { const targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); const sourceSig = getSingleCallSignature(sourceType); const targetSig = getSingleCallSignature(targetType); - // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter - // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, - // they naturally relate only contra-variantly). However, if the source and target parameters both have - // function types with a single call signature, we known we are relating two callback parameters. In - // that case it is sufficient to only relate the parameters of the signatures co-variantly because, - // similar to return values, callback parameters are output positions. This means that a Promise, - // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) - // with respect to T. - const related = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate ? - compareSignaturesRelated(targetSig, sourceSig, /*checkAsCallback*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : - !checkAsCallback && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + // If the source and target parameters both have function types with a single call signature we are + // relating two callback parameters. In that case we compare the callback signatures with strict + // variance, meaning we require the callback parameters to be pairwise co-variant (because, similar + // to return values, callback parameters are output positions). + const related = sourceSig && targetSig ? + compareSignaturesRelated(targetSig, sourceSig, /*strictVariance*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, @@ -8277,11 +8273,7 @@ namespace ts { } } else { - // When relating callback signatures, we still need to relate return types bi-variantly as otherwise - // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } - // wouldn't be co-variant for T without this rule. - result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || - compareTypes(sourceReturnType, targetReturnType, reportErrors); + result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); } } @@ -9249,7 +9241,7 @@ namespace ts { * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source: Signature, target: Signature, reportErrors: boolean): Ternary { - return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + return compareSignaturesRelated(source, target, /*strictVariance*/ false, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary { From 3abd0c8ac2f34182797fd9782d64e816cd2498d7 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:47:16 -0700 Subject: [PATCH 6/9] Revert "Add tests" This reverts commit 50f84b12a2ad5fef8294410c2cdfcce35b49a577. --- .../reference/covariantCallbacks.errors.txt | 105 ------------------ .../baselines/reference/covariantCallbacks.js | 82 -------------- .../covariantCallbacks.ts | 59 ---------- 3 files changed, 246 deletions(-) delete mode 100644 tests/baselines/reference/covariantCallbacks.errors.txt delete mode 100644 tests/baselines/reference/covariantCallbacks.js delete mode 100644 tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts diff --git a/tests/baselines/reference/covariantCallbacks.errors.txt b/tests/baselines/reference/covariantCallbacks.errors.txt deleted file mode 100644 index 3a1ea25b96e46..0000000000000 --- a/tests/baselines/reference/covariantCallbacks.errors.txt +++ /dev/null @@ -1,105 +0,0 @@ -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(12,5): error TS2322: Type 'P' is not assignable to type 'P'. - Type 'A' is not assignable to type 'B'. - Property 'b' is missing in type 'A'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(17,5): error TS2322: Type 'Promise' is not assignable to type 'Promise'. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(30,5): error TS2322: Type 'AList1' is not assignable to type 'BList1'. - Types of property 'forEach' are incompatible. - Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: B) => void) => void'. - Types of parameters 'cb' and 'cb' are incompatible. - Types of parameters 'item' and 'item' are incompatible. - Type 'A' is not assignable to type 'B'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(43,5): error TS2322: Type 'AList2' is not assignable to type 'BList2'. - Types of property 'forEach' are incompatible. - Type '(cb: (item: A) => boolean) => void' is not assignable to type '(cb: (item: A) => void) => void'. - Types of parameters 'cb' and 'cb' are incompatible. - Type 'void' is not assignable to type 'boolean'. -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts(56,5): error TS2322: Type 'AList3' is not assignable to type 'BList3'. - Types of property 'forEach' are incompatible. - Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: A, context: any) => void) => void'. - Types of parameters 'cb' and 'cb' are incompatible. - - -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts (5 errors) ==== - // Test that callback parameters are related covariantly - - interface P { - then(cb: (value: T) => void): void; - }; - - interface A { a: string } - interface B extends A { b: string } - - function f1(a: P, b: P) { - a = b; - b = a; // Error - ~ -!!! error TS2322: Type 'P' is not assignable to type 'P'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. -!!! error TS2322: Property 'b' is missing in type 'A'. - } - - function f2(a: Promise, b: Promise) { - a = b; - b = a; // Error - ~ -!!! error TS2322: Type 'Promise' is not assignable to type 'Promise'. -!!! error TS2322: Type 'A' is not assignable to type 'B'. - } - - interface AList1 { - forEach(cb: (item: A) => void): void; - } - - interface BList1 { - forEach(cb: (item: B) => void): void; - } - - function f11(a: AList1, b: BList1) { - a = b; - b = a; // Error - ~ -!!! error TS2322: Type 'AList1' is not assignable to type 'BList1'. -!!! error TS2322: Types of property 'forEach' are incompatible. -!!! error TS2322: Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: B) => void) => void'. -!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible. -!!! error TS2322: Types of parameters 'item' and 'item' are incompatible. -!!! error TS2322: Type 'A' is not assignable to type 'B'. - } - - interface AList2 { - forEach(cb: (item: A) => boolean): void; - } - - interface BList2 { - forEach(cb: (item: A) => void): void; - } - - function f12(a: AList2, b: BList2) { - a = b; - b = a; // Error - ~ -!!! error TS2322: Type 'AList2' is not assignable to type 'BList2'. -!!! error TS2322: Types of property 'forEach' are incompatible. -!!! error TS2322: Type '(cb: (item: A) => boolean) => void' is not assignable to type '(cb: (item: A) => void) => void'. -!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible. -!!! error TS2322: Type 'void' is not assignable to type 'boolean'. - } - - interface AList3 { - forEach(cb: (item: A) => void): void; - } - - interface BList3 { - forEach(cb: (item: A, context: any) => void): void; - } - - function f13(a: AList3, b: BList3) { - a = b; - b = a; // Error - ~ -!!! error TS2322: Type 'AList3' is not assignable to type 'BList3'. -!!! error TS2322: Types of property 'forEach' are incompatible. -!!! error TS2322: Type '(cb: (item: A) => void) => void' is not assignable to type '(cb: (item: A, context: any) => void) => void'. -!!! error TS2322: Types of parameters 'cb' and 'cb' are incompatible. - } \ No newline at end of file diff --git a/tests/baselines/reference/covariantCallbacks.js b/tests/baselines/reference/covariantCallbacks.js deleted file mode 100644 index fb2ecfbc3c18e..0000000000000 --- a/tests/baselines/reference/covariantCallbacks.js +++ /dev/null @@ -1,82 +0,0 @@ -//// [covariantCallbacks.ts] -// Test that callback parameters are related covariantly - -interface P { - then(cb: (value: T) => void): void; -}; - -interface A { a: string } -interface B extends A { b: string } - -function f1(a: P, b: P) { - a = b; - b = a; // Error -} - -function f2(a: Promise, b: Promise) { - a = b; - b = a; // Error -} - -interface AList1 { - forEach(cb: (item: A) => void): void; -} - -interface BList1 { - forEach(cb: (item: B) => void): void; -} - -function f11(a: AList1, b: BList1) { - a = b; - b = a; // Error -} - -interface AList2 { - forEach(cb: (item: A) => boolean): void; -} - -interface BList2 { - forEach(cb: (item: A) => void): void; -} - -function f12(a: AList2, b: BList2) { - a = b; - b = a; // Error -} - -interface AList3 { - forEach(cb: (item: A) => void): void; -} - -interface BList3 { - forEach(cb: (item: A, context: any) => void): void; -} - -function f13(a: AList3, b: BList3) { - a = b; - b = a; // Error -} - -//// [covariantCallbacks.js] -// Test that callback parameters are related covariantly -; -function f1(a, b) { - a = b; - b = a; // Error -} -function f2(a, b) { - a = b; - b = a; // Error -} -function f11(a, b) { - a = b; - b = a; // Error -} -function f12(a, b) { - a = b; - b = a; // Error -} -function f13(a, b) { - a = b; - b = a; // Error -} diff --git a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts b/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts deleted file mode 100644 index c46f396f414ea..0000000000000 --- a/tests/cases/conformance/types/typeRelationships/assignmentCompatibility/covariantCallbacks.ts +++ /dev/null @@ -1,59 +0,0 @@ -// @target: es2015 - -// Test that callback parameters are related covariantly - -interface P { - then(cb: (value: T) => void): void; -}; - -interface A { a: string } -interface B extends A { b: string } - -function f1(a: P, b: P) { - a = b; - b = a; // Error -} - -function f2(a: Promise, b: Promise) { - a = b; - b = a; // Error -} - -interface AList1 { - forEach(cb: (item: A) => void): void; -} - -interface BList1 { - forEach(cb: (item: B) => void): void; -} - -function f11(a: AList1, b: BList1) { - a = b; - b = a; // Error -} - -interface AList2 { - forEach(cb: (item: A) => boolean): void; -} - -interface BList2 { - forEach(cb: (item: A) => void): void; -} - -function f12(a: AList2, b: BList2) { - a = b; - b = a; // Error -} - -interface AList3 { - forEach(cb: (item: A) => void): void; -} - -interface BList3 { - forEach(cb: (item: A, context: any) => void): void; -} - -function f13(a: AList3, b: BList3) { - a = b; - b = a; // Error -} \ No newline at end of file From 70bb2d3b0f506f2ff5cba8809a8822eb81154d62 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:47:26 -0700 Subject: [PATCH 7/9] Revert "Accept new baselines" This reverts commit 11543d7369b6b0fc594dd0d38b092f0fa66e8075. --- ...typeIsAssignableToReadonlyArray.errors.txt | 2 + ...gnmentCompatWithCallSignatures3.errors.txt | 113 ------------------ ...gnmentCompatWithCallSignatures4.errors.txt | 36 +++--- ...tCompatWithConstructSignatures3.errors.txt | 113 ------------------ ...tCompatWithConstructSignatures4.errors.txt | 36 +++--- ...tureAssignabilityInInheritance3.errors.txt | 18 +-- ...tureAssignabilityInInheritance3.errors.txt | 18 +-- ...ptionalFunctionArgAssignability.errors.txt | 10 +- ...rloadOnConstNoAnyImplementation.errors.txt | 5 +- ...loadOnConstNoAnyImplementation2.errors.txt | 5 +- .../reference/promisePermutations.errors.txt | 44 +++---- .../reference/promisePermutations2.errors.txt | 44 +++---- .../reference/promisePermutations3.errors.txt | 44 +++---- .../promisesWithConstraints.errors.txt | 36 ------ .../recursiveTypeComparison2.errors.txt | 9 +- .../subtypingWithCallSignatures2.types | 40 +++---- .../subtypingWithCallSignatures3.types | 8 +- .../subtypingWithCallSignatures4.types | 8 +- 18 files changed, 172 insertions(+), 417 deletions(-) delete mode 100644 tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt delete mode 100644 tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt delete mode 100644 tests/baselines/reference/promisesWithConstraints.errors.txt diff --git a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt index 51a581b7fb392..90dc909b11a93 100644 --- a/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt +++ b/tests/baselines/reference/arrayOfSubtypeIsAssignableToReadonlyArray.errors.txt @@ -3,6 +3,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(13,1): error T 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[]; }'. @@ -29,6 +30,7 @@ tests/cases/compiler/arrayOfSubtypeIsAssignableToReadonlyArray.ts(18,1): error T !!! 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 diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt deleted file mode 100644 index 0e8605efafdc7..0000000000000 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures3.errors.txt +++ /dev/null @@ -1,113 +0,0 @@ -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts(71,1): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'. - Types of parameters 'y' and 'y' are incompatible. - Types of parameters 'arg2' and 'arg2' are incompatible. - Type 'Base' is not assignable to type '{ foo: string; bing: number; }'. - Property 'bing' is missing in type 'Base'. - - -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures3.ts (1 errors) ==== - // these are all permitted with the current rules, since we do not do contextual signature instantiation - - class Base { foo: string; } - class Derived extends Base { bar: string; } - class Derived2 extends Derived { baz: string; } - class OtherDerived extends Base { bing: string; } - - var a: (x: number) => number[]; - var a2: (x: number) => string[]; - var a3: (x: number) => void; - var a4: (x: string, y: number) => string; - var a5: (x: (arg: string) => number) => string; - var a6: (x: (arg: Base) => Derived) => Base; - var a7: (x: (arg: Base) => Derived) => (r: Base) => Derived; - var a8: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; - var a9: (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; - var a10: (...x: Derived[]) => Derived; - var a11: (x: { foo: string }, y: { foo: string; bar: string }) => Base; - var a12: (x: Array, y: Array) => Array; - var a13: (x: Array, y: Array) => Array; - var a14: (x: { a: string; b: number }) => Object; - var a15: { - (x: number): number[]; - (x: string): string[]; - } - var a16: { - (x: T): number[]; - (x: U): number[]; - } - var a17: { - (x: (a: number) => number): number[]; - (x: (a: string) => string): string[]; - }; - var a18: { - (x: { - (a: number): number; - (a: string): string; - }): any[]; - (x: { - (a: boolean): boolean; - (a: Date): Date; - }): any[]; - } - - var b: (x: T) => T[]; - a = b; // ok - b = a; // ok - var b2: (x: T) => string[]; - a2 = b2; // ok - b2 = a2; // ok - var b3: (x: T) => T; - a3 = b3; // ok - b3 = a3; // ok - var b4: (x: T, y: U) => T; - a4 = b4; // ok - b4 = a4; // ok - var b5: (x: (arg: T) => U) => T; - a5 = b5; // ok - b5 = a5; // ok - var b6: (x: (arg: T) => U) => T; - a6 = b6; // ok - b6 = a6; // ok - var b7: (x: (arg: T) => U) => (r: T) => U; - a7 = b7; // ok - b7 = a7; // ok - var b8: (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U; - a8 = b8; // ok - b8 = a8; // ok - var b9: (x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U; - a9 = b9; // ok - b9 = a9; // ok - ~~ -!!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'. -!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. -!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. -!!! error TS2322: Type 'Base' is not assignable to type '{ foo: string; bing: number; }'. -!!! error TS2322: Property 'bing' is missing in type 'Base'. - var b10: (...x: T[]) => T; - a10 = b10; // ok - b10 = a10; // ok - var b11: (x: T, y: T) => T; - a11 = b11; // ok - b11 = a11; // ok - var b12: >(x: Array, y: T) => Array; - a12 = b12; // ok - b12 = a12; // ok - var b13: >(x: Array, y: T) => T; - a13 = b13; // ok - b13 = a13; // ok - var b14: (x: { a: T; b: T }) => T; - a14 = b14; // ok - b14 = a14; // ok - var b15: (x: T) => T[]; - a15 = b15; // ok - b15 = a15; // ok - var b16: (x: T) => number[]; - a16 = b16; // ok - b16 = a16; // ok - var b17: (x: (a: T) => T) => T[]; // ok - a17 = b17; // ok - b17 = a17; // ok - var b18: (x: (a: T) => T) => T[]; - a18 = b18; // ok - b18 = a18; // ok - \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt index df391b27f9873..8d184edc085ef 100644 --- a/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithCallSignatures4.errors.txt @@ -1,15 +1,17 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(52,9): error TS2322: Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. Types of parameters 'y' and 'y' are incompatible. - Types of parameters 'arg2' and 'arg2' are incompatible. - Type '{ foo: number; }' is not assignable to type 'Base'. - Types of property 'foo' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. + Types of parameters 'arg2' and 'arg2' are incompatible. + Type '{ foo: number; }' is not assignable to type 'Base'. + Types of property 'foo' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts(53,9): error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'. Types of parameters 'y' and 'y' are incompatible. - Types of parameters 'arg2' and 'arg2' are incompatible. - Type 'Base' is not assignable to type '{ foo: number; }'. - Types of property 'foo' are incompatible. - Type 'string' is not assignable to type 'number'. + Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'. + Types of parameters 'arg2' and 'arg2' are incompatible. + Type 'Base' is not assignable to type '{ foo: number; }'. + Types of property 'foo' are incompatible. + Type 'string' is not assignable to type 'number'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithCallSignatures4.ts (2 errors) ==== @@ -68,18 +70,20 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~ !!! error TS2322: Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. -!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. -!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. +!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. +!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b8 = a8; // error, { foo: number } and Base are incompatible ~~ !!! error TS2322: Type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. -!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. -!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'. +!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. +!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. var b10: (...x: T[]) => T; diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt deleted file mode 100644 index 995a9b67ccd72..0000000000000 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures3.errors.txt +++ /dev/null @@ -1,113 +0,0 @@ -tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts(71,1): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'. - Types of parameters 'y' and 'y' are incompatible. - Types of parameters 'arg2' and 'arg2' are incompatible. - Type 'Base' is not assignable to type '{ foo: string; bing: number; }'. - Property 'bing' is missing in type 'Base'. - - -==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures3.ts (1 errors) ==== - // checking assignment compatibility relations for function types. All of these are valid. - - class Base { foo: string; } - class Derived extends Base { bar: string; } - class Derived2 extends Derived { baz: string; } - class OtherDerived extends Base { bing: string; } - - var a: new (x: number) => number[]; - var a2: new (x: number) => string[]; - var a3: new (x: number) => void; - var a4: new (x: string, y: number) => string; - var a5: new (x: (arg: string) => number) => string; - var a6: new (x: (arg: Base) => Derived) => Base; - var a7: new (x: (arg: Base) => Derived) => (r: Base) => Derived; - var a8: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; - var a9: new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived; - var a10: new (...x: Derived[]) => Derived; - var a11: new (x: { foo: string }, y: { foo: string; bar: string }) => Base; - var a12: new (x: Array, y: Array) => Array; - var a13: new (x: Array, y: Array) => Array; - var a14: new (x: { a: string; b: number }) => Object; - var a15: { - new (x: number): number[]; - new (x: string): string[]; - } - var a16: { - new (x: T): number[]; - new (x: U): number[]; - } - var a17: { - new (x: new (a: number) => number): number[]; - new (x: new (a: string) => string): string[]; - }; - var a18: { - new (x: { - new (a: number): number; - new (a: string): string; - }): any[]; - new (x: { - new (a: boolean): boolean; - new (a: Date): Date; - }): any[]; - } - - var b: new (x: T) => T[]; - a = b; // ok - b = a; // ok - var b2: new (x: T) => string[]; - a2 = b2; // ok - b2 = a2; // ok - var b3: new (x: T) => T; - a3 = b3; // ok - b3 = a3; // ok - var b4: new (x: T, y: U) => T; - a4 = b4; // ok - b4 = a4; // ok - var b5: new (x: (arg: T) => U) => T; - a5 = b5; // ok - b5 = a5; // ok - var b6: new (x: (arg: T) => U) => T; - a6 = b6; // ok - b6 = a6; // ok - var b7: new (x: (arg: T) => U) => (r: T) => U; - a7 = b7; // ok - b7 = a7; // ok - var b8: new (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U; - a8 = b8; // ok - b8 = a8; // ok - var b9: new (x: (arg: T) => U, y: (arg2: { foo: string; bing: number }) => U) => (r: T) => U; - a9 = b9; // ok - b9 = a9; // ok - ~~ -!!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U'. -!!! error TS2322: Types of parameters 'y' and 'y' are incompatible. -!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. -!!! error TS2322: Type 'Base' is not assignable to type '{ foo: string; bing: number; }'. -!!! error TS2322: Property 'bing' is missing in type 'Base'. - var b10: new (...x: T[]) => T; - a10 = b10; // ok - b10 = a10; // ok - var b11: new (x: T, y: T) => T; - a11 = b11; // ok - b11 = a11; // ok - var b12: new >(x: Array, y: T) => Array; - a12 = b12; // ok - b12 = a12; // ok - var b13: new >(x: Array, y: T) => T; - a13 = b13; // ok - b13 = a13; // ok - var b14: new (x: { a: T; b: T }) => T; - a14 = b14; // ok - b14 = a14; // ok - var b15: new (x: T) => T[]; - a15 = b15; // ok - b15 = a15; // ok - var b16: new (x: T) => number[]; - a16 = b16; // ok - b16 = a16; // ok - var b17: new (x: new (a: T) => T) => T[]; // ok - a17 = b17; // ok - b17 = a17; // ok - var b18: new (x: new (a: T) => T) => T[]; - a18 = b18; // ok - b18 = a18; // ok - \ No newline at end of file diff --git a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt index 6b2f4a0de176d..f6e93e13f0462 100644 --- a/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt +++ b/tests/baselines/reference/assignmentCompatWithConstructSignatures4.errors.txt @@ -1,15 +1,17 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(52,9): error TS2322: Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. Types of parameters 'y' and 'y' are incompatible. - Types of parameters 'arg2' and 'arg2' are incompatible. - Type '{ foo: number; }' is not assignable to type 'Base'. - Types of property 'foo' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. + Types of parameters 'arg2' and 'arg2' are incompatible. + Type '{ foo: number; }' is not assignable to type 'Base'. + Types of property 'foo' are incompatible. + Type 'number' is not assignable to type 'string'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(53,9): error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'. Types of parameters 'y' and 'y' are incompatible. - Types of parameters 'arg2' and 'arg2' are incompatible. - Type 'Base' is not assignable to type '{ foo: number; }'. - Types of property 'foo' are incompatible. - Type 'string' is not assignable to type 'number'. + Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'. + Types of parameters 'arg2' and 'arg2' are incompatible. + Type 'Base' is not assignable to type '{ foo: number; }'. + Types of property 'foo' are incompatible. + Type 'string' is not assignable to type 'number'. tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithConstructSignatures4.ts(77,9): error TS2322: Type 'new (x: (a: T) => T) => T[]' is not assignable to type '{ new (x: { new (a: number): number; new (a?: number): number; }): number[]; new (x: { new (a: boolean): boolean; new (a?: boolean): boolean; }): boolean[]; }'. Types of parameters 'x' and 'x' are incompatible. Type '{ new (a: number): number; new (a?: number): number; }' is not assignable to type '(a: any) => any'. @@ -84,18 +86,20 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignme ~~ !!! error TS2322: Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. -!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. -!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. +!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. +!!! error TS2322: Type '{ foo: number; }' is not assignable to type 'Base'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. b8 = a8; // error ~~ !!! error TS2322: Type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived' is not assignable to type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U'. !!! error TS2322: Types of parameters 'y' and 'y' are incompatible. -!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. -!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'. -!!! error TS2322: Types of property 'foo' are incompatible. -!!! error TS2322: Type 'string' is not assignable to type 'number'. +!!! error TS2322: Type '(arg2: { foo: number; }) => any' is not assignable to type '(arg2: Base) => Derived'. +!!! error TS2322: Types of parameters 'arg2' and 'arg2' are incompatible. +!!! error TS2322: Type 'Base' is not assignable to type '{ foo: number; }'. +!!! error TS2322: Types of property 'foo' are incompatible. +!!! error TS2322: Type 'string' is not assignable to type 'number'. var b10: new (...x: T[]) => T; diff --git a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt index f5e05567b2580..2d7e795d26ab7 100644 --- a/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/callSignatureAssignabilityInInheritance3.errors.txt @@ -7,10 +7,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign Types of property 'a8' are incompatible. Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. Types of parameters 'y' and 'y' are incompatible. - Types of parameters 'arg2' and 'arg2' are incompatible. - Type '{ foo: number; }' is not assignable to type 'Base'. - Types of property 'foo' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. + Types of parameters 'arg2' and 'arg2' are incompatible. + Type '{ foo: number; }' is not assignable to type 'Base'. + Types of property 'foo' are incompatible. + Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance3.ts (2 errors) ==== @@ -85,10 +86,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSign !!! error TS2430: Types of property 'a8' are incompatible. !!! error TS2430: Type '(x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type '(x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. !!! error TS2430: Types of parameters 'y' and 'y' are incompatible. -!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible. -!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'. -!!! error TS2430: Types of property 'foo' are incompatible. -!!! error TS2430: Type 'number' is not assignable to type 'string'. +!!! error TS2430: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. +!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible. +!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'. +!!! error TS2430: Types of property 'foo' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. a8: (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; // error, type mismatch } diff --git a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt index 7bd761593912f..086372aac179f 100644 --- a/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt +++ b/tests/baselines/reference/constructSignatureAssignabilityInInheritance3.errors.txt @@ -7,10 +7,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc Types of property 'a8' are incompatible. Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. Types of parameters 'y' and 'y' are incompatible. - Types of parameters 'arg2' and 'arg2' are incompatible. - Type '{ foo: number; }' is not assignable to type 'Base'. - Types of property 'foo' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. + Types of parameters 'arg2' and 'arg2' are incompatible. + Type '{ foo: number; }' is not assignable to type 'Base'. + Types of property 'foo' are incompatible. + Type 'number' is not assignable to type 'string'. ==== tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance3.ts (2 errors) ==== @@ -75,10 +76,11 @@ tests/cases/conformance/types/typeRelationships/assignmentCompatibility/construc !!! error TS2430: Types of property 'a8' are incompatible. !!! error TS2430: Type 'new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U' is not assignable to type 'new (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived'. !!! error TS2430: Types of parameters 'y' and 'y' are incompatible. -!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible. -!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'. -!!! error TS2430: Types of property 'foo' are incompatible. -!!! error TS2430: Type 'number' is not assignable to type 'string'. +!!! error TS2430: Type '(arg2: Base) => Derived' is not assignable to type '(arg2: { foo: number; }) => any'. +!!! error TS2430: Types of parameters 'arg2' and 'arg2' are incompatible. +!!! error TS2430: Type '{ foo: number; }' is not assignable to type 'Base'. +!!! error TS2430: Types of property 'foo' are incompatible. +!!! error TS2430: Type 'number' is not assignable to type 'string'. a8: new (x: (arg: T) => U, y: (arg2: { foo: number; }) => U) => (r: T) => U; // error, type mismatch } diff --git a/tests/baselines/reference/optionalFunctionArgAssignability.errors.txt b/tests/baselines/reference/optionalFunctionArgAssignability.errors.txt index 1898db924635b..024c5c1ea2b4d 100644 --- a/tests/baselines/reference/optionalFunctionArgAssignability.errors.txt +++ b/tests/baselines/reference/optionalFunctionArgAssignability.errors.txt @@ -1,7 +1,8 @@ tests/cases/compiler/optionalFunctionArgAssignability.ts(7,1): error TS2322: Type '(onFulFill?: (value: number) => U, onReject?: (reason: any) => U) => Promise' is not assignable to type '(onFulfill?: (value: string) => U, onReject?: (reason: any) => U) => Promise'. Types of parameters 'onFulFill' and 'onFulfill' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '(value: string) => any' is not assignable to type '(value: number) => any'. + Types of parameters 'value' and 'value' are incompatible. + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/optionalFunctionArgAssignability.ts (1 errors) ==== @@ -15,6 +16,7 @@ tests/cases/compiler/optionalFunctionArgAssignability.ts(7,1): error TS2322: Typ ~ !!! error TS2322: Type '(onFulFill?: (value: number) => U, onReject?: (reason: any) => U) => Promise' is not assignable to type '(onFulfill?: (value: string) => U, onReject?: (reason: any) => U) => Promise'. !!! error TS2322: Types of parameters 'onFulFill' and 'onFulfill' are incompatible. -!!! error TS2322: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2322: Type 'number' is not assignable to type 'string'. +!!! error TS2322: Type '(value: string) => any' is not assignable to type '(value: number) => any'. +!!! error TS2322: Types of parameters 'value' and 'value' are incompatible. +!!! error TS2322: Type 'number' is not assignable to type 'string'. \ No newline at end of file diff --git a/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt b/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt index aa7bbf7723968..0573c6ed79ee6 100644 --- a/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt +++ b/tests/baselines/reference/overloadOnConstNoAnyImplementation.errors.txt @@ -1,11 +1,8 @@ -tests/cases/compiler/overloadOnConstNoAnyImplementation.ts(1,10): error TS2394: Overload signature is not compatible with function implementation. 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 (2 errors) ==== +==== tests/cases/compiler/overloadOnConstNoAnyImplementation.ts (1 errors) ==== function x1(a: number, cb: (x: 'hi') => number); - ~~ -!!! error TS2394: Overload signature is not compatible with function implementation. function x1(a: number, cb: (x: 'bye') => number); function x1(a: number, cb: (x: string) => number) { cb('hi'); diff --git a/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt b/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt index a090f370863f5..24047578ec6a1 100644 --- a/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt +++ b/tests/baselines/reference/overloadOnConstNoAnyImplementation2.errors.txt @@ -1,4 +1,3 @@ -tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(6,5): error TS2394: Overload signature is not compatible with function implementation. 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") => number' is not assignable to parameter of type '(x: "hi") => number'. Types of parameters 'x' and 'x' are incompatible. @@ -8,15 +7,13 @@ tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts(21,9): error TS2345: Type '"hi"' is not assignable to type 'number'. -==== tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts (4 errors) ==== +==== tests/cases/compiler/overloadOnConstNoAnyImplementation2.ts (3 errors) ==== interface I { x1(a: number, callback: (x: 'hi') => number); } class C { x1(a: number, callback: (x: 'hi') => number); - ~~ -!!! error TS2394: Overload signature is not compatible with function implementation. x1(a: number, callback: (x: string) => number) { callback('hi'); callback('bye'); diff --git a/tests/baselines/reference/promisePermutations.errors.txt b/tests/baselines/reference/promisePermutations.errors.txt index 8b46f18666fde..e5e7f2109a963 100644 --- a/tests/baselines/reference/promisePermutations.errors.txt +++ b/tests/baselines/reference/promisePermutations.errors.txt @@ -31,16 +31,16 @@ tests/cases/compiler/promisePermutations.ts(110,19): error TS2345: Argument of t tests/cases/compiler/promisePermutations.ts(111,19): error TS2345: Argument of type '(cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: string) => IPromise'. Types of parameters 'cb' and 'value' are incompatible. Type 'string' is not assignable to type '(a: T) => T'. -tests/cases/compiler/promisePermutations.ts(117,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations.ts(120,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations.ts(117,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations.ts(120,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations.ts(122,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations.ts(126,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(129,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/promisePermutations.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations.ts(134,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations.ts(137,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. @@ -51,8 +51,9 @@ tests/cases/compiler/promisePermutations.ts(152,12): error TS2453: The type argu 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 '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (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 'onfulfilled' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'string' is not assignable to type 'number'. + Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. + 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'. @@ -66,8 +67,9 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t Types of property 'then' are incompatible. Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (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 'onfulfilled' and 'success' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '(value: string) => IPromise' is not assignable to type '(value: number) => any'. + Types of parameters 'value' and 'value' are incompatible. + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/promisePermutations.ts (33 errors) ==== @@ -239,15 +241,15 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t var nPromise: (x: any) => Promise; var r8a = r8.then(testFunction8, testFunction8, testFunction8); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var r8b = r8.then(nIPromise, nIPromise, nIPromise).then(nIPromise, nIPromise, nIPromise); // ok var s8: Promise; var s8a = s8.then(testFunction8, testFunction8, testFunction8); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var s8b = s8.then(testFunction8P, testFunction8P, testFunction8P); // error ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. var s8c = s8.then(testFunction8P, testFunction8, testFunction8); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. @@ -256,7 +258,7 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t var r9: IPromise; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok var r9d = r9.then(testFunction, sIPromise, nIPromise); // ok @@ -268,10 +270,10 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. @@ -305,8 +307,9 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t !!! 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 '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (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 'onfulfilled' are incompatible. -!!! error TS2453: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2453: Type 'string' is not assignable to type 'number'. +!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. +!!! 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; @@ -332,8 +335,9 @@ tests/cases/compiler/promisePermutations.ts(160,21): error TS2345: Argument of t !!! error TS2345: Types of property 'then' are incompatible. !!! error TS2345: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (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 'onfulfilled' and 'success' are incompatible. -!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. +!!! error TS2345: Type '(value: string) => IPromise' is not assignable to type '(value: number) => 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 diff --git a/tests/baselines/reference/promisePermutations2.errors.txt b/tests/baselines/reference/promisePermutations2.errors.txt index 32df80e20f148..26fec6b2fd118 100644 --- a/tests/baselines/reference/promisePermutations2.errors.txt +++ b/tests/baselines/reference/promisePermutations2.errors.txt @@ -31,16 +31,16 @@ tests/cases/compiler/promisePermutations2.ts(109,19): error TS2345: Argument of tests/cases/compiler/promisePermutations2.ts(110,19): error TS2345: Argument of type '(cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: string) => IPromise'. Types of parameters 'cb' and 'value' are incompatible. Type 'string' is not assignable to type '(a: T) => T'. -tests/cases/compiler/promisePermutations2.ts(116,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations2.ts(119,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations2.ts(120,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations2.ts(116,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations2.ts(119,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations2.ts(120,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations2.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations2.ts(125,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(128,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/promisePermutations2.ts(131,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations2.ts(131,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations2.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations2.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations2.ts(136,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. @@ -51,8 +51,9 @@ tests/cases/compiler/promisePermutations2.ts(151,12): error TS2453: The type arg 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 '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. Types of parameters 'success' and 'onfulfilled' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'string' is not assignable to type 'number'. + Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. + 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'. @@ -66,8 +67,9 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of Types of property 'then' are incompatible. Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): 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 'onfulfilled' and 'success' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '(value: string) => IPromise' is not assignable to type '(value: number) => any'. + Types of parameters 'value' and 'value' are incompatible. + Type 'number' is not assignable to type 'string'. ==== tests/cases/compiler/promisePermutations2.ts (33 errors) ==== @@ -238,15 +240,15 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of var nPromise: (x: any) => Promise; var r8a = r8.then(testFunction8, testFunction8, testFunction8); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var r8b = r8.then(nIPromise, nIPromise, nIPromise).then(nIPromise, nIPromise, nIPromise); // ok var s8: Promise; var s8a = s8.then(testFunction8, testFunction8, testFunction8); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var s8b = s8.then(testFunction8P, testFunction8P, testFunction8P); // error ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. var s8c = s8.then(testFunction8P, testFunction8, testFunction8); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. @@ -255,7 +257,7 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of var r9: IPromise; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok var r9d = r9.then(testFunction, sIPromise, nIPromise); // error @@ -267,10 +269,10 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. @@ -304,8 +306,9 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! 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 '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (success?: (value: number) => U, error?: (error: any) => U, progress?: (progress: any) => void): Promise; }'. !!! error TS2453: Types of parameters 'success' and 'onfulfilled' are incompatible. -!!! error TS2453: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2453: Type 'string' is not assignable to type 'number'. +!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => IPromise'. +!!! 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; @@ -331,8 +334,9 @@ tests/cases/compiler/promisePermutations2.ts(159,21): error TS2345: Argument of !!! error TS2345: Types of property 'then' are incompatible. !!! error TS2345: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): 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 'onfulfilled' and 'success' are incompatible. -!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. +!!! error TS2345: Type '(value: string) => IPromise' is not assignable to type '(value: number) => 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 diff --git a/tests/baselines/reference/promisePermutations3.errors.txt b/tests/baselines/reference/promisePermutations3.errors.txt index 3d9fc1b2d26dd..1354f486fcb26 100644 --- a/tests/baselines/reference/promisePermutations3.errors.txt +++ b/tests/baselines/reference/promisePermutations3.errors.txt @@ -34,16 +34,16 @@ tests/cases/compiler/promisePermutations3.ts(109,19): error TS2345: Argument of tests/cases/compiler/promisePermutations3.ts(110,19): error TS2345: Argument of type '(cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: string) => IPromise'. Types of parameters 'cb' and 'value' are incompatible. Type 'string' is not assignable to type '(a: T) => T'. -tests/cases/compiler/promisePermutations3.ts(116,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations3.ts(119,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations3.ts(120,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations3.ts(116,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(119,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(120,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations3.ts(121,19): error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(125,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(128,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. Type 'string' is not assignable to type 'number'. -tests/cases/compiler/promisePermutations3.ts(131,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. -tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +tests/cases/compiler/promisePermutations3.ts(131,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +tests/cases/compiler/promisePermutations3.ts(132,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. tests/cases/compiler/promisePermutations3.ts(133,19): error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. tests/cases/compiler/promisePermutations3.ts(136,11): error TS2453: The type argument for type parameter 'U' cannot be inferred from the usage. Consider specifying the type arguments explicitly. Type argument candidate 'IPromise' is not a valid type argument because it is not a supertype of candidate 'IPromise'. @@ -54,8 +54,9 @@ tests/cases/compiler/promisePermutations3.ts(151,12): error TS2453: The type arg 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 '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (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 'onfulfilled' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'string' is not assignable to type 'number'. + Type '(value: number) => any' is not assignable to type '(value: string) => any'. + 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'. @@ -69,8 +70,9 @@ tests/cases/compiler/promisePermutations3.ts(159,21): error TS2345: Argument of Types of property 'then' are incompatible. Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (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 'onfulfilled' and 'success' are incompatible. - Types of parameters 'value' and 'value' are incompatible. - Type 'number' is not assignable to type 'string'. + Type '(value: string) => any' is not assignable to type '(value: number) => 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'. Types of property 'then' are incompatible. @@ -250,15 +252,15 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var nPromise: (x: any) => Promise; var r8a = r8.then(testFunction8, testFunction8, testFunction8); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var r8b = r8.then(nIPromise, nIPromise, nIPromise).then(nIPromise, nIPromise, nIPromise); // ok var s8: Promise; var s8a = s8.then(testFunction8, testFunction8, testFunction8); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var s8b = s8.then(testFunction8P, testFunction8P, testFunction8P); // error ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => Promise'. var s8c = s8.then(testFunction8P, testFunction8, testFunction8); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T, cb: (a: T) => T) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. @@ -267,7 +269,7 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var r9: IPromise; var r9a = r9.then(testFunction9, testFunction9, testFunction9); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var r9b = r9.then(sIPromise, sIPromise, sIPromise); // ok var r9c = r9.then(nIPromise, nIPromise, nIPromise); // ok var r9d = r9.then(testFunction, sIPromise, nIPromise); // error @@ -279,10 +281,10 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of var s9: Promise; var s9a = s9.then(testFunction9, testFunction9, testFunction9); // error ~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => IPromise' is not assignable to parameter of type '(value: number) => IPromise'. var s9b = s9.then(testFunction9P, testFunction9P, testFunction9P); // error ~~~~~~~~~~~~~~ -!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. +!!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => Promise'. var s9c = s9.then(testFunction9P, testFunction9, testFunction9); // error ~~~~~~~~~~~~~~ !!! error TS2345: Argument of type '(x: T, cb: (a: U) => U) => Promise' is not assignable to parameter of type '(value: number) => IPromise'. @@ -316,8 +318,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! 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 '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (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 'onfulfilled' are incompatible. -!!! error TS2453: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2453: Type 'string' is not assignable to type 'number'. +!!! error TS2453: Type '(value: number) => any' is not assignable to type '(value: string) => 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; @@ -343,8 +346,9 @@ tests/cases/compiler/promisePermutations3.ts(165,21): error TS2345: Argument of !!! error TS2345: Types of property 'then' are incompatible. !!! error TS2345: Type '{ (onfulfilled?: (value: number) => TResult1 | PromiseLike, onrejected?: (reason: any) => TResult2 | PromiseLike): Promise; (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 'onfulfilled' and 'success' are incompatible. -!!! error TS2345: Types of parameters 'value' and 'value' are incompatible. -!!! error TS2345: Type 'number' is not assignable to type 'string'. +!!! error TS2345: Type '(value: string) => any' is not assignable to type '(value: number) => 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 diff --git a/tests/baselines/reference/promisesWithConstraints.errors.txt b/tests/baselines/reference/promisesWithConstraints.errors.txt deleted file mode 100644 index d2c459da28486..0000000000000 --- a/tests/baselines/reference/promisesWithConstraints.errors.txt +++ /dev/null @@ -1,36 +0,0 @@ -tests/cases/compiler/promisesWithConstraints.ts(15,1): error TS2322: Type 'Promise' is not assignable to type 'Promise'. - Type 'Foo' is not assignable to type 'Bar'. - Property 'y' is missing in type 'Foo'. -tests/cases/compiler/promisesWithConstraints.ts(20,1): error TS2322: Type 'CPromise' is not assignable to type 'CPromise'. - Type 'Foo' is not assignable to type 'Bar'. - - -==== tests/cases/compiler/promisesWithConstraints.ts (2 errors) ==== - interface Promise { - then(cb: (x: T) => Promise): Promise; - } - - interface CPromise { - then(cb: (x: T) => Promise): Promise; - } - - interface Foo { x; } - interface Bar { x; y; } - - var a: Promise; - var b: Promise; - a = b; // ok - b = a; // ok - ~ -!!! error TS2322: Type 'Promise' is not assignable to type 'Promise'. -!!! error TS2322: Type 'Foo' is not assignable to type 'Bar'. -!!! error TS2322: Property 'y' is missing in type 'Foo'. - - var a2: CPromise; - var b2: CPromise; - a2 = b2; // ok - b2 = a2; // was error - ~~ -!!! error TS2322: Type 'CPromise' is not assignable to type 'CPromise'. -!!! error TS2322: Type 'Foo' is not assignable to type 'Bar'. - \ No newline at end of file diff --git a/tests/baselines/reference/recursiveTypeComparison2.errors.txt b/tests/baselines/reference/recursiveTypeComparison2.errors.txt index 71f337ad15fb4..5c1200ceec61f 100644 --- a/tests/baselines/reference/recursiveTypeComparison2.errors.txt +++ b/tests/baselines/reference/recursiveTypeComparison2.errors.txt @@ -1,9 +1,7 @@ tests/cases/compiler/recursiveTypeComparison2.ts(13,80): error TS2304: Cannot find name 'StateValue'. -tests/cases/compiler/recursiveTypeComparison2.ts(30,5): error TS2322: Type 'Bus<{}>' is not assignable to type 'Bus'. - Type '{}' is not assignable to type 'number'. -==== tests/cases/compiler/recursiveTypeComparison2.ts (2 errors) ==== +==== tests/cases/compiler/recursiveTypeComparison2.ts (1 errors) ==== // Before fix this would cause compiler to hang (#1170) declare module Bacon { @@ -35,7 +33,4 @@ tests/cases/compiler/recursiveTypeComparison2.ts(30,5): error TS2322: Type 'Bus< var Bus: new () => Bus; } - var stuck: Bacon.Bus = new Bacon.Bus(); - ~~~~~ -!!! error TS2322: Type 'Bus<{}>' is not assignable to type 'Bus'. -!!! error TS2322: Type '{}' is not assignable to type 'number'. \ No newline at end of file + var stuck: Bacon.Bus = new Bacon.Bus(); \ No newline at end of file diff --git a/tests/baselines/reference/subtypingWithCallSignatures2.types b/tests/baselines/reference/subtypingWithCallSignatures2.types index 3d0b212acceb6..8ce4b566b8651 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures2.types +++ b/tests/baselines/reference/subtypingWithCallSignatures2.types @@ -470,14 +470,14 @@ var r5 = foo5(r5arg1); // any >r5arg1 : (x: (arg: T) => U) => T var r5a = [r5arg1, r5arg2]; ->r5a : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] ->[r5arg1, r5arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>r5a : ((x: (arg: T) => U) => T)[] +>[r5arg1, r5arg2] : ((x: (arg: T) => U) => T)[] >r5arg1 : (x: (arg: T) => U) => T >r5arg2 : (x: (arg: string) => number) => string var r5b = [r5arg2, r5arg1]; ->r5b : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] ->[r5arg2, r5arg1] : (((x: (arg: T) => U) => T) | ((x: (arg: string) => number) => string))[] +>r5b : ((x: (arg: T) => U) => T)[] +>[r5arg2, r5arg1] : ((x: (arg: T) => U) => T)[] >r5arg2 : (x: (arg: string) => number) => string >r5arg1 : (x: (arg: T) => U) => T @@ -514,14 +514,14 @@ var r6 = foo6(r6arg1); // any >r6arg1 : (x: (arg: T) => U) => T var r6a = [r6arg1, r6arg2]; ->r6a : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] ->[r6arg1, r6arg2] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg1, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg1 : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: Base) => Derived) => Base var r6b = [r6arg2, r6arg1]; ->r6b : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] ->[r6arg2, r6arg1] : (((x: (arg: T) => U) => T) | ((x: (arg: Base) => Derived) => Base))[] +>r6b : ((x: (arg: T) => U) => T)[] +>[r6arg2, r6arg1] : ((x: (arg: T) => U) => T)[] >r6arg2 : (x: (arg: Base) => Derived) => Base >r6arg1 : (x: (arg: T) => U) => T @@ -564,14 +564,14 @@ var r7 = foo7(r7arg1); // any >r7arg1 : (x: (arg: T) => U) => (r: T) => U var r7a = [r7arg1, r7arg2]; ->r7a : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] ->[r7arg1, r7arg2] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>r7a : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg1, r7arg2] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg1 : (x: (arg: T) => U) => (r: T) => U >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived var r7b = [r7arg2, r7arg1]; ->r7b : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] ->[r7arg2, r7arg1] : (((x: (arg: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived) => (r: Base) => Derived))[] +>r7b : ((x: (arg: T) => U) => (r: T) => U)[] +>[r7arg2, r7arg1] : ((x: (arg: T) => U) => (r: T) => U)[] >r7arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived >r7arg1 : (x: (arg: T) => U) => (r: T) => U @@ -622,14 +622,14 @@ var r8 = foo8(r8arg1); // any >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U var r8a = [r8arg1, r8arg2]; ->r8a : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r8arg1, r8arg2] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r8a : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg1, r8arg2] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r8b = [r8arg2, r8arg1]; ->r8b : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r8arg2, r8arg1] : (((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r8b : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] +>[r8arg2, r8arg1] : ((x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U)[] >r8arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r8arg1 : (x: (arg: T) => U, y: (arg2: T) => U) => (r: T) => U @@ -681,14 +681,14 @@ var r9 = foo9(r9arg1); // any >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U var r9a = [r9arg1, r9arg2]; ->r9a : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r9arg1, r9arg2] : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r9a : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg1, r9arg2] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived var r9b = [r9arg2, r9arg1]; ->r9b : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] ->[r9arg2, r9arg1] : (((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U) | ((x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived))[] +>r9b : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] +>[r9arg2, r9arg1] : ((x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U)[] >r9arg2 : (x: (arg: Base) => Derived, y: (arg2: Base) => Derived) => (r: Base) => Derived >r9arg1 : (x: (arg: T) => U, y: (arg2: { foo: string; bing: number; }) => U) => (r: T) => U diff --git a/tests/baselines/reference/subtypingWithCallSignatures3.types b/tests/baselines/reference/subtypingWithCallSignatures3.types index d505fc7d3468f..6abc7567efb2c 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures3.types +++ b/tests/baselines/reference/subtypingWithCallSignatures3.types @@ -291,14 +291,14 @@ module Errors { >r2arg : (x: (arg: T) => U) => (r: T) => V var r2a = [r2arg2, r2arg]; ->r2a : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] ->[r2arg2, r2arg] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>r2a : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg2, r2arg] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 >r2arg : (x: (arg: T) => U) => (r: T) => V var r2b = [r2arg, r2arg2]; ->r2b : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] ->[r2arg, r2arg2] : (((x: (arg: T) => U) => (r: T) => V) | ((x: (arg: Base) => Derived) => (r: Base) => Derived2))[] +>r2b : ((x: (arg: T) => U) => (r: T) => V)[] +>[r2arg, r2arg2] : ((x: (arg: T) => U) => (r: T) => V)[] >r2arg : (x: (arg: T) => U) => (r: T) => V >r2arg2 : (x: (arg: Base) => Derived) => (r: Base) => Derived2 diff --git a/tests/baselines/reference/subtypingWithCallSignatures4.types b/tests/baselines/reference/subtypingWithCallSignatures4.types index a882d07e8ea33..5926636289abc 100644 --- a/tests/baselines/reference/subtypingWithCallSignatures4.types +++ b/tests/baselines/reference/subtypingWithCallSignatures4.types @@ -447,14 +447,14 @@ var r6 = foo6(r6arg); >r6arg : (x: (arg: T) => U) => T var r6a = [r6arg, r6arg2]; ->r6a : ((x: (arg: T) => Derived) => T)[] ->[r6arg, r6arg2] : ((x: (arg: T) => Derived) => T)[] +>r6a : ((x: (arg: T) => U) => T)[] +>[r6arg, r6arg2] : ((x: (arg: T) => U) => T)[] >r6arg : (x: (arg: T) => U) => T >r6arg2 : (x: (arg: T) => Derived) => T var r6b = [r6arg2, r6arg]; ->r6b : ((x: (arg: T) => Derived) => T)[] ->[r6arg2, r6arg] : ((x: (arg: T) => Derived) => T)[] +>r6b : ((x: (arg: T) => U) => T)[] +>[r6arg2, r6arg] : ((x: (arg: T) => U) => T)[] >r6arg2 : (x: (arg: T) => Derived) => T >r6arg : (x: (arg: T) => U) => T From 96a3c91122bcb959975f8797710c67a21853e004 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:47:38 -0700 Subject: [PATCH 8/9] Revert "Fix callback types to match covariantly" This reverts commit eebd67f8d53939e63fc54829dffec88f333ff64d. --- src/compiler/parser.ts | 2 +- src/compiler/visitor.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d355ff2458322..adce393de436a 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -57,7 +57,7 @@ namespace ts { // The visitXXX functions could be written as local functions that close over the cbNode and cbNodeArray // callback parameters, but that causes a closure allocation for each invocation with noticeable effects // on performance. - const visitNodes: (cb: ((node: Node) => T) | ((node: Node[]) => T), nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode; + const visitNodes: (cb: (node: Node | Node[]) => T, nodes: Node[]) => T = cbNodeArray ? visitNodeArray : visitEachNode; const cbNodes = cbNodeArray || cbNode; switch (node.kind) { case SyntaxKind.QualifiedName: diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 7850155ed2518..b4b46a52fee67 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -885,7 +885,7 @@ namespace ts { return initial; } - const reduceNodes: (nodes: NodeArray, f: ((memo: T, node: Node) => T) | ((memo: T, node: NodeArray) => T), initial: T) => T = cbNodeArray ? reduceNodeArray : reduceLeft; + const reduceNodes: (nodes: NodeArray, f: (memo: T, node: Node | NodeArray) => T, initial: T) => T = cbNodeArray ? reduceNodeArray : reduceLeft; const cbNodes = cbNodeArray || cbNode; const kind = node.kind; From fe0a3071c2435ac33b72568a0d4a268da9017222 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 25 Apr 2017 14:48:06 -0700 Subject: [PATCH 9/9] Revert "Treat callback parameters as strictly covariant" This reverts commit 8ae3e050759311d6cef51cc7b5067a5257b7f33c. --- src/compiler/checker.ts | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 8906ce9401849..fea692a1dcec2 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -8177,8 +8177,7 @@ namespace ts { function isSignatureAssignableTo(source: Signature, target: Signature, ignoreReturnTypes: boolean): boolean { - return compareSignaturesRelated(source, target, /*strictVariance*/ false, ignoreReturnTypes, /*reportErrors*/ false, - /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False; + return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== Ternary.False; } type ErrorReporter = (message: DiagnosticMessage, arg0?: string, arg1?: string) => void; @@ -8188,7 +8187,6 @@ namespace ts { */ function compareSignaturesRelated(source: Signature, target: Signature, - strictVariance: boolean, ignoreReturnTypes: boolean, reportErrors: boolean, errorReporter: ErrorReporter, @@ -8231,17 +8229,9 @@ namespace ts { const sourceParams = source.parameters; const targetParams = target.parameters; for (let i = 0; i < checkCount; i++) { - const sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - const targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); - const sourceSig = getSingleCallSignature(sourceType); - const targetSig = getSingleCallSignature(targetType); - // If the source and target parameters both have function types with a single call signature we are - // relating two callback parameters. In that case we compare the callback signatures with strict - // variance, meaning we require the callback parameters to be pairwise co-variant (because, similar - // to return values, callback parameters are output positions). - const related = sourceSig && targetSig ? - compareSignaturesRelated(targetSig, sourceSig, /*strictVariance*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : - !strictVariance && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); + const s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); + const t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + const related = compareTypes(s, t, /*reportErrors*/ false) || compareTypes(t, s, reportErrors); if (!related) { if (reportErrors) { errorReporter(Diagnostics.Types_of_parameters_0_and_1_are_incompatible, @@ -9241,7 +9231,7 @@ namespace ts { * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source: Signature, target: Signature, reportErrors: boolean): Ternary { - return compareSignaturesRelated(source, target, /*strictVariance*/ false, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source: Type, target: Type, kind: SignatureKind): Ternary {