Skip to content

Object spread and Map #33081

@bs85

Description

@bs85

When spreading a Map, the resulting object is also considered a Map, allowing to call all the Map methods on it even though they aren't inherited.

const map: Map<number, string> = new Map();
const spread = { ...map };
spread.has(0)

// -> spread.has is not a function

Is this intended, and is there a compiler option that would result in an error here?

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