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

Improve references search and quick info on properties with type errors within nullable contextual types #61383

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

Conversation

Andarist
Copy link
Contributor

@Andarist Andarist commented Mar 9, 2025

fixes #61382

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 9, 2025
@@ -3558,6 +3558,7 @@ function getSymbolAtLocationForQuickInfo(node: Node, checker: TypeChecker): Symb
* @internal
*/
export function getPropertySymbolsFromContextualType(node: ObjectLiteralElementWithName, checker: TypeChecker, contextualType: Type, unionSymbolOk: boolean): readonly Symbol[] {
contextualType = contextualType.getNonNullableType();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just fine-tunes the algorithm for a common case. By discarding nullable (that can't provide anything useful here as they don't have properties anyway) the !contextualType.isUnion() "fast path" is taken here. This allows for better symbol result to be returned from here - despite those locations having errors. Without this the symbol of the anonymous object literal type (the one with error) is picked and that's less useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
Development

Successfully merging this pull request may close these issues.

Regression in the way optional properties behave when there's an error in the property value
2 participants