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:
Not absolutely sure, but I would like to be able to reason about T[keyof T] in terms of the types I already known - either it should behave like {} | null | undefined or like never. Or maybe I shouldn't be allowed to write that type.
Actual behavior: Type 'T[keyof T]' is not assignable to type '{} | null | undefined'.
We noticed this during upgrading TS2.6 to TS2.7. It appears in TS2.6 this assignment was allowed for if one wrote Bounded<T extends {}>, where as in 2.7 and 2.8 that makes no difference. As expected when then lower bound has actual keys, they are used.
P.S. I miss the TS spec.
The text was updated successfully, but these errors were encountered:
rkirov
changed the title
Unclear what is the type T[keyof T] for a generic T is assignable to
Unclear what is T[keyof T] for a generic T assignable to
Apr 4, 2018
Search Terms:
T[keyof T]
Code
Expected behavior:
Not absolutely sure, but I would like to be able to reason about
T[keyof T]
in terms of the types I already known - either it should behave like{} | null | undefined
or likenever
. Or maybe I shouldn't be allowed to write that type.Actual behavior:
Type 'T[keyof T]' is not assignable to type '{} | null | undefined'.
We noticed this during upgrading TS2.6 to TS2.7. It appears in TS2.6 this assignment was allowed for if one wrote
Bounded<T extends {}>
, where as in 2.7 and 2.8 that makes no difference. As expected when then lower bound has actual keys, they are used.P.S. I miss the TS spec.
The text was updated successfully, but these errors were encountered: