Skip to content
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

Fixed an issue with property type display when contextual type is a union #56318

Merged

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Nov 5, 2023

fixes #55495

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Nov 5, 2023
if (unionSymbolOk && (discriminatedPropertySymbols.length === 0 || discriminatedPropertySymbols.length === contextualType.types.length)) {
const symbol = contextualType.getProperty(name);
if (symbol) return [symbol];
}
if (discriminatedPropertySymbols.length === 0) {
if (!filteredTypes.length && !discriminatedPropertySymbols.length) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main idea behind the fix is that we don't want to go into this branch because the type satisfies its contextual type in this test case. So there is one filtered type here but there are no discriminated property symbols. The first type in the union doesn't have an explicit prop for someProp and the second one is rejected by the isTypeInvalidDueToUnionDiscriminant check.

@andrewbranch andrewbranch merged commit 02f9ddf into microsoft:main Jan 4, 2024
19 checks passed
@Andarist Andarist deleted the fix/quick-info-contextual-union-type branch January 4, 2024 17:45
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
Archived in project
Development

Successfully merging this pull request may close these issues.

Quick info displays incorrect type in discriminated union type
3 participants