Skip to content

Commit c48c363

Browse files
committed
Update tests
1 parent 529ed2d commit c48c363

8 files changed

+10
-10
lines changed

tests/cases/compiler/contextualSignatureInstatiationContravariance.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ interface Elephant extends Animal { y2 }
55
var f2: <T extends Animal>(x: T, y: T) => void;
66

77
var g2: (g: Giraffe, e: Elephant) => void;
8-
g2 = f2; // valid because both Giraffe and Elephant satisfy the constraint. T is Animal
8+
g2 = f2; // error because Giraffe and Elephant are disjoint types
99

1010
var h2: (g1: Giraffe, g2: Giraffe) => void;
1111
h2 = f2; // valid because Giraffe satisfies the constraint. It is safe in the traditional contravariant fashion.

tests/cases/conformance/types/typeRelationships/assignmentCompatibility/assignmentCompatWithGenericCallSignatures2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ interface B {
1111
var a: A;
1212
var b: B;
1313

14-
// Both ok
14+
// Both errors
1515
a = b;
1616
b = a;

tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ interface I extends A {
6161
a11: <T extends Base>(x: T, y: T) => T; // ok
6262
a12: <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
6363
a13: <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
64-
a14: <T>(x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature
64+
a14: <T, U>(x: { a: T; b: U }) => T; // ok
6565
a15: <T>(x: T) => T[]; // ok
6666
a16: <T extends Base>(x: T) => number[]; // ok
6767
a17: <T>(x: (a: T) => T) => T[]; // ok

tests/cases/conformance/types/typeRelationships/assignmentCompatibility/callSignatureAssignabilityInInheritance5.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ interface I extends B {
4444
a11: <T extends Base>(x: T, y: T) => T; // ok
4545
a12: <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
4646
a13: <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
47-
a14: <T>(x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature
47+
a14: <T, U>(x: { a: T; b: U }) => T; // ok
4848
}

tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ interface I extends A {
6161
a11: new <T extends Base>(x: T, y: T) => T; // ok
6262
a12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
6363
a13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
64-
a14: new <T>(x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature
64+
a14: new <T, U>(x: { a: T; b: U }) => T; // ok
6565
a15: new <T>(x: T) => T[]; // ok
6666
a16: new <T extends Base>(x: T) => number[]; // ok
6767
a17: new <T>(x: new (a: T) => T) => T[]; // ok

tests/cases/conformance/types/typeRelationships/assignmentCompatibility/constructSignatureAssignabilityInInheritance5.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ interface I extends B {
4444
a11: new <T extends Base>(x: T, y: T) => T; // ok
4545
a12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
4646
a13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
47-
a14: new <T>(x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature
47+
a14: new <T, U>(x: { a: T; b: U }) => T; // ok
4848
}

tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithConstructSignatures5.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ interface I extends B {
4444
a11: new <T extends Base>(x: T, y: T) => T; // ok
4545
a12: new <T extends Array<Base>>(x: Array<Base>, y: T) => Array<Derived>; // ok, less specific parameter type
4646
a13: new <T extends Array<Derived>>(x: Array<Base>, y: T) => T; // ok, T = Array<Derived>, satisfies constraint, contextual signature instantiation succeeds
47-
a14: new <T>(x: { a: T; b: T }) => T; // ok, best common type yields T = {} but that's satisfactory for this signature
47+
a14: new <T, U>(x: { a: T; b: U }) => T; // ok
4848
}

tests/cases/conformance/types/typeRelationships/typeInference/contextualSignatureInstantiation.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ var a = bar(1, 1, g); // Should be number
1616
var a = baz(1, 1, g); // Should be number
1717

1818
var b: number | string;
19-
var b = foo(g); // Should be number | string
20-
var b = bar(1, "one", g); // Should be number | string
21-
var b = bar("one", 1, g); // Should be number | string
19+
var b = foo(g); // Error, number and string are disjoint types
20+
var b = bar(1, "one", g); // Error, number and string are disjoint types
21+
var b = bar("one", 1, g); // Error, number and string are disjoint types
2222
var b = baz(b, b, g); // Should be number | string
2323

2424
var d: number[] | string[];

0 commit comments

Comments
 (0)