Fix panic in declaration emit for export default arrow/function expression with unnameable inferred return type - #63989
Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
Draft
Fix panic in declaration emit for export default arrow/function expression with unnameable inferred return type#63989Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
export default arrow/function expression with unnameable inferred return type#63989Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
Conversation
…ssion Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix panic during declaration emit for export default arrow functions
Fix panic in declaration emit for Aug 24, 2026
export default arrow/function expression with unnameable inferred return type
Wesley Wigham (weswigham)
left a comment
Member
There was a problem hiding this comment.
Copilot rather than duplicating the exact same logic in basically every branch of transforming the export, why not just move the existing getSymbolAccessibilityDiagnostic (and fallback node push) assignment below up to before unwrapped := so it covers the case in question?
…ssignment Co-authored-by: weswigham <2932786+weswigham@users.noreply.github.com>
Contributor
Author
Good call, done in 7c40297 - moved the diagnostic context assignment and |
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.
export default () => makeFoo()(or a function expression) whose inferred return type contains a symbol that cannot be named from the exporting module crashed the compiler withpanic("Diagnostic emitted without context")instead of emittingTS4082, as TS 6.x did.Root cause
transformExportAssignment'sast.IsFunctionLike(unwrapped)branch promotes arrow/function-expression default exports to a function declaration viatransformFunctionLikeToDeclaration→ensureType→serializeReturnTypeForSignature.getSymbolAccessibilityDiagnosticcontext or pushed an error fallback node before serializing.CannotBeNamedaccessibility result during return-type serialization, it fell through to the file-level default handler, which is justpanic(...).Fix
Default_export_of_the_module_has_or_is_using_private_name_0diagnostic context andPushErrorFallbackNode(assignment)/PopErrorFallbackNode()pair around the function-like promotion, matching the parity already present in the fallback branch below it.Tests
declarationEmitDefaultExportArrowFunctionPrivateName.tsanddeclarationEmitDefaultExportFunctionExpressionPrivateName.ts, covering bothexport default () => ...andexport default (function () {...})forms with a cross-module unique-symbol-keyed member causing an unnameable inferred return type. Both now emitTS4082instead of crashing.export defaultarrow/function expression with non-portable inferred return type #63761