Microsoft/TypeScript
GitHub ã§èŠãNested destructuring does not narrow dependent parameters
Open
#48,378 opened on 2022幎3æ22æ¥
BugDomain: check: Control FlowHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
destructuring destructured dependent parameters nested control flow analysis
ð Version & Regression Information
- This changed between versions 4.5.5 and 4.6
⯠Playground Link
Playground link with relevant code
ð» Code
declare const Tuple: [true, string] | [false, number];
const [[val1, val2]] = [Tuple];
if (val1) {
val2 // string | number
}
ð Actual behavior
TypeScript does not correctly narrow val2 when narrowing val1 if it's in any type of nested destructuring.
ð Expected behavior
I expect it to behave the same as directly destructuring the object.