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

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

Closed
LongTengDao opened this issue Jul 6, 2019 · 2 comments

Comments

@LongTengDao
Copy link
Contributor

LongTengDao commented Jul 6, 2019

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:

@MartinJohns
Copy link
Contributor

In TypeScript 3.5.2 the second parameter is readonly any[], if you have the compiler option strictBindCallApply enabled. This option was released with TypeScript 3.2 (November 2018).

#27028

@vbraun
Copy link

vbraun commented Aug 27, 2020

This is still broken on Typescript 4.0.2, and has been since at least 3.5.1 (oldest version on the typescript playground):

https://www.typescriptlang.org/play?ts=4.0.2#code/GYVwdgxgLglg9mABAWwIYyQCgwBxFRALgCcBTVAEwQBsBPRVMWgbQF0BKRAbwChF+B-CAgDOBOPjwFCjFq0QBeRGwDcfQQICCxYqloA6HMThQTtHKUMgRAC32ocOOpglQpAGkS587NRoFkUCDESK5SfgIAvkA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants