Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Avoid resolving source prop type when the target is unknown/any #61660

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

Andarist
Copy link
Contributor

@Andarist Andarist commented May 5, 2025

closes #61659

@Copilot Copilot AI review requested due to automatic review settings May 5, 2025 09:54
@Andarist Andarist force-pushed the avoid-circularity-on-any-unknown-target-props branch from c5da502 to 8289db7 Compare May 5, 2025 09:54
@github-project-automation github-project-automation bot moved this to Not started in PR Backlog May 5, 2025
@typescript-bot typescript-bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels May 5, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves the performance and accuracy of type checking for property symbols by short‐circuiting the relation check when the target type is “any” (or “any”/“unknown” when not using strict subtype relation).

Files not reviewed (5)
  • tests/baselines/reference/multiline.types: Language not supported
  • tests/baselines/reference/noCircularitySelfReferentialGetter1.symbols: Language not supported
  • tests/baselines/reference/noCircularitySelfReferentialGetter1.types: Language not supported
  • tests/baselines/reference/noCircularitySelfReferentialGetter2.symbols: Language not supported
  • tests/baselines/reference/noCircularitySelfReferentialGetter2.types: Language not supported

@@ -24057,6 +24057,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
function isPropertySymbolTypeRelated(sourceProp: Symbol, targetProp: Symbol, getTypeOfSourceProperty: (sym: Symbol) => Type, reportErrors: boolean, intersectionState: IntersectionState): Ternary {
const targetIsOptional = strictNullChecks && !!(getCheckFlags(targetProp) & CheckFlags.Partial);
const effectiveTarget = addOptionality(getNonMissingTypeOfSymbol(targetProp), /*isProperty*/ false, targetIsOptional);
// source could resolve to `any` and that's not related to `unknown` target under strict subtype relation
if (effectiveTarget.flags & (relation === strictSubtypeRelation ? TypeFlags.Any : TypeFlags.AnyOrUnknown)) {
Copy link
Preview

Copilot AI May 5, 2025

Choose a reason for hiding this comment

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

The condition now short-circuits the type relation check when the target type is 'any' (or 'any'/'unknown' depending on the relation), which is the intended behavior per issue #61659. Consider adding a reference to the issue number in the comment for clearer context and future maintainability.

Copilot uses AI. Check for mistakes.

@Andarist Andarist force-pushed the avoid-circularity-on-any-unknown-target-props branch from 8289db7 to 540e84d Compare May 5, 2025 09:59
@LukeAbby
Copy link

LukeAbby commented May 5, 2025

I will just pop in here to note that this would presumably hep with a number of circularities I've experienced.

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
3 participants