Repository navigation
Improve diagnostic for automatic JSX in script files - #64908
Gabriel Fonseca (gabrielvfonseca) wants to merge 1 commit into
Conversation
|
Gabriel Fonseca (@gabrielvfonseca) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
1 similar comment
|
Gabriel Fonseca (@gabrielvfonseca) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
🟡 Changes recommended
The new guard also rejects valid preserve and react-native scripts that only need JSX type resolution.
1 open issue
1 file not reviewed
tsc/internal/diagnostics/diagnostics_generated.go: Generated file
What changed in this PR
Improves the automatic JSX diagnostic for script files, addressing #64438 with guidance to add export {}.
Changes:
- Adds TS2884 and a script-file check.
- Adds regression coverage and updates legacy module-detection baselines.
| File | Description |
|---|---|
tsc/testdata/tests/cases/compiler/jsxScriptFile.tsx |
Adds script-file regression case. |
tsc/testdata/baselines/reference/compiler/jsxScriptFile.types |
Records inferred types. |
tsc/testdata/baselines/reference/compiler/jsxScriptFile.symbols |
Records symbols. |
tsc/testdata/baselines/reference/compiler/jsxScriptFile.js |
Records emitted JavaScript. |
tsc/testdata/baselines/reference/compiler/jsxScriptFile.errors.txt |
Records expected diagnostics. |
tsc/testdata/baselines/reference/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsxdev,module=commonjs,moduledetection=legacy).errors.txt |
Updates development-runtime diagnostic. |
tsc/testdata/baselines/reference/compiler/commentsOnJSXExpressionsArePreserved(jsx=react-jsx,module=commonjs,moduledetection=legacy).errors.txt |
Updates production-runtime diagnostic. |
tsc/internal/diagnostics/diagnostics_generated.go |
Registers generated TS2884 message. |
tsc/internal/diagnostics/diagnosticMessages.json |
Defines TS2884. |
tsc/internal/diagnostics/diagnosticMessages.generated.json |
Adds generated diagnostic entry. |
tsc/internal/checker/jsx.go |
Reports script-specific JSX error. |
Review effort: Balanced
| if moduleReference == "" { | ||
| return nil | ||
| } | ||
| if !ast.IsExternalOrCommonJSModule(file) { |

Fixes #64438. Automatic JSX runtime in a script file now reports TS2884 with guidance to add export {}. Added regression coverage and updated legacy module-detection baselines. Validation: npx hereby test (168194 tests, 2148 skipped), npx hereby lint, npx hereby check:format, and npx hereby build.