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
Expected behavior:
I expected to be able to assign something to x. (As my coworkers explained to me) In this case, you can't assign anything to x, because "T extends foo" means T is subtype of foo (Not the other way around).
Second Expected behavior:
Given above, I think it would be nice if TS allowed something like:
The first example is wrong as you already noted. Baz<number> is a valid instantiation, and thus x: number = "a" is invalid.
The second is tracked by #14520
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: all
Code
Expected behavior:
I expected to be able to assign something to x. (As my coworkers explained to me) In this case, you can't assign anything to x, because "T extends foo" means T is subtype of foo (Not the other way around).
Second Expected behavior:
Given above, I think it would be nice if TS allowed something like:
Or maybe something like below (which i heard is supported in Java)?
The text was updated successfully, but these errors were encountered: