Skip to content

Commit 10c9fbc

Browse files
committed
Accept new baselines
1 parent ea0a6de commit 10c9fbc

6 files changed

+112
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
tests/cases/compiler/genericSignatureIdentity.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '<T extends Date>(x: T) => T', but here has type '<T extends number>(x: T) => T'.
2+
tests/cases/compiler/genericSignatureIdentity.ts(14,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '<T extends Date>(x: T) => T', but here has type '<T>(x: T) => T'.
3+
tests/cases/compiler/genericSignatureIdentity.ts(18,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '<T extends Date>(x: T) => T', but here has type '<T>(x: any) => any'.
4+
5+
6+
==== tests/cases/compiler/genericSignatureIdentity.ts (3 errors) ====
7+
// This test is here to remind us of our current limits of type identity checking.
8+
// Ideally all of the below declarations would be considered different (and thus errors)
9+
// but they aren't because we erase type parameters to type any and don't check that
10+
// constraints are identical.
11+
12+
var x: {
13+
<T extends Date>(x: T): T;
14+
};
15+
16+
var x: {
17+
~
18+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '<T extends Date>(x: T) => T', but here has type '<T extends number>(x: T) => T'.
19+
!!! related TS6203 tests/cases/compiler/genericSignatureIdentity.ts:6:5: 'x' was also declared here.
20+
<T extends number>(x: T): T;
21+
};
22+
23+
var x: {
24+
~
25+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '<T extends Date>(x: T) => T', but here has type '<T>(x: T) => T'.
26+
!!! related TS6203 tests/cases/compiler/genericSignatureIdentity.ts:6:5: 'x' was also declared here.
27+
<T>(x: T): T;
28+
};
29+
30+
var x: {
31+
~
32+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '<T extends Date>(x: T) => T', but here has type '<T>(x: any) => any'.
33+
!!! related TS6203 tests/cases/compiler/genericSignatureIdentity.ts:6:5: 'x' was also declared here.
34+
<T>(x: any): any;
35+
};
36+

tests/baselines/reference/identityForSignaturesWithTypeParametersAndAny.errors.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '<T, U>(x: T, y: U) => T', but here has type '<T, U>(x: any, y: any) => any'.
12
tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(5,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'g' must be of type '<T, U>(x: T, y: U) => T', but here has type '<T>(x: any, y: any) => any'.
23
tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(8,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'h' must be of type '<T, U>(x: T, y: U) => T', but here has type '(x: any, y: any) => any'.
34
tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type '<T, U>(x: T, y: U) => T', but here has type '<T, U>(x: any, y: string) => any'.
45
tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(14,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'j' must be of type '<T, U>(x: T, y: U) => T', but here has type '<T, U>(x: any, y: any) => string'.
56

67

7-
==== tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts (4 errors) ====
8+
==== tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts (5 errors) ====
89
var f: <T, U>(x: T, y: U) => T;
910
var f: <T, U>(x: any, y: any) => any;
11+
~
12+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '<T, U>(x: T, y: U) => T', but here has type '<T, U>(x: any, y: any) => any'.
13+
!!! related TS6203 tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts:1:5: 'f' was also declared here.
1014

1115
var g: <T, U>(x: T, y: U) => T;
1216
var g: <T>(x: any, y: any) => any;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tests/cases/compiler/identityForSignaturesWithTypeParametersSwitched.ts(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '<T, U>(x: T, y: U) => T', but here has type '<T, U>(x: U, y: T) => U'.
2+
3+
4+
==== tests/cases/compiler/identityForSignaturesWithTypeParametersSwitched.ts (1 errors) ====
5+
var f: <T, U>(x: T, y: U) => T;
6+
var f: <T, U>(x: U, y: T) => U;
7+
~
8+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '<T, U>(x: T, y: U) => T', but here has type '<T, U>(x: U, y: T) => U'.
9+
!!! related TS6203 tests/cases/compiler/identityForSignaturesWithTypeParametersSwitched.ts:1:5: 'f' was also declared here.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
tests/cases/compiler/promiseIdentity.ts(21,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'IPromise2<string, number>', but here has type 'Promise2<any, string>'.
2+
3+
4+
==== tests/cases/compiler/promiseIdentity.ts (1 errors) ====
5+
export interface IPromise<T> {
6+
then<U>(callback: (x: T) => IPromise<U>): IPromise<U>;
7+
}
8+
interface Promise<T> {
9+
then<U>(callback: (x: T) => Promise<U>): Promise<U>;
10+
}
11+
var x: IPromise<string>;
12+
var x: Promise<string>;
13+
14+
15+
interface IPromise2<T, V> {
16+
then<U, W>(callback: (x: T) => IPromise2<U, W>): IPromise2<W, U>;
17+
}
18+
interface Promise2<T, V> {
19+
then<U, W>(callback: (x: V) => Promise2<U, T>): Promise2<T, W>; // Uses V instead of T in callback's parameter
20+
}
21+
22+
// Ok because T in this particular Promise2 is any, as are all the U and W references.
23+
// Also, the V of Promise2 happens to coincide with the T of IPromise2 (they are both string).
24+
var y: IPromise2<string, number>;
25+
var y: Promise2<any, string>;
26+
~
27+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'IPromise2<string, number>', but here has type 'Promise2<any, string>'.
28+
!!! related TS6203 tests/cases/compiler/promiseIdentity.ts:20:5: 'y' was also declared here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tests/cases/compiler/promiseIdentityWithAny.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'IPromise<string, number>', but here has type 'Promise<string, boolean>'.
2+
3+
4+
==== tests/cases/compiler/promiseIdentityWithAny.ts (1 errors) ====
5+
export interface IPromise<T, V> {
6+
then<U, W>(callback: (x: T) => IPromise<U, W>): IPromise<U, W>;
7+
}
8+
export interface Promise<T, V> {
9+
then<U, W>(callback: (x: T) => Promise<any, any>): Promise<any, any>;
10+
}
11+
12+
// Should be ok because signature type parameters get erased to any
13+
var x: IPromise<string, number>;
14+
var x: Promise<string, boolean>;
15+
~
16+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'IPromise<string, number>', but here has type 'Promise<string, boolean>'.
17+
!!! related TS6203 tests/cases/compiler/promiseIdentityWithAny.ts:9:5: 'x' was also declared here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
tests/cases/compiler/promiseIdentityWithConstraints.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'IPromise<string, number>', but here has type 'Promise<string, boolean>'.
2+
3+
4+
==== tests/cases/compiler/promiseIdentityWithConstraints.ts (1 errors) ====
5+
export interface IPromise<T, V> {
6+
then<U extends T, W extends V>(callback: (x: T) => IPromise<U, W>): IPromise<U, W>;
7+
}
8+
export interface Promise<T, V> {
9+
then<U extends T, W extends V>(callback: (x: T) => Promise<U, W>): Promise<U, W>;
10+
}
11+
12+
// Error because constraint V doesn't match
13+
var x: IPromise<string, number>;
14+
var x: Promise<string, boolean>;
15+
~
16+
!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'IPromise<string, number>', but here has type 'Promise<string, boolean>'.
17+
!!! related TS6203 tests/cases/compiler/promiseIdentityWithConstraints.ts:9:5: 'x' was also declared here.

0 commit comments

Comments
 (0)