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

Array.from throws "Expected 1-3 arguments, but got 2." #23880

Closed
bowenni opened this issue May 3, 2018 · 4 comments
Closed

Array.from throws "Expected 1-3 arguments, but got 2." #23880

bowenni opened this issue May 3, 2018 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@bowenni
Copy link

bowenni commented May 3, 2018

TypeScript Version: 2.9.0-dev.20180502

Search Terms:
Array.from

Code

Array.from<{}>([1], (num: number) => num);

Expected behavior:
No errors

Actual behavior:
error TS2554: Expected 1-3 arguments, but got 2.

Playground Link:
https://www.typescriptlang.org/play/#src=Array.from%3C%7B%7D%3E(%5B%5D%2C%20()%20%3D%3E%20%7B%7D)%3B

Related Issues:

CC @rkirov

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label May 3, 2018
@RyanCavanaugh
Copy link
Member

Duplicate #19220; please put a little more effort into searching next time - you just had to put the error message into the search box or read the second page of search results for "Array.from"

image

@bowenni
Copy link
Author

bowenni commented May 3, 2018

Sorry I thought this has something to do with Array.from type declarations and only searched for Array.from

@RyanCavanaugh
Copy link
Member

Actually not really a duplicate since what you were expecting was no error - but this is the intended behavior because you provided a generic type argument arity that didn't match with any normal argument arity

@bowenni
Copy link
Author

bowenni commented May 3, 2018

Thanks Ryan. I see the problem now (got confused by the error message).

@microsoft microsoft locked and limited conversation to collaborators Jul 31, 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

2 participants