Report cyclic structures and truncation during declaration emit - #64461
Jake Bailey (jakebailey) wants to merge 2 commits into
Conversation
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.
|
TypeScript Bot (@typescript-bot) test it |
There was a problem hiding this comment.
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.
|
Jake Bailey (@jakebailey) Here they are:
tscComparison Report - baseline..pr
System info unknown
Hosts
Scenarios
Developer Information: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Jake Bailey (@jakebailey) 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! |
|
Hey Jake Bailey (@jakebailey), it looks like the DT test run failed. Please check the log for more details. |
|
Jake Bailey (@jakebailey) Here are the results of running the top 400 repos with tsc comparing Something interesting changed - please have a look. Details
|
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.