-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Milestone
Description
Adapted from #3275:
class GenericThingamabob<T> {
constructor(private entity: T) {}
add(item: T) { }
}
class CouponInfo {
private couponTag: {};
}
class Snake {
private snakeTag: {};
}
var blah = new GenericThingamabob(new CouponInfo());
blah.add(new Snake());
// ~~~~~~~~~~~
var x: CouponInfo = new Snake();
// ~On the first error, I get
Argument of type 'Snake' is not assignable to parameter of type 'CouponInfo'.
Property 'couponTag' is missing in type 'Snake'
On the second, I get
Type 'Snake' is not assignable to type 'CouponInfo'.
Note that if you turned blah.add(new Snake()); into a variable assignment like var a: CouponInfo = new Snake(), you'll get the same issue.
Reactions are currently unavailable