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 excess/ common property check errors being incorrectly reported when relating to targets with multiple index signatures #60869

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

Conversation

Andarist
Copy link
Contributor

fixes #58442

…ectly reported when relating to targets with multiple index signatures
@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Dec 29, 2024
const propType = getNonMissingTypeOfSymbol(prop);
const type = exactOptionalPropertyTypes || propType.flags & TypeFlags.Undefined || keyType === numberType || !(prop.flags & SymbolFlags.Optional)
? propType
: getTypeWithFacts(propType, TypeFacts.NEUndefined);
const related = isRelatedTo(type, targetInfo.type, RecursionFlags.Both, reportErrors, /*headMessage*/ undefined, intersectionState);
const related = isRelatedTo(type, targetInfo.type, RecursionFlags.Both, reportErrors, /*headMessage*/ undefined, intersectionState, targetInfo === getApplicableIndexInfo(target, propKeyType));
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 is where the allowExtraPropertyChecks is toggled~ when relating to a targetInfo.type. The source is related to all target infos (that's what the indexSignaturesRelatedTo caller does). Those checks should only be performed when relating to the applicable index info to reflect what happens in assignments like:

obj.indexSignatureProp = { someProp: 'foo' }

In the example above, { someProp: string } is only related to the applicable index info "selected" by obj.indexSignatureProp

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.

Error in Index Signature Assignment
2 participants