Skip to content

the typing the second parameter of push.apply should be readonly T[], not T[] #32276

@LongTengDao

Description

@LongTengDao

TypeScript Version: 3.4.1

Search Terms:

Code

function main (input :readonly any[]) {
    const output :any[] = [];
    Array.prototype.push.apply(output, input);
    return output;
}

Expected behavior:

Not to report an error.

Actual behavior:

Report error TS2345.

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions