Repository navigation
Unify recursive type naming during serialization - #64751
Open
Jake Bailey (jakebailey) wants to merge 2 commits into
Open
Jake Bailey (jakebailey) wants to merge 2 commits into
Jake Bailey (jakebailey) wants to merge 2 commits into
Conversation
Recursive values should retain their structure across declaration emit and downstream consumption instead of failing emit or acquiring any. Cover functions, object members, containers, and generic aliases, with repeated builds and displays at different expansion levels. Broader annotations and inaccessible names must not silently weaken recursive types. Preserve coverage of declaration error reporting even when formerly unrepresentable structural types become nameable. Declaration and call-site displays should agree on recursive boundaries without losing the selected overload or generic specialization. Recursive generic owners must remain reusable with new type arguments. A captured specialization must not change a method's own generic contract or leak into declarations consumed by downstream projects. For 55832
Recursive values can have valid declaration types without annotations. Separate function and alias fallbacks leave equivalent constructs with different results, and broader value annotations can silently weaken the recursive type. Keep ordinary type names independent of the definitions being emitted. Share definition context across syntax reuse and structural expansion so recursive references and cycle detection agree on what is in scope. A value self-reference must cross a lazy resolution boundary, and names usable in local displays are not necessarily usable in declarations. Starting from a selected signature must not add an extra recursive unfolding merely because its containing type was not traversed. Preserve isolated declaration inference restrictions and prevent cached output from crossing incompatible recursion contexts. Captured generic substitutions must not escape into parameters bound by a re-entered signature. Otherwise declaration consumers lose valid calls even when the original source infers the correct result. Fixes 55832
Jake Bailey (jakebailey)
added this pull request to stack #64753
October 12, 2026 19:06
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
It substantially changes core serializer cycle detection, caching, accessibility, and scope handling across many compiler outputs.
0 open findings
What changed in this PR
Unifies recursive type naming during serialization, enabling stable typeof/indexed-access back-references instead of falling back to any or serialization errors.
Changes:
- Adds serialization definition tracking and deferred type scopes.
- Improves recursive symbol naming, scope mapping, and structural fallback.
- Expands compiler, declaration emit, incremental, and Quick Info coverage.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/recursiveFunctionDeclarationSerialization.ts |
Adds comprehensive recursive serialization cases. |
tsc/testdata/tests/cases/compiler/isolatedDeclarationErrorsReturnTypes.ts |
Adds isolated-declaration recursion cases. |
tsc/testdata/baselines/reference/tsc/declarationEmit/reports-dts-generation-errors.js |
Updates declaration-error baseline. |
tsc/testdata/baselines/reference/tsc/declarationEmit/reports-dts-generation-errors-with-incremental.js |
Updates incremental declaration-error baseline. |
tsc/testdata/baselines/reference/tsbuild/declarationEmit/reports-dts-generation-errors.js |
Updates build declaration-error baseline. |
tsc/testdata/baselines/reference/tsbuild/declarationEmit/reports-dts-generation-errors-with-incremental.js |
Updates incremental build baseline. |
tsc/testdata/baselines/reference/fourslash/quickInfo/quickinfoVerbosityInstantiationTruncation80.baseline |
Adds hover truncation coverage. |
tsc/testdata/baselines/reference/fourslash/quickInfo/quickinfoVerbosityInstantiationTruncation40.baseline |
Adds hover truncation coverage. |
tsc/testdata/baselines/reference/fourslash/quickInfo/quickinfoVerbosityInstantiationTruncation20.baseline |
Adds hover truncation coverage. |
tsc/testdata/baselines/reference/fourslash/quickInfo/quickinfoVerbosityConstMergedWithNamespace.baseline |
Covers merged callable expansion. |
tsc/testdata/baselines/reference/conformance/templateStringWithEmbeddedFunctionExpressionES6.types |
Updates recursive function type display. |
tsc/testdata/baselines/reference/conformance/templateStringWithEmbeddedFunctionExpression.types |
Updates recursive function type display. |
tsc/testdata/baselines/reference/conformance/protectedClassPropertyAccessibleWithinNestedClass(target=es2015).types |
Uses indexed protected-member references. |
tsc/testdata/baselines/reference/conformance/protectedClassPropertyAccessibleWithinClass(target=es2015).types |
Uses indexed protected-member references. |
tsc/testdata/baselines/reference/conformance/privateClassPropertyAccessibleWithinNestedClass(target=es2015).types |
Uses indexed private-member references. |
tsc/testdata/baselines/reference/conformance/privateClassPropertyAccessibleWithinClass.types |
Uses indexed private-member references. |
tsc/testdata/baselines/reference/conformance/newTarget.es6.types |
Updates recursive member types. |
tsc/testdata/baselines/reference/conformance/newTarget.es5(target=es2015).types |
Updates recursive member types. |
tsc/testdata/baselines/reference/conformance/functionImplementations.types |
Updates named-function recursion display. |
tsc/testdata/baselines/reference/compiler/thisInPropertyBoundDeclarations.types |
Updates property-bound recursive types. |
tsc/testdata/baselines/reference/compiler/returnInfiniteIntersection.types |
Names recursive intersection references. |
tsc/testdata/baselines/reference/compiler/recursiveTypeInference2.types |
Updates recursive inference output. |
tsc/testdata/baselines/reference/compiler/recursiveTypeInference.types |
Updates recursive inference output. |
tsc/testdata/baselines/reference/compiler/recursiveLetConst.types |
Names recursive object methods. |
tsc/testdata/baselines/reference/compiler/recursiveFunctionTypes.errors.txt |
Updates indexed-member diagnostic text. |
tsc/testdata/baselines/reference/compiler/recursiveFunctionDeclarationSerialization.errors.txt |
Adds recursive serialization diagnostics. |
tsc/testdata/baselines/reference/compiler/recursiveConditionalTypes.types |
Updates recursive conditional output. |
tsc/testdata/baselines/reference/compiler/recursiveConditionalCrash3.types |
Updates generated type-parameter names. |
tsc/testdata/baselines/reference/compiler/noImplicitThisBigThis.types |
Updates cyclic object display. |
tsc/testdata/baselines/reference/compiler/noCircularitySelfReferentialGetter4.types |
Names self-referential getters. |
tsc/testdata/baselines/reference/compiler/noCircularitySelfReferentialGetter3.types |
Names self-referential getters. |
tsc/testdata/baselines/reference/compiler/noCircularitySelfReferentialGetter2.types |
Updates recursive getter output. |
tsc/testdata/baselines/reference/compiler/noCircularitySelfReferentialGetter1.types |
Updates recursive getter output. |
tsc/testdata/baselines/reference/compiler/jsFunctionWithPrototypeNoErrorTruncationNoCrash.types |
Bounds recursive prototype display. |
tsc/testdata/baselines/reference/compiler/iteratorZip(exactoptionalpropertytypes=true).js |
Updates generated type-parameter naming. |
tsc/testdata/baselines/reference/compiler/iteratorZip(exactoptionalpropertytypes=false).js |
Updates generated type-parameter naming. |
tsc/testdata/baselines/reference/compiler/isolatedDeclarationErrorsReturnTypes.types |
Records recursive isolated-declaration types. |
tsc/testdata/baselines/reference/compiler/isolatedDeclarationErrorsReturnTypes.js |
Records added isolated-declaration inputs. |
tsc/testdata/baselines/reference/compiler/genericCallOnMemberReturningClosedOverObject.types |
Names closed-over recursive objects. |
tsc/testdata/baselines/reference/compiler/functionExpressionReturningItself.types |
Names self-returning expressions. |
tsc/testdata/baselines/reference/compiler/functionExpressionReturningItself.js |
Adds successful declaration emit. |
tsc/testdata/baselines/reference/compiler/functionExpressionReturningItself.errors.txt |
Removes obsolete serialization error. |
tsc/testdata/baselines/reference/compiler/discriminateWithOptionalProperty2(exactoptionalpropertytypes=true).types |
Names recursive async iterator. |
tsc/testdata/baselines/reference/compiler/discriminateWithOptionalProperty2(exactoptionalpropertytypes=false).types |
Names recursive async iterator. |
tsc/testdata/baselines/reference/compiler/declFileTypeofFunction.js |
Adds recursive declaration output. |
tsc/testdata/baselines/reference/compiler/declFileTypeofFunction.errors.txt |
Removes obsolete recursive errors. |
tsc/testdata/baselines/reference/compiler/declarationEmitUnserializableTypes.types |
Updates recursive declaration types. |
tsc/testdata/baselines/reference/compiler/declarationEmitUnserializableTypes.errors.txt |
Removes now-serializable object error. |
tsc/testdata/baselines/reference/compiler/declarationEmitClassMemberWithComputedPropertyName.js |
Emits indexed class-member references. |
tsc/testdata/baselines/reference/compiler/commentsClassMembers(target=es2015).js |
Emits indexed static-member references. |
tsc/testdata/baselines/reference/compiler/classExpressionInClassStaticDeclarations.js |
Adds recursive class-expression declaration. |
tsc/testdata/baselines/reference/compiler/classExpressionInClassStaticDeclarations.errors.txt |
Removes obsolete class serialization error. |
tsc/testdata/baselines/reference/compiler/blockScopedVariablesUseBeforeDef(target=es2015).types |
Names mutually recursive functions. |
tsc/testdata/baselines/reference/checker/typeToStringMergedNamespace.baseline |
Adds merged namespace formatting coverage. |
tsc/internal/fourslash/tests/recursiveFunctionQuickInfo_test.go |
Tests recursive Quick Info output. |
tsc/internal/fourslash/tests/quickinfoVerbosityTruncation1_test.go |
Tests truncation budgets. |
tsc/internal/fourslash/tests/quickinfoVerbosityRecursiveType_test.go |
Expands recursive hover coverage. |
tsc/internal/fourslash/tests/quickinfoVerbosityConstMergedWithNamespace_test.go |
Tests merged callable verbosity. |
tsc/internal/execute/tsctests/tsc_test.go |
Adds incremental producer/consumer coverage. |
tsc/internal/checker/utilities.go |
Finds declarations owning wrapped values. |
tsc/internal/checker/symbolaccessibility.go |
Resolves wrapped object-literal owners. |
tsc/internal/checker/pseudotypenodebuilder.go |
Preserves recursive back-references in pseudo types. |
tsc/internal/checker/nodecopy.go |
Tracks signature and deferred scopes during reuse. |
tsc/internal/checker/nodebuilderscopes.go |
Implements recursive naming and scope tracking. |
tsc/internal/checker/nodebuilderimpl.go |
Integrates definitions, cycle handling, and caching. |
tsc/internal/checker/checker_test.go |
Adds formatting and bounded-recursion tests. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP