| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…ft#64438) When a file uses JSX but is not an external module (no imports/exports), the error message 'This JSX tag requires the module path X to exist...' is confusing because the file cannot import modules at all. The fix checks if the file is an external module before attempting to resolve the JSX runtime import. If not, it returns nil early, which allows the existing 'JSX element implicitly has type any' error (7026) to surface as the primary diagnostic. This matches the expected behavior described in the issue where the real issue is 'scripts can't import modules'.
There was a problem hiding this comment.
The early return can hide missing runtime imports and disable runtime-provided JSX types, and lacks regression coverage.
Review effort: Balanced
Findings: 1
Improves JSX diagnostics for non-module files by skipping implicit runtime resolution.
Changes:
| File | Description |
|---|---|
| tsc/internal/checker/jsx.go | Adds the non-module early return. |
Sorry, something went wrong.
| // If the file is not an external module (no imports/exports), it cannot import the JSX runtime. | ||
| // Return nil to avoid the confusing "module path ... could not be found" error (Issue #64438). | ||
| if file.ExternalModuleIndicator == nil { |
| Back | FazBrowse Home | New Git URL |
Summary
Fixes #64438
The Problem
When a file uses JSX but is not an external module (no imports/exports), TypeScript shows the confusing error:
This is misleading because the file cannot import modules at all - it's a script, not a module. The real issue is that JSX requires the automatic runtime which imports from , but non-module files can't import anything.
The Fix
Added a check in to return early if the file is not an external module (). This allows the existing, more appropriate error (TS7026: "JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists") to surface as the primary diagnostic.
Expected Behavior After Fix
For a file like:
Before: Confusing "module path react/jsx-runtime could not be found" error
After: Clear "JSX element implicitly has type 'any'" error (TS7026) - which correctly indicates the file needs to be a module or have JSX types configured.