Skip to content

Report cyclic structures and truncation during declaration emit - #64461

Open
Jake Bailey (jakebailey) wants to merge 2 commits into
microsoft:mainfrom
jakebailey:fix-declaration-serialization-errors
Open

Jake Bailey (jakebailey) wants to merge 2 commits into
microsoft:mainfrom
jakebailey:fix-declaration-serialization-errors

Conversation

@jakebailey

Copy link
Copy Markdown
Member

If type printing sees visitedTypes.Has, then there's a cycle. Rather than silently returning /* elided */ any, actually report that something bad happened.

This gets rid of all the current elided anys in the repo (though I have PRs that will add more cycle checks), besides the cases where we show them in tooltips.

Record declaration serialization that silently substitutes any for
recursive or growing inferred types, including annotated controls.
When inferred types cannot be serialized, declaration emit must report
cyclic structure or truncation errors rather than silently substitute any.
Keep type display unchanged.
Copilot AI balanced review requested due to automatic review settings September 26, 2026 02:46
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Sep 26, 2026
@jakebailey

Copy link
Copy Markdown
Member Author

TypeScript Bot (@typescript-bot) test it

@typescript-automation

typescript-automation Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

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

Command Status Results
test top400 ✅ Started 👀 Results
user test this ✅ Started ✅ Results
run dt ✅ Started ❌ Results
perf test this faster ✅ Started 👀 Results

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

The compiler-wide serialization change intentionally converts numerous successful declaration emits into errors and warrants final human compatibility review.

Review effort: Balanced
Findings: None

What changed in this PR

Reports declaration-emit cycles and serialization truncation instead of silently producing elided any types.

Changes:

  • Adds cycle diagnostics and marks depth-limit serialization as truncated.
  • Adds regression coverage for cyclic, growing, and explicitly annotated types.
  • Updates affected declaration and diagnostic baselines.
File Description
tsc/​internal/​checker/​nodebuilderimpl.go Reports cycles and depth truncation.
tsc/​testdata/​tests/​cases/​compiler/​declarationEmitUnserializableTypes.ts Adds focused regression cases.
tsc/​testdata/​tests/​cases/​compiler/​declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.ts Updates expected behavior documentation.
tsc/​testdata/​baselines/​reference/​conformance/​varianceAnnotations.js Removes invalid declaration output.
tsc/​testdata/​baselines/​reference/​conformance/​varianceAnnotations.errors.txt Records cycle diagnostic.
tsc/​testdata/​baselines/​reference/​conformance/​commonJSImportNestedClassTypeReference.js Removes invalid declaration output.
tsc/​testdata/​baselines/​reference/​conformance/​commonJSImportNestedClassTypeReference.errors.txt Records cycle diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​noImplicitThisBigThis.js Removes truncated declarations.
tsc/​testdata/​baselines/​reference/​compiler/​noImplicitThisBigThis.errors.txt Records cycle diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​functionExpressionReturningItself.js Removes cyclic declaration output.
tsc/​testdata/​baselines/​reference/​compiler/​functionExpressionReturningItself.errors.txt Records cycle diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​emitClassExpressionInDeclarationFile.js Removes invalid declaration output.
tsc/​testdata/​baselines/​reference/​compiler/​emitClassExpressionInDeclarationFile.errors.txt Records cycle diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​declFileTypeofFunction.js Removes cyclic declaration output.
tsc/​testdata/​baselines/​reference/​compiler/​declFileTypeofFunction.errors.txt Records cycle diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.types Updates type truncation baseline.
tsc/​testdata/​baselines/​reference/​compiler/​declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.symbols Updates source-comment baseline.
tsc/​testdata/​baselines/​reference/​compiler/​declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.js Removes truncated declarations.
tsc/​testdata/​baselines/​reference/​compiler/​declarationsWithRecursiveInternalTypesProduceUniqueTypeParams.errors.txt Records length diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitUnserializableTypes.types Captures inferred test types.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitUnserializableTypes.symbols Captures test symbols.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitUnserializableTypes.js Captures emit behavior.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitUnserializableTypes.errors.txt Verifies cycle and length diagnostics.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitStaticMethodNonIdentifierNames.js Removes cyclic declaration output.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitStaticMethodNonIdentifierNames.errors.txt Records cycle diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitInferredTypeAlias4.js Removes invalid declaration output.
tsc/​testdata/​baselines/​reference/​compiler/​declarationEmitInferredTypeAlias4.errors.txt Records cycle diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​classExpressionInClassStaticDeclarations.js Removes cyclic declaration output.
tsc/​testdata/​baselines/​reference/​compiler/​classExpressionInClassStaticDeclarations.errors.txt Records cycle diagnostic.
tsc/​testdata/​baselines/​reference/​compiler/​arrayFakeFlatNoCrashInferenceDeclarations.types Updates recursive inference truncation.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@typescript-automation

Copy link
Copy Markdown

Jake Bailey (@jakebailey)
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-Unions - native
Errors 41 41 ~ ~ ~ p=1.000 n=12
Symbols 115,480 115,480 ~ ~ ~ p=1.000 n=12
Types 96,949 96,949 ~ ~ ~ p=1.000 n=12
Memory Used 149,063k (± 0.55%) 148,924k (± 0.47%) ~ 147,397k 151,110k p=0.843 n=12
Memory Allocs 2,271,691 (± 0.00%) 2,271,633 (± 0.01%) ~ 2,271,354 2,272,078 p=0.724 n=12
Config Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Parse Time 0.040s (± 3.87%) 0.041s (± 4.50%) ~ 0.037s 0.046s p=0.553 n=12
Bind Time 0.013s (±12.36%) 0.012s (± 6.64%) ~ 0.010s 0.013s p=0.198 n=12
Check Time 0.496s (± 0.61%) 0.504s (± 0.89%) +0.008s (+ 1.56%) 0.498s 0.523s p=0.002 n=12
Emit Time 0.267s (± 2.13%) 0.274s (± 2.37%) ~ 0.260s 0.292s p=0.212 n=12
Total Time 0.822s (± 0.65%) 0.837s (± 0.96%) +0.015s (+ 1.80%) 0.819s 0.858s p=0.003 n=12
angular-1 - native
Errors 3 3 ~ ~ ~ p=1.000 n=12
Symbols 847,157 (± 0.08%) 847,477 (± 0.06%) ~ 846,090 849,204 p=0.630 n=12
Types 250,004 (± 0.00%) 250,006 (± 0.00%) ~ 250,001 250,016 p=0.738 n=12
Memory Used 793,300k (± 0.05%) 793,792k (± 0.06%) +492k (+ 0.06%) 792,307k 794,738k p=0.033 n=12
Memory Allocs 12,958,584 (± 0.04%) 12,965,179 (± 0.11%) ~ 12,954,575 13,033,922 p=0.514 n=12
Config Time 0.016s 0.016s ~ ~ ~ p=1.000 n=12
Parse Time 0.274s (± 1.71%) 0.273s (± 2.45%) ~ 0.257s 0.287s p=0.943 n=12
Bind Time 0.060s (± 5.65%) 0.062s (± 9.88%) ~ 0.057s 0.088s p=0.741 n=12
Check Time 0s 0s ~ ~ ~ p=1.000 n=12
Emit Time 1.611s (± 1.08%) 1.620s (± 1.16%) ~ 1.586s 1.686s p=0.434 n=12
Total Time 1.975s (± 1.01%) 1.991s (± 1.26%) ~ 1.952s 2.070s p=0.284 n=12
mui-docs - native
Errors 11,402 (± 0.03%) 11,399 (± 0.04%) ~ 11,379 11,408 p=0.165 n=12
Symbols 4,603,369 4,603,369 ~ ~ ~ p=1.000 n=12
Types 1,643,150 1,643,150 ~ ~ ~ p=1.000 n=12
Memory Used 4,957,474k (± 0.03%) 4,955,583k (± 0.03%) ~ 4,951,350k 4,959,992k p=0.078 n=12
Memory Allocs 48,681,862 (± 0.03%) 48,652,610 (± 0.04%) -29,253 (- 0.06%) 48,610,600 48,716,664 p=0.028 n=12
Config Time 0.015s (± 2.02%) 0.016s (± 2.08%) ~ 0.015s 0.016s p=0.414 n=12
Parse Time 0.580s (± 2.55%) 0.580s (± 1.92%) ~ 0.549s 0.612s p=0.766 n=12
Bind Time 0.002s 0.002s ~ ~ ~ p=1.000 n=12
Check Time 15.098s (± 0.73%) 14.927s (± 0.70%) -0.170s (- 1.13%) 14.771s 15.189s p=0.020 n=12
Emit Time 0.443s (± 2.35%) 0.459s (± 2.70%) +0.017s (+ 3.79%) 0.435s 0.477s p=0.004 n=12
Total Time 16.916s (± 0.67%) 16.748s (± 0.62%) -0.169s (- 1.00%) 16.622s 17.028s p=0.040 n=12
strada-build-src - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,394,252 1,394,252 ~ ~ ~ p=1.000 n=12
Types 443,566 443,566 ~ ~ ~ p=1.000 n=12
Memory Used 1,699,116k (± 0.84%) 1,694,979k (± 0.60%) ~ 1,681,647k 1,725,027k p=0.932 n=12
Memory Allocs 93,543,401 (± 0.12%) 93,509,268 (± 0.14%) ~ 93,069,495 93,779,484 p=0.887 n=12
Config Time 0.004s (± 8.45%) 0.004s (±22.15%) ~ 0.002s 0.007s p=0.900 n=12
Parse Time 0.207s (± 3.77%) 0.209s (± 4.01%) ~ 0.190s 0.232s p=0.702 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.830s (± 0.58%) 1.851s (± 0.65%) +0.021s (+ 1.14%) 1.816s 1.888s p=0.006 n=12
Emit Time 0.295s (± 4.30%) 0.301s (± 6.05%) ~ 0.251s 0.338s p=0.354 n=12
Total Time 23.703s (± 0.69%) 23.985s (± 0.91%) +0.282s (+ 1.19%) 23.506s 24.548s p=0.039 n=12
strada-compiler - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 337,531 337,531 ~ ~ ~ p=1.000 n=12
Types 198,885 198,885 ~ ~ ~ p=1.000 n=12
Memory Used 319,658k (± 0.04%) 319,855k (± 0.11%) ~ 319,441k 321,092k p=0.630 n=12
Memory Allocs 4,673,189 (± 0.01%) 4,673,370 (± 0.01%) ~ 4,671,797 4,674,193 p=0.347 n=12
Config Time 0.001s 0.001s ~ ~ ~ p=1.000 n=12
Parse Time 0.115s (± 4.68%) 0.117s (± 5.48%) ~ 0.101s 0.132s p=0.787 n=12
Bind Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Check Time 1.068s (± 0.57%) 1.070s (± 0.40%) ~ 1.060s 1.087s p=0.722 n=12
Emit Time 0.129s (±12.89%) 0.134s (±11.09%) ~ 0.094s 0.166s p=0.989 n=12
Total Time 1.367s (± 1.33%) 1.373s (± 1.10%) ~ 1.332s 1.414s p=0.701 n=12
ts-pre-modules - native
Errors 87 87 ~ ~ ~ p=1.000 n=12
Symbols 305,179 305,179 ~ ~ ~ p=1.000 n=12
Types 181,926 181,926 ~ ~ ~ p=1.000 n=12
Memory Used 277,179k (± 0.02%) 277,126k (± 0.03%) ~ 276,843k 277,251k p=0.514 n=12
Memory Allocs 1,642,102 (± 0.01%) 1,642,309 (± 0.02%) ~ 1,641,836 1,643,618 p=0.139 n=12
Config Time 0.000s (±217.90%) 0.000s (±77.74%) ~ 0.000s 0.001s p=0.155 n=12
Parse Time 0.100s (± 2.79%) 0.100s (± 2.93%) ~ 0.091s 0.106s p=0.764 n=12
Bind Time 0.039s (±10.26%) 0.035s (± 9.91%) ~ 0.028s 0.044s p=0.136 n=12
Check Time 0.843s (± 0.51%) 0.850s (± 0.73%) ~ 0.838s 0.866s p=0.080 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 0.995s (± 0.53%) 0.998s (± 0.85%) ~ 0.982s 1.027s p=0.765 n=12
vscode - native
Errors 371 371 ~ ~ ~ p=1.000 n=12
Symbols 9,916,442 9,916,442 ~ ~ ~ p=1.000 n=12
Types 3,343,567 3,343,567 ~ ~ ~ p=1.000 n=12
Memory Used 6,490,666k (± 0.02%) 6,490,416k (± 0.02%) ~ 6,486,813k 6,493,688k p=0.660 n=12
Memory Allocs 49,854,446 (± 0.03%) 49,857,839 (± 0.02%) ~ 49,838,987 49,884,950 p=0.347 n=12
Config Time 0.066s (± 0.49%) 0.066s (± 0.41%) ~ 0.065s 0.067s p=0.832 n=12
Parse Time 1.799s (± 2.31%) 1.840s (± 2.87%) ~ 1.715s 1.972s p=0.298 n=12
Bind Time 0.465s (±19.73%) 0.489s (±19.24%) ~ 0.403s 0.807s p=0.085 n=12
Check Time 13.293s (± 1.18%) 13.186s (± 1.34%) ~ 12.781s 13.478s p=0.843 n=12
Emit Time 4.084s (±10.76%) 4.500s (±11.73%) ~ 3.668s 5.582s p=0.139 n=12
Total Time 19.814s (± 1.78%) 20.194s (± 1.93%) ~ 19.497s 21.045s p=0.052 n=12
webpack - native
Errors 848 848 ~ ~ ~ p=1.000 n=12
Symbols 1,362,981 1,362,981 ~ ~ ~ p=1.000 n=12
Types 591,426 591,426 ~ ~ ~ p=1.000 n=12
Memory Used 963,915k (± 0.02%) 964,041k (± 0.02%) ~ 963,670k 964,466k p=0.410 n=12
Memory Allocs 6,194,379 (± 0.02%) 6,194,633 (± 0.03%) ~ 6,192,848 6,201,173 p=0.977 n=12
Config Time 0.009s 0.009s ~ ~ ~ p=1.000 n=12
Parse Time 0.261s (± 2.71%) 0.264s (± 1.15%) ~ 0.256s 0.271s p=0.353 n=12
Bind Time 0.072s (±17.90%) 0.064s (±13.64%) ~ 0.054s 0.092s p=0.152 n=12
Check Time 1.776s (± 0.48%) 1.781s (± 1.04%) ~ 1.737s 1.840s p=0.990 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 2.155s (± 0.40%) 2.155s (± 1.19%) ~ 2.102s 2.248s p=0.766 n=12
xstate-main - native
Errors 0 0 ~ ~ ~ p=1.000 n=12
Symbols 1,045,695 1,045,695 ~ ~ ~ p=1.000 n=12
Types 383,049 383,049 ~ ~ ~ p=1.000 n=12
Memory Used 611,268k (± 0.01%) 611,318k (± 0.01%) ~ 611,077k 611,533k p=0.319 n=12
Memory Allocs 4,828,467 (± 0.03%) 4,830,390 (± 0.04%) ~ 4,826,270 4,836,103 p=0.143 n=12
Config Time 0.003s (± 8.64%) 0.003s (±11.61%) ~ 0.002s 0.003s p=0.640 n=12
Parse Time 0.147s (± 2.70%) 0.153s (± 3.93%) ~ 0.138s 0.171s p=0.079 n=12
Bind Time 0.039s (±13.81%) 0.040s (±15.76%) ~ 0.033s 0.062s p=0.475 n=12
Check Time 1.191s (± 0.54%) 1.197s (± 0.96%) ~ 1.177s 1.239s p=0.504 n=12
Emit Time 0.000s 0.000s ~ ~ ~ p=1.000 n=12
Total Time 1.390s (± 0.54%) 1.403s (± 1.04%) ~ 1.368s 1.455s p=0.091 n=12
System info unknown
Hosts
  • native
Scenarios
  • Compiler-Unions - native
  • angular-1 - native
  • mui-docs - native
  • strada-build-src - native
  • strada-compiler - native
  • ts-pre-modules - native
  • vscode - native
  • webpack - native
  • xstate-main - native
Benchmark Name Iterations
Current pr 12
Baseline baseline 12

Developer Information:

Download Benchmarks

@typescript-automation

Copy link
Copy Markdown

Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing main and refs/pull/64461/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Git clone failed"
  • 1 instance of "Package install failed"

Otherwise...

Everything looks good!

@typescript-automation

Copy link
Copy Markdown

Hey Jake Bailey (@jakebailey), it looks like the DT test run failed. Please check the log for more details.

You can check the log here.

@typescript-automation

Copy link
Copy Markdown

Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing main and refs/pull/64461/merge:

Something interesting changed - please have a look.

Details

different-ai/openwork

16 of 43 projects failed to build with the old tsc and were ignored

packages/enterprise-mcp-mock-server/tsconfig.json

facebook/docusaurus

26 of 43 projects failed to build with the old tsc and were ignored

packages/docusaurus-faster/tsconfig.json

teableio/teable

144 of 147 projects failed to build with the old tsc and were ignored

packages/sdk/tsconfig.json

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

2 participants