mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
* Add actual baselines for a problem with global namespace being preferred over config & pragma implicit ones * Fixed an issue with global React namespace being preferred over config & pragma implicit ones * Do not try to mark JSX classic runtime symbols as used when automatic runtime is used Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
This commit is contained in:
co-authored by
Mateusz Burzyński
parent
d72de70fbc
commit
ca766df7e4
+25
-20
@@ -25174,11 +25174,13 @@ namespace ts {
|
||||
return links.jsxNamespace;
|
||||
}
|
||||
if (!links || links.jsxNamespace !== false) {
|
||||
const namespaceName = getJsxNamespace(location);
|
||||
let resolvedNamespace = resolveName(location, namespaceName, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false);
|
||||
let resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location);
|
||||
|
||||
if (!resolvedNamespace || resolvedNamespace === unknownSymbol) {
|
||||
resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location);
|
||||
const namespaceName = getJsxNamespace(location);
|
||||
resolvedNamespace = resolveName(location, namespaceName, SymbolFlags.Namespace, /*diagnosticMessage*/ undefined, namespaceName, /*isUse*/ false);
|
||||
}
|
||||
|
||||
if (resolvedNamespace) {
|
||||
const candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, SymbolFlags.Namespace));
|
||||
if (candidate && candidate !== unknownSymbol) {
|
||||
@@ -25401,26 +25403,29 @@ namespace ts {
|
||||
}
|
||||
|
||||
checkJsxPreconditions(node);
|
||||
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
|
||||
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
|
||||
const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
|
||||
const jsxFactoryNamespace = getJsxNamespace(node);
|
||||
const jsxFactoryLocation = isNodeOpeningLikeElement ? (<JsxOpeningLikeElement>node).tagName : node;
|
||||
|
||||
// allow null as jsxFragmentFactory
|
||||
let jsxFactorySym: Symbol | undefined;
|
||||
if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
|
||||
jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, SymbolFlags.Value, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true);
|
||||
}
|
||||
if (!getJsxNamespaceContainerForImplicitImport(node)) {
|
||||
// The reactNamespace/jsxFactory's root symbol should be marked as 'used' so we don't incorrectly elide its import.
|
||||
// And if there is no reactNamespace/jsxFactory's symbol in scope when targeting React emit, we should issue an error.
|
||||
const jsxFactoryRefErr = diagnostics && compilerOptions.jsx === JsxEmit.React ? Diagnostics.Cannot_find_name_0 : undefined;
|
||||
const jsxFactoryNamespace = getJsxNamespace(node);
|
||||
const jsxFactoryLocation = isNodeOpeningLikeElement ? (<JsxOpeningLikeElement>node).tagName : node;
|
||||
|
||||
if (jsxFactorySym) {
|
||||
// Mark local symbol as referenced here because it might not have been marked
|
||||
// if jsx emit was not jsxFactory as there wont be error being emitted
|
||||
jsxFactorySym.isReferenced = SymbolFlags.All;
|
||||
// allow null as jsxFragmentFactory
|
||||
let jsxFactorySym: Symbol | undefined;
|
||||
if (!(isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
|
||||
jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, SymbolFlags.Value, jsxFactoryRefErr, jsxFactoryNamespace, /*isUse*/ true);
|
||||
}
|
||||
|
||||
// If react/jsxFactory symbol is alias, mark it as refereced
|
||||
if (jsxFactorySym.flags & SymbolFlags.Alias && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
|
||||
markAliasSymbolAsReferenced(jsxFactorySym);
|
||||
if (jsxFactorySym) {
|
||||
// Mark local symbol as referenced here because it might not have been marked
|
||||
// if jsx emit was not jsxFactory as there wont be error being emitted
|
||||
jsxFactorySym.isReferenced = SymbolFlags.All;
|
||||
|
||||
// If react/jsxFactory symbol is alias, mark it as refereced
|
||||
if (jsxFactorySym.flags & SymbolFlags.Alias && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
|
||||
markAliasSymbolAsReferenced(jsxFactorySym);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user