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
functionset<T,KextendskeyofT>(obj: T,key: K,value: T[K]){obj[key]=value;}varO={a: "string"};// var k: keyof typeof O;for(varkinO){set(O,k,"another");// string is not assignable to "a"}
The text was updated successfully, but these errors were encountered:
I have my doubts about this one. In for (var k in x) where x is of some type T, it is only safe to say that k is of type keyof T when the exact type of x is T. If the actual type of x is a subtype of T, as is permitted by our assignment compatibility rules, you will see values in k that are not of type keyof T.
The same argument holds for the built-in Object.keys() method.
The text was updated successfully, but these errors were encountered: