-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Regression in array destruction in TypeScript 3.3 #29731
Comments
Simplified code type ImmutableTuple2 = {
readonly [0]: number
readonly [1]: string
} & Iterable<number|string>
const f = ([a, b]: ImmutableTuple2) => {
const _a: number = a // a should be a `number` but it's `number`|`string` in TS 3.3
const _b: string = b // b should be a `string` but it's `number`|`string` in TS 3.3
} |
Workaround # 1const f = (ab: ImmutableTuple2) => {
const _a: number = ab[0] // ok
const _b: string = ab[1] // ok
} Workaround # 2const f = (ab: ImmutableTuple2) => {
const [a, b] = ab
const _a: number = a // ok
const _b: string = b // ok
} |
The bug is also in TypeScript 3.4.1. |
@ahejlsberg is there any expected release when this to be fixed ? |
Starting with TypeScript 3.4 we have proper support for const f = <T>(_v: T, _c: (v: T) => void) => {}
const v: readonly [number, string] = [4, "hello"]
f(v, ([a, b]) => {
const _a: number = a;
const _b: string = b;
}) We no longer recognize "pseudo-tuples" like |
TypeScript Version: 3.3.1 and 3.4.1
Search Terms:
Code
Expected behavior:
No compilation errors. (TypeScript 3.2)
Actual behavior:
TypeScript 3.3.1 and up
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: