mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-11 06:02:53 -05:00
Adding regression test
This commit is contained in:
14
tests/baselines/reference/unionTypeParameterInference.js
Normal file
14
tests/baselines/reference/unionTypeParameterInference.js
Normal file
@@ -0,0 +1,14 @@
|
||||
//// [unionTypeParameterInference.ts]
|
||||
interface Foo<T> { prop: T; }
|
||||
|
||||
declare function lift<U>(value: U | Foo<U>): Foo<U>;
|
||||
|
||||
function unlift<U>(value: U | Foo<U>): U {
|
||||
return lift(value).prop; // error TS2322: Type '{}' is not assignable to type 'U'.
|
||||
}
|
||||
|
||||
|
||||
//// [unionTypeParameterInference.js]
|
||||
function unlift(value) {
|
||||
return lift(value).prop; // error TS2322: Type '{}' is not assignable to type 'U'.
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/compiler/unionTypeParameterInference.ts ===
|
||||
interface Foo<T> { prop: T; }
|
||||
>Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0))
|
||||
>T : Symbol(T, Decl(unionTypeParameterInference.ts, 0, 14))
|
||||
>prop : Symbol(prop, Decl(unionTypeParameterInference.ts, 0, 18))
|
||||
>T : Symbol(T, Decl(unionTypeParameterInference.ts, 0, 14))
|
||||
|
||||
declare function lift<U>(value: U | Foo<U>): Foo<U>;
|
||||
>lift : Symbol(lift, Decl(unionTypeParameterInference.ts, 0, 29))
|
||||
>U : Symbol(U, Decl(unionTypeParameterInference.ts, 2, 22))
|
||||
>value : Symbol(value, Decl(unionTypeParameterInference.ts, 2, 25))
|
||||
>U : Symbol(U, Decl(unionTypeParameterInference.ts, 2, 22))
|
||||
>Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0))
|
||||
>U : Symbol(U, Decl(unionTypeParameterInference.ts, 2, 22))
|
||||
>Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0))
|
||||
>U : Symbol(U, Decl(unionTypeParameterInference.ts, 2, 22))
|
||||
|
||||
function unlift<U>(value: U | Foo<U>): U {
|
||||
>unlift : Symbol(unlift, Decl(unionTypeParameterInference.ts, 2, 52))
|
||||
>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 16))
|
||||
>value : Symbol(value, Decl(unionTypeParameterInference.ts, 4, 19))
|
||||
>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 16))
|
||||
>Foo : Symbol(Foo, Decl(unionTypeParameterInference.ts, 0, 0))
|
||||
>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 16))
|
||||
>U : Symbol(U, Decl(unionTypeParameterInference.ts, 4, 16))
|
||||
|
||||
return lift(value).prop; // error TS2322: Type '{}' is not assignable to type 'U'.
|
||||
>lift(value).prop : Symbol(Foo.prop, Decl(unionTypeParameterInference.ts, 0, 18))
|
||||
>lift : Symbol(lift, Decl(unionTypeParameterInference.ts, 0, 29))
|
||||
>value : Symbol(value, Decl(unionTypeParameterInference.ts, 4, 19))
|
||||
>prop : Symbol(Foo.prop, Decl(unionTypeParameterInference.ts, 0, 18))
|
||||
}
|
||||
|
||||
34
tests/baselines/reference/unionTypeParameterInference.types
Normal file
34
tests/baselines/reference/unionTypeParameterInference.types
Normal file
@@ -0,0 +1,34 @@
|
||||
=== tests/cases/compiler/unionTypeParameterInference.ts ===
|
||||
interface Foo<T> { prop: T; }
|
||||
>Foo : Foo<T>
|
||||
>T : T
|
||||
>prop : T
|
||||
>T : T
|
||||
|
||||
declare function lift<U>(value: U | Foo<U>): Foo<U>;
|
||||
>lift : <U>(value: U | Foo<U>) => Foo<U>
|
||||
>U : U
|
||||
>value : U | Foo<U>
|
||||
>U : U
|
||||
>Foo : Foo<T>
|
||||
>U : U
|
||||
>Foo : Foo<T>
|
||||
>U : U
|
||||
|
||||
function unlift<U>(value: U | Foo<U>): U {
|
||||
>unlift : <U>(value: U | Foo<U>) => U
|
||||
>U : U
|
||||
>value : U | Foo<U>
|
||||
>U : U
|
||||
>Foo : Foo<T>
|
||||
>U : U
|
||||
>U : U
|
||||
|
||||
return lift(value).prop; // error TS2322: Type '{}' is not assignable to type 'U'.
|
||||
>lift(value).prop : U
|
||||
>lift(value) : Foo<U>
|
||||
>lift : <U>(value: U | Foo<U>) => Foo<U>
|
||||
>value : U | Foo<U>
|
||||
>prop : U
|
||||
}
|
||||
|
||||
7
tests/cases/compiler/unionTypeParameterInference.ts
Normal file
7
tests/cases/compiler/unionTypeParameterInference.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
interface Foo<T> { prop: T; }
|
||||
|
||||
declare function lift<U>(value: U | Foo<U>): Foo<U>;
|
||||
|
||||
function unlift<U>(value: U | Foo<U>): U {
|
||||
return lift(value).prop; // error TS2322: Type '{}' is not assignable to type 'U'.
|
||||
}
|
||||
Reference in New Issue
Block a user