我正在尝试使打字稿发出警告,以将错误的类解释为通用类型参数。
预期结果:
class A { }
class B extends A { }
class C<T extends A> { }
const instance1 = new C<A>(); // error: wrong type
const instance2 = new C<B>(); // success: inherited type
实际结果:
class A { }
class B extends A { }
class C<T extends A> { }
const instance1 = new C<A>(); // success: but the type is wrong
const instance2 = new C<B>(); // success: inherited type