-
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
Type guard and assertion do not properly refine union types with optional properties #60979
Labels
Duplicate
An existing issue was already created
Comments
Thank you for the feedback, @Andarist! I wasn't able to find that specific issue, when I was searching for the bug, but I agree—the problem seems to be exactly the same! 😊 |
Ah yes, I definitely have wanted link to #58520 😅 |
This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🔎 Search Terms
"type guard union types narrowing"
"asserts is not refining type"
"type refinement union types bug"
"dryRun outputPath assertion"
"optional property refinement bug"
🕗 Version & Regression Information
This changed between versions 4.7.4 and 4.8.4.
After bisecting i found that the regression has been introduced in commit: 2c68ded95498dc637acdb00e8349f51832f5a6df.
⏯ Playground Link
https://www.typescriptlang.org/play/?ts=5.7.3#code/KYDwDg9gTgLgBASwHY2FAZgQwMbDgMQQBtgBnAYRMyQFcxKF8jMBzUuAbwCg5e4pgmACYQkRAJ5whUcQCUaSAPwAuOACMIEKkgDcPPgOGiJcCDRhhzABUwwAFirikYUZCz0BfLlwD0PuAAq4mB4LDSYUEJwAO4I9nAABgikCXDo0PzA6MhucAoIonAwwWRc6ArYMAVIcNh2wNgA1gxMrKQAFPq86MxsqoQkFNp0Lb2kADRcAJSqPW2I7ByZRmKS0nIKqi40wDrLIqum5pYwNvaqzq5ILHAecAA+nPvGazLySrOYRKR4d9x8iHQcHaczYADp1u84AAyaFwACEoNIYLMFmstjsU04XQBRTsUAg0TgSGARIAolACVB2gByAL1OAAWkZqJOZzspjAVUKyUyAEcaAgBFFkFIZIyoAo4ABbCBCPDUKLSmjOJwhbAIdCSex4cpEIhpYh4MAYsE0qZ6AFeAECGA0KA1ba7LheXz+ACymFF5SQlWqeVIuR1RRKcDCESEZQq3Jq0q9SHaWP+fGwolVEC51VI-SNQ0EtHoREYYzgAF5OB49DjNcC6g1mkXWmx2hmY6QpkmcQDU0hVUtIQpxkc0acMbcy5y25bcbw-HAyeAGqghKogiEAMrYVxcpx2MxEKICbIkxKtrOpGAQJ4DpBbSW7YdsjEXFy5O6PftvBSOLDfX5dvg5wAQUqcIiFXEpN23eAj2QMhT0zNNUheIor0-DZbyKe89lZdFzicV9rluSYZ1nfwIGlOIqiIhJ0PeH8vh+W5UmwTAfjBHEvFdOcAFVAxotiflgdhklSAA3NBA0KCAgWDOsmijX0Y1qeomlGNoAHU4jsIDSCEmAOhxJEc0GSh8xGRsxkmGY4EEtADLSEteSWQwDhMG87x2PZXJQ3DR3wy43weJ4fMOG8GL-cdk14GsQTGCEvxqWEESRFFjjwzFsVIvECSJElyUpaBaXpPBmT89lJ39XkBAFIVgBFGp1glKVZXlWykCVFV4FIdVNW1Bk9QNbISDgE17DNC1OJdbw509b1o39FVcjs4TFL9Qo42QLT7F0-SOk7bs03gM80xMsgzOoCzi3mcsOErbxu1UhtrrYbadL0+yOhO3tJpxHs+zFDCh3Ksc7nLb7SGnMj50XSp6ogjctwQHdSD3GgD0yY88ASCGLzQwH3k8h8QYCwibnfa9EoipjrUA-wQLtL4EeAKDkZgrI4PYHHEN7ZDDkvSmMKJnD0v8uwXyucmSLp0xKJgaiblognv0+SKPBYtjgA4rwgA
💻 Code
🙁 Actual behavior
TypeScript does not refine the type of
options
correctly after the type guard (checkCliFlags
) or assertion (checkCliFlagsWithAsserts
)checkCliFlags(optins)
orcheckCliFlagsWithAsserts(options)
, the expected refinement is:options
to{ readonly dryRun: true; readonly outputPath: string }
, and the{ dryRun?: false }
branch is omitted.🙂 Expected behavior
TypeScript should refine the type of
options
to:Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: