You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//Given abstract generic class
interface IA {
id: string;
}
abstract class A<TA extends IA> {
abstract save(): TA
}
//Given that's class concerete implementation
interface IB extends IA {
name: string;
}
class B extends A<IB>
{
save(): IB {
return null as any as IB;
}
}
//How to enforce the "matching" types?
class C {
callSave<TClass extends A<TInterface>,
TInterface extends IA>(): TInterface {
return null as any as TInterface;
}
}
var c = new C();
//In C# that would fail
c.callSave<B, IA>();
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.6.2
Search Terms:
Generic, parameter, constraint
Code
Expected behavior:
Code does not compile
Actual behavior:
Code compiles
Playground Link:
link
Related Issues:
#21249
The text was updated successfully, but these errors were encountered: