Skip to content

spread operator in combination with Set reports error 'error TS2461: Type 'Set<string>' is not an array type.' #21058

@basti1253

Description

@basti1253

Code

let data: string[] = [];
data.push('foo');
data.push('foo');
data.push('bar');
data = [...new Set(data)];

Expected behavior:
data = [...new Set(data)] should match data = Array.from(new Set(data));
=> ["foo", "bar"]

Actual behavior:
typescript compilation error "error TS2461: Type 'Set' is not an array type."

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions