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

Overly strict type narrowing in tuple #27557

Closed
westonpace opened this issue Oct 4, 2018 · 1 comment
Closed

Overly strict type narrowing in tuple #27557

westonpace opened this issue Oct 4, 2018 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@westonpace
Copy link

TypeScript Version: 3.2.0-dev.201xxxxx

Search Terms:
type narrowing tuple
type inference tuple

Code

const x: [number, number] = [0, 0];
if (x[0] === 0) {
    x[0] = -1;
}

Expected behavior:
The code should compile. The above code does compile with typescript@3.0.3.

Actual behavior:

error TS2322: Type '-1' is not assignable to type '0'.

Playground Link: http://www.typescriptlang.org/play/

Related Issues:

@ghost ghost added the Bug A bug in TypeScript label Oct 4, 2018
@ahejlsberg
Copy link
Member

Duplicate of #27412.

@ahejlsberg ahejlsberg added Duplicate An existing issue was already created and removed Bug A bug in TypeScript labels Oct 5, 2018
sandersn added a commit that referenced this issue Oct 5, 2018
sandersn added a commit that referenced this issue Oct 5, 2018
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

2 participants