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
I'd like to use keyof to add strong typings to that function, but can't traverse the numeric indexer to get the indexed type. Something like this works if i index using strings instead:
TypeScript Version: 2.1.6
I have a collection of entities mapped by numeric ID, and a function that plucks a single property out of the collection:
I'd like to use
keyof
to add strong typings to that function, but can't traverse the numeric indexer to get the indexed type. Something like this works if i index using strings instead:This works, i think, because
keyof {[key: string]: T}
isstring
, but wont work when indexing by number becausekeyof {[key: number]: T}
isnever
.I've been able to work around this limitation by doing this:
But that feels hackish, and if
keyof
is supported for string indexers then i feel it should probably work for the numeric case too.The text was updated successfully, but these errors were encountered: