Prevent auto-import crash with automatic JSX runtime - #64417
Daniel Rosenwasser (DanielRosenwasser) merged 7 commits into
Conversation
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
|
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. |
There was a problem hiding this comment.
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.
|
Can we hit this without a targeted unit test? I don't know why we'd need this function present... |
|
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; |
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>
|
Since it stopped with an error, I wonder if the test actually fails without the fix 🤔 |
Addressed in 5c3daaf (final cleanup a785796). The production path is |
| Widg/**/` | ||
| f, done := fourslash.NewFourslash(t, nil /*capabilities*/, content) | ||
| defer done() | ||
| f.MarkTestAsStradaServer() |
There was a problem hiding this comment.
What does this do?
There was a problem hiding this comment.
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.
Daniel Rosenwasser (DanielRosenwasser)
left a comment
There was a problem hiding this comment.
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.
Co-authored-by: DanielRosenwasser <972891+DanielRosenwasser@users.noreply.github.com>
Added the project-reference case in 1995e1d. It uses a composite TSX library whose package |
| // GetJSXRuntimeImportSpecifier implements checker.Program. | ||
| func (r *aliasResolver) GetJSXRuntimeImportSpecifier(path tspath.Path) (moduleReference string, specifier *ast.Node) { | ||
| panic("unimplemented") | ||
| return "", nil |
There was a problem hiding this comment.
If this is happening on a real TSX/JSX (even JS) file, won't it be bad that this is not here?
There was a problem hiding this comment.
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.
Auto-import export extraction crashed when checking JSX configured for the automatic runtime because its lightweight
aliasResolverleft the runtime-specifier hook unimplemented.Fix
aliasResolver, matching a compiler program without a recorded runtime import.Coverage
satisfieschecking path.