49 lines
1.3 KiB
Plaintext
49 lines
1.3 KiB
Plaintext
|
=== tests/cases/compiler/contextualSignatureInstatiationCovariance.ts ===
|
||
|
interface Animal { x }
|
||
|
>Animal : Animal
|
||
|
>x : any
|
||
|
|
||
|
interface TallThing { x2 }
|
||
|
>TallThing : TallThing
|
||
|
>x2 : any
|
||
|
|
||
|
interface Giraffe extends Animal, TallThing { y }
|
||
|
>Giraffe : Giraffe
|
||
|
>Animal : Animal
|
||
|
>TallThing : TallThing
|
||
|
>y : any
|
||
|
|
||
|
var f2: <T extends Giraffe>(x: T, y: T) => void;
|
||
|
>f2 : <T extends Giraffe>(x: T, y: T) => void
|
||
|
>T : T
|
||
|
>Giraffe : Giraffe
|
||
|
>x : T
|
||
|
>T : T
|
||
|
>y : T
|
||
|
>T : T
|
||
|
|
||
|
var g2: (a: Animal, t: TallThing) => void;
|
||
|
>g2 : (a: Animal, t: TallThing) => void
|
||
|
>a : Animal
|
||
|
>Animal : Animal
|
||
|
>t : TallThing
|
||
|
>TallThing : TallThing
|
||
|
|
||
|
g2 = f2; // While neither Animal nor TallThing satisfy the constraint, T is at worst a Giraffe and compatible with both via covariance.
|
||
|
>g2 = f2 : <T extends Giraffe>(x: T, y: T) => void
|
||
|
>g2 : (a: Animal, t: TallThing) => void
|
||
|
>f2 : <T extends Giraffe>(x: T, y: T) => void
|
||
|
|
||
|
var h2: (a1: Animal, a2: Animal) => void;
|
||
|
>h2 : (a1: Animal, a2: Animal) => void
|
||
|
>a1 : Animal
|
||
|
>Animal : Animal
|
||
|
>a2 : Animal
|
||
|
>Animal : Animal
|
||
|
|
||
|
h2 = f2; // Animal does not satisfy the constraint, but T is at worst a Giraffe and compatible with Animal via covariance.
|
||
|
>h2 = f2 : <T extends Giraffe>(x: T, y: T) => void
|
||
|
>h2 : (a1: Animal, a2: Animal) => void
|
||
|
>f2 : <T extends Giraffe>(x: T, y: T) => void
|
||
|
|