diff --git a/tests/baselines/reference/genericSignatureIdentity.errors.txt b/tests/baselines/reference/genericSignatureIdentity.errors.txt new file mode 100644 index 00000000000..6aed55a1237 --- /dev/null +++ b/tests/baselines/reference/genericSignatureIdentity.errors.txt @@ -0,0 +1,36 @@ +tests/cases/compiler/genericSignatureIdentity.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '(x: T) => T', but here has type '(x: T) => T'. +tests/cases/compiler/genericSignatureIdentity.ts(14,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '(x: T) => T', but here has type '(x: T) => T'. +tests/cases/compiler/genericSignatureIdentity.ts(18,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '(x: T) => T', but here has type '(x: any) => any'. + + +==== tests/cases/compiler/genericSignatureIdentity.ts (3 errors) ==== + // This test is here to remind us of our current limits of type identity checking. + // Ideally all of the below declarations would be considered different (and thus errors) + // but they aren't because we erase type parameters to type any and don't check that + // constraints are identical. + + var x: { + (x: T): T; + }; + + var x: { + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '(x: T) => T', but here has type '(x: T) => T'. +!!! related TS6203 tests/cases/compiler/genericSignatureIdentity.ts:6:5: 'x' was also declared here. + (x: T): T; + }; + + var x: { + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '(x: T) => T', but here has type '(x: T) => T'. +!!! related TS6203 tests/cases/compiler/genericSignatureIdentity.ts:6:5: 'x' was also declared here. + (x: T): T; + }; + + var x: { + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type '(x: T) => T', but here has type '(x: any) => any'. +!!! related TS6203 tests/cases/compiler/genericSignatureIdentity.ts:6:5: 'x' was also declared here. + (x: any): any; + }; + \ No newline at end of file diff --git a/tests/baselines/reference/identityForSignaturesWithTypeParametersAndAny.errors.txt b/tests/baselines/reference/identityForSignaturesWithTypeParametersAndAny.errors.txt index 092bfaaeeb3..11fb2950aa8 100644 --- a/tests/baselines/reference/identityForSignaturesWithTypeParametersAndAny.errors.txt +++ b/tests/baselines/reference/identityForSignaturesWithTypeParametersAndAny.errors.txt @@ -1,12 +1,16 @@ +tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: T, y: U) => T', but here has type '(x: any, y: any) => any'. tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(5,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'g' must be of type '(x: T, y: U) => T', but here has type '(x: any, y: any) => any'. tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(8,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'h' must be of type '(x: T, y: U) => T', but here has type '(x: any, y: any) => any'. tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(11,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'i' must be of type '(x: T, y: U) => T', but here has type '(x: any, y: string) => any'. tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts(14,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'j' must be of type '(x: T, y: U) => T', but here has type '(x: any, y: any) => string'. -==== tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts (4 errors) ==== +==== tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts (5 errors) ==== var f: (x: T, y: U) => T; var f: (x: any, y: any) => any; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: T, y: U) => T', but here has type '(x: any, y: any) => any'. +!!! related TS6203 tests/cases/compiler/identityForSignaturesWithTypeParametersAndAny.ts:1:5: 'f' was also declared here. var g: (x: T, y: U) => T; var g: (x: any, y: any) => any; diff --git a/tests/baselines/reference/identityForSignaturesWithTypeParametersSwitched.errors.txt b/tests/baselines/reference/identityForSignaturesWithTypeParametersSwitched.errors.txt new file mode 100644 index 00000000000..81d0eb6c961 --- /dev/null +++ b/tests/baselines/reference/identityForSignaturesWithTypeParametersSwitched.errors.txt @@ -0,0 +1,9 @@ +tests/cases/compiler/identityForSignaturesWithTypeParametersSwitched.ts(2,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: T, y: U) => T', but here has type '(x: U, y: T) => U'. + + +==== tests/cases/compiler/identityForSignaturesWithTypeParametersSwitched.ts (1 errors) ==== + var f: (x: T, y: U) => T; + var f: (x: U, y: T) => U; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'f' must be of type '(x: T, y: U) => T', but here has type '(x: U, y: T) => U'. +!!! related TS6203 tests/cases/compiler/identityForSignaturesWithTypeParametersSwitched.ts:1:5: 'f' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/promiseIdentity.errors.txt b/tests/baselines/reference/promiseIdentity.errors.txt new file mode 100644 index 00000000000..b104dc68e5f --- /dev/null +++ b/tests/baselines/reference/promiseIdentity.errors.txt @@ -0,0 +1,28 @@ +tests/cases/compiler/promiseIdentity.ts(21,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'IPromise2', but here has type 'Promise2'. + + +==== tests/cases/compiler/promiseIdentity.ts (1 errors) ==== + export interface IPromise { + then(callback: (x: T) => IPromise): IPromise; + } + interface Promise { + then(callback: (x: T) => Promise): Promise; + } + var x: IPromise; + var x: Promise; + + + interface IPromise2 { + then(callback: (x: T) => IPromise2): IPromise2; + } + interface Promise2 { + then(callback: (x: V) => Promise2): Promise2; // Uses V instead of T in callback's parameter + } + + // Ok because T in this particular Promise2 is any, as are all the U and W references. + // Also, the V of Promise2 happens to coincide with the T of IPromise2 (they are both string). + var y: IPromise2; + var y: Promise2; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'y' must be of type 'IPromise2', but here has type 'Promise2'. +!!! related TS6203 tests/cases/compiler/promiseIdentity.ts:20:5: 'y' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/promiseIdentityWithAny.errors.txt b/tests/baselines/reference/promiseIdentityWithAny.errors.txt new file mode 100644 index 00000000000..c318925c617 --- /dev/null +++ b/tests/baselines/reference/promiseIdentityWithAny.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/promiseIdentityWithAny.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'IPromise', but here has type 'Promise'. + + +==== tests/cases/compiler/promiseIdentityWithAny.ts (1 errors) ==== + export interface IPromise { + then(callback: (x: T) => IPromise): IPromise; + } + export interface Promise { + then(callback: (x: T) => Promise): Promise; + } + + // Should be ok because signature type parameters get erased to any + var x: IPromise; + var x: Promise; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'IPromise', but here has type 'Promise'. +!!! related TS6203 tests/cases/compiler/promiseIdentityWithAny.ts:9:5: 'x' was also declared here. \ No newline at end of file diff --git a/tests/baselines/reference/promiseIdentityWithConstraints.errors.txt b/tests/baselines/reference/promiseIdentityWithConstraints.errors.txt new file mode 100644 index 00000000000..9b72f8363ed --- /dev/null +++ b/tests/baselines/reference/promiseIdentityWithConstraints.errors.txt @@ -0,0 +1,17 @@ +tests/cases/compiler/promiseIdentityWithConstraints.ts(10,5): error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'IPromise', but here has type 'Promise'. + + +==== tests/cases/compiler/promiseIdentityWithConstraints.ts (1 errors) ==== + export interface IPromise { + then(callback: (x: T) => IPromise): IPromise; + } + export interface Promise { + then(callback: (x: T) => Promise): Promise; + } + + // Error because constraint V doesn't match + var x: IPromise; + var x: Promise; + ~ +!!! error TS2403: Subsequent variable declarations must have the same type. Variable 'x' must be of type 'IPromise', but here has type 'Promise'. +!!! related TS6203 tests/cases/compiler/promiseIdentityWithConstraints.ts:9:5: 'x' was also declared here. \ No newline at end of file