Change test to use type variables

This commit is contained in:
Anders Hejlsberg 2018-03-25 15:30:46 -07:00 committed by Mohamed Hegazy
parent ca3d0d37a7
commit 072401e29f

View File

@ -13,21 +13,17 @@ interface Invariant<T> {
foo: T extends string ? keyof T : T;
}
interface A { a: string }
interface B extends A { b: string }
function f1(a: Covariant<A>, b: Covariant<B>) {
function f1<A, B extends A>(a: Covariant<A>, b: Covariant<B>) {
a = b;
b = a; // Error
}
function f2(a: Contravariant<A>, b: Contravariant<B>) {
function f2<A, B extends A>(a: Contravariant<A>, b: Contravariant<B>) {
a = b; // Error
b = a;
}
function f3(a: Invariant<A>, b: Invariant<B>) {
function f3<A, B extends A>(a: Invariant<A>, b: Invariant<B>) {
a = b; // Error
b = a; // Error
}