Skip to content

Conversation

@Andarist
Copy link
Contributor

@Andarist Andarist commented Mar 9, 2025

fixes #61382

@github-project-automation github-project-automation bot moved this to Not started in PR Backlog Mar 9, 2025
@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Mar 9, 2025
* @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.

@github-project-automation github-project-automation bot moved this from Not started to Needs merge in PR Backlog Mar 24, 2025
@jakebailey jakebailey merged commit 2b2d6ce into microsoft:main Oct 30, 2025
33 checks passed
@github-project-automation github-project-automation bot moved this from Needs merge to Done in PR Backlog Oct 30, 2025
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: Done

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

4 participants