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

Wrong type inferred for array of tuples #28336

Closed
chinhodado opened this issue Nov 5, 2018 · 4 comments
Closed

Wrong type inferred for array of tuples #28336

chinhodado opened this issue Nov 5, 2018 · 4 comments
Labels
Duplicate An existing issue was already created

Comments

@chinhodado
Copy link

TypeScript Version: 3.1.6

Search Terms:
array tuple inference inferred argument

Code

let x = [["a", [1]]];

function f(arg: [string, number[]][]) {
}

f(x);

// If I declare x's type directly like this then it works:
// let x: [string, number[]][] = [["a", [1]]];

Expected behavior:
No error

Actual behavior:
Error:

Error:(352, 3) TS2345: Argument of type '(string | number[])[][]' is not assignable to parameter of type '[string, number[]][]'.
  Type '(string | number[])[]' is not assignable to type '[string, number[]]'.
    Property '0' is missing in type '(string | number[])[]'.

Playground Link:
Link

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Nov 5, 2018

Duplicate of #20899 and duplicate of #3369.

@DanielRosenwasser DanielRosenwasser marked this as a duplicate of #16389 Nov 5, 2018
@DanielRosenwasser DanielRosenwasser added the Duplicate An existing issue was already created label Nov 5, 2018
@DanielRosenwasser DanielRosenwasser marked this as a duplicate of #20899 Nov 5, 2018
@ahejlsberg
Copy link
Member

Also see my comment here.

@chinhodado
Copy link
Author

I see, thank you for the quick response!

@typescript-bot
Copy link
Collaborator

This issue has been marked as a duplicate and has seen no activity in the last day. It has been closed for automatic house-keeping purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

4 participants