Skip to content

Array.concat() 's params wrong!!! #17447

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

Closed
scp1513 opened this issue Jul 27, 2017 · 5 comments
Closed

Array.concat() 's params wrong!!! #17447

scp1513 opened this issue Jul 27, 2017 · 5 comments
Labels
Duplicate An existing issue was already created

Comments

@scp1513
Copy link

scp1513 commented Jul 27, 2017

TypeScript Version: 2.4.1

Code

let a: ReadonlyArray<number> = [];
let b: number[] = [];
// compile error
let c = b.concat(a);
// you see Array.concat() doesn't change the params

Expected behavior:

Actual behavior:

@MrKou47
Copy link

MrKou47 commented Jul 27, 2017

let a: ReadonlyArray<number> = [];
let b: number[] = [];
let c = b.concat([...a]);

this will be ok.

@scp1513
Copy link
Author

scp1513 commented Jul 27, 2017

@MrKou47 It works. thanks.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Jul 27, 2017
@arusakov
Copy link
Contributor

arusakov commented Sep 13, 2017

@RyanCavanaugh
Code example generates error (TypeScript 2.5.2):

[ts]
Argument of type 'ReadonlyArray<number>' is not assignable to parameter of type 'number | number[]'.
  Type 'ReadonlyArray<number>' is not assignable to type 'number[]'.
    Property 'push' is missing in type 'ReadonlyArray<number>'.

Is it right definition for push method for ReadonlyArray<T>?

push(): never

Also we need the same definitions for other methods, like pop and so on... Am I right?

@mhegazy mhegazy added the Help Wanted You can do this label Sep 14, 2017
@mhegazy mhegazy added this to the Community milestone Sep 14, 2017
@mhegazy
Copy link
Contributor

mhegazy commented Sep 14, 2017

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

@NaridaL
Copy link
Contributor

NaridaL commented Sep 18, 2017

This is a duplicate of #17076 and has been fixed by #17806.

@mhegazy mhegazy closed this as completed Sep 18, 2017
@mhegazy mhegazy added Duplicate An existing issue was already created and removed Help Wanted You can do this Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Sep 18, 2017
@mhegazy mhegazy modified the milestone: Community Sep 18, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

6 participants