Skip to content

Narrow destructured variables based on initializer's analysis result #59745

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nekolab
Copy link

@nekolab nekolab commented Aug 25, 2024

This PR introduces a method to narrow the types of destructured variables through control flow analysis without relying on the discriminant member.

When the initializer of the ObjectBindingPattern is available, we attempt to narrow its type, which in turn helps further refine the type of the destructured variable.

Partially fixes #59657

This PR introduces a method to narrow the types of destructured
variables through control flow analysis without relying on the
discriminant member.

When the initializer of the `ObjectBindingPattern` is available,
we attempt to narrow its type, which in turn helps further refine
the type of the destructured variable.

Partially fixes microsoft#59657
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Aug 25, 2024
@nekolab
Copy link
Author

nekolab commented Aug 25, 2024

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Make type narrowing for destructured discriminated unions work for more types
2 participants