Skip to content

Commit e772e51

Browse files
committed
Do not try to mark JSX classic runtime symbols as used when automatic runtime is used
1 parent 0870655 commit e772e51

3 files changed

+24
-90
lines changed

src/compiler/checker.ts

+23-20
Original file line numberDiff line numberDiff line change
@@ -25412,26 +25412,29 @@ namespace ts {
2541225412
}
2541325413

2541425414
checkJsxPreconditions(node);
25415-
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
25416-
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
25417-
const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
25418-
const jsxFactoryNamespace = getJsxNamespace(node);
25419-
const jsxFactoryLocation = isNodeOpeningLikeElement ? (<JsxOpeningLikeElement>node).tagName : node;
25420-
25421-
// allow null as jsxFragmentFactory
25422-
let jsxFactorySym: Symbol | undefined;
25423-
if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
25424-
jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, SymbolFlags.Value, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true);
25425-
}
25426-
25427-
if (jsxFactorySym) {
25428-
// Mark local symbol as referenced here because it might not have been marked
25429-
// if jsx emit was not jsxFactory as there wont be error being emitted
25430-
jsxFactorySym.isReferenced = SymbolFlags.All;
25431-
25432-
// If react/jsxFactory symbol is alias, mark it as refereced
25433-
if (jsxFactorySym.flags & SymbolFlags.Alias && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
25434-
markAliasSymbolAsReferenced(jsxFactorySym);
25415+
25416+
if (!getJsxNamespaceContainerForImplicitImport(node)) {
25417+
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
25418+
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
25419+
const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
25420+
const jsxFactoryNamespace = getJsxNamespace(node);
25421+
const jsxFactoryLocation = isNodeOpeningLikeElement ? (<JsxOpeningLikeElement>node).tagName : node;
25422+
25423+
// allow null as jsxFragmentFactory
25424+
let jsxFactorySym: Symbol | undefined;
25425+
if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
25426+
jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, SymbolFlags.Value, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true);
25427+
}
25428+
25429+
if (jsxFactorySym) {
25430+
// Mark local symbol as referenced here because it might not have been marked
25431+
// if jsx emit was not jsxFactory as there wont be error being emitted
25432+
jsxFactorySym.isReferenced = SymbolFlags.All;
25433+
25434+
// If react/jsxFactory symbol is alias, mark it as refereced
25435+
if (jsxFactorySym.flags & SymbolFlags.Alias && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
25436+
markAliasSymbolAsReferenced(jsxFactorySym);
25437+
}
2543525438
}
2543625439
}
2543725440

tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.errors.txt

-69
This file was deleted.

tests/baselines/reference/jsxNamespaceImplicitImportJSXNamespaceFromPragmaPickedOverGlobalOne.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export = React;
33
>React : any
44

55
export as namespace React;
6-
>React : any
6+
>React : error
77

88
declare namespace React { }
99

0 commit comments

Comments
 (0)