mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05:00
Use synthetic identifier during emit instead
This commit is contained in:
@@ -7629,12 +7629,8 @@ namespace ts {
|
||||
// is no 'React' symbol in scope, we should issue an error.
|
||||
if (compilerOptions.jsx === JsxEmit.React) {
|
||||
let reactSym = resolveName(node.tagName, "React", SymbolFlags.Value, Diagnostics.Cannot_find_name_0, "React");
|
||||
if (reactSym && reactSym !== unknownSymbol) {
|
||||
if (reactSym) {
|
||||
getSymbolLinks(reactSym).referenced = true;
|
||||
let reactNode = <Identifier>createSynthesizedNode(SyntaxKind.Identifier, false);
|
||||
reactNode.text = 'React';
|
||||
getNodeLinks(reactNode).resolvedSymbol = reactSym;
|
||||
node.reactNode = reactNode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1177,14 +1177,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
|
||||
function emitJsxElement(openingNode: JsxOpeningLikeElement, children?: JsxChild[]) {
|
||||
let syntheticReactRef = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||
syntheticReactRef.text = 'React';
|
||||
syntheticReactRef.parent = openingNode;
|
||||
|
||||
// Call React.createElement(tag, ...
|
||||
emitLeadingComments(openingNode);
|
||||
if (openingNode.reactNode) {
|
||||
emitExpressionIdentifier(openingNode.reactNode);
|
||||
}
|
||||
else {
|
||||
write('React');
|
||||
}
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".createElement(");
|
||||
emitTagName(openingNode.tagName);
|
||||
write(", ");
|
||||
@@ -1199,12 +1198,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
// a call to React.__spread
|
||||
let attrs = openingNode.attributes;
|
||||
if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) {
|
||||
if (openingNode.reactNode) {
|
||||
emitExpressionIdentifier(openingNode.reactNode);
|
||||
}
|
||||
else {
|
||||
write('React');
|
||||
}
|
||||
emitExpressionIdentifier(syntheticReactRef);
|
||||
write(".__spread(");
|
||||
|
||||
let haveOpenedObjectLiteral = false;
|
||||
|
||||
Reference in New Issue
Block a user