1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
=== tests/cases/compiler/typeArgumentInferenceWithConstraintAsCommonRoot.ts ===
interface Animal { x }
>Animal : Symbol(Animal, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 0, 0))
>x : Symbol(Animal.x, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 0, 18))
interface Giraffe extends Animal { y }
>Giraffe : Symbol(Giraffe, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 0, 22))
>Animal : Symbol(Animal, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 0, 0))
>y : Symbol(Giraffe.y, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 1, 34))
interface Elephant extends Animal { z }
>Elephant : Symbol(Elephant, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 1, 38))
>Animal : Symbol(Animal, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 0, 0))
>z : Symbol(Elephant.z, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 2, 35))
function f<T extends Animal>(x: T, y: T): T { return undefined; }
>f : Symbol(f, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 2, 39))
>T : Symbol(T, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 3, 11))
>Animal : Symbol(Animal, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 0, 0))
>x : Symbol(x, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 3, 29))
>T : Symbol(T, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 3, 11))
>y : Symbol(y, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 3, 34))
>T : Symbol(T, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 3, 11))
>T : Symbol(T, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 3, 11))
>undefined : Symbol(undefined)
var g: Giraffe;
>g : Symbol(g, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 4, 3))
>Giraffe : Symbol(Giraffe, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 0, 22))
var e: Elephant;
>e : Symbol(e, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 5, 3))
>Elephant : Symbol(Elephant, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 1, 38))
f(g, e); // valid because both Giraffe and Elephant satisfy the constraint. T is Animal
>f : Symbol(f, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 2, 39))
>g : Symbol(g, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 4, 3))
>e : Symbol(e, Decl(typeArgumentInferenceWithConstraintAsCommonRoot.ts, 5, 3))
|