Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tsc/testdata/fixtures/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34064,6 +34064,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
if (!runtimeImportSpecifier) {
return undefined;
}

// Check if the file is a script (not a module) - scripts can't use automatic JSX runtime
if (file && !isExternalOrCommonJsModule(file)) {
error(location, Diagnostics.JSX_cannot_be_used_in_a_script_file_when_using_automatic_JSX_runtime_jsx_react_jsx_or_react_jsxdev_Add_export_to_make_this_a_module_or_use_a_module_file);
Comment on lines +34068 to +34070
if (links) {
links.jsxImplicitImportContainer = false;
}
return undefined;
}

const isClassic = getEmitModuleResolutionKind(compilerOptions) === ModuleResolutionKind.Classic;
const errorMessage = isClassic
? Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_nodenext_or_to_add_aliases_to_the_paths_option
Expand Down
4 changes: 4 additions & 0 deletions tsc/testdata/fixtures/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,10 @@
"category": "Error",
"code": 1280
},
"JSX cannot be used in a script file when using automatic JSX runtime (jsx: 'react-jsx' or 'react-jsxdev'). Add 'export {}' to make this a module, or use a module file.": {
"category": "Error",
"code": 1281
},
"Cannot access '{0}' from another file without qualification when '{1}' is enabled. Use '{2}' instead.": {
"category": "Error",
"code": 1281
Expand Down