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
As you can see, at the end there I'm forced to cast rank and suit, they should be inferred. If I change lib.d.ts to have the signature I suggest, it correctly infers the types there. It shouldn't cause edge cases or break code as I can't imagine there's any code that expects Object.keys to return a string that's not a key of that object.
The above code is MIT license btw, if anyone feels like using it.
The text was updated successfully, but these errors were encountered:
The signature of Object.getOwnPropertyNames is
getOwnPropertyNames(o: any): string[];
Would it be possible to get
getOwnPropertyNames<T>(o: T): (keyof T)[];
instead?The same for Object.keys:
keys<T>(o: T): (keyof T)[];
If I'm correct, this doesn't cause any edge cases, but allows us to write more typesafe code. Right now, I'm forced to cast some things.
Here's a toy example:
As you can see, at the end there I'm forced to cast rank and suit, they should be inferred. If I change lib.d.ts to have the signature I suggest, it correctly infers the types there. It shouldn't cause edge cases or break code as I can't imagine there's any code that expects Object.keys to return a string that's not a key of that object.
The above code is MIT license btw, if anyone feels like using it.
The text was updated successfully, but these errors were encountered: