Skip to content

Always generate a jsx implicit import specifier for tsx/jsx files#3803

Merged
weswigham merged 3 commits into
microsoft:mainfrom
weswigham:jsx-always-have-implicit-import-available-if-jsxtsx
May 12, 2026
Merged

Always generate a jsx implicit import specifier for tsx/jsx files#3803
weswigham merged 3 commits into
microsoft:mainfrom
weswigham:jsx-always-have-implicit-import-available-if-jsxtsx

Conversation

@weswigham
Copy link
Copy Markdown
Member

@weswigham weswigham commented May 11, 2026

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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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/ScriptKindJSX files, independent of “is external module / isolated modules” gating.
  • Stop pulling JSX runtime types into builds that contain no .tsx/.jsx inputs (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.

@weswigham weswigham requested a review from jakebailey May 12, 2026 17:08
@weswigham weswigham force-pushed the jsx-always-have-implicit-import-available-if-jsxtsx branch from 12b7ce3 to 589a2d4 Compare May 12, 2026 17:24
@weswigham weswigham added this pull request to the merge queue May 12, 2026
Merged via the queue into microsoft:main with commit e3ea2a8 May 12, 2026
21 checks passed
@weswigham weswigham deleted the jsx-always-have-implicit-import-available-if-jsxtsx branch May 12, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing error about jsx-runtime package

3 participants