@@ -275,7 +275,6 @@ import {
275275 getEntityNameFromTypeNode,
276276 getErrorSpanForNode,
277277 getEscapedTextOfIdentifierOrLiteral,
278- getEscapedTextOfJsxAttributeName,
279278 getESModuleInterop,
280279 getExpandoInitializer,
281280 getExportAssignmentExpression,
@@ -351,7 +350,6 @@ import {
351350 getSymbolNameForPrivateIdentifier,
352351 getTextOfIdentifierOrLiteral,
353352 getTextOfJSDocComment,
354- getTextOfJsxAttributeName,
355353 getTextOfNode,
356354 getTextOfPropertyName,
357355 getThisContainer,
@@ -595,7 +593,6 @@ import {
595593 isJsxAttributeLike,
596594 isJsxAttributes,
597595 isJsxElement,
598- isJsxNamespacedName,
599596 isJsxOpeningElement,
600597 isJsxOpeningFragment,
601598 isJsxOpeningLikeElement,
@@ -810,6 +807,7 @@ import {
810807 MappedTypeNode,
811808 MatchingKeys,
812809 maybeBind,
810+ MemberName,
813811 MemberOverrideStatus,
814812 memoize,
815813 MetaProperty,
@@ -13519,7 +13517,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1351913517 function isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean {
1352013518 const list = obj.properties as NodeArray<ObjectLiteralElementLike | JsxAttributeLike>;
1352113519 return list.some(property => {
13522- const nameType = property.name && (isJsxNamespacedName(property.name) ? getStringLiteralType(getTextOfJsxAttributeName(property.name)) : getLiteralTypeFromPropertyName(property.name) );
13520+ const nameType = property.name && getLiteralTypeFromPropertyName(property.name);
1352313521 const name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
1352413522 const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
1352513523 return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
@@ -19592,8 +19590,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1959219590 function *generateJsxAttributes(node: JsxAttributes): ElaborationIterator {
1959319591 if (!length(node.properties)) return;
1959419592 for (const prop of node.properties) {
19595- if (isJsxSpreadAttribute(prop) || isHyphenatedJsxName(getTextOfJsxAttributeName (prop.name))) continue;
19596- yield { errorNode: prop.name, innerExpression: prop.initializer, nameType: getStringLiteralType(getTextOfJsxAttributeName (prop.name)) };
19593+ if (isJsxSpreadAttribute(prop) || isHyphenatedJsxName(idText (prop.name))) continue;
19594+ yield { errorNode: prop.name, innerExpression: prop.initializer, nameType: getStringLiteralType(idText (prop.name)) };
1959719595 }
1959819596 }
1959919597
@@ -29268,7 +29266,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2926829266 if (!attributesType || isTypeAny(attributesType)) {
2926929267 return undefined;
2927029268 }
29271- return getTypeOfPropertyOfContextualType(attributesType, getEscapedTextOfJsxAttributeName( attribute.name) );
29269+ return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText );
2927229270 }
2927329271 else {
2927429272 return getContextualType(attribute.parent, contextFlags);
@@ -30402,12 +30400,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3040230400 attributeSymbol.links.target = member;
3040330401 attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
3040430402 allAttributesTable?.set(attributeSymbol.escapedName, attributeSymbol);
30405- if (getEscapedTextOfJsxAttributeName( attributeDecl.name) === jsxChildrenPropertyName) {
30403+ if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
3040630404 explicitlySpecifyChildrenAttribute = true;
3040730405 }
3040830406 if (contextualType) {
3040930407 const prop = getPropertyOfType(contextualType, member.escapedName);
30410- if (prop && prop.declarations && isDeprecatedSymbol(prop) && isIdentifier(attributeDecl.name) ) {
30408+ if (prop && prop.declarations && isDeprecatedSymbol(prop)) {
3041130409 addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText as string);
3041230410 }
3041330411 }
@@ -47854,9 +47852,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4785447852 }
4785547853
4785647854 const { name, initializer } = attr;
47857- const escapedText = getEscapedTextOfJsxAttributeName(name);
47858- if (!seen.get(escapedText)) {
47859- seen.set(escapedText, true);
47855+ if (!seen.get(name.escapedText)) {
47856+ seen.set(name.escapedText, true);
4786047857 }
4786147858 else {
4786247859 return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
@@ -47869,11 +47866,25 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4786947866 }
4787047867
4787147868 function checkGrammarJsxName(node: JsxTagNameExpression) {
47872- if (isPropertyAccessExpression(node) && isJsxNamespacedName(node.expression)) {
47873- return grammarErrorOnNode(node.expression, Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names);
47869+ if (isPropertyAccessExpression(node)) {
47870+ let propName: JsxTagNameExpression = node;
47871+ do {
47872+ const check = checkGrammarJsxNestedIdentifier(propName.name);
47873+ if (check) {
47874+ return check;
47875+ }
47876+ propName = propName.expression;
47877+ } while (isPropertyAccessExpression(propName));
47878+ const check = checkGrammarJsxNestedIdentifier(propName);
47879+ if (check) {
47880+ return check;
47881+ }
4787447882 }
47875- if (isJsxNamespacedName(node) && getJSXTransformEnabled(compilerOptions) && !isIntrinsicJsxName(node.namespace.escapedText)) {
47876- return grammarErrorOnNode(node, Diagnostics.React_components_cannot_include_JSX_namespace_names);
47883+
47884+ function checkGrammarJsxNestedIdentifier(name: MemberName | ThisExpression) {
47885+ if (isIdentifier(name) && idText(name).indexOf(":") !== -1) {
47886+ return grammarErrorOnNode(name, Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names);
47887+ }
4787747888 }
4787847889 }
4787947890
0 commit comments