Always generate a jsx implicit import specifier for tsx/jsx files#3803
Merged
weswigham merged 3 commits intoMay 12, 2026
Merged
Conversation
…en if they are not modules
jakebailey
approved these changes
May 11, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts program construction to always create the JSX implicit runtime import specifier for .tsx/.jsx files (even when the file is not an external module), aligning TS2875 error production with strada and fixing #3480.
Changes:
- Always create and resolve a synthetic JSX runtime import for
ScriptKindTSX/ScriptKindJSXfiles, independent of “is external module / isolated modules” gating. - Stop pulling JSX runtime types into builds that contain no
.tsx/.jsxinputs (removing an unnecessary synthetic reference in non-JSX files). - Update baselines to reflect restored TS2875 diagnostics and adjusted reference/find-all-refs behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/compiler/fileloader.go | Moves JSX runtime synthetic import creation out of the external-module/isolated-modules gate; limits it to TSX/JSX script kinds. |
| testdata/baselines/reference/tsc/composite/synthetic-jsx-import-of-ESM-module-from-CJS-module-no-crash-no-jsx-element.js | Updates buildinfo/baseline to no longer include jsx-runtime.d.ts when there are no TSX/JSX files. |
| testdata/baselines/reference/submoduleTriaged/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=legacy).errors.txt.diff | Removes triaged diff now that TS2875 matches expected output. |
| testdata/baselines/reference/submoduleTriaged/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=legacy).errors.txt.diff | Removes triaged diff now that TS2875 matches expected output. |
| testdata/baselines/reference/submodule/fourslash/findAllReferences/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc.diff | Updates diff baseline: non-JSX file no longer gets an implicit runtime reference included in FAR. |
| testdata/baselines/reference/submodule/fourslash/findAllReferences/jsxFindAllReferencesOnRuntimeImportWithPaths1.baseline.jsonc | Updates baseline to reflect removal of the implicit runtime reference from a non-JSX file. |
| testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=legacy).errors.txt | Adds expected TS2875 diagnostic and adjusts error count/markers accordingly. |
| testdata/baselines/reference/submodule/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=legacy).errors.txt | Adds expected TS2875 diagnostic and adjusts error count/markers accordingly. |
12b7ce3 to
589a2d4
Compare
jakebailey
approved these changes
May 12, 2026
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.
Even if they are not modules, so we have the same error creation behavior as strada.
Fixes #3480
The changed tests not associated with the linked issue (which were testing a crash and find all refs, respectively) seem to show us no longer having a synthetic jsx import in non-jsx/tsx files (in the first, the jsx runtime file isn't in the build anymore because there's no jsx/tsx files, in the second, the jsx runtime file no longer gets an implicit ref to the jsx runtime file because it's not a jsx/tsx file), which seems more correct to me.