Skip to content

Prevent auto-import crash with automatic JSX runtime - #64417

Merged
Daniel Rosenwasser (DanielRosenwasser) merged 7 commits into
mainfrom
copilot/fix-fatal-language-server-crash
Sep 24, 2026
Merged

Daniel Rosenwasser (DanielRosenwasser) merged 7 commits into
mainfrom
copilot/fix-fatal-language-server-crash

Conversation

Copilot AI commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Auto-import export extraction crashed when checking JSX configured for the automatic runtime because its lightweight aliasResolver left the runtime-specifier hook unimplemented.

  • Fix

    • Return no JSX runtime metadata from aliasResolver, matching a compiler program without a recorded runtime import.
  • Coverage

    • Add a TSX regression case exercising automatic-runtime JSX inside the reported object-literal and satisfies checking path.
/** @jsxRuntime automatic */
export const x = { value: <div /> } satisfies {};

Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix fatal language server crash during auto-imports Prevent auto-import crash with automatic JSX runtime Sep 24, 2026
@DanielRosenwasser

Copy link
Copy Markdown
Member

Copilot is the real module specifier necessary for accurate auto-imports?

Copilot AI commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Copilot is the real module specifier necessary for accurate auto-imports?

No—the auto-import registry indexes bound export symbols and resolves their explicit alias chains; it does not use JSX-derived types. The runtime specifier is only needed for JSX namespace/type checking, so omitting it here can affect diagnostics from this lightweight checker but not the exported names, flags, targets, or generated auto-imports.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused fix matches compiler behavior for absent metadata and directly tests the reported crash path.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents auto-import export extraction from crashing when checking TSX with the automatic JSX runtime.

Changes:

  • Return absent JSX runtime metadata from the lightweight alias resolver.
  • Add regression coverage for the reported TSX checking path.
File Description
tsc/​internal/​ls/​autoimport/​aliasresolver.go Safely handles missing JSX runtime metadata.
tsc/​internal/​ls/​autoimport/​aliasresolver_crash_test.go Adds automatic-runtime crash regression coverage.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@jakebailey

Copy link
Copy Markdown
Member

Can we hit this without a targeted unit test? I don't know why we'd need this function present...

@andrewbranch

Copy link
Copy Markdown
Member

Copilot determine the possible paths between the top of the call stack from the issue report and the checker functions actually used by auto-import processing. Try to create a real fourslash test that exercises the failure; GetSemanticDiagnostics() is never called on the auto-import checkers, but we do resolve types in certain cases.

Copilot AI and others added 2 commits September 24, 2026 14:58
Agent-Logs-Url: https://github.com/microsoft/TypeScript/sessions/329b044e-bd60-452c-87bd-720058c69ed0

Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
@andrewbranch

Copy link
Copy Markdown
Member

Since it stopped with an error, I wonder if the test actually fails without the fix 🤔

Copilot AI commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Copilot determine the possible paths between the top of the call stack from the issue report and the checker functions actually used by auto-import processing. Try to create a real foursl...

Addressed in 5c3daaf (final cleanup a785796). The production path is extractPackage → extractFromFile → tryResolveSymbol → GetAliasedSymbol → export-assignment property-access resolution → inferred container initializer → satisfies/JSX checking. The new fourslash completion test exercises that path through a dependency’s default export; it panics with the old implementation and passes with the fix. npx hereby validate passes.

Widg/**/`
f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content)
defer done()
f.MarkTestAsStradaServer()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this do?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean f.MarkTestAsStradaServer(), one of the things it does is avoid the usual fourslash behavior of opening every file in the test before running the test (because Strada Server tests didn't have this behavior). We should probably rename it now that we're done with the port.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot is a package with a types field that directs to a tsx file the best test case? Maybe something (minimal) with project references would be more realistic if you can prove that it actually caused errors previously. Maybe add that as an additional test case to the same file.

Comment thread tsc/internal/fourslash/tests/autoImportAutomaticJsxRuntimeCrash_test.go Outdated
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>

Copilot AI commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Copilot is a package with a types field that directs to a tsx file the best test case? Maybe something (minimal) with project references would be more realistic if you can prove that it actuall...

Added the project-reference case in 1995e1d. It uses a composite TSX library whose package types output is redirected to source through the app’s project reference and node_modules symlink. I verified this test panics with the old implementation and passes with the fix; npx hereby validate passes.

// GetJSXRuntimeImportSpecifier implements checker.Program.
func (r *aliasResolver) GetJSXRuntimeImportSpecifier(path tspath.Path) (moduleReference string, specifier *ast.Node) {
panic("unimplemented")
return "", nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is happening on a real TSX/JSX (even JS) file, won't it be bad that this is not here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda, but not that bad. We only pull on types to get flags that contribute to the little icon in the dropdown list, and it's already an intentional compromise between accuracy and performance. I don't feel bad about stopping the spiraling type resolution here.

Merged via the queue into main with commit 6e8d127 Sep 24, 2026
29 checks passed
@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser) deleted the copilot/fix-fatal-language-server-crash branch September 24, 2026 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fatal language server crash during auto-imports

6 participants