-
Notifications
You must be signed in to change notification settings - Fork 13k
Properly propagate ObjectFlags.NonInferrableType
onto non-aliased anonymous object types instantiations
#62346
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
base: main
Are you sure you want to change the base?
Conversation
…nonymous object types instantiations
There was a problem hiding this 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 fixes the proper propagation of ObjectFlags.NonInferrableType
onto non-aliased anonymous object type instantiations, addressing issue #62345. The fix ensures that when instantiating generic types, certain object flags (including NonInferrableType
) are properly carried forward from the type arguments to the resulting instantiated type.
- Extracts propagating flags from type arguments before computing type variable containment
- Applies all propagating flags (including
NonInferrableType
) to the result object type - Adds comprehensive test coverage for various scenarios where non-inferrable type propagation should occur
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tests/cases/compiler/nonInferrableTypePropagation4.ts | Adds test cases covering object types, type aliases, arrays, and nested structures |
tests/baselines/reference/nonInferrableTypePropagation4.types | Expected type inference baseline showing unknown types in results |
tests/baselines/reference/nonInferrableTypePropagation4.symbols | Expected symbol resolution baseline for the test |
tests/baselines/reference/nonInferrableTypePropagation4.errors.txt | Expected compilation errors showing type assignment failures |
src/compiler/checker.ts | Core fix in type instantiation logic to propagate object flags properly |
else { | ||
(result as ObjectFlagsType).objectFlags |= !resultCouldContainTypeVariables ? ObjectFlags.CouldContainTypeVariablesComputed : 0; | ||
if (result.flags & TypeFlags.ObjectFlagsType) { | ||
let propagatingFlags = getPropagatingFlagsOfTypes(typeArguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Propagating from typeArguments
is the core of the fix, the rest is just adjusted indentation.
You can also find some prior related discussion here: #49887 (comment)
@typescript-bot test it |
Hey @RyanCavanaugh, the results of running the DT tests are ready. Everything looks the same! |
@RyanCavanaugh Here are the results of running the user tests with tsc comparing There were infrastructure failures potentially unrelated to your change:
Otherwise... Everything looks good! |
@RyanCavanaugh Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
@RyanCavanaugh Here are the results of running the top 400 repos with tsc comparing Everything looks good! |
fixes #62345