You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Nested destructuring does not narrow dependent parametersΒ #48378
typeT={path: ['one'],value: string}|{path: ['two'],value: number}functionfoo(payload: T){if(payload.path[0]==='one'){payload.value// string | number, should be just string}}
This is fixed by #56306. The nested tuple binding in the original example now preserves the dependency between the discriminant and its paired value: value2 is narrowed to string after if (value1).
The example still reports TS2322 in 5.4.0-dev.20231128 and is clean in 5.4.0-dev.20231129, TypeScript 6.0.3, and the current native compiler.
Activity
jtbandes commentedon Jun 21, 2022
Is this the same issue?
Fireboltofdeath commentedon Jun 22, 2022
This issue is referring to the control flow analysis of destructured unions so I don't believe this is related to that issue.
RyanCavanaugh commentedon Sep 8, 2026
This is fixed by #56306. The nested tuple binding in the original example now preserves the dependency between the discriminant and its paired value:
value2is narrowed tostringafterif (value1).The example still reports TS2322 in 5.4.0-dev.20231128 and is clean in 5.4.0-dev.20231129, TypeScript 6.0.3, and the current native compiler.