Skip to content

Commit 202093a

Browse files
committed
When creating react namespace identifier, set its parent to jsx opening element in the parse tree
This helps in resolving the react identifier correctly and Fixes #11654
1 parent 8e6467c commit 202093a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/compiler/factory.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1625,7 +1625,9 @@ namespace ts {
16251625
// flag and setting a parent node.
16261626
const react = createIdentifier(reactNamespace || "React");
16271627
react.flags &= ~NodeFlags.Synthesized;
1628-
react.parent = parent;
1628+
// Set the parent that is in parse tree
1629+
// this makes sure that parent chain is intact for checker to traverse complete scope tree
1630+
react.parent = getParseTreeNode(parent);
16291631
return react;
16301632
}
16311633

tests/baselines/reference/jsxEmitWithAttributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class A {
7575
view() {
7676
return [
7777
Element_1.Element.createElement("meta", { content: "helloworld" }),
78-
Element.createElement("meta", { content: c.a.b })
78+
Element_1.Element.createElement("meta", { content: c.a.b })
7979
];
8080
}
8181
}

0 commit comments

Comments
 (0)