-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Optional chaining control flow cannot narrow discriminated unions. #42120
Comments
The original repro in #18758 can be changed very slightly to show this bug: type A = { type: "a" }
type X = { type: A, a: string }
type Y = { type?: undefined, b: string }
declare let x: X | Y
if (x.type?.type === "a") {
x.a // Type Error
} |
Interesting. I remember I try to handle expression with optional chain, but it seems I do not do it well. |
This is fixed in #38839 now!
|
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Bug Report
π Search Terms
optional chaining discriminated union control flow
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
Possibly related: #34597
The text was updated successfully, but these errors were encountered: