You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Panic during declaration emit with stripInternal on parenthesized or wrapped internal type #65623
This is the behavior in every version I tried, and I reviewed the FAQ for entries about stripInternal
Tested on TypeScript main (Version 7.1.0-dev)
⏯ Playground Link
No response
💻 Code
interfaceFoo{}// Case 1: Type alias with parenthesized internal typeexporttypeT=(/** @internal */Foo);// Case 2: Variable type annotation with parenthesized internal typeexportconstx: (/** @internal */Foo)={}asany;// Case 3: Type operator and array wrapping parenthesized internal typeexporttypeT2=readonly(/** @internal */Foo)[];
🙁 Actual behavior
Running tsc -d --stripInternal crashes the compiler with a runtime panic (nil pointer dereference):
Cause:
When --stripInternal elides an @internal type wrapped in a parenthesized type, VisitEachChild calls UpdateParenthesizedTypeNode(input, nil), constructing a node with an inner nil pointer. The printer attempts to inspect node.Type.Kind for operator precedence and dereferences nil.
🙂 Expected behavior
The compiler should emit declarations without crashing:
T should fall back to export type T = any; (matching the behavior of bare export type T = /** @internal */ Foo;).
Activity