Repository navigation
Fix nil panic when stripInternal elides type alias RHS - #64770
Merged
Jake Bailey (jakebailey) merged 1 commit intoOct 13, 2026
Merged
Jake Bailey (jakebailey) merged 1 commit into
Jake Bailey (jakebailey) merged 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused fallback matches existing index-signature behavior and the regression baseline verifies export type T = any.
0 open findings
What changed in this PR
Fixes declaration emit panics when stripInternal removes a type alias RHS.
Changes:
- Falls back to
anywhen the transformed RHS is nil. - Adds a focused compiler regression test and baselines.
| File | Description |
|---|---|
tsc/internal/transformers/declarations/transform.go |
Adds the any fallback. |
tsc/testdata/tests/cases/compiler/declarationEmitStripInternalTypeAliasRHS.ts |
Reproduces the panic. |
tsc/testdata/baselines/reference/compiler/declarationEmitStripInternalTypeAliasRHS.js |
Verifies declaration output. |
tsc/testdata/baselines/reference/compiler/declarationEmitStripInternalTypeAliasRHS.symbols |
Records symbol baseline. |
tsc/testdata/baselines/reference/compiler/declarationEmitStripInternalTypeAliasRHS.types |
Records type baseline. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Jake Bailey (jakebailey)
approved these changes
Oct 13, 2026
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.
Fixes #64667
Analysis
With
--declaration --stripInternal,@internalon a type-alias RHS can be stripped byvisitDeclarationSubtree, leaving a nilTypeon the alias:Declaration emit then called
ast.GetTypeNodePrecedencewith nil fromemitTypeAliasDeclaration→emitTypeNode, causing:panic: runtime error: invalid memory address or nil pointer dereferenceIndex signatures already fall back to
anywhen the visited type is nil; type aliases did not.Fix
In
transformTypeAliasDeclaration, ifVisit(input.Type)returns nil, substituteany(same pattern astransformIndexSignatureDeclaration). AddeddeclarationEmitStripInternalTypeAliasRHS.tsand baselines.Alternate considered: nil-guard only in
emitTypeNode/GetTypeNodePrecedence. That would avoid the crash but could emit anincomplete alias; transforming to
anymatches existing stripInternal declaration behavior.AI Assistance
This PR was authored with AI assistance (Cursor); I have reviewed and understand the changes.