Skip to content
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

Object.fromEntries: return type does not account for symbols #44405

Closed
mfulton26 opened this issue Jun 3, 2021 · 3 comments
Closed

Object.fromEntries: return type does not account for symbols #44405

mfulton26 opened this issue Jun 3, 2021 · 3 comments
Labels
Duplicate An existing issue was already created

Comments

@mfulton26
Copy link
Contributor

mfulton26 commented Jun 3, 2021

fromEntries<T = any>(entries: Iterable<readonly [PropertyKey, T]>): { [k: string]: T };

const record = Object.fromEntries([[Symbol.for("1"), "hi"]]);
console.log(record[Symbol.for("1")]);
error: TS2538 [ERROR]: Type 'symbol' cannot be used as an index type.
console.log(record[Symbol.for("1")]);
                   ~~~~~~~~~~~~~~~

the return type should account for objects built with symbols for keys (e.g. through a generic type or something)

@jcalz
Copy link
Contributor

jcalz commented Jun 3, 2021

There's a whole template you're supposed to fill out when you file a bug here, to help the TS team triage and respond.

Anyway I don't think much can be done here until something like #35909 and #26797 are dealt with. Also relevant: #37457, with the comment: "Symbols are still dropped on the floor, just like the rest of the compiler."

@mfulton26
Copy link
Contributor Author

Weird, I was never prompted with a template. Maybe that is because I made the issue from clicking the referenced line of code...

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Jun 10, 2021
@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants