@@ -275,6 +275,7 @@ import {
275275 getEntityNameFromTypeNode,
276276 getErrorSpanForNode,
277277 getEscapedTextOfIdentifierOrLiteral,
278+ getEscapedTextOfJsxAttributeName,
278279 getESModuleInterop,
279280 getExpandoInitializer,
280281 getExportAssignmentExpression,
@@ -350,6 +351,7 @@ import {
350351 getSymbolNameForPrivateIdentifier,
351352 getTextOfIdentifierOrLiteral,
352353 getTextOfJSDocComment,
354+ getTextOfJsxAttributeName,
353355 getTextOfNode,
354356 getTextOfPropertyName,
355357 getThisContainer,
@@ -593,6 +595,7 @@ import {
593595 isJsxAttributeLike,
594596 isJsxAttributes,
595597 isJsxElement,
598+ isJsxNamespacedName,
596599 isJsxOpeningElement,
597600 isJsxOpeningFragment,
598601 isJsxOpeningLikeElement,
@@ -807,7 +810,6 @@ import {
807810 MappedTypeNode,
808811 MatchingKeys,
809812 maybeBind,
810- MemberName,
811813 MemberOverrideStatus,
812814 memoize,
813815 MetaProperty,
@@ -13517,7 +13519,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1351713519 function isTypeInvalidDueToUnionDiscriminant(contextualType: Type, obj: ObjectLiteralExpression | JsxAttributes): boolean {
1351813520 const list = obj.properties as NodeArray<ObjectLiteralElementLike | JsxAttributeLike>;
1351913521 return list.some(property => {
13520- const nameType = property.name && getLiteralTypeFromPropertyName(property.name);
13522+ const nameType = property.name && (isJsxNamespacedName(property.name) ? getStringLiteralType(getTextOfJsxAttributeName(property.name)) : getLiteralTypeFromPropertyName(property.name) );
1352113523 const name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
1352213524 const expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
1352313525 return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
@@ -19590,8 +19592,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
1959019592 function *generateJsxAttributes(node: JsxAttributes): ElaborationIterator {
1959119593 if (!length(node.properties)) return;
1959219594 for (const prop of node.properties) {
19593- if (isJsxSpreadAttribute(prop) || isHyphenatedJsxName(idText (prop.name))) continue;
19594- yield { errorNode: prop.name, innerExpression: prop.initializer, nameType: getStringLiteralType(idText (prop.name)) };
19595+ if (isJsxSpreadAttribute(prop) || isHyphenatedJsxName(getTextOfJsxAttributeName (prop.name))) continue;
19596+ yield { errorNode: prop.name, innerExpression: prop.initializer, nameType: getStringLiteralType(getTextOfJsxAttributeName (prop.name)) };
1959519597 }
1959619598 }
1959719599
@@ -29266,7 +29268,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
2926629268 if (!attributesType || isTypeAny(attributesType)) {
2926729269 return undefined;
2926829270 }
29269- return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText );
29271+ return getTypeOfPropertyOfContextualType(attributesType, getEscapedTextOfJsxAttributeName( attribute.name) );
2927029272 }
2927129273 else {
2927229274 return getContextualType(attribute.parent, contextFlags);
@@ -30400,12 +30402,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3040030402 attributeSymbol.links.target = member;
3040130403 attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
3040230404 allAttributesTable?.set(attributeSymbol.escapedName, attributeSymbol);
30403- if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
30405+ if (getEscapedTextOfJsxAttributeName( attributeDecl.name) === jsxChildrenPropertyName) {
3040430406 explicitlySpecifyChildrenAttribute = true;
3040530407 }
3040630408 if (contextualType) {
3040730409 const prop = getPropertyOfType(contextualType, member.escapedName);
30408- if (prop && prop.declarations && isDeprecatedSymbol(prop)) {
30410+ if (prop && prop.declarations && isDeprecatedSymbol(prop) && isIdentifier(attributeDecl.name) ) {
3040930411 addDeprecatedSuggestion(attributeDecl.name, prop.declarations, attributeDecl.name.escapedText as string);
3041030412 }
3041130413 }
@@ -47852,8 +47854,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4785247854 }
4785347855
4785447856 const { name, initializer } = attr;
47855- if (!seen.get(name.escapedText)) {
47856- seen.set(name.escapedText, true);
47857+ const escapedText = getEscapedTextOfJsxAttributeName(name);
47858+ if (!seen.get(escapedText)) {
47859+ seen.set(escapedText, true);
4785747860 }
4785847861 else {
4785947862 return grammarErrorOnNode(name, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
@@ -47866,25 +47869,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4786647869 }
4786747870
4786847871 function checkGrammarJsxName(node: JsxTagNameExpression) {
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- }
47872+ if (isPropertyAccessExpression(node) && isJsxNamespacedName(node.expression)) {
47873+ return grammarErrorOnNode(node.expression, Diagnostics.JSX_property_access_expressions_cannot_include_JSX_namespace_names);
4788247874 }
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- }
47875+ if (isJsxNamespacedName(node) && getJSXTransformEnabled(compilerOptions) && !isIntrinsicJsxName(node.namespace.escapedText)) {
47876+ return grammarErrorOnNode(node, Diagnostics.React_components_cannot_include_JSX_namespace_names);
4788847877 }
4788947878 }
4789047879
0 commit comments