mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-29 16:29:19 -05:00
Adjust scanning of keywordy jsx namespace names, add grammar error for jsx dotted names containing namespace names (#43104)
This commit is contained in:
@@ -40728,6 +40728,7 @@ namespace ts {
|
||||
}
|
||||
|
||||
function checkGrammarJsxElement(node: JsxOpeningLikeElement) {
|
||||
checkGrammarJsxName(node.tagName);
|
||||
checkGrammarTypeArguments(node, node.typeArguments);
|
||||
const seen = new Map<__String, boolean>();
|
||||
|
||||
@@ -40750,6 +40751,29 @@ namespace ts {
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarJsxName(node: JsxTagNameExpression) {
|
||||
if (isPropertyAccessExpression(node)) {
|
||||
let propName: JsxTagNameExpression = node;
|
||||
do {
|
||||
const check = checkGrammarJsxNestedIdentifier(propName.name);
|
||||
if (check) {
|
||||
return check;
|
||||
}
|
||||
propName = propName.expression;
|
||||
} while (isPropertyAccessExpression(propName));
|
||||
const check = checkGrammarJsxNestedIdentifier(propName);
|
||||
if (check) {
|
||||
return check;
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarJsxNestedIdentifier(name: MemberName | ThisExpression) {
|
||||
if (isIdentifier(name) && idText(name).indexOf(":") !== -1) {
|
||||
return grammarErrorOnNode(name, Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkGrammarJsxExpression(node: JsxExpression) {
|
||||
if (node.expression && isCommaSequence(node.expression)) {
|
||||
return grammarErrorOnNode(node.expression, Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array);
|
||||
|
||||
@@ -2674,6 +2674,10 @@
|
||||
"category": "Error",
|
||||
"code": 2632
|
||||
},
|
||||
"JSX property access expressions cannot include JSX namespace names": {
|
||||
"category": "Error",
|
||||
"code": 2633
|
||||
},
|
||||
|
||||
"Cannot augment module '{0}' with value exports because it resolves to a non-module entity.": {
|
||||
"category": "Error",
|
||||
|
||||
@@ -2335,6 +2335,7 @@ namespace ts {
|
||||
tokenValue += ":";
|
||||
pos++;
|
||||
namespaceSeparator = true;
|
||||
token = SyntaxKind.Identifier; // swap from keyword kind to identifier kind
|
||||
continue;
|
||||
}
|
||||
const oldPos = pos;
|
||||
|
||||
Reference in New Issue
Block a user