Files

26 lines
712 B
Plaintext

covariance1.ts(11,10): error TS2454: Variable 'a' is used before being assigned.
covariance1.ts(14,10): error TS2454: Variable 'b' is used before being assigned.
==== covariance1.ts (2 errors) ====
namespace M {
interface X { m1:number; }
export class XX implements X { constructor(public m1:number) { } }
interface Y { x:X; }
export function f(y:Y) { }
var a:X;
f({x:a}); // ok
~
!!! error TS2454: Variable 'a' is used before being assigned.
var b:XX;
f({x:b}); // ok covariant subtype
~
!!! error TS2454: Variable 'b' is used before being assigned.
}