Unclear what is T[keyof T]
for a generic T
assignable to
#23133
Milestone
T[keyof T]
for a generic T
assignable to
#23133
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: