Skip to content

Properly propagate ObjectFlags.NonInferrableType onto non-aliased anonymous object types instantiations - #62346

Closed
Mateusz Burzyński (Andarist) wants to merge 4 commits into
microsoft:mainfrom
Andarist:fix/silent-never-leak-anonymous-object-types
Closed

Properly propagate ObjectFlags.NonInferrableType onto non-aliased anonymous object types instantiations#62346
Mateusz Burzyński (Andarist) wants to merge 4 commits into
microsoft:mainfrom
Andarist:fix/silent-never-leak-anonymous-object-types

Conversation

@Andarist

Copy link
Copy Markdown
Contributor

fixes#62345

CopilotAI review requested due to automatic review settings August 27, 2025 21:57
@github-project-automationgithub-project-automationBot moved this to Not started in PR BacklogAug 27, 2025
@typescript-botTypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 27, 2025

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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
FileDescription
tests/cases/compiler/nonInferrableTypePropagation4.tsAdds test cases covering object types, type aliases, arrays, and nested structures
tests/baselines/reference/nonInferrableTypePropagation4.typesExpected type inference baseline showing unknown types in results
tests/baselines/reference/nonInferrableTypePropagation4.symbolsExpected symbol resolution baseline for the test
tests/baselines/reference/nonInferrableTypePropagation4.errors.txtExpected compilation errors showing type assignment failures
src/compiler/checker.tsCore 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);

Copy link
Copy Markdown
ContributorAuthor

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)

@RyanCavanaugh

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) test it

@typescript-bot

TypeScript Bot (typescript-bot) commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
test top400✅ Started✅ Results
user test this✅ Started✅ Results
run dt✅ Started✅ Results
perf test this faster✅ Started👀 Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Ryan Cavanaugh (@RyanCavanaugh), the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot

Copy link
Copy Markdown
Contributor

Ryan Cavanaugh (@RyanCavanaugh) Here are the results of running the user tests with tsc comparing main and refs/pull/62346/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"

Otherwise...

Everything looks good!

@typescript-bot

Copy link
Copy Markdown
Contributor

Ryan Cavanaugh (@RyanCavanaugh)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3434~~~p=1.000 n=6
Symbols62,37062,370~~~p=1.000 n=6
Types50,38650,386~~~p=1.000 n=6
Memory used194,110k (± 0.96%)194,609k (± 0.95%)~192,918k196,534kp=0.378 n=6
Parse Time1.30s (± 0.75%)1.31s (± 0.31%)~1.31s1.32sp=0.056 n=6
Bind Time0.73s (± 0.56%)0.73s (± 0.56%)~0.72s0.73sp=1.000 n=6
Check Time9.76s (± 0.19%)9.76s (± 0.50%)~9.71s9.84sp=1.000 n=6
Emit Time2.73s (± 0.80%)2.75s (± 1.38%)~2.70s2.80sp=0.291 n=6
Total Time14.52s (± 0.20%)14.55s (± 0.47%)~14.47s14.67sp=0.332 n=6
angular-1 - node (v18.15.0, x64)
Errors11~~~p=1.000 n=6
Symbols948,914948,914~~~p=1.000 n=6
Types410,884410,884~~~p=1.000 n=6
Memory used1,246,608k (± 0.00%)1,246,637k (± 0.00%)~1,246,581k1,246,682kp=0.298 n=6
Parse Time6.53s (± 0.99%)6.51s (± 0.91%)~6.47s6.63sp=0.466 n=6
Bind Time1.87s (± 0.59%)1.87s (± 0.62%)~1.85s1.88sp=0.729 n=6
Check Time32.24s (± 0.31%)32.24s (± 0.31%)~32.14s32.41sp=1.000 n=6
Emit Time14.79s (± 0.36%)14.78s (± 0.50%)~14.71s14.91sp=0.517 n=6
Total Time55.43s (± 0.22%)55.40s (± 0.23%)~55.24s55.51sp=0.936 n=6
mui-docs - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols2,545,9482,545,948~~~p=1.000 n=6
Types902,562902,562~~~p=1.000 n=6
Memory used2,830,891k (± 0.01%)2,830,788k (± 0.00%)~2,830,718k2,830,954kp=0.093 n=6
Parse Time8.76s (± 0.36%)8.77s (± 0.20%)~8.75s8.80sp=0.683 n=6
Bind Time2.23s (± 0.72%)2.23s (± 0.73%)~2.21s2.25sp=0.934 n=6
Check Time86.50s (± 1.67%)87.77s (± 0.93%)~86.38s88.66sp=0.066 n=6
Emit Time0.62s (±124.07%)0.36s (±39.04%)~0.30s0.65sp=1.000 n=6
Total Time98.10s (± 1.61%)99.13s (± 0.80%)~97.70s99.98sp=0.230 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,236,9221,236,923+1 (+ 0.00%)~~p=0.001 n=6
Types259,638259,638~~~p=1.000 n=6
Memory used2,507,831k (±11.82%)2,447,319k (± 6.06%)~2,386,546k2,750,149kp=0.810 n=6
Parse Time5.22s (± 1.30%)5.19s (± 1.05%)~5.13s5.28sp=0.748 n=6
Bind Time1.81s (± 0.45%)1.80s (± 1.26%)~1.75s1.81sp=0.491 n=6
Check Time35.17s (± 0.52%)34.97s (± 0.42%)~34.70s35.11sp=0.066 n=6
Emit Time3.01s (± 2.54%)2.98s (± 1.23%)~2.93s3.02sp=0.521 n=6
Total Time45.21s (± 0.46%)44.96s (± 0.33%)~44.79s45.12sp=0.066 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,236,9221,236,923+1 (+ 0.00%)~~p=0.001 n=6
Types259,638259,638~~~p=1.000 n=6
Memory used2,818,872k (±14.05%)2,940,056k (±12.71%)~2,457,031k3,182,171kp=0.230 n=6
Parse Time6.86s (± 1.08%)6.86s (± 1.78%)~6.69s6.96sp=1.000 n=6
Bind Time2.19s (± 1.57%)2.19s (± 1.29%)~2.16s2.24sp=0.810 n=6
Check Time42.48s (± 0.56%)42.40s (± 0.47%)~42.16s42.70sp=0.521 n=6
Emit Time3.59s (± 4.83%)3.48s (± 0.48%)~3.46s3.50sp=0.470 n=6
Total Time55.11s (± 0.62%)54.94s (± 0.50%)~54.58s55.27sp=0.298 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols262,416262,417+1 (+ 0.00%)~~p=0.001 n=6
Types103,917103,917~~~p=1.000 n=6
Memory used441,719k (± 0.02%)441,676k (± 0.02%)~441,605k441,776kp=0.378 n=6
Parse Time4.40s (± 0.87%)4.39s (± 0.84%)~4.33s4.42sp=0.568 n=6
Bind Time1.64s (± 1.21%)1.63s (± 0.72%)~1.62s1.65sp=0.506 n=6
Check Time23.39s (± 0.48%)23.43s (± 0.16%)~23.38s23.49sp=0.521 n=6
Emit Time1.90s (± 0.86%)1.90s (± 0.72%)~1.89s1.92sp=0.564 n=6
Total Time31.33s (± 0.39%)31.35s (± 0.08%)~31.31s31.37sp=0.374 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors7272~~~p=1.000 n=6
Symbols225,367225,367~~~p=1.000 n=6
Types94,29094,290~~~p=1.000 n=6
Memory used371,153k (± 0.03%)371,212k (± 0.03%)~371,103k371,454kp=0.093 n=6
Parse Time2.88s (± 1.31%)2.87s (± 0.84%)~2.85s2.92sp=0.628 n=6
Bind Time1.57s (± 1.04%)1.59s (± 0.66%)~1.58s1.61sp=0.061 n=6
Check Time16.45s (± 0.38%)16.46s (± 0.40%)~16.38s16.54sp=0.809 n=6
Emit Time0.00s (±154.76%)0.00s~~~p=0.174 n=6
Total Time20.91s (± 0.38%)20.93s (± 0.41%)~20.83s21.07sp=0.873 n=6
vscode - node (v18.15.0, x64)
Errors11~~~p=1.000 n=6
Symbols3,874,6233,874,623~~~p=1.000 n=6
Types1,221,0941,221,094~~~p=1.000 n=6
Memory used3,701,589k (± 0.01%)3,701,741k (± 0.01%)~3,701,252k3,702,002kp=0.471 n=6
Parse Time18.79s (± 0.50%)18.75s (± 0.35%)~18.66s18.84sp=0.809 n=6
Bind Time6.22s (± 2.84%)6.10s (± 1.67%)~6.03s6.30sp=0.260 n=6
Check Time126.11s (± 2.87%)127.00s (± 4.03%)~122.01s133.41sp=0.936 n=6
Emit Time44.65s (±22.78%)44.96s (±19.89%)~37.34s55.73sp=0.810 n=6
Total Time195.76s (± 6.85%)196.81s (± 4.42%)~184.69s205.25sp=0.689 n=6
webpack - node (v18.15.0, x64)
Errors3737~~~p=1.000 n=6
Symbols356,094356,094~~~p=1.000 n=6
Types156,860156,860~~~p=1.000 n=6
Memory used513,209k (± 0.04%)513,205k (± 0.04%)~512,919k513,373kp=0.689 n=6
Parse Time4.60s (± 0.41%)4.60s (± 0.70%)~4.57s4.66sp=1.000 n=6
Bind Time1.90s (± 0.52%)1.91s (± 0.97%)~1.88s1.93sp=0.118 n=6
Check Time22.05s (± 0.82%)21.92s (± 0.54%)~21.80s22.13sp=0.230 n=6
Emit Time0.00s (±244.70%)0.00s (±244.70%)~0.00s0.01sp=1.000 n=6
Total Time28.55s (± 0.69%)28.44s (± 0.31%)~28.35s28.59sp=0.378 n=6
xstate-main - node (v18.15.0, x64)
Errors3036🔻+6 (+20.00%)~~p=0.001 n=6
Symbols666,064665,668-396 (- 0.06%)~~p=0.001 n=6
Types199,729199,550-179 (- 0.09%)~~p=0.001 n=6
Memory used572,484k (± 0.03%)572,249k (± 0.02%)~572,027k572,378kp=0.065 n=6
Parse Time5.29s (± 0.44%)5.33s (± 1.21%)~5.22s5.42sp=0.091 n=6
Bind Time1.65s (± 0.91%)1.65s (± 0.62%)~1.64s1.67sp=0.867 n=6
Check Time25.27s (± 1.98%)24.87s (± 1.12%)~24.68s25.43sp=0.229 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time32.21s (± 1.50%)31.85s (± 0.94%)~31.66s32.45sp=0.199 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • Compiler-Unions - node (v18.15.0, x64)
  • angular-1 - node (v18.15.0, x64)
  • mui-docs - node (v18.15.0, x64)
  • self-build-src - node (v18.15.0, x64)
  • self-build-src-public-api - node (v18.15.0, x64)
  • self-compiler - node (v18.15.0, x64)
  • ts-pre-modules - node (v18.15.0, x64)
  • vscode - node (v18.15.0, x64)
  • webpack - node (v18.15.0, x64)
  • xstate-main - node (v18.15.0, x64)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot

Copy link
Copy Markdown
Contributor

Ryan Cavanaugh (@RyanCavanaugh) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/62346/merge:

Everything looks good!

@typescript-botTypeScript Bot (typescript-bot) added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 5, 2025
@RyanCavanaugh

Copy link
Copy Markdown
Member

TypeScript Bot (@typescript-bot) pack this

@typescript-bot

TypeScript Bot (typescript-bot) commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
pack this✅ Started✅ Results

@typescript-bot

Copy link
Copy Markdown
Contributor

Hey Ryan Cavanaugh (@RyanCavanaugh), I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/166456/artifacts?artifactName=tgz&fileId=FF881A7181E51FD746226C8F8B8AD2F99F484D2FAFBA4296A8441045ED0E10F602&fileName=/typescript-6.0.0-insiders.20251105.tgz"
}
}

and then running npm install.

@github-project-automationgithub-project-automationBot moved this from Not started to Needs merge in PR BacklogDec 5, 2025
@typescript-bot

Copy link
Copy Markdown
Contributor

With 6.0 out as the final release vehicle for this codebase, we're closing all PRs that don't fit the merge criteria for post-6.0 patches. If you think this was a mistake and this PR fits the post-6.0 patch criteria, please post to the 6.0 iteration issue with details (specifically, which PR and which patch criteria it satisfies).

Next steps for PRs:

  • For crash bugfixes or language service improvements, PRs are currently accepted at the typescript-go repo
  • Changes to type system behavior should wait until after 7.0, at which point mainline TypeScript development will resume in this repository with the Go codebase
  • Library file updates (lib.d.ts etc) continue to live in this repo or the DOM Generator repo as appropriate

@github-project-automationgithub-project-automationBot moved this from Needs merge to Done in PR BacklogMar 24, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Backlog BugPRs that fix a backlog bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

silentNeverType leak in contextual parameter types coming from anonymous non-aliased object type instantiations

5 participants

@Andarist@RyanCavanaugh@typescript-bot@jakebailey