-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Object.fromEntries
loses all types on the key
#49305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See also: #37457 (comment) I just noted that this doesn't work because it's possible to omit a particular row in Apparently fromEntries<K extends PropertyKey, T = any>(entries: Iterable<readonly [K, T]>): { [k: K]: T }; doesn't work either |
Essentially a duplicate of #35745 but that issue has been closed without resolution. |
It wouldn't be correct to do this, because the type of an array tells you want might be in it, not what is in it. For example, |
This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Why not type it as |
lib Update Request
Configuration Check
My compilation target is
es2020
and my lib isES2020
.Missing / Incorrect Definition
should be
Sample Code
Returns error for object:
Documentation Link
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/fromEntries
Notes
I've read the soundness issues discussion on Object.keys(), but I'm not seeing how that should/would apply to
Object.fromEntries()
.Say if I am passing a [A, B][] into Object.fromEntries() where A is union of a class C and another enum D, I am going to get
C.toString()
|D
. I am already hittingfromEntries(entries: Iterable<readonly any[]>): any;
instead.The text was updated successfully, but these errors were encountered: