Skip to content

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

Description

@mfulton26

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)

Activity

  1. jcalz commented on Jun 3, 2021

    @jcalz
    Contributor

    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."

  2. mfulton26 commented on Jun 4, 2021

    @mfulton26
    ContributorAuthor

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

  3. typescript-bot commented on Jun 13, 2021

    @typescript-bot
    Contributor

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

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions