Preserve reverse mapped types in declaration emit - #64558
Jake Bailey (jakebailey) merged 2 commits into
Conversation
Reverse-mapped property and index signature types are lost in emitted declarations even when source consumers retain them. Cover finite nested shapes, recursive inputs, and consumers of the generated declarations.
Display placeholders discard real property and index signature types when reused for declaration emit. Preserve those types in declarations while leaving editor display unchanged. Reverse-mapped types without symbols can still recurse. Track their type identities and bound expansion by mapped declaration when changing type arguments prevent repetition. Report cycles and truncation rather than silently replacing these types with any.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The implementation preserves declaration accuracy, bounds recursive expansion, and includes comprehensive regression coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Preserves inferred reverse-mapped types during declaration emit while retaining concise Quick Info display behavior.
Changes:
- Expands reverse-mapped properties and index signatures for declarations.
- Adds recursion and growth safeguards.
- Adds compiler, incremental-build, and Quick Info coverage.
| File | Description |
|---|---|
tsc/internal/checker/nodebuilderimpl.go |
Implements declaration serialization and recursion limits. |
tsc/testdata/tests/cases/compiler/reverseMappedDeclarationSerialization.ts |
Covers finite and recursive mappings. |
tsc/internal/fourslash/tests/reverseMappedDeclarationQuickInfo_test.go |
Tests Quick Info behavior. |
tsc/internal/execute/tsctests/tsc_test.go |
Tests incremental declaration consumption. |
tsc/testdata/baselines/reference/compiler/reverseMappedDeclarationSerialization.js |
Records emit results. |
tsc/testdata/baselines/reference/compiler/reverseMappedDeclarationSerialization.errors.txt |
Records recursion diagnostics. |
tsc/testdata/baselines/reference/compiler/reverseMappedDeclarationSerialization.symbols |
Records symbol baselines. |
tsc/testdata/baselines/reference/compiler/reverseMappedDeclarationSerialization.types |
Records inferred-type baselines. |
tsc/testdata/baselines/reference/fourslash/quickInfo/reverseMappedDeclarationQuickInfo.baseline |
Records hover output. |
tsc/testdata/baselines/reference/tsbuild/incremental/reverse-mapped-declaration-consumption.js |
Records incremental-build behavior. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
TypeScript Bot (@typescript-bot) test it |
|
Hey Jake Bailey (@jakebailey), the results of running the DT tests are ready. Everything looks the same! |
|
Jake Bailey (@jakebailey) Here are the results of running the user tests with tsc comparing Everything looks good! |
|
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 top 400 repos with tsc comparing Everything looks good! |
Gets rid of more silently-produced elided
anys. See the second commit for the actual change.