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
Argument of type 'string' is not assignable to parameter of type '"a"'.
The obvious solution here is to make the type definition for Object.keys return keyof property, and I'm happy to submit that small PR to the appropriate lib files:
// within the Object type definitionkeys<T,KextendskeyofT>(o: T): K[];
This automatically works everywhere that Object.keys works today because (keyof T)[] is always a proper subtype of string[].
This resolves it nicely. However, I'm unsure what the relationship between the versions of the typings in lib here and TS versions is – do they need to be backwards compatible to previous versions of TS? Otherwise, as noted, I'll happily open that PR.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 2.6.2 (but
tsc
isn't the problem here; the typings are).Code
Expected behavior:
This should type-check!
Actual behavior:
The obvious solution here is to make the type definition for
Object.keys
returnkeyof
property, and I'm happy to submit that small PR to the appropriate lib files:This automatically works everywhere that
Object.keys
works today because(keyof T)[]
is always a proper subtype ofstring[]
.This resolves it nicely. However, I'm unsure what the relationship between the versions of the typings in
lib
here and TS versions is – do they need to be backwards compatible to previous versions of TS? Otherwise, as noted, I'll happily open that PR.The text was updated successfully, but these errors were encountered: