Skip to content

Commit 5208bde

Browse files
committed
Merge pull request microsoft#3675 from RyanCavanaugh/fix3674
Correctly flag JSX elements as being used for the purposes of module imports
2 parents fe46122 + 342ae96 commit 5208bde

9 files changed

+218
-294
lines changed

src/compiler/checker.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7088,7 +7088,7 @@ namespace ts {
70887088

70897089
let jsxElementClassType: Type = undefined;
70907090
function getJsxGlobalElementClassType(): Type {
7091-
if(!jsxElementClassType) {
7091+
if (!jsxElementClassType) {
70927092
jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass);
70937093
}
70947094
return jsxElementClassType;
@@ -7107,7 +7107,7 @@ namespace ts {
71077107
}
71087108

71097109
if (jsxElementType === undefined) {
7110-
if(compilerOptions.noImplicitAny) {
7110+
if (compilerOptions.noImplicitAny) {
71117111
error(errorNode, Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
71127112
}
71137113
}
@@ -7119,6 +7119,15 @@ namespace ts {
71197119

71207120
let targetAttributesType = getJsxElementAttributesType(node);
71217121

7122+
if (getNodeLinks(node).jsxFlags & JsxFlags.ClassElement) {
7123+
if (node.tagName.kind === SyntaxKind.Identifier) {
7124+
checkIdentifier(<Identifier>node.tagName);
7125+
}
7126+
else {
7127+
checkQualifiedName(<QualifiedName>node.tagName);
7128+
}
7129+
}
7130+
71227131
let nameTable: Map<boolean> = {};
71237132
// Process this array in right-to-left order so we know which
71247133
// attributes (mostly from spreads) are being overwritten and
@@ -7131,7 +7140,7 @@ namespace ts {
71317140
else {
71327141
Debug.assert(node.attributes[i].kind === SyntaxKind.JsxSpreadAttribute);
71337142
let spreadType = checkJsxSpreadAttribute(<JsxSpreadAttribute>(node.attributes[i]), targetAttributesType, nameTable);
7134-
if(isTypeAny(spreadType)) {
7143+
if (isTypeAny(spreadType)) {
71357144
sawSpreadedAny = true;
71367145
}
71377146
}
@@ -12336,7 +12345,7 @@ namespace ts {
1233612345
}
1233712346

1233812347
function checkTypePredicate(node: TypePredicateNode) {
12339-
if(!isInLegalTypePredicatePosition(node)) {
12348+
if (!isInLegalTypePredicatePosition(node)) {
1234012349
error(node, Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
1234112350
}
1234212351
}

tests/baselines/reference/jsxEsprimaFbTestSuite.symbols

Lines changed: 0 additions & 92 deletions
This file was deleted.

tests/baselines/reference/jsxEsprimaFbTestSuite.types

Lines changed: 0 additions & 160 deletions
This file was deleted.

tests/baselines/reference/tsxElementResolution16.symbols

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/baselines/reference/tsxElementResolution16.types

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)